PluginProbe
Float menu – awesome floating side menu / trunk
Float menu – awesome floating side menu vtrunk
7.2.5 trunk 2.1 2.2 3.0.1 3.1 3.2.2 3.3.1 3.5 3.5.1 3.5.2 3.5.3. 3.5.4 4.0 4.1 4.1.1 4.2 4.3 4.3.1 4.3.2 5.0 5.0.1 5.0.2 5.0.3 5.1 All 57 releases
float-menu / classes / Admin / AdminNotices.php

AdminNotices.php in Float menu – awesome floating side menu trunk, at classes/Admin/AdminNotices.php

67 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Class AdminNotices
5 *
6 * This class handles the admin notices for the plugin.
7 *
8 * @package WowPlugin
9 * @subpackage Admin
10 * @author Dmytro Lobov <dev@wow-company.com>, Wow-Company
11 * @copyright 2024 Dmytro Lobov
12 * @license GPL-2.0+
13 *
14 */
15
16 namespace FloatMenuLite\Admin;
17
18 use FloatMenuLite\WOWP_Plugin;
19
20 defined( 'ABSPATH' ) || exit;
21
22 class AdminNotices {
23
24
25 public static function init(): void {
26 add_action( 'admin_notices', [ __CLASS__, 'admin_notice' ] );
27 }
28
29 public static function admin_notice(): bool {
30
31 // phpcs:disable WordPress.Security.NonceVerification.Recommended -- Nonce verification is handled elsewhere.
32 if ( ! isset( $_GET['page'] ) ) {
33 return false;
34 }
35
36 if ( $_GET['page'] !== WOWP_Plugin::SLUG ) {
37 return false;
38 }
39
40 $notice = isset( $_GET['notice'] ) ? sanitize_text_field( wp_unslash( $_GET['notice'] ) ) : '';
41 // phpcs:enable
42
43 if ( ! empty( $notice ) && $notice === 'save_item' ) {
44 self::save_item();
45 } elseif ( ! empty( $notice ) && $notice === 'remove_item' ) {
46 self::remove_item();
47 }
48
49 return true;
50 }
51
52 public static function save_item(): void {
53 if ( isset( $_REQUEST['nonce'] ) ) {
54 $nonce = sanitize_text_field( wp_unslash( $_REQUEST['nonce'] ) );
55
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 }
60 }
61 }
62 public static function remove_item(): void {
63 $text = __( 'Item Remove', 'float-menu' );
64 echo '<div class="wpie-notice notice notice-warning is-dismissible">' . esc_html( $text ) . '</div>';
65 }
66
67 }