Centralize check for default themes.

This should make Storefront appear in the Setup Wizard again.
This commit is contained in:
Peter Fabian 2019-12-11 18:35:04 +01:00
parent 16868fe780
commit 72925ef41c
3 changed files with 24 additions and 23 deletions

View File

@ -73,7 +73,7 @@ class WC_Admin_Setup_Wizard {
* @return boolean
*/
protected function should_show_theme() {
$support_woocommerce = current_theme_supports( 'woocommerce' ) && ! $this->is_default_theme();
$support_woocommerce = current_theme_supports( 'woocommerce' ) && ! wc_is_wp_default_theme_active();
return (
current_user_can( 'install_themes' ) &&
@ -83,27 +83,6 @@ class WC_Admin_Setup_Wizard {
);
}
/**
* Is the user using a default WP theme?
*
* @return boolean
*/
protected function is_default_theme() {
return wc_is_active_theme(
array(
'twentynineteen',
'twentyseventeen',
'twentysixteen',
'twentyfifteen',
'twentyfourteen',
'twentythirteen',
'twentyeleven',
'twentytwelve',
'twentyten',
)
);
}
/**
* The "automated tax" extra should only be shown if the current user can
* install plugins and the store is in a supported country.

View File

@ -478,7 +478,7 @@ final class WooCommerce {
* @since 3.3.0
*/
private function theme_support_includes() {
if ( wc_is_active_theme( array( 'twentytwenty', 'twentynineteen', 'twentyseventeen', 'twentysixteen', 'twentyfifteen', 'twentyfourteen', 'twentythirteen', 'twentyeleven', 'twentytwelve', 'twentyten' ) ) ) {
if ( wc_is_wp_default_theme_active() ) {
switch ( get_template() ) {
case 'twentyten':
include_once WC_ABSPATH . 'includes/theme-support/class-wc-twenty-ten.php';

View File

@ -2143,6 +2143,28 @@ function wc_is_active_theme( $theme ) {
return is_array( $theme ) ? in_array( get_template(), $theme, true ) : get_template() === $theme;
}
/**
* Is the user using a default WP theme?
*
* @return boolean
*/
function wc_is_wp_default_theme_active() {
return wc_is_active_theme(
array(
'twentytwenty',
'twentynineteen',
'twentyseventeen',
'twentysixteen',
'twentyfifteen',
'twentyfourteen',
'twentythirteen',
'twentyeleven',
'twentytwelve',
'twentyten',
)
);
}
/**
* Cleans up session data - cron callback.
*