Options Framework & Theme Customizer

While working on the next version of Techozoic Fluid I’ve been incorporating the new theme customizer features of WordPress 3.4. Currently Techozoic uses the Options Framework from Devin Price to handle all the settings pages. The framework is awesome and saves developers tons of time implementing the settings api. As always Devin already had a great tutorial on using the customizer with the framework. He went over all the basics of getting it working together. However with Techozoic there are many options and including them in the customizer by hand would have been a huge job. So I came up with this simple loop to accomplish the job of getting all the options into the customizer.

After following all the directions from Devin about changing the options array to used named keys then this loop will come into play. I’ll go over the basics of what the loop does. First of all you’ll need to replace all instances of theme_slug with your own theme’s slug. The $customizer_array is where it starts this array setups your option sections and which options will be displayed in each section. The sample array is broken down into two sub arrays the key of these being the section id used for the customizer sections, this will produce two sections. Under each of these is some info about the section itself name is the title of the section, localized in this example, and priority is where in the customizer list the section will show up. Next is the settings key which is an array itself of option ids that you setup early following Devin’s tutorial.

Now on to the loop itself, basically this will loop over each section and then loop over each settings array in that section. Then it will use the appropriate way of adding the option to the customizer, since the different option types require slightly different way of adding them to the customizer. Currently only checkbox, radio, text, select, color, and image option types are supported. While extending the customizer is entirely possible it’s beyond this guide.

About Jeremy Clark

Small town IT worker with interests in all things technological and technical. Biggest interests are in web development especially the WordPress publishing platform and the community supporting it. Currently developing and maintain the free WordPress theme Techozoic. I'm also always available for hire.
This entry was posted in tech, wordpress and tagged , , . Bookmark the permalink.

5 Responses to "Options Framework & Theme Customizer"

Leave a reply

Comments will be sent to the moderation queue.