On: 2005/09/03 Viewed: 234272 times

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.

CODE:
  1. 'cc_number' => 'Credit Card Number ## Display it on your site.'

Bare Input field :
When the option is self explanatory, trim it to the minimum.

CODE:
  1. 'age' => 'Your age'

Text Area :
Adding {textarea|number of rows|number of columns} create a textarea input field.

CODE:
  1. '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.

CODE:
  1. '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.

CODE:
  1. '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.

CODE:
  1. '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)
Theme Toolkit : admin menu example

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 :

CODE:
  1. '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)
Theme Toolkit : admin menu example

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 :

CODE:
  1. function mytheme_creditcard () {
  2.     global $mytheme;
  3.     print $mytheme->option['cc_number'] ;
  4. }

Related posts

Page: #1 #2 #3 #4 #5

Metastuff

This page "Wordpress Theme Toolkit" was posted on 03/09/2005 at 2:36 pm
Watch this discussion : Comments RSS 2.0. You can trackback this post from your own site

145 Blablas

    Pages: « 1 2 3 4 5 6 7 [8] Show All

  1. 141
    Motti Israel »
    thought, on 29/Jun/08 at 11:08 am # :

    Just wanted to say thank you for that wonderful Kit.

  2. 142
    Braincast » Storelicious» Pr... United States »
    pingback on 01/Jul/08 at 11:07 am # :

    [...] Theme ToolKit [...]

  3. 143
    RodeWorks » WordPress Theme Toolki... United States »
    pingback on 01/Jul/08 at 1:28 pm # :

    [...] Wordpress Theme Toolkit « planetOzh [...]

  4. 144
    Nuevo Theme para mi blog | Omar Corrales... United States »
    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. [...]

  5. 145
    The P! Company - iamnotagoodartist United States »
    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 [...]

Pages: « 1 2 3 4 5 6 7 [8] Show All

Leave a Reply

Comment Guidelines or Die

  • HTML: You can use these tags: <a href=""> <em> <i> <b> <strong> <blockquote>
  • Posting code: Post raw code (no <> &lt; etc) within appropriate tags : [php][/php], [css][/css], [html][/html], [js][/js], [sql][/sql], [xml][/xml], or generic [code][code]
  • Gravatars: Curious about the little images next to each commenter's name ? Go to Gravatar.
  • Spam: Various spam plugins on patrol. I'll put pins in a Voodoo doll if you spam me.
  • I will mark as Spam test comments, all comments with SEO names (ie "My Cool Online Shop" instead of "Joe") or containing forum-like signatures.

Close
E-mail It