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