diff --git a/includes/admin/class-wc-admin-plugin-updates.php b/includes/admin/class-wc-admin-plugin-updates.php index 3ad345b9d87..0cf759a4759 100644 --- a/includes/admin/class-wc-admin-plugin-updates.php +++ b/includes/admin/class-wc-admin-plugin-updates.php @@ -57,7 +57,19 @@ class WC_Admin_Plugin_Updates { */ public function __construct() { add_filter( 'extra_plugin_headers', array( $this, 'enable_wc_plugin_headers' ) ); - add_action( 'in_plugin_update_message-woocommerce/woocommerce.php', array( $this, 'in_plugin_update_message' ), 10, 2 ); + + $screen = get_current_screen(); + if ( ! $screen ) { + return; + } + + if ( 'plugins' === $screen->id ) { + add_action( 'in_plugin_update_message-woocommerce/woocommerce.php', array( $this, 'in_plugin_update_message' ), 10, 2 ); + } + + if ( 'update-core' === $screen->id ) { + add_action( 'admin_print_footer_scripts', array( $this, 'update_screen_modal' ) ); + } } /** @@ -73,7 +85,7 @@ class WC_Admin_Plugin_Updates { } /** - * Show plugin changes. Code adapted from W3 Total Cache. + * Show plugin changes on the plugins screen. Code adapted from W3 Total Cache. * * @param array $args */ @@ -93,33 +105,47 @@ class WC_Admin_Plugin_Updates { if ( ! empty( $this->major_untested_plugins ) ) { $this->upgrade_notice .= $this->get_extensions_modal_warning(); - add_action( 'admin_print_footer_scripts', array( $this, 'modal_js' ) ); + add_action( 'admin_print_footer_scripts', array( $this, 'plugin_screen_modal_js' ) ); } echo apply_filters( 'woocommerce_in_plugin_update_message', $this->upgrade_notice ? '

' . wp_kses_post( $this->upgrade_notice ) . '

' : '' ); } /** - * JS for the modal window. + * Show a warning message on the upgrades screen if the user tries to upgrade and has untested plugins. */ - public function modal_js() { + public function update_screen_modal() { + $updateable_plugins = get_plugin_updates(); + if ( empty( $updateable_plugins['woocommerce/woocommerce.php'] ) + || empty( $updateable_plugins['woocommerce/woocommerce.php']->update ) + || empty( $updateable_plugins['woocommerce/woocommerce.php']->update->new_version ) ) { + return; + } + + $this->new_version = wc_clean( $updateable_plugins['woocommerce/woocommerce.php']->update->new_version ); + $this->major_untested_plugins = $this->get_untested_plugins( $this->new_version, 'major' ); + if ( empty( $this->major_untested_plugins ) ) { + return; + } + + echo $this->get_extensions_modal_warning(); + $this->update_screen_modal_js(); + } + + /** + * Common JS for initializing and managing the modals. + */ + protected function generic_modal_js() { ?> + + generic_modal_js(); + } + + /** + * JS for the modal window on the updates screen. + */ + protected function update_screen_modal_js() { + ?> + + generic_modal_js(); } /* diff --git a/includes/admin/class-wc-admin.php b/includes/admin/class-wc-admin.php index f00c89a661e..9b87db21c91 100644 --- a/includes/admin/class-wc-admin.php +++ b/includes/admin/class-wc-admin.php @@ -101,6 +101,7 @@ class WC_Admin { include( 'class-wc-admin-permalink-settings.php' ); break; case 'plugins' : + case 'update-core' : include( 'class-wc-admin-plugin-updates.php' ); break; case 'users' : diff --git a/includes/admin/views/html-notice-untested-extensions-modal.php b/includes/admin/views/html-notice-untested-extensions-modal.php index b413e932f86..0f6bfe18b13 100644 --- a/includes/admin/views/html-notice-untested-extensions-modal.php +++ b/includes/admin/views/html-notice-untested-extensions-modal.php @@ -44,5 +44,6 @@ if ( ! defined( 'ABSPATH' ) ) {

+