WC_Admin_Notices::init()public staticWC 1.0

Initializes the class.

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

Хуков нет.

Возвращает

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

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

$result = WC_Admin_Notices::init();

Код WC_Admin_Notices::init() WC 9.4.2

public static function init() {
	self::$is_multisite = is_multisite();
	self::set_notices( get_option( 'woocommerce_admin_notices', array() ) );

	add_action( 'switch_theme', array( __CLASS__, 'reset_admin_notices' ) );
	add_action( 'woocommerce_installed', array( __CLASS__, 'reset_admin_notices' ) );
	add_action( 'wp_loaded', array( __CLASS__, 'add_redirect_download_method_notice' ) );
	add_action( 'admin_init', array( __CLASS__, 'hide_notices' ), 20 );
	self::add_action( 'admin_init', array( __CLASS__, 'maybe_remove_legacy_api_removal_notice' ), 20 );

	// @TODO: This prevents Action Scheduler async jobs from storing empty list of notices during WC installation.
	// That could lead to OBW not starting and 'Run setup wizard' notice not appearing in WP admin, which we want
	// to avoid.
	if ( ! WC_Install::is_new_install() || ! wc_is_running_from_async_action_scheduler() ) {
		add_action( 'shutdown', array( __CLASS__, 'store_notices' ) );
	}

	if ( current_user_can( 'manage_woocommerce' ) ) {
		add_action( 'admin_print_styles', array( __CLASS__, 'add_notices' ) );
	}
}