Merge pull request #19772 from woocommerce/update/notice-display

Only show notices on specific screens
This commit is contained in:
Claudio Sanches 2018-04-18 12:23:11 -03:00 committed by GitHub
commit 9679e7be1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 24 additions and 10 deletions

View File

@ -152,7 +152,22 @@ class WC_Admin_Notices {
public static function add_notices() {
$notices = self::get_notices();
if ( ! empty( $notices ) ) {
if ( empty( $notices ) ) {
return;
}
$screen = get_current_screen();
$screen_id = $screen ? $screen->id : '';
$show_on_screens = array(
'dashboard',
'plugins',
);
// Notices should only show on WooCommerce screens, the main dashboard, and on the plugins screen.
if ( ! in_array( $screen_id, wc_get_screen_ids(), true ) && ! in_array( $screen_id, $show_on_screens, true ) ) {
return;
}
wp_enqueue_style( 'woocommerce-activation', plugins_url( '/assets/css/activation.css', WC_PLUGIN_FILE ), array(), WC_VERSION );
// Add RTL support.
@ -166,7 +181,6 @@ class WC_Admin_Notices {
}
}
}
}
/**
* Add a custom notice.