Simple syntax, detailed results
The syntax of options you can add into the option array, in functions.php, is very simple, yet it allows you to create detailed and complex admin forms : input fields, checkboxes, radio buttons, multiline text areas, mostly everything you will need. Let's make another menu with the following entries in the array of options :
Input field :
Regular input field, with the text "optional explanations" below it.
-
'cc_number' => 'Credit Card Number ## Display it on your site.'
Bare Input field :
When the option is self explanatory, trim it to the minimum.
-
'age' => 'Your age'
Text Area :
Adding {textarea|number of rows|number of columns} create a textarea input field.
-
'politics' => 'Political Views {textarea|6|50} ## What are your views ?'
Radio Buttons :
Use {radio|value1|text1|value2|text2} with any number of options to add radio buttons.
-
'menu' => 'Sidebar Menu on the {radio|left|Left Hand|right|Right Hand}'
Check Boxes :
Checkbox syntax is the following : {checkbox|name of variable|value of variable when checked|text} with any number of options.
-
'blah' => 'You are ... {checkbox|is_happy|yes|Happy ?|is_human|human|Human ?} ## Check if applicable'
Separator :
You can add a separator line if you feel your options list gets too long.
-
'some_random_and_unique_name' => 'This is a separator {separator}'
The result of such an array of options would be the following admin menu (click to enlarge)

Handy to Programmers
What you probably like, as a PHP programmer who wants to write your own functions, is to know any time what variables you have, and their values. Wordpress Theme Toolkit come in with a handy feature called the Programmer's Corner.
Just add this fake entry in your array of options :
-
'debug' => 'debug'
And whenever you input something in the admin menu, you will be shown the list of option variables and their values : (click to enlarge)

Nice to Wordpress
Wordpress Theme Toolkit likes to be discreet :
Everything you will input in your fresh admin menu will be stored in a single entry, in Wordpress' option table (wp_options, most of the time). It's not like those dirty plugins who add ten entries in the database !
Wordpress Theme Toolkit likes to be clean :
Admin menu created will include a "Delete" option, so that when a user decides to remove your theme and clean the option table, it's just one click away.
Wordpress Theme Toolkit likes to be smart :
Even if you run 10 themes that come with their own copy of Wordpress Theme Toolkit, its modular architecture and code relying on PHP classes make that only one is actually included in memory. And the 10 admin menus are functional, of course.
Wordpress Theme Toolkit likes to be light :
Reading options stored in your database won't cost you a single additional MySQL query. No extra database lookup. Everything at light speed just as if there was no Theme Toolkit behind the hoods.
Wordpress Theme Toolkit likes to be compatible :
Wordpress 2.0 and the Wordpress Theme Toolkit are friends. With Wordpress versions 1.5xx, you need to add an include line at the beginning of header.php, while this is not necessary with 2.0 (although leaving the line is harmless)
Adding custom functions
Now, in functions.php, add your own functions that will make use of input values. Be sure to add a global declaration for your options array, and here you go. Syntax of your functions will be something like :
-
function mytheme_creditcard () {
-
global $mytheme;
-
print $mytheme->option['cc_number'] ;
-
}
Related posts
Page: #1 #2 #3 #4 #5Metastuff
145 Blablas
Pages: « 1 2 3 4 5 6 7 [8] Show All
Pages: « 1 2 3 4 5 6 7 [8] Show All
thought, on 29/Jun/08 at 11:08 am # :
Just wanted to say thank you for that wonderful Kit.
pingback on 01/Jul/08 at 11:07 am # :
[...] Theme ToolKit [...]
pingback on 01/Jul/08 at 1:28 pm # :
[...] Wordpress Theme Toolkit « planetOzh [...]
pingback on 03/Jul/08 at 4:54 am # :
[...] pensado liberar el theme WP-Resurrection pero como queria añadirle algunas opciones intente usar Wordpress Theme Toolkit pero tuve algunos errores con el y la verdad no soy tan experto en PHP como para arreglarlo. [...]
pingback on 04/Jul/08 at 5:41 am # :
[...] their latest sketch shoved down the throat of their visitors. With some help from planetOzh’s Theme Toolkit, I put together a YouTube embed box that can be easily changed from the admin [...]