Onboarding: Allow any uploaded theme to be activated (https://github.com/woocommerce/woocommerce-admin/pull/3620)
* Allow installed themes to be installed and activated * Filter themes on client-side by WC support and currently active * Run transient deletion hook during REST requests * Delete transient on theme switch for non-admin requests
This commit is contained in:
parent
2438885f09
commit
fcd2d517cd
|
@ -236,9 +236,11 @@ class Theme extends Component {
|
||||||
|
|
||||||
getThemes( activeTab = 'all' ) {
|
getThemes( activeTab = 'all' ) {
|
||||||
const { uploadedThemes } = this.state;
|
const { uploadedThemes } = this.state;
|
||||||
const { themes = [] } = getSetting( 'onboarding', {} );
|
const { activeTheme = '', themes = [] } = getSetting( 'onboarding', {} );
|
||||||
themes.concat( uploadedThemes );
|
const allThemes = [
|
||||||
const allThemes = [ ...themes, ...uploadedThemes ];
|
...themes.filter( theme => theme.has_woocommerce_support || theme.slug === activeTheme ),
|
||||||
|
...uploadedThemes,
|
||||||
|
];
|
||||||
|
|
||||||
switch ( activeTab ) {
|
switch ( activeTab ) {
|
||||||
case 'paid':
|
case 'paid':
|
||||||
|
|
|
@ -76,6 +76,8 @@ class Onboarding {
|
||||||
|
|
||||||
// Rest API hooks need to run before is_admin() checks.
|
// Rest API hooks need to run before is_admin() checks.
|
||||||
add_filter( 'woocommerce_rest_prepare_themes', array( $this, 'add_uploaded_theme_data' ) );
|
add_filter( 'woocommerce_rest_prepare_themes', array( $this, 'add_uploaded_theme_data' ) );
|
||||||
|
add_action( 'woocommerce_theme_installed', array( $this, 'delete_themes_transient' ) );
|
||||||
|
add_action( 'after_switch_theme', array( $this, 'delete_themes_transient' ) );
|
||||||
|
|
||||||
// Add onboarding notes.
|
// Add onboarding notes.
|
||||||
new WC_Admin_Notes_Onboarding_Profiler();
|
new WC_Admin_Notes_Onboarding_Profiler();
|
||||||
|
@ -92,8 +94,6 @@ class Onboarding {
|
||||||
add_filter( 'woocommerce_component_settings_preload_endpoints', array( $this, 'add_preload_endpoints' ) );
|
add_filter( 'woocommerce_component_settings_preload_endpoints', array( $this, 'add_preload_endpoints' ) );
|
||||||
add_filter( 'woocommerce_admin_preload_options', array( $this, 'preload_options' ) );
|
add_filter( 'woocommerce_admin_preload_options', array( $this, 'preload_options' ) );
|
||||||
add_filter( 'woocommerce_admin_preload_settings', array( $this, 'preload_settings' ) );
|
add_filter( 'woocommerce_admin_preload_settings', array( $this, 'preload_settings' ) );
|
||||||
add_action( 'woocommerce_theme_installed', array( $this, 'delete_themes_transient' ) );
|
|
||||||
add_action( 'after_switch_theme', array( $this, 'delete_themes_transient' ) );
|
|
||||||
add_action( 'current_screen', array( $this, 'finish_paypal_connect' ) );
|
add_action( 'current_screen', array( $this, 'finish_paypal_connect' ) );
|
||||||
add_action( 'current_screen', array( $this, 'finish_square_connect' ) );
|
add_action( 'current_screen', array( $this, 'finish_square_connect' ) );
|
||||||
add_action( 'current_screen', array( $this, 'add_help_tab' ), 60 );
|
add_action( 'current_screen', array( $this, 'add_help_tab' ), 60 );
|
||||||
|
@ -236,12 +236,7 @@ class Onboarding {
|
||||||
$active_theme = get_option( 'stylesheet' );
|
$active_theme = get_option( 'stylesheet' );
|
||||||
|
|
||||||
foreach ( $installed_themes as $slug => $theme ) {
|
foreach ( $installed_themes as $slug => $theme ) {
|
||||||
$theme_data = self::get_theme_data( $theme );
|
$theme_data = self::get_theme_data( $theme );
|
||||||
|
|
||||||
if ( ! $theme_data['has_woocommerce_support'] && $active_theme !== $slug ) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$installed_themes = wp_get_themes();
|
$installed_themes = wp_get_themes();
|
||||||
$themes[ $slug ] = $theme_data;
|
$themes[ $slug ] = $theme_data;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue