| @@ -26,10 +26,10 @@ | ||
| 26 | 26 | add_action( 'admin_notices', [ __CLASS__, 'admin_notice' ] ); |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | public static function admin_notice(): bool { |
| 30 | + $notice = $_GET['notice'] ?? ''; | |
| 30 | 31 | |
| 31 | - // phpcs:disable WordPress.Security.NonceVerification.Recommended -- Nonce verification is handled elsewhere. | |
| 32 | 32 | if ( ! isset( $_GET['page'] ) ) { |
| 33 | 33 | return false; |
| 34 | 34 | } |
| 35 | 35 | |
| @@ -36,11 +36,8 @@ | ||
| 36 | 36 | if ( $_GET['page'] !== WOWP_Plugin::SLUG ) { |
| 37 | 37 | return false; |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - $notice = isset( $_GET['notice'] ) ? sanitize_text_field( wp_unslash( $_GET['notice'] ) ) : ''; | |
| 41 | - // phpcs:enable | |
| 42 | - | |
| 43 | 40 | if ( ! empty( $notice ) && $notice === 'save_item' ) { |
| 44 | 41 | self::save_item(); |
| 45 | 42 | } elseif ( ! empty( $notice ) && $notice === 'remove_item' ) { |
| 46 | 43 | self::remove_item(); |
| @@ -49,17 +46,15 @@ | ||
| 49 | 46 | return true; |
| 50 | 47 | } |
| 51 | 48 | |
| 52 | 49 | public static function save_item(): void { |
| 53 | - if ( isset( $_REQUEST['nonce'] ) ) { | |
| 54 | - $nonce = sanitize_text_field( wp_unslash( $_REQUEST['nonce'] ) ); | |
| 50 | + if ( isset( $_REQUEST['nonce'] ) && wp_verify_nonce( $_REQUEST['nonce'], 'save-item' ) ) { | |
| 55 | 51 | |
| 56 | - if ( wp_verify_nonce( $nonce, 'save-item' ) ) { | |
| 57 | - $text = __( 'Item Saved', 'float-menu' ); | |
| 58 | - echo '<div class="wpie-notice notice notice-success is-dismissible">' . esc_html( $text ) . '</div>'; | |
| 59 | - } | |
| 52 | + $text = __( 'Item Saved', 'float-menu' ); | |
| 53 | + echo '<div class="wpie-notice notice notice-success is-dismissible">' . esc_html( $text ) . '</div>'; | |
| 60 | 54 | } |
| 61 | 55 | } |
| 56 | + | |
| 62 | 57 | public static function remove_item(): void { |
| 63 | 58 | $text = __( 'Item Remove', 'float-menu' ); |
| 64 | 59 | echo '<div class="wpie-notice notice notice-warning is-dismissible">' . esc_html( $text ) . '</div>'; |
| 65 | 60 | } |