PluginProbe ʕ •ᴥ•ʔ
Email Encoder – Protect Email Addresses and Phone Numbers / 2.4.3
Email Encoder – Protect Email Addresses and Phone Numbers v2.4.3
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 4 months ago AdminEnqueue.php 4 months ago AdminHelp.php 4 months ago AdminMenu.php 4 months ago AdminMetaBox.php 4 months ago PluginActionLinks.php 4 months ago
Admin.php
91 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 /** @var array< string > $display_notices */
12 public static array $display_notices = [];
13
14
15 public function boot(): void
16 {
17 ( new AdminEnqueue() )->boot();
18 ( new AdminMenu() )->boot(); // AdminMetaBox & AdminHelp are added here
19 ( new PluginActionLinks() )->boot();
20
21 add_action( 'init', [ $this, 'register_hooks' ] );
22 }
23
24 # ADMIN METHODS ============================================================
25
26 public function register_hooks(): void
27 {
28 add_action( 'admin_init', [ $this, 'save_settings_admin' ] );
29 }
30
31
32
33
34
35 public function save_settings_admin(): void
36 {
37 // $this->log( __METHOD__ );
38 if ( !isset( $_POST[ $this->getPageName() . '_nonce' ] ) ) {
39 return;
40 };
41
42 if ( ! wp_verify_nonce( $_POST[ $this->getPageName() . '_nonce' ], $this->getPageName() ) ) {
43 wp_die( __( 'You don\'t have permission to update these settings.', 'email-encoder-bundle' ) );
44 }
45
46 if ( ! current_user_can( $this->getAdminCap( 'admin-update-settings' ) ) ) {
47 wp_die( __( 'You don\'t have permission to update these settings.', 'email-encoder-bundle' ) );
48 }
49
50 $raw = wp_unslash( $_POST );
51
52 if ( isset( $raw[ $this->getSettingsKey() ] ) && is_array( $raw[ $this->getSettingsKey() ] ) ) {
53
54 //Strip duplicate slashes before saving
55 foreach ( $raw[ $this->getSettingsKey() ] as $k => $v ) {
56 if ( is_string( $v ) ) {
57 $raw[ $this->getSettingsKey() ][ $k ] = $this->sanitise( $v, $k );
58 // $this->log( $raw[ $this->getSettingsKey() ][ $k ] );
59 }
60 }
61
62 // $this->log( $this->getSettingsKey() );
63 $check = update_option( $this->getSettingsKey(), $raw[ $this->getSettingsKey() ] );
64
65 if ( $check ) {
66 $this->reloadSettings();
67 $update_notice = $this->helper()->create_admin_notice( 'Settings successfully saved.', 'success', true );
68 self::$display_notices[] = $update_notice;
69 } else {
70 $update_notice = $this->helper()->create_admin_notice( 'No changes were made to your settings with your last save.', 'info', true );
71 self::$display_notices[] = $update_notice;
72 }
73 }
74
75 }
76
77 protected function sanitise( string $value, ?string $key = null ): string
78 {
79 // if ( $key == 'protection_text' ) {
80 // $this->log( [
81 // 'k' => $key,
82 // 'v' => $value,
83 // // 'config' => $this->getSetting( $key ),
84 // ] );
85 // }
86
87 return sanitize_text_field( $value );
88 }
89
90 }
91