devinsays/options-framework-theme

options.php being required in functions.

Closed this issue · 1 comments

Hi,
As per this commit fdf2e5f the options.php file has been required in functions.php
Any particular reason why this was done as this code was not there before and it seems to work fine without requiring it in functions.php
The options.php has been required in class-options-framework.php

static function &_optionsframework_options() {
        static $options = null;
        if ( !$options ) {
            // Load options from options.php file (if it exists)
            $location = apply_filters( 'options_framework_location', array( 'options.php' ) );
            if ( $optionsfile = locate_template( $location ) ) {
                $maybe_options = require_once $optionsfile;
                if ( is_array( $maybe_options ) ) {
                    $options = $maybe_options;
                } else if ( function_exists( 'optionsframework_options' ) ) {
                    $options = optionsframework_options();
                }
            }

            // Allow setting/manipulating options via filters
            $options = apply_filters( 'of_options', $options );
        }

        return $options;
    } 

Am I missing something, was there any particular reason for doing this.

Sure, download this Framework as is and set some options. They should output correctly when you view the site.

Now in options.php set optionsframework_option_name to something that doesn't match the slug. Something like this for example:

function optionsframework_option_name() {

    // Change this to use your theme slug
    return 'no-match';
}

Also delete the call to options.php in functions.php.

Now save some new options and look at the output the front end. The theme is outputting the same values that were originally set for the previous slug. That because options.php isn't loaded earlier enough to be available for of_get_option as bundled.

If you have written your own version of "of_get_option" using the actual option name, you should be fine and can delete the call to options.php in functions.php.