Replaces all uses of TEMPLATEPATH and STYLESHEETPATH in core with get_template_directory() and get_stylesheet_directory().

Add `@deprecated` annotations to `TEMPLATEPATH` and `STYLESHEETPATH` definitions.

Props obenland, aaroncampbell. 
Fixes #18298.

Built from https://develop.svn.wordpress.org/trunk@28563


git-svn-id: http://core.svn.wordpress.org/trunk@28389 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2014-05-23 20:12:15 +00:00
parent 44c4b365a0
commit b75c79500b
5 changed files with 20 additions and 14 deletions

View File

@ -1049,7 +1049,7 @@ function wp_comment_form_unfiltered_html_nonce() {
* and the post ID respectively. * and the post ID respectively.
* *
* The $file path is passed through a filter hook called, 'comments_template' * The $file path is passed through a filter hook called, 'comments_template'
* which includes the TEMPLATEPATH and $file combined. Tries the $filtered path * which includes the template path and $file combined. Tries the $filtered path
* first and if it fails it will require the default comment template from the * first and if it fails it will require the default comment template from the
* default theme. If either does not exist, then the WordPress process will be * default theme. If either does not exist, then the WordPress process will be
* halted. It is advised for that reason, that the default theme is not deleted. * halted. It is advised for that reason, that the default theme is not deleted.
@ -1134,7 +1134,7 @@ function comments_template( $file = '/comments.php', $separate_comments = false
if ( !defined('COMMENTS_TEMPLATE') ) if ( !defined('COMMENTS_TEMPLATE') )
define('COMMENTS_TEMPLATE', true); define('COMMENTS_TEMPLATE', true);
$theme_template = STYLESHEETPATH . $file; $theme_template = get_stylesheet_directory() . $file;
/** /**
* Filter the path to the theme template file used for the comments template. * Filter the path to the theme template file used for the comments template.
* *
@ -1145,8 +1145,8 @@ function comments_template( $file = '/comments.php', $separate_comments = false
$include = apply_filters( 'comments_template', $theme_template ); $include = apply_filters( 'comments_template', $theme_template );
if ( file_exists( $include ) ) if ( file_exists( $include ) )
require( $include ); require( $include );
elseif ( file_exists( TEMPLATEPATH . $file ) ) elseif ( file_exists( get_template_directory() . $file ) )
require( TEMPLATEPATH . $file ); require( get_template_directory() . $file );
else // Backward compat code will be removed in a future release else // Backward compat code will be removed in a future release
require( ABSPATH . WPINC . '/theme-compat/comments.php'); require( ABSPATH . WPINC . '/theme-compat/comments.php');
} }

View File

@ -296,12 +296,16 @@ function wp_templating_constants() {
/** /**
* Filesystem path to the current active template directory * Filesystem path to the current active template directory
* @since 1.5.0 * @since 1.5.0
* @deprecated 4.0
* @deprecated Use get_template_directory()
*/ */
define('TEMPLATEPATH', get_template_directory()); define('TEMPLATEPATH', get_template_directory());
/** /**
* Filesystem path to the current active template stylesheet directory * Filesystem path to the current active template stylesheet directory
* @since 2.1.0 * @since 2.1.0
* @deprecated 4.0
* @deprecated Use get_stylesheet_directory()
*/ */
define('STYLESHEETPATH', get_stylesheet_directory()); define('STYLESHEETPATH', get_stylesheet_directory());

View File

@ -449,7 +449,7 @@ function get_comments_popup_template() {
/** /**
* Retrieve the name of the highest priority template file that exists. * Retrieve the name of the highest priority template file that exists.
* *
* Searches in the STYLESHEETPATH before TEMPLATEPATH so that themes which * Searches in the stylesheet path before template path so that themes which
* inherit from a parent theme can just overload one file. * inherit from a parent theme can just overload one file.
* *
* @since 2.7.0 * @since 2.7.0
@ -464,11 +464,11 @@ function locate_template($template_names, $load = false, $require_once = true )
foreach ( (array) $template_names as $template_name ) { foreach ( (array) $template_names as $template_name ) {
if ( !$template_name ) if ( !$template_name )
continue; continue;
if ( file_exists(STYLESHEETPATH . '/' . $template_name)) { if ( file_exists( get_stylesheet_directory() . '/' . $template_name ) ) {
$located = STYLESHEETPATH . '/' . $template_name; $located = get_stylesheet_directory() . '/' . $template_name;
break; break;
} else if ( file_exists(TEMPLATEPATH . '/' . $template_name) ) { } else if ( file_exists( get_template_directory() . '/' . $template_name ) ) {
$located = TEMPLATEPATH . '/' . $template_name; $located = get_template_directory() . '/' . $template_name;
break; break;
} }
} }

View File

@ -128,7 +128,7 @@ function wp_clean_themes_cache( $clear_update_cache = true ) {
* @return bool true if a child theme is in use, false otherwise. * @return bool true if a child theme is in use, false otherwise.
**/ **/
function is_child_theme() { function is_child_theme() {
return ( TEMPLATEPATH !== STYLESHEETPATH ); return get_template_directory() !== get_stylesheet_directory();
} }
/** /**

View File

@ -322,10 +322,12 @@ $GLOBALS['wp_locale'] = new WP_Locale();
// Load the functions for the active theme, for both parent and child theme if applicable. // Load the functions for the active theme, for both parent and child theme if applicable.
if ( ! defined( 'WP_INSTALLING' ) || 'wp-activate.php' === $pagenow ) { if ( ! defined( 'WP_INSTALLING' ) || 'wp-activate.php' === $pagenow ) {
if ( TEMPLATEPATH !== STYLESHEETPATH && file_exists( STYLESHEETPATH . '/functions.php' ) ) if ( is_child_theme() && file_exists( get_stylesheet_directory() . '/functions.php' ) ) {
include( STYLESHEETPATH . '/functions.php' ); include get_stylesheet_directory() . '/functions.php';
if ( file_exists( TEMPLATEPATH . '/functions.php' ) ) }
include( TEMPLATEPATH . '/functions.php' ); if ( file_exists( get_template_directory() . '/functions.php' ) ) {
include get_template_directory() . '/functions.php';
}
} }
/** /**