Automattic\WooCommerce\Admin\API
Notice::dissmiss_notice()
Save notice dismiss information in user meta.
Метод класса: Notice{}
Хуков нет.
Возвращает
WP_REST_Response|WP_Error
.
Использование
$Notice = new Notice(); $Notice->dissmiss_notice( $request );
- $request(WP_REST_Request) (обязательный)
- Request object.
Код Notice::dissmiss_notice() Notice::dissmiss notice WC 9.3.3
public function dissmiss_notice( $request ) { if ( ! isset( $request['dismiss_notice_nonce'] ) || ! wp_verify_nonce( $request['dismiss_notice_nonce'], 'dismiss_notice' ) ) { return new WP_Error( 'unauthorized', 'Invalid nonce.', array( 'status' => 401 ) ); } $notice_id = isset( $request['notice_id'] ) ? sanitize_text_field( wp_unslash( $request['notice_id'] ) ) : ''; $dismissed = false; switch ( $notice_id ) { case 'woo-subscription-expired-notice': update_user_meta( get_current_user_id(), PluginsHelper::DISMISS_EXPIRED_SUBS_NOTICE, time() ); $dismissed = true; break; case 'woo-subscription-expiring-notice': update_user_meta( get_current_user_id(), PluginsHelper::DISMISS_EXPIRING_SUBS_NOTICE, time() ); $dismissed = true; break; } return rest_ensure_response( array( 'success' => $dismissed, ) ); }