Skip to content

Commit 6bf1947

Browse files
committed
Prevent TGMPA notice showing on WP core update pages.
Prevents core/plugin/theme updates screens looking like: ![screenshot](http://snag.gy/mIFC6.jpg)
1 parent 0e8e844 commit 6bf1947

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

class-tgm-plugin-activation.php

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1001,7 +1001,7 @@ protected function activate_single_plugin( $file_path, $slug, $automatic = false
10011001
*/
10021002
public function notices() {
10031003
// Remove nag on the install page / Return early if the nag message has been dismissed or user < author.
1004-
if ( $this->is_tgmpa_page() || get_user_meta( get_current_user_id(), 'tgmpa_dismissed_notice_' . $this->id, true ) || ! current_user_can( apply_filters( 'tgmpa_show_admin_notice_capability', 'publish_posts' ) ) ) {
1004+
if ( ( $this->is_tgmpa_page() || $this->is_core_update_page() ) || get_user_meta( get_current_user_id(), 'tgmpa_dismissed_notice_' . $this->id, true ) || ! current_user_can( apply_filters( 'tgmpa_show_admin_notice_capability', 'publish_posts' ) ) ) {
10051005
return;
10061006
}
10071007

@@ -1600,6 +1600,35 @@ protected function is_tgmpa_page() {
16001600
return isset( $_GET['page'] ) && $this->menu === $_GET['page'];
16011601
}
16021602

1603+
/**
1604+
* Determine if we're on a WP Core installation/upgrade page.
1605+
*
1606+
* @since 2.x.x
1607+
*
1608+
* @return boolean True when on a WP Core installation/upgrade page, false otherwise.
1609+
*/
1610+
protected function is_core_update_page() {
1611+
// Current screen is not always available, most notably on the customizer screen.
1612+
if ( ! function_exists( 'get_current_screen' ) ) {
1613+
return false;
1614+
}
1615+
1616+
$screen = get_current_screen();
1617+
1618+
if ( 'update-core' === $screen->base ) {
1619+
// Core update screen.
1620+
return true;
1621+
} elseif ( 'plugins' === $screen->base && isset( $_POST['action'] ) ) { // WPCS: CSRF ok.
1622+
// Plugins bulk update screen.
1623+
return true;
1624+
} elseif ( 'update' === $screen->base && isset( $_POST['action'] ) ) { // WPCS: CSRF ok.
1625+
// Individual updates (ajax call).
1626+
return true;
1627+
}
1628+
1629+
return false;
1630+
}
1631+
16031632
/**
16041633
* Retrieve the URL to the TGMPA Install page.
16051634
*

0 commit comments

Comments
 (0)