WC_Admin_Notices::remove_notices()
Remove a given set of notices.
An array of notice names or a regular expression string can be passed, in the later case all the notices whose name matches the regular expression will be removed.
Метод класса: WC_Admin_Notices{}
Хуков нет.
Возвращает
null
. Ничего (null).
Использование
$result = WC_Admin_Notices::remove_notices( $names_array_or_regex, $force_save );
- $names_array_or_regex(массив|строка) (обязательный)
- An array of notice names, or a string representing a regular expression.
- $force_save(true|false)
- Force saving inside this method instead of at the 'shutdown'.
По умолчанию: false
Код WC_Admin_Notices::remove_notices() WC Admin Notices::remove notices WC 9.4.2
public static function remove_notices( $names_array_or_regex, $force_save = false ) { if ( ! is_array( $names_array_or_regex ) ) { $names_array_or_regex = array_filter( self::get_notices(), fn( $notice_name ) => 1 === preg_match( $names_array_or_regex, $notice_name ) ); } self::set_notices( array_diff( self::get_notices(), $names_array_or_regex ) ); if ( $force_save ) { // Adding early save to prevent more race conditions with notices. self::store_notices(); } }