WordPress ReCaptcha Integration - Version 1.0.2

Version Description

  • Feature: option to disable submit button, until the captcha is solved
  • Rearrange comment form (put captcha above submit button)
  • Fix: NoCaptcha did not refresh after submitting invalid ninja form via ajax
Download this release

Release Info

Developer podpirate
Plugin Icon 128x128 WordPress ReCaptcha Integration
Version 1.0.2
Comparing to
See all releases

Code changes from version 1.0.1 to 1.0.2

inc/class-wp-recaptcha-options.php CHANGED
@@ -2,6 +2,9 @@
2
 
3
 
4
 
 
 
 
5
  class WP_reCaptcha_Options {
6
  private $enter_api_key;
7
  /**
@@ -181,8 +184,10 @@ class WP_reCaptcha_Options {
181
 
182
  if ( $has_api_key ) {
183
  if ( ! WP_reCaptcha::is_network_activated() || ! is_network_admin() ) {
 
184
  register_setting( 'recaptcha_options', 'recaptcha_flavor' , array( &$this , 'sanitize_flavor' ) );
185
  register_setting( 'recaptcha_options', 'recaptcha_theme' , array( &$this , 'sanitize_theme' ) );
 
186
 
187
  add_settings_field('recaptcha_flavor', __('Flavor','wp-recaptcha-integration'),
188
  array(&$this,'input_radio'), 'recaptcha', 'recaptcha_options',
@@ -202,9 +207,14 @@ class WP_reCaptcha_Options {
202
 
203
  add_settings_field('recaptcha_theme', __('Theme','wp-recaptcha-integration'), array(&$this,'select_theme'), 'recaptcha', 'recaptcha_options');
204
 
 
 
 
 
205
 
206
  }
207
  if ( ! WP_reCaptcha::is_network_activated() || is_network_admin() ) {
 
208
  register_setting( 'recaptcha_options', 'recaptcha_enable_comments' , 'intval');
209
  register_setting( 'recaptcha_options', 'recaptcha_enable_signup', 'intval' );
210
  register_setting( 'recaptcha_options', 'recaptcha_enable_login' , 'intval');
@@ -505,7 +515,7 @@ class WP_reCaptcha_Options {
505
  remove_action('admin_notices',array( &$this , 'api_key_notice'));
506
  }
507
  /**
508
- * Enqueue script and css for options page.
509
  */
510
  public function render_options_page() {
511
  ?><div class="wrap"><?php
2
 
3
 
4
 
5
+ /**
6
+ * Class to manage the recaptcha options.
7
+ */
8
  class WP_reCaptcha_Options {
9
  private $enter_api_key;
10
  /**
184
 
185
  if ( $has_api_key ) {
186
  if ( ! WP_reCaptcha::is_network_activated() || ! is_network_admin() ) {
187
+ // local options
188
  register_setting( 'recaptcha_options', 'recaptcha_flavor' , array( &$this , 'sanitize_flavor' ) );
189
  register_setting( 'recaptcha_options', 'recaptcha_theme' , array( &$this , 'sanitize_theme' ) );
190
+ register_setting( 'recaptcha_options', 'recaptcha_disable_submit' , 'intval');
191
 
192
  add_settings_field('recaptcha_flavor', __('Flavor','wp-recaptcha-integration'),
193
  array(&$this,'input_radio'), 'recaptcha', 'recaptcha_options',
207
 
208
  add_settings_field('recaptcha_theme', __('Theme','wp-recaptcha-integration'), array(&$this,'select_theme'), 'recaptcha', 'recaptcha_options');
209
 
210
+ add_settings_field('recaptcha_disable_submit', __('Disable Submit Button','wp-recaptcha-integration'),
211
+ array(&$this,'input_checkbox'), 'recaptcha', 'recaptcha_options' ,
212
+ array('name'=>'recaptcha_disable_submit','label'=>__( 'Disable Form Submit Button until no-captcha is entered.' ,'wp-recaptcha-integration' ) )
213
+ );
214
 
215
  }
216
  if ( ! WP_reCaptcha::is_network_activated() || is_network_admin() ) {
217
+ // network options
218
  register_setting( 'recaptcha_options', 'recaptcha_enable_comments' , 'intval');
219
  register_setting( 'recaptcha_options', 'recaptcha_enable_signup', 'intval' );
220
  register_setting( 'recaptcha_options', 'recaptcha_enable_login' , 'intval');
515
  remove_action('admin_notices',array( &$this , 'api_key_notice'));
516
  }
517
  /**
518
+ * Rendering the options page
519
  */
520
  public function render_options_page() {
521
  ?><div class="wrap"><?php
inc/ninja_forms_field_recaptcha.php CHANGED
@@ -46,15 +46,31 @@ function ninja_forms_recaptcha_field_data( $data, $field_id ) {
46
  }
47
 
48
  function ninja_forms_recaptcha_script($id) {
49
- // print script
50
- if ( 'recaptcha' == WP_reCaptcha::instance()->get_option( 'recaptcha_flavor' ) ) {
51
- $html = '<script type="text/javascript">
52
- jQuery(document).on("submitResponse.default", function(e, response){
53
- Recaptcha.reload();
54
- });
55
- </script>';
56
- echo $html;
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  }
 
 
 
58
  }
59
 
60
  function ninja_forms_field_recaptcha_display($field_id, $data){
46
  }
47
 
48
  function ninja_forms_recaptcha_script($id) {
49
+ $flavor = WP_reCaptcha::instance()->get_option( 'recaptcha_flavor' );
50
+ switch ( $flavor ) {
51
+ case 'recaptcha':
52
+ $html = '<script type="text/javascript">
53
+ // reload recaptcha after failed ajax form submit
54
+ jQuery(document).on("submitResponse.default", function(e, response){
55
+ Recaptcha.reload();
56
+ });
57
+ </script>';
58
+ break;
59
+ case 'grecaptcha':
60
+ $html = '<script type="text/javascript">
61
+ // reload recaptcha after failed ajax form submit
62
+ (function($){
63
+ $(document).on("submitResponse.default", function(e, response){
64
+ var wid = $(\'#ninja_forms_form_\'+response.form_id).find(\'.g-recaptcha\').data(\'widget-id\');
65
+ grecaptcha.reset(wid);
66
+ });
67
+ })(jQuery);
68
+ </script>';
69
+ break;
70
  }
71
+ WP_reCaptcha::instance()->begin_inject(false,', Ninja form integration');
72
+ echo $html;
73
+ WP_reCaptcha::instance()->end_inject();
74
  }
75
 
76
  function ninja_forms_field_recaptcha_display($field_id, $data){
languages/wp-recaptcha-integration-de_DE.mo CHANGED
Binary file
languages/wp-recaptcha-integration-de_DE.po CHANGED
@@ -1,9 +1,9 @@
1
  msgid ""
2
  msgstr ""
3
- "Project-Id-Version: WP reCaptcha Integration v0.9.2\n"
4
  "Report-Msgid-Bugs-To: \n"
5
  "POT-Creation-Date: \n"
6
- "PO-Revision-Date: 2014-12-21 17:02:22+0000\n"
7
  "Last-Translator: admin <joern@flyingletters.com>\n"
8
  "Language-Team: \n"
9
  "MIME-Version: 1.0\n"
@@ -20,44 +20,44 @@ msgstr ""
20
  "X-Poedit-SearchPath-0: .\n"
21
  "X-Textdomain-Support: yes"
22
 
23
- #: inc/ninja_forms_field_recaptcha.php:67
24
- #: wp-recaptcha-integration.php:129
25
- #: wp-recaptcha-integration.php:136
26
  #@ wp-recaptcha-integration
27
  msgid "<strong>Error:</strong> the Captcha didn’t verify."
28
  msgstr "<strong>Fehler:</strong> Sicherheitstest nicht bestanden"
29
 
30
- #: wp-recaptcha-integration.php:174
31
  #@ wp-recaptcha-integration
32
  msgid "Sorry, the Captcha didn’t verify."
33
  msgstr "Tut uns leid, aber Sie haben den Sicherheitstest nicht bestanden."
34
 
35
- #: wp-recaptcha-integration.php:216
36
  #@ wp-recaptcha-integration
37
  msgid "Incorrect please try again"
38
  msgstr "Falsch. Bitte noch einmal versuchen"
39
 
40
- #: wp-recaptcha-integration.php:218
41
  #@ wp-recaptcha-integration
42
  msgid "Enter the words above:"
43
  msgstr "Geben Sie die Wörten oben ein."
44
 
45
- #: wp-recaptcha-integration.php:219
46
  #@ wp-recaptcha-integration
47
  msgid "Enter the numbers you hear:"
48
  msgstr "Geben Sie die Zahlen ein, die Sie hören:"
49
 
50
- #: wp-recaptcha-integration.php:223
51
  #@ wp-recaptcha-integration
52
  msgid "Get another CAPTCHA"
53
  msgstr "Anderes CAPTCHA."
54
 
55
- #: wp-recaptcha-integration.php:224
56
  #@ wp-recaptcha-integration
57
  msgid "Get an audio CAPTCHA"
58
  msgstr "Audio CAPTCHA"
59
 
60
- #: wp-recaptcha-integration.php:225
61
  #@ wp-recaptcha-integration
62
  msgid "Get an image CAPTCHA"
63
  msgstr "Bild CAPTCHA"
@@ -113,72 +113,72 @@ msgstr "Private Key"
113
  msgid "Connecting"
114
  msgstr "Verbindung"
115
 
116
- #: inc/class-wp-recaptcha-options.php:239
117
  #@ wp-recaptcha-integration
118
  msgid "Features"
119
  msgstr "Funktionen"
120
 
121
- #: inc/class-wp-recaptcha-options.php:187
122
  #@ wp-recaptcha-integration
123
  msgid "Flavor"
124
  msgstr "Geschmacksrichtung"
125
 
126
- #: inc/class-wp-recaptcha-options.php:198
127
  #@ wp-recaptcha-integration
128
  msgid "Old style reCAPTCHA where you type some cryptic text"
129
  msgstr "Klassisch, man muß kryptische Wörter eingeben"
130
 
131
- #: inc/class-wp-recaptcha-options.php:203
132
  #@ wp-recaptcha-integration
133
  msgid "Theme"
134
  msgstr "Theme"
135
 
136
- #: inc/class-wp-recaptcha-options.php:214
137
  #@ wp-recaptcha-integration
138
  msgid "Protect Comments"
139
  msgstr "Kommentare schützen"
140
 
141
- #: inc/class-wp-recaptcha-options.php:216
142
  #@ wp-recaptcha-integration
143
  msgid "Protect comment forms with recaptcha."
144
  msgstr "Das Kommentarformular mit einem reCaptcha schützen"
145
 
146
- #: inc/class-wp-recaptcha-options.php:219
147
  #@ wp-recaptcha-integration
148
  msgid "Protect Signup"
149
  msgstr "Registrierung schützen"
150
 
151
- #: inc/class-wp-recaptcha-options.php:221
152
  #@ wp-recaptcha-integration
153
  msgid "Protect signup form with recaptcha."
154
  msgstr "Die Registrierung mit einem reCaptcha schützen."
155
 
156
- #: inc/class-wp-recaptcha-options.php:224
157
  #@ wp-recaptcha-integration
158
  msgid "Protect Login"
159
  msgstr "Login schützen"
160
 
161
- #: inc/class-wp-recaptcha-options.php:226
162
  #@ wp-recaptcha-integration
163
  msgid "Protect Login form with recaptcha."
164
  msgstr "Das Anmeldeformular mit einem reCaptcha schützen"
165
 
166
- #: inc/class-wp-recaptcha-options.php:234
167
  #@ wp-recaptcha-integration
168
  msgid "Disable for known users"
169
  msgstr "Abschalten bei bekannten Benutzern"
170
 
171
- #: inc/class-wp-recaptcha-options.php:236
172
  #@ wp-recaptcha-integration
173
  msgid "Disable reCaptcha verification for logged in users."
174
  msgstr "Die reCaptcha-Verifizierung für eingeloggte Benutzer deaktivieren"
175
 
176
- #: inc/class-wp-recaptcha-options.php:242
177
  #@ wp-recaptcha-integration
178
  msgid "Please configure the public and private key. <a href=\"http://www.google.com/recaptcha/whyrecaptcha\">What are you trying to tell me?</a>"
179
  msgstr "Bitte konfigurieren Sie den privaten und den Öffentlichen Schlüssel (private &amp; public key). <a href=\"http://www.google.com/recaptcha/whyrecaptcha\">Was willst Du mir damit zu sagen?</a>"
180
 
181
- #: inc/class-wp-recaptcha-options.php:255
182
  #, php-format
183
  #@ wp-recaptcha-integration
184
  msgid "Please register your blog through the <a href=\"%s\">Google reCAPTCHA admin page</a> and enter the public and private key in the fields below. <a href=\"%s\">What is this all about</a>"
@@ -187,83 +187,83 @@ msgstr ""
187
  "und trage unten den öffentlichen und privaten Schüssel ein. <a \n"
188
  "href=\"%s\">Was erzählst Du mir da?</a>"
189
 
190
- #: inc/class-wp-recaptcha-options.php:263
191
  #@ wp-recaptcha-integration
192
  msgid "You already entered an API Key. Use the button below to enter it again."
193
  msgstr "Du hast schon einen API-Schlüssel eingetragen. Klick den Button unten, um es nochmal zu tun."
194
 
195
- #: inc/class-wp-recaptcha-options.php:274
196
  #@ wp-recaptcha-integration
197
  msgid "New API Key"
198
  msgstr "Neuer API-Schlüssel"
199
 
200
- #: inc/class-wp-recaptcha-options.php:331
201
  #@ default
202
  msgid "Cancel"
203
  msgstr ""
204
 
205
- #: inc/class-wp-recaptcha-options.php:401
206
  #@ wp-recaptcha-integration
207
  msgid "Light"
208
  msgstr "Hell"
209
 
210
- #: inc/class-wp-recaptcha-options.php:405
211
  #@ wp-recaptcha-integration
212
  msgid "Dark"
213
  msgstr "Dunkel"
214
 
215
- #: inc/class-wp-recaptcha-options.php:410
216
  #@ wp-recaptcha-integration
217
  msgid "Red"
218
  msgstr "Rot"
219
 
220
- #: inc/class-wp-recaptcha-options.php:414
221
  #@ wp-recaptcha-integration
222
  msgid "White"
223
  msgstr "Weiß"
224
 
225
- #: inc/class-wp-recaptcha-options.php:418
226
  #@ wp-recaptcha-integration
227
  msgid "Black Glass"
228
  msgstr "Schwarzes Glas"
229
 
230
- #: inc/class-wp-recaptcha-options.php:422
231
  #@ wp-recaptcha-integration
232
  msgid "Clean"
233
  msgstr "Clean"
234
 
235
- #: inc/class-wp-recaptcha-options.php:426
236
  #@ wp-recaptcha-integration
237
  msgid "Custom"
238
  msgstr "Eigenes"
239
 
240
- #: inc/class-wp-recaptcha-options.php:446
241
  #@ wp-recaptcha-integration
242
  msgid "Unstyled HTML to apply your own Stylesheets."
243
  msgstr "Pures HTML für Deine eigenen Stylessheets"
244
 
245
- #: inc/class-wp-recaptcha-options.php:490
246
- #: inc/class-wp-recaptcha-options.php:514
247
  #@ wp-recaptcha-integration
248
  msgid "ReCaptcha"
249
  msgstr "ReCaptcha"
250
 
251
- #: inc/class-wp-recaptcha-options.php:512
252
  #@ default
253
  msgid "Settings"
254
  msgstr ""
255
 
256
- #: inc/class-wp-recaptcha-options.php:194
257
  #@ wp-recaptcha-integration
258
  msgid "No Captcha where you just click a button"
259
  msgstr "No Captcha. Einfach Checkbox anklicken."
260
 
261
- #: inc/class-wp-recaptcha-options.php:229
262
  #@ wp-recaptcha-integration
263
  msgid "Protect Lost Password"
264
  msgstr "Passwort verloren schützen"
265
 
266
- #: inc/class-wp-recaptcha-options.php:231
267
  #@ wp-recaptcha-integration
268
  msgid "Protect Lost Password form with recaptcha."
269
  msgstr "Das Passwort Verloren Formular mit einem reCaptcha schützen"
@@ -279,38 +279,48 @@ msgstr "reCaptcha Einstellungen"
279
  msgid "reCaptcha"
280
  msgstr "reCaptcha"
281
 
282
- #: inc/class-wp-recaptcha-options.php:275
283
  #@ wp-recaptcha-integration
284
  msgid "Test API Key"
285
  msgstr "API Schlüssel testen"
286
 
287
- #: inc/class-wp-recaptcha-options.php:294
288
  #@ wp-recaptcha-integration
289
  msgid "Test verfication"
290
  msgstr "Captcha-Prüfung testen"
291
 
292
- #: inc/class-wp-recaptcha-options.php:307
293
  #@ wp-recaptcha-integration
294
  msgid "The secret Key is missing."
295
  msgstr "Der geheime Schlüssel fehlt."
296
 
297
- #: inc/class-wp-recaptcha-options.php:308
298
  #@ wp-recaptcha-integration
299
  msgid "The secret Key is invalid. You better check your domain configuration and enter it again."
300
  msgstr "Der geheime Schlüssel ist ungültig. Am besten prüfst Du Deine Domain.-Konfiguration und trägst ihn nochmal ein."
301
 
302
- #: inc/class-wp-recaptcha-options.php:309
303
  #@ wp-recaptcha-integration
304
  msgid "The user response was missing "
305
  msgstr ""
306
 
307
- #: inc/class-wp-recaptcha-options.php:310
308
  #@ wp-recaptcha-integration
309
  msgid "Invalid user response"
310
  msgstr ""
311
 
312
- #: inc/class-wp-recaptcha-options.php:319
313
  #@ wp-recaptcha-integration
314
  msgid "Works! All good!"
315
  msgstr "Läuft! Sehr gut."
316
 
 
 
 
 
 
 
 
 
 
 
1
  msgid ""
2
  msgstr ""
3
+ "Project-Id-Version: WP reCaptcha Integration v1.0.1\n"
4
  "Report-Msgid-Bugs-To: \n"
5
  "POT-Creation-Date: \n"
6
+ "PO-Revision-Date: 2014-12-29 13:22:41+0000\n"
7
  "Last-Translator: admin <joern@flyingletters.com>\n"
8
  "Language-Team: \n"
9
  "MIME-Version: 1.0\n"
20
  "X-Poedit-SearchPath-0: .\n"
21
  "X-Textdomain-Support: yes"
22
 
23
+ #: inc/ninja_forms_field_recaptcha.php:69
24
+ #: wp-recaptcha-integration.php:157
25
+ #: wp-recaptcha-integration.php:164
26
  #@ wp-recaptcha-integration
27
  msgid "<strong>Error:</strong> the Captcha didn’t verify."
28
  msgstr "<strong>Fehler:</strong> Sicherheitstest nicht bestanden"
29
 
30
+ #: wp-recaptcha-integration.php:255
31
  #@ wp-recaptcha-integration
32
  msgid "Sorry, the Captcha didn’t verify."
33
  msgstr "Tut uns leid, aber Sie haben den Sicherheitstest nicht bestanden."
34
 
35
+ #: wp-recaptcha-integration.php:298
36
  #@ wp-recaptcha-integration
37
  msgid "Incorrect please try again"
38
  msgstr "Falsch. Bitte noch einmal versuchen"
39
 
40
+ #: wp-recaptcha-integration.php:300
41
  #@ wp-recaptcha-integration
42
  msgid "Enter the words above:"
43
  msgstr "Geben Sie die Wörten oben ein."
44
 
45
+ #: wp-recaptcha-integration.php:301
46
  #@ wp-recaptcha-integration
47
  msgid "Enter the numbers you hear:"
48
  msgstr "Geben Sie die Zahlen ein, die Sie hören:"
49
 
50
+ #: wp-recaptcha-integration.php:305
51
  #@ wp-recaptcha-integration
52
  msgid "Get another CAPTCHA"
53
  msgstr "Anderes CAPTCHA."
54
 
55
+ #: wp-recaptcha-integration.php:306
56
  #@ wp-recaptcha-integration
57
  msgid "Get an audio CAPTCHA"
58
  msgstr "Audio CAPTCHA"
59
 
60
+ #: wp-recaptcha-integration.php:307
61
  #@ wp-recaptcha-integration
62
  msgid "Get an image CAPTCHA"
63
  msgstr "Bild CAPTCHA"
113
  msgid "Connecting"
114
  msgstr "Verbindung"
115
 
116
+ #: inc/class-wp-recaptcha-options.php:246
117
  #@ wp-recaptcha-integration
118
  msgid "Features"
119
  msgstr "Funktionen"
120
 
121
+ #: inc/class-wp-recaptcha-options.php:189
122
  #@ wp-recaptcha-integration
123
  msgid "Flavor"
124
  msgstr "Geschmacksrichtung"
125
 
126
+ #: inc/class-wp-recaptcha-options.php:200
127
  #@ wp-recaptcha-integration
128
  msgid "Old style reCAPTCHA where you type some cryptic text"
129
  msgstr "Klassisch, man muß kryptische Wörter eingeben"
130
 
131
+ #: inc/class-wp-recaptcha-options.php:205
132
  #@ wp-recaptcha-integration
133
  msgid "Theme"
134
  msgstr "Theme"
135
 
136
+ #: inc/class-wp-recaptcha-options.php:221
137
  #@ wp-recaptcha-integration
138
  msgid "Protect Comments"
139
  msgstr "Kommentare schützen"
140
 
141
+ #: inc/class-wp-recaptcha-options.php:223
142
  #@ wp-recaptcha-integration
143
  msgid "Protect comment forms with recaptcha."
144
  msgstr "Das Kommentarformular mit einem reCaptcha schützen"
145
 
146
+ #: inc/class-wp-recaptcha-options.php:226
147
  #@ wp-recaptcha-integration
148
  msgid "Protect Signup"
149
  msgstr "Registrierung schützen"
150
 
151
+ #: inc/class-wp-recaptcha-options.php:228
152
  #@ wp-recaptcha-integration
153
  msgid "Protect signup form with recaptcha."
154
  msgstr "Die Registrierung mit einem reCaptcha schützen."
155
 
156
+ #: inc/class-wp-recaptcha-options.php:231
157
  #@ wp-recaptcha-integration
158
  msgid "Protect Login"
159
  msgstr "Login schützen"
160
 
161
+ #: inc/class-wp-recaptcha-options.php:233
162
  #@ wp-recaptcha-integration
163
  msgid "Protect Login form with recaptcha."
164
  msgstr "Das Anmeldeformular mit einem reCaptcha schützen"
165
 
166
+ #: inc/class-wp-recaptcha-options.php:241
167
  #@ wp-recaptcha-integration
168
  msgid "Disable for known users"
169
  msgstr "Abschalten bei bekannten Benutzern"
170
 
171
+ #: inc/class-wp-recaptcha-options.php:243
172
  #@ wp-recaptcha-integration
173
  msgid "Disable reCaptcha verification for logged in users."
174
  msgstr "Die reCaptcha-Verifizierung für eingeloggte Benutzer deaktivieren"
175
 
176
+ #: inc/class-wp-recaptcha-options.php:249
177
  #@ wp-recaptcha-integration
178
  msgid "Please configure the public and private key. <a href=\"http://www.google.com/recaptcha/whyrecaptcha\">What are you trying to tell me?</a>"
179
  msgstr "Bitte konfigurieren Sie den privaten und den Öffentlichen Schlüssel (private &amp; public key). <a href=\"http://www.google.com/recaptcha/whyrecaptcha\">Was willst Du mir damit zu sagen?</a>"
180
 
181
+ #: inc/class-wp-recaptcha-options.php:262
182
  #, php-format
183
  #@ wp-recaptcha-integration
184
  msgid "Please register your blog through the <a href=\"%s\">Google reCAPTCHA admin page</a> and enter the public and private key in the fields below. <a href=\"%s\">What is this all about</a>"
187
  "und trage unten den öffentlichen und privaten Schüssel ein. <a \n"
188
  "href=\"%s\">Was erzählst Du mir da?</a>"
189
 
190
+ #: inc/class-wp-recaptcha-options.php:270
191
  #@ wp-recaptcha-integration
192
  msgid "You already entered an API Key. Use the button below to enter it again."
193
  msgstr "Du hast schon einen API-Schlüssel eingetragen. Klick den Button unten, um es nochmal zu tun."
194
 
195
+ #: inc/class-wp-recaptcha-options.php:281
196
  #@ wp-recaptcha-integration
197
  msgid "New API Key"
198
  msgstr "Neuer API-Schlüssel"
199
 
200
+ #: inc/class-wp-recaptcha-options.php:339
201
  #@ default
202
  msgid "Cancel"
203
  msgstr ""
204
 
205
+ #: inc/class-wp-recaptcha-options.php:409
206
  #@ wp-recaptcha-integration
207
  msgid "Light"
208
  msgstr "Hell"
209
 
210
+ #: inc/class-wp-recaptcha-options.php:413
211
  #@ wp-recaptcha-integration
212
  msgid "Dark"
213
  msgstr "Dunkel"
214
 
215
+ #: inc/class-wp-recaptcha-options.php:418
216
  #@ wp-recaptcha-integration
217
  msgid "Red"
218
  msgstr "Rot"
219
 
220
+ #: inc/class-wp-recaptcha-options.php:422
221
  #@ wp-recaptcha-integration
222
  msgid "White"
223
  msgstr "Weiß"
224
 
225
+ #: inc/class-wp-recaptcha-options.php:426
226
  #@ wp-recaptcha-integration
227
  msgid "Black Glass"
228
  msgstr "Schwarzes Glas"
229
 
230
+ #: inc/class-wp-recaptcha-options.php:430
231
  #@ wp-recaptcha-integration
232
  msgid "Clean"
233
  msgstr "Clean"
234
 
235
+ #: inc/class-wp-recaptcha-options.php:434
236
  #@ wp-recaptcha-integration
237
  msgid "Custom"
238
  msgstr "Eigenes"
239
 
240
+ #: inc/class-wp-recaptcha-options.php:454
241
  #@ wp-recaptcha-integration
242
  msgid "Unstyled HTML to apply your own Stylesheets."
243
  msgstr "Pures HTML für Deine eigenen Stylessheets"
244
 
245
+ #: inc/class-wp-recaptcha-options.php:498
246
+ #: inc/class-wp-recaptcha-options.php:522
247
  #@ wp-recaptcha-integration
248
  msgid "ReCaptcha"
249
  msgstr "ReCaptcha"
250
 
251
+ #: inc/class-wp-recaptcha-options.php:520
252
  #@ default
253
  msgid "Settings"
254
  msgstr ""
255
 
256
+ #: inc/class-wp-recaptcha-options.php:196
257
  #@ wp-recaptcha-integration
258
  msgid "No Captcha where you just click a button"
259
  msgstr "No Captcha. Einfach Checkbox anklicken."
260
 
261
+ #: inc/class-wp-recaptcha-options.php:236
262
  #@ wp-recaptcha-integration
263
  msgid "Protect Lost Password"
264
  msgstr "Passwort verloren schützen"
265
 
266
+ #: inc/class-wp-recaptcha-options.php:238
267
  #@ wp-recaptcha-integration
268
  msgid "Protect Lost Password form with recaptcha."
269
  msgstr "Das Passwort Verloren Formular mit einem reCaptcha schützen"
279
  msgid "reCaptcha"
280
  msgstr "reCaptcha"
281
 
282
+ #: inc/class-wp-recaptcha-options.php:282
283
  #@ wp-recaptcha-integration
284
  msgid "Test API Key"
285
  msgstr "API Schlüssel testen"
286
 
287
+ #: inc/class-wp-recaptcha-options.php:302
288
  #@ wp-recaptcha-integration
289
  msgid "Test verfication"
290
  msgstr "Captcha-Prüfung testen"
291
 
292
+ #: inc/class-wp-recaptcha-options.php:315
293
  #@ wp-recaptcha-integration
294
  msgid "The secret Key is missing."
295
  msgstr "Der geheime Schlüssel fehlt."
296
 
297
+ #: inc/class-wp-recaptcha-options.php:316
298
  #@ wp-recaptcha-integration
299
  msgid "The secret Key is invalid. You better check your domain configuration and enter it again."
300
  msgstr "Der geheime Schlüssel ist ungültig. Am besten prüfst Du Deine Domain.-Konfiguration und trägst ihn nochmal ein."
301
 
302
+ #: inc/class-wp-recaptcha-options.php:317
303
  #@ wp-recaptcha-integration
304
  msgid "The user response was missing "
305
  msgstr ""
306
 
307
+ #: inc/class-wp-recaptcha-options.php:318
308
  #@ wp-recaptcha-integration
309
  msgid "Invalid user response"
310
  msgstr ""
311
 
312
+ #: inc/class-wp-recaptcha-options.php:327
313
  #@ wp-recaptcha-integration
314
  msgid "Works! All good!"
315
  msgstr "Läuft! Sehr gut."
316
 
317
+ #: inc/class-wp-recaptcha-options.php:207
318
+ #@ wp-recaptcha-integration
319
+ msgid "Disable Submit Button"
320
+ msgstr "Absendebutton deaktivieren"
321
+
322
+ #: inc/class-wp-recaptcha-options.php:209
323
+ #@ wp-recaptcha-integration
324
+ msgid "Disable Form Submit Button until no-captcha is entered."
325
+ msgstr "Den Absendenbutton deaktivieren, bis das Captcha gelöst wurde."
326
+
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
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: 1.0.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -102,6 +102,11 @@ I will migrate all the translation stuff there.
102
 
103
  == Changelog ==
104
 
 
 
 
 
 
105
  = 1.0.1 =
106
  - Fix API Key test
107
  - Fix theme select
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: 1.0.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
102
 
103
  == Changelog ==
104
 
105
+ = 1.0.2 =
106
+ - Feature: option to disable submit button, until the captcha is solved
107
+ - Rearrange comment form (put captcha above submit button)
108
+ - Fix: NoCaptcha did not refresh after submitting invalid ninja form via ajax
109
+
110
  = 1.0.1 =
111
  - Fix API Key test
112
  - Fix theme select
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: 1.0.1
7
  Author: Jörn Lund
8
  Author URI: https://github.com/mcguffin/
9
  */
@@ -26,6 +26,9 @@ Author URI: https://github.com/mcguffin/
26
 
27
 
28
 
 
 
 
29
  class WP_reCaptcha {
30
 
31
  private static $_is_network_activated = null;
@@ -35,6 +38,8 @@ class WP_reCaptcha {
35
  private $last_error = '';
36
  private $_last_result;
37
 
 
 
38
  /**
39
  * Holding the singleton instance
40
  */
@@ -60,6 +65,7 @@ class WP_reCaptcha {
60
  private function __construct() {
61
  add_option('recaptcha_flavor','grecaptcha'); // local
62
  add_option('recaptcha_theme','light'); // local
 
63
  add_option('recaptcha_publickey',''); // 1st global -> then local
64
  add_option('recaptcha_privatekey',''); // 1st global -> then local
65
 
@@ -100,10 +106,18 @@ class WP_reCaptcha {
100
  register_uninstall_hook( __FILE__ , array( __CLASS__ , 'uninstall' ) );
101
 
102
  }
 
 
 
 
103
  function has_api_key() {
104
  return $this->_has_api_key;
105
  }
106
 
 
 
 
 
107
  function plugins_loaded() {
108
  if ( $this->_has_api_key ) {
109
  // check if ninja forms is present
@@ -115,15 +129,22 @@ class WP_reCaptcha {
115
  include_once dirname(__FILE__).'/inc/contact_form_7_recaptcha.php';
116
  }
117
  }
 
 
 
 
118
  function init() {
119
  load_plugin_textdomain( 'wp-recaptcha-integration', false , dirname( plugin_basename( __FILE__ ) ).'/languages/' );
120
 
121
  $require_recaptcha = $this->is_required();
122
 
123
  if ( $this->get_option('recaptcha_enable_comments') && $require_recaptcha ) {
124
- add_action('comment_form',array($this,'print_recaptcha_html'),10,0);
 
 
 
 
125
  add_action('pre_comment_on_post',array($this,'recaptcha_check_or_die'));
126
- // add action @ comment approve
127
  }
128
  if ( $this->get_option('recaptcha_enable_signup') && $require_recaptcha ) {
129
  add_action('register_form',array($this,'print_recaptcha_html'),10,0);
@@ -138,19 +159,41 @@ class WP_reCaptcha {
138
  add_filter('lostpassword_post' , array(&$this,'recaptcha_check_or_die'),99 );
139
  }
140
  }
141
-
 
 
 
 
 
 
 
 
 
 
 
 
142
  function is_required() {
143
  $is_required = ! ( $this->get_option('recaptcha_disable_for_known_users') && current_user_can( 'read' ) );
144
  return apply_filters( 'recaptcha_required' , $is_required );
145
  }
146
 
147
- function deny_login( $user ){
 
 
 
 
 
148
  if ( isset( $_POST["log"] ) && ! $this->recaptcha_check() ) {
149
  return new WP_Error( 'captcha_error' , __("<strong>Error:</strong> the Captcha didn’t verify.",'wp-recaptcha-integration') );
150
  } else {
151
  return $user;
152
  }
153
  }
 
 
 
 
 
154
  function login_errors( $errors ) {
155
  if ( isset( $_POST["log"] ) && ! $this->recaptcha_check() ) {
156
  $errors->add( 'captcha_error' , __("<strong>Error:</strong> the Captcha didn’t verify.",'wp-recaptcha-integration') );
@@ -158,9 +201,14 @@ class WP_reCaptcha {
158
  return $errors;
159
  }
160
 
 
 
 
 
161
  function recaptcha_head( $flavor = '' ) {
162
  if ( empty( $flavor ) )
163
  $flavor = $this->get_option( 'recaptcha_flavor' );
 
164
  switch ( $flavor ) {
165
  case 'grecaptcha':
166
  ?><style type="text/css">
@@ -187,46 +235,133 @@ class WP_reCaptcha {
187
  }
188
  break;
189
  }
 
190
  }
 
 
 
 
191
  function recaptcha_foot( $flavor = '' ) {
192
  if ( empty( $flavor ) )
193
  $flavor = $this->get_option( 'recaptcha_flavor' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
194
  switch ( $flavor ) {
195
  case 'grecaptcha':
196
  ?><script type="text/javascript">
 
197
  function recaptchaLoadCallback(){
198
- var e=document.getElementsByClassName('g-recaptcha');
199
- for (var i=0;i<e.length;i++)
200
- grecaptcha.render(e[i],{'sitekey':'<?php echo $this->get_option('recaptcha_publickey'); ?>','theme':'<?php echo $this->get_option('recaptcha_theme'); ?>'});
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
201
  }
202
  </script><?php
203
  ?><script src="https://www.google.com/recaptcha/api.js?onload=recaptchaLoadCallback&render=explicit" async defer></script><?php
204
  break;
205
  case 'recaptcha':
 
 
 
 
 
 
 
 
 
 
 
 
 
 
206
  break;
207
  }
 
208
  }
 
 
 
 
209
  function recaptcha_check_or_die( ) {
210
  if ( ! $this->recaptcha_check() )
211
  wp_die( __("Sorry, the Captcha didn’t verify.",'wp-recaptcha-integration') );
212
  }
213
 
 
 
 
214
  function print_recaptcha_html( $flavor = '' ) {
215
  echo $this->recaptcha_html( $flavor );
216
  }
217
 
 
 
 
 
218
  function recaptcha_html( $flavor = '' ) {
219
 
220
  if ( empty( $flavor ) )
221
  $flavor = $this->get_option( 'recaptcha_flavor' );
 
 
222
  switch ( $flavor ) {
223
  case 'grecaptcha':
224
- return $this->grecaptcha_html();
 
225
  case 'recaptcha':
226
- return $this->old_recaptcha_html();
 
227
  }
 
 
228
  }
229
 
 
 
 
 
230
  function old_recaptcha_html() {
231
  require_once dirname(__FILE__).'/recaptchalib.php';
232
  $public_key = $this->get_option( 'recaptcha_publickey' );
@@ -236,16 +371,27 @@ class WP_reCaptcha {
236
  $return = $this->get_custom_html( $public_key );
237
  else
238
  $return = recaptcha_get_html( $public_key, $this->last_error );
 
 
 
239
  return $return;
240
  }
241
 
 
 
 
 
242
  function grecaptcha_html() {
243
  $public_key = $this->get_option( 'recaptcha_publickey' );
244
  $theme = $this->get_option('recaptcha_theme');
245
- $return = sprintf( '<div class="g-recaptcha" data-sitekey="%s" data-theme="%s"></div>',$public_key,$theme);
246
  return $return;
247
  }
248
 
 
 
 
 
249
  function get_custom_html( $public_key ) {
250
 
251
  $return = '<div id="recaptcha_widget" style="display:none">';
@@ -276,10 +422,18 @@ class WP_reCaptcha {
276
  return $return;
277
  }
278
 
 
 
 
 
279
  function get_last_result() {
280
  return $this->_last_result;
281
  }
282
 
 
 
 
 
283
  function recaptcha_check( $flavor = '' ) {
284
  if ( empty( $flavor ) )
285
  $flavor = $this->get_option( 'recaptcha_flavor' );
@@ -290,6 +444,10 @@ class WP_reCaptcha {
290
  return $this->old_recaptcha_check();
291
  }
292
  }
 
 
 
 
293
  function grecaptcha_check() {
294
  $private_key = $this->get_option( 'recaptcha_privatekey' );
295
  $user_response = isset( $_REQUEST['g-recaptcha-response'] ) ? $_REQUEST['g-recaptcha-response'] : false;
@@ -305,6 +463,10 @@ class WP_reCaptcha {
305
  }
306
  return false;
307
  }
 
 
 
 
308
  function old_recaptcha_check() {
309
  require_once dirname(__FILE__).'/recaptchalib.php';
310
  $private_key = $this->get_option( 'recaptcha_privatekey' );
@@ -319,18 +481,21 @@ class WP_reCaptcha {
319
  return $this->_last_result->is_valid;
320
  }
321
 
 
 
 
 
 
 
322
  public function get_option( $option_name ) {
323
  switch ( $option_name ) {
324
- case 'recaptcha_flavor':
325
- case 'recaptcha_theme':
326
- return get_option($option_name);
327
- case 'recaptcha_publickey':
328
  case 'recaptcha_privatekey':
329
  $option_value = get_option($option_name);
330
  if ( ! $option_value && WP_reCaptcha::is_network_activated() )
331
  $option_value = get_site_option( $option_name );
332
  return $option_value;
333
- case 'recaptcha_enable_comments':
334
  case 'recaptcha_enable_signup':
335
  case 'recaptcha_enable_login':
336
  case 'recaptcha_enable_lostpw':
@@ -338,6 +503,8 @@ class WP_reCaptcha {
338
  if ( WP_reCaptcha::is_network_activated() )
339
  return get_site_option($option_name);
340
  return get_option( $option_name );
 
 
341
  }
342
  }
343
 
@@ -385,6 +552,11 @@ class WP_reCaptcha {
385
  }
386
  }
387
 
 
 
 
 
 
388
  static function is_network_activated() {
389
  if ( is_null(self::$_is_network_activated) ) {
390
  if ( ! is_multisite() )
@@ -396,9 +568,31 @@ class WP_reCaptcha {
396
  }
397
  return self::$_is_network_activated;
398
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
399
  }
400
 
401
-
402
  WP_reCaptcha::instance();
403
 
404
  if ( is_admin() )
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: 1.0.2
7
  Author: Jörn Lund
8
  Author URI: https://github.com/mcguffin/
9
  */
26
 
27
 
28
 
29
+ /**
30
+ * Plugin base Class
31
+ */
32
  class WP_reCaptcha {
33
 
34
  private static $_is_network_activated = null;
38
  private $last_error = '';
39
  private $_last_result;
40
 
41
+ private $_counter = 0;
42
+
43
  /**
44
  * Holding the singleton instance
45
  */
65
  private function __construct() {
66
  add_option('recaptcha_flavor','grecaptcha'); // local
67
  add_option('recaptcha_theme','light'); // local
68
+ add_option('recaptcha_disable_submit',false); // local
69
  add_option('recaptcha_publickey',''); // 1st global -> then local
70
  add_option('recaptcha_privatekey',''); // 1st global -> then local
71
 
106
  register_uninstall_hook( __FILE__ , array( __CLASS__ , 'uninstall' ) );
107
 
108
  }
109
+
110
+ /**
111
+ * @return bool return if google api is configured
112
+ */
113
  function has_api_key() {
114
  return $this->_has_api_key;
115
  }
116
 
117
+ /**
118
+ * Load ninja/cf7 php files if necessary
119
+ * Hooks into 'plugins_loaded'
120
+ */
121
  function plugins_loaded() {
122
  if ( $this->_has_api_key ) {
123
  // check if ninja forms is present
129
  include_once dirname(__FILE__).'/inc/contact_form_7_recaptcha.php';
130
  }
131
  }
132
+ /**
133
+ * Init plugin
134
+ * set hooks
135
+ */
136
  function init() {
137
  load_plugin_textdomain( 'wp-recaptcha-integration', false , dirname( plugin_basename( __FILE__ ) ).'/languages/' );
138
 
139
  $require_recaptcha = $this->is_required();
140
 
141
  if ( $this->get_option('recaptcha_enable_comments') && $require_recaptcha ) {
142
+ /*
143
+ add_action('comment_form_after_fields',array($this,'print_recaptcha_html'),10,0);
144
+ /*/
145
+ add_filter('comment_form_defaults',array($this,'comment_form_defaults'),10);
146
+ //*/
147
  add_action('pre_comment_on_post',array($this,'recaptcha_check_or_die'));
 
148
  }
149
  if ( $this->get_option('recaptcha_enable_signup') && $require_recaptcha ) {
150
  add_action('register_form',array($this,'print_recaptcha_html'),10,0);
159
  add_filter('lostpassword_post' , array(&$this,'recaptcha_check_or_die'),99 );
160
  }
161
  }
162
+ /**
163
+ * Display recaptcha on comments form.
164
+ * filter function for `comment_form_defaults`
165
+ * set hooks
166
+ */
167
+ function comment_form_defaults( $defaults ) {
168
+ $defaults['comment_notes_after'] .= '<p>' . $this->recaptcha_html() . '</p>';
169
+ return $defaults;
170
+ }
171
+ /**
172
+ * returns if recaptcha is required.
173
+ * @return bool
174
+ */
175
  function is_required() {
176
  $is_required = ! ( $this->get_option('recaptcha_disable_for_known_users') && current_user_can( 'read' ) );
177
  return apply_filters( 'recaptcha_required' , $is_required );
178
  }
179
 
180
+ /**
181
+ * check recaptcha on login
182
+ * filter function for `wp_authenticate_user`
183
+ * @return object user or wp error
184
+ */
185
+ function deny_login( $user ) {
186
  if ( isset( $_POST["log"] ) && ! $this->recaptcha_check() ) {
187
  return new WP_Error( 'captcha_error' , __("<strong>Error:</strong> the Captcha didn’t verify.",'wp-recaptcha-integration') );
188
  } else {
189
  return $user;
190
  }
191
  }
192
+ /**
193
+ * check recaptcha on registration
194
+ * filter function for `registration_errors`
195
+ * @return object errors
196
+ */
197
  function login_errors( $errors ) {
198
  if ( isset( $_POST["log"] ) && ! $this->recaptcha_check() ) {
199
  $errors->add( 'captcha_error' , __("<strong>Error:</strong> the Captcha didn’t verify.",'wp-recaptcha-integration') );
201
  return $errors;
202
  }
203
 
204
+ /**
205
+ * print recaptcha stylesheets
206
+ * hooks into `wp_head`
207
+ */
208
  function recaptcha_head( $flavor = '' ) {
209
  if ( empty( $flavor ) )
210
  $flavor = $this->get_option( 'recaptcha_flavor' );
211
+ $this->begin_inject( );
212
  switch ( $flavor ) {
213
  case 'grecaptcha':
214
  ?><style type="text/css">
235
  }
236
  break;
237
  }
238
+ $this->end_inject( );
239
  }
240
+ /**
241
+ * Print recaptcha scripts
242
+ * hooks into `wp_footer`
243
+ */
244
  function recaptcha_foot( $flavor = '' ) {
245
  if ( empty( $flavor ) )
246
  $flavor = $this->get_option( 'recaptcha_flavor' );
247
+
248
+ $this->begin_inject( );
249
+ // getting submit buttons of an elements form
250
+ if ( $this->get_option( 'recaptcha_disable_submit' ) ) {
251
+ ?><script type="text/javascript">
252
+ function get_form_submits(el){
253
+ var form,current=el,ui,type,slice = Array.prototype.slice,self=this;
254
+ this.submits=[];
255
+ this.form=false;
256
+
257
+ this.setEnabled=function(e){
258
+ for ( var s in self.submits ) {
259
+ if (e) self.submits[s].removeAttribute('disabled');
260
+ else self.submits[s].setAttribute('disabled','disabled');
261
+ }
262
+ return this;
263
+ };
264
+ while ( current && current.nodeName != 'BODY' && current.nodeName != 'FORM' ) {
265
+ current = current.parentNode;
266
+ }
267
+ if ( !current || current.nodeName != 'FORM' )
268
+ return false;
269
+ this.form=current;
270
+ ui=slice.call(this.form.getElementsByTagName('input')).concat(slice.call(this.form.getElementsByTagName('button')));
271
+ for (var i in ui ) if ( (type=ui[i].getAttribute('TYPE')) && type=='submit' ) this.submits.push(ui[i]);
272
+ return this;
273
+ }
274
+ </script><?php
275
+ }
276
  switch ( $flavor ) {
277
  case 'grecaptcha':
278
  ?><script type="text/javascript">
279
+ var recaptcha_widgets={};
280
  function recaptchaLoadCallback(){
281
+ var e=document.getElementsByClassName('g-recaptcha'),form_submits;
282
+
283
+ for (var i=0;i<e.length;i++) {
284
+ (function(el){
285
+ <?php if ( $this->get_option( 'recaptcha_disable_submit' ) ) { ?>
286
+ var form_submits = get_form_submits(el).setEnabled(false),wid;
287
+ <?php } ?>
288
+
289
+ wid = grecaptcha.render(el,{
290
+ 'sitekey':'<?php echo $this->get_option('recaptcha_publickey'); ?>',
291
+ 'theme':'<?php echo $this->get_option('recaptcha_theme'); ?>'
292
+ <?php if ( $this->get_option( 'recaptcha_disable_submit' ) ) { ?>
293
+ ,
294
+ 'callback' : function(r){ get_form_submits(el).setEnabled(true); /* enable submit buttons */ }
295
+ <?php } ?>
296
+ });
297
+ el.setAttribute('data-widget-id',wid);
298
+ })(e[i]);
299
+ }
300
  }
301
  </script><?php
302
  ?><script src="https://www.google.com/recaptcha/api.js?onload=recaptchaLoadCallback&render=explicit" async defer></script><?php
303
  break;
304
  case 'recaptcha':
305
+ if ( $this->get_option( 'recaptcha_disable_submit' ) ) {
306
+ ?><script type="text/javascript">
307
+ document.addEventListener('keyup',function(e){
308
+ if (e.target && typeof e.target.getAttribute=='function' && e.target.getAttribute('ID')=='recaptcha_response_field') {
309
+ get_form_submits(e.target).setEnabled(!!e.target.value);
310
+ }
311
+ });
312
+ document.addEventListener('DOMContentLoaded',function(e){
313
+ try {
314
+ get_form_submits(document.getElementById('wp-recaptcha-integration-marker')).setEnabled(false);
315
+ } catch(e){};
316
+ });
317
+ </script><?php
318
+ }
319
  break;
320
  }
321
+ $this->end_inject( );
322
  }
323
+ /**
324
+ * Check recaptcha and wp_die() on fail
325
+ * hooks into `pre_comment_on_post`, `lostpassword_post`
326
+ */
327
  function recaptcha_check_or_die( ) {
328
  if ( ! $this->recaptcha_check() )
329
  wp_die( __("Sorry, the Captcha didn’t verify.",'wp-recaptcha-integration') );
330
  }
331
 
332
+ /**
333
+ * Print recaptcha HTML. Use inside a form.
334
+ */
335
  function print_recaptcha_html( $flavor = '' ) {
336
  echo $this->recaptcha_html( $flavor );
337
  }
338
 
339
+ /**
340
+ * Get recaptcha HTML.
341
+ * @return string recaptcha html
342
+ */
343
  function recaptcha_html( $flavor = '' ) {
344
 
345
  if ( empty( $flavor ) )
346
  $flavor = $this->get_option( 'recaptcha_flavor' );
347
+ $return = $this->begin_inject( true );
348
+
349
  switch ( $flavor ) {
350
  case 'grecaptcha':
351
+ $return .= $this->grecaptcha_html();
352
+ break;
353
  case 'recaptcha':
354
+ $return .= $this->old_recaptcha_html();
355
+ break;
356
  }
357
+ $return .= $this->end_inject( true );
358
+ return $return;
359
  }
360
 
361
+ /**
362
+ * Get old style recaptcha HTML.
363
+ * @return string recaptcha html
364
+ */
365
  function old_recaptcha_html() {
366
  require_once dirname(__FILE__).'/recaptchalib.php';
367
  $public_key = $this->get_option( 'recaptcha_publickey' );
371
  $return = $this->get_custom_html( $public_key );
372
  else
373
  $return = recaptcha_get_html( $public_key, $this->last_error );
374
+ if ( $this->get_option( 'recaptcha_disable_submit' ) ) {
375
+ $return .= '<span id="wp-recaptcha-integration-marker"></span>';
376
+ }
377
  return $return;
378
  }
379
 
380
+ /**
381
+ * Get no captcha (new style recaptcha) HTML.
382
+ * @return string recaptcha html
383
+ */
384
  function grecaptcha_html() {
385
  $public_key = $this->get_option( 'recaptcha_publickey' );
386
  $theme = $this->get_option('recaptcha_theme');
387
+ $return = sprintf( '<div id="g-recaptcha-%d" class="g-recaptcha" data-sitekey="%s" data-theme="%s"></div>',$this->_counter++,$public_key,$theme);
388
  return $return;
389
  }
390
 
391
+ /**
392
+ * Get un-themed old style recaptcha HTML.
393
+ * @return string recaptcha html
394
+ */
395
  function get_custom_html( $public_key ) {
396
 
397
  $return = '<div id="recaptcha_widget" style="display:none">';
422
  return $return;
423
  }
424
 
425
+ /**
426
+ * Get last result of recaptcha check
427
+ * @return string recaptcha html
428
+ */
429
  function get_last_result() {
430
  return $this->_last_result;
431
  }
432
 
433
+ /**
434
+ * Check recaptcha
435
+ * @return bool false if check does not validate
436
+ */
437
  function recaptcha_check( $flavor = '' ) {
438
  if ( empty( $flavor ) )
439
  $flavor = $this->get_option( 'recaptcha_flavor' );
444
  return $this->old_recaptcha_check();
445
  }
446
  }
447
+ /**
448
+ * Check no captcha
449
+ * @return bool false if check does not validate
450
+ */
451
  function grecaptcha_check() {
452
  $private_key = $this->get_option( 'recaptcha_privatekey' );
453
  $user_response = isset( $_REQUEST['g-recaptcha-response'] ) ? $_REQUEST['g-recaptcha-response'] : false;
463
  }
464
  return false;
465
  }
466
+ /**
467
+ * Check old style recaptcha
468
+ * @return bool false if check does not validate
469
+ */
470
  function old_recaptcha_check() {
471
  require_once dirname(__FILE__).'/recaptchalib.php';
472
  $private_key = $this->get_option( 'recaptcha_privatekey' );
481
  return $this->_last_result->is_valid;
482
  }
483
 
484
+ /**
485
+ * Get plugin option by name.
486
+ *
487
+ * @param $option_name string
488
+ * @return bool false if check does not validate
489
+ */
490
  public function get_option( $option_name ) {
491
  switch ( $option_name ) {
492
+ case 'recaptcha_publickey': // first try local, then global
 
 
 
493
  case 'recaptcha_privatekey':
494
  $option_value = get_option($option_name);
495
  if ( ! $option_value && WP_reCaptcha::is_network_activated() )
496
  $option_value = get_site_option( $option_name );
497
  return $option_value;
498
+ case 'recaptcha_enable_comments': // global on network. else local
499
  case 'recaptcha_enable_signup':
500
  case 'recaptcha_enable_login':
501
  case 'recaptcha_enable_lostpw':
503
  if ( WP_reCaptcha::is_network_activated() )
504
  return get_site_option($option_name);
505
  return get_option( $option_name );
506
+ default: // always local
507
+ return get_option($option_name);
508
  }
509
  }
510
 
552
  }
553
  }
554
 
555
+ /**
556
+ * Get plugin option by name.
557
+ *
558
+ * @return bool true if plugin is activated on network
559
+ */
560
  static function is_network_activated() {
561
  if ( is_null(self::$_is_network_activated) ) {
562
  if ( ! is_multisite() )
568
  }
569
  return self::$_is_network_activated;
570
  }
571
+ /**
572
+ * HTML comment with some notes (beginning)
573
+ *
574
+ * @param $return bool Whether to print or to return the comment
575
+ * @param $moretext string Additional information being included in the comment
576
+ * @return null|string HTML-Comment
577
+ */
578
+ function begin_inject($return = false,$moretext='') {
579
+ $html = "\n<!-- BEGIN recaptcha, injected by plugin wp-recaptcha-integration $moretext -->\n";
580
+ if ( $return ) return $html;
581
+ echo $html;
582
+ }
583
+ /**
584
+ * HTML comment with some notes (ending)
585
+ *
586
+ * @param $return bool Whether to print or to return the comment
587
+ * @return null|string HTML-Comment
588
+ */
589
+ function end_inject( $return = false ) {
590
+ $html = "\n<!-- END recaptcha -->\n";
591
+ if ( $return ) return $html;
592
+ echo $html;
593
+ }
594
  }
595
 
 
596
  WP_reCaptcha::instance();
597
 
598
  if ( is_admin() )