Automattic\WooCommerce\Internal\StockNotifications\Admin

NotificationsPage::add_notice │ public static │ WC 1.0

Add a notice to the admin notices.

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

Хуков нет.

Возвращает

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

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

$result = NotificationsPage::add_notice( $message, $type );
$message(строка) (обязательный)
The notice message.
$type(строка)
The notice type (optional).
По умолчанию: 'info'

Код NotificationsPage::add_notice() WC 11.2.2

public static function add_notice( $message, $type = 'info' ) {
	if ( empty( $message ) ) {
		return;
	}

	$notice_data = get_option( self::ADMIN_NOTICE_OPTION_NAME );
	if ( false !== $notice_data ) {
		return;
	}

	if ( ! in_array( $type, array( 'error', 'warning', 'success', 'info' ), true ) ) {
		$type = 'info';
	}

	$notice_data = array(
		'message' => $message,
		'type'    => $type,
	);

	update_option( self::ADMIN_NOTICE_OPTION_NAME, $notice_data );
}