Skip to content

Commit

Permalink
Hide WCPayments alerts on plugins installation in progress and Jetpac…
Browse files Browse the repository at this point in the history
…k setup pages
  • Loading branch information
vbelolapotkov committed Feb 7, 2020
1 parent 02c12c8 commit 4a4bd98
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion includes/class-wc-payments.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,11 @@ public static function check_plugin_dependencies( $silent ) {

$plugin_headers = self::get_plugin_headers();

// Do not show alerts while installing plugins.
if ( ! $silent && self::is_at_plugin_install_page() ) {
return true;
}

$wc_version = $plugin_headers['WCRequires'];
$wp_version = $plugin_headers['RequiresWP'];

Expand Down Expand Up @@ -235,7 +240,8 @@ public static function check_plugin_dependencies( $silent ) {

// Check if Jetpack is connected.
if ( ! self::is_jetpack_connected() ) {
if ( ! $silent ) {
// Do not show an alert on Jetpack admin pages.
if ( ! $silent && ! self::is_at_jetpack_admin_page() ) {
$set_up_url = wp_nonce_url( 'admin.php?page=jetpack' );
$message = sprintf(
/* translators: %1: WooCommerce Payments version, %2: Jetpack setup url */
Expand All @@ -252,6 +258,26 @@ public static function check_plugin_dependencies( $silent ) {
return true;
}

/**
* Checks if current page is plugin installation process page.
*
* @return bool True when installing plugin.
*/
private static function is_at_plugin_install_page() {
$cur_screen = get_current_screen();
return 'update' === $cur_screen->id && 'plugins' === $cur_screen->parent_base;
}

/**
* Checks if current page is Jetpack admin page.
*
* @return bool True when current page is one of the Jetpack admin pages.
*/
private static function is_at_jetpack_admin_page() {
$cur_screen = get_current_screen();
return 'jetpack' === $cur_screen->parent_base;
}

/**
* Checks if Jetpack is connected.
*
Expand Down

0 comments on commit 4a4bd98

Please sign in to comment.