What is it exactly ?
WordPress Theme Toolkit is just a set of 2 PHP files you will drop into your theme directory (see Page 4 for download links)
- themetoolkit.php : the class definition. You'll never need to do anything with it. Put it in the directory, forget about it.
- functions.php : this small file contains the few things you will edit.
So, how easily ?
Ready for a 3 minutes tour ? Let's create our admin menu. Say we are working on a theme named, how original, "My Neat Theme", which would sit in wp-content/themes/mytheme.
- Step 1
Put the required files functions.php and themetoolkit.php in your theme directory.
- Step 2
File functions.php looks like this :
- 'option1' => 'Text for Option One',
- 'option2' => 'Text for Option Two',
- 'option3' => 'Text for Option Two',
First line is where the class definition is included. Nothing to edit here.
Then, a function call with three parameters : themetoolkit(), which is passed a theme name, an array of options, and PHP predefined constant __FILE__. Leave this last parameter untouched, edit the first two to suit your needs.
- Step 3
(This step is not required with WordPress 2.0, but is for WP 1.5 compatibility. Once the whole world will have switched to 2.0, you can just skip it !)
Add this line to your template header.php :
- <?php include_once(dirname(__FILE__) . '/functions.php'); ?>
Now load your blog with your theme enabled.
And that's about it.
And what did that do ?
These three steps produced a few things :
- Now, in the Themes admin area, we have another menu added. Just like a plugin adds a menu, except that this time your theme did the job.
- Let's click on this menu : here is your theme control panel ! The three lines you edited created a menu, nicely integrated within WordPress admin area, ready to accept some input from theme users. (click image to enlarge)
Now what ?
From now on, everything you will input in the admin menu you've just created will be stored in a array of variables, named $mytheme->option. For example, if you enter in our 3 input fields the values "value1", "43", "some other text", the following array will be available :
- $mytheme->option['option1'] = "value1"
- $mytheme->option['option2'] = "43"
- $mytheme->option['option3'] = "some other text"
What you "just" have to do now is create your own functions, add features to your theme that will use these values the user can input. Look below in section "Examples and Ideas" to see what you could use this for.Page: #1 #2 #3 #4 #5
Want to share or tweet this page? Please use this short URL: http://ozh.in/ko