Options Framework Theme v1.9.0

Although I do my best to ensure compatibility between versions of the Options Framework theme (GitHub), upgrading to this latest version will require some minor updates on the part of theme developers.

I am also planning to write some tutorial soon about how to migrate from the Options Framework to the native WordPress Customizer if you’d prefer to take that route.


When the Options Framework was originally released as a plugin is was designed to set an option “optionsframework” which would track all the individual themes it was used with, so that, on deletion of the plugin, it could remove any options that it had set.

I later removed this “feature” because losing any sort of data is not a great experience, and I felt users might not necessarily connect that removing the plugin data was also removing the data associated with their theme when it was deleted.

However, a system had been set up whereby the Options Framework knew which options to pull for a theme based on the setting in the “optionsframework” option.

Sane Defaults

Justin Tadlock recently brought it to my attention that saving options in this way was causing issues for developers who have themes in the WordPress.org theme repository. Guidelines for the repository are very specific, including one about “sane defaults”- which basically means that no options should be set in the database until a user actually alters one of the defaults and saves them.

So I’ve altered the theme version of the Options Framework slightly to make sure it complies with this requirement. It’s actually a nice improvement, and something I wish had been implemented from the beginning.

Here’s the GitHub issue if you’d like to read the specifics and see the actual code changes.

How to Update a Theme

Please note, the following only applies to the theme version of the Options Framework. For those using the plugin, it is still business as usual.

In options.php, you should have a function called “optionsframework_option_name”. This is what defines where options are saved in the database. Instead of setting this as an option as we had previously, we’ll just return it.

If you had something like this:

function optionsframework_option_name() {
     // This gets the theme name from the stylesheet (lowercase and without spaces)
     $themename = get_option( 'stylesheet' );
     $themename = preg_replace("/\W/", "_", strtolower($themename) );

     $optionsframework_settings = get_option('optionsframework');
     $optionsframework_settings['id'] = $themename;
     update_option('optionsframework', $optionsframework_settings);

You can change it to:

function optionsframework_option_name() {
       $themename = get_option( 'stylesheet' );
       $themename = preg_replace( "/\W/", "_", strtolower( $themename ) );
       return $themename;

Even better, if you were already setting the option name manually (rather than dynamically based on the theme name), you could do something like this:

function optionsframework_option_name() {
       // Change this to use your theme slug
       return 'options-framework-theme';

Including the Files

We’ll also include options.php earlier that we did previously from functions.php:

define( 'OPTIONS_FRAMEWORK_DIRECTORY', get_template_directory_uri() . '/inc/' );
require_once dirname( __FILE__ ) . '/inc/options-framework.php';

// Loads options.php from child or parent theme
$optionsfile = locate_template( 'options.php' );
load_template( $optionsfile );

Pulling Options

of_get_option should still work with this new method. But, you could also write your own function for pulling options- especially if you are not setting the option name dynamically:

function of_get_option( $name, $default = false ) {

    // Get theme options
    $options = get_option( 'example-option-name' );

    // Return specific option
    if ( isset( $options[$name] ) ) {
        return $options[$name];
    return $default;

Wrap Up

Hopefully this update isn’t too difficult to make, but please test it thoroughly to make sure your users and customers don’t notice a thing. Feel free to open tickets on GitHub if you have specific questions.

Folks who have purchased the Options Framework Kit will get an e-mail next week with the new version.

About Devin

I am a developer based in Austin, Texas. I run a little theme shop called DevPress and help manage a WooCommerce shop with Universal Yums. Find me on twitter @devinsays.

7 Responses

  1. Srikanth

    Hello Devin,

    I noticed a problem, If I had any other theme that used OF active and then switch to a theme using OF with this fix, options panel is still using the old theme’s name as ID.

  2. 58 $name = (new Options_Framework)->get_option_name();

    “Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /home/fpaulino/public_html/besteiras/wp-content/themes/ascent/options-framework/includes/class-options-framework-admin.php on line 58”

    what is occurring??

Leave a Reply