PluginProbe ʕ •ᴥ•ʔ
Email Encoder – Protect Email Addresses and Phone Numbers / 2.4.1
Email Encoder – Protect Email Addresses and Phone Numbers v2.4.1
2.5.0 2.4.8 trunk 0.10 0.11 0.12 0.20 0.21 0.22 0.30 0.31 0.32 0.40 0.41 0.42 0.50 0.60 0.70 0.71 0.80 1.0.0 1.0.1 1.0.2 1.1.0 1.2.0 1.2.1 1.3.0 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.5 1.5.2 1.51 1.53 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1.0 2.1.1 2.1.10 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.3.0 2.3.1 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8 2.3.9 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7
email-encoder-bundle / src / Admin / Admin.php
email-encoder-bundle / src / Admin Last commit date
Admin.php 5 months ago AdminEnqueue.php 5 months ago AdminHelp.php 5 months ago AdminMenu.php 5 months ago AdminMetaBox.php 5 months ago PluginActionLinks.php 5 months ago
Admin.php
90 lines
1 <?php
2
3 namespace OnlineOptimisation\EmailEncoderBundle\Admin;
4
5 use OnlineOptimisation\EmailEncoderBundle\Traits\PluginHelper;
6
7 class Admin
8 {
9 use PluginHelper;
10
11 public static array $display_notices = [];
12
13
14 public function boot(): void
15 {
16 ( new AdminEnqueue() )->boot();
17 ( new AdminMenu() )->boot(); // AdminMetaBox & AdminHelp are added here
18 ( new PluginActionLinks() )->boot();
19
20 add_action( 'init', [ $this, 'register_hooks' ] );
21 }
22
23 # ADMIN METHODS ============================================================
24
25 public function register_hooks()
26 {
27 add_action( 'admin_init', [ $this, 'save_settings_admin' ] );
28 }
29
30
31
32
33
34 public function save_settings_admin()
35 {
36 // $this->log( __METHOD__ );
37 if ( !isset( $_POST[ $this->getPageName() . '_nonce' ] ) ) {
38 return;
39 };
40
41 if ( ! wp_verify_nonce( $_POST[ $this->getPageName() . '_nonce' ], $this->getPageName() ) ) {
42 wp_die( __( 'You don\'t have permission to update these settings.', 'email-encoder-bundle' ) );
43 }
44
45 if ( ! current_user_can( $this->getAdminCap( 'admin-update-settings' ) ) ) {
46 wp_die( __( 'You don\'t have permission to update these settings.', 'email-encoder-bundle' ) );
47 }
48
49 $raw = wp_unslash( $_POST );
50
51 if ( isset( $raw[ $this->getSettingsKey() ] ) && is_array( $raw[ $this->getSettingsKey() ] ) ) {
52
53 //Strip duplicate slashes before saving
54 foreach ( $raw[ $this->getSettingsKey() ] as $k => $v ) {
55 if ( is_string( $v ) ) {
56 $raw[ $this->getSettingsKey() ][ $k ] = $this->sanitise( $v, $k );
57 // $this->log( $raw[ $this->getSettingsKey() ][ $k ] );
58 }
59 }
60
61 // $this->log( $this->getSettingsKey() );
62 $check = update_option( $this->getSettingsKey(), $raw[ $this->getSettingsKey() ] );
63
64 if ( $check ) {
65 $this->reloadSettings();
66 $update_notice = $this->helper()->create_admin_notice( 'Settings successfully saved.', 'success', true );
67 self::$display_notices[] = $update_notice;
68 } else {
69 $update_notice = $this->helper()->create_admin_notice( 'No changes were made to your settings with your last save.', 'info', true );
70 self::$display_notices[] = $update_notice;
71 }
72 }
73
74 }
75
76 protected function sanitise( string $value, ?string $key = null ): string
77 {
78 // if ( $key == 'protection_text' ) {
79 // $this->log( [
80 // 'k' => $key,
81 // 'v' => $value,
82 // // 'config' => $this->getSetting( $key ),
83 // ] );
84 // }
85
86 return sanitize_text_field( $value );
87 }
88
89 }
90