PluginProbe ʕ •ᴥ•ʔ
Email Encoder – Protect Email Addresses and Phone Numbers / 2.3.5
Email Encoder – Protect Email Addresses and Phone Numbers v2.3.5
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 / Validate / EncoderForm.php
email-encoder-bundle / src / Validate Last commit date
EncoderForm.php 6 months ago Encoding.php 6 months ago Filters.php 6 months ago Validate.php 6 months ago
EncoderForm.php
193 lines
1 <?php
2
3 namespace OnlineOptimisation\EmailEncoderBundle\Validate;
4
5 use OnlineOptimisation\EmailEncoderBundle\Traits\PluginHelper;
6
7 class EncoderForm {
8
9 use PluginHelper;
10
11 public function boot(): void {
12 }
13
14
15 /**
16 * ######################
17 * ###
18 * #### ENCODER FORM
19 * ###
20 * ######################
21 */
22
23 /**
24 * Get the encoder form (to use as a demo, like on the options page)
25 * @return string
26 */
27 public function get_encoder_form() {
28 $powered_by_setting = (bool) $this->getSetting( 'powered_by', true, 'encoder_form' );
29
30 //shorten circle
31 if (
32 ! $this->helper()->is_page( $this->getPageName() )
33 && ! (bool) $this->getSetting( 'encoder_form_frontend', true, 'encoder_form' )
34 ) {
35 return apply_filters('eeb_form_content_inactive', '' );
36 }
37
38 $powered_by = '';
39 if ($powered_by_setting) {
40 $powered_by .= '<p class="powered-by">' . __('Powered by free', 'email-encoder-bundle') . ' <a rel="external" href="https://wordpress.org/plugins/email-encoder-bundle/">Email Encoder</a></p>';
41 }
42
43 $smethods = array(
44 'rot13' => __( 'Rot13 (Javascript)', 'email-encoder-bundle' ),
45 'escape' => __( 'Escape (Javascript)', 'email-encoder-bundle' ),
46 'encode' => __( 'Encode (HTML)', 'email-encoder-bundle' ),
47 );
48 $method_options = '';
49 $selected = false;
50 foreach( $smethods as $method_name => $name ) {
51 $method_options .= '<option value="' . $method_name . '"' . ( ($selected === false ) ? ' selected="selected"' : '') . '>' . $name . '</option>';
52 $selected = true;
53 }
54
55 $labels = array(
56 'email' => __( 'Email Address:', 'email-encoder-bundle' ),
57 'display' => __( 'Display Text:', 'email-encoder-bundle' ),
58 'mailto' => __( 'Mailto Link:', 'email-encoder-bundle' ),
59 'method' => __( 'Encoding Method:', 'email-encoder-bundle' ),
60 'create_link' => __( 'Create Protected Mail Link &gt;&gt;', 'email-encoder-bundle' ),
61 'output' => __( 'Protected Mail Link (code):', 'email-encoder-bundle' ),
62 'powered_by' => $powered_by,
63 );
64
65 extract( $labels );
66
67 $form = <<<FORM
68 <div class="eeb-form">
69 <form>
70 <fieldset>
71 <div class="input">
72 <table>
73 <tbody>
74 <tr>
75 <th><label for="eeb-email">{$email}</label></th>
76 <td><input type="text" class="regular-text" id="eeb-email" name="eeb-email" /></td>
77 </tr>
78 <tr>
79 <th><label for="eeb-display">{$display}</label></th>
80 <td><input type="text" class="regular-text" id="eeb-display" name="eeb-display" /></td>
81 </tr>
82 <tr>
83 <th>{$mailto}</th>
84 <td><span class="eeb-example"></span></td>
85 </tr>
86 <tr>
87 <th><label for="eeb-encode-method">{$method}</label></th>
88 <td><select id="eeb-encode-method" name="eeb-encode-method" class="postform">
89 {$method_options}
90 </select>
91 <input type="button" id="eeb-ajax-encode" name="eeb-ajax-encode" value="{$create_link}" />
92 </td>
93 </tr>
94 </tbody>
95 </table>
96 </div>
97 <div class="eeb-output">
98 <table>
99 <tbody>
100 <tr>
101 <th><label for="eeb-encoded-output">{$output}</label></th>
102 <td><textarea class="large-text node" id="eeb-encoded-output" name="eeb-encoded-output" cols="50" rows="4"></textarea></td>
103 </tr>
104 </tbody>
105 </table>
106 </div>
107 {$powered_by}
108 </fieldset>
109 </form>
110 </div>
111 FORM;
112
113 // apply filters
114 $form = apply_filters('eeb_form_content', $form, $labels, $powered_by_setting );
115
116 return $form;
117 }
118
119
120 public function is_post_excluded( $post_id = null ) {
121
122 $return = false;
123 $skip_posts = (string) $this->getSetting( 'skip_posts', true );
124 if ( ! empty( $skip_posts ) ) {
125
126 if ( empty( $post_id ) ) {
127 global $post;
128 if ( ! empty( $post ) ) {
129 $post_id = $post->ID;
130 }
131 } else {
132 $post_id = intval( $post_id );
133 }
134
135 $exclude_pages = explode( ',', $skip_posts );
136
137 if ( is_array( $exclude_pages ) ) {
138 $exclude_pages_validated = array();
139
140 foreach( $exclude_pages as $spost_id ) {
141 $spost_id = trim($spost_id);
142 if ( is_numeric( $spost_id ) ) {
143 $exclude_pages_validated[] = intval( $spost_id );
144 }
145 }
146
147 if ( in_array( $post_id, $exclude_pages_validated ) ) {
148 $return = true;
149 }
150 }
151
152 }
153
154 return apply_filters( 'eeb/validate/is_post_excluded', $return, $post_id, $skip_posts );
155 }
156
157 /**
158 * Filter if to exclude specific URL parameters from filtering
159 *
160 * @since 2.2.0
161 * @param array $parameters
162 * @return boolean
163 */
164 public function is_query_parameter_excluded( $parameters = null ) {
165
166 if ( $parameters === null ) {
167 $parameters = $_GET;
168 }
169
170 $return = false;
171 $skip_query_parameters = (string) $this->getSetting( 'skip_query_parameters', true );
172 if ( ! empty( $skip_query_parameters ) && ! empty( $parameters ) ) {
173
174 $excluded_parameters = explode( ',', $skip_query_parameters );
175
176 if ( is_array( $excluded_parameters ) ) {
177
178 foreach( $excluded_parameters as $param ) {
179 $param = trim($param);
180
181 if ( isset( $parameters[ $param ] ) ) {
182 $return = true;
183 break;
184 }
185 }
186
187 }
188
189 }
190
191 return apply_filters( 'eeb/validate/is_query_parameter_excluded', $return, $parameters );
192 }
193 }