PluginProbe ʕ •ᴥ•ʔ
Email Encoder – Protect Email Addresses and Phone Numbers / 2.0.5
Email Encoder – Protect Email Addresses and Phone Numbers v2.0.5
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 / core / includes / classes / class-email-encoder-bundle-ajax.php
email-encoder-bundle / core / includes / classes Last commit date
class-email-encoder-bundle-ajax.php 6 years ago class-email-encoder-bundle-helpers.php 6 years ago class-email-encoder-bundle-run-admin.php 6 years ago class-email-encoder-bundle-run.php 6 years ago class-email-encoder-bundle-settings.php 6 years ago class-email-encoder-bundle-validate.php 6 years ago index.php 6 years ago
class-email-encoder-bundle-ajax.php
122 lines
1 <?php
2
3 /**
4 * Class Email_Encoder_Ajax
5 *
6 * Thats where we bring the plugin to life
7 *
8 * @since 2.0.0
9 * @package EEB
10 * @author Ironikus <info@ironikus.com>
11 */
12
13 class Email_Encoder_Ajax{
14
15 /**
16 * The main page name for our admin page
17 *
18 * @var string
19 * @since 2.0.0
20 */
21 private $page_name;
22
23 /**
24 * The main page title for our admin page
25 *
26 * @var string
27 * @since 2.0.0
28 */
29 private $page_title;
30
31 /**
32 * Our Email_Encoder_Run constructor.
33 */
34 function __construct(){
35 $this->page_name = EEB()->settings->get_page_name();
36 $this->page_title = EEB()->settings->get_page_title();
37 $this->add_hooks();
38 }
39
40 /**
41 * Define all of our necessary hooks
42 */
43 private function add_hooks(){
44 add_action( 'wp_enqueue_scripts', array( $this, 'load_ajax_scripts_styles' ), EEB()->settings->get_hook_priorities( 'load_ajax_scripts_styles' ) );
45 add_action( 'admin_enqueue_scripts', array( $this, 'load_ajax_scripts_styles' ), EEB()->settings->get_hook_priorities( 'load_ajax_scripts_styles_admin' ) );
46
47 add_action( 'wp_ajax_eeb_get_email_form_output', array( $this, 'eeb_ajax_email_encoder_response' ) );
48 add_action( 'wp_ajax_nopriv_eeb_get_email_form_output', array( $this, 'eeb_ajax_email_encoder_response' ) );
49 }
50
51 /**
52 * ######################
53 * ###
54 * #### SCRIPTS & STYLES
55 * ###
56 * ######################
57 */
58
59 /**
60 * Register all necessary scripts and styles
61 *
62 * @since 2.0.0
63 */
64 public function load_ajax_scripts_styles() {
65 $display_encoder_form = (bool) EEB()->settings->get_setting( 'display_encoder_form', true, 'encoder_form' );
66
67 if( $display_encoder_form ){
68 $js_version_form = date( "ymd-Gis", filemtime( EEB_PLUGIN_DIR . 'core/includes/assets/js/encoder-form.js' ));
69 wp_enqueue_script( 'eeb-js-ajax-ef', EEB_PLUGIN_URL . 'core/includes/assets/js/encoder-form.js', array('jquery'), $js_version_form, true );
70 wp_localize_script( 'eeb-js-ajax-ef', 'eeb_ef', array(
71 'ajaxurl' => admin_url( 'admin-ajax.php' ),
72 'security' => wp_create_nonce( $this->page_name )
73 ));
74 }
75
76 }
77
78 /**
79 * ######################
80 * ###
81 * #### CORE LOGIC
82 * ###
83 * ######################
84 */
85
86 public function eeb_ajax_email_encoder_response(){
87 check_ajax_referer( $this->page_name, 'eebsec' );
88
89 $email = html_entity_decode( sanitize_email( $_POST['eebEmail'] ) );
90 $method = sanitize_text_field( $_POST['eebMethod'] );
91 $display = wp_kses_post( $_POST['eebDisplay'] );
92 $custom_class = (string) EEB()->settings->get_setting( 'class_name', true );
93 $protection_text = __( EEB()->settings->get_setting( 'protection_text', true ), 'email-encoder-bundle' );
94
95 if( empty( $display ) ) {
96 $display = $email;
97 } else {
98 $display = html_entity_decode($display);
99 }
100
101 $class_name = ' class="' . esc_attr( $custom_class ) . '"';
102 $mailto = '<a href="mailto:' . $email . '"'. $class_name . '>' . $display . '</a>';
103
104 switch( $method ){
105 case 'rot13':
106 $mailto = EEB()->validate->encode_ascii( $mailto, $protection_text );
107 break;
108 case 'escape':
109 $mailto = EEB()->validate->encode_escape( $mailto, $protection_text );
110 break;
111 case 'encode':
112 default:
113 $mailto = '<a href="mailto:' . antispambot( $email ) . '"'. $class_name . '>' . antispambot( $display ) . '</a>';
114 break;
115 }
116
117 echo apply_filters( 'eeb/ajax/encoder_form_response', $mailto );
118 exit;
119 }
120
121 }
122