Version Description
- Add testing tool for checking the api key.
- Fixes
Download this release
Release Info
Developer | podpirate |
Plugin | WordPress ReCaptcha Integration |
Version | 0.9.1 |
Comparing to | |
See all releases |
Code changes from version 0.9.0 to 0.9.1
- inc/recaptcha-options.php +53 -12
- js/recaptcha-options.js +11 -0
- readme.txt +28 -6
- wp-recaptcha-integration.php +12 -8
inc/recaptcha-options.php
CHANGED
@@ -29,7 +29,26 @@ class WordPress_reCaptcha_Options {
|
|
29 |
private function __construct() {
|
30 |
add_action('admin_init', array(&$this,'admin_init') );
|
31 |
add_action('admin_menu', array(&$this,'add_options_page') );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
function api_key_notice() {
|
34 |
?><div class="notice error above-h1"><p><?php
|
35 |
printf(
|
@@ -45,8 +64,9 @@ class WordPress_reCaptcha_Options {
|
|
45 |
add_action('admin_notices',array( &$this , 'api_key_notice'));
|
46 |
}
|
47 |
|
48 |
-
$this->enter_api_key = ! $has_api_key || ( isset($_REQUEST['action']) && $_REQUEST['action'] == 'recaptcha-api-key'
|
49 |
if ( $this->enter_api_key ) {
|
|
|
50 |
register_setting( 'recaptcha_options', 'recaptcha_publickey' );
|
51 |
register_setting( 'recaptcha_options', 'recaptcha_privatekey' );
|
52 |
add_settings_field('recaptcha_publickey', __('Public Key','wp-recaptcha-integration'), array(&$this,'input_text'), 'recaptcha', 'recaptcha_apikey' , array('name'=>'recaptcha_publickey') );
|
@@ -58,9 +78,11 @@ class WordPress_reCaptcha_Options {
|
|
58 |
} else if ( @$nonce_valid === false) {
|
59 |
wp_die('Security Check');
|
60 |
} else {
|
|
|
61 |
add_settings_section('recaptcha_apikey', __( 'Connecting' , 'wp-recaptcha-integration' ), array(&$this,'explain_apikey'), 'recaptcha');
|
|
|
62 |
}
|
63 |
-
|
64 |
if ( $has_api_key ) {
|
65 |
register_setting( 'recaptcha_options', 'recaptcha_flavor' , array( &$this , 'sanitize_flavor' ) );
|
66 |
register_setting( 'recaptcha_options', 'recaptcha_theme' , array( &$this , 'sanitize_theme' ) );
|
@@ -131,21 +153,40 @@ class WordPress_reCaptcha_Options {
|
|
131 |
$admin_url , $info_url
|
132 |
);
|
133 |
?></p><?php
|
|
|
134 |
} else {
|
135 |
-
?><
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
?><a class="button" href="<?php echo $url ?>"><?php _e('New API Key' , 'wp-recaptcha-integration') ?></a><?php
|
143 |
-
?></p><?php
|
144 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
145 |
}
|
146 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
147 |
public function cancel_enter_api_key(){
|
148 |
-
$url =
|
|
|
149 |
?><a class="button" href="<?php echo $url ?>"><?php _e( 'Cancel' ) ?></a><?php
|
150 |
}
|
151 |
|
29 |
private function __construct() {
|
30 |
add_action('admin_init', array(&$this,'admin_init') );
|
31 |
add_action('admin_menu', array(&$this,'add_options_page') );
|
32 |
+
|
33 |
+
add_action( 'pre_update_option_recaptcha_publickey' , array( &$this , 'update_option_recaptcha_apikey' ) , 10 , 2 );
|
34 |
+
add_action( 'pre_update_option_recaptcha_privatekey' , array( &$this , 'update_option_recaptcha_apikey' ) , 10 , 2 );
|
35 |
+
add_action( 'add_option_recaptcha_publickey' , array( &$this , 'add_option_recaptcha_apikey' ) , 10 , 2 );
|
36 |
+
add_action( 'add_option_recaptcha_privatekey' , array( &$this , 'add_option_recaptcha_apikey' ) , 10 , 2 );
|
37 |
+
}
|
38 |
+
|
39 |
+
function update_option_recaptcha_apikey( $new , $old ){
|
40 |
+
add_filter( 'wp_redirect' , array( &$this , 'remove_new_apikey_url' ) );
|
41 |
+
return $new;
|
42 |
}
|
43 |
+
function add_option_recaptcha_apikey( $option , $value ){
|
44 |
+
if ( in_array( $option , array('recaptcha_publickey','recaptcha_privatekey') ) )
|
45 |
+
add_filter( 'wp_redirect' , array( &$this , 'remove_new_apikey_url' ) );
|
46 |
+
}
|
47 |
+
|
48 |
+
function remove_new_apikey_url( $url = null ) {
|
49 |
+
return remove_query_arg( array('_wpnonce' , 'recaptcha-action' , 'settings-updated' ) , $url );
|
50 |
+
}
|
51 |
+
|
52 |
function api_key_notice() {
|
53 |
?><div class="notice error above-h1"><p><?php
|
54 |
printf(
|
64 |
add_action('admin_notices',array( &$this , 'api_key_notice'));
|
65 |
}
|
66 |
|
67 |
+
$this->enter_api_key = ! $has_api_key || ( isset($_REQUEST['recaptcha-action']) && $_REQUEST['recaptcha-action'] == 'recaptcha-set-api-key');
|
68 |
if ( $this->enter_api_key ) {
|
69 |
+
// no API Key. Let the user enter it.
|
70 |
register_setting( 'recaptcha_options', 'recaptcha_publickey' );
|
71 |
register_setting( 'recaptcha_options', 'recaptcha_privatekey' );
|
72 |
add_settings_field('recaptcha_publickey', __('Public Key','wp-recaptcha-integration'), array(&$this,'input_text'), 'recaptcha', 'recaptcha_apikey' , array('name'=>'recaptcha_publickey') );
|
78 |
} else if ( @$nonce_valid === false) {
|
79 |
wp_die('Security Check');
|
80 |
} else {
|
81 |
+
// API Key. Add test tool.
|
82 |
add_settings_section('recaptcha_apikey', __( 'Connecting' , 'wp-recaptcha-integration' ), array(&$this,'explain_apikey'), 'recaptcha');
|
83 |
+
add_action('wp_ajax_recaptcha-test-api-key' , array( &$this , 'ajax_test_api_key' ) );
|
84 |
}
|
85 |
+
|
86 |
if ( $has_api_key ) {
|
87 |
register_setting( 'recaptcha_options', 'recaptcha_flavor' , array( &$this , 'sanitize_flavor' ) );
|
88 |
register_setting( 'recaptcha_options', 'recaptcha_theme' , array( &$this , 'sanitize_theme' ) );
|
153 |
$admin_url , $info_url
|
154 |
);
|
155 |
?></p><?php
|
156 |
+
?><input type="hidden" name="recaptcha-action" value="recaptcha-set-api-key" /><?php
|
157 |
} else {
|
158 |
+
?><div class="recaptcha-explain"><?php
|
159 |
+
?><p class="description"><?php
|
160 |
+
_e( 'You already entered an API Key. Use the button below to enter it again.','wp-recaptcha-integration');
|
161 |
+
?></p><?php
|
162 |
+
$action = 'recaptcha-set-api-key';
|
163 |
+
$nonce = wp_create_nonce( $action );
|
164 |
+
$new_url = add_query_arg( array('_wpnonce' => $nonce , 'recaptcha-action' => $action ) );
|
|
|
|
|
165 |
|
166 |
+
$action = 'recaptcha-test-api-key';
|
167 |
+
$nonce = wp_create_nonce( $action );
|
168 |
+
$test_url = add_query_arg( array('_wpnonce' => $nonce , 'action' => $action ) , admin_url( 'admin-ajax.php' ) );
|
169 |
+
|
170 |
+
?><p class="submit"><?php
|
171 |
+
?><a class="button" href="<?php echo $new_url ?>"><?php _e('New API Key' , 'wp-recaptcha-integration') ?></a><?php
|
172 |
+
?><a id="test-api-key" class="button" href="<?php echo $test_url ?>"><?php _e('Test API Key' , 'wp-recaptcha-integration') ?></a><?php
|
173 |
+
?></p><?php
|
174 |
+
?></div><?php
|
175 |
}
|
176 |
}
|
177 |
+
|
178 |
+
public function ajax_test_api_key() {
|
179 |
+
if ( isset( $_REQUEST['_wpnonce'] ) && wp_verify_nonce( $_REQUEST['_wpnonce'] , $_REQUEST['action'] ) ) {
|
180 |
+
header('Content-Type: text/html');
|
181 |
+
WordPress_reCaptcha::instance()->recaptcha_script( 'grecaptcha' );
|
182 |
+
WordPress_reCaptcha::instance()->print_recaptcha_html( 'grecaptcha' );
|
183 |
+
}
|
184 |
+
exit(0);
|
185 |
+
}
|
186 |
+
|
187 |
public function cancel_enter_api_key(){
|
188 |
+
$url = $this->remove_new_apikey_url( );
|
189 |
+
// $url = remove_query_arg( array('_wpnonce' , 'recaptcha-action' , 'settings-updated' ) );
|
190 |
?><a class="button" href="<?php echo $url ?>"><?php _e( 'Cancel' ) ?></a><?php
|
191 |
}
|
192 |
|
js/recaptcha-options.js
CHANGED
@@ -8,4 +8,15 @@
|
|
8 |
.removeClass('flavor-grecaptcha')
|
9 |
.addClass('flavor-'+$(this).val());
|
10 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
})(jQuery);
|
8 |
.removeClass('flavor-grecaptcha')
|
9 |
.addClass('flavor-'+$(this).val());
|
10 |
});
|
11 |
+
|
12 |
+
|
13 |
+
$(document).on('click','#test-api-key' , function(e){
|
14 |
+
console.log( $(this).prop('href') );
|
15 |
+
if ( ! $('#recaptcha-test-result').length )
|
16 |
+
$(this).closest('div').append('<div id="recaptcha-test-result" />');
|
17 |
+
$('#recaptcha-test-result').load( $(this).prop('href') ,{},function(e){console.log(e);});
|
18 |
+
e.preventDefault();
|
19 |
+
e.stopPropagation();
|
20 |
+
});
|
21 |
+
|
22 |
})(jQuery);
|
readme.txt
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
=== WordPress ReCaptcha Integration ===
|
2 |
Contributors: podpirate
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=F8NKC6TCASUXE
|
4 |
-
Tags: security, captcha, recaptcha,
|
5 |
Requires at least: 3.8
|
6 |
Tested up to: 4.1
|
7 |
Stable tag: trunk
|
@@ -12,9 +12,9 @@ reCaptcha for login, signup, comment forms, Ninja Forms and Contact Form 7.
|
|
12 |
|
13 |
== Description ==
|
14 |
|
15 |
-
Integrate reCaptcha in your blog. Supports
|
16 |
-
for signup, login, comment forms, Ninja Forms and contact
|
17 |
-
your own integrations.
|
18 |
|
19 |
= Features: =
|
20 |
- Secures login, signup and comments with a recaptcha.
|
@@ -24,14 +24,32 @@ your own integrations.
|
|
24 |
|
25 |
Latest Files on GitHub: [https://github.com/mcguffin/wp-recaptcha-integration](https://github.com/mcguffin/wp-recaptcha-integration)
|
26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
== Installation ==
|
28 |
|
29 |
First follow the standard [WordPress plugin installation procedere](http://codex.wordpress.org/Managing_Plugins).
|
30 |
|
31 |
-
Then
|
32 |
|
33 |
== Frequently asked questions ==
|
34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
= I found a bug. Where should I post it? =
|
36 |
|
37 |
I personally prefer GitHub but you can post it in the forum as well. The plugin code is here: [GitHub](https://github.com/mcguffin/wp-recaptcha-integration)
|
@@ -74,7 +92,11 @@ I will migrate all the translation stuff there.
|
|
74 |
|
75 |
== Changelog ==
|
76 |
|
77 |
-
=
|
|
|
|
|
|
|
|
|
78 |
Initial Release
|
79 |
|
80 |
== Plugin API ==
|
1 |
=== WordPress ReCaptcha Integration ===
|
2 |
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
|
5 |
Requires at least: 3.8
|
6 |
Tested up to: 4.1
|
7 |
Stable tag: trunk
|
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 forms, Ninja Forms and contact
|
17 |
+
form 7 as well as a plugin API for your own integrations.
|
18 |
|
19 |
= Features: =
|
20 |
- Secures login, signup and comments with a recaptcha.
|
24 |
|
25 |
Latest Files on GitHub: [https://github.com/mcguffin/wp-recaptcha-integration](https://github.com/mcguffin/wp-recaptcha-integration)
|
26 |
|
27 |
+
= Known Limitations =
|
28 |
+
- Currently you can't have more than one reCaptcha on a page.
|
29 |
+
This may affect you for example when you have a contact page with a comment form.
|
30 |
+
For old style reCaptcha this cannot be fixed. For the new Style reCaptchas
|
31 |
+
this is due to be implemented in the near future.
|
32 |
+
|
33 |
+
- On a Contact Form 7 when the reCaptcha is disabled (e.g. for logged in users) the field
|
34 |
+
label will be still visible. This is due to CF7 Shortcode architecture, and can't be fixed.
|
35 |
+
|
36 |
+
To handle this there is a filter `recaptcha_disabled_html`. You can return a message for your logged-in
|
37 |
+
users here. Check out the [GitHub Repo](https://github.com/mcguffin/wp-recaptcha-integration) for details.
|
38 |
+
|
39 |
== Installation ==
|
40 |
|
41 |
First follow the standard [WordPress plugin installation procedere](http://codex.wordpress.org/Managing_Plugins).
|
42 |
|
43 |
+
Then go to the [Google Recaptcha Site](http://www.google.com/recaptcha), sign up your site and enter your API-Keys on the configuration page.
|
44 |
|
45 |
== Frequently asked questions ==
|
46 |
|
47 |
+
= The plugin does not show up. What’s wrong? =
|
48 |
+
|
49 |
+
On the plugin settings page check out if the option “Disable for known users” is activated (it is by default).
|
50 |
+
Then log out (or open your page in a private browser window) and try again.
|
51 |
+
If the problem still persist, Houson really has a problem, and you are welcome to post a support request.
|
52 |
+
|
53 |
= I found a bug. Where should I post it? =
|
54 |
|
55 |
I personally prefer GitHub but you can post it in the forum as well. The plugin code is here: [GitHub](https://github.com/mcguffin/wp-recaptcha-integration)
|
92 |
|
93 |
== Changelog ==
|
94 |
|
95 |
+
= 0.9.1 =
|
96 |
+
- Add testing tool for checking the api key.
|
97 |
+
- Fixes
|
98 |
+
|
99 |
+
= 0.9.0 =
|
100 |
Initial Release
|
101 |
|
102 |
== Plugin API ==
|
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 stle reCaptcha. Provides of the box integration for signup, login, comment forms, lost password, Ninja Forms and contact form 7.
|
6 |
-
Version: 0.9.
|
7 |
Author: Jörn Lund
|
8 |
Author URI: https://github.com/mcguffin/
|
9 |
*/
|
@@ -127,10 +127,12 @@ class WordPress_reCaptcha {
|
|
127 |
return $errors;
|
128 |
}
|
129 |
|
130 |
-
function recaptcha_script() {
|
131 |
-
|
|
|
|
|
132 |
case 'grecaptcha':
|
133 |
-
?><script src="https://www.google.com/recaptcha/api.js
|
134 |
?><style type="text/css">
|
135 |
#login {
|
136 |
width:350px !important;
|
@@ -160,12 +162,14 @@ class WordPress_reCaptcha {
|
|
160 |
wp_die( __("Sorry, the Captcha didn’t verify.",'wp-recaptcha-integration') );
|
161 |
}
|
162 |
|
163 |
-
function print_recaptcha_html(){
|
164 |
-
echo $this->recaptcha_html();
|
165 |
}
|
166 |
|
167 |
-
function recaptcha_html() {
|
168 |
-
|
|
|
|
|
169 |
case 'grecaptcha':
|
170 |
return $this->grecaptcha_html();
|
171 |
case 'recaptcha':
|
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 stle reCaptcha. Provides of the box integration for signup, login, comment forms, lost password, Ninja Forms and contact form 7.
|
6 |
+
Version: 0.9.1
|
7 |
Author: Jörn Lund
|
8 |
Author URI: https://github.com/mcguffin/
|
9 |
*/
|
127 |
return $errors;
|
128 |
}
|
129 |
|
130 |
+
function recaptcha_script( $flavor = '' ) {
|
131 |
+
if ( empty( $flavor ) )
|
132 |
+
$flavor = get_option( 'recaptcha_flavor' );
|
133 |
+
switch ( $flavor ) {
|
134 |
case 'grecaptcha':
|
135 |
+
?><script src="https://www.google.com/recaptcha/api.js" async defer></script><?php
|
136 |
?><style type="text/css">
|
137 |
#login {
|
138 |
width:350px !important;
|
162 |
wp_die( __("Sorry, the Captcha didn’t verify.",'wp-recaptcha-integration') );
|
163 |
}
|
164 |
|
165 |
+
function print_recaptcha_html( $flavor = '' ){
|
166 |
+
echo $this->recaptcha_html( $flavor );
|
167 |
}
|
168 |
|
169 |
+
function recaptcha_html( $flavor = '' ) {
|
170 |
+
if ( empty( $flavor ) )
|
171 |
+
$flavor = get_option( 'recaptcha_flavor' );
|
172 |
+
switch ( $flavor ) {
|
173 |
case 'grecaptcha':
|
174 |
return $this->grecaptcha_html();
|
175 |
case 'recaptcha':
|