Contact Form 7 – reCaptcha v2 - Version 1.1.4

Version Description

(2019-02-21) = * We need your help translating this plugin! Interested parties may contribute at: https://translate.wordpress.org/projects/wp-plugins/wpcf7-recaptcha * * Ensured WordPress 5.1 compatibility * Removed languages folder to avoid confusion with glotpress. * Multisite - Network Admins will notice a new menu item under plugins labelled "WPCF7 reCaptcha Settings" * Multisite - Network Admins now have the ability to add default keys and settings for sites. Individual sites can overwrite these defaults should they choose to. * Multisite - Default Network settings do not override keys or settings if they are already set/saved on the individual site. These only apply if none are found on the individual site.

Download this release

Release Info

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

Code changes from version 1.1.3 to 1.1.4

Files changed (4) hide show
  1. changelog.txt +16 -0
  2. languages/wpcf7-recaptcha.pot +0 -119
  3. readme.txt +12 -6
  4. wpcf7-recaptcha.php +139 -7
changelog.txt CHANGED
@@ -2,6 +2,22 @@
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.1.3 =
6
 
7
  Relase Date: February 06, 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.1.4 =
6
+
7
+ Relase Date: February 22, 2019
8
+
9
+ * General
10
+ * Ensured WordPress 5.1 compatibility
11
+ * We need your help translating this plugin! Please contribute at: https://translate.wordpress.org/projects/wp-plugins/wpcf7-recaptcha
12
+
13
+ * Multisite
14
+ * Multisite - Network Admins will notice a new menu item under plugins labelled "WPCF7 reCaptcha Settings"
15
+ * Multisite - Network Admins now have the ability to add default keys and settings for sites. Individual sites can overwrite these defaults should they choose to.
16
+ * Multisite - Default Network settings do not override keys or settings if they are already set/saved on the individual site. These only apply if none are found on the individual site.
17
+
18
+ * Cleanup
19
+ * Removed languages folder to avoid confusion with glotpress.
20
+
21
  = 1.1.3 =
22
 
23
  Relase Date: February 06, 2019
languages/wpcf7-recaptcha.pot DELETED
@@ -1,119 +0,0 @@
1
- msgid ""
2
- msgstr ""
3
- "Project-Id-Version: \n"
4
- "POT-Creation-Date: 2019-01-12 19:12-0600\n"
5
- "PO-Revision-Date: 2019-01-12 19:20-0600\n"
6
- "Last-Translator: \n"
7
- "Language-Team: \n"
8
- "Language: en\n"
9
- "MIME-Version: 1.0\n"
10
- "Content-Type: text/plain; charset=UTF-8\n"
11
- "Content-Transfer-Encoding: 8bit\n"
12
- "X-Generator: Poedit 2.2\n"
13
- "X-Poedit-Basepath: ..\n"
14
- "Plural-Forms: nplurals=2; plural=(n != 1);\n"
15
- "X-Poedit-KeywordsList: __;_e;esc_html;esc_html__;esc_att;esc_attr__;"
16
- "esc_attr_e;esc_html_e\n"
17
- "X-Poedit-SearchPath-0: .\n"
18
-
19
- #: recaptcha-v2.php:71
20
- msgid "Please verify that you are not a robot."
21
- msgstr ""
22
-
23
- #: recaptcha-v2.php:338 recaptcha-v2.php:369 recaptcha-v2.php:378
24
- msgid "reCAPTCHA"
25
- msgstr ""
26
-
27
- #: recaptcha-v2.php:369
28
- #, php-format
29
- msgid ""
30
- "To use reCAPTCHA, first you need to install an API key pair. For more "
31
- "details, see %s."
32
- msgstr ""
33
-
34
- #: recaptcha-v2.php:369 recaptcha-v2.php:378
35
- msgid "https://contactform7.com/recaptcha/"
36
- msgstr ""
37
-
38
- #: recaptcha-v2.php:377
39
- #, php-format
40
- msgid "Generate a form-tag for a reCAPTCHA widget. For more details, see %s."
41
- msgstr ""
42
-
43
- #: recaptcha-v2.php:388 recaptcha-v2.php:391
44
- msgid "Size"
45
- msgstr ""
46
-
47
- #: recaptcha-v2.php:392
48
- msgid "Normal"
49
- msgstr ""
50
-
51
- #: recaptcha-v2.php:394
52
- msgid "Compact"
53
- msgstr ""
54
-
55
- #: recaptcha-v2.php:400 recaptcha-v2.php:403
56
- msgid "Theme"
57
- msgstr ""
58
-
59
- #: recaptcha-v2.php:404
60
- msgid "Light"
61
- msgstr ""
62
-
63
- #: recaptcha-v2.php:406
64
- msgid "Dark"
65
- msgstr ""
66
-
67
- #: recaptcha-v2.php:412
68
- msgid "Id attribute"
69
- msgstr ""
70
-
71
- #: recaptcha-v2.php:417
72
- msgid "Class attribute"
73
- msgstr ""
74
-
75
- #: recaptcha-v2.php:430
76
- msgid "Insert Tag"
77
- msgstr ""
78
-
79
- #: wpcf7-recaptcha.php:88 wpcf7-recaptcha.php:89
80
- msgid "reCaptcha Version"
81
- msgstr ""
82
-
83
- #: wpcf7-recaptcha.php:123 wpcf7-recaptcha.php:135
84
- msgid "Contact Form 7 - reCaptcha v2"
85
- msgstr ""
86
-
87
- #: wpcf7-recaptcha.php:124
88
- msgid ""
89
- "This version of Contact Form 7 already uses reCaptcha version 2, you do not "
90
- "need 'Contact Form 7 - reCaptcha v2' installed at this time."
91
- msgstr ""
92
-
93
- #: wpcf7-recaptcha.php:140
94
- msgid "Your reCaptcha settings have been updated."
95
- msgstr ""
96
-
97
- #: wpcf7-recaptcha.php:145
98
- msgid "Select the version of reCaptcha you would like to use."
99
- msgstr ""
100
-
101
- #: wpcf7-recaptcha.php:146
102
- msgid "You will still need to use the"
103
- msgstr ""
104
-
105
- #: wpcf7-recaptcha.php:147
106
- msgid "shortcode tag in your Contact Form 7 forms."
107
- msgstr ""
108
-
109
- #: wpcf7-recaptcha.php:154
110
- msgid "Default Usage"
111
- msgstr ""
112
-
113
- #: wpcf7-recaptcha.php:155
114
- msgid "reCaptcha Version 2"
115
- msgstr ""
116
-
117
- #: wpcf7-recaptcha.php:158
118
- msgid "Submit"
119
- msgstr ""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.0.2
6
- Stable tag: 1.1.3
7
  License: GPLv2 or later
8
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -59,6 +59,15 @@ Should the above be correct, at this point it's time to open a support thread fo
59
 
60
  == Changelog ==
61
 
 
 
 
 
 
 
 
 
 
62
  = 1.1.3 (2019-02-06) =
63
  * An attempt to make translations easier and better overall.
64
  * Combined a few redundant translation functions into a single translation function.
@@ -68,7 +77,4 @@ Should the above be correct, at this point it's time to open a support thread fo
68
  = 1.1.2 (2019-01-14) =
69
  * Renamed Text Domain to match the plugin slug which should help translations.
70
  * Added Portable Object Template (.pot) file to /languages/ folder.
71
- * Added call to action on settings page which encourages users to like IQComputing on Facebook to receive the latest news and updates.
72
-
73
- = 1.1.1 (2019-01-07) =
74
- * Adds message whenever user forgets to click reCaptcha checkbox.
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.1
6
+ Stable tag: 1.1.4
7
  License: GPLv2 or later
8
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
9
 
59
 
60
  == Changelog ==
61
 
62
+ = 1.1.4 (2019-02-21) =
63
+ * We need your help translating this plugin! Interested parties may contribute at: https://translate.wordpress.org/projects/wp-plugins/wpcf7-recaptcha
64
+ *
65
+ * Ensured WordPress 5.1 compatibility
66
+ * Removed languages folder to avoid confusion with glotpress.
67
+ * Multisite - Network Admins will notice a new menu item under plugins labelled "WPCF7 reCaptcha Settings"
68
+ * Multisite - Network Admins now have the ability to add default keys and settings for sites. Individual sites can overwrite these defaults should they choose to.
69
+ * Multisite - Default Network settings do not override keys or settings if they are already set/saved on the individual site. These only apply if none are found on the individual site.
70
+
71
  = 1.1.3 (2019-02-06) =
72
  * An attempt to make translations easier and better overall.
73
  * Combined a few redundant translation functions into a single translation function.
77
  = 1.1.2 (2019-01-14) =
78
  * Renamed Text Domain to match the plugin slug which should help translations.
79
  * Added Portable Object Template (.pot) file to /languages/ folder.
80
+ * Added call to action on settings page which encourages users to like IQComputing on Facebook to receive the latest news and updates.
 
 
 
wpcf7-recaptcha.php CHANGED
@@ -2,7 +2,7 @@
2
  /**
3
  * Plugin Name: Contact Form 7 - reCaptcha v2
4
  * Description: ReCaptcha v2 Fix for Contact Form 7 5.1 and later.
5
- * Version: 1.1.3
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.1.3';
22
 
23
 
24
  /**
@@ -31,6 +31,7 @@ Class IQFix_WPCF7_Deity {
31
  $class = new self();
32
  $class->include_files();
33
  $class->action_hooks();
 
34
 
35
  }
36
 
@@ -63,9 +64,22 @@ Class IQFix_WPCF7_Deity {
63
  */
64
  private function action_hooks() {
65
 
66
- add_action( 'admin_menu', array( $this, 'register_submenus' ) );
 
67
 
68
  }
 
 
 
 
 
 
 
 
 
 
 
 
69
 
70
 
71
  /**
@@ -85,6 +99,25 @@ Class IQFix_WPCF7_Deity {
85
  );
86
 
87
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
 
89
 
90
  /**
@@ -95,14 +128,39 @@ Class IQFix_WPCF7_Deity {
95
  public function display_recaptcha_version_subpage() {
96
 
97
  $updated = false;
98
- $selection = WPCF7::get_option( 'iqfix_recaptcha' );
 
 
 
 
 
 
 
 
99
 
100
  // Update Option
101
  if( isset( $_POST, $_POST['iqfix_recaptcha_version'], $_POST['iqfix_wpcf7_submit'] ) ) {
102
 
103
  if( ! empty( $_POST['iqfix_wpcf7_nonce'] ) && wp_verify_nonce( $_POST['iqfix_wpcf7_nonce'], 'iqfix_wpcf7_vers_select' ) ) {
104
  $selection = intval( $_POST['iqfix_recaptcha_version'] );
105
- WPCF7::update_option( 'iqfix_recaptcha', $selection );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
  $updated = true;
107
  }
108
 
@@ -152,7 +210,34 @@ Class IQFix_WPCF7_Deity {
152
  <option value="0"><?php esc_html_e( 'Default Usage', 'wpcf7-recaptcha' ); ?></option>
153
  <option value="2" <?php selected( $selection, 2, true ); ?>><?php esc_html_e( 'reCaptcha Version 2', 'wpcf7-recaptcha' ); ?></option>
154
  </select>
155
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
156
  <?php submit_button( esc_html__( 'Submit', 'wpcf7-recaptcha' ), 'submit', 'iqfix_wpcf7_submit' ); ?>
157
  </form>
158
 
@@ -160,7 +245,7 @@ Class IQFix_WPCF7_Deity {
160
  <?php
161
  printf( '<a href="%1$s" target="_blank"><img src="%2$s" width="540" height="410" alt="%3$s" /></a>',
162
  esc_url( 'https://www.facebook.com/iqcomputing' ),
163
- esc_url( trailingslashit( plugin_dir_url( __FILE__ ) ) . 'assets/images/facebook-like.png' ),
164
  /* translators: Image alternative tag. */
165
  esc_attr__( 'Like IQComputing on Facebook mascot', 'wpcf7-recaptcha' )
166
  );
@@ -175,6 +260,53 @@ Class IQFix_WPCF7_Deity {
175
  <?php
176
 
177
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
178
 
179
 
180
  } // END Class IQFix_WPCF7_Deity
2
  /**
3
  * Plugin Name: Contact Form 7 - reCaptcha v2
4
  * Description: ReCaptcha v2 Fix for Contact Form 7 5.1 and later.
5
+ * Version: 1.1.4
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.1.4';
22
 
23
 
24
  /**
31
  $class = new self();
32
  $class->include_files();
33
  $class->action_hooks();
34
+ $class->filter_hooks();
35
 
36
  }
37
 
64
  */
65
  private function action_hooks() {
66
 
67
+ add_action( 'admin_menu', array( $this, 'register_submenus' ) );
68
+ add_action( 'network_admin_menu', array( $this, 'register_network_submenus' ) );
69
 
70
  }
71
+
72
+
73
+ /**
74
+ * Add any necessary filter hooks
75
+ *
76
+ * @return void
77
+ */
78
+ private function filter_hooks() {
79
+
80
+ add_filter( 'option_wpcf7', array( $this, 'network_wpcf7_options' ), 9 );
81
+
82
+ }
83
 
84
 
85
  /**
99
  );
100
 
101
  }
102
+
103
+
104
+ /**
105
+ * Register submenus for the Network Admin Panel
106
+ *
107
+ * @return void
108
+ */
109
+ public function register_network_submenus() {
110
+
111
+ add_submenu_page(
112
+ 'plugins.php',
113
+ esc_html__( 'WPCF7 reCaptcha Settings', 'wpcf7-recaptcha' ),
114
+ esc_html__( 'WPCF7 reCaptcha Settings', 'wpcf7-recaptcha' ),
115
+ 'manage_network_plugins',
116
+ 'recaptcha-version',
117
+ array( $this, 'display_recaptcha_version_subpage' )
118
+ );
119
+
120
+ }
121
 
122
 
123
  /**
128
  public function display_recaptcha_version_subpage() {
129
 
130
  $updated = false;
131
+
132
+ if( is_network_admin() ) {
133
+ $network_options = get_site_option( 'network_iqfix_recaptcha' );
134
+ $selection = ( ! empty( $network_options['iqfix_recaptcha'] ) ) ? $network_options['iqfix_recaptcha'] : '';
135
+ $sitekey = ( ! empty( $network_options['sitekey'] ) ) ? $network_options['sitekey'] : '';
136
+ $secretkey = ( ! empty( $network_options['secret'] ) ) ? $network_options['secret'] : '';
137
+ } else {
138
+ $selection = WPCF7::get_option( 'iqfix_recaptcha' );
139
+ }
140
 
141
  // Update Option
142
  if( isset( $_POST, $_POST['iqfix_recaptcha_version'], $_POST['iqfix_wpcf7_submit'] ) ) {
143
 
144
  if( ! empty( $_POST['iqfix_wpcf7_nonce'] ) && wp_verify_nonce( $_POST['iqfix_wpcf7_nonce'], 'iqfix_wpcf7_vers_select' ) ) {
145
  $selection = intval( $_POST['iqfix_recaptcha_version'] );
146
+
147
+ if( is_network_admin() && isset( $_POST['wpcf7_recaptcha_network'] ) ) {
148
+
149
+ $sitekey = trim( $_POST['wpcf7_recaptcha_network']['sitekey'] );
150
+ $secretkey = trim( $_POST['wpcf7_recaptcha_network']['secretkey'] );
151
+
152
+ update_site_option( 'network_iqfix_recaptcha', array(
153
+ 'sitekey' => $sitekey,
154
+ 'secret' => $secretkey,
155
+ 'iqfix_recaptcha' => $selection,
156
+ ) );
157
+
158
+ } else {
159
+
160
+ WPCF7::update_option( 'iqfix_recaptcha', $selection );
161
+
162
+ }
163
+
164
  $updated = true;
165
  }
166
 
210
  <option value="0"><?php esc_html_e( 'Default Usage', 'wpcf7-recaptcha' ); ?></option>
211
  <option value="2" <?php selected( $selection, 2, true ); ?>><?php esc_html_e( 'reCaptcha Version 2', 'wpcf7-recaptcha' ); ?></option>
212
  </select>
213
+
214
+ <?php if( is_network_admin() ) : ?>
215
+
216
+ <hr />
217
+ <h2>Network Wide Settings</h2>
218
+
219
+ <p><strong><?php _e( 'Please read all of the below before committing to these changes.', 'wpcf7-recaptcha' ); ?></strong></p>
220
+ <p><?php _e( 'You may set Network wide API keys below. Please ensure that every network site is whitelisted in the Google API Console. ReCaptcha keys can still be set ( or unset ) on a per site basis if necessary.', 'wpcf7-recaptcha' ); ?></p>
221
+ <p><?php
222
+ /* translators: Care for HTML in string used for emphasis. */
223
+ _e( 'Do note that these keys will automatically apply to all network websites upon save <strong>if keys are not detected</strong>. If some network websites use reCaptcha v3 please <u>do not use this option</u> and set it on a per site level.', 'wpcf7-recaptcha' );
224
+ ?></p>
225
+
226
+ <table class="form-table">
227
+ <tbody>
228
+ <tr>
229
+ <th><?php _e( 'Site Key', 'wpcf7-recaptcha' ); ?></th>
230
+ <td><input type="text" name="wpcf7_recaptcha_network[sitekey]" class="regular-text" value="<?php echo esc_attr( $sitekey ); ?>" /></td>
231
+ </tr>
232
+ <tr>
233
+ <th><?php _e( 'Secret Key', 'wpcf7-recaptcha' ); ?></th>
234
+ <td><input type="password" name="wpcf7_recaptcha_network[secretkey]" class="regular-text" value="<?php echo esc_attr( $secretkey ); ?>" /></td>
235
+ </tr>
236
+ </tbody>
237
+ </table>
238
+
239
+ <?php endif; ?>
240
+
241
  <?php submit_button( esc_html__( 'Submit', 'wpcf7-recaptcha' ), 'submit', 'iqfix_wpcf7_submit' ); ?>
242
  </form>
243
 
245
  <?php
246
  printf( '<a href="%1$s" target="_blank"><img src="%2$s" width="540" height="410" alt="%3$s" /></a>',
247
  esc_url( 'https://www.facebook.com/iqcomputing' ),
248
+ plugins_url( 'assets/images/facebook-like.png', __FILE__ ),
249
  /* translators: Image alternative tag. */
250
  esc_attr__( 'Like IQComputing on Facebook mascot', 'wpcf7-recaptcha' )
251
  );
260
  <?php
261
 
262
  }
263
+
264
+
265
+ /**
266
+ * Filter Hook into WPCF7 get option
267
+ * Maybe replace it work a network option
268
+ *
269
+ * @param Mixed $value
270
+ * @param Stirng $option_name
271
+ *
272
+ * @return Mixed $value
273
+ */
274
+ public function network_wpcf7_options( $value ) {
275
+
276
+ // If we're not on a multisite setup we can skip this filter hook
277
+ if( ! is_multisite() || empty( $value ) ) {
278
+ return $value;
279
+ }
280
+
281
+ // Allow sites to be setup regardless of network specifciations
282
+ if( is_admin()
283
+ && isset( $_GET, $_GET['page'], $_GET['service'], $_GET['action'] )
284
+ && 'wpcf7-integration' == $_GET['page']
285
+ && 'recaptcha' == $_GET['service']
286
+ && 'setup' == $_GET['action']
287
+ ) {
288
+ return $value;
289
+ }
290
+
291
+ // Grab Network Option
292
+ $network_wpcf7 = get_site_option( 'network_iqfix_recaptcha' );
293
+ $network_wpcf7 = array_filter( (array)$network_wpcf7 );
294
+
295
+ // Set site keys IF there are no API keys set.
296
+ if( empty( $value['recaptcha'] ) && ! empty( $network_wpcf7['sitekey'] ) && ! empty( $network_wpcf7['secret'] ) ) {
297
+ $value['recaptcha'] = array(
298
+ $network_wpcf7['sitekey'] => $network_wpcf7['secret'],
299
+ );
300
+ }
301
+
302
+ // Set IQFix reCaptcha
303
+ if( ! isset( $value['iqfix_recaptcha'] ) && ! empty( $network_wpcf7['iqfix_recaptcha'] ) ) {
304
+ $value['iqfix_recaptcha'] = $network_wpcf7['iqfix_recaptcha'];
305
+ }
306
+
307
+ return $value;
308
+
309
+ }
310
 
311
 
312
  } // END Class IQFix_WPCF7_Deity