From b57bdd7a6827e613700b11dcf8bf9fe4b00a26cc Mon Sep 17 00:00:00 2001 From: "Panos (Panagiotis) Synetos" <2484390+PanosSynetos@users.noreply.github.com> Date: Tue, 19 Sep 2023 12:55:09 +0300 Subject: [PATCH 1/7] Revert aggressive page deletion - Flush cache and sleep --- includes/class-wc-calypso-bridge-setup.php | 104 +++++++++++---------- readme.txt | 4 + 2 files changed, 59 insertions(+), 49 deletions(-) diff --git a/includes/class-wc-calypso-bridge-setup.php b/includes/class-wc-calypso-bridge-setup.php index 4fce5fb4..2371e498 100644 --- a/includes/class-wc-calypso-bridge-setup.php +++ b/includes/class-wc-calypso-bridge-setup.php @@ -4,7 +4,7 @@ * * @package WC_Calypso_Bridge/Classes * @since 1.0.0 - * @version 2.2.13 + * @version x.x.x */ use Automattic\WooCommerce\Admin\WCAdminHelper; @@ -221,10 +221,10 @@ public function woocommerce_create_pages_callback() { $operation = 'woocommerce_create_pages'; - $this->write_to_log( $operation, 'initialized' ); + $this->write_to_log( $operation, 'INITIALIZED' ); - // Set the operation as completed if the store is active for more than 1 hour. - if ( WCAdminHelper::is_wc_admin_active_for( 60 * MINUTE_IN_SECONDS ) ) { + // Set the operation as completed if the store is active for more than 5 minutes. + if ( WCAdminHelper::is_wc_admin_active_for( 5 * MINUTE_IN_SECONDS ) ) { update_option( $this->option_prefix . $operation, 'completed', 'no' ); $this->write_to_log( $operation, 'completed (60 minutes)' ); @@ -268,28 +268,27 @@ public function woocommerce_create_pages_callback() { } try { - /* - * Force delete all pages (including duplicates), except some which are whitelisted. - */ - $exclude_pages = array( 'faq', 'contact-us', 'blog' ); - $args_pages = array( - 'post_type' => 'page', - 'post_status' => 'any', - 'posts_per_page' => - 1, + + $this->write_to_log( $operation, 'DELETING WOOCOMMERCE PAGES '); + + $woocommerce_slugs = array( + 'shop' => _x( 'shop', 'Page slug', 'woocommerce' ), + 'cart' => _x( 'cart', 'Page slug', 'woocommerce' ), + 'checkout' => _x( 'checkout', 'Page slug', 'woocommerce' ), + 'myaccount' => _x( 'my-account', 'Page slug', 'woocommerce' ), + 'refund_returns' => _x( 'refund_returns', 'Page slug', 'woocommerce' ), ); - $query_pages = new WP_Query( $args_pages ); - - $this->write_to_log( $operation, 'DELETING PAGES '); - if ( ! empty( $query_pages->posts ) ) { - foreach ( $query_pages->posts as $page ) { - if ( ! in_array( $page->post_name, $exclude_pages ) ) { - $result = wp_delete_post( $page->ID, true ); - $this->write_to_log( $operation, 'deleted WooCommerce page ' . $page->ID . ' - ' . $page->post_name ); - if ( ! $result ) { - $this->write_to_log( $operation, 'failed to delete WooCommerce page ' . $page->ID . ' - ' . $page->post_name ); + foreach ( $woocommerce_slugs as $key => $page_slug ) { + $slugs = array( $page_slug, $page_slug . '-2' ); + foreach ( $slugs as $slug ) { + $page = get_page_by_path( $slug, ARRAY_A ); + if ( is_array( $page ) && isset( $page['ID'] ) ) { + $result = wp_delete_post( $page['ID'], true ); + if ( $result ) { + $this->write_to_log( $operation, 'deleted WooCommerce page ' . $slug ); + } else { + $this->write_to_log( $operation, 'failed to delete WooCommerce page ' . $slug ); } - } else { - $this->write_to_log( $operation, 'skipped WooCommerce page ' . $page->ID . ' - ' . $page->post_name ); } } } @@ -303,21 +302,41 @@ public function woocommerce_create_pages_callback() { * `My Account` page id setting, is created with key `myaccount`. * @see WC_Install::create_pages() */ - $this->write_to_log( $operation, 'DELETING OPTIONS '); - foreach ( [ 'shop', 'cart', 'myaccount', 'checkout', 'refund_returns' ] as $page ) { - $value = get_option( "woocommerce_{$page}_page_id" ); - $result = delete_option( "woocommerce_{$page}_page_id" ); - $this->write_to_log( $operation, 'deleted option woocommerce_' . $page . '_page_id : ' . $value ); - if ( ! $result ) { - $this->write_to_log( $operation, 'failed to delete option woocommerce_' . $page . '_page_id : ' . $value ); + $this->write_to_log( $operation, 'DELETING WOOCOMMERCE PAGE OPTIONS '); + + foreach ( $woocommerce_slugs as $key => $page_slug ) { + $value = get_option( "woocommerce_{$key}_page_id" ); + $result = delete_option( "woocommerce_{$key}_page_id" ); + if ( $result ) { + $this->write_to_log( $operation, 'deleted option woocommerce_' . $key . '_page_id : ' . $value ); + } else { + $this->write_to_log( $operation, 'failed to delete option woocommerce_' . $key . '_page_id : ' . $value ); + } + } + + $this->write_to_log( $operation, 'DELETING HEADSTART PAGES '); + + // See https://github.com/Automattic/theme-tsubaki/blob/trunk/inc/headstart/en.json + $headstart_slugs = array( 'shop', 'cart', 'checkout', 'my-account', 'refund_returns' ); + foreach ( $headstart_slugs as $page_slug ) { + $slugs = array( $page_slug, $page_slug . '-2' ); + foreach ( $slugs as $slug ) { + $page = get_page_by_path( $slug, ARRAY_A ); + if ( is_array( $page ) && isset( $page['ID'] ) ) { + $result = wp_delete_post( $page['ID'], true ); + if ( $result ) { + $this->write_to_log( $operation, 'deleted headstart page ' . $slug ); + } else { + $this->write_to_log( $operation, 'failed to delete headstart page ' . $slug ); + } + } } } - // Commenting this out, to see if this was the reason that the pages are now created. -// foreach ( [ 'shop', 'cart', 'myaccount', 'checkout', 'refund_returns' ] as $page ) { -// $value = get_option( "woocommerce_{$page}_page_id" ); -// $this->write_to_log( $operation, 'getting option woocommerce_' . $page . '_page_id : ' . $value ); -// } + $this->write_to_log( $operation, 'FLUSH CACHE AND SLEEP '); + // sleep for 0.5 second to give enough time to memcache to flush and revalidate. + wp_cache_flush(); + usleep( 500000 ); // Delete the following note, so it can be recreated with the correct refund page ID. if ( class_exists( 'Automattic\WooCommerce\Admin\Notes\Notes' ) ) { @@ -436,19 +455,6 @@ class_exists( 'Automattic\WooCommerce\Blocks\Package' ) }, PHP_INT_MAX ); - // Log if valid page exists. - add_filter( 'woocommerce_create_page_id', function ( $valid_page_found, $slug, $page_content ) { - - $operation = 'woocommerce_create_pages'; - if ( $valid_page_found ) { - $this->write_to_log( $operation, 'woocommerce_create_page_id filter - valid page found - slug: ' . $slug ); - } else { - $this->write_to_log( $operation, 'woocommerce_create_page_id filter - valid page not found - slug: ' . $slug ); - } - - return $valid_page_found; - }, PHP_INT_MAX, 3 ); - // Log which pages have been created. add_action( 'woocommerce_page_created', function ( $page_id, $page_data ) { $operation = 'woocommerce_create_pages'; diff --git a/readme.txt b/readme.txt index c56785dd..8cc8fa4f 100644 --- a/readme.txt +++ b/readme.txt @@ -22,6 +22,10 @@ This section describes how to install the plugin and get it working. == Changelog == += unreleased = +* Revert all page deletion and delete only WooCommerce related pages #xxx +* Purge cache before creating WooCommerce related pages #xxx + = 2.2.14 = * Updated plugins landing page (free trial) #1300 * Removed some get_options logging during the page creation one time job #1296 From be4413413989b618e787f16d6028c0270390b661 Mon Sep 17 00:00:00 2001 From: "Panos (Panagiotis) Synetos" <2484390+PanosSynetos@users.noreply.github.com> Date: Tue, 19 Sep 2023 15:50:56 +0300 Subject: [PATCH 2/7] Avoid duplications --- includes/class-wc-calypso-bridge-setup.php | 66 ++++++++++++++-------- 1 file changed, 41 insertions(+), 25 deletions(-) diff --git a/includes/class-wc-calypso-bridge-setup.php b/includes/class-wc-calypso-bridge-setup.php index 2371e498..21f4c274 100644 --- a/includes/class-wc-calypso-bridge-setup.php +++ b/includes/class-wc-calypso-bridge-setup.php @@ -226,7 +226,7 @@ public function woocommerce_create_pages_callback() { // Set the operation as completed if the store is active for more than 5 minutes. if ( WCAdminHelper::is_wc_admin_active_for( 5 * MINUTE_IN_SECONDS ) ) { update_option( $this->option_prefix . $operation, 'completed', 'no' ); - $this->write_to_log( $operation, 'completed (60 minutes)' ); + $this->write_to_log( $operation, 'completed (5 minutes)' ); return; } @@ -269,27 +269,24 @@ public function woocommerce_create_pages_callback() { try { + /* + * Delete all WooCommerce pages, by translated slug, and start fresh. + * + * @see WC_Install::create_pages() + */ $this->write_to_log( $operation, 'DELETING WOOCOMMERCE PAGES '); - $woocommerce_slugs = array( + $woocommerce_pages = array( 'shop' => _x( 'shop', 'Page slug', 'woocommerce' ), 'cart' => _x( 'cart', 'Page slug', 'woocommerce' ), 'checkout' => _x( 'checkout', 'Page slug', 'woocommerce' ), 'myaccount' => _x( 'my-account', 'Page slug', 'woocommerce' ), 'refund_returns' => _x( 'refund_returns', 'Page slug', 'woocommerce' ), ); - foreach ( $woocommerce_slugs as $key => $page_slug ) { + foreach ( $woocommerce_pages as $key => $page_slug ) { $slugs = array( $page_slug, $page_slug . '-2' ); foreach ( $slugs as $slug ) { - $page = get_page_by_path( $slug, ARRAY_A ); - if ( is_array( $page ) && isset( $page['ID'] ) ) { - $result = wp_delete_post( $page['ID'], true ); - if ( $result ) { - $this->write_to_log( $operation, 'deleted WooCommerce page ' . $slug ); - } else { - $this->write_to_log( $operation, 'failed to delete WooCommerce page ' . $slug ); - } - } + $this->delete_page_by_slug( $slug, $operation ); } } @@ -299,12 +296,11 @@ public function woocommerce_create_pages_callback() { * for an ecommerce plan. WC_Install:create_pages() might not create all the * required pages without resetting these options first. * - * `My Account` page id setting, is created with key `myaccount`. * @see WC_Install::create_pages() */ $this->write_to_log( $operation, 'DELETING WOOCOMMERCE PAGE OPTIONS '); - foreach ( $woocommerce_slugs as $key => $page_slug ) { + foreach ( $woocommerce_pages as $key => $page_slug ) { $value = get_option( "woocommerce_{$key}_page_id" ); $result = delete_option( "woocommerce_{$key}_page_id" ); if ( $result ) { @@ -314,22 +310,18 @@ public function woocommerce_create_pages_callback() { } } + /* + * Deleting the hardcoded pages created by Headstart. + * + * @see https://github.com/Automattic/theme-tsubaki/blob/trunk/inc/headstart/en.json + */ $this->write_to_log( $operation, 'DELETING HEADSTART PAGES '); - // See https://github.com/Automattic/theme-tsubaki/blob/trunk/inc/headstart/en.json - $headstart_slugs = array( 'shop', 'cart', 'checkout', 'my-account', 'refund_returns' ); + $headstart_slugs = array( 'shop', 'cart', 'checkout', 'my-account', 'refund_returns' ); foreach ( $headstart_slugs as $page_slug ) { $slugs = array( $page_slug, $page_slug . '-2' ); foreach ( $slugs as $slug ) { - $page = get_page_by_path( $slug, ARRAY_A ); - if ( is_array( $page ) && isset( $page['ID'] ) ) { - $result = wp_delete_post( $page['ID'], true ); - if ( $result ) { - $this->write_to_log( $operation, 'deleted headstart page ' . $slug ); - } else { - $this->write_to_log( $operation, 'failed to delete headstart page ' . $slug ); - } - } + $this->delete_page_by_slug( $slug, $operation ); } } @@ -686,6 +678,30 @@ public function prevent_redirects_on_activation( $location, $status ) { private function write_to_log( $operation, $message ) { error_log( 'WooExpress: Operation: (' . microtime( true ) . ') ' . $operation . ': ' . print_r( $message, 1 ) ); } + + /** + * Delete page by slug + * + * @param string $slug Slug. + * @param string $operation Operation. + * + * @since x.x.x + * + * @return void + */ + private function delete_page_by_slug( $slug, $operation ) { + + $page = get_page_by_path( $slug, ARRAY_A ); + if ( is_array( $page ) && isset( $page['ID'] ) ) { + $result = wp_delete_post( $page['ID'], true ); + if ( $result ) { + $this->write_to_log( $operation, 'deleted page ' . $slug ); + } else { + $this->write_to_log( $operation, 'failed to delete page ' . $slug ); + } + } + + } } WC_Calypso_Bridge_Setup::get_instance(); From c11b6198254d21afcfb0b3c157dbd046f18d6311 Mon Sep 17 00:00:00 2001 From: "Panos (Panagiotis) Synetos" <2484390+PanosSynetos@users.noreply.github.com> Date: Wed, 20 Sep 2023 17:47:20 +0300 Subject: [PATCH 3/7] Do not delete pages that are older than 10 minutes and recreate all Woo --- includes/class-wc-calypso-bridge-setup.php | 30 +++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/includes/class-wc-calypso-bridge-setup.php b/includes/class-wc-calypso-bridge-setup.php index 21f4c274..432ba113 100644 --- a/includes/class-wc-calypso-bridge-setup.php +++ b/includes/class-wc-calypso-bridge-setup.php @@ -223,10 +223,10 @@ public function woocommerce_create_pages_callback() { $this->write_to_log( $operation, 'INITIALIZED' ); - // Set the operation as completed if the store is active for more than 5 minutes. - if ( WCAdminHelper::is_wc_admin_active_for( 5 * MINUTE_IN_SECONDS ) ) { + // Set the operation as completed if the store is active for more than 10 minutes. + if ( WCAdminHelper::is_wc_admin_active_for( 10 * MINUTE_IN_SECONDS ) ) { update_option( $this->option_prefix . $operation, 'completed', 'no' ); - $this->write_to_log( $operation, 'completed (5 minutes)' ); + $this->write_to_log( $operation, 'completed (10 minutes)' ); return; } @@ -447,6 +447,14 @@ class_exists( 'Automattic\WooCommerce\Blocks\Package' ) }, PHP_INT_MAX ); + // Force WooCommerce to recreate pages. + add_filter( 'woocommerce_create_page_id', function ( $valid_page_found, $slug, $page_content ) { + $operation = 'woocommerce_create_pages'; + $this->write_to_log( $operation, 'woocommerce_create_page_id force create slug: ' . $slug ); + return false; + }, PHP_INT_MAX, 3 ); + + // Log which pages have been created. add_action( 'woocommerce_page_created', function ( $page_id, $page_data ) { $operation = 'woocommerce_create_pages'; @@ -692,7 +700,23 @@ private function write_to_log( $operation, $message ) { private function delete_page_by_slug( $slug, $operation ) { $page = get_page_by_path( $slug, ARRAY_A ); + if ( is_array( $page ) && isset( $page['ID'] ) ) { + + $page_gmt_ts = get_post_time( 'U', true, $page['ID'] ); + // draft pages don't have a post_date_gmt, so we need to calculate it. + if ( false === $page_gmt_ts ) { + $page_gmt_ts = get_gmt_from_date( $page['post_date'], 'U' ); + } + $current_time_gmt_ts = current_time( 'U', true ); + $diff_ts = $current_time_gmt_ts - $page_gmt_ts; + + if ( $diff_ts > 10 * MINUTE_IN_SECONDS ) { + $this->write_to_log( $operation, 'ignored page deletion (too old) ' . $slug . ' diff: ' . $diff_ts ); + + return; + } + $result = wp_delete_post( $page['ID'], true ); if ( $result ) { $this->write_to_log( $operation, 'deleted page ' . $slug ); From dac76a829abb70cf0031e4a9f5b379c71c78c3df Mon Sep 17 00:00:00 2001 From: "Panos (Panagiotis) Synetos" <2484390+PanosSynetos@users.noreply.github.com> Date: Thu, 21 Sep 2023 12:40:47 +0300 Subject: [PATCH 4/7] Identify old sites/pages by 10 minutes --- includes/class-wc-calypso-bridge-setup.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/includes/class-wc-calypso-bridge-setup.php b/includes/class-wc-calypso-bridge-setup.php index 432ba113..aa59324c 100644 --- a/includes/class-wc-calypso-bridge-setup.php +++ b/includes/class-wc-calypso-bridge-setup.php @@ -224,7 +224,7 @@ public function woocommerce_create_pages_callback() { $this->write_to_log( $operation, 'INITIALIZED' ); // Set the operation as completed if the store is active for more than 10 minutes. - if ( WCAdminHelper::is_wc_admin_active_for( 10 * MINUTE_IN_SECONDS ) ) { + if ( WCAdminHelper::is_wc_admin_active_for( 5 * MINUTE_IN_SECONDS ) ) { update_option( $this->option_prefix . $operation, 'completed', 'no' ); $this->write_to_log( $operation, 'completed (10 minutes)' ); @@ -286,7 +286,7 @@ public function woocommerce_create_pages_callback() { foreach ( $woocommerce_pages as $key => $page_slug ) { $slugs = array( $page_slug, $page_slug . '-2' ); foreach ( $slugs as $slug ) { - $this->delete_page_by_slug( $slug, $operation ); + $this->maybe_delete_page_by_slug( $slug, $operation ); } } @@ -321,7 +321,7 @@ public function woocommerce_create_pages_callback() { foreach ( $headstart_slugs as $page_slug ) { $slugs = array( $page_slug, $page_slug . '-2' ); foreach ( $slugs as $slug ) { - $this->delete_page_by_slug( $slug, $operation ); + $this->maybe_delete_page_by_slug( $slug, $operation ); } } @@ -688,16 +688,17 @@ private function write_to_log( $operation, $message ) { } /** - * Delete page by slug - * - * @param string $slug Slug. - * @param string $operation Operation. + * Maybe delete page by slug. + * If the page is older than 10 minutes, it will be ignored. * * @since x.x.x * + * @param string $operation Operation. + * + * @param string $slug Slug. * @return void */ - private function delete_page_by_slug( $slug, $operation ) { + private function maybe_delete_page_by_slug( $slug, $operation ) { $page = get_page_by_path( $slug, ARRAY_A ); @@ -712,7 +713,7 @@ private function delete_page_by_slug( $slug, $operation ) { $diff_ts = $current_time_gmt_ts - $page_gmt_ts; if ( $diff_ts > 10 * MINUTE_IN_SECONDS ) { - $this->write_to_log( $operation, 'ignored page deletion (too old) ' . $slug . ' diff: ' . $diff_ts ); + $this->write_to_log( $operation, 'ignored page deletion ' . $slug . ' diff: ' . $diff_ts / 60 . ' minutes (older than 10 minutes) ' ); return; } From 3d14a6b74dac1b3415ebc29ff22cfcaff2defa42 Mon Sep 17 00:00:00 2001 From: "Panos (Panagiotis) Synetos" <2484390+PanosSynetos@users.noreply.github.com> Date: Fri, 22 Sep 2023 08:37:27 +0300 Subject: [PATCH 5/7] Applied review - bail out early --- includes/class-wc-calypso-bridge-setup.php | 38 ++++++++++++---------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/includes/class-wc-calypso-bridge-setup.php b/includes/class-wc-calypso-bridge-setup.php index aa59324c..8b462a6c 100644 --- a/includes/class-wc-calypso-bridge-setup.php +++ b/includes/class-wc-calypso-bridge-setup.php @@ -702,30 +702,32 @@ private function maybe_delete_page_by_slug( $slug, $operation ) { $page = get_page_by_path( $slug, ARRAY_A ); - if ( is_array( $page ) && isset( $page['ID'] ) ) { + if ( ! is_array( $page ) || ! isset( $page['ID'] ) ) { + return; + } - $page_gmt_ts = get_post_time( 'U', true, $page['ID'] ); - // draft pages don't have a post_date_gmt, so we need to calculate it. - if ( false === $page_gmt_ts ) { - $page_gmt_ts = get_gmt_from_date( $page['post_date'], 'U' ); - } - $current_time_gmt_ts = current_time( 'U', true ); - $diff_ts = $current_time_gmt_ts - $page_gmt_ts; + $page_gmt_ts = get_post_time( 'U', true, $page['ID'] ); + // draft pages don't have a post_date_gmt, so we need to calculate it. + if ( false === $page_gmt_ts ) { + $page_gmt_ts = get_gmt_from_date( $page['post_date'], 'U' ); + } + $current_time_gmt_ts = current_time( 'U', true ); + $diff_ts = $current_time_gmt_ts - $page_gmt_ts; - if ( $diff_ts > 10 * MINUTE_IN_SECONDS ) { - $this->write_to_log( $operation, 'ignored page deletion ' . $slug . ' diff: ' . $diff_ts / 60 . ' minutes (older than 10 minutes) ' ); + if ( $diff_ts > 10 * MINUTE_IN_SECONDS ) { + $this->write_to_log( $operation, 'ignored page deletion ' . $slug . ' diff: ' . $diff_ts / 60 . ' minutes (older than 10 minutes) ' ); - return; - } + return; + } - $result = wp_delete_post( $page['ID'], true ); - if ( $result ) { - $this->write_to_log( $operation, 'deleted page ' . $slug ); - } else { - $this->write_to_log( $operation, 'failed to delete page ' . $slug ); - } + $result = wp_delete_post( $page['ID'], true ); + if ( $result ) { + $this->write_to_log( $operation, 'deleted page ' . $slug ); + } else { + $this->write_to_log( $operation, 'failed to delete page ' . $slug ); } + } } From e2c554cc90ff4c576396afe8ce52c7eeb7bbe438 Mon Sep 17 00:00:00 2001 From: "Panos (Panagiotis Synetos)" <2484390+PanosSynetos@users.noreply.github.com> Date: Fri, 22 Sep 2023 08:39:06 +0300 Subject: [PATCH 6/7] Update logging order Co-authored-by: daledupreez --- includes/class-wc-calypso-bridge-setup.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/class-wc-calypso-bridge-setup.php b/includes/class-wc-calypso-bridge-setup.php index 8b462a6c..8614fbe3 100644 --- a/includes/class-wc-calypso-bridge-setup.php +++ b/includes/class-wc-calypso-bridge-setup.php @@ -684,7 +684,7 @@ public function prevent_redirects_on_activation( $location, $status ) { * @return void */ private function write_to_log( $operation, $message ) { - error_log( 'WooExpress: Operation: (' . microtime( true ) . ') ' . $operation . ': ' . print_r( $message, 1 ) ); + error_log( 'WooExpress: Operation: ' . $operation . ': (' . microtime( true ) . ') ' . print_r( $message, 1 ) ); } /** From 85d89bd170c776a50446f03dfb1c5761d166b79d Mon Sep 17 00:00:00 2001 From: "Panos (Panagiotis) Synetos" <2484390+PanosSynetos@users.noreply.github.com> Date: Wed, 27 Sep 2023 10:22:20 +0300 Subject: [PATCH 7/7] Set as complete if the store is active for more than 10 minutes --- includes/class-wc-calypso-bridge-setup.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/class-wc-calypso-bridge-setup.php b/includes/class-wc-calypso-bridge-setup.php index 8614fbe3..5da9ae33 100644 --- a/includes/class-wc-calypso-bridge-setup.php +++ b/includes/class-wc-calypso-bridge-setup.php @@ -224,7 +224,7 @@ public function woocommerce_create_pages_callback() { $this->write_to_log( $operation, 'INITIALIZED' ); // Set the operation as completed if the store is active for more than 10 minutes. - if ( WCAdminHelper::is_wc_admin_active_for( 5 * MINUTE_IN_SECONDS ) ) { + if ( WCAdminHelper::is_wc_admin_active_for( 10 * MINUTE_IN_SECONDS ) ) { update_option( $this->option_prefix . $operation, 'completed', 'no' ); $this->write_to_log( $operation, 'completed (10 minutes)' );