WC_Admin_Notices::hide_notices()
Hide a notice if the GET variable is set.
Метод класса: WC_Admin_Notices{}
Хуки из метода
Возвращает
null
. Ничего (null).
Использование
$result = WC_Admin_Notices::hide_notices();
Код WC_Admin_Notices::hide_notices() WC Admin Notices::hide notices WC 9.4.2
public static function hide_notices() { if ( isset( $_GET['wc-hide-notice'] ) && isset( $_GET['_wc_notice_nonce'] ) ) { if ( ! wp_verify_nonce( sanitize_key( wp_unslash( $_GET['_wc_notice_nonce'] ) ), 'woocommerce_hide_notices_nonce' ) ) { wp_die( esc_html__( 'Action failed. Please refresh the page and retry.', 'woocommerce' ) ); } $notice_name = sanitize_text_field( wp_unslash( $_GET['wc-hide-notice'] ) ); /** * Filter the capability required to dismiss a given notice. * * @since 6.7.0 * * @param string $default_capability The default required capability. * @param string $notice_name The notice name. */ $required_capability = apply_filters( 'woocommerce_dismiss_admin_notice_capability', 'manage_woocommerce', $notice_name ); if ( ! current_user_can( $required_capability ) ) { wp_die( esc_html__( 'You don’t have permission to do this.', 'woocommerce' ) ); } self::hide_notice( $notice_name ); } }