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