Automattic\WooCommerce\Admin\Features
TransientNotices::add()
Add a notice to be shown.
Метод класса: TransientNotices{}
Хуков нет.
Возвращает
null
. Ничего (null).
Использование
$result = TransientNotices::add( $notice );
- $notice(массив) (обязательный)
- Notice.
php $notice = array( 'id' => (string) Unique ID for the notice. Required. 'user_id' => (int|null) User ID to show the notice to. 'status' => (string) info|error|success 'content' => (string) Content to be shown for the notice. Required. 'options' => (array) Array of options to be passed to the notice component. See https://developer.wordpress.org/block-editor/reference-guides/data/data-core-notices/#createNotice for available options. ).
Код TransientNotices::add() TransientNotices::add WC 8.7.0
public static function add( $notice ) { $queue = self::get_queue(); $defaults = array( 'user_id' => null, 'status' => 'info', 'options' => array(), ); $notice_data = array_merge( $defaults, $notice ); $notice_data['options'] = (object) $notice_data['options']; $queue[ $notice['id'] ] = $notice_data; update_option( self::QUEUE_OPTION, $queue ); }