WC_Admin_Notices::add_notices()public staticWC 1.0

Add notices + styles if needed.

Метод класса: WC_Admin_Notices{}

Хуки из метода

Возвращает

null. Ничего (null).

Использование

$result = WC_Admin_Notices::add_notices();

Код WC_Admin_Notices::add_notices() WC 8.7.0

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' ) );
		}
	}
}