Make underscores the default

This commit is contained in:
claudiulodro 2017-11-07 08:45:05 -08:00
parent c3689134d0
commit 6b514aaab8
3 changed files with 9 additions and 37 deletions

View File

@ -2736,33 +2736,5 @@ add_action( 'wp_head', 'wc_page_noindex' );
* @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;
return apply_filters( 'woocommerce_theme_slug_for_templates', get_option( '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' );

View File

@ -23,6 +23,9 @@ if ( ! defined( 'ABSPATH' ) ) {
$template = wc_get_theme_slug_for_templates();
switch ( $template ) {
case 'twentyten' :
echo '</div></div>';
break;
case 'twentyeleven' :
echo '</div>';
get_sidebar( 'shop' );
@ -44,10 +47,7 @@ switch ( $template ) {
case 'twentysixteen' :
echo '</main></div>';
break;
case 'underscores' :
default :
echo '</div></main>';
break;
default :
echo '</div></div>';
break;
}

View File

@ -23,6 +23,9 @@ if ( ! defined( 'ABSPATH' ) ) {
$template = wc_get_theme_slug_for_templates();
switch ( $template ) {
case 'twentyten' :
echo '<div id="container"><div id="content" role="main">';
break;
case 'twentyeleven' :
echo '<div id="primary"><div id="content" role="main" class="twentyeleven">';
break;
@ -41,10 +44,7 @@ switch ( $template ) {
case 'twentysixteen' :
echo '<div id="primary" class="content-area twentysixteen"><main id="main" class="site-main" role="main">';
break;
case 'underscores' :
default :
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;
}