From 609cfe0eceef0780200ea79b756d1c586602ddeb Mon Sep 17 00:00:00 2001 From: moon Date: Mon, 25 Sep 2023 17:04:51 -0700 Subject: [PATCH 1/7] Mark customize store task complete when user redirects to the site editor from a theme details page --- class-wc-calypso-bridge.php | 1 + ...lass-wc-calypso-bridge-customize-store.php | 68 +++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 includes/class-wc-calypso-bridge-customize-store.php diff --git a/class-wc-calypso-bridge.php b/class-wc-calypso-bridge.php index d18450d0..a4cbf1e0 100644 --- a/class-wc-calypso-bridge.php +++ b/class-wc-calypso-bridge.php @@ -132,6 +132,7 @@ public function includes() { require_once WC_CALYPSO_BRIDGE_PLUGIN_PATH . '/includes/class-wc-calypso-bridge-product-import-fix.php'; require_once WC_CALYPSO_BRIDGE_PLUGIN_PATH . '/includes/class-wc-calypso-bridge-skip-obw.php'; require_once WC_CALYPSO_BRIDGE_PLUGIN_PATH . '/includes/class-wc-calypso-bridge-footer-credits.php'; + require_once WC_CALYPSO_BRIDGE_PLUGIN_PATH . '/includes/class-wc-calypso-bridge-customize-store.php'; // Experiments. require_once WC_CALYPSO_BRIDGE_PLUGIN_PATH . '/includes/experiments/class-wc-calypso-bridge-task-list-reminderbar-experiment.php'; diff --git a/includes/class-wc-calypso-bridge-customize-store.php b/includes/class-wc-calypso-bridge-customize-store.php new file mode 100644 index 00000000..63fa866f --- /dev/null +++ b/includes/class-wc-calypso-bridge-customize-store.php @@ -0,0 +1,68 @@ +id === 'site-editor' ) { + $referrer = wp_get_referer(); + $pattern = "/^\/theme\/[^\/]+\/[^\/]+\/?$/"; + $isFromThemeDetailsPage = preg_match( $pattern, parse_url( $referrer, PHP_URL_PATH ) ); + if ( $isFromThemeDetailsPage ) { + update_option( 'woocommerce_admin_customize_store_completed', 'yes' ); + } + } + } +} + +WC_Calypso_Bridge_Customize_Store::get_instance(); From 41cbd6f5ed54e2bb71f1afd1e3b3b9510b169df7 Mon Sep 17 00:00:00 2001 From: moon Date: Tue, 26 Sep 2023 13:21:58 -0700 Subject: [PATCH 2/7] Uses from GET var to detect users from the theme browser -- the value is set from wp-calypso --- includes/class-wc-calypso-bridge-customize-store.php | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/includes/class-wc-calypso-bridge-customize-store.php b/includes/class-wc-calypso-bridge-customize-store.php index 63fa866f..b1979cc3 100644 --- a/includes/class-wc-calypso-bridge-customize-store.php +++ b/includes/class-wc-calypso-bridge-customize-store.php @@ -37,7 +37,7 @@ public static function get_instance() { private function __construct() { // Only in Ecommerce or Free Trial - if ( ! wc_calypso_bridge_has_ecommerce_features() || ! wc_calypso_bridge_is_ecommerce_trial_plan() ) { + if ( ! wc_calypso_bridge_has_ecommerce_features() && ! wc_calypso_bridge_is_ecommerce_trial_plan() ) { return; } @@ -54,13 +54,8 @@ private function __construct() { */ public function mark_customize_store_task_as_completed_on_site_editor() { $screen = get_current_screen(); - if ( $screen->id === 'site-editor' ) { - $referrer = wp_get_referer(); - $pattern = "/^\/theme\/[^\/]+\/[^\/]+\/?$/"; - $isFromThemeDetailsPage = preg_match( $pattern, parse_url( $referrer, PHP_URL_PATH ) ); - if ( $isFromThemeDetailsPage ) { - update_option( 'woocommerce_admin_customize_store_completed', 'yes' ); - } + if ( $screen->id === 'site-editor' && isset( $_GET['from'] ) && $_GET['from'] === 'theme-browser' ) { + update_option( 'woocommerce_admin_customize_store_completed', 'yes' ); } } } From 6299866e9aa59f438ebae78366cd8f41d4ec8630 Mon Sep 17 00:00:00 2001 From: Moon Date: Wed, 27 Sep 2023 08:53:01 -0700 Subject: [PATCH 3/7] Update includes/class-wc-calypso-bridge-customize-store.php Co-authored-by: Adrian Duffell <9312929+adrianduffell@users.noreply.github.com> --- includes/class-wc-calypso-bridge-customize-store.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/class-wc-calypso-bridge-customize-store.php b/includes/class-wc-calypso-bridge-customize-store.php index b1979cc3..2bf885bb 100644 --- a/includes/class-wc-calypso-bridge-customize-store.php +++ b/includes/class-wc-calypso-bridge-customize-store.php @@ -41,7 +41,7 @@ private function __construct() { return; } - add_action( 'current_screen', array( $this, 'mark_customize_store_task_as_completed_on_site_editor' ) ); + add_action( 'load-site-editor.php', array( $this, 'mark_customize_store_task_as_completed_on_site_editor' ) ); } From 82287306ba04fd16b7b5168bfea0a1f1f8b14ab9 Mon Sep 17 00:00:00 2001 From: moon Date: Tue, 26 Sep 2023 13:23:10 -0700 Subject: [PATCH 4/7] Update comment --- includes/class-wc-calypso-bridge-customize-store.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/includes/class-wc-calypso-bridge-customize-store.php b/includes/class-wc-calypso-bridge-customize-store.php index 2bf885bb..19588c3b 100644 --- a/includes/class-wc-calypso-bridge-customize-store.php +++ b/includes/class-wc-calypso-bridge-customize-store.php @@ -46,7 +46,8 @@ private function __construct() { } /** - * Mark Customize Store task as completed on Site Editor + * Mark Customize Store task as completed on Site Editor by checking $_GET['from'] value. + * The value is set from WP-Calypso. * * @since 2.2.14 * From cd67ace32d330e95e87cd5f5d7339e7f864e4c0d Mon Sep 17 00:00:00 2001 From: moon Date: Wed, 27 Sep 2023 08:59:53 -0700 Subject: [PATCH 5/7] Remove screen id check --- includes/class-wc-calypso-bridge-customize-store.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/includes/class-wc-calypso-bridge-customize-store.php b/includes/class-wc-calypso-bridge-customize-store.php index 19588c3b..760e9f1a 100644 --- a/includes/class-wc-calypso-bridge-customize-store.php +++ b/includes/class-wc-calypso-bridge-customize-store.php @@ -42,20 +42,18 @@ private function __construct() { } add_action( 'load-site-editor.php', array( $this, 'mark_customize_store_task_as_completed_on_site_editor' ) ); - } /** * Mark Customize Store task as completed on Site Editor by checking $_GET['from'] value. - * The value is set from WP-Calypso. + * The value is set from WP-Calypso. * * @since 2.2.14 * * @return void */ public function mark_customize_store_task_as_completed_on_site_editor() { - $screen = get_current_screen(); - if ( $screen->id === 'site-editor' && isset( $_GET['from'] ) && $_GET['from'] === 'theme-browser' ) { + if ( isset( $_GET['from'] ) && $_GET['from'] === 'theme-browser' ) { update_option( 'woocommerce_admin_customize_store_completed', 'yes' ); } } From dee4b2537b577e1ec5c2ca204fcd9b3cbf058d8c Mon Sep 17 00:00:00 2001 From: moon Date: Wed, 27 Sep 2023 09:12:35 -0700 Subject: [PATCH 6/7] Use feature flag detection --- includes/class-wc-calypso-bridge-customize-store.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/includes/class-wc-calypso-bridge-customize-store.php b/includes/class-wc-calypso-bridge-customize-store.php index 760e9f1a..897dc41d 100644 --- a/includes/class-wc-calypso-bridge-customize-store.php +++ b/includes/class-wc-calypso-bridge-customize-store.php @@ -35,13 +35,11 @@ public static function get_instance() { * Constructor. */ private function __construct() { - - // Only in Ecommerce or Free Trial - if ( ! wc_calypso_bridge_has_ecommerce_features() && ! wc_calypso_bridge_is_ecommerce_trial_plan() ) { - return; - } - - add_action( 'load-site-editor.php', array( $this, 'mark_customize_store_task_as_completed_on_site_editor' ) ); + add_action( 'plugins_loaded', function() { + if ( class_exists( '\Automattic\WooCommerce\Admin\Features\Features' ) && \Automattic\WooCommerce\Admin\Features\Features::is_enabled( 'customize-store' ) ) { + add_action( 'load-site-editor.php', array( $this, 'mark_customize_store_task_as_completed_on_site_editor' ) ); + } + }); } /** From b03b170b39854b286a52488b141bc2780a70a9bc Mon Sep 17 00:00:00 2001 From: moon Date: Mon, 2 Oct 2023 14:15:04 -0700 Subject: [PATCH 7/7] Update from value to theme-info --- includes/class-wc-calypso-bridge-customize-store.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/class-wc-calypso-bridge-customize-store.php b/includes/class-wc-calypso-bridge-customize-store.php index 897dc41d..5ef011f1 100644 --- a/includes/class-wc-calypso-bridge-customize-store.php +++ b/includes/class-wc-calypso-bridge-customize-store.php @@ -51,7 +51,7 @@ private function __construct() { * @return void */ public function mark_customize_store_task_as_completed_on_site_editor() { - if ( isset( $_GET['from'] ) && $_GET['from'] === 'theme-browser' ) { + if ( isset( $_GET['from'] ) && $_GET['from'] === 'theme-info' ) { update_option( 'woocommerce_admin_customize_store_completed', 'yes' ); } }