PluginProbe
Captcha Code / 3.2
Captcha Code v3.2
trunk 2.7 2.8 2.9 3.0 3.1 3.2 3.3 3.31 3.32
captcha-code-authentication / wpCaptcha.php

wpCaptcha.php in Captcha Code 3.2, at wpCaptcha.php

1,247 lines 50.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 Plugin Name: Captcha Code
4 Description: Adds captcha to front-end forms.
5 Version: 3.2
6 Author: WebFactory Ltd
7 Author URI: https://www.webfactoryltd.com/
8 License: GPL2
9
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License, version 2, as
12 published by the Free Software Foundation.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
24 define('WP_CAPTCHA_CODE_URL', plugin_dir_url(__FILE__));
25 define('WP_CAPTCHA_CODE_DIR', dirname(__FILE__));
26 define('WP_CAPTCHA_CODE_OPTIONS', 'wp_captcha_code_options');
27
28 require_once WP_CAPTCHA_CODE_DIR . '/wf-flyout/wf-flyout.php';
29
30 class WP_Captcha_Code
31 {
32 static $version;
33 static $options;
34
35 static function init()
36 {
37 self::$version = self::get_plugin_version();
38 $options = self::load_options();
39
40 if (!session_id()) {
41 @session_start();
42 }
43
44 if (is_admin()) {
45 new wf_flyout(__FILE__);
46
47 add_action('admin_menu', array(__CLASS__, 'admin_menu'));
48 add_action('admin_enqueue_scripts', array(__CLASS__, 'admin_enqueue_scripts'));
49 add_action('admin_action_wp_captcha_code_install_wp301', array(__CLASS__, 'install_wp301'));
50 add_filter('admin_footer_text', array(__CLASS__, 'admin_footer_text'));
51 add_filter('plugin_action_links_' . plugin_basename(__FILE__), array(__CLASS__, 'plugin_action_links'));
52 } else {
53 if ($options['show_login'] == 'yes') {
54 add_action('login_form', array(__CLASS__, 'captcha_for_login'));
55 add_filter('login_errors', array(__CLASS__, 'captcha_login_errors'));
56 add_filter('login_redirect', array(__CLASS__, 'captcha_login_redirect'), 10, 3);
57 }
58
59 if ($options['show_comments'] == 'yes') {
60 add_action('comment_form_after_fields', array(__CLASS__, 'captcha_comment_form'), 1);
61 add_action('comment_form_logged_in_after', array(__CLASS__, 'captcha_comment_form'), 1);
62 add_filter('preprocess_comment', array(__CLASS__, 'captcha_comment_post'));
63 }
64
65 if ($options['show_registration'] == 'yes') {
66 add_action('register_form', array(__CLASS__, 'wp_captcha_register'));
67 add_action('register_post', array(__CLASS__, 'captcha_register_post'), 10, 3);
68 add_action('signup_extra_fields', array(__CLASS__, 'wp_captcha_register'));
69 add_filter('wpmu_validate_user_signup', array(__CLASS__, 'captcha_register_validate'));
70 }
71
72 if ($options['show_lost_password'] == 'yes') {
73 add_action('lostpassword_form', array(__CLASS__, 'captcha_lostpassword'));
74 add_action('lostpassword_post', array(__CLASS__, 'captcha_lostpassword_post'), 10, 3);
75 }
76 }
77 } // init
78
79
80 // add settings link to plugins page
81 static function plugin_action_links($links)
82 {
83 $settings_link = '<a href="' . admin_url('options-general.php?page=captcha-code-authentication') . '" title="Configure Captcha">Configure Captcha</a>';
84 $pro_link = '<a href="' . admin_url('options-general.php?page=captcha-code-authentication#get-pro') . '" title="Get PRO"><b>Get PRO</b></a>';
85
86 array_unshift($links, $settings_link);
87 array_unshift($links, $pro_link);
88
89 return $links;
90 } // plugin_action_links
91
92 static function admin_enqueue_scripts($hook)
93 {
94 if ('settings_page_captcha-code-authentication' == $hook) {
95 wp_enqueue_style('wp-jquery-ui-dialog');
96 wp_enqueue_style('wp-captcha-code-admin', WP_CAPTCHA_CODE_URL . 'css/wp-captcha-code.css', array(), self::$version);
97
98 wp_enqueue_script('jquery-ui-core');
99 wp_enqueue_script('jquery-ui-position');
100 wp_enqueue_script('jquery-effects-core');
101 wp_enqueue_script('jquery-effects-blind');
102 wp_enqueue_script('jquery-ui-dialog');
103
104 $js_localize = array(
105 'wp301_install_url' => add_query_arg(array('action' => 'wp_captcha_code_install_wp301', '_wpnonce' => wp_create_nonce('install_wp301'), 'rnd' => rand()), admin_url('admin.php'))
106 );
107 wp_enqueue_script('wp-captcha-code-admin', WP_CAPTCHA_CODE_URL . 'js/wp-captcha-code.js', array('jquery'), self::$version, true);
108 wp_localize_script('wp-captcha-code-admin', 'wp_captcha_code_vars', $js_localize);
109 }
110 } // admin_enqueue_scripts
111
112 static function is_plugin_page()
113 {
114 $current_screen = get_current_screen();
115
116 if ($current_screen->id == 'settings_page_captcha-code-authentication') {
117 return true;
118 } else {
119 return false;
120 }
121 } // is_plugin_page
122
123 static function admin_footer_text($text)
124 {
125 if (!self::is_plugin_page()) {
126 return $text;
127 }
128
129 $text = '<i class="wp-captcha-code-footer">Captcha Code v' . self::$version . ' <a href="' . self::generate_web_link('admin_footer') . '" title="Visit WP Captcha page for more info" target="_blank">WebFactory Ltd</a>. Please <a target="_blank" href="https://wordpress.org/support/plugin/captcha-code-authentication/reviews/#new-post" title="Rate the plugin">rate the plugin <span>�
130 �
131 �
132 �
133 �
134 </span></a> to help us spread the word. Thank you 🙌 from the WebFactory team!</i>';
135
136 return $text;
137 } // admin_footer_text
138
139 static function generate_web_link($placement = '', $page = '/', $params = array(), $anchor = '')
140 {
141 $base_url = 'https://getwpcaptcha.com';
142
143 if ('/' != $page) {
144 $page = '/' . trim($page, '/') . '/';
145 }
146 if ($page == '//') {
147 $page = '/';
148 }
149
150 $parts = array_merge(array('utm_source' => 'captcha-code-authentication', 'utm_content' => $placement), $params);
151
152 if (!empty($anchor)) {
153 $anchor = '#' . trim($anchor, '#');
154 }
155
156 $out = $base_url . $page . '?' . http_build_query($parts, '', '&amp;') . $anchor;
157
158 return $out;
159 } // generate_web_link
160
161 static function load_options()
162 {
163 $options = get_option(WP_CAPTCHA_CODE_OPTIONS, array());
164 $change = false;
165
166 if (!isset($options['meta'])) {
167 $options['meta'] = array('first_version' => self::$version, 'first_install' => current_time('timestamp', true));
168 $change = true;
169 }
170 if (!isset($options['dismissed_notices'])) {
171 $options['dismissed_notices'] = array();
172 $change = true;
173 }
174
175 if (!isset($options['options'])) {
176 $options['options'] = array();
177
178 $options['options']['show_login'] = get_option('wpcaptcha_login') !== false ? get_option('wpcaptcha_login') : 'yes';
179 $options['options']['show_registration'] = get_option('wpcaptcha_register') !== false ? get_option('wpcaptcha_register') : 'yes';
180 $options['options']['show_lost_password'] = get_option('wpcaptcha_lost') !== false ? get_option('wpcaptcha_lost') : 'yes';
181 $options['options']['show_comments'] = get_option('wpcaptcha_comments') !== false ? get_option('wpcaptcha_comments') : 'yes';
182 $options['options']['show_logged_in'] = get_option('wpcaptcha_registered') !== false ? get_option('wpcaptcha_registered') : 'no';
183 $options['options']['captcha_type'] = get_option('wpcaptcha_type') !== false ? get_option('wpcaptcha_type') : 'alphanumeric';
184 $options['options']['captcha_letters'] = get_option('wpcaptcha_letters') !== false ? get_option('wpcaptcha_letters') : 'capital';
185 $options['options']['total_no_of_characters'] = get_option('wpcaptcha_total_no_of_characters') !== false ? get_option('wpcaptcha_total_no_of_characters') : 3;
186
187 $change = true;
188 }
189
190 if (isset($_POST['submit']) && isset($_POST['wpcatpcha_update_admin_options_nonce'])) {
191 if (!wp_verify_nonce($_POST['wpcatpcha_update_admin_options_nonce'], 'wpcatpcha_update_admin_options')) {
192 echo '<div id="message" class="updated fade">
193 <p><strong>' . esc_html__('Sorry, your nonce did not verify.', 'captcha-code-authentication') . '</strong></p>
194 </div>';
195 } else {
196 if (isset($_POST['captcha_show_login'])) {
197 $options['options']['show_login'] = sanitize_text_field($_POST['captcha_show_login']);
198 }
199
200 if (isset($_POST['captcha_show_registration'])) {
201 $options['options']['show_registration'] = sanitize_text_field($_POST['captcha_show_registration']);
202 }
203
204 if (isset($_POST['captcha_show_lost_password'])) {
205 $options['options']['show_lost_password'] = sanitize_text_field($_POST['captcha_show_lost_password']);
206 }
207
208 if (isset($_POST['captcha_show_comments'])) {
209 $options['options']['show_comments'] = sanitize_text_field($_POST['captcha_show_comments']);
210 }
211
212 if (isset($_POST['captcha_show_logged_in'])) {
213 $options['options']['show_logged_in'] = sanitize_text_field($_POST['captcha_show_logged_in']);
214 }
215
216 if (isset($_POST['captcha_type'])) {
217 $options['options']['captcha_type'] = sanitize_text_field($_POST['captcha_type']);
218 }
219
220 if (isset($_POST['captcha_letters'])) {
221 $options['options']['captcha_letters'] = sanitize_text_field($_POST['captcha_letters']);
222 }
223
224 if (isset($_POST['total_no_of_characters'])) {
225 $options['options']['total_no_of_characters'] = sanitize_text_field($_POST['total_no_of_characters']);
226 }
227
228 $change = true;
229
230 echo '<div id="message" class="updated fade">
231 <p><strong>' . esc_html__('Options saved.', 'captcha-code-authentication') . '</strong></p>
232 </div>';
233 }
234 }
235
236
237 if ($change) {
238 update_option(WP_CAPTCHA_CODE_OPTIONS, $options, true);
239 }
240
241 self::$options = $options;
242 return $options['options'];
243 } // load_options
244
245 static function get_options()
246 {
247 return self::$options['options'];
248 } // get_options
249
250 static function update_options($key, $data)
251 {
252 if (false === in_array($key, array('meta', 'dismissed_notices', 'options'))) {
253 user_error('Unknown options key.', E_USER_ERROR);
254 return false;
255 }
256
257 self::$options[$key] = $data;
258 $tmp = update_option(WP_CAPTCHA_CODE_OPTIONS, self::$options);
259
260 return $tmp;
261 } // update_options
262
263 static function get_plugin_version()
264 {
265 $plugin_data = get_file_data(__FILE__, array('version' => 'Version'), 'plugin');
266
267 return $plugin_data['version'];
268 } // get_plugin_version
269
270 static function admin_menu()
271 {
272 add_options_page(
273 esc_html__('Captcha'),
274 esc_html__('Captcha'),
275 'manage_options',
276 'captcha-code-authentication',
277 array(__CLASS__, 'options_page')
278 );
279 } // admin_menu
280
281 static function captcha_for_login()
282 {
283 echo '<p class="login-form-captcha">
284 <label><b>' . esc_html__('Captcha', 'captcha-code-authentication') . ' </b> <span class="required">*</span></label>
285 <div style="clear:both;"></div><div style="clear:both;"></div>';
286 self::generate_captcha_image();
287
288 if (isset($_GET['captcha']) && $_GET['captcha'] == 'confirm_error') {
289 echo '<label style="color:#FF0000;" id="capt_err">' . esc_html($_SESSION['captcha_error']) . '</label><div style="clear:both;"></div>';;
290 $_SESSION['captcha_error'] = '';
291 }
292
293 echo '<label>' . esc_html__('Type the text displayed above', 'captcha-code-authentication') . ':</label>
294 <input id="captcha_code" name="captcha_code" size="15" type="text" tabindex="30" />
295 </p>';
296 return true;
297 } // captcha_for_login
298
299 static function captcha_login_errors($errors)
300 {
301 if (isset($_REQUEST['action']) && 'register' == sanitize_text_field($_REQUEST['action'])) {
302 return ($errors);
303 }
304
305 if (esc_html($_SESSION['captcha_code']) != sanitize_text_field($_REQUEST['captcha_code'])) {
306 return $errors . '<label id="capt_err" for="captcha_code_error">' . esc_html__('Captcha confirmation error!', 'captcha-code-authentication') . '</label>';
307 }
308 return $errors;
309 } // captcha_login_errors
310
311 static function captcha_login_redirect($url)
312 {
313 /* Captcha mismatch */
314 if (empty($_REQUEST['captcha_code']) || (isset($_SESSION['captcha_code']) && esc_html($_SESSION['captcha_code']) != sanitize_text_field($_REQUEST['captcha_code']))) {
315 $_SESSION['captcha_error'] = esc_html__('Incorrect captcha confirmation!', 'captcha-code-authentication');
316 wp_clear_auth_cookie();
317 return $_SERVER["REQUEST_URI"] . "/?captcha='confirm_error'";
318 }
319 /* Captcha match: take to the admin panel */ else {
320 return home_url('/wp-admin/');
321 }
322 } // captcha_login_redirect
323
324 static function captcha_comment_form()
325 {
326 $options = self::get_options();
327
328 if (is_user_logged_in() && $options['show_logged_in'] == 'yes') {
329 return true;
330 }
331
332 echo '<p class="comment-form-captcha">
333 <label><b>' . esc_html__('Captcha', 'captcha-code-authentication') . ' </b><span class="required">*</span></label>
334 <div style="clear:both;"></div><div style="clear:both;"></div>';
335 self::generate_captcha_image();
336 echo '<label>' . esc_html__('Type the text displayed above', 'captcha-code-authentication') . ':</label>
337 <input id="captcha_code" name="captcha_code" size="15" type="text" />
338 <div style="clear:both;"></div>
339 </p>';
340
341 remove_action('comment_form', 'captcha_comment_form');
342
343 return true;
344 } // captcha_comment_form
345
346 static function captcha_comment_post($comment)
347 {
348 $options = self::get_options();
349
350 if (is_user_logged_in() && $options['show_logged_in'] == 'yes') {
351 return $comment;
352 }
353
354 // skip captcha for comment replies from the admin menu
355 if (
356 isset($_REQUEST['action']) && $_REQUEST['action'] == 'replyto-comment' &&
357 (check_ajax_referer('replyto-comment', '_ajax_nonce', false) || check_ajax_referer('replyto-comment', '_ajax_nonce-replyto-comment', false))
358 ) {
359 // skip captcha
360 return $comment;
361 }
362
363 // Skip captcha for trackback or pingback
364 if ($comment['comment_type'] != '' && $comment['comment_type'] != 'comment') {
365 // skip captcha
366 return $comment;
367 }
368
369 // If captcha is empty
370 if (empty($_REQUEST['captcha_code']))
371 wp_die(esc_html__('CAPTCHA cannot be empty.', 'captcha-code-authentication'));
372
373 // captcha was matched
374 if ($_SESSION['captcha_code'] == $_REQUEST['captcha_code']) {
375 return ($comment);
376 } else {
377 wp_die(esc_html__('Error: Incorrect CAPTCHA. Press your browser\'s back button and try again.', 'captcha-code-authentication'));
378 }
379 } // captcha_comment_post
380
381 static function wp_captcha_register($default)
382 {
383 echo '<p class="register-form-captcha">
384 <label><b>' . esc_html__('Captcha', 'captcha-code-authentication') . ' </b><span class="required">*</span></label>
385 <div style="clear:both;"></div><div style="clear:both;"></div>';
386 self::generate_captcha_image();
387 echo '<label>' . esc_html__('Type the text displayed above', 'captcha-code-authentication') . ':</label>
388 <input id="captcha_code" name="captcha_code" size="15" type="text" />
389 </p>';
390 return true;
391 } // wp_captcha_register
392
393 static function captcha_register_post($login, $email, $errors)
394 {
395 // If captcha is blank - add error
396 if (isset($_REQUEST['captcha_code']) && "" == $_REQUEST['captcha_code']) {
397 $errors->add('captcha_blank', '<strong>' . esc_html__('ERROR', 'captcha-code-authentication') . '</strong>: ' . esc_html__('Please complete the CAPTCHA.', 'captcha-code-authentication'));
398 return $errors;
399 }
400
401 if (isset($_REQUEST['captcha_code']) && ($_SESSION['captcha_code'] == $_REQUEST['captcha_code'])) {
402 // captcha was matched
403 } else {
404 $errors->add('captcha_wrong', '<strong>' . esc_html__('ERROR', 'captcha-code-authentication') . '</strong>: ' . esc_html__('That CAPTCHA was incorrect.', 'captcha-code-authentication'));
405 }
406 return ($errors);
407 } // captcha_register_post
408
409 static function captcha_register_validate($results)
410 {
411 if (isset($_REQUEST['captcha_code']) && "" == $_REQUEST['captcha_code']) {
412 $results['errors']->add('captcha_blank', '<strong>' . esc_html__('ERROR', 'captcha-code-authentication') . '</strong>: ' . esc_html__('Please complete the CAPTCHA.', 'captcha-code-authentication'));
413 return $results;
414 }
415
416 if (isset($_REQUEST['captcha_code']) && ($_SESSION['captcha_code'] == $_REQUEST['captcha_code'])) {
417 // captcha was matched
418 } else {
419 $results['errors']->add('captcha_wrong', '<strong>' . esc_html__('ERROR', 'captcha-code-authentication') . '</strong>: ' . esc_html__('That CAPTCHA was incorrect.', 'captcha-code-authentication'));
420 }
421 return ($results);
422 } // captcha_register_validate
423
424 static function captcha_lostpassword($default)
425 {
426 echo '<p class="lost-form-captcha">
427 <label><b>' . esc_html__('Captcha', 'captcha-code-authentication') . ' </b><span class="required">*</span></label>
428 <div style="clear:both;"></div><div style="clear:both;"></div>';
429 self::generate_captcha_image();
430 echo '<label>' . esc_html__('Type the text displayed above', 'captcha-code-authentication') . ':</label>
431 <input id="captcha_code" name="captcha_code" size="15" type="text" />
432 </p>';
433 } // captcha_lostpassword
434
435 static function captcha_lostpassword_post()
436 {
437 if (isset($_REQUEST['user_login']) && "" == $_REQUEST['user_login'])
438 return;
439
440 // If captcha doesn't entered
441 if (empty($_REQUEST['captcha_code'])) {
442 wp_die(esc_html__('Please complete the CAPTCHA.', 'captcha-code-authentication'));
443 }
444
445 // Check entered captcha
446 if (isset($_REQUEST['captcha_code']) && ($_SESSION['captcha_code'] == $_REQUEST['captcha_code'])) {
447 return;
448 } else {
449 wp_die(esc_html__('Error: Incorrect CAPTCHA. Press your browser\'s back button and try again.', 'captcha-code-authentication'));
450 }
451 } // captcha_lostpassword_post
452
453 static function generate_captcha_image()
454 {
455 $image_width = 120;
456 $image_height = 40;
457
458 $options = self::get_options();
459
460 $font = WP_CAPTCHA_CODE_DIR . '/css/monofont.ttf';
461
462 if (!empty($options['captcha_type']) && $options['captcha_type'] == 'alphanumeric') {
463 switch ($options['captcha_letters']) {
464 case 'capital':
465 $possible_letters = '23456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
466 break;
467 case 'small':
468 $possible_letters = '23456789bcdfghjkmnpqrstvwxyz';
469 break;
470 case 'capitalsmall':
471 $possible_letters = '23456789bcdfghjkmnpqrstvwxyzABCEFGHJKMNPRSTVWXYZ';
472 break;
473 default:
474 $possible_letters = '23456789bcdfghjkmnpqrstvwxyz';
475 break;
476 }
477 } elseif (!empty($options['captcha_type']) && $options['captcha_type'] == 'alphabets') {
478 switch ($options['captcha_letters']) {
479 case 'capital':
480 $possible_letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
481 break;
482 case 'small':
483 $possible_letters = 'bcdfghjkmnpqrstvwxyz';
484 break;
485 case 'capitalsmall':
486 $possible_letters = 'bcdfghjkmnpqrstvwxyzABCEFGHJKMNPRSTVWXYZ';
487 break;
488 default:
489 $possible_letters = 'abcdefghijklmnopqrstuvwxyz';
490 break;
491 }
492 } elseif (!empty($options['captcha_type']) && $options['captcha_type'] == 'numbers') {
493 $possible_letters = '0123456789';
494 } else {
495 $possible_letters = '0123456789';
496 }
497 $random_dots = 0;
498 $random_lines = 20;
499 $captcha_text_color = "0x142864";
500 $captcha_noice_color = "0x142864";
501
502 $code = '';
503
504 $i = 0;
505 while ($i < $options['total_no_of_characters']) {
506 $code .= substr($possible_letters, mt_rand(0, strlen($possible_letters) - 1), 1);
507 $i++;
508 }
509
510 $font_size = $image_height * 0.75;
511 $image = @imagecreate($image_width, $image_height);
512
513 /* setting the background, text and noise colours here */
514 imagecolorallocate($image, 255, 255, 255);
515
516 $arr_text_color = self::captcha_hexrgb($captcha_text_color);
517 $text_color = imagecolorallocate(
518 $image,
519 $arr_text_color['red'],
520 $arr_text_color['green'],
521 $arr_text_color['blue']
522 );
523
524 $arr_noice_color = self::captcha_hexrgb($captcha_noice_color);
525 $image_noise_color = imagecolorallocate(
526 $image,
527 $arr_noice_color['red'],
528 $arr_noice_color['green'],
529 $arr_noice_color['blue']
530 );
531
532 /* generating the dots randomly in background */
533 for ($i = 0; $i < $random_dots; $i++) {
534 imagefilledellipse($image, mt_rand(0, $image_width), mt_rand(0, $image_height), 2, 3, $image_noise_color);
535 }
536
537 /* generating lines randomly in background of image */
538 for ($i = 0; $i < $random_lines; $i++) {
539 imageline($image, mt_rand(0, $image_width), mt_rand(0, $image_height), mt_rand(0, $image_width), mt_rand(0, $image_height), $image_noise_color);
540 }
541
542 /* create a text box and add 6 letters code in it */
543 $textbox = imagettfbbox($font_size, 0, $font, $code);
544 $x = ($image_width - $textbox[4]) / 2;
545 $y = ($image_height - $textbox[5]) / 2;
546 imagettftext($image, $font_size, 0, (int)$x, (int)$y, $text_color, $font, $code);
547
548 ob_start();
549 imagejpeg($image); //showing the image
550 echo '<img src="data:image/png;base64,' . esc_html(base64_encode(ob_get_clean())) . '" width="100">';
551 imagedestroy($image); //destroying the image instance
552 $_SESSION['captcha_code'] = $code;
553 } // generate_captcha_image
554
555 static function captcha_hexrgb($hexstr)
556 {
557 $int = hexdec($hexstr);
558
559 return array(
560 "red" => 0xFF & ($int >> 0x10),
561 "green" => 0xFF & ($int >> 0x8),
562 "blue" => 0xFF & $int
563 );
564 } // captcha_hexrgb
565
566 static function create_select_options($options, $selected = null, $output = true)
567 {
568 $out = "\n";
569
570 foreach ($options as $tmp) {
571 if ((is_array($selected) && in_array($tmp['val'], $selected)) || $selected == $tmp['val']) {
572 $out .= "<option selected=\"selected\" value=\"{$tmp['val']}\" " . (isset($tmp['class']) ? "class=\"{$tmp['class']}\"" : "") . ">{$tmp['label']}&nbsp;</option>\n";
573 } else {
574 $out .= "<option value=\"{$tmp['val']}\" " . (isset($tmp['class']) ? "class=\"{$tmp['class']}\"" : "") . ">{$tmp['label']}&nbsp;</option>\n";
575 }
576 }
577
578 if ($output) {
579 self::wp_kses_wf($out);
580 } else {
581 return $out;
582 }
583 } // create_select_options
584
585 static function options_page()
586 {
587 $options = self::get_options();
588
589 echo '<div class="wrap">';
590 echo '<h1><img src="' . esc_url(WP_CAPTCHA_CODE_URL . '/images/wp-captcha-logo.png') . '" alt="WP Captcha PRO" title="WP Captcha PRO"></h1>';
591 echo '<form method="post" action="">';
592 echo '<div id="wp_captcha_code_settings">';
593 wp_nonce_field('wpcatpcha_update_admin_options', 'wpcatpcha_update_admin_options_nonce');
594 echo '<table class="form-table">';
595 $captcha = array();
596 $captcha[] = array('val' => 'builtin', 'label' => 'Built-in Captcha');
597 $captcha[] = array('val' => 'icons', 'label' => 'Built-in Icon Captcha', 'class' => 'pro-option');
598 $captcha[] = array('val' => 'recaptchav2', 'label' => 'Google reCAPTCHA v2', 'class' => 'pro-option');
599 $captcha[] = array('val' => 'recaptchav3', 'label' => 'Google reCAPTCHA v3', 'class' => 'pro-option');
600 $captcha[] = array('val' => 'hcaptcha', 'label' => 'hCaptcha', 'class' => 'pro-option');
601 $captcha[] = array('val' => 'cloudflare', 'label' => 'Cloudflare Turnstile', 'class' => 'pro-option');
602
603 echo '<tr valign="top">
604 <th scope="row"><label for="captcha">Captcha:</label></th>
605 <td><select id="cc-captcha" name="">';
606 self::create_select_options($captcha, 'builtin');
607 echo '</select>';
608 echo '</td></tr>';
609 echo '<tr valign="top">
610 <th scope="row" style="width:260px;"><label for="captcha_letters">' . esc_html__('Select Captcha letters type', 'captcha-code-authentication') . ':</label></th>
611 <td>
612 <select id="captcha_letters" name="captcha_letters" style="margin:0;">
613 <option value="capital" ' . ($options['captcha_letters'] == 'capital' ? 'selected="selected"' : '') . '>' . esc_html__('Capital letters only', 'captcha-code-authentication') . '</option>
614 <option value="small" ' . ($options['captcha_letters'] == 'small' ? 'selected="selected"' : '') . '>' . esc_html__('Small letters only', 'captcha-code-authentication') . '</option>
615 <option value="capitalsmall" ' . ($options['captcha_letters'] == 'capitalsmall' ? 'selected="selected"' : '') . '>' . esc_html__('Capital & Small letters', 'captcha-code-authentication') . '</option>
616 </select>
617 </td>
618 </tr>
619 <tr valign="top">
620 <th scope="row"><label for="captcha_type">' . esc_html__('Select a Captcha type', 'captcha-code-authentication') . ':</label></th>
621 <td>
622 <select id="captcha_type" name="captcha_type" style="margin:0;">
623 <option value="alphanumeric" ' . ($options['captcha_type'] == 'alphanumeric' ? 'selected="selected"' : '') . '>' . esc_html__('Alphanumeric', 'captcha-code-authentication') . '</option>
624 <option value="alphabets" ' . ($options['captcha_type'] == 'alphabets' ? 'selected="selected"' : '') . '>' . esc_html__('Alphabets only', 'captcha-code-authentication') . '</option>
625 <option value="numbers" ' . ($options['captcha_type'] == 'numbers' ? 'selected="selected"' : '') . '>' . esc_html__('Numbers only', 'captcha-code-authentication') . '</option>
626 </select>
627 </td>
628 </tr>
629 <tr valign="top">
630 <th scope="row"><label for="total_no_of_characters">' . esc_html__('Total number of Captcha Characters', 'captcha-code-authentication') . ':</label></th>
631 <td>
632 <select id="total_no_of_characters" name="total_no_of_characters" style="margin:0;width: 50px;">';
633 for ($i = 3; $i <= 6; $i++) {
634 echo '<option value="' . intval($i) . '" ';
635 if ($options['total_no_of_characters'] == $i) echo 'selected="selected"';
636 echo '>' . intval($i) . '</option>';
637 }
638 echo '</select>
639 </td>
640 </tr>
641 </table>
642 <h3>' . esc_html__('Display Options', 'captcha-code-authentication') . '</h3>
643 <table class="form-table">
644 <tr valign="top">
645 <th scope="row" style="width:260px;"><label for="captcha_show_login">' . esc_html__("Enable Captcha for Login form", "captcha-code-authentication") . ':</label></th>
646 <td>
647 <select name="captcha_show_login" id="captcha_show_login" style="width:75px;margin:0;">
648 <option value="yes" ' . ($options['show_login'] == 'yes' ? 'selected="selected"' : '') . '>' . esc_html__('Yes', 'captcha-code-authentication') . '</option>
649 <option value="no" ' . ($options['show_login'] != 'yes' ? 'selected="selected"' : '') . '>' . esc_html__('No', 'captcha-code-authentication') . '</option>
650 </select>
651 </td>
652 </tr>
653 <tr valign="top">
654 <th scope="row"><label for="captcha_show_registration">' . esc_html__('Enable Captcha for Register form', 'captcha-code-authentication') . ':</label></th>
655 <td>
656 <select name="captcha_show_registration" id="captcha_show_registration" style="width:75px;margin:0;">
657 <option value="yes" ' . ($options['show_registration'] == 'yes' ? 'selected="selected"' : '') . '>' . esc_html__('Yes', 'captcha-code-authentication') . '</option>
658 <option value="no" ' . ($options['show_registration'] != 'yes' ? 'selected="selected"' : '') . '>' . esc_html__('No', 'captcha-code-authentication') . '</option>
659 </select>
660 </td>
661 </tr>
662 <tr valign="top">
663 <th scope="row"><label for="captcha_show_lost_password">' . esc_html__('Enable Captcha for Lost Password form', 'captcha-code-authentication') . ':</label></th>
664 <td>
665 <select name="captcha_show_lost_password" id="captcha_show_lost_password" style="width:75px;margin:0;">
666 <option value="yes" ' . ($options['show_lost_password'] == 'yes' ? 'selected="selected"' : '') . '>' . esc_html__('Yes', 'captcha-code-authentication') . '</option>
667 <option value="no" ' . ($options['show_lost_password'] != 'yes' ? 'selected="selected"' : '') . '>' . esc_html__('No', 'captcha-code-authentication') . '</option>
668 </select>
669 </td>
670 </tr>
671 <tr valign="top">
672 <th scope="row"><label for="captcha_show_comments">' . esc_html__('Enable Captcha for Comments form', 'captcha-code-authentication') . ':</label></th>
673 <td>
674 <select name="captcha_show_comments" id="captcha_show_comments" style="width:75px;margin:0;">
675 <option value="yes" ' . ($options['show_comments'] == 'yes' ? 'selected="selected"' : '') . '>' . esc_html__('Yes', 'captcha-code-authentication') . '</option>
676 <option value="no" ' . ($options['show_comments'] != 'yes' ? 'selected="selected"' : '') . '>' . esc_html__('No', 'captcha-code-authentication') . '</option>
677 </select>
678 </td>
679 </tr>
680 <tr valign="top">
681 <th scope="row"><label for="captcha_show_logged_in">' . esc_html__('Hide Captcha for logged in users', 'captcha-code-authentication') . ':</label></th>
682 <td>
683 <select name="captcha_show_logged_in" id="captcha_show_logged_in" style="width:75px;margin:0;">
684 <option value="yes" ' . ($options['show_logged_in'] == 'yes' ? 'selected="selected"' : '') . '>' . esc_html__('Yes', 'captcha-code-authentication') . '</option>
685 <option value="no" ' . ($options['show_logged_in'] != 'yes' ? 'selected="selected"' : '') . '>' . esc_html__('No', 'captcha-code-authentication') . '</option>
686 </select>
687 </td>
688 </tr>
689 <tr height="60">
690 <td>';
691 submit_button();
692 echo '</td>
693 <td></td>
694 </tr>
695 </table>';
696
697 echo '</div>';
698
699 echo '<div id="wp_captcha_code_sidebar">';
700 echo '<div class="sidebar-box pro-ad-box">
701 <p class="text-center"><a href="#" data-pro-feature="cc-sidebar-box-logo" class="open-pro-dialog">
702 <img src="' . esc_url(WP_CAPTCHA_CODE_URL . '/images/wp-captcha-logo.png') . '" alt="WP Captcha PRO" title="WP Captcha PRO"></a><br><b>PRO version is here! Grab the launch discount.</b></p>
703 <ul class="plain-list">
704 <li>7 Types of Captcha + GDPR Compatibility</li>
705 <li>Login Page Customization - Visual &amp; URL</li>
706 <li>Advanced Login Page Protection</li>
707 <li>Email Based Two Factor Authentication (2FA)</li>
708 <li>Advanced Firewall + Cloud Blacklists</li>
709 <li>Country Blocking (whitelist &amp; blacklist)</li>
710 <li>Temporary Access Links</li>
711 <li>Recovery URL - You Can Never Get Locked Out</li>
712 <li>Licenses &amp; Sites Manager (remote SaaS dashboard)</li>
713 <li>White-label Mode</li>
714 <li>Complete Codeless Plugin Rebranding</li>
715 <li>Email support from plugin developers</li>
716 </ul>
717
718 <p class="text-center"><a href="#" class="open-pro-dialog button button-buy" data-pro-feature="cc-sidebar-box">Get PRO Now</a></p>
719 </div>';
720
721 if (!defined('EPS_REDIRECT_VERSION') && !defined('WF301_PLUGIN_FILE')) {
722 echo '<div class="sidebar-box pro-ad-box box-301">
723 <h3 class="textcenter"><b>Problems with redirects?<br>Moving content around or changing posts\' URL?<br>Old URLs giving you problems?<br><br><u>Improve your SEO &amp; manage all redirects in one place!</u></b></h3>
724
725 <p class="text-center"><a href="#" class="install-wp301">
726 <img src="' . esc_url(WP_CAPTCHA_CODE_URL . '/images/wp-301-logo.png') . '" alt="WP 301 Redirects" title="WP 301 Redirects"></a></p>
727
728 <p class="text-center"><a href="#" class="button button-buy install-wp301">Install and activate the <u>free</u> WP 301 Redirects plugin</a></p>
729
730 <p><a href="https://wordpress.org/plugins/eps-301-redirects/" target="_blank">WP 301 Redirects</a> is a free WP plugin maintained by the same team as this WP Captcha plugin. It has <b>+250,000 users, 5-star rating</b>, and is hosted on the official WP repository.</p>
731 </div>';
732 }
733
734 echo '<div class="sidebar-box" style="margin-top: 35px; margin-bottom: 35px;">
735 <p>Need help? Ask on the <a href="https://wordpress.org/support/plugin/captcha-code-authentication/" target="_blank">support forum</a>. We\'ll answer ASAP!</p>
736 <p>Please <a href="https://wordpress.org/support/plugin/captcha-code-authentication/reviews/#new-post" target="_blank">rate the plugin �
737 �
738 �
739 �
740 �
741 </a> to <b>keep it up-to-date &amp; maintained</b>. It only takes a second to rate. Thank you! 👋</p>
742 </div>';
743 echo '</div>';
744
745 echo '</form>';
746
747 echo ' <div id="wp-captcha-code-pro-dialog" style="display: none;" title="WP Captcha PRO is here!"><span class="ui-helper-hidden-accessible"><input type="text"/></span>
748
749 <div class="center logo"><a href="https://getwpcaptcha.com/?ref=wp-captcha-code-free-pricing-table" target="_blank"><img src="' . esc_url(WP_CAPTCHA_CODE_URL . '/images/wp-captcha-logo.png') . '" alt="WP Captcha PRO" title="WP Captcha PRO"></a><br>
750
751 <span>Grab the limited PRO <b>Launch Discount</b></span>
752 </div>
753
754 <table id="wp-captcha-code-pro-table">
755 <tr>
756 <td class="center">Personal License</td>
757 <td class="center">Team License</td>
758 <td class="center">Agency License</td>
759 </tr>
760
761 <tr class="prices">
762 <td class="center"><span><del>$59</del> $49</span> <b>/year</b></td>
763 <td class="center"><span><del>$119</del> $99</span> <b>/year</b></td>
764 <td class="center"><span><del>$149</del> $119</span> <b>/year</b></td>
765 </tr>
766
767 <tr>
768 <td><span class="dashicons dashicons-yes"></span><b>1 Site License</b> ($49 per site)</td>
769 <td><span class="dashicons dashicons-yes"></span><b>5 Sites License</b> ($20 per site)</td>
770 <td><span class="dashicons dashicons-yes"></span><b>100 Sites License</b> ($1.2 per site)</td>
771 </tr>
772
773 <tr>
774 <td><span class="dashicons dashicons-yes"></span>All Plugin Features</td>
775 <td><span class="dashicons dashicons-yes"></span>All Plugin Features</td>
776 <td><span class="dashicons dashicons-yes"></span>All Plugin Features</td>
777 </tr>
778
779 <tr>
780 <td><span class="dashicons dashicons-yes"></span>7 Types of Captcha</td>
781 <td><span class="dashicons dashicons-yes"></span>7 Types of Captcha</td>
782 <td><span class="dashicons dashicons-yes"></span>7 Types of Captcha</td>
783 </tr>
784
785 <tr>
786 <td><span class="dashicons dashicons-yes"></span>Advanced Firewall + Cloud Blacklists</td>
787 <td><span class="dashicons dashicons-yes"></span>Advanced Firewall + Cloud Blacklists</td>
788 <td><span class="dashicons dashicons-yes"></span>Advanced Firewall + Cloud Blacklists</td>
789 </tr>
790
791 <tr>
792 <td><span class="dashicons dashicons-yes"></span>Login Page Customization</td>
793 <td><span class="dashicons dashicons-yes"></span>Login Page Customization</td>
794 <td><span class="dashicons dashicons-yes"></span>Login Page Customization</td>
795 </tr>
796
797 <tr>
798 <td><span class="dashicons dashicons-yes"></span>Email Based 2FA</td>
799 <td><span class="dashicons dashicons-yes"></span>Email Based 2FA</td>
800 <td><span class="dashicons dashicons-yes"></span>Email Based 2FA</td>
801 </tr>
802
803 <tr>
804 <td><span class="dashicons dashicons-yes"></span>Temporary Access Links</td>
805 <td><span class="dashicons dashicons-yes"></span>Temporary Access Links</td>
806 <td><span class="dashicons dashicons-yes"></span>Temporary Access Links</td>
807 </tr>
808
809 <tr>
810 <td><span class="dashicons dashicons-yes"></span>Country Blocking</td>
811 <td><span class="dashicons dashicons-yes"></span>Country Blocking</td>
812 <td><span class="dashicons dashicons-yes"></span>Country Blocking</td>
813 </tr>
814
815 <tr>
816 <td><span class="dashicons dashicons-yes"></span>SaaS Dashboard</td>
817 <td><span class="dashicons dashicons-yes"></span>SaaS Dashboard</td>
818 <td><span class="dashicons dashicons-yes"></span>SaaS Dashboard</td>
819 </tr>
820
821 <tr>
822 <td><span class="dashicons dashicons-no"></span>White-label Mode</td>
823 <td><span class="dashicons dashicons-yes"></span>White-label Mode</td>
824 <td><span class="dashicons dashicons-yes"></span>White-label Mode</td>
825 </tr>
826
827 <tr>
828 <td><span class="dashicons dashicons-no"></span>Full Plugin Rebranding</td>
829 <td><span class="dashicons dashicons-no"></span>Full Plugin Rebranding</td>
830 <td><span class="dashicons dashicons-yes"></span>Full Plugin Rebranding</td>
831 </tr>
832
833 <tr>
834 <td><a class="button button-buy" data-href-org="https://getwpcaptcha.com/buy/?product=personal-yearly-launch&ref=pricing-table" href="https://getwpcaptcha.com/buy/?product=personal-yearly-launch&ref=pricing-table" target="_blank"><del>$59</del> $49 <small>/y</small><br>BUY NOW</a>
835 <br>or <a class="button-buy" data-href-org="https://getwpcaptcha.com/buy/?product=personal-ltd-launch&ref=pricing-table" href="https://getwpcaptcha.com/buy/?product=personal-ltd-launch&ref=pricing-table" target="_blank">only <del>$99</del> $79 for a lifetime license</a></td>
836 <td><a class="button button-buy" data-href-org="https://getwpcaptcha.com/buy/?product=team-yearly-launch&ref=pricing-table" href="https://getwpcaptcha.com/buy/?product=team-yearly-launch&ref=pricing-table" target="_blank"><del>$119</del> $99 <small>/y</small><br>BUY NOW</a></td>
837 <td><a class="button button-buy" data-href-org="https://getwpcaptcha.com/buy/?product=agency-yearly-launch&ref=pricing-table" href="https://getwpcaptcha.com/buy/?product=agency-yearly-launch&ref=pricing-table" target="_blank"><del>$149</del> $119 <small>/y</small><br>BUY NOW</a></td>
838 </tr>
839
840 </table>
841
842 <div class="center footer"><b>100% No-Risk Money Back Guarantee!</b> If you don\'t like the plugin over the next 7 days, we will happily refund 100% of your money. No questions asked! Payments are processed by our merchant of records - <a href="https://paddle.com/" target="_blank">Paddle</a>.</div>
843 </div>';
844 echo '</div>';
845 } // options_page
846
847 static function install_wp301()
848 {
849 check_ajax_referer('install_wp301');
850
851 if (false === current_user_can('administrator')) {
852 wp_die('Sorry, you have to be an admin to run this action.');
853 }
854
855 $plugin_slug = 'eps-301-redirects/eps-301-redirects.php';
856 $plugin_zip = 'https://downloads.wordpress.org/plugin/eps-301-redirects.latest-stable.zip';
857
858 @include_once ABSPATH . 'wp-admin/includes/plugin.php';
859 @include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
860 @include_once ABSPATH . 'wp-admin/includes/plugin-install.php';
861 @include_once ABSPATH . 'wp-admin/includes/file.php';
862 @include_once ABSPATH . 'wp-admin/includes/misc.php';
863 echo '<style>
864 body{
865 font-family: sans-serif;
866 font-size: 14px;
867 line-height: 1.5;
868 color: #444;
869 }
870 </style>';
871
872 echo '<div style="margin: 20px; color:#444;">';
873 echo 'If things are not done in a minute <a target="_parent" href="' . esc_url(admin_url('plugin-install.php?s=301%20redirects%20webfactory&tab=search&type=term')) . '">install the plugin manually via Plugins page</a><br><br>';
874 echo 'Starting ...<br><br>';
875
876 wp_cache_flush();
877 $upgrader = new Plugin_Upgrader();
878 echo 'Check if WP 301 Redirects is already installed ... <br />';
879 if (self::is_plugin_installed($plugin_slug)) {
880 echo 'WP 301 Redirects is already installed! <br /><br />Making sure it\'s the latest version.<br />';
881 $upgrader->upgrade($plugin_slug);
882 $installed = true;
883 } else {
884 echo 'Installing WP 301 Redirects.<br />';
885 $installed = $upgrader->install($plugin_zip);
886 }
887 wp_cache_flush();
888
889 if (!is_wp_error($installed) && $installed) {
890 echo 'Activating WP 301 Redirects.<br />';
891 $activate = activate_plugin($plugin_slug);
892
893 if (is_null($activate)) {
894 echo 'WP 301 Redirects Activated.<br />';
895
896 echo '<script>setTimeout(function() { top.location = "' . esc_url(admin_url('options-general.php?page=eps_redirects')) . '"; }, 1000);</script>';
897 echo '<br>If you are not redirected in a few seconds - <a href="' . esc_url(admin_url('options-general.php?page=eps_redirects')) . '" target="_parent">click here</a>.';
898 }
899 } else {
900 echo 'Could not install WP 301 Redirects. You\'ll have to <a target="_parent" href="' . esc_url(admin_url('plugin-install.php?s=301%20redirects%20webfactory&tab=search&type=term')) . '">download and install manually</a>.';
901 }
902
903 echo '</div>';
904 } // install_wp301
905
906 static function is_plugin_installed($slug)
907 {
908 if (!function_exists('get_plugins')) {
909 require_once ABSPATH . 'wp-admin/includes/plugin.php';
910 }
911 $all_plugins = get_plugins();
912
913 if (!empty($all_plugins[$slug])) {
914 return true;
915 } else {
916 return false;
917 }
918 } // is_plugin_installed
919
920 static function wp_kses_wf($html)
921 {
922 add_filter('safe_style_css', function ($styles) {
923 $styles_wf = array(
924 'text-align',
925 'margin',
926 'color',
927 'float',
928 'border',
929 'background',
930 'background-color',
931 'border-bottom',
932 'border-bottom-color',
933 'border-bottom-style',
934 'border-bottom-width',
935 'border-collapse',
936 'border-color',
937 'border-left',
938 'border-left-color',
939 'border-left-style',
940 'border-left-width',
941 'border-right',
942 'border-right-color',
943 'border-right-style',
944 'border-right-width',
945 'border-spacing',
946 'border-style',
947 'border-top',
948 'border-top-color',
949 'border-top-style',
950 'border-top-width',
951 'border-width',
952 'caption-side',
953 'clear',
954 'cursor',
955 'direction',
956 'font',
957 'font-family',
958 'font-size',
959 'font-style',
960 'font-variant',
961 'font-weight',
962 'height',
963 'letter-spacing',
964 'line-height',
965 'margin-bottom',
966 'margin-left',
967 'margin-right',
968 'margin-top',
969 'overflow',
970 'padding',
971 'padding-bottom',
972 'padding-left',
973 'padding-right',
974 'padding-top',
975 'text-decoration',
976 'text-indent',
977 'vertical-align',
978 'width',
979 'display',
980 );
981
982 foreach ($styles_wf as $style_wf) {
983 $styles[] = $style_wf;
984 }
985 return $styles;
986 });
987
988 $allowed_tags = wp_kses_allowed_html('post');
989 $allowed_tags['input'] = array(
990 'type' => true,
991 'style' => true,
992 'class' => true,
993 'id' => true,
994 'checked' => true,
995 'disabled' => true,
996 'name' => true,
997 'size' => true,
998 'placeholder' => true,
999 'value' => true,
1000 'data-*' => true,
1001 'size' => true,
1002 'disabled' => true
1003 );
1004
1005 $allowed_tags['textarea'] = array(
1006 'type' => true,
1007 'style' => true,
1008 'class' => true,
1009 'id' => true,
1010 'checked' => true,
1011 'disabled' => true,
1012 'name' => true,
1013 'size' => true,
1014 'placeholder' => true,
1015 'value' => true,
1016 'data-*' => true,
1017 'cols' => true,
1018 'rows' => true,
1019 'disabled' => true,
1020 'autocomplete' => true
1021 );
1022
1023 $allowed_tags['select'] = array(
1024 'type' => true,
1025 'style' => true,
1026 'class' => true,
1027 'id' => true,
1028 'checked' => true,
1029 'disabled' => true,
1030 'name' => true,
1031 'size' => true,
1032 'placeholder' => true,
1033 'value' => true,
1034 'data-*' => true,
1035 'multiple' => true,
1036 'disabled' => true
1037 );
1038
1039 $allowed_tags['option'] = array(
1040 'type' => true,
1041 'style' => true,
1042 'class' => true,
1043 'id' => true,
1044 'checked' => true,
1045 'disabled' => true,
1046 'name' => true,
1047 'size' => true,
1048 'placeholder' => true,
1049 'value' => true,
1050 'selected' => true,
1051 'data-*' => true
1052 );
1053
1054 $allowed_tags['optgroup'] = array(
1055 'type' => true,
1056 'style' => true,
1057 'class' => true,
1058 'id' => true,
1059 'checked' => true,
1060 'disabled' => true,
1061 'name' => true,
1062 'size' => true,
1063 'placeholder' => true,
1064 'value' => true,
1065 'selected' => true,
1066 'data-*' => true,
1067 'label' => true
1068 );
1069
1070 $allowed_tags['a'] = array(
1071 'href' => true,
1072 'data-*' => true,
1073 'class' => true,
1074 'style' => true,
1075 'id' => true,
1076 'target' => true,
1077 'data-*' => true,
1078 'role' => true,
1079 'aria-controls' => true,
1080 'aria-selected' => true,
1081 'disabled' => true
1082 );
1083
1084 $allowed_tags['div'] = array(
1085 'style' => true,
1086 'class' => true,
1087 'id' => true,
1088 'data-*' => true,
1089 'role' => true,
1090 'aria-labelledby' => true,
1091 'value' => true,
1092 'aria-modal' => true,
1093 'tabindex' => true
1094 );
1095
1096 $allowed_tags['li'] = array(
1097 'style' => true,
1098 'class' => true,
1099 'id' => true,
1100 'data-*' => true,
1101 'role' => true,
1102 'aria-labelledby' => true,
1103 'value' => true,
1104 'aria-modal' => true,
1105 'tabindex' => true
1106 );
1107
1108 $allowed_tags['span'] = array(
1109 'style' => true,
1110 'class' => true,
1111 'id' => true,
1112 'data-*' => true,
1113 'aria-hidden' => true
1114 );
1115
1116 $allowed_tags['style'] = array(
1117 'class' => true,
1118 'id' => true,
1119 'type' => true,
1120 'style' => true
1121 );
1122
1123 $allowed_tags['fieldset'] = array(
1124 'class' => true,
1125 'id' => true,
1126 'type' => true,
1127 'style' => true
1128 );
1129
1130 $allowed_tags['link'] = array(
1131 'class' => true,
1132 'id' => true,
1133 'type' => true,
1134 'rel' => true,
1135 'href' => true,
1136 'media' => true,
1137 'style' => true
1138 );
1139
1140 $allowed_tags['form'] = array(
1141 'style' => true,
1142 'class' => true,
1143 'id' => true,
1144 'method' => true,
1145 'action' => true,
1146 'data-*' => true,
1147 'style' => true
1148 );
1149
1150 $allowed_tags['script'] = array(
1151 'class' => true,
1152 'id' => true,
1153 'type' => true,
1154 'src' => true,
1155 'style' => true
1156 );
1157
1158 $allowed_tags['table'] = array(
1159 'class' => true,
1160 'id' => true,
1161 'type' => true,
1162 'cellpadding' => true,
1163 'cellspacing' => true,
1164 'border' => true,
1165 'style' => true
1166 );
1167
1168 $allowed_tags['canvas'] = array(
1169 'class' => true,
1170 'id' => true,
1171 'style' => true
1172 );
1173
1174 echo wp_kses($html, $allowed_tags);
1175
1176 add_filter('safe_style_css', function ($styles) {
1177 $styles_wf = array(
1178 'text-align',
1179 'margin',
1180 'color',
1181 'float',
1182 'border',
1183 'background',
1184 'background-color',
1185 'border-bottom',
1186 'border-bottom-color',
1187 'border-bottom-style',
1188 'border-bottom-width',
1189 'border-collapse',
1190 'border-color',
1191 'border-left',
1192 'border-left-color',
1193 'border-left-style',
1194 'border-left-width',
1195 'border-right',
1196 'border-right-color',
1197 'border-right-style',
1198 'border-right-width',
1199 'border-spacing',
1200 'border-style',
1201 'border-top',
1202 'border-top-color',
1203 'border-top-style',
1204 'border-top-width',
1205 'border-width',
1206 'caption-side',
1207 'clear',
1208 'cursor',
1209 'direction',
1210 'font',
1211 'font-family',
1212 'font-size',
1213 'font-style',
1214 'font-variant',
1215 'font-weight',
1216 'height',
1217 'letter-spacing',
1218 'line-height',
1219 'margin-bottom',
1220 'margin-left',
1221 'margin-right',
1222 'margin-top',
1223 'overflow',
1224 'padding',
1225 'padding-bottom',
1226 'padding-left',
1227 'padding-right',
1228 'padding-top',
1229 'text-decoration',
1230 'text-indent',
1231 'vertical-align',
1232 'width'
1233 );
1234
1235 foreach ($styles_wf as $style_wf) {
1236 if (($key = array_search($style_wf, $styles)) !== false) {
1237 unset($styles[$key]);
1238 }
1239 }
1240 return $styles;
1241 });
1242 } // is_plugin_installed
1243 } // WP_Captcha_Code
1244
1245 add_action('init', array('WP_Captcha_Code', 'init'));
1246
1247