diff --git a/projects/plugins/wpcomsh/changelog/update-enforce-jetpack-modules-setup b/projects/plugins/wpcomsh/changelog/update-enforce-jetpack-modules-setup deleted file mode 100644 index 402987c2a5044..0000000000000 --- a/projects/plugins/wpcomsh/changelog/update-enforce-jetpack-modules-setup +++ /dev/null @@ -1,4 +0,0 @@ -Significance: minor -Type: fixed - -Ensure we'll always enable jetpack modules after an atomic transfer diff --git a/projects/plugins/wpcomsh/woa.php b/projects/plugins/wpcomsh/woa.php index 9101dbc62ab6f..e275761a3f196 100644 --- a/projects/plugins/wpcomsh/woa.php +++ b/projects/plugins/wpcomsh/woa.php @@ -393,69 +393,3 @@ function wpcomsh_woa_post_process_store_woocommerce_connection_details( $args, $ add_action( 'wpcomsh_woa_post_clone', 'wpcomsh_woa_post_process_store_woocommerce_connection_details', 10, 2 ); add_action( 'wpcomsh_woa_post_reset', 'wpcomsh_woa_post_process_store_woocommerce_connection_details', 10, 2 ); add_action( 'wpcomsh_woa_post_transfer', 'wpcomsh_woa_post_process_store_woocommerce_connection_details', 10, 2 ); - -/** - * Ensures that specific Jetpack modules are activated after a transfer. - * Addresses the issue where certain modules like blocks, account-protection and blaze - * may be disabled during the transfer process. - * - * @param array $args Arguments. - * @param array $assoc_args Associated arguments. - */ -function wpcomsh_woa_post_process_activate_jetpack_modules( $args, $assoc_args ) { - - if ( ! is_plugin_active( 'jetpack/jetpack.php' ) ) { - WP_CLI::warning( 'Jetpack plugin is not active, skipping module activation' ); - return; - } - - // First, make sure the jetpack_blocks_disabled option is deleted - delete_option( 'jetpack_blocks_disabled' ); - - $modules_to_activate = array( - 'account-protection', - 'blaze', - 'blocks', - ); - - $activated_modules = array(); - - foreach ( $modules_to_activate as $module ) { - $result = WP_CLI::runcommand( - "jetpack module activate $module", - array( - 'return' => 'all', - 'launch' => false, - 'exit_error' => false, - ) - ); - - if ( 0 === $result->return_code ) { - WP_CLI::log( sprintf( 'Successfully activated Jetpack module: %s', $module ) ); - $activated_modules[] = $module; - } else { - WP_CLI::warning( sprintf( 'Failed to activate Jetpack module: %s - %s', $module, $result->stderr ) ); - } - } - - // Get a list of all active modules to verify - $active_modules_result = WP_CLI::runcommand( - 'jetpack module list --status=active', - array( - 'return' => 'all', - 'launch' => false, - 'exit_error' => false, - ) - ); - - WP_CLI::log( 'Currently active Jetpack modules:' ); - WP_CLI::log( $active_modules_result->stdout ); - - if ( count( $activated_modules ) === count( $modules_to_activate ) ) { - WP_CLI::success( 'Jetpack modules activation completed' ); - } -} - -// Add this action for all three operation types to ensure modules are always activated -add_action( 'wpcomsh_woa_post_transfer', 'wpcomsh_woa_post_process_activate_jetpack_modules', 10, 2 ); -add_action( 'wpcomsh_woa_post_reset', 'wpcomsh_woa_post_process_activate_jetpack_modules', 10, 2 );