PluginProbe
Floating Button – Easily Create Sticky, Fixed & Floating Buttons / 6.0.10
Floating Button – Easily Create Sticky, Fixed & Floating Buttons v6.0.10
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 / AdminActions.php

AdminActions.php in Floating Button – Easily Create Sticky, Fixed & Floating Buttons 6.0.10, at classes/Admin/AdminActions.php

81 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FloatingButton\Admin;
4
5 defined( 'ABSPATH' ) || exit;
6
7 use FloatingButton\Dashboard\DBManager;
8 use FloatingButton\Dashboard\ImporterExporter;
9 use FloatingButton\Dashboard\Settings;
10 use FloatingButton\WOW_Plugin;
11
12 class AdminActions {
13
14 public function __construct() {
15 add_action( 'admin_init', [ $this, 'actions' ] );
16 }
17
18
19 public function actions() {
20 $name = $this->check_name( $_REQUEST );
21 if ( ! $name ) {
22 return false;
23 }
24 $verify = $this->verify( $name );
25
26 if ( ! $verify ) {
27 return false;
28 }
29
30
31 if ( strpos( $name, '_export_data' ) !== false ) {
32 ImporterExporter::export_data();
33 } elseif ( strpos( $name, '_export_item' ) !== false ) {
34 ImporterExporter::export_item();
35 } elseif ( strpos( $name, '_import_data' ) !== false ) {
36 ImporterExporter::import_data();
37 } elseif ( strpos( $name, '_remove_item' ) !== false ) {
38 DBManager::remove_item();
39 } elseif ( strpos( $name, '_settings' ) !== false ) {
40 Settings::save_item();
41 } elseif ( strpos( $name, '_activate_item' ) !== false ) {
42 Settings::activate_item();
43 } elseif ( strpos( $name, '_deactivate_item' ) !== false ) {
44 Settings::deactivate_item();
45 } elseif ( strpos( $name, '_activate_mode' ) !== false ) {
46 Settings::activate_mode();
47 } elseif ( strpos( $name, '_deactivate_mode' ) !== false ) {
48 Settings::deactivate_mode();
49 }
50 }
51
52 private function verify( $name ): bool {
53 $nonce_action = WOW_Plugin::PREFIX . '_nonce';
54 $nonce = isset( $_REQUEST[ $name ] ) ? sanitize_text_field( wp_unslash( $_REQUEST[ $name ] ) ) : '';
55
56 return ( ! empty( $nonce ) && wp_verify_nonce( $nonce, $nonce_action ) && current_user_can( 'manage_options' ) );
57 }
58
59 private function check_name( $request ) {
60 $names = [
61 WOW_Plugin::PREFIX . '_import_data',
62 WOW_Plugin::PREFIX . '_export_data',
63 WOW_Plugin::PREFIX . '_export_item',
64 WOW_Plugin::PREFIX . '_remove_item',
65 WOW_Plugin::PREFIX . '_settings',
66 WOW_Plugin::PREFIX . '_activate_item',
67 WOW_Plugin::PREFIX . '_deactivate_item',
68 WOW_Plugin::PREFIX . '_activate_mode',
69 WOW_Plugin::PREFIX . '_deactivate_mode',
70 ];
71
72 foreach ( $request as $key => $value ) {
73 if ( in_array( $key, $names, true ) ) {
74 return $key;
75 }
76 }
77
78 return false;
79 }
80
81 }