Astra_Notices::dismiss_notice()
Dismiss Notice.
Description
Return
(void)
Source
File: inc/lib/astra-notices/class-astra-notices.php
public function dismiss_notice() { $notice_id = ( isset( $_POST['notice_id'] ) ) ? sanitize_key( $_POST['notice_id'] ) : ''; $repeat_notice_after = ( isset( $_POST['repeat_notice_after'] ) ) ? absint( $_POST['repeat_notice_after'] ) : ''; $nonce = ( isset( $_POST['nonce'] ) ) ? sanitize_key( $_POST['nonce'] ) : ''; $notice = $this->get_notice_by_id( $notice_id ); $capability = isset( $notice['capability'] ) ? $notice['capability'] : 'manage_options'; if ( ! apply_filters( 'astra_notices_user_cap_check', current_user_can( $capability ) ) ) { return; } if ( false === wp_verify_nonce( $nonce, 'astra-notices' ) ) { wp_send_json_error( esc_html_e( 'WordPress Nonce not validated.', 'astra' ) ); } // Valid inputs? if ( ! empty( $notice_id ) ) { if ( ! empty( $repeat_notice_after ) ) { set_transient( $notice_id, true, $repeat_notice_after ); } else { update_user_meta( get_current_user_id(), $notice_id, 'notice-dismissed' ); } wp_send_json_success(); } wp_send_json_error(); }
Expand full source code Collapse full source code View on Trac
Changelog
Version | Description |
---|---|
1.0.0 | Introduced. |