Automattic\WooCommerce\Internal\StockNotifications\Admin
NotificationsPage::add_notice
Add a notice to the admin notices.
Method of the class: NotificationsPage{}
No Hooks.
Returns
null. Nothing (null).
Usage
$result = NotificationsPage::add_notice( $message, $type );
- $message(string) (required)
- The notice message.
- $type(string)
- The notice type (optional).
Default: 'info'
NotificationsPage::add_notice() NotificationsPage::add notice code WC 10.3.6
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 );
}