[Plugin: OptionTree] Path Issues in 'Theme Mode' when Using a Child Theme Fix
-
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!
The topic ‘[Plugin: OptionTree] Path Issues in 'Theme Mode' when Using a Child Theme Fix’ is closed to new replies.