PluginProbe ʕ •ᴥ•ʔ
reCaptcha by BestWebSoft / 1.84
reCaptcha by BestWebSoft v1.84
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 / includes / forms.php
google-captcha / includes Last commit date
allowlist.php 10 months ago captcha-for-formidable.php 10 months ago class-gglcptch-settings-tabs.php 10 months ago forms.php 10 months ago pro_banners.php 10 months ago
forms.php
623 lines
1 <?php
2 /**
3 * Contains the extending functionality
4 *
5 * @since 1.32
6 */
7
8 if ( ! defined( 'ABSPATH' ) ) exit;
9
10 if ( ! function_exists( 'gglcptch_get_forms' ) ) {
11 /**
12 * All forms for reCaptcha
13 *
14 * @return array $gglcptch_forms Forms for reCaptcha.
15 */
16 function gglcptch_get_forms() {
17 global $gglcptch_forms;
18
19 $default_forms = array(
20 'login_form' => array( 'form_name' => __( 'Login form', 'google-captcha' ) ),
21 'registration_form' => array( 'form_name' => __( 'Registration form', 'google-captcha' ) ),
22 'reset_pwd_form' => array( 'form_name' => __( 'Reset password form', 'google-captcha' ) ),
23 'password_form' => array( 'form_name' => __( 'Protected post password form', 'google-captcha' ) ),
24 'comments_form' => array( 'form_name' => __( 'Comments form', 'google-captcha' ) ),
25 'contact_form' => array( 'form_name' => 'Contact Form' ),
26 'testimonials' => array( 'form_name' => __( 'Testimonials', 'google-captcha' ) ),
27 'frm_contact_form' => array( 'form_name' => __( 'Formidable Contact Form', 'google-captcha' ) ),
28 'bws_login_form' => array( 'form_name' => __( 'BWS Login form', 'google-captcha' ) ),
29 'bws_register_form' => array( 'form_name' => __( 'BWS Register form', 'google-captcha' ) ),
30 'bws_forgot_pass_form' => array( 'form_name' => __( 'BWS Forgot Password form', 'google-captcha' ) ),
31 );
32
33 $custom_forms = apply_filters( 'gglcptch_add_custom_form', array() );
34 $gglcptch_forms = array_merge( $default_forms, $custom_forms );
35
36 foreach ( $gglcptch_forms as $form_slug => $form_data ) {
37 $gglcptch_forms[ $form_slug ]['form_notice'] = gglcptch_get_form_notice( $form_slug );
38 }
39
40 $gglcptch_forms = apply_filters( 'gglcptch_forms', $gglcptch_forms );
41
42 return $gglcptch_forms;
43 }
44 }
45
46 if ( ! function_exists( 'gglcptch_get_sections' ) ) {
47 /**
48 * Google captcha sections for dashboard setting page
49 *
50 * @return array $gglcptch_sections Google captcha sections.
51 */
52 function gglcptch_get_sections() {
53 global $gglcptch_sections;
54
55 $default_sections = array(
56 'standard' => array(
57 'name' => __( 'WordPress default', 'google-captcha' ),
58 'forms' => array(
59 'login_form',
60 'registration_form',
61 'reset_pwd_form',
62 'password_form',
63 'comments_form',
64 ),
65 ),
66 'external' => array(
67 'name' => __( 'External Plugins', 'google-captcha' ),
68 'forms' => array(
69 'contact_form',
70 'testimonials',
71 'frm_contact_form'
72 ),
73 ),
74 'bws_login_register' => array(
75 'name' => 'BWS Login Register',
76 'forms' => array(
77 'bws_login_form',
78 'bws_register_form',
79 'bws_forgot_pass_form'
80 ),
81 ),
82 );
83
84 $custom_forms = apply_filters( 'gglcptch_add_custom_form', array() );
85
86 $custom_sections = ( empty( $custom_forms ) ) ? array() : array(
87 'custom' => array(
88 'name' => __( 'Custom Forms', 'google-captcha' ),
89 'forms' => array_keys( $custom_forms ),
90 ),
91 );
92 $gglcptch_sections = array_merge( $default_sections, $custom_sections );
93
94 foreach ( $gglcptch_sections as $section_slug => $section_data ) {
95 $gglcptch_sections[ $section_slug ]['section_notice'] = gglcptch_get_section_notice( $section_slug );
96 }
97
98 $gglcptch_sections = apply_filters( 'gglcptch_sections', $gglcptch_sections );
99
100 return $gglcptch_sections;
101 }
102 }
103
104 if ( ! function_exists( 'gglcptch_add_lmtttmpts_forms' ) ) {
105 /**
106 * Add reCaptcha forms to the Limit Attempts plugin
107 *
108 * @param array $forms (Optional) Forms array.
109 * @return array $forms Forms array.
110 */
111 function gglcptch_add_lmtttmpts_forms( $forms = array() ) {
112 if ( ! is_array( $forms ) ) {
113 $forms = array();
114 }
115
116 $forms['gglcptch'] = array(
117 'name' => __( 'reCaptcha Plugin', 'google-captcha' ),
118 'forms' => array(),
119 );
120
121 $recaptcha_forms = gglcptch_get_forms();
122
123 foreach ( $recaptcha_forms as $form_slug => $form_data ) {
124 $forms['gglcptch']['forms'][ "{$form_slug}_captcha_check" ] = $form_data;
125 if ( empty( $form_data['form_notice'] ) ) {
126 $forms['gglcptch']['forms'][ "{$form_slug}_captcha_check" ]['form_notice'] = gglcptch_get_section_notice( $form_slug );
127 }
128 }
129
130 return $forms;
131 }
132 }
133
134 if ( ! function_exists( 'gglcptch_get_section_notice' ) ) {
135 /**
136 * Display section notice
137 *
138 * @access public
139 * @param string $section_slug Section slug for notice.
140 * @return array The action results.
141 */
142 function gglcptch_get_section_notice( $section_slug = '' ) {
143 $section_notice = '';
144
145 $plugins = array(
146 'bws_login_register' => 'bws-login-register/bws-login-register.php'
147 );
148
149 $plugins = apply_filters( 'gglcptch_custom_plugin_section_notice', $plugins );
150
151 $is_network_admin = is_network_admin();
152
153 if ( isset( $plugins[ $section_slug ] ) ) {
154 $slug = explode( '/', $plugins[ $section_slug ] );
155 $slug = $slug[0];
156 $plugin_info = gglcptch_plugin_status( $plugins[ $section_slug ], get_plugins(), $is_network_admin );
157 if ( 'deactivated' === $plugin_info['status'] ) {
158 $section_notice = '<a href="' . self_admin_url( 'plugins.php' ) . '">' . __( 'Activate', 'google-captcha' ) . '</a>';
159 } elseif ( 'not_installed' === $plugin_info['status'] ) {
160 $section_notice = sprintf( '<a href="http://wordpress.org/plugins/%s/" target="_blank">%s</a>', $slug, __( 'Install Now', 'google-captcha' ) );
161 }
162 }
163
164 return apply_filters( 'gglcptch_section_notice', $section_notice, $section_slug );
165 }
166 }
167
168 if ( ! function_exists( 'gglcptch_get_form_notice' ) ) {
169 /**
170 * Add Settings and Support links
171 *
172 * @param string $form_slug Form slug.
173 * @return string apply_filters result.
174 */
175 function gglcptch_get_form_notice( $form_slug = '' ) {
176 global $wp_version, $gglcptch_plugin_info;
177 $form_notice = '';
178
179 $plugins = array(
180 'contact_form' => array( 'contact-form-plugin/contact_form.php', 'contact-form-pro/contact_form_pro.php', 'contact-form-plus/contact-form-plus.php' ),
181 'testimonials' => array( 'bws-testimonials/bws-testimonials.php', 'bws-testimonials-pro/bws-testimonials-pro.php' ),
182 'frm_contact_form' => array( 'formidable/formidable.php', 'formidable-pro/formidable-pro.php' ),
183 );
184
185 if ( isset( $plugins[ $form_slug ] ) ) {
186 $plugin_info = gglcptch_plugin_status( $plugins[ $form_slug ], get_plugins(), is_network_admin() );
187
188 if ( 'deactivated' === $plugin_info['status'] ) {
189 $form_notice = '<a href="' . self_admin_url( 'plugins.php' ) . '">' . __( 'Activate', 'google-captcha' ) . '</a>';
190 } elseif ( 'not_installed' === $plugin_info['status'] ) {
191 if ( 'contact_form' === $form_slug ) {
192 $form_notice = '<a href="https://bestwebsoft.com/products/wordpress/plugins/contact-form/?k=fa26df3911ebcd90c3e85117d6dd0ce0&pn=281&v=' . $gglcptch_plugin_info['Version'] . '&wp_v=' . $wp_version . '" target="_blank">' . __( 'Install Now', 'google-captcha' ) . '</a>';
193 } else {
194 $form_notice = '<a href="https://bestwebsoft.com/products/wordpress/plugins/bws-testimonials/?k=451513a59dcd9844db90b567473022ce&pn=281&v=' . $gglcptch_plugin_info['Version'] . '&wp_v=' . $wp_version . '" target="_blank">' . __( 'Install Now', 'google-captcha' ) . '</a>';
195 }
196 }
197 }
198 return apply_filters( 'gglcptch_form_notice', $form_notice, $form_slug );
199 }
200 }
201
202 if ( ! function_exists( 'gglcptch_add_actions' ) ) {
203 /**
204 * Add Settings and Support links
205 */
206 function gglcptch_add_actions() {
207 global $gglcptch_options;
208
209 $is_user_logged_in = is_user_logged_in();
210
211 if ( ! empty( $gglcptch_options['login_form'] ) || ! empty( $gglcptch_options['reset_pwd_form'] ) || ! empty( $gglcptch_options['registration_form'] ) ) {
212
213 if ( gglcptch_is_recaptcha_required( 'login_form', $is_user_logged_in ) ) {
214 add_action( 'login_form', 'gglcptch_login_display' );
215 add_action( 'authenticate', 'gglcptch_login_check', 21, 1 );
216 }
217
218 if ( gglcptch_is_recaptcha_required( 'registration_form', $is_user_logged_in ) ) {
219 if ( ! is_multisite() ) {
220 add_action( 'register_form', 'gglcptch_login_display', 99 );
221 add_action( 'registration_errors', 'gglcptch_register_check', 10, 1 );
222 } else {
223 add_action( 'signup_extra_fields', 'gglcptch_signup_display' );
224 add_action( 'signup_blogform', 'gglcptch_signup_display' );
225 add_filter( 'wpmu_validate_user_signup', 'gglcptch_signup_check', 10, 3 );
226 }
227 }
228
229 if ( gglcptch_is_recaptcha_required( 'reset_pwd_form', $is_user_logged_in ) ) {
230 add_action( 'lostpassword_form', 'gglcptch_login_display' );
231 add_action( 'allow_password_reset', 'gglcptch_lostpassword_check' );
232 }
233 }
234
235 /* Add Google Captcha to Protected post password */
236 if ( gglcptch_is_recaptcha_required( 'password_form', $is_user_logged_in ) ) {
237 add_filter( 'the_password_form', 'gglcptch_password_form_display', 10, 2 );
238 add_filter( 'post_password_expires', 'gglcptch_password_form_cookie' );
239 add_filter( 'post_password_required', 'gglcptch_password_form_check', 10, 2 );
240 }
241
242 /* Add Google Captcha to WP comments */
243 if ( gglcptch_is_recaptcha_required( 'comments_form', $is_user_logged_in ) ) {
244 add_action( 'comment_form_after_fields', 'gglcptch_commentform_display' );
245 add_action( 'comment_form_logged_in_after', 'gglcptch_commentform_display' );
246 add_action( 'pre_comment_on_post', 'gglcptch_commentform_check' );
247 }
248
249 /* Add Google Captcha to Contact Form by BestWebSoft */
250 if ( gglcptch_is_recaptcha_required( 'contact_form', $is_user_logged_in ) ) {
251 add_filter( 'cntctfrm_display_captcha', 'gglcptch_display', 10, 1 );
252 add_filter( 'cntctfrm_check_form', 'gglcptch_contact_form_check' );
253 }
254
255 /* Add Google Captcha to Testimonials by BestWebSoft */
256 if ( gglcptch_is_recaptcha_required( 'testimonials', $is_user_logged_in ) ) {
257 add_filter( 'tstmnls_display_recaptcha', 'gglcptch_display', 10, 0 );
258 }
259
260 /* Add Google Captcha to BWS Login Register */
261 if ( gglcptch_is_recaptcha_required( 'bws_login_form', $is_user_logged_in ) || gglcptch_is_recaptcha_required( 'bws_register_form', $is_user_logged_in ) || gglcptch_is_recaptcha_required( 'bws_forgot_pass_form', $is_user_logged_in ) ) {
262 add_filter( 'lgnrgstrfrm_add_field', 'gglcptch_add_login_register_forms', 10, 2 );
263 add_filter( 'lgnrgstrfrm_check_field', 'gglcptch_check_login_register_forms', 10 );
264 }
265
266 do_action( 'gglcptch_add_plus_actions', $is_user_logged_in );
267 }
268 }
269
270 if ( ! function_exists( 'gglcptch_echo_recaptcha' ) ) {
271 /**
272 * Echo google captcha
273 *
274 * @param string $content Content without captcha.
275 */
276 function gglcptch_echo_recaptcha( $content = '' ) {
277 echo gglcptch_display( $content );
278 }
279 }
280
281 if ( ! function_exists( 'gglcptch_login_display' ) ) {
282 /**
283 * Add google captcha to the login form
284 *
285 * @return bool true
286 */
287 function gglcptch_login_display() {
288
289 global $gglcptch_options;
290
291 if ( isset( $gglcptch_options['recaptcha_version'] ) ) {
292 if ( 'v2' === $gglcptch_options['recaptcha_version'] ) {
293 $from_width = 302; ?>
294 <style type="text/css" media="screen">
295 .login-action-login #loginform,
296 .login-action-lostpassword #lostpasswordform,
297 .login-action-register #registerform {
298 width: <?php echo esc_attr( $from_width ); ?>px !important;
299 }
300 #login_error,
301 .message {
302 width: <?php echo absint( esc_attr( $from_width ) ) + 20; ?>px !important;
303 }
304 .login-action-login #loginform .gglcptch,
305 .login-action-lostpassword #lostpasswordform .gglcptch,
306 .login-action-register #registerform .gglcptch {
307 margin-bottom: 10px;
308 }
309 </style>
310 <?php
311 }
312 }
313 echo gglcptch_display();
314 return true;
315 }
316 }
317
318 if ( ! function_exists( 'gglcptch_login_check' ) ) {
319 /**
320 * Check google captcha in login form
321 *
322 * @param object $user User object or errros array.
323 * @return object $user User object or errros array.
324 */
325 function gglcptch_login_check( $user ) {
326 global $gglcptch_check;
327 if ( gglcptch_is_woocommerce_page() ) {
328 return $user;
329 }
330 if ( is_wp_error( $user ) && isset( $user->errors['empty_username'] ) && isset( $user->errors['empty_password'] ) ) {
331 return $user;
332 }
333 /* Skip check if connecting to XMLRPC */
334 if ( defined( 'XMLRPC_REQUEST' ) ) {
335 return $user;
336 }
337
338 $gglcptch_check = gglcptch_check( 'login_form' );
339
340 if ( ! $gglcptch_check['response'] ) {
341 if ( 'VERIFICATION_FAILED' === $gglcptch_check['reason'] ) {
342 wp_clear_auth_cookie();
343 }
344 $error_code = ( is_wp_error( $user ) ) ? $user->get_error_code() : 'incorrect_password';
345 $errors = new WP_Error( $error_code, __( 'Authentication failed.', 'google-captcha' ) );
346 if ( isset( $gglcptch_check['errors'] ) ) {
347 $gglcptch_errors = $gglcptch_check['errors']->errors;
348 foreach ( $gglcptch_errors as $code => $messages ) {
349 foreach ( $messages as $message ) {
350 $errors->add( $code, $message );
351 }
352 }
353 }
354 $gglcptch_check['errors'] = $errors;
355 return $gglcptch_check['errors'];
356 }
357 return $user;
358 }
359 }
360
361 if ( ! function_exists( 'gglcptch_register_check' ) ) {
362 /**
363 * Check google captcha in registration form
364 *
365 * @param bool $allow Flag for captcha result.
366 * @return bool $allow Flag for captcha result.
367 */
368 function gglcptch_register_check( $allow ) {
369 if ( gglcptch_is_woocommerce_page() ) {
370 return $allow;
371 }
372 /* Skip check if connecting to XMLRPC */
373 if ( defined( 'XMLRPC_REQUEST' ) ) {
374 return $allow;
375 }
376
377 $gglcptch_check = gglcptch_check( 'registration_form' );
378 if ( ! $gglcptch_check['response'] ) {
379 return $gglcptch_check['errors'];
380 }
381 $_POST['g-recaptcha-response-check'] = true;
382 return $allow;
383 }
384 }
385
386 if ( ! function_exists( 'gglcptch_lostpassword_check' ) ) {
387 /**
388 * Check google captcha in lostpassword form
389 *
390 * @param bool $allow Flag for captcha result.
391 * @return bool $allow Flag for captcha result.
392 */
393 function gglcptch_lostpassword_check( $allow ) {
394 if ( gglcptch_is_woocommerce_page() || ( isset( $_POST['g-recaptcha-response-check'] ) && true === $_POST['g-recaptcha-response-check'] ) ) {
395 return $allow;
396 }
397 $gglcptch_check = gglcptch_check( 'reset_pwd_form' );
398 if ( ! $gglcptch_check['response'] ) {
399 return $gglcptch_check['errors'];
400 }
401 return $allow;
402 }
403 }
404
405 if ( ! function_exists( 'gglcptch_password_form_display' ) ) {
406 /**
407 * Add google captcha to the protected post password form
408 *
409 * @param string $output Form content.
410 * @param object $post Post object.
411 * @return string $expire Form content.
412 */
413 function gglcptch_password_form_display( $output, $post = null ) {
414 $recaptcha = gglcptch_display();
415 if ( '' !== $recaptcha && isset( $_COOKIE['gglcptch_password_form_errors'] ) ) {
416 $output = str_replace( '</form>', '<div class="error gglcptch-password-form-error"><p>' . wp_kses_post( wp_unslash( $_COOKIE['gglcptch_password_form_errors'] ) ) . '</p></div>' . $recaptcha . '</form>', $output );
417 } else {
418 $output = str_replace( '</form>', $recaptcha . '</form>', $output );
419 }
420 return $output;
421 }
422 }
423
424 if ( ! function_exists( 'gglcptch_password_form_cookie' ) ) {
425 /**
426 * Add google captcha to the protected post password form
427 *
428 * @param array $expire Expire time.
429 * @return array $expire Expire time.
430 */
431 function gglcptch_password_form_cookie( $expire ) {
432 if ( isset( $_POST['g-recaptcha-response'] ) ) {
433 $gglcptch_check = gglcptch_check( 'password_form' );
434 if ( ! $gglcptch_check['response'] ) {
435 setcookie( 'gglcptch_password_form_errors', $gglcptch_check['errors']->get_error_message( 'gglcptch_error' ), time() + 300, COOKIEPATH, COOKIE_DOMAIN, false );
436 } else {
437 setcookie( 'gglcptch_password_form_errors', '', -1, COOKIEPATH, COOKIE_DOMAIN, false );
438 }
439 }
440 return $expire;
441 }
442 }
443
444 if ( ! function_exists( 'gglcptch_password_form_check' ) ) {
445 /**
446 * Check google captcha in protected post password form
447 *
448 * @param bool $required Flag for required password form.
449 * @param object $post Post object.
450 * @return bool $required Flag for required password form.
451 */
452 function gglcptch_password_form_check( $required, $post ) {
453 if ( isset( $_COOKIE['gglcptch_password_form_errors'] ) ) {
454 $required = true;
455 }
456 return $required;
457 }
458 }
459
460 if ( ! function_exists( 'gglcptch_signup_display' ) ) {
461 /**
462 * Add google captcha to the multisite login form
463 *
464 * @param array $errors Login form errors.
465 */
466 function gglcptch_signup_display( $errors ) {
467 $error_message = $errors->get_error_message( 'gglcptch_error' );
468 if ( ! empty( $error_message ) ) {
469 printf( '<p class="error gglcptch_error">%s</p>', wp_kses_post( $error_message ) );
470 }
471 $error_message = $errors->get_error_message( 'lmttmpts_error' );
472 if ( ! empty( $error_message ) ) {
473 printf( '<p class="error lmttmpts_error">%s</p>', wp_kses_post( $error_message ) );
474 }
475 echo gglcptch_display();
476 }
477 }
478
479 if ( ! function_exists( 'gglcptch_signup_check' ) ) {
480 /**
481 * Check google captcha in multisite login form
482 *
483 * @param array $result Result/Error.
484 * @return array $result Result/Error.
485 */
486 function gglcptch_signup_check( $result ) {
487 global $current_user;
488 if ( is_admin() && ! defined( 'DOING_AJAX' ) && ! empty( $current_user->data->ID ) ) {
489 return $result;
490 }
491 $gglcptch_check = gglcptch_check( 'registration_form' );
492 if ( ! $gglcptch_check['response'] ) {
493 $result['errors'] = $gglcptch_check['errors'];
494 return $result;
495 }
496 return $result;
497 }
498 }
499
500 if ( ! function_exists( 'gglcptch_commentform_display' ) ) {
501 /**
502 * Add google captcha to the comment form
503 *
504 * @return bool true
505 */
506 function gglcptch_commentform_display() {
507 if ( gglcptch_is_hidden_for_role() ) {
508 return;
509 }
510 echo gglcptch_display();
511 return true;
512 }
513 }
514
515 if ( ! function_exists( 'gglcptch_commentform_check' ) ) {
516 /**
517 * Check JS enabled for comment form
518 */
519 function gglcptch_commentform_check() {
520 $gglcptch_check = gglcptch_check( 'comments_form' );
521 if ( ! $gglcptch_check['response'] ) {
522 $message = gglcptch_get_message( $gglcptch_check['reason'] ) . '<br />';
523 if ( ! empty( $gglcptch_check['errors'] ) && is_wp_error( $gglcptch_check['errors'] ) ){
524 $lmttmpts_error = $gglcptch_check['errors']->get_error_message( 'lmttmpts_error' );
525 if ( ! empty( $lmttmpts_error ) ) {
526 $message .= sprintf(
527 '<strong>%s</strong>:&nbsp;%s<br />',
528 __( 'Error', 'google-captcha' ),
529 $gglcptch_check['errors']->get_error_message( 'lmttmpts_error' )
530 );
531 }
532 }
533
534 $error_message = sprintf(
535 '<strong>%s</strong>:&nbsp;%s&nbsp;%s',
536 __( 'Error', 'google-captcha' ),
537 $message,
538 __( 'Click the BACK button on your browser and try again.', 'google-captcha' )
539 );
540 wp_die( wp_kses_post( $error_message ) );
541 }
542 }
543 }
544
545 if ( ! function_exists( 'gglcptch_contact_form_check' ) ) {
546 /**
547 * Check google captcha in BWS Contact Form
548 *
549 * @param bool $allow (Optional) reCaptcha for contact form.
550 * @return bool $allow Result check.
551 */
552 function gglcptch_contact_form_check( $allow = true ) {
553 if ( ! $allow || is_string( $allow ) || is_wp_error( $allow ) ) {
554 return $allow;
555 }
556 $gglcptch_check = gglcptch_check( 'contact_form' );
557 if ( ! $gglcptch_check['response'] ) {
558 return $gglcptch_check['errors'];
559 }
560 return $allow;
561 }
562 }
563
564 if ( ! function_exists( 'gglcptch_testimonials_check' ) ) {
565 /**
566 * Check google captcha in BWS Testimonial
567 *
568 * @param bool $allow (Optional) reCaptcha for testimonials.
569 * @return bool $allow Result check.
570 */
571 function gglcptch_testimonials_check( $allow = true ) {
572 global $gglcptch_check;
573 if ( ! $allow || is_string( $allow ) || is_wp_error( $allow ) ) {
574 return $allow;
575 }
576 $gglcptch_check = gglcptch_check( 'testimonials' );
577 if ( ! $gglcptch_check['response'] ) {
578 return $gglcptch_check['errors'];
579 }
580 return $allow;
581 }
582 }
583
584 if ( ! function_exists( 'gglcptch_add_login_register_forms' ) ) {
585 /**
586 * Check google captcha in BWS Testimonial
587 *
588 * @param string $content Content.
589 * @param string $form Form name.
590 * @return string $content Content after update.
591 */
592 function gglcptch_add_login_register_forms( $content, $form ) {
593 $is_user_logged_in = is_user_logged_in();
594 if ( gglcptch_is_recaptcha_required( 'bws_login_form', $is_user_logged_in ) && 'login' === $form ) {
595 return gglcptch_display( array(), $content );
596 } elseif ( gglcptch_is_recaptcha_required( 'bws_register_form', $is_user_logged_in ) && 'register' === $form ) {
597 return gglcptch_display( array(), $content );
598 } elseif( gglcptch_is_recaptcha_required( 'bws_forgot_pass_form', $is_user_logged_in ) && 'forgot_password' === $form ) {
599 return gglcptch_display( array(), $content );
600 }
601 return $content;
602 }
603 }
604
605 if ( ! function_exists( 'gglcptch_check_login_register_forms' ) ) {
606 /**
607 * Check google captcha in BWS Testimonial
608 *
609 * @param string $form Form name.
610 * @return string $error_message Error for reCaptcha.
611 */
612 function gglcptch_check_login_register_forms( $form ) {
613 global $gglcptch_options;
614 $gglcptch_check = gglcptch_check( 'bws_' . $form . '_form' );
615 if ( ! $gglcptch_check['response'] ) {
616 $error_message = implode( '<br>', $gglcptch_check['errors']->get_error_messages() );
617 return $error_message;
618 }
619 return '';
620 }
621 }
622
623