WC_Admin_Notices::add_notices()
Add notices + styles if needed.
Method of the class: WC_Admin_Notices{}
Hooks from the method
Return
null
. Nothing (null).
Usage
$result = WC_Admin_Notices::add_notices();
WC_Admin_Notices::add_notices() WC Admin Notices::add notices code WC 9.7.1
public static function add_notices() { $notices = self::get_notices(); if ( empty( $notices ) ) { return; } require_once WC_ABSPATH . 'includes/admin/wc-admin-functions.php'; $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' ) ); } } }