Version Description
- Feature: Changed Contact Form 7 support: As of version 4.3 CF7 comes with its own recaptcha. The plugin now just makes sure both captchas work together. It also keeps the API keys in sync.
- Fix: Disable Captcha for logged in users now respects custom roles without read capability. (Thanks to @lainme)
Download this release
Release Info
Developer | podpirate |
Plugin | WordPress ReCaptcha Integration |
Version | 1.1.10 |
Comparing to | |
See all releases |
Code changes from version 1.1.9 to 1.1.10
- .svnignore +2 -1
- inc/class-wp_recaptcha_contactform7.php +15 -8
- inc/class-wp_recaptcha_nocaptcha.php +9 -5
- readme.txt +24 -16
- wp-recaptcha-integration.php +21 -6
.svnignore
CHANGED
@@ -2,4 +2,5 @@
|
|
2 |
.gitignore
|
3 |
composer.json
|
4 |
mkzip.sh
|
5 |
-
README.md
|
|
2 |
.gitignore
|
3 |
composer.json
|
4 |
mkzip.sh
|
5 |
+
README.md
|
6 |
+
scss
|
inc/class-wp_recaptcha_contactform7.php
CHANGED
@@ -29,14 +29,22 @@ class WP_reCaptcha_ContactForm7 {
|
|
29 |
* Prevent from creating more than one instance
|
30 |
*/
|
31 |
private function __construct() {
|
32 |
-
add_action( 'wpcf7_init', array( &$this , 'add_shortcode_recaptcha' ) );
|
33 |
-
add_action( 'wp_enqueue_scripts' , array( &$this , 'recaptcha_enqueue_script') );
|
34 |
-
add_action( 'admin_init', array( &$this , 'add_tag_generator_recaptcha' ), 45 );
|
35 |
-
add_filter( 'wpcf7_validate_recaptcha', array( &$this , 'recaptcha_validation_filter' ) , 10, 2 );
|
36 |
-
add_filter( 'wpcf7_validate_recaptcha*', array( &$this , 'recaptcha_validation_filter' ) , 10, 2 );
|
37 |
-
add_filter( 'wpcf7_messages' , array( &$this , 'add_error_message' ) );
|
38 |
-
}
|
39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
|
41 |
function add_error_message( $messages ) {
|
42 |
$messages['wp_recaptcha_invalid'] = array(
|
@@ -222,7 +230,6 @@ class WP_reCaptcha_ContactForm7 {
|
|
222 |
$result['valid'] = false;
|
223 |
$result['reason'][$name] = $message;
|
224 |
}
|
225 |
-
// var_dump(WP_reCaptcha::instance()->captcha_instance()->get_last_result());
|
226 |
}
|
227 |
return $result;
|
228 |
}
|
29 |
* Prevent from creating more than one instance
|
30 |
*/
|
31 |
private function __construct() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
|
33 |
+
$wpcf7_version = defined('WPCF7_VERSION') ? WPCF7_VERSION : '0';
|
34 |
+
$wpcf7_recaptcha_configured = class_exists('WPCF7_RECAPTCHA') && ($cf7_sitekey = WPCF7_RECAPTCHA::get_instance()->get_sitekey()) && WPCF7_RECAPTCHA::get_instance()->get_secret( $cf7_sitekey );
|
35 |
+
|
36 |
+
// Skip WPCF7 reCaptcha
|
37 |
+
if ( $wpcf7_recaptcha_configured || version_compare( $wpcf7_version , '4.3' , '<' ) ) {
|
38 |
+
add_action( 'wpcf7_init', array( &$this , 'add_shortcode_recaptcha' ) );
|
39 |
+
add_action( 'wp_enqueue_scripts' , array( &$this , 'recaptcha_enqueue_script') );
|
40 |
+
add_action( 'admin_init', array( &$this , 'add_tag_generator_recaptcha' ), 45 );
|
41 |
+
add_filter( 'wpcf7_validate_recaptcha', array( &$this , 'recaptcha_validation_filter' ) , 10, 2 );
|
42 |
+
add_filter( 'wpcf7_validate_recaptcha*', array( &$this , 'recaptcha_validation_filter' ) , 10, 2 );
|
43 |
+
add_filter( 'wpcf7_messages' , array( &$this , 'add_error_message' ) );
|
44 |
+
}
|
45 |
+
}
|
46 |
+
|
47 |
+
|
48 |
|
49 |
function add_error_message( $messages ) {
|
50 |
$messages['wp_recaptcha_invalid'] = array(
|
230 |
$result['valid'] = false;
|
231 |
$result['reason'][$name] = $message;
|
232 |
}
|
|
|
233 |
}
|
234 |
return $result;
|
235 |
}
|
inc/class-wp_recaptcha_nocaptcha.php
CHANGED
@@ -56,6 +56,8 @@ class WP_reCaptcha_NoCaptcha extends WP_reCaptcha_Captcha {
|
|
56 |
'vi' => 'Vietnamese',
|
57 |
);
|
58 |
private $_counter = 0;
|
|
|
|
|
59 |
/**
|
60 |
* Holding the singleton instance
|
61 |
*/
|
@@ -140,18 +142,19 @@ class WP_reCaptcha_NoCaptcha extends WP_reCaptcha_Captcha {
|
|
140 |
|
141 |
?><script type="text/javascript">
|
142 |
var recaptcha_widgets={};
|
143 |
-
function
|
144 |
try {
|
145 |
grecaptcha;
|
146 |
} catch(err){
|
147 |
return;
|
148 |
}
|
149 |
-
var e=document.querySelectorAll ? document.querySelectorAll('.g-recaptcha') : document.getElementsByClassName('g-recaptcha'),
|
|
|
150 |
|
151 |
for (var i=0;i<e.length;i++) {
|
152 |
(function(el){
|
153 |
<?php if ( WP_reCaptcha::instance()->get_option( 'recaptcha_disable_submit' ) ) { ?>
|
154 |
-
var form_submits = get_form_submits(el).setEnabled(false),wid;
|
155 |
<?php } else { ?>
|
156 |
var wid;
|
157 |
<?php } ?>
|
@@ -178,13 +181,13 @@ class WP_reCaptcha_NoCaptcha extends WP_reCaptcha_Captcha {
|
|
178 |
if ( typeof jQuery !== 'undefined' )
|
179 |
jQuery(document).ajaxComplete( function(evt,xhr,set){
|
180 |
if( xhr.responseText && xhr.responseText.indexOf('<?php echo $sitekey ?>') !== -1)
|
181 |
-
|
182 |
} );
|
183 |
|
184 |
</script><?php
|
185 |
$recaptcha_api_url = "https://www.google.com/recaptcha/api.js";
|
186 |
$recaptcha_api_url = add_query_arg(array(
|
187 |
-
'onload' => '
|
188 |
'render' => 'explicit',
|
189 |
),$recaptcha_api_url);
|
190 |
if ( $language_code = apply_filters( 'wp_recaptcha_language' , WP_reCaptcha::instance()->get_option( 'recaptcha_language' ) ) )
|
@@ -209,6 +212,7 @@ class WP_reCaptcha_NoCaptcha extends WP_reCaptcha_Captcha {
|
|
209 |
'data-theme' => $theme,
|
210 |
);
|
211 |
$attr = wp_parse_args( $attr , $default );
|
|
|
212 |
$attr_str = '';
|
213 |
foreach ( $attr as $attr_name => $attr_val )
|
214 |
$attr_str .= sprintf( ' %s="%s"' , $attr_name , esc_attr( $attr_val ) );
|
56 |
'vi' => 'Vietnamese',
|
57 |
);
|
58 |
private $_counter = 0;
|
59 |
+
|
60 |
+
|
61 |
/**
|
62 |
* Holding the singleton instance
|
63 |
*/
|
142 |
|
143 |
?><script type="text/javascript">
|
144 |
var recaptcha_widgets={};
|
145 |
+
function wp_recaptchaLoadCallback(){
|
146 |
try {
|
147 |
grecaptcha;
|
148 |
} catch(err){
|
149 |
return;
|
150 |
}
|
151 |
+
var e = document.querySelectorAll ? document.querySelectorAll('.g-recaptcha:not(.wpcf7-form-control)') : document.getElementsByClassName('g-recaptcha'),
|
152 |
+
form_submits;
|
153 |
|
154 |
for (var i=0;i<e.length;i++) {
|
155 |
(function(el){
|
156 |
<?php if ( WP_reCaptcha::instance()->get_option( 'recaptcha_disable_submit' ) ) { ?>
|
157 |
+
var form_submits = get_form_submits(el).setEnabled(false), wid;
|
158 |
<?php } else { ?>
|
159 |
var wid;
|
160 |
<?php } ?>
|
181 |
if ( typeof jQuery !== 'undefined' )
|
182 |
jQuery(document).ajaxComplete( function(evt,xhr,set){
|
183 |
if( xhr.responseText && xhr.responseText.indexOf('<?php echo $sitekey ?>') !== -1)
|
184 |
+
wp_recaptchaLoadCallback();
|
185 |
} );
|
186 |
|
187 |
</script><?php
|
188 |
$recaptcha_api_url = "https://www.google.com/recaptcha/api.js";
|
189 |
$recaptcha_api_url = add_query_arg(array(
|
190 |
+
'onload' => 'wp_recaptchaLoadCallback',
|
191 |
'render' => 'explicit',
|
192 |
),$recaptcha_api_url);
|
193 |
if ( $language_code = apply_filters( 'wp_recaptcha_language' , WP_reCaptcha::instance()->get_option( 'recaptcha_language' ) ) )
|
212 |
'data-theme' => $theme,
|
213 |
);
|
214 |
$attr = wp_parse_args( $attr , $default );
|
215 |
+
|
216 |
$attr_str = '';
|
217 |
foreach ( $attr as $attr_name => $attr_val )
|
218 |
$attr_str .= sprintf( ' %s="%s"' , $attr_name , esc_attr( $attr_val ) );
|
readme.txt
CHANGED
@@ -3,18 +3,18 @@ Contributors: podpirate
|
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=F8NKC6TCASUXE
|
4 |
Tags: security, captcha, recaptcha, no captcha, login, signup, contact form 7, ninja forms, woocommerce
|
5 |
Requires at least: 3.8
|
6 |
-
Tested up to: 4.
|
7 |
-
Stable tag: 1.1.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
11 |
-
reCaptcha for login, signup, comment forms, Ninja Forms
|
12 |
|
13 |
== Description ==
|
14 |
|
15 |
Integrate reCaptcha in your blog. Supports no Captcha as well as old style recaptcha.
|
16 |
-
Provides of the box integration for signup, login, comment
|
17 |
-
|
18 |
|
19 |
= Features: =
|
20 |
- Secures login, signup und comments with a recaptcha.
|
@@ -26,7 +26,6 @@ form 7 as well as a plugin API for your own integrations.
|
|
26 |
- AwesomeSupport (thanks to [Julien Liabeuf](http://julienliabeuf.com/)
|
27 |
- WooCommerce (Only checkout, registration and login form. Not password reset)
|
28 |
- [Ninja Forms](http://ninjaforms.com/)
|
29 |
-
- [Contact Form 7](https://wordpress.org/plugins/contact-form-7/)
|
30 |
|
31 |
- For integration in your self-coded forms see this [wiki article](https://github.com/mcguffin/wp-recaptcha-integration/wiki/Custom-Themes-and-Forms) for details.
|
32 |
|
@@ -63,6 +62,10 @@ running under his/her own domain name.
|
|
63 |
To handle this there is a filter `recaptcha_disabled_html`. You can return a message for your logged-in
|
64 |
users here. Check out the [GitHub Repo](https://github.com/mcguffin/wp-recaptcha-integration) for details.
|
65 |
|
|
|
|
|
|
|
|
|
66 |
- Old style reCaptcha does not work together with **WooCommerce**.
|
67 |
|
68 |
- In **WooCommerce** the reset password form can not be protected by a captcha. Woocommerce does
|
@@ -101,8 +104,8 @@ You will either need one of the following:
|
|
101 |
|
102 |
1. Look at source code of the login page.
|
103 |
|
104 |
-
2. Find the part saying <code>data-sitekey="
|
105 |
-
The part
|
106 |
|
107 |
3. Go to the [Google reCaptcha API key administration](https://www.google.com/recaptcha/admin#list)
|
108 |
|
@@ -144,7 +147,8 @@ That's too bad...
|
|
144 |
|
145 |
= I can't get it to work with my custom comments form. Will you fix for me? =
|
146 |
|
147 |
-
|
|
|
148 |
|
149 |
|
150 |
= Privacy: Will the captcha send the visitors IP address to google? =
|
@@ -158,7 +162,7 @@ evaluated and stored forever.
|
|
158 |
|
159 |
In other words: Google knows which (recaptcha protected) website is accessed from which IP.
|
160 |
|
161 |
-
If that's an issue for you, you
|
162 |
|
163 |
|
164 |
= Will you support plugin XYZ? =
|
@@ -166,6 +170,10 @@ If that's an issue for you, you should rather use a self hosted solution.
|
|
166 |
If XYZ stands for a widely used free and OpenSource plugin in active development with some
|
167 |
100k+ downloads I will give it a try. Just ask.
|
168 |
|
|
|
|
|
|
|
|
|
169 |
|
170 |
= The captcha does not show up. What’s wrong? =
|
171 |
|
@@ -235,12 +243,8 @@ Either post it on [GitHub](https://github.com/mcguffin/wp-recaptcha-integration)
|
|
235 |
|
236 |
= Will you accept translations? =
|
237 |
|
238 |
-
|
239 |
-
|
240 |
-
or removed some strings in the meantime.
|
241 |
-
|
242 |
-
As soon as there is a [public centralized repository for WordPress plugin translations](https://translate.wordpress.org/projects/wp-plugins)
|
243 |
-
I will migrate all the translation stuff there.
|
244 |
|
245 |
|
246 |
== Screenshots ==
|
@@ -252,6 +256,10 @@ I will migrate all the translation stuff there.
|
|
252 |
|
253 |
== Changelog ==
|
254 |
|
|
|
|
|
|
|
|
|
255 |
= 1.1.9 =
|
256 |
- Fix: Layout issues on recaptcha nojs fallback (thanks to [nurupo](https://github.com/nurupo))
|
257 |
- Metadata: add plugin textdomain
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=F8NKC6TCASUXE
|
4 |
Tags: security, captcha, recaptcha, no captcha, login, signup, contact form 7, ninja forms, woocommerce
|
5 |
Requires at least: 3.8
|
6 |
+
Tested up to: 4.4
|
7 |
+
Stable tag: 1.1.10
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
11 |
+
reCaptcha for login, signup, comment forms, Ninja Forms and woocommerce.
|
12 |
|
13 |
== Description ==
|
14 |
|
15 |
Integrate reCaptcha in your blog. Supports no Captcha as well as old style recaptcha.
|
16 |
+
Provides of the box integration for signup, login, comment formsand Ninja Forms as well
|
17 |
+
as a plugin API for your own integrations.
|
18 |
|
19 |
= Features: =
|
20 |
- Secures login, signup und comments with a recaptcha.
|
26 |
- AwesomeSupport (thanks to [Julien Liabeuf](http://julienliabeuf.com/)
|
27 |
- WooCommerce (Only checkout, registration and login form. Not password reset)
|
28 |
- [Ninja Forms](http://ninjaforms.com/)
|
|
|
29 |
|
30 |
- For integration in your self-coded forms see this [wiki article](https://github.com/mcguffin/wp-recaptcha-integration/wiki/Custom-Themes-and-Forms) for details.
|
31 |
|
62 |
To handle this there is a filter `recaptcha_disabled_html`. You can return a message for your logged-in
|
63 |
users here. Check out the [GitHub Repo](https://github.com/mcguffin/wp-recaptcha-integration) for details.
|
64 |
|
65 |
+
- As of version 4.3 CF7 comes with its own recaptcha. Both are supposed to work together.
|
66 |
+
I you want to keep the WP ReCaptcha functionality, e.g. if you want to hide the captcha
|
67 |
+
from known users, leave the integration in the CF7 settings unconfigured.
|
68 |
+
|
69 |
- Old style reCaptcha does not work together with **WooCommerce**.
|
70 |
|
71 |
- In **WooCommerce** the reset password form can not be protected by a captcha. Woocommerce does
|
104 |
|
105 |
1. Look at source code of the login page.
|
106 |
|
107 |
+
2. Find the part saying <code>data-sitekey="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"</code>
|
108 |
+
(The XXX-part should be your sitekey.)
|
109 |
|
110 |
3. Go to the [Google reCaptcha API key administration](https://www.google.com/recaptcha/admin#list)
|
111 |
|
147 |
|
148 |
= I can't get it to work with my custom comments form. Will you fix for me? =
|
149 |
|
150 |
+
Nope. I cannot give support on your individual projects for free, no matter how many one
|
151 |
+
star reviews you will give me. Have a look at the project wiki or find a WordPress coder.
|
152 |
|
153 |
|
154 |
= Privacy: Will the captcha send the visitors IP address to google? =
|
162 |
|
163 |
In other words: Google knows which (recaptcha protected) website is accessed from which IP.
|
164 |
|
165 |
+
If that's an issue for you, you better use a self hosted solution.
|
166 |
|
167 |
|
168 |
= Will you support plugin XYZ? =
|
170 |
If XYZ stands for a widely used free and OpenSource plugin in active development with some
|
171 |
100k+ downloads I will give it a try. Just ask.
|
172 |
|
173 |
+
If XYZ is some rarely used plugin (about 1k+ active installs or so), I will accept pull
|
174 |
+
requests on github and push it to the WP repository. Please note that in such cases I will
|
175 |
+
not feel responsible for code maintainance.
|
176 |
+
|
177 |
|
178 |
= The captcha does not show up. What’s wrong? =
|
179 |
|
243 |
|
244 |
= Will you accept translations? =
|
245 |
|
246 |
+
Since late 2015 WordPress.org offers a plugin translation API. Just use the
|
247 |
+
"Translate this plugin" button in the right sidebar.
|
|
|
|
|
|
|
|
|
248 |
|
249 |
|
250 |
== Screenshots ==
|
256 |
|
257 |
== Changelog ==
|
258 |
|
259 |
+
= 1.1.10 =
|
260 |
+
- Feature: Changed Contact Form 7 support: As of version 4.3 CF7 comes with its own recaptcha. The plugin now just makes sure both captchas work together. It also keeps the API keys in sync.
|
261 |
+
- Fix: Disable Captcha for logged in users now respects custom roles without read capability. (Thanks to [@lainme](https://github.com/lainme))
|
262 |
+
|
263 |
= 1.1.9 =
|
264 |
- Fix: Layout issues on recaptcha nojs fallback (thanks to [nurupo](https://github.com/nurupo))
|
265 |
- Metadata: add plugin textdomain
|
wp-recaptcha-integration.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: WP reCaptcha Integration
|
4 |
Plugin URI: https://wordpress.org/plugins/wp-recaptcha-integration/
|
5 |
Description: Integrate reCaptcha in your blog. Supports no Captcha (new style recaptcha) as well as the old style reCaptcha. Provides of the box integration for signup, login, comment forms, lost password, Ninja Forms and contact form 7.
|
6 |
-
Version: 1.1.
|
7 |
Author: Jörn Lund
|
8 |
Author URI: https://github.com/mcguffin/
|
9 |
Text Domain: wp-recaptcha-integration
|
@@ -25,7 +25,11 @@ Text Domain: wp-recaptcha-integration
|
|
25 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
26 |
*/
|
27 |
|
28 |
-
|
|
|
|
|
|
|
|
|
29 |
|
30 |
/**
|
31 |
* Plugin base Class
|
@@ -39,8 +43,6 @@ class WP_reCaptcha {
|
|
39 |
private $last_error = '';
|
40 |
private $_last_result;
|
41 |
|
42 |
-
private $_counter = 0;
|
43 |
-
|
44 |
private $_captcha_instance = null;
|
45 |
|
46 |
/**
|
@@ -98,7 +100,7 @@ class WP_reCaptcha {
|
|
98 |
if ( $this->has_api_key() ) {
|
99 |
|
100 |
add_action('init' , array(&$this,'init') , 9 );
|
101 |
-
add_action('plugins_loaded' , array(&$this,'plugins_loaded') );
|
102 |
|
103 |
}
|
104 |
|
@@ -244,7 +246,7 @@ class WP_reCaptcha {
|
|
244 |
* @return bool
|
245 |
*/
|
246 |
function is_required() {
|
247 |
-
$is_required = ! ( $this->get_option('recaptcha_disable_for_known_users') &&
|
248 |
return apply_filters( 'wp_recaptcha_required' , $is_required );
|
249 |
}
|
250 |
|
@@ -591,6 +593,19 @@ class WP_reCaptcha {
|
|
591 |
* Fired on plugin activation
|
592 |
*/
|
593 |
public static function activate() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
594 |
}
|
595 |
|
596 |
/**
|
3 |
Plugin Name: WP reCaptcha Integration
|
4 |
Plugin URI: https://wordpress.org/plugins/wp-recaptcha-integration/
|
5 |
Description: Integrate reCaptcha in your blog. Supports no Captcha (new style recaptcha) as well as the old style reCaptcha. Provides of the box integration for signup, login, comment forms, lost password, Ninja Forms and contact form 7.
|
6 |
+
Version: 1.1.10
|
7 |
Author: Jörn Lund
|
8 |
Author URI: https://github.com/mcguffin/
|
9 |
Text Domain: wp-recaptcha-integration
|
25 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
26 |
*/
|
27 |
|
28 |
+
/*
|
29 |
+
ToDo:
|
30 |
+
- CF7:
|
31 |
+
|
32 |
+
*/
|
33 |
|
34 |
/**
|
35 |
* Plugin base Class
|
43 |
private $last_error = '';
|
44 |
private $_last_result;
|
45 |
|
|
|
|
|
46 |
private $_captcha_instance = null;
|
47 |
|
48 |
/**
|
100 |
if ( $this->has_api_key() ) {
|
101 |
|
102 |
add_action('init' , array(&$this,'init') , 9 );
|
103 |
+
add_action('plugins_loaded' , array(&$this,'plugins_loaded'), 9 );
|
104 |
|
105 |
}
|
106 |
|
246 |
* @return bool
|
247 |
*/
|
248 |
function is_required() {
|
249 |
+
$is_required = ! ( $this->get_option('recaptcha_disable_for_known_users') && is_user_logged_in() );
|
250 |
return apply_filters( 'wp_recaptcha_required' , $is_required );
|
251 |
}
|
252 |
|
593 |
* Fired on plugin activation
|
594 |
*/
|
595 |
public static function activate() {
|
596 |
+
|
597 |
+
if ( function_exists('wpcf7') ) {
|
598 |
+
// IF CF7 is active, try to configure plugin from cf7 options
|
599 |
+
if ( $wpcf7_options = get_option('wpcf7') ) {
|
600 |
+
if ( isset( $wpcf7_options['recaptcha'] ) && !self::instance()->has_api_key() ) {
|
601 |
+
foreach ( $wpcf7_options['recaptcha'] as $sitekey => $secretkey ) {
|
602 |
+
update_option('recaptcha_publickey',$sitekey);
|
603 |
+
update_option('recaptcha_privatekey',$secretkey);
|
604 |
+
break;
|
605 |
+
}
|
606 |
+
}
|
607 |
+
}
|
608 |
+
}
|
609 |
}
|
610 |
|
611 |
/**
|