I'm creating a plugin version of the Roots Theme function additions - to make it a bit more portable, but have run into a snag.

Part of what Roots does is add htaccess rules based on the current theme information -- like so:

// only use clean urls if the theme isn't a child or an MU (Network) install
if (!is_multisite() && !is_child_theme() && get_option('permalink_structure')) {
  add_action('generate_rewrite_rules', 'roots_add_rewrites');
  add_action('generate_rewrite_rules', 'roots_add_h5bp_htaccess');
  if (!is_admin()) {
    $tags = array(

    add_filters($tags, 'roots_clean_urls');

So, it's basically checking to make sure that the current setup is not a multisite environment, not a child theme and that the permalink structure has been updated from the defaults. It seems like the is_child_theme() is not being called correctly, mainly because I get the following error on the frontend:

Notice: Use of undefined constant TEMPLATEPATH - assumed 'TEMPLATEPATH' in /Users/studio/Sites/base_wp/wp-includes/theme.php on line 17

Notice: Use of undefined constant STYLESHEETPATH - assumed 'STYLESHEETPATH' in /Users/studio/Sites/base_wp/wp-includes/theme.php on line 17

So, from what I can gather, it's the wp-includes/theme.php file that is not included in plugin files (which makes senses).

I've been banging my head against the wall with this one, but am trying to figure out the cleanest way possible to add in those constants to the plugin itself -> should I just include that theme.php file? Thanks.

UPDATE: Looks like I can use functions that are in wp-includes/theme.php (like get_themes()) so I know that's not the issue. hm...

1 Answer 1


TEMPLATEPATH and STYLESHEETPATH will be deprecated in the near future. It is not safe to rely on these constants. Use get_template_directory() and get_stylesheet_directory() instead.
And wait until the init hook (or after_setup_theme before you use them to be sure all needed files are loaded.

Example for a plugin:

add_action( 'after_setup_theme', 'wpse_50359_set_plugin_basics' );

function wpse_50359_set_plugin_basics()
    if ( is_child_theme() )
        // do something awesome …
  • Hi @toscho - thanks for the response -- I think what I'm struggling to understand here is that I'm not actually using those constants anywhere -- it looks like is_child_theme references them --> is there a better/different way to check if the active theme is a child theme via a plugin? Thanks.
    – Zach
    Commented Apr 26, 2012 at 19:05
  • The function is okay, you just can not call it too early. I'll edit my answer.
    – fuxia
    Commented Apr 26, 2012 at 19:17
  • Thanks! That leads me to another question about plugin functions in general - but I'll open up another question for that if I can't find it after some research. Thanks!
    – Zach
    Commented Apr 26, 2012 at 19:32
  • near future might be relative .. core.trac.wordpress.org/ticket/18298 Opened 8 years ago Last modified 20 months ago
    – arno
    Commented Aug 21, 2019 at 19:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.