Skip to content

Commit

Permalink
Merge pull request woocommerce#5701 from afurculita/master
Browse files Browse the repository at this point in the history
Deprecate WP_TEMPLATE_PATH
  • Loading branch information
mikejolley committed Jun 23, 2014
2 parents 8416361 + 494b55a commit 34c6143
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
28 changes: 14 additions & 14 deletions includes/class-wc-template-loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static function template_loader( $template ) {

$file = 'single-product.php';
$find[] = $file;
$find[] = WC_TEMPLATE_PATH . $file;
$find[] = WC()->template_path() . $file;

} elseif ( is_product_taxonomy() ) {

Expand All @@ -54,17 +54,17 @@ public static function template_loader( $template ) {
}

$find[] = 'taxonomy-' . $term->taxonomy . '-' . $term->slug . '.php';
$find[] = WC_TEMPLATE_PATH . 'taxonomy-' . $term->taxonomy . '-' . $term->slug . '.php';
$find[] = WC()->template_path() . 'taxonomy-' . $term->taxonomy . '-' . $term->slug . '.php';
$find[] = 'taxonomy-' . $term->taxonomy . '.php';
$find[] = WC_TEMPLATE_PATH . 'taxonomy-' . $term->taxonomy . '.php';
$find[] = WC()->template_path() . 'taxonomy-' . $term->taxonomy . '.php';
$find[] = $file;
$find[] = WC_TEMPLATE_PATH . $file;
$find[] = WC()->template_path() . $file;

} elseif ( is_post_type_archive( 'product' ) || is_page( wc_get_page_id( 'shop' ) ) ) {

$file = 'archive-product.php';
$find[] = $file;
$find[] = WC_TEMPLATE_PATH . $file;
$find[] = WC()->template_path() . $file;

}

Expand All @@ -89,17 +89,17 @@ public static function comments_template_loader( $template ) {
if ( get_post_type() !== 'product' )
return $template;

if ( file_exists( STYLESHEETPATH . '/' . WC_TEMPLATE_PATH . 'single-product-reviews.php' ))
return STYLESHEETPATH . '/' . WC_TEMPLATE_PATH . 'single-product-reviews.php';
elseif ( file_exists( TEMPLATEPATH . '/' . WC_TEMPLATE_PATH . 'single-product-reviews.php' ))
return TEMPLATEPATH . '/' . WC_TEMPLATE_PATH . 'single-product-reviews.php';
elseif ( file_exists( STYLESHEETPATH . '/' . 'single-product-reviews.php' ))
return STYLESHEETPATH . '/' . 'single-product-reviews.php';
elseif ( file_exists( TEMPLATEPATH . '/' . 'single-product-reviews.php' ))
return TEMPLATEPATH . '/' . 'single-product-reviews.php';
if ( file_exists( get_stylesheet_directory() . '/' . WC()->template_path() . 'single-product-reviews.php' ))
return get_stylesheet_directory() . '/' . WC()->template_path() . 'single-product-reviews.php';
elseif ( file_exists( get_template_directory() . '/' . WC()->template_path() . 'single-product-reviews.php' ))
return get_template_directory() . '/' . WC()->template_path() . 'single-product-reviews.php';
elseif ( file_exists( get_stylesheet_directory() . '/' . 'single-product-reviews.php' ))
return get_stylesheet_directory() . '/' . 'single-product-reviews.php';
elseif ( file_exists( get_template_directory() . '/' . 'single-product-reviews.php' ))
return get_template_directory() . '/' . 'single-product-reviews.php';
else
return WC()->plugin_path() . '/templates/single-product-reviews.php';
}
}

WC_Template_Loader::init();
WC_Template_Loader::init();
8 changes: 6 additions & 2 deletions woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ public function __get( $key ) {
}
else switch( $key ) {
case 'template_url':
_deprecated_argument( 'Woocommerce->template_url', '2.1', 'WC_TEMPLATE_PATH constant' );
return WC_TEMPLATE_PATH;
_deprecated_argument( 'Woocommerce->template_url', '2.1', 'Use WC()->template_path()' );
return $this->template_path();
case 'messages':
_deprecated_argument( 'Woocommerce->messages', '2.1', 'Use wc_get_notices' );
return wc_get_notices( 'success' );
Expand Down Expand Up @@ -231,6 +231,10 @@ private function define_constants() {
define( 'WC_VERSION', $this->version );
define( 'WOOCOMMERCE_VERSION', WC_VERSION ); // Backwards compat

/**
* @deprecated 2.2
* @deprecated Use WC()->template_path()
*/
if ( ! defined( 'WC_TEMPLATE_PATH' ) ) {
define( 'WC_TEMPLATE_PATH', $this->template_path() );
}
Expand Down

0 comments on commit 34c6143

Please sign in to comment.