Options Framework Theme

The Options Framework Theme has all the code included to build a out a full featured options panel. It’s basically a bundled version of the Options Framework Plugin for those folks who want to build the options directly into the theme (rather than relying on a plugin).

Options Framework screenshot

Available Options

  • text
  • textarea
  • checkbox
  • select
  • radio
  • upload (an image uploader)
  • images (use images instead of radio buttons)
  • background (a set of options to define a background)
  • multicheck
  • color (a jquery color picker)
  • typography (a set of options to define typography)

There’s also “heading” to define the menu tabs, and “info” if you just want to add some additional information to the panel.

Instructions

This theme has examples of all the options you can use (defined in options.php), and how to access them from the database (in index.php).

I’d suggest just digging in and getting familiar with the code.

I also have a video demonstration over on the plugin page, which also might be helpful.

When to Use Theme Version vs. Plugin Version

The code is 99% the same between the plugin and theme version. If you can do what you need with the plugin version, I think that’s the best route. If you find that you need to make significant modifications that aren’t possible with the plugin, go ahead and use the theme version.

Importing/Exporting Options

This is something I’m not supporting at this point, however someone has forked the code and built their own importer/exporter if you’re interested: https://github.com/vauvarin/options-framework-theme

Change the Menu Location

It’s highly recommended that you leave theme options under the “Appearance” menu where users expect them.

But, if you do decide to change the menu location it will break the media uploader. This is because the media uploader scripts are enqueued on $of_page= ‘appearance_page_options-framework’ in options-medialibrary-uploader.php. If you change the name or location of the menu, you’ll need to update the hook to be accurate, e.g. $of_page= ‘toplevel_page_options-framework’ and those scripts will load properly again.

Sanitization Filters

If you’re interested in how the options data is verified, or if you’re wondering why your script and embed tags are stripped out in the Options Framework, read this post.

Can I Use This Code in Commercial Themes

Yes! This code is 100% GPL. Please read the included license for more details.

Donations and Support

If you find this code useful, if it saves you time, or if it makes you money- please consider making a donation.

Download the Options Framework Theme

283 comments on “Options Framework Theme

    • In the HTML of the uploader, I noticed the name was wonky. It was showing as “slideshow_image1″ instead of “optionsframework[slideshow_image1]“.

      In optionsframework_medialibrary_uploader, I replaced the $option_name = $optionsframework_settings['id']; line with the same check you do in optionsframework_fields():

      if (isset($optionsframework_settings['id'])) {
      $option_name = $optionsframework_settings['id'];
      }
      else {
      $option_name = ‘optionsframework’;
      };

      It is a hack, but it works. I don’t know why this didn’t effect me before.

  1. Having problems with media uploader, just getting a white screen in the thickbox.

    Moved the options to a top level menu, made the changes as above in the medialibrary-uploader and options-framwork files. Reset browser, no plugins active.

    The only other change I made was to rename “Theme Options”. Could this be the problem? Any help on where to debug would be much appreciated.

      • I finally found the problem. I have a custom posttype and was using the add_action (‘admin_head’, “my_icons”) function to add a 32×32 icon. Every time I add that in, the media uploader breaks everywhere.

        Extremely strange, and I’ve opened it up for discussion on wordpress.org.

        So solved, definitely not the framework :-)

        If anyone else runs into this, make sure you aren’t adding 32×32 icons using that add_action method.

  2. Out of curiosity, is there a way to get the attachment ID from a file uploaded, so I can use the thumbnail sizes? (or just pass a thumb size?)

  3. Hi,

    Thanks for this plugin/theme! I was actually surprised there’s not something like this built-in into WordPress :)

    I was curious though, why didn’t you merge the importer/exporter code? It’s pretty useful, and seems to be mostly well-coded?

    Cheers,
    Julien

    • I’m trying to keep the codebase as slim and maintainable as possible. If it is not something that I think 80% of users/developers will use- I’m a bit wary of adding it in. See the WordPress philosophy under “Clean, Lean and Mean”: http://wordpress.org/about/philosophy/.

      A couple people have asked about an export function, but it hasn’t been highly requested. What is your use case, if I might ask?

      • Hi Devin,

        I’m building a theme that’s very versatile and has a fairly high number of options (though I’m trying to abstract some of them from the end-user as much as I can).

        I’m also deploying a dozen of installs as demo and staging sites for the theme (think demo1.example.com, demo2.example.com, etc.) and want to automate that as much as I can. I’m looking into the new WP CLI too, but exporting/importing theme settings seem more straightforward from the theme itself.

        I think it makes sense for the end-user as well: you can import settings from a demo site and then just change what you need to change, etc.

        More generally than this precise feature, I think it would be cool to have more extensibility capabilities built in the Framework (so that people can distribute packaged “plugins” to your framework, so to speak). I will be suggesting a few things like this on Github in the next couple of days, I hope you’ll like them! (for instance, I would like to be able to configure — not extend — some options in `options.custom.js`).

        Thanks for your terrific work on this framework,

        Julien

  4. Hi,
    is possible to add a on/off button? With this button i should be able to show or hide individual options in options panel.

  5. WP (3.3) debugger throws “Notice: wp_enqueue_script was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or init hooks…blah, blah” error. Any idea how to get rid of it? …or is there any more convenient method to enqueue required scripts?
    Thanks a ton for all of your efforts Devin!!!

  6. Hi Devin,
    Is it possible to have a 2nd instance of the options framework to capture different theme options. I don’t want this to be additional tabs, but a separate “page” with different tabs.

  7. Hi Devin,

    Is it possible to pass any additional variables to the textarea option? In particular, I need to default the rows and columns larger. Is this possible?

    • If you’re using the theme version, you can edit it directly. You can also pass a parameter in the option for columns: “options” => array(‘cols’=>’100′), but it looks like the option for columns needs to be added too.

      • Thanks Devin, I see it. In admin-interface “rows” is hardcoded at the moment, but I think I know how to update this. Will you be adding this to a future version?

  8. I think the fully featured media library is not a good choice for uploads. Something much simpler, that just allows the user to upload an image would be a better choice, in my opinion. I’m trying to implement something like that.

    If anyone has some suggestions, let me know!

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>