Merge pull request #18184 from woocommerce/fix/18182-storefront-wizard-notice

Storefront in wizard for non WC themes and default themes
This commit is contained in:
Mike Jolley 2017-12-15 12:51:19 +00:00 committed by GitHub
commit fd2c676837
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 36 additions and 13 deletions

View File

@ -72,11 +72,23 @@ class WC_Admin_Setup_Wizard {
* and the store doesn't already have a WooCommerce compatible theme.
*/
protected function should_show_theme_extra() {
$is_default_theme = wc_is_active_theme( array(
'twentyseventeen',
'twentysixteen',
'twentyfifteen',
'twentyfourteen',
'twentythirteen',
'twentyeleven',
'twentytwelve',
'twentyten',
) );
$support_woocommerce = current_theme_supports( 'woocommerce' ) && ! $is_default_theme;
return (
current_user_can( 'install_themes' ) &&
current_user_can( 'switch_themes' ) &&
! is_multisite() &&
! current_theme_supports( 'woocommerce' )
! $support_woocommerce
);
}

View File

@ -247,17 +247,6 @@ final class WooCommerce {
}
}
/**
* Check the active theme.
*
* @since 2.6.9
* @param string $theme Theme slug to check.
* @return bool
*/
private function is_active_theme( $theme ) {
return is_array( $theme ) ? in_array( get_template(), $theme, true ) : get_template() === $theme;
}
/**
* Include required core files used in admin and on the frontend.
*/
@ -408,7 +397,7 @@ final class WooCommerce {
* @since 3.3.0
*/
private function theme_support_includes() {
if ( $this->is_active_theme( array( 'twentyseventeen', 'twentysixteen', 'twentyfifteen', 'twentyfourteen', 'twentythirteen', 'twentyeleven', 'twentytwelve', 'twentyten' ) ) ) {
if ( wc_is_active_theme( array( 'twentyseventeen', 'twentysixteen', 'twentyfifteen', 'twentyfourteen', 'twentythirteen', 'twentyeleven', 'twentytwelve', 'twentyten' ) ) ) {
switch ( get_template() ) {
case 'twentyten':
include_once( WC_ABSPATH . 'includes/theme-support/class-wc-twenty-ten.php' );

View File

@ -1947,3 +1947,14 @@ function wc_is_external_resource( $url ) {
return strstr( $url, '://' ) && strstr( $wp_base, $url );
}
/**
* See if theme/s is activate or not.
*
* @since 3.3.0
* @param string|array $theme Theme name or array of theme names to check.
* @return boolean
*/
function wc_is_active_theme( $theme ) {
return is_array( $theme ) ? in_array( get_template(), $theme, true ) : get_template() === $theme;
}

View File

@ -52,4 +52,15 @@ class WC_Tests_WooCommerce_Functions extends WC_Unit_Test_Case {
) );
$this->assertEquals( $new_currency, $order->get_currency() );
}
/**
* Test the wc_is_active_theme function.
*
* @return void
*/
public function test_wc_is_active_theme() {
$this->assertTrue( wc_is_active_theme( 'default' ) );
$this->assertFalse( wc_is_active_theme( 'twentyfifteen' ) );
$this->assertTrue( wc_is_active_theme( array( 'default', 'twentyseventeen' ) ) );
}
}