Made template debug mode set WC_TEMPLATE_DEBUG_MODE constant and remove all overrides for all template loading functions.
Closes #6436
This commit is contained in:
parent
c8ffee57ff
commit
d1de7f42b9
|
@ -70,8 +70,7 @@ class WC_Template_Loader {
|
|||
|
||||
if ( $file ) {
|
||||
$template = locate_template( array_unique( $find ) );
|
||||
$status_options = get_option( 'woocommerce_status_options', array() );
|
||||
if ( ! $template || ( ! empty( $status_options['template_debug_mode'] ) && current_user_can( 'manage_options' ) ) ) {
|
||||
if ( ! $template || WC_TEMPLATE_DEBUG_MODE ) {
|
||||
$template = WC()->plugin_path() . '/templates/' . $file;
|
||||
}
|
||||
}
|
||||
|
@ -86,19 +85,27 @@ class WC_Template_Loader {
|
|||
* @return string
|
||||
*/
|
||||
public static function comments_template_loader( $template ) {
|
||||
if ( get_post_type() !== 'product' )
|
||||
if ( get_post_type() !== 'product' ) {
|
||||
return $template;
|
||||
}
|
||||
|
||||
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';
|
||||
$check_dirs = array(
|
||||
trailingslashit( get_stylesheet_directory() ) . WC()->template_path(),
|
||||
trailingslashit( get_template_directory() ) . WC()->template_path(),
|
||||
trailingslashit( get_stylesheet_directory() ),
|
||||
trailingslashit( get_template_directory() ),
|
||||
trailingslashit( WC()->plugin_path() ) . 'templates/'
|
||||
);
|
||||
|
||||
if ( WC_TEMPLATE_DEBUG_MODE ) {
|
||||
$check_dirs = array( array_pop( $check_dirs ) );
|
||||
}
|
||||
|
||||
foreach ( $check_dirs as $dir ) {
|
||||
if ( file_exists( trailingslashit( $dir ) . 'single-product-reviews.php' ) ) {
|
||||
return trailingslashit( $dir ) . 'single-product-reviews.php';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -137,7 +137,7 @@ function wc_get_template_part( $slug, $name = '' ) {
|
|||
$template = '';
|
||||
|
||||
// Look in yourtheme/slug-name.php and yourtheme/woocommerce/slug-name.php
|
||||
if ( $name ) {
|
||||
if ( $name && ! WC_TEMPLATE_DEBUG_MODE ) {
|
||||
$template = locate_template( array( "{$slug}-{$name}.php", WC()->template_path() . "{$slug}-{$name}.php" ) );
|
||||
}
|
||||
|
||||
|
@ -147,12 +147,14 @@ function wc_get_template_part( $slug, $name = '' ) {
|
|||
}
|
||||
|
||||
// If template file doesn't exist, look in yourtheme/slug.php and yourtheme/woocommerce/slug.php
|
||||
if ( ! $template ) {
|
||||
if ( ! $template && ! WC_TEMPLATE_DEBUG_MODE ) {
|
||||
$template = locate_template( array( "{$slug}.php", WC()->template_path() . "{$slug}.php" ) );
|
||||
}
|
||||
|
||||
// Allow 3rd party plugin filter template file from their plugin
|
||||
$template = apply_filters( 'wc_get_template_part', $template, $slug, $name );
|
||||
if ( ( ! $template && WC_TEMPLATE_DEBUG_MODE ) || $template ) {
|
||||
$template = apply_filters( 'wc_get_template_part', $template, $slug, $name );
|
||||
}
|
||||
|
||||
if ( $template ) {
|
||||
load_template( $template, false );
|
||||
|
@ -224,12 +226,12 @@ function wc_locate_template( $template_name, $template_path = '', $default_path
|
|||
);
|
||||
|
||||
// Get default template
|
||||
if ( ! $template ) {
|
||||
if ( ! $template || WC_TEMPLATE_DEBUG_MODE ) {
|
||||
$template = $default_path . $template_name;
|
||||
}
|
||||
|
||||
// Return what we found
|
||||
return apply_filters('woocommerce_locate_template', $template, $template_name, $template_path);
|
||||
return apply_filters( 'woocommerce_locate_template', $template, $template_name, $template_path );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -140,6 +140,7 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
|
|||
* Tweak - Logic in wc_paying_customer to only increase for 'simple' orders.
|
||||
* Tweak - Added tool to refresh stats to customer list.
|
||||
* Tweak - Recent order table on my account is responsive.
|
||||
* Dev - Made template debug mode set WC_TEMPLATE_DEBUG_MODE constant and remove all overrides for all template loading functions.
|
||||
|
||||
= 2.2.5 =
|
||||
* Fix - Filters in admin screen for coupons and orders.
|
||||
|
|
|
@ -356,6 +356,16 @@ final class WooCommerce {
|
|||
// Set up localisation
|
||||
$this->load_plugin_textdomain();
|
||||
|
||||
// Template debug mode
|
||||
if ( ! defined( 'WC_TEMPLATE_DEBUG_MODE' ) ) {
|
||||
$status_options = get_option( 'woocommerce_status_options', array() );
|
||||
if ( ! empty( $status_options['template_debug_mode'] ) && current_user_can( 'manage_options' ) ) {
|
||||
define( 'WC_TEMPLATE_DEBUG_MODE', true );
|
||||
} else {
|
||||
define( 'WC_TEMPLATE_DEBUG_MODE', false );
|
||||
}
|
||||
}
|
||||
|
||||
// Load class instances
|
||||
$this->product_factory = new WC_Product_Factory(); // Product Factory to create new product instances
|
||||
$this->order_factory = new WC_Order_Factory(); // Order Factory to create new order instances
|
||||
|
|
Loading…
Reference in New Issue