WordPress Theme Framework

2012 年 11 月 16 日7,2610

WordPress Theme Framework

PHP Ease WordPress Theme Framework Screenshot

This WordPress 机制 framework is a custom implementation of our Page class. Tailor made to simplify the process of creating a WordPress 机制, while giving you total flexibility and control afterwards. This class will completely separate your page's content from it's layout, freeing you from establishing an ugly foundation of inflexible divs. This framework is the cure for the common divitis.

The PHP Ease WordPress Theme Framework is somewhat stylish in it's own right, but if you don't make any changes to suit your fancy then you're not seeing the big picture. Making changes with this framework is so easy, you'll be a professional WordPress Theme Designer in no time. I have prepared a sample Child Theme that you can use for your own personal playground.

object WPage ( [ string $title ] )

This is the constructor for the class, and it creates a WordPress page object.

$title

You can set the title here if you already know what it's going to be, or your can always set it later. The default page title is your blog's name and description with a pipe '|' in the middle.

Example

$wpage = new WPage;

doctype ( [ string $type= 'html' [, string $standard= 'strict' ]] )

This sets the page's doctype, and makes the appropriate declaration for it in the head section of your html. If this method is not called then the default is HTML5, and your doctype will be declared as '<!DOCTYPE html>'. Fully valid (X)HTML, and we even throw in the required profile link (properly declared) in the header for you.

$type

Either 'html', or 'xhtml'. The default is 'html'

$standard

Either 'strict', or 'transitional'. The default is 'strict'.

Example

$wpage->doctype ('xhtml');

string title ( [ string $title ] )

Sets or changes the page's title.

$title

What you want the page title to be. Leave blank if you just want the return value.

Returns

The current page title.

Example

$wpage->title ('My WordPress Blog');

description ( string $description )

Sets the content for the meta description tag.

$description

a string

Example

$wpage->description ('A description of my blog, and the content you will find there.');

keywords ( string $keywords )

Sets the content for the meta keywords tag.

$keywords

a string

Example

$wpage->keywords ('easy, wordpress, 机制, framework');

robots ( bool $allow )

Tells the search engines if you would like them to crawl and index your page.

$allow

Set to false if you don't want robots (crawlers) to index or follow this page. Default is true.

Example

$wpage->robots (false);

link ( string or array $link [, bool $prepend= false ] )

Use this method to include any javascript or css files, favicon image, or explicitly formatted tags in the head section of your page. Any javascript file that ships with WordPress will be included here if you request it. Your 机制's style.css will automatically be included. Also, the profile, pingback, and feed links are included free of charge (or effort).

$link

You can link to one file or many (in an array), and you can call this method as many times as you want. If there are any duplicates they will be taken out. To include anything else such as a google maps api you can include it here, you just need to spell everything out.

'/' - this file is in the currently activated 机制's directory.
'../' - this file is in the parent 机制's directory.
'(?)' - this file will be included as is. If it's a javascript file that ships with WordPress, then just link to it as 'file.js'.

$prepend

Set to 'true' if you want the $link(s) to come first before everything you've already set. Default is 'false'.

Example

$wpage->link (array('/script.js', '/someother.css')); // these are in your activated 机制's directory 



$wpage->link (array('jquery.js', '../css/reset.css', '/images/favicon.ico'), true); // your reset.css file (from the parent directory) will now come before your someother.css file so that the two don't clash 



$wpage->link ('<script type="text/javascript" src="http://http://www.zjjv.com///maps?file=api&v=2&key=' . $key . '"></script>');

css ( string $link [, string $media [, string $ie ]] )

This extends the functionality of the link method, to include special case css file(s). You could just spell it all out for the link method, but I'm lazy and I like compact beautiful code.

$link

The css file, same as you would request in it in the link method.

$media

This is the media attribute. The default is 'all'.

$ie

If you put something (appropriate) here, then only Internet Explorer will process your css file.

Example

$wpage->css('../css/bp.print.css', 'print');  



$wpage->css('../css/bp.ie.css', '', 'lt IE 7');

jquery ( string $code [, bool $oneliner= true ] )

This method allows you to aggregate all of your jQuery calls and put them all under one $(document).ready(function(){}) in the head section of your page.

$code

Your jQuery code

$oneliner

If you don't want this code to be a oneliner in your head section then set this to false. It comes in handy for debugging.

Example

$wpage->jquery('$("p.neat").addClass("ohmy").show("slow");');

body ( string $insert )

Sometimes you need to put something in the body tag, so here you go. WordPress has it's own special body tags, and they will also be included here through no effort on your part.

$insert

a string

Example

$wpage->body ('onload="googleMaps()" onunload="GUnload()"');

vars ( string $var [, string $function [, bool $prepend= false ]] )

This method takes everything that WordPress has echo'd up until you call this method, and puts it into a variable that you can use later.

$var

This is the name of your var. It will be encased in div tags with the id of $var. If you call this method again with the same $var name, the new html will just be added to the old.

$function

If the content of your $var comes from a function call, then name the function here so that it can be called and added to your $var. If the function receives parameters, then make this an array with the function name first. If the function does not exist, then it will be added to your $var as a regular string.

$prepend

Set this to true if you want the code to be prepended to your var. The default is false.

Example

$wpage->vars('header', 'get_header');  



$wpage->vars('content', array('get_template_part', 'loop'));  



$wpage->vars('sidebar', 'get_sidebar');  



$wpage->vars('footer', 'get_footer'); 



$wpage->vars('sidebar', 'get_search_form', true); // oh yeah, let's put the search form at the top of our sidebar.

string get ( string $var )

This method "gets" the var that you set earlier in the vars method.

$var

The name of the var you set earlier.

Returns

A string of code to add to your $html.

Example

// Blueprint CSS Class Example Usage  



$bp = new Blueprint(24);  



$html .= $bp->page();  



$html .= $bp->row($wpage->get('header'));  



$html .= $bp->swap(19, 5, $wpage->get('content'), $wpage->get('sidebar'));  



$html .= $bp->row($wpage->get('footer'));  



$html .= $bp->close();  



unset ($bp);

string display ( string $html )

Returns the entire page, so this is the last method of all that you will call.

$html

The entire content of your page between the body tags. All of the hooks and tags that WordPress requires and recommends are already put in place so that you can focus on your content, and not their protocol.

Returns

Everything from beginning to end.

Example

echo $wpage->display ($html); 



ob_end_flush();

0 0