Core
1 year ago
Util
1 year ago
Check_Email_Encode_Tab.php
1 year ago
Check_Email_SMTP_Tab.php
1 year ago
class-check-email-header-parser.php
1 year ago
class-check-email-log-autoloader.php
1 year ago
class-check-email-newsletter.php
1 year ago
deactivate-feedback.php
1 year ago
helper-function.php
1 year ago
install.php
1 year ago
Check_Email_Encode_Tab.php
170 lines
| 1 | <?php namespace CheckEmail; |
| 2 | defined( 'ABSPATH' ) || exit; // Exit if accessed directly |
| 3 | |
| 4 | /** |
| 5 | * @class Check_Email_SMTP_Tab |
| 6 | * @since 2.0 |
| 7 | */ |
| 8 | /** |
| 9 | * Its functionality is inspired by Email encode address |
| 10 | */ |
| 11 | use CheckEmail\Core\Auth; |
| 12 | class Check_Email_Encode_Tab { |
| 13 | |
| 14 | private $encode_options; |
| 15 | private $is_enable; |
| 16 | |
| 17 | public function __construct() { |
| 18 | add_action( 'init', array( $this, 'init' ) ); |
| 19 | } |
| 20 | |
| 21 | public function init() { |
| 22 | if ( ! is_admin() ) { |
| 23 | return; |
| 24 | } |
| 25 | $this->setup_vars(); |
| 26 | |
| 27 | add_action( 'check_mail_email_encode', array($this, 'load_email_encode_settings')); |
| 28 | add_action('admin_init', array($this, 'check_mail_encode_submission_handler')); |
| 29 | |
| 30 | } |
| 31 | |
| 32 | |
| 33 | /** |
| 34 | * Get smtp options |
| 35 | * |
| 36 | * @return void |
| 37 | * @since 1.0.12 |
| 38 | */ |
| 39 | public function setup_vars(){ |
| 40 | $this->encode_options = get_option('check-email-email-encode-options', true); |
| 41 | } |
| 42 | |
| 43 | public function load_email_encode_settings(){ |
| 44 | |
| 45 | if (isset($this->encode_options['email_using']) && !empty( $this->encode_options['email_using'] ) ) { |
| 46 | $email_using_radio = $this->encode_options['email_using']; |
| 47 | }else{ |
| 48 | $email_using_radio = 'filters'; |
| 49 | } |
| 50 | if (isset($this->encode_options['email_technique']) && !empty( $this->encode_options['email_technique'] ) ) { |
| 51 | $email_technique_radio = $this->encode_options['email_technique']; |
| 52 | }else{ |
| 53 | $email_technique_radio = 'html_entities'; |
| 54 | } |
| 55 | |
| 56 | ?> |
| 57 | |
| 58 | <form action="" method="post" > |
| 59 | <div> |
| 60 | <table class="form-table" role="presentation"> |
| 61 | <thead> |
| 62 | <tr> |
| 63 | <th scope="row"><label for="check-email-email-encode-options-is_enable" class="check-email-opt-labels"><?php esc_html_e( 'Email Encoder', 'check-email' ); ?></label></th> |
| 64 | <td> |
| 65 | <input class="" type="checkbox" id="check-email-email-encode-options-is_enable" name="check-email-email-encode-options[is_enable]" value="1" <?php echo (isset($this->encode_options['is_enable'])) && $this->encode_options['is_enable'] ? "checked" : ''; ?>> |
| 66 | </td> |
| 67 | </tr> |
| 68 | <tr class="check-email-etr" style="<?php echo (isset($this->encode_options['is_enable'])) && $this->encode_options['is_enable'] ? "" : 'display:none;'; ?>"> |
| 69 | <th scope="row" style="padding-left: 10px;;"><label class="check-email-opt-labels"><?php esc_html_e( 'Search for emails using', 'check-email' ); ?></label></th> |
| 70 | <td> |
| 71 | <label for="check-email-email-encode-options-filter" class="check-email-opt-labels-encoder"> |
| 72 | <input id="check-email-email-encode-options-filter" type="radio" name="check-email-email-encode-options[email_using]" value="filters" <?php echo $email_using_radio == 'filters' ? "checked" : ''; ?>> |
| 73 | <?php esc_html_e( 'WordPress Filters', 'check-email' ); ?></label> |
| 74 | <small><?php esc_html_e( 'Scan for protection in wordpress filters only.', 'check-email' ); ?></small> |
| 75 | |
| 76 | <label for="check-email-email-encode-options-full_page" class="check-email-opt-labels-encoder"> |
| 77 | <input id="check-email-email-encode-options-full_page" type="radio" name="check-email-email-encode-options[email_using]" value="full_page" <?php echo $email_using_radio == 'full_page' ? "checked" : ''; ?>> |
| 78 | <?php esc_html_e( 'Full-Page Scanner', 'check-email' ); ?></label> |
| 79 | <small><?php esc_html_e( 'Scan for protection on entire page.', 'check-email' ); ?></small> |
| 80 | </td> |
| 81 | </tr> |
| 82 | <tr class="check-email-etr" style="<?php echo (isset($this->encode_options['is_enable'])) && $this->encode_options['is_enable'] ? "" : 'display:none;'; ?>"> |
| 83 | <th scope="row" style="padding-left: 10px;;"><label class="check-email-opt-labels"><?php esc_html_e( 'Protect emails using', 'check-email' ); ?></label></th> |
| 84 | <td> |
| 85 | <label for="check-email-email-encode-options-html-entities" class="check-email-opt-labels-encoder"> |
| 86 | <input id="check-email-email-encode-options-html-entities" type="radio" name="check-email-email-encode-options[email_technique]" value="html_entities" <?php echo $email_technique_radio == 'html_entities' ? "checked" : ''; ?>> |
| 87 | <?php esc_html_e( 'Html Entities', 'check-email' ); ?></label> |
| 88 | <small><?php esc_html_e( 'Provides reliable protection and suits most situations.', 'check-email' ); ?></small> |
| 89 | |
| 90 | |
| 91 | |
| 92 | <label for="check-email-email-encode-options-css_direction" class="check-email-opt-labels-encoder"> |
| 93 | <input id="check-email-email-encode-options-css_direction" type="radio" name="check-email-email-encode-options[email_technique]" value="css_direction" <?php echo $email_technique_radio == 'css_direction' ? "checked" : ''; ?>> <?php esc_html_e( 'CSS Direction', 'check-email' ); ?></label> |
| 94 | <small><?php esc_html_e( 'Shields from intelligent bots without requiring JavaScript.', 'check-email' ); ?></small> |
| 95 | |
| 96 | <label for="check-email-email-encode-options-rot_13" class="check-email-opt-labels-encoder"> |
| 97 | <input id="check-email-email-encode-options-rot_13" type="radio" name="check-email-email-encode-options[email_technique]" value="rot_13" <?php echo $email_technique_radio == 'rot_13' ? "checked" : ''; ?>> <?php esc_html_e( 'ROT13 Encoding', 'check-email' ); ?></label> |
| 98 | <small><?php esc_html_e( 'Shields from intelligent bots but needs JavaScript.', 'check-email' ); ?></small> |
| 99 | |
| 100 | <label for="check-email-email-encode-options-rot_47" class="check-email-opt-labels-encoder"> |
| 101 | <input id="check-email-email-encode-options-rot_47" type="radio" name="check-email-email-encode-options[email_technique]" value="rot_47" <?php echo $email_technique_radio == 'rot_47' ? "checked" : ''; ?>> |
| 102 | <?php esc_html_e( 'Polymorphous ROT47/CSS', 'check-email' ); ?></label> |
| 103 | <small><?php esc_html_e( 'Top-tier security against sophisticated bots, but JavaScript is necessary.', 'check-email' ); ?></small> |
| 104 | </td> |
| 105 | </tr> |
| 106 | <tr> |
| 107 | <th scope="row"><label class="check-email-opt-labels"><?php esc_html_e( 'Mobile / Phone Encoder', 'check-email' ); ?></label></th> |
| 108 | <td> |
| 109 | <p><?php esc_html_e( 'Other content ( like phone numbers ) can be protected using [checkmail-encode] shortcode', 'check-email' ); ?></p></br> |
| 110 | <code> |
| 111 | [checkmail-encode]+1 (555) 123-4569[/checkmail-encode]</code> <br/> |
| 112 | <code> |
| 113 | [checkmail-encode link="tel:+15551234569"]+1 (555) 123-4569[/checkmail-encode] |
| 114 | </code> |
| 115 | </td> |
| 116 | </tr> |
| 117 | </thead> |
| 118 | |
| 119 | </table> |
| 120 | </div> |
| 121 | <?php wp_nonce_field('check_mail_email_encode_nonce','check_mail_email_encode_nonce'); ?> |
| 122 | <p class="submit"><input type="submit" name="check_mail_email_encode_submit" id="check_mail_email_encode_submit" class="button button-primary" value="<?php esc_attr_e( 'Save', 'check-email' ); ?>"></p> |
| 123 | </form> |
| 124 | <?php |
| 125 | } |
| 126 | |
| 127 | /** |
| 128 | * Save SMTP options |
| 129 | * |
| 130 | * @return void |
| 131 | * @since 1.0.12 |
| 132 | */ |
| 133 | |
| 134 | public function check_mail_encode_submission_handler(){ |
| 135 | |
| 136 | if(isset($_POST['check_mail_email_encode_submit']) && $_POST['check_mail_email_encode_submit'] == 'Save'){ |
| 137 | if(!isset($_POST['check_mail_email_encode_nonce'])){ |
| 138 | return; |
| 139 | } |
| 140 | |
| 141 | if ( !wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['check_mail_email_encode_nonce'] ) ), 'check_mail_email_encode_nonce' ) ){ |
| 142 | return; |
| 143 | } |
| 144 | |
| 145 | if ( ! current_user_can( 'manage_check_email' ) ) { |
| 146 | return; |
| 147 | } |
| 148 | $email_encode_option['is_enable'] = 0; |
| 149 | if ( isset($_POST['check-email-email-encode-options']['is_enable'] ) ) { |
| 150 | $email_encode_option['is_enable'] = 1; |
| 151 | } |
| 152 | if ( isset($_POST['check-email-email-encode-options']['email_using'] ) ) { |
| 153 | $email_encode_option['email_using'] = sanitize_text_field( wp_unslash( $_POST['check-email-email-encode-options']['email_using'] ) ); |
| 154 | }else{ |
| 155 | $email_encode_option['email_using'] = 'filters'; |
| 156 | } |
| 157 | if ( isset($_POST['check-email-email-encode-options']['email_technique'] ) ) { |
| 158 | $email_encode_option['email_technique'] = sanitize_text_field( wp_unslash( $_POST['check-email-email-encode-options']['email_technique'] ) ); |
| 159 | }else{ |
| 160 | $email_encode_option['email_technique'] = 'html_entities'; |
| 161 | } |
| 162 | |
| 163 | update_option('check-email-email-encode-options', $email_encode_option); |
| 164 | |
| 165 | wp_safe_redirect(admin_url('admin.php?page=check-email-settings&tab=email-encode')); |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | } |
| 170 |