[wp-hackers] Constant for Theme File Path

Mike Schinkel mikeschinkel at newclarity.net
Fri Jan 7 19:32:29 UTC 2011


<?php

include 'wp-load.php';
header('Content-type: text/plain');
echo get_theme_root_uri();
echo "\n-------------\n";
echo get_theme_root_uri('twentyten');
echo "\n-------------\n";
print_r(get_theme_roots());

?>

On Jan 7, 2011, at 2:17 PM, Chip Bennett wrote:

> I need to check for the existence of the default Theme (i.e. TwentyTen),
> which is easy enough: use file_exists() to find twentyten/style.css.
> 
> WordPress has a defined constant, WP_PLUGIN_DIR, for retrieving the file
> path (not URL) of the directory in which Plugins are installed. Does a
> similar constant (or other means) exist for retrieving the file path (not
> URL) of the directory in which Themes are installed?
> 
> Currently, I'm hacking WP_PLUGIN_DIR, like such:
> 
> if ( file_exists( rtrim( WP_PLUGIN_DIR, 'plugins' ) .
> 'themes/twentyten/style.css' ) ) {
> 
> // do stuff
> 
> }
> 
> 
> This works, but intuition tells me that there has to be a more direct way.
> I've searched through the constants, bloginfo(), etc. and cannot find
> anything resembling WP_THEMES_DIR or WP_TEMPLATE_DIR (or anything that
> likewise returns a file path for the Themes directory).
> 
> Does any such means exist? If not, is there a better work-around than the
> one I'm using?
> 
> Chip
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers



More information about the wp-hackers mailing list