Contact Form 7 – reCaptcha v2 - Version 1.3.9

Version Description

(2022-04-13) = * Using wp_is_block_theme() to conditionally test if Google ReCaptcha script should be enqueued globally or inline.

Download this release

Release Info

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

Code changes from version 1.3.8 to 1.3.9

Files changed (4) hide show
  1. changelog.txt +15 -0
  2. readme.txt +5 -5
  3. recaptcha-v2.php +12 -1
  4. wpcf7-recaptcha.php +1 -1
changelog.txt CHANGED
@@ -2,6 +2,21 @@
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.3.8 =
6
 
7
  Release Date: March 07, 2022
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.3.9 =
6
+
7
+ Release Date: April 13, 2022
8
+
9
+ * Overview
10
+ * Used the `wp_is_block_theme()` to conditionally check if Google ReCaptcha should be enqueued globally.
11
+ If false, the script will load whenever the shortcode is called and only enqueue on pages where it's used.
12
+ WordPress should detect this and late enqueue it into the footer.
13
+ * FSE Themes will still need to use Google ReCpatha script globally until there is an easier way to detect if a script
14
+ should be used or start supporting late enqueues.
15
+
16
+ * Code Changes
17
+ * Added conditional for `wp_is_block_theme()`: recaptcha-v2.php LN 87
18
+ * Re-added the inline enqueue check to shortcode callback: recaptcha-v2.php LN 110
19
+
20
  = 1.3.8 =
21
 
22
  Release Date: March 07, 2022
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: iqcomputing
3
  Tags: contact-form-7, contact-form-7-recaptcha, recaptcha, spam
4
  Requires at least: 4.9
5
  Tested up to: 5.8
6
- Stable tag: 1.3.8
7
  License: GPLv2 or later
8
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -60,12 +60,12 @@ Should the above be correct, at this point it's time to open a support thread fo
60
 
61
  == Changelog ==
62
 
 
 
 
63
  = 1.3.8 (2022-03-07) =
64
  * New global reCaptcha Locale filter hook `wpcf7_recaptcha_locale`.
65
 
66
  = 1.3.7 (2022-01-03) =
67
  * Happy New Year!
68
- * Fixed issue with reCpatcha not appearing in the new WordPress Full Site Editing feature of TwentyTwentyTwo theme. Thanks @gerhardfasol !
69
-
70
- = 1.3.6 (2021-11-29) =
71
- * Resolved conflict with Conditional Fields for Contact Form 7.
3
  Tags: contact-form-7, contact-form-7-recaptcha, recaptcha, spam
4
  Requires at least: 4.9
5
  Tested up to: 5.8
6
+ Stable tag: 1.3.9
7
  License: GPLv2 or later
8
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
9
 
60
 
61
  == Changelog ==
62
 
63
+ = 1.3.9 (2022-04-13) =
64
+ * Using `wp_is_block_theme()` to conditionally test if Google ReCaptcha script should be enqueued globally or inline.
65
+
66
  = 1.3.8 (2022-03-07) =
67
  * New global reCaptcha Locale filter hook `wpcf7_recaptcha_locale`.
68
 
69
  = 1.3.7 (2022-01-03) =
70
  * Happy New Year!
71
+ * Fixed issue with reCpatcha not appearing in the new WordPress Full Site Editing feature of TwentyTwentyTwo theme. Thanks @gerhardfasol !
 
 
 
recaptcha-v2.php CHANGED
@@ -79,7 +79,14 @@ function iqfix_wpcf7_recaptcha_enqueue_scripts() {
79
  'response_err' => esc_html__( 'wpcf7-recaptcha: Could not verify reCaptcha response.', 'wpcf7-recaptcha' ),
80
  ) );
81
 
82
- wp_enqueue_script( 'google-recaptcha' );
 
 
 
 
 
 
 
83
 
84
  }
85
  add_action( 'wp_enqueue_scripts', 'iqfix_wpcf7_recaptcha_enqueue_scripts', 50 );
@@ -100,6 +107,10 @@ function iqfix_wpcf7_recaptcha_form_tag_handler( $tag ) {
100
 
101
  $atts = array();
102
 
 
 
 
 
103
  $recaptcha = WPCF7_RECAPTCHA::get_instance();
104
  $atts['data-sitekey'] = $recaptcha->get_sitekey();
105
  $atts['data-type'] = $tag->get_option( 'type', '(audio|image)', true );
79
  'response_err' => esc_html__( 'wpcf7-recaptcha: Could not verify reCaptcha response.', 'wpcf7-recaptcha' ),
80
  ) );
81
 
82
+ /**
83
+ * Enqueue globally for FSE Themes.
84
+ * Enqueue as needed for all other
85
+ * themes in the shortcode callback.
86
+ */
87
+ if( function_exists( 'wp_is_block_theme' ) && wp_is_block_theme() ) {
88
+ wp_enqueue_script( 'google-recaptcha' );
89
+ }
90
 
91
  }
92
  add_action( 'wp_enqueue_scripts', 'iqfix_wpcf7_recaptcha_enqueue_scripts', 50 );
107
 
108
  $atts = array();
109
 
110
+ if( ! wp_script_is( 'google-recaptcha', 'enequeued' ) ) {
111
+ wp_enqueue_script( 'google-recaptcha' );
112
+ }
113
+
114
  $recaptcha = WPCF7_RECAPTCHA::get_instance();
115
  $atts['data-sitekey'] = $recaptcha->get_sitekey();
116
  $atts['data-type'] = $tag->get_option( 'type', '(audio|image)', true );
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.3.8
6
  * Author: IQComputing
7
  * Author URI: http://www.iqcomputing.com/
8
  * License: GPL2
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.3.9
6
  * Author: IQComputing
7
  * Author URI: http://www.iqcomputing.com/
8
  * License: GPL2