PluginProbe
Floating Button – Easily Create Sticky, Fixed & Floating Buttons / 7.0
Floating Button – Easily Create Sticky, Fixed & Floating Buttons v7.0
trunk 2.0.2 3.0 4.0 4.1.2 4.3 5.0 5.0.1 5.1 5.1.1 5.2 5.3 5.3.1 6.0 6.0.1 6.0.10 6.0.11 6.0.12 6.0.13 6.0.2 6.0.3 6.0.4 6.0.5 6.0.6 6.0.7 All 31 releases
floating-button / classes / Admin / AdminNotices.php

AdminNotices.php in Floating Button – Easily Create Sticky, Fixed & Floating Buttons 7.0, 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 FloatingButton\Admin;
17
18 use FloatingButton\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', 'floating-button' );
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', 'floating-button' );
64 echo '<div class="wpie-notice notice notice-warning is-dismissible">' . esc_html( $text ) . '</div>';
65 }
66
67 }