WC_Admin_Notices::add_notices()
Add notices + styles if needed.
Description Description
Source Source
File: includes/admin/class-wc-admin-notices.php
public static function add_notices() {
$notices = self::get_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(), Constants::get_constant( 'WC_VERSION' ) );
// Add RTL support.
wp_style_add_data( 'woocommerce-activation', 'rtl', 'replace' );
foreach ( $notices as $notice ) {
if ( ! empty( self::$core_notices[ $notice ] ) && apply_filters( 'woocommerce_show_admin_notice', true, $notice ) ) {
add_action( 'admin_notices', array( __CLASS__, self::$core_notices[ $notice ] ) );
} else {
add_action( 'admin_notices', array( __CLASS__, 'output_custom_notices' ) );
}
}
}