Underscores wrappers
This commit is contained in:
parent
b24519b0c9
commit
c3689134d0
|
@ -2728,3 +2728,41 @@ function wc_page_noindex() {
|
|||
}
|
||||
}
|
||||
add_action( 'wp_head', 'wc_page_noindex' );
|
||||
|
||||
/**
|
||||
* Get a slug identifying the current theme.
|
||||
*
|
||||
* @since 3.3.0
|
||||
* @return string
|
||||
*/
|
||||
function wc_get_theme_slug_for_templates() {
|
||||
/**
|
||||
* @hooked wc_check_for_underscores_theme
|
||||
* @since 3.3.0
|
||||
*/
|
||||
$template = apply_filters( 'woocommerce_theme_slug_for_templates', get_option( 'template' ) );
|
||||
|
||||
return $template;
|
||||
}
|
||||
|
||||
/**
|
||||
* Treat all themes that don't formally support WooCommerce and are based on Underscores as one 'underscores' theme for templates.
|
||||
*
|
||||
* @since 3.3.0
|
||||
* @param string $template
|
||||
* @return string
|
||||
*/
|
||||
function wc_check_for_underscores_theme( $template ) {
|
||||
if ( ! current_theme_supports( 'woocommerce' ) && ! in_array( $template, wc_get_core_supported_themes() ) ) {
|
||||
$stylesheet = get_stylesheet_directory() . '/style.css';
|
||||
if( file_exists( $stylesheet ) ) {
|
||||
$stylesheet_contents = file_get_contents( $stylesheet );
|
||||
if ( stripos( $stylesheet_contents, 'underscores' ) ) {
|
||||
return 'underscores';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $template;
|
||||
}
|
||||
add_filter( 'woocommerce_theme_slug_for_templates', 'wc_check_for_underscores_theme' );
|
||||
|
|
|
@ -13,14 +13,14 @@
|
|||
* @see https://docs.woocommerce.com/document/template-structure/
|
||||
* @author WooThemes
|
||||
* @package WooCommerce/Templates
|
||||
* @version 1.6.4
|
||||
* @version 3.3.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
$template = get_option( 'template' );
|
||||
$template = wc_get_theme_slug_for_templates();
|
||||
|
||||
switch ( $template ) {
|
||||
case 'twentyeleven' :
|
||||
|
@ -44,6 +44,9 @@ switch ( $template ) {
|
|||
case 'twentysixteen' :
|
||||
echo '</main></div>';
|
||||
break;
|
||||
case 'underscores' :
|
||||
echo '</div></main>';
|
||||
break;
|
||||
default :
|
||||
echo '</div></div>';
|
||||
break;
|
||||
|
|
|
@ -13,14 +13,14 @@
|
|||
* @see https://docs.woocommerce.com/document/template-structure/
|
||||
* @author WooThemes
|
||||
* @package WooCommerce/Templates
|
||||
* @version 1.6.4
|
||||
* @version 3.3.0
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
$template = get_option( 'template' );
|
||||
$template = wc_get_theme_slug_for_templates();
|
||||
|
||||
switch ( $template ) {
|
||||
case 'twentyeleven' :
|
||||
|
@ -41,6 +41,9 @@ switch ( $template ) {
|
|||
case 'twentysixteen' :
|
||||
echo '<div id="primary" class="content-area twentysixteen"><main id="main" class="site-main" role="main">';
|
||||
break;
|
||||
case 'underscores' :
|
||||
echo '<div id="primary" class="content-area"><main id="main" class="site-main" role="main">';
|
||||
break;
|
||||
default :
|
||||
echo '<div id="container"><div id="content" role="main">';
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue