Automattic\WooCommerce\Internal\StockNotifications\Admin
NotificationsPage::output_admin_notice
Display admin notices.
Method of the class: NotificationsPage{}
No Hooks.
Returns
null. Nothing (null).
Usage
$NotificationsPage = new NotificationsPage(); $NotificationsPage->output_admin_notice(): void;
NotificationsPage::output_admin_notice() NotificationsPage::output admin notice code WC 10.3.6
public function output_admin_notice(): void {
if ( ! function_exists( 'wp_admin_notice' ) ) {
return;
}
$notice_data = get_option( self::ADMIN_NOTICE_OPTION_NAME );
if ( false === $notice_data ) {
return;
}
// Check if invalid data.
if ( empty( $notice_data ) || ! is_array( $notice_data ) || empty( $notice_data['message'] ) ) {
delete_option( self::ADMIN_NOTICE_OPTION_NAME );
return;
}
$type = in_array( $notice_data['type'], array( 'error', 'warning', 'success', 'info' ), true )
? $notice_data['type']
: 'info';
\wp_admin_notice(
$notice_data['message'],
array(
'type' => $type,
'id' => self::ADMIN_NOTICE_OPTION_NAME,
'dismissible' => false,
)
);
delete_option( self::ADMIN_NOTICE_OPTION_NAME );
}