Contact Form 7 – reCaptcha v2 - Version 1.2.3

Version Description

(2019-10-13) = * Added support for wp-config Contact Form 7 key constants. * Added support for reCaptcha alignment. * Fixed an issue with google response logging should the api return an error.

Download this release

Release Info

Developer IQComputing
Plugin Icon 128x128 Contact Form 7 – reCaptcha v2
Version 1.2.3
Comparing to
See all releases

Code changes from version 1.2.2 to 1.2.3

Files changed (4) hide show
  1. changelog.txt +12 -0
  2. readme.txt +8 -8
  3. recaptcha-v2.php +41 -10
  4. wpcf7-recaptcha.php +2 -2
changelog.txt CHANGED
@@ -2,6 +2,18 @@
2
 
3
  This is to keep track of all changes the plugin undertakes. The readme.txt should only contain the most recent 3.
4
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  = 1.2.2 =
6
 
7
  Release Date: September 17, 2019
2
 
3
  This is to keep track of all changes the plugin undertakes. The readme.txt should only contain the most recent 3.
4
 
5
+ = 1.2.3 =
6
+
7
+ Release Date: November 13, 2019
8
+
9
+ * Features
10
+ * Added reCaptcha alignment controls to the reCaptcha shortcode. Left, Center, Right.
11
+ * Added support for the Contact Form 7 constants `WPCF7_RECAPTCHA_SITEKEY` and `WPCF7_RECAPTCHA_SECRET` in the WP Config.
12
+ * For more information see the post by Takayuki Miyoshi ( https://contactform7.com/2019/08/04/contact-form-7-514/ )
13
+
14
+ * Fixes
15
+ * Updated the logging feature for whenever the reCaptcha returns an error. Uses Contact Form 7 log method.
16
+
17
  = 1.2.2 =
18
 
19
  Release Date: September 17, 2019
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: iqcomputing
3
  Tags: contact-form-7, contact-form-7-recaptcha, recaptcha, spam
4
  Requires at least: 4.9
5
- Tested up to: 5.2
6
- Stable tag: 1.2.2
7
  License: GPLv2 or later
8
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -60,13 +60,13 @@ Should the above be correct, at this point it's time to open a support thread fo
60
 
61
  == Changelog ==
62
 
 
 
 
 
 
63
  = 1.2.2 (2019-09-17) =
64
  * Fixed translation function to include plugin slug. Thanks @alexclassroom !
65
 
66
  = 1.2.1 (2019-09-09) =
67
- * Updated the plugin name to fix Trademark infringement.
68
-
69
- = 1.2.0 (2019-06-13) =
70
- * Removed jQuery dependecy.
71
- * Converted jQuery reCaptcha submission check to vanilla JavaScript.
72
- * Updated reCaptcha noscript to account for A3 Lazy Load Plugin.
2
  Contributors: iqcomputing
3
  Tags: contact-form-7, contact-form-7-recaptcha, recaptcha, spam
4
  Requires at least: 4.9
5
+ Tested up to: 5.3
6
+ Stable tag: 1.2.3
7
  License: GPLv2 or later
8
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
9
 
60
 
61
  == Changelog ==
62
 
63
+ = 1.2.3 (2019-10-13) =
64
+ * Added support for wp-config Contact Form 7 key constants.
65
+ * Added support for reCaptcha alignment.
66
+ * Fixed an issue with google response logging should the api return an error.
67
+
68
  = 1.2.2 (2019-09-17) =
69
  * Fixed translation function to include plugin slug. Thanks @alexclassroom !
70
 
71
  = 1.2.1 (2019-09-09) =
72
+ * Updated the plugin name to fix Trademark infringement.
 
 
 
 
 
recaptcha-v2.php CHANGED
@@ -109,6 +109,7 @@ var recaptchaCallback = function() {
109
  'type': divs[ j ].getAttribute( 'data-type' ),
110
  'size': divs[ j ].getAttribute( 'data-size' ),
111
  'theme': divs[ j ].getAttribute( 'data-theme' ),
 
112
  'badge': divs[ j ].getAttribute( 'data-badge' ),
113
  'tabindex': divs[ j ].getAttribute( 'data-tabindex' )
114
  };
@@ -189,6 +190,7 @@ function iqfix_wpcf7_recaptcha_form_tag_handler( $tag ) {
189
  $atts['data-size'] = $tag->get_option(
190
  'size', '(compact|normal|invisible)', true );
191
  $atts['data-theme'] = $tag->get_option( 'theme', '(dark|light)', true );
 
192
  $atts['data-badge'] = $tag->get_option(
193
  'badge', '(bottomright|bottomleft|inline)', true );
194
  $atts['data-tabindex'] = $tag->get_option( 'tabindex', 'signed_int', true );
@@ -422,6 +424,26 @@ function iqfix_wpcf7_tag_generator_recaptcha( $contact_form, $args = '' ) {
422
  </td>
423
  </tr>
424
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
425
  <tr>
426
  <th scope="row"><label for="<?php echo esc_attr( $args['content'] . '-id' ); ?>"><?php
427
  /* translators: HTML Attribute ID for reCaptcha box */
@@ -487,7 +509,13 @@ function iqfix_recaptcha_class_init() {
487
  * return void
488
  */
489
  private function __construct() {
490
- $this->sitekeys = WPCF7::get_option( 'recaptcha' );
 
 
 
 
 
 
491
  }
492
 
493
 
@@ -585,19 +613,20 @@ function iqfix_recaptcha_class_init() {
585
  return $is_human;
586
  }
587
 
588
- $source = WPCF7::get_option( 'iqfix_recaptcha_source' );
589
- $source = IQFix_WPCF7_Deity::verify_recaptcha_source( $source );
590
- $url = sprintf( 'https://www.%s/recaptcha/api/siteverify', $source );
591
- $sitekey = $this->get_sitekey();
592
- $secret = $this->get_secret( $sitekey );
593
-
594
- $response = wp_safe_remote_post( $url, array(
595
  'body' => array(
596
  'secret' => $secret,
597
  'response' => $response_token,
598
  'remoteip' => $_SERVER['REMOTE_ADDR'],
599
  ),
600
- ) );
 
 
601
 
602
  if ( 200 != wp_remote_retrieve_response_code( $response ) ) {
603
 
@@ -630,7 +659,9 @@ add_action( 'init', 'iqfix_recaptcha_class_init', 11 );
630
  */
631
  function iqfix_recaptcha_inline_css() {
632
 
633
- $iqfix_css ='.wpcf7 .wpcf7-recaptcha iframe {margin-bottom: 0;}';
 
 
634
  wp_add_inline_style( 'contact-form-7', $iqfix_css );
635
 
636
  }
109
  'type': divs[ j ].getAttribute( 'data-type' ),
110
  'size': divs[ j ].getAttribute( 'data-size' ),
111
  'theme': divs[ j ].getAttribute( 'data-theme' ),
112
+ 'align': divs[ j ].getAttribute( 'data-align' ),
113
  'badge': divs[ j ].getAttribute( 'data-badge' ),
114
  'tabindex': divs[ j ].getAttribute( 'data-tabindex' )
115
  };
190
  $atts['data-size'] = $tag->get_option(
191
  'size', '(compact|normal|invisible)', true );
192
  $atts['data-theme'] = $tag->get_option( 'theme', '(dark|light)', true );
193
+ $atts['data-align'] = $tag->get_option( 'align', '(left|center|right)', true );
194
  $atts['data-badge'] = $tag->get_option(
195
  'badge', '(bottomright|bottomleft|inline)', true );
196
  $atts['data-tabindex'] = $tag->get_option( 'tabindex', 'signed_int', true );
424
  </td>
425
  </tr>
426
 
427
+ <tr>
428
+ <th scope="row"><?php
429
+ /* translators: ReCaptcha theme (light or dark) */
430
+ esc_html_e( 'Alignment', 'wpcf7-recaptcha' );
431
+ ?></th>
432
+ <td>
433
+ <fieldset>
434
+ <legend class="screen-reader-text"><?php
435
+ /* translators: Alignment of the reCaptcha box (left, center, right) */
436
+ esc_html_e( 'Alignment', 'wpcf7-recaptcha' );
437
+ ?></legend>
438
+ <label for="<?php echo esc_attr( $args['content'] . '-align-left' ); ?>"><input type="radio" name="align" class="option default" id="<?php echo esc_attr( $args['content'] . '-align-left' ); ?>" value="left" checked="checked" /> <?php /* translators: ReCaptcha alignment: left */ esc_html_e( 'Left', 'wpcf7-recaptcha' ); ?></label>
439
+ <br />
440
+ <label for="<?php echo esc_attr( $args['content'] . '-align-center' ); ?>"><input type="radio" name="align" class="option" id="<?php echo esc_attr( $args['content'] . '-align-center' ); ?>" value="center" /> <?php /* translators: ReCaptcha alignment: center */ esc_html_e( 'Center', 'wpcf7-recaptcha' ); ?></label>
441
+ <br />
442
+ <label for="<?php echo esc_attr( $args['content'] . '-align-right' ); ?>"><input type="radio" name="align" class="option" id="<?php echo esc_attr( $args['content'] . '-align-right' ); ?>" value="right" /> <?php /* translators: ReCaptcha alignment: right */ esc_html_e( 'Right', 'wpcf7-recaptcha' ); ?></label>
443
+ </fieldset>
444
+ </td>
445
+ </tr>
446
+
447
  <tr>
448
  <th scope="row"><label for="<?php echo esc_attr( $args['content'] . '-id' ); ?>"><?php
449
  /* translators: HTML Attribute ID for reCaptcha box */
509
  * return void
510
  */
511
  private function __construct() {
512
+
513
+ if( defined( 'WPCF7_RECAPTCHA_SITEKEY' ) && defined( 'WPCF7_RECAPTCHA_SECRET' ) ) {
514
+ $this->sitekeys = array( WPCF7_RECAPTCHA_SITEKEY => WPCF7_RECAPTCHA_SECRET );
515
+ } else {
516
+ $this->sitekeys = WPCF7::get_option( 'recaptcha' );
517
+ }
518
+
519
  }
520
 
521
 
613
  return $is_human;
614
  }
615
 
616
+ $source = WPCF7::get_option( 'iqfix_recaptcha_source' );
617
+ $source = IQFix_WPCF7_Deity::verify_recaptcha_source( $source );
618
+ $endpoint = sprintf( 'https://www.%s/recaptcha/api/siteverify', $source );
619
+ $sitekey = $this->get_sitekey();
620
+ $secret = $this->get_secret( $sitekey );
621
+ $request = array(
 
622
  'body' => array(
623
  'secret' => $secret,
624
  'response' => $response_token,
625
  'remoteip' => $_SERVER['REMOTE_ADDR'],
626
  ),
627
+ );
628
+
629
+ $response = wp_safe_remote_post( esc_url_raw( $endpoint ), $request );
630
 
631
  if ( 200 != wp_remote_retrieve_response_code( $response ) ) {
632
 
659
  */
660
  function iqfix_recaptcha_inline_css() {
661
 
662
+ $iqfix_css = '.wpcf7 .wpcf7-recaptcha iframe {margin-bottom: 0;}';
663
+ $iqfix_css .= '.wpcf7 .wpcf7-recaptcha[data-align="center"] > div {margin: 0 auto;}';
664
+ $iqfix_css .= '.wpcf7 .wpcf7-recaptcha[data-align="right"] > div {margin: 0 0 0 auto;}';
665
  wp_add_inline_style( 'contact-form-7', $iqfix_css );
666
 
667
  }
wpcf7-recaptcha.php CHANGED
@@ -2,7 +2,7 @@
2
  /**
3
  * Plugin Name: ReCaptcha v2 for Contact Form 7
4
  * Description: ReCaptcha v2 Fix for Contact Form 7 5.1 and later.
5
- * Version: 1.2.2
6
  * Author: IQComputing
7
  * Author URI: http://www.iqcomputing.com/
8
  * License: GPL2
@@ -18,7 +18,7 @@ defined( 'ABSPATH' ) or die( 'You cannot be here.' );
18
  */
19
  Class IQFix_WPCF7_Deity {
20
 
21
- public static $version = '1.2.2';
22
 
23
 
24
  /**
2
  /**
3
  * Plugin Name: ReCaptcha v2 for Contact Form 7
4
  * Description: ReCaptcha v2 Fix for Contact Form 7 5.1 and later.
5
+ * Version: 1.2.3
6
  * Author: IQComputing
7
  * Author URI: http://www.iqcomputing.com/
8
  * License: GPL2
18
  */
19
  Class IQFix_WPCF7_Deity {
20
 
21
+ public static $version = '1.2.3';
22
 
23
 
24
  /**