PluginProbe ʕ •ᴥ•ʔ
reCaptcha by BestWebSoft / 1.32
reCaptcha by BestWebSoft v1.32
1.79 1.80 1.82 1.83 1.84 1.85 1.86 1.87 trunk 1.01 1.02 1.03 1.04 1.05 1.06 1.07 1.08 1.09 1.10 1.11 1.12 1.13 1.14 1.15 1.16 1.17 1.18 1.19 1.20 1.21 1.22 1.23 1.24 1.25 1.26 1.27 1.28 1.29 1.30 1.31 1.32 1.33 1.34 1.35 1.36 1.37 1.38 1.39 1.40 1.41 1.42 1.43 1.44 1.45 1.46 1.47 1.48 1.49 1.50 1.51 1.52 1.53 1.54 1.55 1.56 1.57 1.58 1.59 1.60 1.61 1.62 1.63 1.64 1.65 1.66 1.67 1.68 1.70 1.71 1.72 1.73 1.74 1.75 1.78
google-captcha / google-captcha.php
google-captcha Last commit date
bws_menu 8 years ago css 8 years ago includes 8 years ago js 8 years ago languages 8 years ago lib 8 years ago google-captcha.php 8 years ago readme.txt 8 years ago screenshot-1.png 8 years ago screenshot-2.png 8 years ago screenshot-3.png 8 years ago screenshot-4.png 8 years ago screenshot-5.png 8 years ago screenshot-6.png 8 years ago screenshot-7.png 8 years ago screenshot-8.png 8 years ago screenshot-9.png 8 years ago
google-captcha.php
1109 lines
1 <?php
2 /*
3 Plugin Name: Google Captcha (reCAPTCHA) by BestWebSoft
4 Plugin URI: https://bestwebsoft.com/products/wordpress/plugins/google-captcha/
5 Description: Protect WordPress website forms from spam entries with Google Captcha (reCaptcha).
6 Author: BestWebSoft
7 Text Domain: google-captcha
8 Domain Path: /languages
9 Version: 1.32
10 Author URI: https://bestwebsoft.com/
11 License: GPLv3 or later
12 */
13
14 /* © Copyright 2017 BestWebSoft ( https://support.bestwebsoft.com )
15
16 This program is free software; you can redistribute it and/or modify
17 it under the terms of the GNU General Public License, version 2, as
18 published by the Free Software Foundation.
19
20 This program is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 GNU General Public License for more details.
24
25 You should have received a copy of the GNU General Public License
26 along with this program; if not, write to the Free Software
27 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 */
29
30 require_once( dirname( __FILE__ ) . '/includes/forms.php' );
31
32 /* Add menu page */
33 if ( ! function_exists( 'gglcptch_admin_menu' ) ) {
34 function gglcptch_admin_menu() {
35 global $submenu, $wp_version, $gglcptch_plugin_info;
36
37 $settings_page = add_menu_page( __( 'Google Captcha Settings', 'google-captcha' ), 'Google Captcha', 'manage_options', 'google-captcha.php', 'gglcptch_add_settings_page', 'none' );
38
39 add_submenu_page( 'google-captcha.php', __( 'Google Captcha Settings', 'google-captcha' ), __( 'Settings', 'google-captcha' ), 'manage_options', 'google-captcha.php', 'gglcptch_add_settings_page' );
40
41 $whitelist_page = add_submenu_page( 'google-captcha.php', __( 'Google Captcha Whitelist', 'google-captcha' ), __( 'Whitelist', 'google-captcha' ), 'manage_options', 'google-captcha-whitelist.php', 'gglcptch_add_settings_page' );
42
43 add_submenu_page( 'google-captcha.php', 'BWS Panel', 'BWS Panel', 'manage_options', 'gglcptch-bws-panel', 'bws_add_menu_render' );
44
45 if ( isset( $submenu['google-captcha.php'] ) ) {
46 $submenu['google-captcha.php'][] = array(
47 '<span style="color:#d86463"> ' . __( 'Upgrade to Pro', 'google-captcha' ) . '</span>',
48 'manage_options',
49 'https://bestwebsoft.com/products/wordpress/plugins/google-captcha/?k=b850d949ccc1239cab0da315c3c822ab&pn=109&v=' . $gglcptch_plugin_info["Version"] . '&wp_v=' . $wp_version );
50 }
51
52 add_action( "load-{$settings_page}", 'gglcptch_add_tabs' );
53 add_action( "load-{$whitelist_page}", 'gglcptch_add_tabs' );
54 }
55 }
56
57 if ( ! function_exists( 'gglcptch_plugins_loaded' ) ) {
58 function gglcptch_plugins_loaded() {
59 /* Internationalization, first(!) */
60 load_plugin_textdomain( 'google-captcha', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
61 }
62 }
63
64 if ( ! function_exists( 'gglcptch_init' ) ) {
65 function gglcptch_init() {
66 global $gglcptch_plugin_info, $gglcptch_options, $gglcptch_ip_in_whitelist;;
67
68 require_once( dirname( __FILE__ ) . '/bws_menu/bws_include.php' );
69 bws_include_init( plugin_basename( __FILE__ ) );
70
71 if ( empty( $gglcptch_plugin_info ) ) {
72 if ( ! function_exists( 'get_plugin_data' ) ) {
73 require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
74 }
75 $gglcptch_plugin_info = get_plugin_data( __FILE__ );
76 }
77
78 /* Function check if plugin is compatible with current WP version */
79 bws_wp_min_version_check( plugin_basename( __FILE__ ), $gglcptch_plugin_info, '3.9' );
80
81 $is_admin = is_admin() && ! defined( 'DOING_AJAX' );
82 /* Call register settings function */
83 if ( ! $is_admin || ( isset( $_GET['page'] ) && 'google-captcha.php' == $_GET['page'] ) ) {
84 register_gglcptch_settings();
85 }
86
87 if ( ! isset( $gglcptch_ip_in_whitelist ) ) {
88 $gglcptch_ip_in_whitelist = gglcptch_whitelisted_ip();
89 }
90
91 /* Add hooks */
92 if ( ! $is_admin && ! empty( $gglcptch_options['public_key'] ) && ! empty( $gglcptch_options['private_key'] ) ) {
93 gglcptch_add_actions();
94 }
95 }
96 }
97
98 /**
99 * Activation plugin function
100 */
101 if ( ! function_exists( 'gglcptch_plugin_activate' ) ) {
102 function gglcptch_plugin_activate( $networkwide ) {
103 /* Activation function for network, check if it is a network activation - if so, run the activation function for each blog id */
104 if ( is_multisite() ) {
105 switch_to_blog( 1 );
106 register_uninstall_hook( __FILE__, 'gglcptch_delete_options' );
107 restore_current_blog();
108 } else {
109 register_uninstall_hook( __FILE__, 'gglcptch_delete_options' );
110 }
111 }
112 }
113
114 if ( ! function_exists( 'gglcptch_admin_init' ) ) {
115 function gglcptch_admin_init() {
116 global $bws_plugin_info, $gglcptch_plugin_info;
117
118 if ( empty( $bws_plugin_info ) ) {
119 $bws_plugin_info = array( 'id' => '109', 'version' => $gglcptch_plugin_info["Version"] );
120 }
121
122 }
123 }
124
125 /* Add google captcha styles */
126 if ( ! function_exists( 'gglcptch_add_admin_script_styles' ) ) {
127 function gglcptch_add_admin_script_styles() {
128 global $gglcptch_plugin_info;
129
130 /* css for displaing an icon */
131 wp_enqueue_style( 'gglcptch_admin_page_stylesheet', plugins_url( 'css/admin_page.css', __FILE__ ) );
132
133 if ( isset( $_REQUEST['page'] ) && ( 'google-captcha.php' == $_REQUEST['page'] || 'google-captcha-whitelist.php' == $_REQUEST['page'] ) ) {
134 wp_enqueue_style( 'gglcptch_stylesheet', plugins_url( 'css/style.css', __FILE__ ), array(), $gglcptch_plugin_info['Version'] );
135 wp_enqueue_script( 'gglcptch_admin_script', plugins_url( 'js/admin_script.js', __FILE__ ), array( 'jquery', 'jquery-ui-accordion' ), $gglcptch_plugin_info['Version'] );
136
137 bws_enqueue_settings_scripts();
138 bws_plugins_include_codemirror();
139 }
140 }
141 }
142
143 /* Add google captcha admin styles for test key */
144 if ( ! function_exists( 'gglcptch_admin_footer' ) ) {
145 function gglcptch_admin_footer() {
146 global $gglcptch_plugin_info, $gglcptch_options;
147 if ( isset( $_REQUEST['page'] ) && 'google-captcha.php' == $_REQUEST['page'] ) {
148
149 /* update $gglcptch_options */
150 register_gglcptch_settings();
151
152 $api_url = gglcptch_get_api_url();
153
154 /* for gglcptch test key */
155 if ( isset( $gglcptch_options['recaptcha_version'] ) && in_array( $gglcptch_options['recaptcha_version'], array( 'v2', 'invisible' ) ) ) {
156 $deps = ( ! empty( $gglcptch_options['disable_submit'] ) ) ? array( 'gglcptch_pre_api' ) : array( 'jquery' );
157 } else {
158 $deps = array();
159 }
160 wp_register_script( 'gglcptch_api', $api_url,$deps, $gglcptch_plugin_info['Version'], true );
161 gglcptch_add_scripts();
162 }
163 }
164 }
165
166 /**
167 * Remove dublicate scripts
168 */
169 if ( ! function_exists( 'gglcptch_remove_dublicate_scripts' ) ) {
170 function gglcptch_remove_dublicate_scripts() {
171 global $wp_scripts;
172
173 if ( ! is_object( $wp_scripts ) || empty( $wp_scripts ) ) {
174 return false;
175 }
176
177 foreach ( $wp_scripts->registered as $script_name => $args ) {
178 if ( preg_match( "|google\.com/recaptcha/api\.js|", $args->src ) && 'gglcptch_api' != $script_name ) {
179 /* remove a previously enqueued script */
180 wp_dequeue_script( $script_name );
181 }
182 }
183 }
184 }
185
186 /**
187 * Add google captcha styles
188 */
189 if ( ! function_exists( 'gglcptch_add_styles' ) ) {
190 function gglcptch_add_styles() {
191 global $gglcptch_plugin_info, $gglcptch_options;
192 wp_enqueue_style( 'gglcptch', plugins_url( 'css/gglcptch.css', __FILE__ ), array(), $gglcptch_plugin_info["Version"] );
193
194 if ( defined( 'BWS_ENQUEUE_ALL_SCRIPTS' ) && BWS_ENQUEUE_ALL_SCRIPTS ) {
195 if ( ! wp_script_is( 'gglcptch_api', 'registered' ) ) {
196 $api_url = gglcptch_get_api_url();
197 if ( isset( $gglcptch_options['recaptcha_version'] ) && in_array( $gglcptch_options['recaptcha_version'], array( 'v2', 'invisible' ) ) ) {
198 $deps = ( ! empty( $gglcptch_options['disable_submit'] ) ) ? array( 'gglcptch_pre_api' ) : array( 'jquery' );
199 } else {
200 $deps = array();
201 }
202
203 wp_register_script( 'gglcptch_api', $api_url, $deps, $gglcptch_plugin_info["Version"], true );
204 add_action( 'wp_footer', 'gglcptch_add_scripts' );
205 if (
206 '1' == $gglcptch_options['login_form'] ||
207 '1' == $gglcptch_options['reset_pwd_form'] ||
208 '1' == $gglcptch_options['registration_form']
209 )
210 add_action( 'login_footer', 'gglcptch_add_scripts' );
211 }
212 }
213 }
214 }
215
216 /**
217 * Add google captcha js scripts
218 */
219 if ( ! function_exists( 'gglcptch_add_scripts' ) ) {
220 function gglcptch_add_scripts() {
221 global $gglcptch_options, $gglcptch_plugin_info;
222
223 if ( empty( $gglcptch_options ) ) {
224 register_gglcptch_settings();
225 }
226
227 if ( isset( $gglcptch_options['recaptcha_version'] ) && 'v1' != $gglcptch_options['recaptcha_version'] ) {
228 gglcptch_remove_dublicate_scripts();
229 if ( ! empty( $gglcptch_options['disable_submit'] ) ) {
230 wp_enqueue_script( 'gglcptch_pre_api', plugins_url( 'js/pre-api-script.js', __FILE__ ), array( 'jquery'), $gglcptch_plugin_info['Version'], true );
231 wp_localize_script( 'gglcptch_pre_api', 'gglcptch_pre', array(
232 'messages' => array(
233 'in_progress' => __( 'Please wait until Google reCAPTCHA is loaded.', 'google-captcha' ),
234 'timeout' => __( 'Failed to load Google reCAPTCHA. Please check your internet connection and reload this page.', 'google-captcha' )
235 ),
236 'custom_callback' => apply_filters( 'gglcptch_custom_callback', '' )
237 ) );
238 }
239 }
240
241 wp_enqueue_script( 'gglcptch_script', plugins_url( 'js/script.js', __FILE__ ), array( 'jquery', 'gglcptch_api' ), $gglcptch_plugin_info["Version"], true );
242
243 $version = $gglcptch_options['recaptcha_version'] == 'v2' ? '_v2' : '';
244
245 wp_localize_script( 'gglcptch_script', 'gglcptch', array(
246 'options' => array(
247 'version' => $gglcptch_options['recaptcha_version'],
248 'sitekey' => $gglcptch_options['public_key'],
249 'theme' => $gglcptch_options[ 'theme' . $version ],
250 'error' => sprintf( '<strong>%s</strong>:&nbsp;%s', __( 'Warning', 'google-captcha' ), gglcptch_get_message( 'multiple_blocks' ) )
251 ),
252 'vars' => array(
253 'visibility' => ( 'login_footer' == current_filter() )
254 )
255 ) );
256 }
257 }
258
259 if ( ! function_exists( 'gglcptch_pagination_callback' ) ) {
260 function gglcptch_pagination_callback( $content ) {
261 $content .= "if ( typeof Recaptcha != 'undefined' || typeof grecaptcha != 'undefined' ) { gglcptch.prepare(); }";
262 return $content;
263 }
264 }
265
266 /**
267 * Add the "async" attribute to our registered script.
268 */
269 if ( ! function_exists( 'gglcptch_add_async_attribute' ) ) {
270 function gglcptch_add_async_attribute( $tag, $handle ) {
271 if ( 'gglcptch_api' == $handle ) {
272 $tag = str_replace( ' src', ' data-cfasync="false" async="async" defer="defer" src', $tag );
273 }
274 return $tag;
275 }
276 }
277
278 if ( ! function_exists( 'gglcptch_create_table' ) ) {
279 function gglcptch_create_table() {
280 global $wpdb;
281 require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
282 $whitelist_exist = $wpdb->query( "SHOW TABLES LIKE '{$wpdb->prefix}gglcptch_whitelist';" );
283 if ( ! $whitelist_exist ) {
284 $sql = "CREATE TABLE `{$wpdb->prefix}gglcptch_whitelist` (
285 `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
286 `ip` CHAR(31) NOT NULL,
287 `ip_from_int` BIGINT,
288 `ip_to_int` BIGINT,
289 `add_time` DATETIME,
290 PRIMARY KEY (`id`)
291 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;";
292 dbDelta( $sql );
293
294 /* add unique key */
295 if ( 0 == $wpdb->query( "SHOW KEYS FROM `{$wpdb->prefix}gglcptch_whitelist` WHERE Key_name='ip'" ) ) {
296 $wpdb->query( "ALTER TABLE `{$wpdb->prefix}gglcptch_whitelist` ADD UNIQUE(`ip`);" );
297 }
298 }
299 }
300 }
301
302 /* Google catpcha settings */
303 if ( ! function_exists( 'register_gglcptch_settings' ) ) {
304 function register_gglcptch_settings() {
305 global $gglcptch_options, $bws_plugin_info, $gglcptch_plugin_info;
306
307 $plugin_db_version = '0.1';
308
309 /* Install the option defaults */
310 if ( ! get_option( 'gglcptch_options' ) ) {
311 add_option( 'gglcptch_options', gglcptch_get_default_options() );
312 }
313 /* Get options from the database */
314 $gglcptch_options = get_option( 'gglcptch_options' );
315
316 /* Array merge incase this version has added new options */
317 if ( ! isset( $gglcptch_options['plugin_option_version'] ) || $gglcptch_options['plugin_option_version'] != $gglcptch_plugin_info["Version"] ) {
318 $gglcptch_options = array_merge( gglcptch_get_default_options(), $gglcptch_options );
319 $gglcptch_options['plugin_option_version'] = $gglcptch_plugin_info["Version"];
320 /* show pro features */
321 $gglcptch_options['hide_premium_options'] = array();
322
323 if ( is_multisite() ) {
324 switch_to_blog( 1 );
325 register_uninstall_hook( __FILE__, 'gglcptch_delete_options' );
326 restore_current_blog();
327 } else {
328 register_uninstall_hook( __FILE__, 'gglcptch_delete_options' );
329 }
330 update_option( 'gglcptch_options', $gglcptch_options );
331 }
332 /* Update tables when update plugin and tables changes*/
333 if (
334 ! isset( $gglcptch_options['plugin_db_version'] ) ||
335 ( isset( $gglcptch_options['plugin_db_version'] ) && $gglcptch_options['plugin_db_version'] != $plugin_db_version )
336 ) {
337 if ( ! isset( $gglcptch_options['plugin_db_version'] ) ) {
338 gglcptch_create_table();
339 }
340 $gglcptch_options['plugin_db_version'] = $plugin_db_version;
341 update_option( 'gglcptch_options', $gglcptch_options );
342 }
343 }
344 }
345
346 if ( ! function_exists( 'gglcptch_get_default_options' ) ) {
347 function gglcptch_get_default_options() {
348 global $gglcptch_plugin_info;
349
350 $default_options = array(
351 'whitelist_message' => __( 'You are in the whitelist', 'google-captcha' ),
352 'public_key' => '',
353 'private_key' => '',
354 'login_form' => '1',
355 'registration_form' => '1',
356 'reset_pwd_form' => '1',
357 'comments_form' => '1',
358 'contact_form' => '0',
359 'theme' => 'red',
360 'theme_v2' => 'light',
361 'recaptcha_version' => 'v2',
362 'plugin_option_version' => $gglcptch_plugin_info["Version"],
363 'first_install' => strtotime( "now" ),
364 'display_settings_notice' => 1,
365 'suggest_feature_banner' => 1,
366 );
367
368 if ( function_exists( 'get_editable_roles' ) ) {
369 foreach ( get_editable_roles() as $role => $fields ) {
370 $default_options[ $role ] = '0';
371 }
372 }
373 return $default_options;
374 }
375 }
376
377 if ( ! function_exists( 'gglcptch_plugin_status' ) ) {
378 function gglcptch_plugin_status( $plugins, $all_plugins, $is_network ) {
379 $result = array(
380 'status' => '',
381 'plugin' => '',
382 'plugin_info' => array(),
383 );
384 foreach ( (array)$plugins as $plugin ) {
385 if ( array_key_exists( $plugin, $all_plugins ) ) {
386 if (
387 ( $is_network && is_plugin_active_for_network( $plugin ) ) ||
388 ( ! $is_network && is_plugin_active( $plugin ) )
389 ) {
390 $result['status'] = 'activated';
391 $result['plugin'] = $plugin;
392 $result['plugin_info'] = $all_plugins[$plugin];
393 break;
394 } else {
395 $result['status'] = 'deactivated';
396 $result['plugin'] = $plugin;
397 $result['plugin_info'] = $all_plugins[$plugin];
398 }
399
400 }
401 }
402 if ( empty( $result['status'] ) ) {
403 $result['status'] = 'not_installed';
404 }
405 return $result;
406 }
407 }
408
409 if ( ! function_exists( 'gglcptch_whitelisted_ip' ) ) {
410 function gglcptch_whitelisted_ip() {
411 global $wpdb, $gglcptch_options;
412 $checked = false;
413 if ( empty( $gglcptch_options ) ) {
414 $gglcptch_options = get_option( 'gglcptch_options' );
415 }
416 $whitelist_exist = $wpdb->query( "SHOW TABLES LIKE '{$wpdb->prefix}gglcptch_whitelist'" );
417 if ( 1 === $whitelist_exist ) {
418 $ip = gglcptch_get_ip();
419
420 if ( ! empty( $ip ) ) {
421 $ip_int = sprintf( '%u', ip2long( $ip ) );
422 $result = $wpdb->get_var(
423 "SELECT `id`
424 FROM `{$wpdb->prefix}gglcptch_whitelist`
425 WHERE ( `ip_from_int` <= {$ip_int} AND `ip_to_int` >= {$ip_int} ) OR `ip` LIKE '{$ip}' LIMIT 1;"
426 );
427 $checked = is_null( $result ) || ! $result ? false : true;
428 } else {
429 $checked = false;
430 }
431 }
432 return $checked;
433 }
434 }
435
436 /* Display settings page */
437 if ( ! function_exists( 'gglcptch_add_settings_page' ) ) {
438 function gglcptch_add_settings_page() {
439 global $gglcptch_plugin_info;
440 require_once( dirname( __FILE__ ) . '/includes/pro_banners.php' ); ?>
441 <div class="wrap">
442 <?php if ( 'google-captcha.php' == $_GET['page'] ) {
443 require_once( dirname( __FILE__ ) . '/includes/class-gglcptch-settings-tabs.php' );
444 $page = new Gglcptch_Settings_Tabs( plugin_basename( __FILE__ ) ); ?>
445 <h1><?php _e( 'Google Captcha Settings', 'google-captcha' ); ?></h1>
446 <?php $page->display_content();
447 } else {
448 require_once( dirname( __FILE__ ) . '/includes/whitelist.php' );
449 $page = new Gglcptch_Whitelist( plugin_basename( __FILE__ ) );
450 if ( is_object( $page ) ) {
451 $page->display_content();
452 }
453
454 bws_plugin_reviews_block( $gglcptch_plugin_info['Name'], 'google-captcha' );
455 } ?>
456 </div>
457 <?php }
458 }
459
460 if ( ! function_exists( 'gglcptch_is_recaptcha_required' ) ) {
461 function gglcptch_is_recaptcha_required( $form_slug = '', $is_user_logged_in = null ) {
462 global $gglcptch_options;
463
464 if ( is_null( $is_user_logged_in ) ) {
465 $is_user_logged_in = is_user_logged_in();
466 }
467
468 if ( empty( $gglcptch_options ) ) {
469 $gglcptch_options = get_option( 'gglcptch_options' );
470 if ( empty( $gglcptch_options ) ) {
471 register_gglcptch_settings();
472 }
473 }
474
475 return
476 ! isset( $gglcptch_options[ $form_slug ] ) ||
477 (
478 ! empty( $gglcptch_options[ $form_slug ] ) &&
479 ( ! $is_user_logged_in || ! gglcptch_is_hidden_for_role() )
480 );
481 }
482 }
483
484 /* Checking current user role */
485 if ( ! function_exists( 'gglcptch_is_hidden_for_role' ) ) {
486 function gglcptch_is_hidden_for_role() {
487 global $current_user, $gglcptch_options;
488
489 if ( ! is_user_logged_in() ) {
490 return false;
491 }
492
493 if ( ! empty( $current_user->roles[0] ) ) {
494 $role = $current_user->roles[0];
495 if ( empty( $gglcptch_options ) ) {
496 register_gglcptch_settings();
497 }
498 return ! empty( $gglcptch_options[ $role ] );
499 } else {
500 return false;
501 }
502 }
503 }
504
505 /* Display google captcha via shortcode */
506 if ( ! function_exists( 'gglcptch_display' ) ) {
507 function gglcptch_display( $content = false ) {
508 global $gglcptch_options, $gglcptch_count, $gglcptch_ip_in_whitelist, $gglcptch_plugin_info;
509
510 if ( empty( $gglcptch_options ) ) {
511 register_gglcptch_settings();
512 }
513
514 if ( ! isset( $gglcptch_ip_in_whitelist ) ) {
515 $gglcptch_ip_in_whitelist = gglcptch_whitelisted_ip();
516 }
517
518 if ( ! $gglcptch_ip_in_whitelist ) {
519
520 if ( ! $gglcptch_count ) {
521 $gglcptch_count = 1;
522 }
523
524 $publickey = $gglcptch_options['public_key'];
525 $privatekey = $gglcptch_options['private_key'];
526
527 $content .= '<div class="gglcptch gglcptch_' . $gglcptch_options['recaptcha_version'] . '">';
528 if ( ! $privatekey || ! $publickey ) {
529 if ( current_user_can( 'manage_options' ) ) {
530 $content .= sprintf(
531 '<strong>%s <a target="_blank" href="https://www.google.com/recaptcha/admin#list">%s</a> %s <a target="_blank" href="%s">%s</a>.</strong>',
532 __( 'To use Google Captcha you must get the keys from', 'google-captcha' ),
533 __( 'here', 'google-captcha' ),
534 __( 'and enter them on the', 'google-captcha' ),
535 admin_url( '/admin.php?page=google-captcha.php' ),
536 __( 'plugin setting page', 'google-captcha' )
537 );
538 }
539 $content .= '</div>';
540 $gglcptch_count++;
541 return $content;
542 }
543
544 $api_url = gglcptch_get_api_url();
545
546 /* generating random id value in case of getting content with pagination plugin for not getting duplicate id values */
547 $id = mt_rand();
548 if ( isset( $gglcptch_options['recaptcha_version'] ) && in_array( $gglcptch_options['recaptcha_version'], array( 'v2', 'invisible' ) ) ) {
549 $content .= '<div id="gglcptch_recaptcha_' . $id . '" class="gglcptch_recaptcha"></div>
550 <noscript>
551 <div style="width: 302px;">
552 <div style="width: 302px; height: 422px; position: relative;">
553 <div style="width: 302px; height: 422px; position: absolute;">
554 <iframe src="https://www.google.com/recaptcha/api/fallback?k=' . $publickey . '" frameborder="0" scrolling="no" style="width: 302px; height:422px; border-style: none;"></iframe>
555 </div>
556 </div>
557 <div style="border-style: none; bottom: 12px; left: 25px; margin: 0px; padding: 0px; right: 25px; background: #f9f9f9; border: 1px solid #c1c1c1; border-radius: 3px; height: 60px; width: 300px;">
558 <textarea id="g-recaptcha-response" name="g-recaptcha-response" class="g-recaptcha-response" style="width: 250px !important; height: 40px !important; border: 1px solid #c1c1c1 !important; margin: 10px 25px !important; padding: 0px !important; resize: none !important;"></textarea>
559 </div>
560 </div>
561 </noscript>';
562 $deps = ( ! empty( $gglcptch_options['disable_submit'] ) ) ? array( 'gglcptch_pre_api' ) : array( 'jquery' );
563 } else {
564 require_once( 'lib/recaptchalib.php' );
565 $content .= '<div id="gglcptch_recaptcha_' . $id . '" class="gglcptch_recaptcha"></div>';
566 $content .= gglcptch_recaptcha_get_html( $publickey, null, is_ssl() );
567 $deps = array();
568 }
569 $content .= '</div>';
570 $gglcptch_count++;
571
572 /* register reCAPTCHA script */
573 if ( ! wp_script_is( 'gglcptch_api', 'registered' ) ) {
574 wp_register_script( 'gglcptch_api', $api_url, $deps, $gglcptch_plugin_info['Version'], true );
575 add_action( 'wp_footer', 'gglcptch_add_scripts' );
576 if (
577 '1' == $gglcptch_options['login_form'] ||
578 '1' == $gglcptch_options['reset_pwd_form'] ||
579 '1' == $gglcptch_options['registration_form']
580 )
581 add_action( 'login_footer', 'gglcptch_add_scripts' );
582 }
583 } elseif ( ! empty( $gglcptch_options['whitelist_message'] ) ) {
584 $content .= '<label class="gglcptch_whitelist_message">' . $gglcptch_options['whitelist_message'] . '</label>';
585 }
586
587 return $content;
588 }
589 }
590
591 /* Return google captcha content for custom form */
592 if ( ! function_exists( 'gglcptch_display_custom' ) ) {
593 function gglcptch_display_custom( $content = '', $form_slug = '' ) {
594 if ( gglcptch_is_recaptcha_required( $form_slug ) ) {
595 $content = gglcptch_display( $content );
596 }
597
598 return $content;
599 }
600 }
601
602 /* Get the reCAPTCHA api js url that corresponds to the reCAPTCHA version. */
603 if ( ! function_exists( 'gglcptch_get_api_url' ) ) {
604 function gglcptch_get_api_url() {
605 global $gglcptch_options;
606
607 if ( isset( $gglcptch_options['recaptcha_version'] ) && in_array( $gglcptch_options['recaptcha_version'], array( 'v2', 'invisible' ) ) ) {
608 $callback = ( ! empty( $gglcptch_options['disable_submit'] ) ) ? "onload=gglcptch_onload_callback&" : "";
609
610 $api_url = sprintf( "https://www.google.com/recaptcha/api.js?%srender=explicit", $callback );
611 } else {
612 $api_url = "https://www.google.com/recaptcha/api/js/recaptcha_ajax.js";
613 }
614 return $api_url;
615 }
616 }
617
618 if ( ! function_exists( 'gglcptch_get_response' ) ) {
619 function gglcptch_get_response( $privatekey, $remote_ip ) {
620 $args = array(
621 'body' => array(
622 'secret' => $privatekey,
623 'response' => stripslashes( esc_html( $_POST["g-recaptcha-response"] ) ),
624 'remoteip' => $remote_ip,
625 ),
626 'sslverify' => false
627 );
628 $resp = wp_remote_post( 'https://www.google.com/recaptcha/api/siteverify', $args );
629 return json_decode( wp_remote_retrieve_body( $resp ), true );
630 }
631 }
632
633 /* Check google captcha */
634 if ( ! function_exists( 'gglcptch_check' ) ) {
635 function gglcptch_check( $debug = false ) {
636 global $gglcptch_options;
637
638 if ( empty( $gglcptch_options ) ) {
639 register_gglcptch_settings();
640 }
641
642 $publickey = $gglcptch_options['public_key'];
643 $privatekey = $gglcptch_options['private_key'];
644
645 if ( ! $privatekey || ! $publickey ) {
646 return array(
647 'response' => false,
648 'reason' => 'ERROR_NO_KEYS'
649 );
650 }
651
652 $gglcptch_remote_addr = filter_var( $_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP );
653
654 if (
655 isset( $gglcptch_options['recaptcha_version'] ) &&
656 in_array( $gglcptch_options['recaptcha_version'], array( 'v2', 'invisible' ) )
657 ) {
658 if ( ! isset( $_POST["g-recaptcha-response"] ) ) {
659 $result = array(
660 'response' => false,
661 'reason' => 'RECAPTCHA_NO_RESPONSE'
662 );
663 } elseif ( empty( $_POST["g-recaptcha-response"] ) ) {
664 $result = array(
665 'response' => false,
666 'reason' => 'RECAPTCHA_EMPTY_RESPONSE'
667 );
668 } else {
669 $response = gglcptch_get_response( $privatekey, $gglcptch_remote_addr );
670 if ( isset( $response['success'] ) && !! $response['success'] ) {
671 $result = array(
672 'response' => true,
673 'reason' => ''
674 );
675 } else {
676 if (
677 ! $debug && ! empty( $response['error-codes'] ) &&
678 (
679 in_array( 'missing-input-secret', $response['error-codes'] ) ||
680 in_array( 'invalid-input-secret', $response['error-codes'] )
681 )
682 ) {
683 $result = array(
684 'response' => false,
685 'reason' => 'ERROR_WRONG_SECRET'
686 );
687 } else {
688 $result = array(
689 'response' => false,
690 'reason' => $debug ? $response['error-codes'] : 'VERIFICATION_FAILED'
691 );
692 }
693 }
694 }
695 } else {
696 $gglcptch_recaptcha_challenge_field = $gglcptch_recaptcha_response_field = '';
697
698 if ( ! isset( $_POST['recaptcha_challenge_field'] ) && ! isset( $_POST['recaptcha_response_field'] ) ) {
699 $result = array(
700 'response' => false,
701 'reason' => 'RECAPTCHA_NO_RESPONSE'
702 );
703 } elseif ( ! empty( $_POST['recaptcha_challenge_field'] ) && empty( $_POST['recaptcha_response_field'] ) ) {
704 $result = array(
705 'response' => false,
706 'reason' => 'RECAPTCHA_EMPTY_RESPONSE'
707 );
708 } else {
709 $gglcptch_recaptcha_challenge_field = stripslashes( esc_html( $_POST['recaptcha_challenge_field'] ) );
710 $gglcptch_recaptcha_response_field = stripslashes( esc_html( $_POST['recaptcha_response_field'] ) );
711
712 require_once( 'lib/recaptchalib.php' );
713 $response = gglcptch_recaptcha_check_answer( $privatekey, $gglcptch_remote_addr, $gglcptch_recaptcha_challenge_field, $gglcptch_recaptcha_response_field );
714
715 if ( ! $response->is_valid ) {
716 $result = array(
717 'response' => false,
718 'reason' => $debug ? $response->error : 'VERIFICATION_FAILED'
719 );
720 } else {
721 $result = array(
722 'response' => true,
723 'reason' => ''
724 );
725 }
726 }
727 }
728
729 return $result;
730 }
731 }
732
733 /**
734 * Check google captcha for custom form
735 * @since 1.32
736 * @param bool $allow (Optional) initial value wheter the previous verification is passed
737 * @param string $return_format (Optional) The type of variable to be returned when recaptcha is failed.
738 * @param string $form_slug (Optional) The slug of the form to check.
739 * Default is empty string. When specified, the reCAPTCHA check may be skipped if the form is disabled on the plugin settings page.
740 * @return mixed $allow True if ReCapthca is successfully completed, error message string, WP_Error object or false otherwise, depending on the $return_format value.
741 */
742 if ( ! function_exists( 'gglcptch_check_custom' ) ) {
743 function gglcptch_check_custom( $allow = true, $return_format = 'bool', $form_slug = '' ) {
744
745 if ( true !== $allow ) {
746 return $allow;
747 }
748
749 if ( gglcptch_is_recaptcha_required( $form_slug ) ) {
750 $gglcptch_check = gglcptch_check();
751
752 if ( ! $gglcptch_check['response'] && $gglcptch_check['reason'] == 'ERROR_NO_KEYS' ) {
753 return $allow;
754 }
755
756 $la_result = ( ! empty( $form_slug ) ) ? gglcptch_handle_by_limit_attempts( $gglcptch_check['response'], $form_slug ) : true;
757
758 if ( ! $gglcptch_check['response'] || true !== $la_result ) {
759 if ( ! in_array( $return_format, array( 'bool', 'string', 'wp_error' ) ) ) {
760 $return_format = 'bool';
761 }
762
763 switch ( $return_format ) {
764 case 'string':
765 $allow = '';
766 if ( true !== $la_result ) {
767 if ( is_wp_error( $la_result ) ) {
768 $allow .= $la_result->get_error_message();
769 } elseif ( is_string( $la_result ) ) {
770 $allow .= $la_result;
771 }
772 }
773 if ( ! $gglcptch_check['response'] ) {
774 $allow .= ( ( '' != $allow ) ? "&nbsp;" : '' ) . gglcptch_get_message();
775 }
776 break;
777 case 'wp_error':
778 $allow = new WP_Error();
779 if ( true !== $la_result ) {
780 if ( is_wp_error( $la_result ) ) {
781 $allow = $la_result;
782 } elseif ( is_string( $la_result ) ) {
783 $allow->add( 'gglcptch_la_error', $la_result );
784 }
785 }
786 if ( ! $gglcptch_check['response'] ) {
787 $error_message = sprintf( '<strong>%s</strong>:&nbsp;%s', __( 'Error', 'google-captcha-pro' ), gglcptch_get_message() );
788 $allow->add( 'gglcptch_error', $error_message );
789 }
790 break;
791 case 'bool':
792 default:
793 $allow = false;
794 break;
795 }
796 }
797 }
798
799 return $allow;
800 }
801 }
802
803 /**
804 *
805 * @since 1.32
806 */
807 if ( ! function_exists( 'gglcptch_handle_by_limit_attempts' ) ) {
808 function gglcptch_handle_by_limit_attempts( $check_result, $form_slug = 'login_form' ) {
809 global $gglcptch_forms;
810
811 if ( ! has_filter( 'lmtttmpts_check_ip' ) ) {
812 return $check_result;
813 }
814
815 if ( empty( $gglcptch_forms ) ) {
816 $gglcptch_forms = gglcptch_get_forms();
817 }
818
819 $la_form_slug = "{$form_slug}_recaptcha_check";
820
821 /* if reCAPTCHA answer is right */
822 if ( true === $check_result ) {
823 /* check if user IP is blocked in the Limit Attempts plugin lists */
824 $check_result = apply_filters( 'lmtttmpts_check_ip', $check_result );
825 /* if IP isn't blocked */
826 if ( true === $check_result ) {
827 do_action( 'lmtttmpts_form_success', $la_form_slug, gglcptch_get_ip(), array( 'form_name' => $gglcptch_forms[ $form_slug ]['form_name'] ) );
828 }
829 } else {
830 /* if reCAPTCHA answer is wrong */
831 $form_data = array( 'form_name' => $gglcptch_forms[ $form_slug ]['form_name'] );
832
833 $la_error = apply_filters( 'lmtttmpts_form_fail', $la_form_slug, '', $form_data );
834 if ( ! empty( $la_error ) && $la_form_slug != $la_error ) {
835 if ( is_wp_error( $check_result ) ) {
836 $check_result->add( "gglcptch_error_lmttmpts", $la_error );
837 } elseif ( is_string( $check_result ) ) {
838 $check_result .= '<br />' . $la_error;
839 } else {
840 $check_result = $la_error;
841 }
842 }
843 }
844
845 return $check_result;
846 }
847 }
848
849 if ( ! function_exists( 'gglcptch_get_ip' ) ) {
850 function gglcptch_get_ip() {
851 $ip = '';
852 if ( isset( $_SERVER ) ) {
853 $server_vars = array( 'HTTP_X_REAL_IP', 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'REMOTE_ADDR' );
854 foreach( $server_vars as $var ) {
855 if ( isset( $_SERVER[ $var ] ) && ! empty( $_SERVER[ $var ] ) ) {
856 if ( filter_var( $_SERVER[ $var ], FILTER_VALIDATE_IP ) ) {
857 $ip = $_SERVER[ $var ];
858 break;
859 } else { /* if proxy */
860 $ip_array = explode( ',', $_SERVER[ $var ] );
861 if ( is_array( $ip_array ) && ! empty( $ip_array ) && filter_var( $ip_array[0], FILTER_VALIDATE_IP ) ) {
862 $ip = $ip_array[0];
863 break;
864 }
865 }
866 }
867 }
868 }
869 return $ip;
870 }
871 }
872
873 /**
874 * Retrieve the message that corresponds to its message code
875 * @since 1.29
876 * @param string $message_code used to switch the corresponding message
877 * @param boolean $echo 'false' is default. If 'false' - returns a message, if 'true' - first, echo a message and then return it.
878 * @return string $message Returned message.
879 */
880 if ( ! function_exists( 'gglcptch_get_message' ) ) {
881 function gglcptch_get_message( $message_code = 'incorrect', $echo = false ) {
882 $message = '';
883
884 $messages = array(
885 /* custom error */
886 'RECAPTCHA_EMPTY_RESPONSE' => __( 'User response is missing.', 'google-captcha' ),
887 /* v1 error */
888 'invalid-site-private-key' => sprintf(
889 '<strong>%s</strong> <a target="_blank" href="https://www.google.com/recaptcha/admin#list">%s</a> %s.',
890 __( 'Secret Key is invalid.', 'google-captcha' ),
891 __( 'Check your domain configurations', 'google-captcha' ),
892 __( 'and enter it again', 'google-captcha' )
893 ),
894 /* v2 error */
895 'missing-input-secret' => __( 'Secret Key is missing.', 'google-captcha' ),
896 'invalid-input-secret' => sprintf(
897 '<strong>%s</strong> <a target="_blank" href="https://www.google.com/recaptcha/admin#list">%s</a> %s.',
898 __( 'Secret Key is invalid.', 'google-captcha' ),
899 __( 'Check your domain configurations', 'google-captcha' ),
900 __( 'and enter it again', 'google-captcha' )
901 ),
902 'incorrect-captcha-sol' => __( 'User response is invalid', 'google-captcha' ),
903 'incorrect' => __( 'You have entered an incorrect reCAPTCHA value.', 'google-captcha' ),
904 'multiple_blocks' => __( 'More than one reCAPTCHA has been found in the current form. Please remove all unnecessary reCAPTCHA fields to make it work properly.', 'google-captcha' )
905 );
906
907 if ( isset( $messages[ $message_code ] ) ) {
908 $message = $messages[ $message_code ];
909 } else {
910 $message = $messages['incorrect'];
911 }
912
913 if ( $echo ) {
914 echo $message;
915 }
916
917 return $message;
918 }
919 }
920
921 if ( ! function_exists( 'gglcptch_test_keys' ) ) {
922 function gglcptch_test_keys() {
923 global $gglcptch_ip_in_whitelist, $gglcptch_options;
924 if ( isset( $_REQUEST['_wpnonce'] ) && wp_verify_nonce( $_REQUEST['_wpnonce'] , $_REQUEST['action'] ) ) {
925 header( 'Content-Type: text/html' );
926 register_gglcptch_settings(); ?>
927 <p>
928 <?php if ( 'invisible' == $gglcptch_options['recaptcha_version'] ) {
929 _e( 'Please submit "Test verification"', 'google-captcha' );
930 } else {
931 _e( 'Please complete the captcha and submit "Test verification"', 'google-captcha' );
932 } ?>
933 </p>
934 <?php $gglcptch_ip_in_whitelist = false;
935 echo gglcptch_display(); ?>
936 <p>
937 <input type="hidden" name="gglcptch_test_keys_verification-nonce" value="<?php echo wp_create_nonce( 'gglcptch_test_keys_verification' ); ?>" />
938 <button id="gglcptch_test_keys_verification" name="action" class="button-primary" value="gglcptch_test_keys_verification"><?php _e( 'Test verification', 'google-captcha' ); ?></button>
939 </p>
940 <?php }
941 die();
942 }
943 }
944
945 if ( ! function_exists( 'gglcptch_test_keys_verification' ) ) {
946 function gglcptch_test_keys_verification() {
947 if ( isset( $_REQUEST['_wpnonce'] ) && wp_verify_nonce( $_REQUEST['_wpnonce'] , $_REQUEST['action'] ) ) {
948 $result = gglcptch_check( true );
949
950 if ( ! $result['response'] ) {
951 if ( isset( $result['reason'] ) ) {
952 foreach ( (array)$result['reason'] as $error ) { ?>
953 <div class="error gglcptch-test-results"><p>
954 <?php gglcptch_get_message( $error, true ); ?>
955 </p></div>
956 <?php }
957 }
958 } else { ?>
959 <div class="updated gglcptch-test-results"><p><?php _e( 'The verification is successfully completed.','google-captcha' ); ?></p></div>
960 <?php $gglcptch_options = get_option( 'gglcptch_options' );
961 $gglcptch_options['keys_verified'] = true;
962 unset( $gglcptch_options['need_keys_verified_check'] );
963 update_option( 'gglcptch_options', $gglcptch_options );
964 }
965 }
966 die();
967 }
968 }
969
970 if ( ! function_exists( 'gglcptch_action_links' ) ) {
971 function gglcptch_action_links( $links, $file ) {
972 if ( ! is_network_admin() ) {
973 static $this_plugin;
974 if ( ! $this_plugin ) {
975 $this_plugin = plugin_basename(__FILE__);
976 }
977
978 if ( $file == $this_plugin ) {
979 $settings_link = '<a href="admin.php?page=google-captcha.php">' . __( 'Settings', 'google-captcha' ) . '</a>';
980 array_unshift( $links, $settings_link );
981 }
982 }
983 return $links;
984 }
985 }
986
987 if ( ! function_exists( 'gglcptch_links' ) ) {
988 function gglcptch_links( $links, $file ) {
989 $base = plugin_basename( __FILE__ );
990 if ( $file == $base ) {
991 if ( ! is_network_admin() ) {
992 $links[] = '<a href="admin.php?page=google-captcha.php">' . __( 'Settings', 'google-captcha' ) . '</a>';
993 }
994 $links[] = '<a href="https://support.bestwebsoft.com/hc/en-us/sections/200538719" target="_blank">' . __( 'FAQ', 'google-captcha' ) . '</a>';
995 $links[] = '<a href="https://support.bestwebsoft.com">' . __( 'Support', 'google-captcha' ) . '</a>';
996 }
997 return $links;
998 }
999 }
1000
1001 if ( ! function_exists ( 'gglcptch_plugin_banner' ) ) {
1002 function gglcptch_plugin_banner() {
1003 global $hook_suffix, $gglcptch_plugin_info, $gglcptch_options;
1004 if ( 'plugins.php' == $hook_suffix ) {
1005 if ( empty( $gglcptch_options ) ) {
1006 register_gglcptch_settings();
1007 }
1008
1009 if ( empty( $gglcptch_options['public_key'] ) || empty( $gglcptch_options['private_key'] ) ) { ?>
1010 <div class="error">
1011 <p>
1012 <?php printf(
1013 '<strong>%s <a target="_blank" href="https://www.google.com/recaptcha/admin#list">%s</a> %s <a target="_blank" href="%s">%s</a>.</strong>',
1014 __( 'To use Google Captcha you must get the keys from', 'google-captcha' ),
1015 __ ( 'here', 'google-captcha' ),
1016 __ ( 'and enter them on the', 'google-captcha' ),
1017 admin_url( '/admin.php?page=google-captcha.php' ),
1018 __( 'plugin setting page', 'google-captcha' )
1019 ); ?>
1020 </p>
1021 </div>
1022 <?php }
1023 if ( isset( $gglcptch_options['first_install'] ) && strtotime( '-1 week' ) > $gglcptch_options['first_install'] ) {
1024 bws_plugin_banner( $gglcptch_plugin_info, 'gglcptch', 'google-captcha', '676d9558f9786ab41d7de35335cf5c4d', '109', '//ps.w.org/google-captcha/assets/icon-128x128.png' );
1025 }
1026
1027 bws_plugin_banner_to_settings( $gglcptch_plugin_info, 'gglcptch_options', 'google-captcha', 'admin.php?page=google-captcha.php' );
1028 }
1029
1030 if ( isset( $_GET['page'] ) && 'google-captcha.php' == $_GET['page'] ) {
1031 bws_plugin_suggest_feature_banner( $gglcptch_plugin_info, 'gglcptch_options', 'google-captcha' );
1032 }
1033 }
1034 }
1035
1036 /* add help tab */
1037 if ( ! function_exists( 'gglcptch_add_tabs' ) ) {
1038 function gglcptch_add_tabs() {
1039 $screen = get_current_screen();
1040 $args = array(
1041 'id' => 'gglcptch',
1042 'section' => '200538719'
1043 );
1044 bws_help_tab( $screen, $args );
1045 }
1046 }
1047
1048 if ( ! function_exists( 'gglcptch_delete_options' ) ) {
1049 function gglcptch_delete_options() {
1050 if ( ! function_exists( 'get_plugins' ) ) {
1051 require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
1052 }
1053 $all_plugins = get_plugins();
1054
1055 if ( ! array_key_exists( 'google-captcha-pro/google-captcha-pro.php', $all_plugins ) ) {
1056 global $wpdb;
1057 if ( function_exists( 'is_multisite' ) && is_multisite() ) {
1058 $old_blog = $wpdb->blogid;
1059 /* Get all blog ids */
1060 $blogids = $wpdb->get_col( "SELECT `blog_id` FROM $wpdb->blogs" );
1061 foreach ( $blogids as $blog_id ) {
1062 switch_to_blog( $blog_id );
1063 $wpdb->query( "DROP TABLE IF EXISTS `{$wpdb->prefix}gglcptch_whitelist`;" );
1064 delete_option( 'gglcptch_options' );
1065 }
1066 switch_to_blog( $old_blog );
1067 delete_site_option( 'gglcptch_options' );
1068 } else {
1069 $wpdb->query( "DROP TABLE IF EXISTS `{$wpdb->prefix}gglcptch_whitelist`;" );
1070 delete_option( 'gglcptch_options' );
1071 }
1072 }
1073
1074 require_once( dirname( __FILE__ ) . '/bws_menu/bws_include.php' );
1075 bws_include_init( plugin_basename( __FILE__ ) );
1076 bws_delete_plugin( plugin_basename( __FILE__ ) );
1077 }
1078 }
1079
1080 register_activation_hook( __FILE__, 'gglcptch_plugin_activate' );
1081
1082 add_action( 'admin_menu', 'gglcptch_admin_menu' );
1083
1084 add_action( 'init', 'gglcptch_init' );
1085 add_action( 'admin_init', 'gglcptch_admin_init' );
1086
1087 add_action( 'plugins_loaded', 'gglcptch_plugins_loaded' );
1088
1089 add_action( 'admin_enqueue_scripts', 'gglcptch_add_admin_script_styles' );
1090 add_action( 'wp_enqueue_scripts', 'gglcptch_add_styles' );
1091 add_filter( 'script_loader_tag', 'gglcptch_add_async_attribute', 10, 2 );
1092 add_action( 'admin_footer', 'gglcptch_admin_footer' );
1093 add_filter( 'pgntn_callback', 'gglcptch_pagination_callback' );
1094
1095 add_filter( 'lmtttmpts_plugin_forms', 'gglcptch_add_lmtttmpts_forms', 10, 1 );
1096
1097 add_shortcode( 'bws_google_captcha', 'gglcptch_display' );
1098 add_filter( 'widget_text', 'do_shortcode' );
1099
1100 add_filter( 'gglcptch_display_recaptcha', 'gglcptch_display_custom', 10, 2 );
1101 add_filter( 'gglcptch_verify_recaptcha', 'gglcptch_check_custom', 10, 3 );
1102
1103 add_filter( 'plugin_action_links', 'gglcptch_action_links', 10, 2 );
1104 add_filter( 'plugin_row_meta', 'gglcptch_links', 10, 2 );
1105
1106 add_action( 'admin_notices', 'gglcptch_plugin_banner' );
1107
1108 add_action( 'wp_ajax_gglcptch-test-keys', 'gglcptch_test_keys' );
1109 add_action( 'wp_ajax_gglcptch_test_keys_verification', 'gglcptch_test_keys_verification' );