• Resolved IntricatePixels

    (@intricatepixels)


    Hello and thanks for this great plugin.

    I’m using the Genesis framework with a custom child theme. Today I decided to set up OptionTree in theme mode. Your instruction are clear and made the set up process easy to follow.

    However, I ran into an issue (that I fixed), that I’d like to report (not sure if this is already reported and you’re well aware of it, if that’s the case, sorry for the double post).

    Because I’m using a child theme I was getting errors about files not being found.

    Warning: require_once(C:\Inetpub\newwww-site-dev/wp-content/themes/genesis/option-tree/includes/ot-functions-admin.php) [function.require-once]: failed to open stream: No such file or directory in C:\Inetpub\newwww-site-dev\wp-content\themes\My.Child.Theme\option-tree\ot-loader.php on line 183

    Then I realized that the ‘OT_DIR’ and ‘OT_URL’ were always being set to the parent theme paths, ignoring Child themes.

    ot-loader.php, around line 128:

    if ( false == OT_THEME_MODE ) {
            define( 'OT_DIR', plugin_dir_path( __FILE__ ) );
            define( 'OT_URL', plugin_dir_url( __FILE__ ) );
    	  } else {
            define( 'OT_DIR', trailingslashit( get_template_directory() ) . trailingslashit( basename( dirname( __FILE__ ) ) ) );
            define( 'OT_URL', trailingslashit( get_template_directory_uri() ) . trailingslashit( basename( dirname( __FILE__ ) ) ) );
          }

    To set the child directory paths if they exist, I modified the code to:

    if ( false == OT_THEME_MODE ) {
            define( 'OT_DIR', plugin_dir_path( __FILE__ ) );
            define( 'OT_URL', plugin_dir_url( __FILE__ ) );
    	  } elseif ( is_child_theme() ) {
    		define( 'OT_DIR', trailingslashit( get_stylesheet_directory() ) . trailingslashit( basename( dirname( __FILE__ ) ) ) );
            define( 'OT_URL', trailingslashit( get_stylesheet_directory_uri() ) . trailingslashit( basename( dirname( __FILE__ ) ) ) );
    	  } else {
            define( 'OT_DIR', trailingslashit( get_template_directory() ) . trailingslashit( basename( dirname( __FILE__ ) ) ) );
            define( 'OT_URL', trailingslashit( get_template_directory_uri() ) . trailingslashit( basename( dirname( __FILE__ ) ) ) );
          }

    The code checks if the theme in use is a child theme (is_child_theme) and sets the dir and url using get_stylesheet_directory() and get_stylesheet_directory_uri().

    Hope this helps out anyone else running into this issue. It would be nice to see this fix included in the next release.

    Again, many thanks for the awesome plugin!

    http://wordpress.org/extend/plugins/option-tree/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Derek Herman

    (@valendesigns)

    Thank you for the suggestion, it’s a good one. However, at a glance it appears your code maybe would only work if OptionTree was in a child theme and not in a parent theme because it doesn’t do any checking for the existence of those files just checks if it’s a child theme. A better solution would be to allow themes the option to filter the paths, which I’ll look into for the next version. Thanks @intricatepixels.

    Plugin Author Derek Herman

    (@valendesigns)

    I created a new issue on github and added it to the 2.0.15 milestone. You can keep track of it here.

    https://github.com/valendesigns/option-tree/issues/78

    Plugin Author Derek Herman

    (@valendesigns)

    There is a new filter to use the plugin in child theme mode as of version 2.0.15

    Thread Starter IntricatePixels

    (@intricatepixels)

    Thanks for implementing this Derek, child theme filter works like a charm!

    / Required: set 'ot_child_theme_mode' filter to true.
    add_filter( 'ot_child_theme_mode', '__return_true' );
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Plugin: OptionTree] Path Issues in 'Theme Mode' when Using a Child Theme Fix’ is closed to new replies.