Advanced noCaptcha & invisible Captcha - Version 4.1

Version Description

  • Settings page redesigned.
  • anr_is_form_enabled function added
  • Captcha error show first before username password error. So if captcha is not validated then username password error is not shown.
  • enqueue login css only if normal captcha is shown
  • Enabled forms stored as an array in db. array key is enabled_forms
  • Add class ANR_Settings, removed class anr_admin_class
  • BuddyPress register captcha added
Download this release

Release Info

Developer shamim51
Plugin Icon 128x128 Advanced noCaptcha & invisible Captcha
Version 4.1
Comparing to
See all releases

Code changes from version 3.1 to 4.1

admin/settings.php ADDED
@@ -0,0 +1,457 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class ANR_Settings {
4
+
5
+ private static $instance;
6
+
7
+ public static function init() {
8
+ if ( ! self::$instance instanceof self ) {
9
+ self::$instance = new self();
10
+ }
11
+ return self::$instance;
12
+ }
13
+
14
+ function actions_filters() {
15
+ add_action( 'admin_init', array( $this, 'admin_init' ) );
16
+ add_filter( 'plugin_action_links', array( $this, 'add_settings_link' ), 10, 2 );
17
+
18
+ if ( is_multisite() ) {
19
+ $same_settings = apply_filters( 'anr_same_settings_for_all_sites', false );
20
+ } else {
21
+ $same_settings = false;
22
+ }
23
+ if ( $same_settings ) {
24
+ add_action( 'network_admin_menu', array( $this, 'menu_page' ) );
25
+ } else {
26
+ add_action( 'admin_menu', array( $this, 'menu_page' ) );
27
+ }
28
+
29
+ }
30
+
31
+ function admin_init() {
32
+ register_setting( 'anr_admin_options', 'anr_admin_options', array( $this, 'options_sanitize' ) );
33
+ foreach ( $this->get_sections() as $section_id => $section ) {
34
+ add_settings_section( $section_id, $section['section_title'], ! empty( $section['section_callback'] ) ? $section['section_callback'] : null, 'anr_admin_options' );
35
+ }
36
+ foreach ( $this->get_fields() as $field_id => $field ) {
37
+ $args = wp_parse_args(
38
+ $field, array(
39
+ 'id' => $field_id,
40
+ 'label' => '',
41
+ 'cb_label' => '',
42
+ 'type' => 'text',
43
+ 'class' => 'regular-text',
44
+ 'section_id' => '',
45
+ 'desc' => '',
46
+ 'std' => '',
47
+ )
48
+ );
49
+ add_settings_field( $args['id'], $args['label'], ! empty( $args['callback'] ) ? $args['callback'] : array( $this, 'callback' ), 'anr_admin_options', $args['section_id'], $args );
50
+ }
51
+ }
52
+
53
+ function get_sections() {
54
+ $sections = array(
55
+ 'google_keys' => array(
56
+ 'section_title' => __( 'Google Keys', 'advanced-nocaptcha-recaptcha' ),
57
+ 'section_callback' => function() {
58
+ printf( __( 'Get reCaptcha v2 keys from <a href="%s">Google</a>. If you select Invisible captcha, make sure to get keys for Invisible captcha.', 'advanced-nocaptcha-recaptcha' ), 'https://www.google.com/recaptcha/admin' );
59
+ },
60
+ ),
61
+ 'forms' => array(
62
+ 'section_title' => __( 'Forms', 'advanced-nocaptcha-recaptcha' ),
63
+ ),
64
+ 'other' => array(
65
+ 'section_title' => __( 'Other Settings', 'advanced-nocaptcha-recaptcha' ),
66
+ ),
67
+ );
68
+ return apply_filters( 'anr_settings_sections', $sections );
69
+ }
70
+
71
+ function get_fields() {
72
+ $fields = array(
73
+ 'site_key' => array(
74
+ 'label' => __( 'Site Key', 'advanced-nocaptcha-recaptcha' ),
75
+ 'section_id' => 'google_keys',
76
+ ),
77
+ 'secret_key' => array(
78
+ 'label' => __( 'Secret Key', 'advanced-nocaptcha-recaptcha' ),
79
+ 'section_id' => 'google_keys',
80
+ ),
81
+ 'enabled_forms' => array(
82
+ 'label' => __( 'Enabled Forms', 'advanced-nocaptcha-recaptcha' ),
83
+ 'section_id' => 'forms',
84
+ 'type' => 'multicheck',
85
+ 'class' => 'checkbox',
86
+ 'options' => array(
87
+ 'login' => __( 'Login Form', 'advanced-nocaptcha-recaptcha' ),
88
+ 'registration' => __( 'Registration Form', 'advanced-nocaptcha-recaptcha' ),
89
+ 'ms_user_signup' => __( 'Multisite User Signup Form', 'advanced-nocaptcha-recaptcha' ),
90
+ 'lost_password' => __( 'Lost Password Form', 'advanced-nocaptcha-recaptcha' ),
91
+ 'reset_password' => __( 'Reset Password Form', 'advanced-nocaptcha-recaptcha' ),
92
+ 'comment' => __( 'Comment Form', 'advanced-nocaptcha-recaptcha' ),
93
+ 'bbp_new' => __( 'bbPress New topic', 'advanced-nocaptcha-recaptcha' ),
94
+ 'bbp_reply' => __( 'bbPress reply to topic', 'advanced-nocaptcha-recaptcha' ),
95
+ 'bp_register' => __( 'BuddyPress register', 'advanced-nocaptcha-recaptcha' ),
96
+ 'wc_checkout' => __( 'WooCommerce Checkout', 'advanced-nocaptcha-recaptcha' ),
97
+ ),
98
+ 'desc' => sprintf( __( 'For other forms see <a href="%s">Instruction</a>', 'advanced-nocaptcha-recaptcha' ), esc_url( admin_url( 'admin.php?page=anr-instruction' ) ) ),
99
+ ),
100
+ 'error_message' => array(
101
+ 'label' => __( 'Error Message', 'advanced-nocaptcha-recaptcha' ),
102
+ 'section_id' => 'other',
103
+ 'std' => __( 'Please solve Captcha correctly', 'advanced-nocaptcha-recaptcha' ),
104
+ ),
105
+ 'language' => array(
106
+ 'label' => __( 'Captcha Language', 'advanced-nocaptcha-recaptcha' ),
107
+ 'section_id' => 'other',
108
+ 'type' => 'select',
109
+ 'class' => 'regular',
110
+ 'options' => array(
111
+ '' => __( 'Auto Detect', 'advanced-nocaptcha-recaptcha' ),
112
+ 'ar' => __( 'Arabic', 'advanced-nocaptcha-recaptcha' ),
113
+ 'bg' => __( 'Bulgarian', 'advanced-nocaptcha-recaptcha' ),
114
+ 'ca' => __( 'Catalan', 'advanced-nocaptcha-recaptcha' ),
115
+ 'zh-CN' => __( 'Chinese (Simplified)', 'advanced-nocaptcha-recaptcha' ),
116
+ 'zh-CN' => __( 'Chinese (Traditional)', 'advanced-nocaptcha-recaptcha' ),
117
+ 'hr' => __( 'Croatian', 'advanced-nocaptcha-recaptcha' ),
118
+ 'cs' => __( 'Czech', 'advanced-nocaptcha-recaptcha' ),
119
+ 'da' => __( 'Danish', 'advanced-nocaptcha-recaptcha' ),
120
+ 'nl' => __( 'Dutch', 'advanced-nocaptcha-recaptcha' ),
121
+ 'en-GB' => __( 'English (UK)', 'advanced-nocaptcha-recaptcha' ),
122
+ 'en' => __( 'English (US)', 'advanced-nocaptcha-recaptcha' ),
123
+ 'fil' => __( 'Filipino', 'advanced-nocaptcha-recaptcha' ),
124
+ 'fi' => __( 'Finnish', 'advanced-nocaptcha-recaptcha' ),
125
+ 'fr' => __( 'French', 'advanced-nocaptcha-recaptcha' ),
126
+ 'fr-CA' => __( 'French (Canadian)', 'advanced-nocaptcha-recaptcha' ),
127
+ 'de' => __( 'German', 'advanced-nocaptcha-recaptcha' ),
128
+ 'de-AT' => __( 'German (Austria)', 'advanced-nocaptcha-recaptcha' ),
129
+ 'de-CH' => __( 'German (Switzerland)', 'advanced-nocaptcha-recaptcha' ),
130
+ 'el' => __( 'Greek', 'advanced-nocaptcha-recaptcha' ),
131
+ 'iw' => __( 'Hebrew', 'advanced-nocaptcha-recaptcha' ),
132
+ 'hi' => __( 'Hindi', 'advanced-nocaptcha-recaptcha' ),
133
+ 'hu' => __( 'Hungarain', 'advanced-nocaptcha-recaptcha' ),
134
+ 'id' => __( 'Indonesian', 'advanced-nocaptcha-recaptcha' ),
135
+ 'it' => __( 'Italian', 'advanced-nocaptcha-recaptcha' ),
136
+ 'ja' => __( 'Japanese', 'advanced-nocaptcha-recaptcha' ),
137
+ 'ko' => __( 'Korean', 'advanced-nocaptcha-recaptcha' ),
138
+ 'lv' => __( 'Latvian', 'advanced-nocaptcha-recaptcha' ),
139
+ 'lt' => __( 'Lithuanian', 'advanced-nocaptcha-recaptcha' ),
140
+ 'no' => __( 'Norwegian', 'advanced-nocaptcha-recaptcha' ),
141
+ 'fa' => __( 'Persian', 'advanced-nocaptcha-recaptcha' ),
142
+ 'pl' => __( 'Polish', 'advanced-nocaptcha-recaptcha' ),
143
+ 'pt' => __( 'Portuguese', 'advanced-nocaptcha-recaptcha' ),
144
+ 'pt-BR' => __( 'Portuguese (Brazil)', 'advanced-nocaptcha-recaptcha' ),
145
+ 'pt-PT' => __( 'Portuguese (Portugal)', 'advanced-nocaptcha-recaptcha' ),
146
+ 'ro' => __( 'Romanian', 'advanced-nocaptcha-recaptcha' ),
147
+ 'ru' => __( 'Russian', 'advanced-nocaptcha-recaptcha' ),
148
+ 'sr' => __( 'Serbian', 'advanced-nocaptcha-recaptcha' ),
149
+ 'sk' => __( 'Slovak', 'advanced-nocaptcha-recaptcha' ),
150
+ 'sl' => __( 'Slovenian', 'advanced-nocaptcha-recaptcha' ),
151
+ 'es' => __( 'Spanish', 'advanced-nocaptcha-recaptcha' ),
152
+ 'es-419' => __( 'Spanish (Latin America)', 'advanced-nocaptcha-recaptcha' ),
153
+ 'sv' => __( 'Swedish', 'advanced-nocaptcha-recaptcha' ),
154
+ 'th' => __( 'Thai', 'advanced-nocaptcha-recaptcha' ),
155
+ 'tr' => __( 'Turkish', 'advanced-nocaptcha-recaptcha' ),
156
+ 'uk' => __( 'Ukrainian', 'advanced-nocaptcha-recaptcha' ),
157
+ 'vi' => __( 'Vietnamese', 'advanced-nocaptcha-recaptcha' ),
158
+ ),
159
+ ),
160
+ 'theme' => array(
161
+ 'label' => __( 'Theme', 'advanced-nocaptcha-recaptcha' ),
162
+ 'section_id' => 'other',
163
+ 'type' => 'select',
164
+ 'class' => 'regular',
165
+ 'std' => 'light',
166
+ 'options' => array(
167
+ 'light' => __( 'Light', 'advanced-nocaptcha-recaptcha' ),
168
+ 'dark' => __( 'Dark', 'advanced-nocaptcha-recaptcha' ),
169
+ ),
170
+ ),
171
+ 'size' => array(
172
+ 'label' => __( 'Size', 'advanced-nocaptcha-recaptcha' ),
173
+ 'section_id' => 'other',
174
+ 'type' => 'select',
175
+ 'class' => 'regular',
176
+ 'std' => 'normal',
177
+ 'options' => array(
178
+ 'normal' => __( 'Normal', 'advanced-nocaptcha-recaptcha' ),
179
+ 'compact' => __( 'Compact', 'advanced-nocaptcha-recaptcha' ),
180
+ 'invisible' => __( 'Invisible', 'advanced-nocaptcha-recaptcha' ),
181
+ ),
182
+ 'desc' => __( 'For invisible captcha set this as Invisible. Make sure to use site key and secret key for invisible captcha', 'advanced-nocaptcha-recaptcha' ),
183
+ ),
184
+ 'badge' => array(
185
+ 'label' => __( 'Badge', 'advanced-nocaptcha-recaptcha' ),
186
+ 'section_id' => 'other',
187
+ 'type' => 'select',
188
+ 'class' => 'regular',
189
+ 'std' => 'bottomright',
190
+ 'options' => array(
191
+ 'bottomright' => __( 'Bottom Right', 'advanced-nocaptcha-recaptcha' ),
192
+ 'bottomleft' => __( 'Bottom Left', 'advanced-nocaptcha-recaptcha' ),
193
+ 'inline' => __( 'Inline', 'advanced-nocaptcha-recaptcha' ),
194
+ ),
195
+ 'desc' => __( 'Badge shows for invisible captcha', 'advanced-nocaptcha-recaptcha' ),
196
+ ),
197
+ 'failed_login_allow' => array(
198
+ 'label' => __( 'Failed login Captcha', 'advanced-nocaptcha-recaptcha' ),
199
+ 'section_id' => 'other',
200
+ 'std' => 0,
201
+ 'type' => 'number',
202
+ 'class' => 'regular-number',
203
+ 'sanitize_callback' => 'absint',
204
+ 'desc' => __( 'Show login Captcha after how many failed attempts? 0 = show always', 'advanced-nocaptcha-recaptcha' ),
205
+ ),
206
+ 'loggedin_hide' => array(
207
+ 'label' => __( 'Logged in Hide', 'advanced-nocaptcha-recaptcha' ),
208
+ 'section_id' => 'other',
209
+ 'type' => 'checkbox',
210
+ 'class' => 'checkbox',
211
+ 'cb_label' => __( 'Hide Captcha for logged in users?', 'advanced-nocaptcha-recaptcha' ),
212
+ ),
213
+ 'remove_css' => array(
214
+ 'label' => __( 'Remove CSS', 'advanced-nocaptcha-recaptcha' ),
215
+ 'section_id' => 'other',
216
+ 'type' => 'checkbox',
217
+ 'class' => 'checkbox',
218
+ 'cb_label' => __( "Remove this plugin's css from login page?", 'advanced-nocaptcha-recaptcha' ),
219
+ 'desc' => __( 'This css increase login page width to adjust with Captcha width.', 'advanced-nocaptcha-recaptcha' ),
220
+ ),
221
+ 'no_js' => array(
222
+ 'label' => __( 'No JS Captcha', 'advanced-nocaptcha-recaptcha' ),
223
+ 'section_id' => 'other',
224
+ 'type' => 'checkbox',
225
+ 'class' => 'checkbox',
226
+ 'cb_label' => __( 'Show captcha if javascript disabled?', 'advanced-nocaptcha-recaptcha' ),
227
+ 'desc' => __( 'If JavaScript is a requirement for your site, we advise that you do NOT check this.', 'advanced-nocaptcha-recaptcha' ),
228
+ ),
229
+ );
230
+ return apply_filters( 'anr_settings_fields', $fields );
231
+ }
232
+
233
+ function callback( $field ) {
234
+ $attrib = '';
235
+ if ( ! empty( $field['required'] ) ) {
236
+ $attrib .= ' required = "required"';
237
+ }
238
+ if ( ! empty( $field['readonly'] ) ) {
239
+ $attrib .= ' readonly = "readonly"';
240
+ }
241
+ if ( ! empty( $field['disabled'] ) ) {
242
+ $attrib .= ' disabled = "disabled"';
243
+ }
244
+ if ( ! empty( $field['minlength'] ) ) {
245
+ $attrib .= ' minlength = "' . absint( $field['minlength'] ) . '"';
246
+ }
247
+ if ( ! empty( $field['maxlength'] ) ) {
248
+ $attrib .= ' maxlength = "' . absint( $field['maxlength'] ) . '"';
249
+ }
250
+
251
+ $value = anr_get_option( $field['id'], $field['std'] );
252
+
253
+ switch ( $field['type'] ) {
254
+ case 'text':
255
+ case 'email':
256
+ case 'url':
257
+ case 'number':
258
+ case 'hidden':
259
+ case 'submit':
260
+ printf(
261
+ '<input type="%1$s" id="anr_admin_options[%2$s]" class="%3$s" name="anr_admin_options[%4$s]" placeholder="%5$s" value="%6$s"%7$s />',
262
+ esc_attr( $field['type'] ),
263
+ esc_attr( $field['id'] ),
264
+ esc_attr( $field['class'] ),
265
+ esc_attr( $field['id'] ),
266
+ isset( $field['placeholder'] ) ? esc_attr( $field['placeholder'] ) : '',
267
+ esc_attr( $value ),
268
+ $attrib
269
+ );
270
+ break;
271
+ case 'checkbox':
272
+ printf( '<input type="hidden" name="anr_admin_options[%s]" value="" />', esc_attr( $field['id'] ) );
273
+ printf(
274
+ '<label><input type="%1$s" id="anr_admin_options[%2$s]" class="%3$s" name="anr_admin_options[%4$s]" value="%5$s"%6$s /> %7$s</label>',
275
+ 'checkbox',
276
+ esc_attr( $field['id'] ),
277
+ esc_attr( $field['class'] ),
278
+ esc_attr( $field['id'] ),
279
+ '1',
280
+ checked( $value, '1', false ),
281
+ esc_attr( $field['cb_label'] )
282
+ );
283
+ break;
284
+ case 'multicheck':
285
+ printf( '<input type="hidden" name="anr_admin_options[%s][]" value="" />', esc_attr( $field['id'] ) );
286
+ foreach ( $field['options'] as $key => $label ) {
287
+ printf(
288
+ '<label><input type="%1$s" id="anr_admin_options[%2$s][%5$s]" class="%3$s" name="anr_admin_options[%4$s][]" value="%5$s"%6$s /> %7$s</label><br>',
289
+ 'checkbox',
290
+ esc_attr( $field['id'] ),
291
+ esc_attr( $field['class'] ),
292
+ esc_attr( $field['id'] ),
293
+ esc_attr( $key ),
294
+ checked( in_array( $key, (array) $value ), true, false ),
295
+ esc_attr( $label )
296
+ );
297
+ }
298
+ break;
299
+ case 'select':
300
+ printf(
301
+ '<select id="anr_admin_options[%1$s]" class="%2$s" name="anr_admin_options[%1$s]">',
302
+ esc_attr( $field['id'] ),
303
+ esc_attr( $field['class'] ),
304
+ esc_attr( $field['id'] )
305
+ );
306
+ foreach ( $field['options'] as $key => $label ) {
307
+ printf(
308
+ '<option value="%1$s"%2$s>%3$s</option>',
309
+ esc_attr( $key ),
310
+ selected( $value, $key, false ),
311
+ esc_attr( $label )
312
+ );
313
+ }
314
+ printf( '</select>' );
315
+ break;
316
+
317
+ default:
318
+ printf( __( 'No hook defined for %s', 'advanced-nocaptcha-recaptcha' ), esc_html( $field['type'] ) );
319
+ break;
320
+ }
321
+ if ( ! empty( $field['desc'] ) ) {
322
+ printf( '<p class="description">%s</p>', $field['desc'] );
323
+ }
324
+ }
325
+
326
+ function options_sanitize( $value ) {
327
+ if ( ! $value || ! is_array( $value ) ) {
328
+ return $value;
329
+ }
330
+ $fields = $this->get_fields();
331
+
332
+ foreach ( $value as $option_slug => $option_value ) {
333
+ if ( isset( $fields[ $option_slug ] ) && ! empty( $fields[ $option_slug ]['sanitize_callback'] ) ) {
334
+ $value[ $option_slug ] = call_user_func( $fields[ $option_slug ]['sanitize_callback'], $option_value );
335
+ }
336
+ }
337
+ return $value;
338
+ }
339
+
340
+ function menu_page() {
341
+ add_options_page( __( 'Advanced noCaptcha & invisible captcha Settings', 'advanced-nocaptcha-recaptcha' ), __( 'Advanced noCaptcha & invisible captcha', 'advanced-nocaptcha-recaptcha' ), 'manage_options', 'anr-admin-settings', array( $this, 'admin_settings' ) );
342
+ add_submenu_page( 'anr-non-exist-menu', 'Advanced noCaptcha reCaptcha - ' . __( 'Instruction', 'advanced-nocaptcha-recaptcha' ), __( 'Instruction', 'advanced-nocaptcha-recaptcha' ), 'manage_options', 'anr-instruction', array( $this, 'instruction_page' ) );
343
+
344
+ }
345
+
346
+ function admin_settings() {
347
+ if ( isset( $_POST['anr_admin_options'] ) && isset( $_POST['action'] ) && 'update' === $_POST['action'] ) {
348
+ check_admin_referer( 'anr_admin_options-options' );
349
+
350
+ $value = wp_unslash( $_POST['anr_admin_options'] );
351
+ if ( ! is_array( $value ) ) {
352
+ $value = [];
353
+ }
354
+ anr_update_option( $value );
355
+
356
+ if ( ! count( get_settings_errors() ) ) {
357
+ add_settings_error( 'anr_admin_options', 'settings_updated', __( 'Settings saved.' ), 'updated' );
358
+ }
359
+ }
360
+ ?>
361
+ <div class="wrap">
362
+ <div id="poststuff">
363
+ <h2><?php _e( 'Advanced noCaptcha & invisible captcha Settings', 'advanced-nocaptcha-recaptcha' ); ?></h2>
364
+ <div id="post-body" class="metabox-holder columns-2">
365
+ <div id="post-body-content">
366
+ <div id="tab_container">
367
+ <?php settings_errors(); ?>
368
+ <form method="post" action="<?php echo esc_attr( wp_unslash( $_SERVER['REQUEST_URI'] ) ); ?>">
369
+ <?php
370
+ settings_fields( 'anr_admin_options' );
371
+ do_settings_sections( 'anr_admin_options' );
372
+ do_action( 'anr_admin_setting_form' );
373
+ submit_button();
374
+ ?>
375
+ </form>
376
+ </div><!-- #tab_container-->
377
+ </div><!-- #post-body-content-->
378
+ <div id="postbox-container-1" class="postbox-container">
379
+ <?php echo $this->anr_admin_sidebar(); ?>
380
+ </div><!-- #postbox-container-1 -->
381
+ </div><!-- #post-body -->
382
+ <br class="clear" />
383
+ </div><!-- #poststuff -->
384
+ </div><!-- .wrap -->
385
+ <?php
386
+ }
387
+
388
+ function anr_admin_sidebar() {
389
+ return '<div class="postbox">
390
+ <h3 class="hndle" style="text-align: center;">
391
+ <span>' . __( 'Plugin Author', 'advanced-nocaptcha-recaptcha' ) . '</span>
392
+ </h3>
393
+
394
+ <div class="inside">
395
+ <div style="text-align: center; margin: auto">
396
+ <strong>Shamim Hasan</strong><br />
397
+ Know php, MySql, css, javascript, html. Expert in WordPress. <br /><br />
398
+
399
+ You can hire for plugin customization, build custom plugin or any kind of WordPress job via <br> <a
400
+ href="https://www.shamimsplugins.com/contact-us/"><strong>Contact Form</strong></a>
401
+ </div>
402
+ </div>
403
+ </div>';
404
+ }
405
+
406
+ function instruction_page() {
407
+ ?>
408
+ <div class="wrap">
409
+ <div id="poststuff">
410
+ <div id="post-body" class="metabox-holder columns-2">
411
+ <h2><?php _e( 'Advanced noCaptcha reCaptcha Setup Instruction', 'advanced-nocaptcha-recaptcha' ); ?></h2>
412
+ <!-- main content -->
413
+ <div id="post-body-content">
414
+ <div class='postbox'>
415
+ <div class='inside'>
416
+ <div><?php printf( __( 'Get your site key and secret key from <a href="%s" target="_blank">GOOGLE</a> if you do not have already.', 'advanced-nocaptcha-recaptcha' ), esc_url( 'https://www.google.com/recaptcha/admin' ) ); ?></div>
417
+ <div><?php printf( __( 'Goto %s page of this plugin and set up as you need. and ENJOY...', 'advanced-nocaptcha-recaptcha' ), '<a href="' . esc_url( admin_url( 'options-general.php?page=anr-admin-settings' ) ) . '">' . esc_html__( 'Settings', 'advanced-nocaptcha-recaptcha' ) . '</a>' ); ?></div>
418
+
419
+ <h3><?php _e( 'Implement noCaptcha in Contact Form 7', 'advanced-nocaptcha-recaptcha' ); ?></h3>
420
+ <div><?php printf( __( 'To show noCaptcha use %s', 'advanced-nocaptcha-recaptcha' ), '<code>[anr_nocaptcha g-recaptcha-response]</code>' ); ?></div>
421
+
422
+ <h3><?php _e( 'Implement noCaptcha in WooCommerce', 'advanced-nocaptcha-recaptcha' ); ?></h3>
423
+ <div><?php _e( 'If Login Form, Registration Form, Lost Password Form, Reset Password Form is selected in SETTINGS page of this plugin they will show and verify Captcha in WooCommerce respective forms also.', 'advanced-nocaptcha-recaptcha' ); ?></div>
424
+
425
+ <h3><?php _e( 'If you want to implement noCaptcha in any other custom form', 'advanced-nocaptcha-recaptcha' ); ?></h3>
426
+ <div><?php printf( __( 'To show noCaptcha in a form use %1$s OR %2$s', 'advanced-nocaptcha-recaptcha' ), "<code>do_action( 'anr_captcha_form_field' )</code>", '<code>[anr-captcha]</code>' ); ?></div>
427
+ <div><?php printf( __( 'To verify use %s. It will return true on success otherwise false.', 'advanced-nocaptcha-recaptcha' ), '<code>anr_verify_captcha()</code>' ); ?></div>
428
+ <div><?php printf( __( 'For paid support pleasse visit <a href="%s" target="_blank">Advanced noCaptcha reCaptcha</a>', 'advanced-nocaptcha-recaptcha' ), esc_url( 'https://www.shamimsplugins.com/contact-us/' ) ); ?></div>
429
+ </div>
430
+ </div>
431
+ <div><a class="button" href="<?php echo esc_url( admin_url( 'options-general.php?page=anr-admin-settings' ) ); ?>"><?php esc_html_e( 'Back to Settings', 'advanced-nocaptcha-recaptcha' ); ?></a></div>
432
+ </div>
433
+ <div id="postbox-container-1" class="postbox-container">
434
+ <?php echo $this->anr_admin_sidebar(); ?>
435
+ </div>
436
+ </div>
437
+ <br class="clear" />
438
+ </div>
439
+ </div>
440
+ <?php
441
+ }
442
+
443
+
444
+ function add_settings_link( $links, $file ) {
445
+ // add settings link in plugins page
446
+ $plugin_file = 'advanced-nocaptcha-recaptcha/advanced-nocaptcha-recaptcha.php';
447
+ if ( $file == $plugin_file ) {
448
+ $settings_link = '<a href="' . admin_url( 'options-general.php?page=anr-admin-settings' ) . '">' . __( 'Settings', 'advanced-nocaptcha-recaptcha' ) . '</a>';
449
+ array_unshift( $links, $settings_link );
450
+ }
451
+ return $links;
452
+ }
453
+
454
+
455
+ } //END CLASS
456
+
457
+ add_action( 'wp_loaded', array( ANR_Settings::init(), 'actions_filters' ) );
advanced-nocaptcha-recaptcha.php CHANGED
@@ -3,13 +3,14 @@
3
  Plugin Name: Advanced noCaptcha & invisible Captcha
4
  Plugin URI: https://www.shamimsplugins.com/contact-us/
5
  Description: Show noCaptcha or invisible captcha in Comment Form (after Comment textarea before submit button), bbPress, Login, Register, Lost Password, Reset Password. Also can implement in any other form easily.
6
- Version: 3.1
7
  Author: Shamim Hasan
8
  Author URI: https://www.shamimsplugins.com/contact-us/
9
  Text Domain: advanced-nocaptcha-recaptcha
10
  License: GPLv2 or later
11
  */
12
  // DEFINE
 
13
  define( 'ANR_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
14
  define( 'ANR_PLUGIN_URL', plugins_url( '/', __FILE__ ) );
15
 
3
  Plugin Name: Advanced noCaptcha & invisible Captcha
4
  Plugin URI: https://www.shamimsplugins.com/contact-us/
5
  Description: Show noCaptcha or invisible captcha in Comment Form (after Comment textarea before submit button), bbPress, Login, Register, Lost Password, Reset Password. Also can implement in any other form easily.
6
+ Version: 4.1
7
  Author: Shamim Hasan
8
  Author URI: https://www.shamimsplugins.com/contact-us/
9
  Text Domain: advanced-nocaptcha-recaptcha
10
  License: GPLv2 or later
11
  */
12
  // DEFINE
13
+ define( 'ANR_PLUGIN_VERSION', '4.1' );
14
  define( 'ANR_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
15
  define( 'ANR_PLUGIN_URL', plugins_url( '/', __FILE__ ) );
16
 
anr-captcha-class.php CHANGED
@@ -1,117 +1,123 @@
1
  <?php
2
 
3
- if (!class_exists('anr_captcha_class'))
4
- {
5
- class anr_captcha_class
6
- {
7
- private static $instance;
8
-
9
- private static $captcha_count = 0;
10
-
11
- public static function init()
12
- {
13
- if(!self::$instance instanceof self) {
14
- self::$instance = new self;
15
  }
16
  return self::$instance;
17
  }
18
-
19
- function actions_filters()
20
- {
21
- if ( '1' == anr_get_option( 'fep_contact_form' )) {
22
- add_action ('fepcf_message_form_after_content', array($this, 'form_field'), 99);
23
- add_action ('fepcf_action_message_before_send', array($this, 'fepcf_verify'));
24
- }
25
-
26
- if ( '1' == anr_get_option( 'login' ) && !defined('XMLRPC_REQUEST')) {
27
- add_action ('login_form', array($this, 'login_form_field'), 99);
28
- add_filter( 'login_form_middle', array( $this, 'login_form_return' ), 99 );
29
- add_action ('woocommerce_login_form', array($this, 'login_form_field'), 99);
30
- add_filter ('authenticate', array($this, 'login_verify'), 999, 3 );
31
-
32
- add_action ('wp_login', array($this, 'clear_data'), 10, 2);
33
- }
34
-
35
- if ( '1' == anr_get_option( 'wc_checkout' )) {
36
- add_action( 'woocommerce_after_checkout_validation', array($this, 'wc_checkout_verify') );
37
- add_action ('woocommerce_checkout_after_order_review', array($this, 'wc_form_field') );
38
- }
39
-
40
- if ( '1' == anr_get_option( 'registration' )) {
41
- add_action ('register_form', array($this, 'form_field'), 99);
42
- add_action ('woocommerce_register_form', array($this, 'form_field'), 99);
43
- add_filter ('registration_errors', array($this, 'registration_verify'), 10, 3 );
44
- add_filter ('woocommerce_registration_errors', array($this, 'wc_registration_verify'), 10, 3 );
45
- //add_action ('woocommerce_checkout_after_order_review', array($this, 'wc_form_field') );
46
- }
47
-
48
- if ( '1' == anr_get_option( 'ms_user_signup' )) {
49
- add_action ('signup_extra_fields', array($this, 'ms_form_field'), 99);
50
- add_filter ('wpmu_validate_user_signup', array($this, 'ms_form_field_verify'));
51
- }
52
 
53
- if ( '1' == anr_get_option( 'lost_password' )) {
54
- add_action ('lostpassword_form', array($this, 'form_field'), 99);
55
- add_action ('woocommerce_lostpassword_form', array($this, 'form_field'), 99);
56
- //add_action ('allow_password_reset', array($this, 'lostpassword_verify'), 10, 2); //lostpassword_post does not return wp_error( prior WP 4.4 )
57
- add_action('lostpassword_post', array($this, 'lostpassword_verify_44'));
58
- }
59
-
60
- if ( '1' == anr_get_option( 'reset_password' )) {
61
- add_action ('resetpass_form', array($this, 'form_field'), 99);
62
- add_action ('woocommerce_resetpassword_form', array($this, 'form_field'), 99);
63
- add_filter ('validate_password_reset', array($this, 'reset_password_verify'), 10, 2 );
64
- }
65
-
66
- if ( '1' == anr_get_option( 'comment' )) {
67
- if( ! is_user_logged_in() ) {
68
- add_action ('comment_form_after_fields', array($this, 'form_field'), 99);
69
- } else {
70
- add_filter ('comment_form_field_comment', array($this, 'comment_form_field'), 99 );
71
- }
72
- add_filter ('preprocess_comment', array($this, 'comment_verify') );
 
 
 
 
 
 
 
 
73
  }
 
 
74
 
75
  if ( function_exists( 'wpcf7_add_form_tag' ) ) {
76
- wpcf7_add_form_tag('anr_nocaptcha', array($this, 'wpcf7_form_field'), array( 'name-attr' => true ) );
77
- add_filter('wpcf7_validate_anr_nocaptcha', array($this, 'wpcf7_verify'), 10, 2);
78
- } elseif( function_exists( 'wpcf7_add_shortcode' ) ){
79
- wpcf7_add_shortcode('anr_nocaptcha', array($this, 'wpcf7_form_field'), true);
80
- add_filter('wpcf7_validate_anr_nocaptcha', array($this, 'wpcf7_verify'), 10, 2);
 
 
 
 
 
 
 
 
 
 
81
  }
82
-
83
- if ( '1' == anr_get_option( 'bb_new' )) {
84
- add_action ('bbp_theme_before_topic_form_submit_wrapper', array($this, 'form_field'), 99);
85
- add_action ('bbp_new_topic_pre_extras', array($this, 'bb_new_verify') );
86
- }
87
-
88
- if ( '1' == anr_get_option( 'bb_reply' )) {
89
- add_action ('bbp_theme_before_reply_form_submit_wrapper', array($this, 'form_field'), 99);
90
- add_action ('bbp_new_reply_pre_extras', array($this, 'bb_reply_verify'), 10, 2 );
91
- }
92
  }
93
-
94
- function total_captcha()
95
- {
96
- return self::$captcha_count;
97
- }
98
-
99
- function captcha_form_field()
100
- {
101
- self::$captcha_count++;
102
- $no_js = anr_get_option( 'no_js' );
103
- $site_key = trim(anr_get_option( 'site_key' ));
104
- $number = $this->total_captcha();
105
-
106
- $field = '<div class="anr_captcha_field"><div id="anr_captcha_field_' . $number . '"></div></div>';
107
-
108
- if ( 1 == $no_js )
109
- {
110
- $field .='<noscript>
 
 
 
 
111
  <div>
112
  <div style="width: 302px; height: 422px; position: relative;">
113
  <div style="width: 302px; height: 422px; position: absolute;">
114
- <iframe src="https://www.google.com/recaptcha/api/fallback?k='. $site_key .'"
115
  frameborder="0" scrolling="no"
116
  style="width: 302px; height:422px; border-style: none;">
117
  </iframe>
@@ -120,58 +126,62 @@ if (!class_exists('anr_captcha_class'))
120
  <div style="width: 300px; height: 60px; border-style: none;
121
  bottom: 12px; left: 25px; margin: 0px; padding: 0px; right: 25px;
122
  background: #f9f9f9; border: 1px solid #c1c1c1; border-radius: 3px;">
123
- <textarea id="g-recaptcha-response-'.$number.'" name="g-recaptcha-response"
124
  class="g-recaptcha-response"
125
  style="width: 250px; height: 40px; border: 1px solid #c1c1c1;
126
  margin: 10px 25px; padding: 0px; resize: none;" ></textarea>
127
  </div>
128
  </div>
129
  </noscript>';
130
- }
131
-
132
  return $field;
133
- }
134
-
135
- function footer_script()
136
- {
137
- $number = $this->total_captcha();
138
- static $included = false;
139
-
140
- if ( !$number )
141
- return;
142
-
143
- if ( $included )
144
- return;
145
-
146
- $included = true;
147
-
148
- $site_key = trim(anr_get_option( 'site_key' ));
149
- $theme = anr_get_option( 'theme', 'light' );
150
- $size = anr_get_option( 'size', 'normal' );
151
- $language = trim(anr_get_option( 'language' ));
152
-
153
- $lang = "";
154
- if ( $language )
155
- $lang = "&hl=$language";
156
-
157
- ?>
158
- <script type="text/javascript">
159
- var anr_onloadCallback = function() {
160
- var anr_obj = {
161
- 'sitekey' : '<?php echo esc_js( $site_key ); ?>',
162
- 'size' : '<?php echo esc_js( $size ); ?>',
163
- };
164
- <?php if( 'invisible' == $size ){
165
- wp_enqueue_script( 'jquery' ); ?>
166
- anr_obj.badge = '<?php echo esc_js( anr_get_option( 'badge', 'bottomright' ) ); ?>';
167
- <?php } else { ?>
 
 
 
 
168
  anr_obj.theme = '<?php echo esc_js( $theme ); ?>';
169
  <?php } ?>
170
 
171
- <?php for ( $num = 1; $num <= $number; $num++ ) { ?>
172
  var anr_captcha_<?php echo $num; ?>;
173
 
174
- <?php if( 'invisible' == $size ){ ?>
175
  var anr_form<?php echo $num; ?> = jQuery('#anr_captcha_field_<?php echo $num; ?>').closest('form')[0];
176
  anr_obj.callback = function(){ anr_form<?php echo $num; ?>.submit(); };
177
  anr_obj["expired-callback"] = function(){ grecaptcha.reset(anr_captcha_<?php echo $num; ?>); };
@@ -181,314 +191,302 @@ if (!class_exists('anr_captcha_class'))
181
  //grecaptcha.reset(anr_captcha_<?php echo $num; ?>);
182
  grecaptcha.execute(anr_captcha_<?php echo $num; ?>);
183
  };
184
- <?php } ?>
185
 
186
  anr_captcha_<?php echo $num; ?> = grecaptcha.render('anr_captcha_field_<?php echo $num; ?>', anr_obj );
187
  <?php } ?>
188
- };
189
- </script>
190
- <script src="https://www.google.com/recaptcha/api.js?onload=anr_onloadCallback&render=explicit<?php echo esc_js( $lang ); ?>"
191
- async defer>
192
- </script>
193
 
194
- <?php
195
 
196
- }
197
-
198
-
199
- function form_field()
200
- {
201
- $loggedin_hide = anr_get_option( 'loggedin_hide' );
202
-
203
- if ( is_user_logged_in() && $loggedin_hide )
204
  return;
205
-
 
206
  anr_captcha_form_field( true );
207
-
208
- }
209
-
210
- function post_id(){
211
- global $wpdb;
212
- static $post_id;
213
-
214
- if( ! absint( anr_get_option( 'failed_login_allow' ) ) ){
215
- return 0;
216
  }
217
- if( is_numeric( $post_id ) ){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
218
  return $post_id;
219
  }
220
- $post_id = $wpdb->get_var( "SELECT ID FROM $wpdb->posts WHERE post_type = 'anr-post' LIMIT 1");
221
-
222
- if( ! $post_id ){
223
- $wpdb->insert( $wpdb->posts, array( 'post_type' => 'anr-post' ) );
224
- $post_id = $wpdb->insert_id;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
225
  }
226
- $post_id = absint( $post_id );
227
-
228
- return $post_id;
229
- }
230
-
231
- function show_login_captcha(){
232
- global $wpdb;
233
-
234
- $show_captcha = true;
235
- $ip = $_SERVER['REMOTE_ADDR'];
236
- //filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE );
237
- $count = absint( anr_get_option( 'failed_login_allow' ) );
238
- $post_id = $this->post_id();
239
-
240
- if( $count && $post_id && filter_var( $ip, FILTER_VALIDATE_IP ) ){
241
- $user_logins = $wpdb->get_col( $wpdb->prepare( "SELECT meta_value FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = %s", $post_id, md5( $ip ) ) );
242
-
243
- if( count( $user_logins ) < $count && count( array_unique( $user_logins ) ) <= 1 ){
244
- $show_captcha = false;
245
  }
246
  }
247
 
248
- return $show_captcha;
249
- }
250
- function login_form_field()
251
- {
252
- if( $this->show_login_captcha() ){
253
- $this->form_field();
254
- }
255
- }
256
-
257
- function login_form_return( $field = '' ) {
258
- if ( $this->show_login_captcha() ) {
259
 
260
- if ( is_user_logged_in() && anr_get_option( 'loggedin_hide' ) ) {
261
- return $field;
262
- }
263
 
264
- $field = anr_captcha_form_field( false );
 
 
265
  }
266
- return $field;
267
- }
268
-
269
- function wc_form_field()
270
- {
271
-
272
- if( ! is_user_logged_in() && 'yes' == get_option( 'woocommerce_enable_signup_and_login_from_checkout', 'yes' ) && '1' == anr_get_option( 'registration' ) ){
273
  $this->form_field();
274
-
275
- } elseif( '1' == anr_get_option( 'wc_checkout' ) ){
276
  $this->form_field();
277
  }
278
-
279
  }
280
-
281
- function ms_form_field( $errors )
282
 
283
- {
284
- $loggedin_hide = anr_get_option( 'loggedin_hide' );
285
 
286
- if ( is_user_logged_in() && $loggedin_hide )
287
  return;
 
288
 
289
- if ( $errmsg = $errors->get_error_message('anr_error') ) {
290
- echo '<p class="error">' . $errmsg . '</p>';
291
- }
292
 
293
  anr_captcha_form_field( true );
294
 
295
  }
296
-
297
- function comment_form_field( $defaults )
298
- {
299
- $loggedin_hide = anr_get_option( 'loggedin_hide' );
300
-
301
- if ( is_user_logged_in() && $loggedin_hide )
302
  return $defaults;
303
-
 
304
  $defaults = $defaults . anr_captcha_form_field( false );
305
  return $defaults;
306
-
307
-
308
  }
309
-
310
- function verify()
311
- {
312
-
313
- $loggedin_hide = anr_get_option( 'loggedin_hide' );
314
-
315
- if ( is_user_logged_in() && $loggedin_hide )
316
  return true;
317
-
 
318
  return anr_verify_captcha();
319
-
320
  }
321
-
322
- function fepcf_verify ( $errors )
323
- {
324
- $error_message = str_replace(__('<strong>ERROR</strong>: ', 'advanced-nocaptcha-recaptcha'), '', anr_get_option( 'error_message' ));
325
-
326
- if ( ! $this->verify() ){
327
- $errors->add('anr_error', $error_message);
328
  }
329
  }
330
-
331
- function login_verify ( $user, $username = '', $password = '' )
332
- {
333
  global $wpdb;
334
-
 
 
 
335
  $show_captcha = $this->show_login_captcha();
336
-
337
- if ( ! ( $user instanceof WP_User ) ){
338
- if( ! $show_captcha && $username && ( $post_id = $this->post_id() ) ){
339
- if( is_email( $username ) ){
340
  $user_data = get_user_by( 'email', $username );
341
- if( $user_data ){
342
  $username = $user_data->user_login;
343
  }
344
  }
345
- $wpdb->insert( $wpdb->postmeta, array( 'post_id' => $post_id, 'meta_key' => md5( $_SERVER['REMOTE_ADDR'] ), 'meta_value' => $username ), array( '%d', '%s', '%s' ) );
 
 
 
 
 
 
346
  }
347
- return $user;
348
  }
349
  if ( $show_captcha && ! $this->verify() ) {
350
- $error_message = anr_get_option( 'error_message' );
351
- return new WP_Error( 'anr_error', $error_message );
352
  }
353
-
354
  return $user;
355
  }
356
-
357
- function clear_data( $user_login, $user ){
358
- global $wpdb;
359
-
360
- if( $post_id = $this->post_id() ){
361
- $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE post_id = %d AND ( meta_key = %s OR meta_value = %s )", $post_id, md5( $_SERVER['REMOTE_ADDR'] ), $user_login ) );
 
362
  }
363
- }
364
-
365
- function registration_verify ( $errors, $sanitized_user_login, $user_email )
366
- {
367
  if ( ! $this->verify() ) {
368
- $error_message = anr_get_option( 'error_message' );
369
- $errors->add( 'anr_error', $error_message );
370
  }
371
-
372
  return $errors;
373
  }
374
-
375
- function wc_registration_verify ( $errors, $sanitized_user_login, $user_email ){
376
- if ( defined( 'WOOCOMMERCE_CHECKOUT' ) && ! anr_get_option( 'wc_checkout' ) ) {
377
- return $errors;
378
- }
379
- if ( ! $this->verify() ) {
380
- $error_message = anr_get_option( 'error_message' );
381
- $errors->add( 'anr_error', $error_message );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
382
  }
383
 
384
- return $errors;
385
- }
386
-
387
- function ms_form_field_verify( $result )
 
388
 
389
- {
390
  if ( ! $this->verify() ) {
391
- $error_message = str_replace(__('<strong>ERROR</strong>: ', 'advanced-nocaptcha-recaptcha'), '', anr_get_option( 'error_message' ));
392
- $result['errors']->add( 'anr_error', $error_message );
393
  }
394
 
395
  return $result;
396
  }
397
-
398
- function lostpassword_verify( $result, $user_id )
399
- {
400
  if ( ! $this->verify() ) {
401
- $error_message = anr_get_option( 'error_message' );
402
- return new WP_Error( 'anr_error', $error_message );
403
  }
404
-
405
  return $result;
406
  }
407
-
408
- function lostpassword_verify_44( $errors )
409
- {
410
  if ( ! $this->verify() ) {
411
- $error_message = anr_get_option( 'error_message' );
412
- $errors->add('anr_error', $error_message);
413
  }
414
  }
415
-
416
-
417
- function reset_password_verify( $errors, $user )
418
- {
419
-
420
  if ( ! $this->verify() ) {
421
- $error_message = anr_get_option( 'error_message' );
422
- $errors->add('anr_error', $error_message);
423
  }
424
  }
425
-
426
- function comment_verify( $commentdata )
427
- {
428
-
429
  if ( ! $this->verify() ) {
430
- $error_message = anr_get_option( 'error_message' );
431
- wp_die( $error_message, 200 );
432
  }
433
-
434
  return $commentdata;
435
  }
436
-
437
- function wpcf7_form_field( $tag )
438
- {
439
- $loggedin_hide = anr_get_option( 'loggedin_hide' );
440
-
441
- if ( is_user_logged_in() && $loggedin_hide )
442
  return '';
443
-
444
- return anr_captcha_form_field( false ). sprintf( '<span class="wpcf7-form-control-wrap %s"></span>', $tag->name );
 
445
  }
446
-
447
- function wpcf7_verify( $result, $tag )
448
- {
449
  if ( ! $this->verify() ) {
450
- $error_message = str_replace(__('<strong>ERROR</strong>: ', 'advanced-nocaptcha-recaptcha'), '', anr_get_option( 'error_message' ));
451
- $result->invalidate( $tag, $error_message );
452
  }
453
 
454
- return $result;
455
- }
456
-
457
- function bb_new_verify( $forum_id )
458
- {
459
-
460
  if ( ! $this->verify() ) {
461
- $error_message = anr_get_option( 'error_message' );
462
- bbp_add_error('anr_error', $error_message);
463
  }
464
  }
465
-
466
- function bb_reply_verify( $topic_id, $forum_id )
467
- {
468
-
469
  if ( ! $this->verify() ) {
470
- $error_message = anr_get_option( 'error_message' );
471
- bbp_add_error('anr_error', $error_message);
472
  }
473
  }
474
-
475
- function wc_checkout_verify()
476
- {
477
- $is_reg_enable = apply_filters( 'woocommerce_checkout_registration_enabled', 'yes' === get_option( 'woocommerce_enable_signup_and_login_from_checkout' ) );
478
-
479
- if( ! is_user_logged_in() && $is_reg_enable && '1' == anr_get_option( 'registration' ) ){
480
- // verification done during ragistration, So no need any more verification
481
-
482
- } elseif( ! $this->verify() ){
483
 
484
- $error_message = anr_get_option( 'error_message' );
485
- wc_add_notice( $error_message, 'error' );
 
 
 
 
 
486
  }
487
  }
488
 
489
-
490
- } //END CLASS
491
  } //ENDIF
492
 
493
- add_action('init', array(anr_captcha_class::init(), 'actions_filters'), -99 );
494
 
1
  <?php
2
 
3
+ if ( ! class_exists( 'anr_captcha_class' ) ) {
4
+ class anr_captcha_class {
5
+
6
+ private static $instance;
7
+
8
+ private static $captcha_count = 0;
9
+
10
+ public static function init() {
11
+ if ( ! self::$instance instanceof self ) {
12
+ self::$instance = new self();
 
 
13
  }
14
  return self::$instance;
15
  }
16
+
17
+ function actions_filters() {
18
+ if ( anr_is_form_enabled( 'fep_contact_form' ) ) {
19
+ add_action( 'fepcf_message_form_after_content', array( $this, 'form_field' ), 99 );
20
+ add_action( 'fepcf_action_message_before_send', array( $this, 'fepcf_verify' ) );
21
+ }
22
+
23
+ if ( anr_is_form_enabled( 'login' ) && ! defined( 'XMLRPC_REQUEST' ) ) {
24
+ add_action( 'login_form', array( $this, 'login_form_field' ), 99 );
25
+ add_filter( 'login_form_middle', array( $this, 'login_form_return' ), 99 );
26
+ add_action( 'woocommerce_login_form', array( $this, 'login_form_field' ), 99 );
27
+ add_filter( 'authenticate', array( $this, 'login_verify' ), 999, 3 );
28
+
29
+ add_action( 'wp_login', array( $this, 'clear_data' ), 10, 2 );
30
+ }
31
+
32
+ if ( anr_is_form_enabled( 'wc_checkout' ) ) {
33
+ add_action( 'woocommerce_after_checkout_validation', array( $this, 'wc_checkout_verify' ) );
34
+ add_action( 'woocommerce_checkout_after_order_review', array( $this, 'wc_form_field' ) );
35
+ }
36
+
37
+ if ( anr_is_form_enabled( 'registration' ) ) {
38
+ add_action( 'register_form', array( $this, 'form_field' ), 99 );
39
+ add_action( 'woocommerce_register_form', array( $this, 'form_field' ), 99 );
40
+ add_filter( 'registration_errors', array( $this, 'registration_verify' ), 10, 3 );
41
+ add_filter( 'woocommerce_registration_errors', array( $this, 'wc_registration_verify' ), 10, 3 );
42
+ // add_action ('woocommerce_checkout_after_order_review', array($this, 'wc_form_field') );
43
+ }
 
 
 
 
 
 
44
 
45
+ if ( anr_is_form_enabled( 'bp_register' ) ) {
46
+ add_action( 'bp_before_registration_submit_buttons', array( $this, 'bp_form_field' ), 99 );
47
+ add_action( 'bp_signup_validate', array( $this, 'bp_registration_verify' ) );
48
+ }
49
+
50
+ if ( anr_is_form_enabled( 'ms_user_signup' ) && is_multisite() ) {
51
+ add_action( 'signup_extra_fields', array( $this, 'ms_form_field' ), 99 );
52
+ add_filter( 'wpmu_validate_user_signup', array( $this, 'ms_form_field_verify' ) );
53
+ }
54
+
55
+ if ( anr_is_form_enabled( 'lost_password' ) ) {
56
+ add_action( 'lostpassword_form', array( $this, 'form_field' ), 99 );
57
+ add_action( 'woocommerce_lostpassword_form', array( $this, 'form_field' ), 99 );
58
+ // add_action ('allow_password_reset', array($this, 'lostpassword_verify'), 10, 2); //lostpassword_post does not return wp_error( prior WP 4.4 )
59
+ add_action( 'lostpassword_post', array( $this, 'lostpassword_verify_44' ) );
60
+ }
61
+
62
+ if ( anr_is_form_enabled( 'reset_password' ) ) {
63
+ add_action( 'resetpass_form', array( $this, 'form_field' ), 99 );
64
+ add_action( 'woocommerce_resetpassword_form', array( $this, 'form_field' ), 99 );
65
+ add_filter( 'validate_password_reset', array( $this, 'reset_password_verify' ), 10, 2 );
66
+ }
67
+
68
+ if ( anr_is_form_enabled( 'comment' ) ) {
69
+ if ( ! is_user_logged_in() ) {
70
+ add_action( 'comment_form_after_fields', array( $this, 'form_field' ), 99 );
71
+ } else {
72
+ add_filter( 'comment_form_field_comment', array( $this, 'comment_form_field' ), 99 );
73
  }
74
+ add_filter( 'preprocess_comment', array( $this, 'comment_verify' ) );
75
+ }
76
 
77
  if ( function_exists( 'wpcf7_add_form_tag' ) ) {
78
+ wpcf7_add_form_tag( 'anr_nocaptcha', array( $this, 'wpcf7_form_field' ), array( 'name-attr' => true ) );
79
+ add_filter( 'wpcf7_validate_anr_nocaptcha', array( $this, 'wpcf7_verify' ), 10, 2 );
80
+ } elseif ( function_exists( 'wpcf7_add_shortcode' ) ) {
81
+ wpcf7_add_shortcode( 'anr_nocaptcha', array( $this, 'wpcf7_form_field' ), true );
82
+ add_filter( 'wpcf7_validate_anr_nocaptcha', array( $this, 'wpcf7_verify' ), 10, 2 );
83
+ }
84
+
85
+ if ( anr_is_form_enabled( 'bbp_new' ) ) {
86
+ add_action( 'bbp_theme_before_topic_form_submit_wrapper', array( $this, 'form_field' ), 99 );
87
+ add_action( 'bbp_new_topic_pre_extras', array( $this, 'bbp_new_verify' ) );
88
+ }
89
+
90
+ if ( anr_is_form_enabled( 'bbp_reply' ) ) {
91
+ add_action( 'bbp_theme_before_reply_form_submit_wrapper', array( $this, 'form_field' ), 99 );
92
+ add_action( 'bbp_new_reply_pre_extras', array( $this, 'bbp_reply_verify' ), 10, 2 );
93
  }
 
 
 
 
 
 
 
 
 
 
94
  }
95
+
96
+ function add_error_to_mgs( $mgs = false ) {
97
+ if ( false === $mgs ) {
98
+ $mgs = anr_get_option( 'error_message', '' );
99
+ }
100
+ return '<strong>' . __( 'ERROR', 'advanced-nocaptcha-recaptcha' ) . '</strong>: ' . $mgs;
101
+ }
102
+
103
+ function total_captcha() {
104
+ return self::$captcha_count;
105
+ }
106
+
107
+ function captcha_form_field() {
108
+ self::$captcha_count++;
109
+ $no_js = anr_get_option( 'no_js' );
110
+ $site_key = trim( anr_get_option( 'site_key' ) );
111
+ $number = $this->total_captcha();
112
+
113
+ $field = '<div class="anr_captcha_field"><div id="anr_captcha_field_' . $number . '"></div></div>';
114
+
115
+ if ( 1 == $no_js ) {
116
+ $field .= '<noscript>
117
  <div>
118
  <div style="width: 302px; height: 422px; position: relative;">
119
  <div style="width: 302px; height: 422px; position: absolute;">
120
+ <iframe src="https://www.google.com/recaptcha/api/fallback?k=' . $site_key . '"
121
  frameborder="0" scrolling="no"
122
  style="width: 302px; height:422px; border-style: none;">
123
  </iframe>
126
  <div style="width: 300px; height: 60px; border-style: none;
127
  bottom: 12px; left: 25px; margin: 0px; padding: 0px; right: 25px;
128
  background: #f9f9f9; border: 1px solid #c1c1c1; border-radius: 3px;">
129
+ <textarea id="g-recaptcha-response-' . $number . '" name="g-recaptcha-response"
130
  class="g-recaptcha-response"
131
  style="width: 250px; height: 40px; border: 1px solid #c1c1c1;
132
  margin: 10px 25px; padding: 0px; resize: none;" ></textarea>
133
  </div>
134
  </div>
135
  </noscript>';
136
+ }
137
+
138
  return $field;
139
+ }
140
+
141
+ function footer_script() {
142
+ $number = $this->total_captcha();
143
+ static $included = false;
144
+
145
+ if ( ! $number ) {
146
+ return;
147
+ }
148
+
149
+ if ( $included ) {
150
+ return;
151
+ }
152
+
153
+ $included = true;
154
+
155
+ $site_key = trim( anr_get_option( 'site_key' ) );
156
+ $theme = anr_get_option( 'theme', 'light' );
157
+ $size = anr_get_option( 'size', 'normal' );
158
+ $language = trim( anr_get_option( 'language' ) );
159
+
160
+ $lang = '';
161
+ if ( $language ) {
162
+ $lang = "&hl=$language";
163
+ }
164
+
165
+ ?>
166
+ <script type="text/javascript">
167
+ var anr_onloadCallback = function() {
168
+ var anr_obj = {
169
+ 'sitekey' : '<?php echo esc_js( $site_key ); ?>',
170
+ 'size' : '<?php echo esc_js( $size ); ?>',
171
+ };
172
+ <?php
173
+ if ( 'invisible' == $size ) {
174
+ wp_enqueue_script( 'jquery' );
175
+ ?>
176
+ anr_obj.badge = '<?php echo esc_js( anr_get_option( 'badge', 'bottomright' ) ); ?>';
177
+ <?php } else { ?>
178
  anr_obj.theme = '<?php echo esc_js( $theme ); ?>';
179
  <?php } ?>
180
 
181
+ <?php for ( $num = 1; $num <= $number; $num++ ) { ?>
182
  var anr_captcha_<?php echo $num; ?>;
183
 
184
+ <?php if ( 'invisible' == $size ) { ?>
185
  var anr_form<?php echo $num; ?> = jQuery('#anr_captcha_field_<?php echo $num; ?>').closest('form')[0];
186
  anr_obj.callback = function(){ anr_form<?php echo $num; ?>.submit(); };
187
  anr_obj["expired-callback"] = function(){ grecaptcha.reset(anr_captcha_<?php echo $num; ?>); };
191
  //grecaptcha.reset(anr_captcha_<?php echo $num; ?>);
192
  grecaptcha.execute(anr_captcha_<?php echo $num; ?>);
193
  };
194
+ <?php } ?>
195
 
196
  anr_captcha_<?php echo $num; ?> = grecaptcha.render('anr_captcha_field_<?php echo $num; ?>', anr_obj );
197
  <?php } ?>
198
+ };
199
+ </script>
200
+ <script src="https://www.google.com/recaptcha/api.js?onload=anr_onloadCallback&render=explicit<?php echo esc_js( $lang ); ?>"
201
+ async defer>
202
+ </script>
203
 
204
+ <?php
205
 
206
+ }
207
+
208
+
209
+ function form_field() {
210
+ $loggedin_hide = anr_get_option( 'loggedin_hide' );
211
+
212
+ if ( is_user_logged_in() && $loggedin_hide ) {
 
213
  return;
214
+ }
215
+
216
  anr_captcha_form_field( true );
217
+
 
 
 
 
 
 
 
 
218
  }
219
+
220
+ function post_id() {
221
+ global $wpdb;
222
+ static $post_id;
223
+
224
+ if ( ! absint( anr_get_option( 'failed_login_allow' ) ) ) {
225
+ return 0;
226
+ }
227
+ if ( is_numeric( $post_id ) ) {
228
+ return $post_id;
229
+ }
230
+ $post_id = $wpdb->get_var( "SELECT ID FROM $wpdb->posts WHERE post_type = 'anr-post' LIMIT 1" );
231
+
232
+ if ( ! $post_id ) {
233
+ $wpdb->insert( $wpdb->posts, array( 'post_type' => 'anr-post' ) );
234
+ $post_id = $wpdb->insert_id;
235
+ }
236
+ $post_id = absint( $post_id );
237
+
238
  return $post_id;
239
  }
240
+
241
+ function show_login_captcha() {
242
+ global $wpdb;
243
+
244
+ $show_captcha = true;
245
+ $ip = $_SERVER['REMOTE_ADDR'];
246
+ // filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE );
247
+ $count = absint( anr_get_option( 'failed_login_allow' ) );
248
+ $post_id = $this->post_id();
249
+
250
+ if ( $count && $post_id && filter_var( $ip, FILTER_VALIDATE_IP ) ) {
251
+ $user_logins = $wpdb->get_col( $wpdb->prepare( "SELECT meta_value FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = %s", $post_id, md5( $ip ) ) );
252
+
253
+ if ( count( $user_logins ) < $count && count( array_unique( $user_logins ) ) <= 1 ) {
254
+ $show_captcha = false;
255
+ }
256
+ }
257
+
258
+ return $show_captcha;
259
  }
260
+ function login_form_field() {
261
+ if ( $this->show_login_captcha() ) {
262
+ $this->form_field();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
263
  }
264
  }
265
 
266
+ function login_form_return( $field = '' ) {
267
+ if ( $this->show_login_captcha() ) {
 
 
 
 
 
 
 
 
 
268
 
269
+ if ( is_user_logged_in() && anr_get_option( 'loggedin_hide' ) ) {
270
+ return $field;
271
+ }
272
 
273
+ $field = $field . anr_captcha_form_field( false );
274
+ }
275
+ return $field;
276
  }
277
+
278
+ function wc_form_field() {
279
+ if ( ! is_user_logged_in() && 'yes' == get_option( 'woocommerce_enable_signup_and_login_from_checkout', 'yes' ) && anr_is_form_enabled( 'registration' ) ) {
 
 
 
 
280
  $this->form_field();
281
+
282
+ } elseif ( anr_is_form_enabled( 'wc_checkout' ) ) {
283
  $this->form_field();
284
  }
285
+
286
  }
 
 
287
 
288
+ function ms_form_field( $errors ) {
289
+ $loggedin_hide = anr_get_option( 'loggedin_hide' );
290
 
291
+ if ( is_user_logged_in() && $loggedin_hide ) {
292
  return;
293
+ }
294
 
295
+ if ( $errmsg = $errors->get_error_message( 'anr_error' ) ) {
296
+ echo '<p class="error">' . $errmsg . '</p>';
297
+ }
298
 
299
  anr_captcha_form_field( true );
300
 
301
  }
302
+
303
+ function comment_form_field( $defaults ) {
304
+ $loggedin_hide = anr_get_option( 'loggedin_hide' );
305
+
306
+ if ( is_user_logged_in() && $loggedin_hide ) {
 
307
  return $defaults;
308
+ }
309
+
310
  $defaults = $defaults . anr_captcha_form_field( false );
311
  return $defaults;
312
+
 
313
  }
314
+
315
+ function verify() {
316
+ $loggedin_hide = anr_get_option( 'loggedin_hide' );
317
+
318
+ if ( is_user_logged_in() && $loggedin_hide ) {
 
 
319
  return true;
320
+ }
321
+
322
  return anr_verify_captcha();
323
+
324
  }
325
+
326
+ function fepcf_verify( $errors ) {
327
+ if ( ! $this->verify() ) {
328
+ $errors->add( 'anr_error', anr_get_option( 'error_message' ) );
 
 
 
329
  }
330
  }
331
+
332
+ function login_verify( $user, $username = '', $password = '' ) {
 
333
  global $wpdb;
334
+ if ( ! $username ) {
335
+ return $user;
336
+ }
337
+
338
  $show_captcha = $this->show_login_captcha();
339
+
340
+ if ( ! ( $user instanceof WP_User ) ) {
341
+ if ( ! $show_captcha && ( $post_id = $this->post_id() ) ) {
342
+ if ( is_email( $username ) ) {
343
  $user_data = get_user_by( 'email', $username );
344
+ if ( $user_data ) {
345
  $username = $user_data->user_login;
346
  }
347
  }
348
+ $wpdb->insert(
349
+ $wpdb->postmeta, array(
350
+ 'post_id' => $post_id,
351
+ 'meta_key' => md5( $_SERVER['REMOTE_ADDR'] ),
352
+ 'meta_value' => $username,
353
+ ), array( '%d', '%s', '%s' )
354
+ );
355
  }
356
+ // return $user;
357
  }
358
  if ( $show_captcha && ! $this->verify() ) {
359
+ return new WP_Error( 'anr_error', $this->add_error_to_mgs() );
 
360
  }
361
+
362
  return $user;
363
  }
364
+
365
+ function clear_data( $user_login, $user ) {
366
+ global $wpdb;
367
+
368
+ if ( $post_id = $this->post_id() ) {
369
+ $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE post_id = %d AND ( meta_key = %s OR meta_value = %s )", $post_id, md5( $_SERVER['REMOTE_ADDR'] ), $user_login ) );
370
+ }
371
  }
372
+
373
+ function registration_verify( $errors, $sanitized_user_login, $user_email ) {
 
 
374
  if ( ! $this->verify() ) {
375
+ $errors->add( 'anr_error', $this->add_error_to_mgs() );
 
376
  }
377
+
378
  return $errors;
379
  }
380
+
381
+ function wc_registration_verify( $errors, $sanitized_user_login, $user_email ) {
382
+ if ( defined( 'WOOCOMMERCE_CHECKOUT' ) && ! anr_is_form_enabled( 'wc_checkout' ) ) {
383
+ return $errors;
384
+ }
385
+ if ( ! $this->verify() ) {
386
+ $errors->add( 'anr_error', anr_get_option( 'error_message' ) );
387
+ }
388
+
389
+ return $errors;
390
+ }
391
+
392
+ function bp_form_field() {
393
+ $loggedin_hide = anr_get_option( 'loggedin_hide' );
394
+
395
+ if ( is_user_logged_in() && $loggedin_hide ) {
396
+ return;
397
+ }
398
+
399
+ do_action( 'bp_anr_error_errors' );
400
+
401
+ anr_captcha_form_field( true );
402
  }
403
 
404
+ function bp_registration_verify() {
405
+ if ( ! $this->verify() ) {
406
+ buddypress()->signup->errors['anr_error'] = anr_get_option( 'error_message' );
407
+ }
408
+ }
409
 
410
+ function ms_form_field_verify( $result ) {
411
  if ( ! $this->verify() ) {
412
+ $result['errors']->add( 'anr_error', anr_get_option( 'error_message' ) );
 
413
  }
414
 
415
  return $result;
416
  }
417
+
418
+ function lostpassword_verify( $result, $user_id ) {
 
419
  if ( ! $this->verify() ) {
420
+ return new WP_Error( 'anr_error', $this->add_error_to_mgs() );
 
421
  }
422
+
423
  return $result;
424
  }
425
+
426
+ function lostpassword_verify_44( $errors ) {
 
427
  if ( ! $this->verify() ) {
428
+ $errors->add( 'anr_error', $this->add_error_to_mgs() );
 
429
  }
430
  }
431
+
432
+
433
+ function reset_password_verify( $errors, $user ) {
 
 
434
  if ( ! $this->verify() ) {
435
+ $errors->add( 'anr_error', $this->add_error_to_mgs() );
 
436
  }
437
  }
438
+
439
+ function comment_verify( $commentdata ) {
 
 
440
  if ( ! $this->verify() ) {
441
+ wp_die( $this->add_error_to_mgs(), 200 );
 
442
  }
443
+
444
  return $commentdata;
445
  }
446
+
447
+ function wpcf7_form_field( $tag ) {
448
+ $loggedin_hide = anr_get_option( 'loggedin_hide' );
449
+
450
+ if ( is_user_logged_in() && $loggedin_hide ) {
 
451
  return '';
452
+ }
453
+
454
+ return anr_captcha_form_field( false ) . sprintf( '<span class="wpcf7-form-control-wrap %s"></span>', $tag->name );
455
  }
456
+
457
+ function wpcf7_verify( $result, $tag ) {
 
458
  if ( ! $this->verify() ) {
459
+ $result->invalidate( $tag, anr_get_option( 'error_message' ) );
 
460
  }
461
 
462
+ return $result;
463
+ }
464
+
465
+ function bbp_new_verify( $forum_id ) {
 
 
466
  if ( ! $this->verify() ) {
467
+ bbp_add_error( 'anr_error', $this->add_error_to_mgs() );
 
468
  }
469
  }
470
+
471
+ function bbp_reply_verify( $topic_id, $forum_id ) {
 
 
472
  if ( ! $this->verify() ) {
473
+ bbp_add_error( 'anr_error', $this->add_error_to_mgs() );
 
474
  }
475
  }
 
 
 
 
 
 
 
 
 
476
 
477
+ function wc_checkout_verify() {
478
+ $is_reg_enable = apply_filters( 'woocommerce_checkout_registration_enabled', 'yes' === get_option( 'woocommerce_enable_signup_and_login_from_checkout' ) );
479
+
480
+ if ( ! is_user_logged_in() && $is_reg_enable && anr_is_form_enabled( 'registration' ) ) {
481
+ // verification done during ragistration, So no need any more verification
482
+ } elseif ( ! $this->verify() ) {
483
+ wc_add_notice( $this->add_error_to_mgs(), 'error' );
484
  }
485
  }
486
 
487
+
488
+ } //END CLASS
489
  } //ENDIF
490
 
491
+ add_action( 'init', array( anr_captcha_class::init(), 'actions_filters' ), -9 );
492
 
functions.php CHANGED
@@ -1,9 +1,74 @@
1
  <?php
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
 
4
  function anr_get_option( $option, $default = '', $section = 'anr_admin_options' ) {
5
-
6
- if ( is_multisite() ) {
7
  $same_settings = apply_filters( 'anr_same_settings_for_all_sites', false );
8
  } else {
9
  $same_settings = false;
@@ -14,23 +79,24 @@ function anr_get_option( $option, $default = '', $section = 'anr_admin_options'
14
  $options = get_option( $section );
15
  }
16
 
17
- if ( isset( $options[$option] ) ) {
18
- return $options[$option];
19
- }
20
 
21
- return $default;
22
  }
23
 
24
  function anr_update_option( $options, $value = '', $section = 'anr_admin_options' ) {
25
-
26
- if( $options && ! is_array( $options ) ){
27
  $options = array(
28
  $options => $value,
29
  );
30
  }
31
- if( ! is_array( $options ) )
32
- return false;
33
-
 
34
  if ( is_multisite() ) {
35
  $same_settings = apply_filters( 'anr_same_settings_for_all_sites', false );
36
  } else {
@@ -42,114 +108,122 @@ function anr_update_option( $options, $value = '', $section = 'anr_admin_options
42
  update_option( $section, wp_parse_args( $options, get_option( $section ) ) );
43
  }
44
 
45
- return true;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  }
47
-
48
- function anr_translation()
49
- {
50
- //SETUP TEXT DOMAIN FOR TRANSLATIONS
51
- load_plugin_textdomain('advanced-nocaptcha-recaptcha', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
52
- }
53
-
54
- //Not used since version 2.1
55
- function anr_enqueue_scripts()
56
- {
57
- $language = trim(anr_get_option( 'language' ));
58
-
59
- $lang = "";
60
- if ( $language )
61
- $lang = "?hl=$language";
62
-
63
- wp_register_script( 'anr-google-recaptcha-script', "https://www.google.com/recaptcha/api.js$lang", array(), '2.0', true );
64
-
65
- }
66
-
67
- function anr_login_enqueue_scripts()
68
- {
69
- $remove_css = trim(anr_get_option( 'remove_css' ));
70
-
71
- if ( !$remove_css )
72
  wp_enqueue_style( 'anr-login-style', ANR_PLUGIN_URL . 'style/style.css' );
73
-
74
  }
75
-
76
- function anr_include_require_files()
77
- {
78
- $fep_files = array(
79
- 'main' => 'anr-captcha-class.php'
80
- );
81
  if ( is_admin() ) {
82
- $fep_files['admin'] = 'admin/anr-admin-class.php';
83
  }
84
-
85
- $fep_files = apply_filters('anr_include_files', $fep_files );
86
-
87
  foreach ( $fep_files as $fep_file ) {
88
- require_once ( $fep_file );
89
- }
90
  }
91
- add_action('wp_footer', 'anr_wp_footer');
92
- add_action('login_footer', 'anr_wp_footer');
 
93
 
94
- function anr_wp_footer()
95
- {
96
  anr_captcha_class::init()->footer_script();
97
  }
98
 
99
- add_action( 'anr_captcha_form_field', function(){ anr_captcha_form_field( true ); } );
 
 
 
 
100
  add_shortcode( 'anr-captcha', 'anr_captcha_form_field' );
101
 
102
- function anr_captcha_form_field( $echo = false )
103
- {
104
-
105
- if ( $echo ) {
106
- echo anr_captcha_class::init()->captcha_form_field();
107
- } else {
108
- return anr_captcha_class::init()->captcha_form_field();
109
- }
110
-
111
- }
112
-
113
- function anr_verify_captcha( $response = false )
114
- {
115
- $secre_key = trim(anr_get_option( 'secret_key' ));
116
- $remoteip = $_SERVER["REMOTE_ADDR"];
117
-
118
- if ( !$secre_key ) //if $secre_key is not set
119
- return true;
120
-
121
- if( false === $response )
122
- $response = isset( $_POST['g-recaptcha-response'] ) ? $_POST['g-recaptcha-response'] : '';
123
-
124
- if ( !$response || !$remoteip )
125
- return false;
126
-
127
- $url = "https://www.google.com/recaptcha/api/siteverify";
128
-
129
- // make a POST request to the Google reCAPTCHA Server
130
- $request = wp_remote_post( $url, array( 'timeout' => 10, 'body' => array( 'secret' => $secre_key, 'response' => $response, 'remoteip' => $remoteip ) ) );
131
-
132
- if ( is_wp_error( $request ) )
133
- return false;
134
-
135
- // get the request response body
136
- $request_body = wp_remote_retrieve_body( $request );
137
- if ( !$request_body )
138
- return false;
139
 
140
- $result = json_decode( $request_body, true );
141
- if ( isset($result['success']) && true == $result['success'] )
142
- return true;
143
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
144
  return false;
145
  }
146
-
147
- add_filter('shake_error_codes', 'anr_add_shake_error_codes' );
148
 
149
- function anr_add_shake_error_codes( $shake_error_codes )
150
- {
151
- $shake_error_codes[] = 'anr_error';
152
-
153
- return $shake_error_codes;
154
  }
155
-
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
 
3
+ // Before all hooks.
4
+ add_action( 'init', 'anr_plugin_update', -15 );
5
+
6
+ function anr_plugin_update() {
7
+ $prev_version = anr_get_option( 'version', '3.1' );
8
+ if ( version_compare( $prev_version, ANR_PLUGIN_VERSION, '!=' ) ) {
9
+ do_action( 'anr_plugin_update', $prev_version );
10
+ anr_update_option( 'version', ANR_PLUGIN_VERSION );
11
+ }
12
+ }
13
+
14
+ add_action( 'anr_plugin_update', 'anr_plugin_update_32' );
15
+
16
+ function anr_plugin_update_32( $prev_version ) {
17
+ if ( version_compare( $prev_version, '3.2', '<' ) ) {
18
+ if ( is_multisite() ) {
19
+ $same_settings = apply_filters( 'anr_same_settings_for_all_sites', false );
20
+ } else {
21
+ $same_settings = false;
22
+ }
23
+ if ( $same_settings ) {
24
+ $options = get_site_option( 'anr_admin_options' );
25
+ } else {
26
+ $options = get_option( 'anr_admin_options' );
27
+ }
28
+ if ( ! $options || ! is_array( $options ) ) {
29
+ return;
30
+ }
31
+ $options['error_message'] = str_replace( __( '<strong>ERROR</strong>: ', 'advanced-nocaptcha-recaptcha' ), '', anr_get_option( 'error_message' ) );
32
+
33
+ $enabled_forms = [];
34
+ if ( ! empty( $options['login'] ) ) {
35
+ $enabled_forms[] = 'login';
36
+ }
37
+ if ( ! empty( $options['registration'] ) ) {
38
+ $enabled_forms[] = 'registration';
39
+ }
40
+ if ( ! empty( $options['ms_user_signup'] ) ) {
41
+ $enabled_forms[] = 'ms_user_signup';
42
+ }
43
+ if ( ! empty( $options['lost_password'] ) ) {
44
+ $enabled_forms[] = 'lost_password';
45
+ }
46
+ if ( ! empty( $options['reset_password'] ) ) {
47
+ $enabled_forms[] = 'reset_password';
48
+ }
49
+ if ( ! empty( $options['comment'] ) ) {
50
+ $enabled_forms[] = 'comment';
51
+ }
52
+ if ( ! empty( $options['bb_new'] ) ) {
53
+ $enabled_forms[] = 'bbp_new';
54
+ }
55
+ if ( ! empty( $options['bb_reply'] ) ) {
56
+ $enabled_forms[] = 'bbp_reply';
57
+ }
58
+ if ( ! empty( $options['wc_checkout'] ) ) {
59
+ $enabled_forms[] = 'wc_checkout';
60
+ }
61
+ $options['enabled_forms'] = $enabled_forms;
62
+
63
+ unset( $options['login'], $options['registration'], $options['ms_user_signup'], $options['lost_password'], $options['reset_password'], $options['comment'], $options['bb_new'], $options['bb_reply'], $options['wc_checkout'] );
64
+
65
+ anr_update_option( $options );
66
+ }
67
+ }
68
 
69
  function anr_get_option( $option, $default = '', $section = 'anr_admin_options' ) {
70
+
71
+ if ( is_multisite() ) {
72
  $same_settings = apply_filters( 'anr_same_settings_for_all_sites', false );
73
  } else {
74
  $same_settings = false;
79
  $options = get_option( $section );
80
  }
81
 
82
+ if ( isset( $options[ $option ] ) ) {
83
+ return $options[ $option ];
84
+ }
85
 
86
+ return $default;
87
  }
88
 
89
  function anr_update_option( $options, $value = '', $section = 'anr_admin_options' ) {
90
+
91
+ if ( $options && ! is_array( $options ) ) {
92
  $options = array(
93
  $options => $value,
94
  );
95
  }
96
+ if ( ! is_array( $options ) ) {
97
+ return false;
98
+ }
99
+
100
  if ( is_multisite() ) {
101
  $same_settings = apply_filters( 'anr_same_settings_for_all_sites', false );
102
  } else {
108
  update_option( $section, wp_parse_args( $options, get_option( $section ) ) );
109
  }
110
 
111
+ return true;
112
+ }
113
+
114
+ function anr_is_form_enabled( $form ) {
115
+ if ( ! $form ) {
116
+ return false;
117
+ }
118
+ $enabled_forms = anr_get_option( 'enabled_forms', array() );
119
+ if ( ! is_array( $enabled_forms ) ) {
120
+ return false;
121
+ }
122
+ return in_array( $form, $enabled_forms, true );
123
+ }
124
+
125
+ function anr_translation() {
126
+ // SETUP TEXT DOMAIN FOR TRANSLATIONS
127
+ load_plugin_textdomain( 'advanced-nocaptcha-recaptcha', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
128
  }
129
+
130
+ function anr_login_enqueue_scripts() {
131
+
132
+ if ( ! anr_get_option( 'remove_css' ) && 'normal' === anr_get_option( 'size', 'normal' ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
133
  wp_enqueue_style( 'anr-login-style', ANR_PLUGIN_URL . 'style/style.css' );
 
134
  }
135
+ }
136
+
137
+ function anr_include_require_files() {
138
+ $fep_files = array(
139
+ 'main' => 'anr-captcha-class.php',
140
+ );
141
  if ( is_admin() ) {
142
+ $fep_files['settings'] = 'admin/settings.php';
143
  }
144
+
145
+ $fep_files = apply_filters( 'anr_include_files', $fep_files );
146
+
147
  foreach ( $fep_files as $fep_file ) {
148
+ require_once $fep_file;
 
149
  }
150
+ }
151
+ add_action( 'wp_footer', 'anr_wp_footer' );
152
+ add_action( 'login_footer', 'anr_wp_footer' );
153
 
154
+ function anr_wp_footer() {
 
155
  anr_captcha_class::init()->footer_script();
156
  }
157
 
158
+ add_action(
159
+ 'anr_captcha_form_field', function() {
160
+ anr_captcha_form_field( true );
161
+ }
162
+ );
163
  add_shortcode( 'anr-captcha', 'anr_captcha_form_field' );
164
 
165
+ function anr_captcha_form_field( $echo = false ) {
166
+ if ( $echo ) {
167
+ echo anr_captcha_class::init()->captcha_form_field();
168
+ } else {
169
+ return anr_captcha_class::init()->captcha_form_field();
170
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
171
 
172
+ }
 
 
173
 
174
+ function anr_verify_captcha( $response = false ) {
175
+ $secre_key = trim( anr_get_option( 'secret_key' ) );
176
+ $remoteip = $_SERVER['REMOTE_ADDR'];
177
+
178
+ if ( ! $secre_key ) { // if $secre_key is not set
179
+ return true;
180
+ }
181
+
182
+ if ( false === $response ) {
183
+ $response = isset( $_POST['g-recaptcha-response'] ) ? $_POST['g-recaptcha-response'] : '';
184
+ }
185
+
186
+ if ( ! $response || ! $remoteip ) {
187
+ return false;
188
+ }
189
+
190
+ $url = 'https://www.google.com/recaptcha/api/siteverify';
191
+
192
+ // make a POST request to the Google reCAPTCHA Server
193
+ $request = wp_remote_post(
194
+ $url, array(
195
+ 'timeout' => 10,
196
+ 'body' => array(
197
+ 'secret' => $secre_key,
198
+ 'response' => $response,
199
+ 'remoteip' => $remoteip,
200
+ ),
201
+ )
202
+ );
203
+
204
+ if ( is_wp_error( $request ) ) {
205
+ return false;
206
+ }
207
+
208
+ // get the request response body
209
+ $request_body = wp_remote_retrieve_body( $request );
210
+ if ( ! $request_body ) {
211
  return false;
212
  }
 
 
213
 
214
+ $result = json_decode( $request_body, true );
215
+ if ( isset( $result['success'] ) && true == $result['success'] ) {
216
+ return true;
 
 
217
  }
218
+
219
+ return false;
220
+ }
221
+
222
+ add_filter( 'shake_error_codes', 'anr_add_shake_error_codes' );
223
+
224
+ function anr_add_shake_error_codes( $shake_error_codes ) {
225
+ $shake_error_codes[] = 'anr_error';
226
+
227
+ return $shake_error_codes;
228
+ }
229
+
languages/advanced-nocaptcha-recaptcha.pot CHANGED
@@ -1,8 +1,8 @@
1
  #, fuzzy
2
  msgid ""
3
  msgstr ""
4
- "Project-Id-Version: Advanced noCaptcha reCaptcha 3.1\n"
5
- "POT-Creation-Date: 2018-12-15 19:18+0600\n"
6
  "PO-Revision-Date: 2018-04-12 17:20+0600\n"
7
  "Last-Translator: \n"
8
  "Language-Team: Shamim\n"
@@ -16,435 +16,468 @@ msgstr ""
16
  "X-Poedit-KeywordsList: __;_e\n"
17
  "X-Poedit-SearchPath-0: .\n"
18
 
19
- #: admin/anr-admin-class.php:45
20
- msgid "Advanced noCaptcha & invisible captcha Settings"
21
  msgstr ""
22
 
23
- #: admin/anr-admin-class.php:45
24
- msgid "Advanced noCaptcha & invisible captcha"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  msgstr ""
26
 
27
- #: admin/anr-admin-class.php:61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  msgid "Auto Detect"
29
  msgstr ""
30
 
31
- #: admin/anr-admin-class.php:62
32
  msgid "Arabic"
33
  msgstr ""
34
 
35
- #: admin/anr-admin-class.php:63
36
  msgid "Bulgarian"
37
  msgstr ""
38
 
39
- #: admin/anr-admin-class.php:64
40
  msgid "Catalan"
41
  msgstr ""
42
 
43
- #: admin/anr-admin-class.php:65
44
  msgid "Chinese (Simplified)"
45
  msgstr ""
46
 
47
- #: admin/anr-admin-class.php:66
48
  msgid "Chinese (Traditional)"
49
  msgstr ""
50
 
51
- #: admin/anr-admin-class.php:67
52
  msgid "Croatian"
53
  msgstr ""
54
 
55
- #: admin/anr-admin-class.php:68
56
  msgid "Czech"
57
  msgstr ""
58
 
59
- #: admin/anr-admin-class.php:69
60
  msgid "Danish"
61
  msgstr ""
62
 
63
- #: admin/anr-admin-class.php:70
64
  msgid "Dutch"
65
  msgstr ""
66
 
67
- #: admin/anr-admin-class.php:71
68
  msgid "English (UK)"
69
  msgstr ""
70
 
71
- #: admin/anr-admin-class.php:72
72
  msgid "English (US)"
73
  msgstr ""
74
 
75
- #: admin/anr-admin-class.php:73
76
  msgid "Filipino"
77
  msgstr ""
78
 
79
- #: admin/anr-admin-class.php:74
80
  msgid "Finnish"
81
  msgstr ""
82
 
83
- #: admin/anr-admin-class.php:75
84
  msgid "French"
85
  msgstr ""
86
 
87
- #: admin/anr-admin-class.php:76
88
  msgid "French (Canadian)"
89
  msgstr ""
90
 
91
- #: admin/anr-admin-class.php:77
92
  msgid "German"
93
  msgstr ""
94
 
95
- #: admin/anr-admin-class.php:78
96
  msgid "German (Austria)"
97
  msgstr ""
98
 
99
- #: admin/anr-admin-class.php:79
100
  msgid "German (Switzerland)"
101
  msgstr ""
102
 
103
- #: admin/anr-admin-class.php:80
104
  msgid "Greek"
105
  msgstr ""
106
 
107
- #: admin/anr-admin-class.php:81
108
  msgid "Hebrew"
109
  msgstr ""
110
 
111
- #: admin/anr-admin-class.php:82
112
  msgid "Hindi"
113
  msgstr ""
114
 
115
- #: admin/anr-admin-class.php:83
116
  msgid "Hungarain"
117
  msgstr ""
118
 
119
- #: admin/anr-admin-class.php:84
120
  msgid "Indonesian"
121
  msgstr ""
122
 
123
- #: admin/anr-admin-class.php:85
124
  msgid "Italian"
125
  msgstr ""
126
 
127
- #: admin/anr-admin-class.php:86
128
  msgid "Japanese"
129
  msgstr ""
130
 
131
- #: admin/anr-admin-class.php:87
132
  msgid "Korean"
133
  msgstr ""
134
 
135
- #: admin/anr-admin-class.php:88
136
  msgid "Latvian"
137
  msgstr ""
138
 
139
- #: admin/anr-admin-class.php:89
140
  msgid "Lithuanian"
141
  msgstr ""
142
 
143
- #: admin/anr-admin-class.php:90
144
  msgid "Norwegian"
145
  msgstr ""
146
 
147
- #: admin/anr-admin-class.php:91
148
  msgid "Persian"
149
  msgstr ""
150
 
151
- #: admin/anr-admin-class.php:92
152
  msgid "Polish"
153
  msgstr ""
154
 
155
- #: admin/anr-admin-class.php:93
156
  msgid "Portuguese"
157
  msgstr ""
158
 
159
- #: admin/anr-admin-class.php:94
160
  msgid "Portuguese (Brazil)"
161
  msgstr ""
162
 
163
- #: admin/anr-admin-class.php:95
164
  msgid "Portuguese (Portugal)"
165
  msgstr ""
166
 
167
- #: admin/anr-admin-class.php:96
168
  msgid "Romanian"
169
  msgstr ""
170
 
171
- #: admin/anr-admin-class.php:97
172
  msgid "Russian"
173
  msgstr ""
174
 
175
- #: admin/anr-admin-class.php:98
176
  msgid "Serbian"
177
  msgstr ""
178
 
179
- #: admin/anr-admin-class.php:99
180
  msgid "Slovak"
181
  msgstr ""
182
 
183
- #: admin/anr-admin-class.php:100
184
  msgid "Slovenian"
185
  msgstr ""
186
 
187
- #: admin/anr-admin-class.php:101
188
  msgid "Spanish"
189
  msgstr ""
190
 
191
- #: admin/anr-admin-class.php:102
192
  msgid "Spanish (Latin America)"
193
  msgstr ""
194
 
195
- #: admin/anr-admin-class.php:103
196
  msgid "Swedish"
197
  msgstr ""
198
 
199
- #: admin/anr-admin-class.php:104
200
  msgid "Thai"
201
  msgstr ""
202
 
203
- #: admin/anr-admin-class.php:105
204
  msgid "Turkish"
205
  msgstr ""
206
 
207
- #: admin/anr-admin-class.php:106
208
  msgid "Ukrainian"
209
  msgstr ""
210
 
211
- #: admin/anr-admin-class.php:107
212
  msgid "Vietnamese"
213
  msgstr ""
214
 
215
- #: admin/anr-admin-class.php:112
216
- msgid "Login Form"
217
- msgstr ""
218
-
219
- #: admin/anr-admin-class.php:113
220
- msgid "Registration Form"
221
- msgstr ""
222
-
223
- #: admin/anr-admin-class.php:114
224
- msgid "Multisite User Signup Form"
225
- msgstr ""
226
-
227
- #: admin/anr-admin-class.php:115
228
- msgid "Lost Password Form"
229
- msgstr ""
230
-
231
- #: admin/anr-admin-class.php:116
232
- msgid "Reset Password Form"
233
- msgstr ""
234
-
235
- #: admin/anr-admin-class.php:117
236
- msgid "Comment Form"
237
- msgstr ""
238
-
239
- #: admin/anr-admin-class.php:118
240
- msgid "bbPress New topic"
241
- msgstr ""
242
-
243
- #: admin/anr-admin-class.php:119
244
- msgid "bbPress reply to topic"
245
- msgstr ""
246
-
247
- #: admin/anr-admin-class.php:120
248
- msgid "WooCommerce Checkout"
249
- msgstr ""
250
-
251
- #: admin/anr-admin-class.php:130
252
- msgid "Options successfully saved."
253
- msgstr ""
254
-
255
- #: admin/anr-admin-class.php:140
256
- msgid "Advanced noCaptcha reCaptcha Settings"
257
- msgstr ""
258
-
259
- #: admin/anr-admin-class.php:141
260
- #, php-format
261
- msgid ""
262
- "If you like this plugin please <a href='%s' target='_blank'>Review in "
263
- "Wordpress.org</a> and give 5 star"
264
- msgstr ""
265
-
266
- #: admin/anr-admin-class.php:145
267
- msgid "Setting"
268
- msgstr ""
269
-
270
- #: admin/anr-admin-class.php:145
271
- msgid "Value"
272
- msgstr ""
273
-
274
- #: admin/anr-admin-class.php:147
275
- msgid "Site Key"
276
- msgstr ""
277
-
278
- #: admin/anr-admin-class.php:148
279
- msgid "Secret key"
280
- msgstr ""
281
-
282
- #: admin/anr-admin-class.php:150
283
- msgid "Language"
284
- msgstr ""
285
-
286
- #: admin/anr-admin-class.php:159
287
  msgid "Theme"
288
  msgstr ""
289
 
290
- #: admin/anr-admin-class.php:161
291
  msgid "Light"
292
  msgstr ""
293
 
294
- #: admin/anr-admin-class.php:162
295
  msgid "Dark"
296
  msgstr ""
297
 
298
- #: admin/anr-admin-class.php:165
299
  msgid "Size"
300
  msgstr ""
301
 
302
- #: admin/anr-admin-class.php:167
303
  msgid "Normal"
304
  msgstr ""
305
 
306
- #: admin/anr-admin-class.php:168
307
  msgid "Compact"
308
  msgstr ""
309
 
310
- #: admin/anr-admin-class.php:169
311
  msgid "Invisible"
312
  msgstr ""
313
 
314
- #: admin/anr-admin-class.php:172
315
  msgid ""
316
  "For invisible captcha set this as Invisible. Make sure to use site key and "
317
  "secret key for invisible captcha"
318
  msgstr ""
319
 
320
- #: admin/anr-admin-class.php:175
321
  msgid "Badge"
322
  msgstr ""
323
 
324
- #: admin/anr-admin-class.php:177
325
  msgid "Bottom Right"
326
  msgstr ""
327
 
328
- #: admin/anr-admin-class.php:178
329
  msgid "Bottom Left"
330
  msgstr ""
331
 
332
- #: admin/anr-admin-class.php:179
333
  msgid "Inline"
334
  msgstr ""
335
 
336
- #: admin/anr-admin-class.php:182
337
  msgid "Badge shows for invisible captcha"
338
  msgstr ""
339
 
340
- #: admin/anr-admin-class.php:185
341
- msgid "Error Message"
342
  msgstr ""
343
 
344
- #: admin/anr-admin-class.php:186
345
- msgid "Show login Captcha after how many failed attempts"
346
  msgstr ""
347
 
348
- #: admin/anr-admin-class.php:188
349
- msgid "Show Captcha on"
350
  msgstr ""
351
 
352
- #: admin/anr-admin-class.php:207
353
  msgid "Hide Captcha for logged in users?"
354
  msgstr ""
355
 
356
- #: admin/anr-admin-class.php:208
 
 
 
 
357
  msgid "Remove this plugin's css from login page?"
358
  msgstr ""
359
 
360
- #: admin/anr-admin-class.php:208
361
  msgid "This css increase login page width to adjust with Captcha width."
362
  msgstr ""
363
 
364
- #: admin/anr-admin-class.php:209
 
 
 
 
365
  msgid "Show captcha if javascript disabled?"
366
  msgstr ""
367
 
368
- #: admin/anr-admin-class.php:209
369
  msgid ""
370
  "If JavaScript is a requirement for your site, we advise that you do NOT "
371
  "check this."
372
  msgstr ""
373
 
374
- #: admin/anr-admin-class.php:210
375
- msgid "Save Options"
 
376
  msgstr ""
377
 
378
- #: admin/anr-admin-class.php:213 admin/anr-admin-class.php:303
379
- #, php-format
380
- msgid ""
381
- "For paid support pleasse visit <a href='%s' target='_blank'>Advanced "
382
- "noCaptcha reCaptcha</a>"
383
  msgstr ""
384
 
385
- #: admin/anr-admin-class.php:226
386
- msgid "Plugin Author"
 
 
 
 
387
  msgstr ""
388
 
389
- #: admin/anr-admin-class.php:251
390
- msgid "No Permission!"
391
  msgstr ""
392
 
393
- #: admin/anr-admin-class.php:255
394
- msgid "Sorry, your nonce did not verify!"
395
  msgstr ""
396
 
397
- #: admin/anr-admin-class.php:289
398
  msgid "Advanced noCaptcha reCaptcha Setup Instruction"
399
  msgstr ""
400
 
401
- #: admin/anr-admin-class.php:291
402
  #, php-format
403
  msgid ""
404
- "Get your site key and secret key from <a href='%s' target='_blank'>GOOGLE</"
405
- "a> if you do not have already."
406
  msgstr ""
407
 
408
- #: admin/anr-admin-class.php:292
409
- msgid "Goto SETTINGS page of this plugin and set up as you need. and ENJOY..."
 
410
  msgstr ""
411
 
412
- #: admin/anr-admin-class.php:294
413
  msgid "Implement noCaptcha in Contact Form 7"
414
  msgstr ""
415
 
416
- #: admin/anr-admin-class.php:295
417
- msgid "To show noCaptcha use "
 
418
  msgstr ""
419
 
420
- #: admin/anr-admin-class.php:297
421
  msgid "Implement noCaptcha in WooCommerce"
422
  msgstr ""
423
 
424
- #: admin/anr-admin-class.php:298
425
  msgid ""
426
  "If Login Form, Registration Form, Lost Password Form, Reset Password Form is "
427
  "selected in SETTINGS page of this plugin they will show and verify Captcha "
428
  "in WooCommerce respective forms also."
429
  msgstr ""
430
 
431
- #: admin/anr-admin-class.php:300
432
  msgid "If you want to implement noCaptcha in any other custom form"
433
  msgstr ""
434
 
435
- #: admin/anr-admin-class.php:301
436
- msgid "To show form field use "
 
437
  msgstr ""
438
 
439
- #: admin/anr-admin-class.php:302
440
- msgid "To verify use "
 
441
  msgstr ""
442
 
443
- #: admin/anr-admin-class.php:314
 
 
 
 
 
 
 
444
  msgid "Settings"
445
  msgstr ""
446
 
447
- #: anr-captcha-class.php:324 anr-captcha-class.php:391
448
- #: anr-captcha-class.php:450
 
 
 
449
  msgid "<strong>ERROR</strong>: "
450
  msgstr ""
1
  #, fuzzy
2
  msgid ""
3
  msgstr ""
4
+ "Project-Id-Version: Advanced noCaptcha reCaptcha 4.1\n"
5
+ "POT-Creation-Date: 2018-12-27 02:29+0600\n"
6
  "PO-Revision-Date: 2018-04-12 17:20+0600\n"
7
  "Last-Translator: \n"
8
  "Language-Team: Shamim\n"
16
  "X-Poedit-KeywordsList: __;_e\n"
17
  "X-Poedit-SearchPath-0: .\n"
18
 
19
+ #: admin/settings.php:56
20
+ msgid "Google Keys"
21
  msgstr ""
22
 
23
+ #: admin/settings.php:58
24
+ #, php-format
25
+ msgid ""
26
+ "Get reCaptcha v2 keys from <a href=\"%s\">Google</a>. If you select "
27
+ "Invisible captcha, make sure to get keys for Invisible captcha."
28
+ msgstr ""
29
+
30
+ #: admin/settings.php:62
31
+ msgid "Forms"
32
+ msgstr ""
33
+
34
+ #: admin/settings.php:65
35
+ msgid "Other Settings"
36
+ msgstr ""
37
+
38
+ #: admin/settings.php:74
39
+ msgid "Site Key"
40
+ msgstr ""
41
+
42
+ #: admin/settings.php:78
43
+ msgid "Secret Key"
44
+ msgstr ""
45
+
46
+ #: admin/settings.php:82
47
+ msgid "Enabled Forms"
48
+ msgstr ""
49
+
50
+ #: admin/settings.php:87
51
+ msgid "Login Form"
52
+ msgstr ""
53
+
54
+ #: admin/settings.php:88
55
+ msgid "Registration Form"
56
+ msgstr ""
57
+
58
+ #: admin/settings.php:89
59
+ msgid "Multisite User Signup Form"
60
  msgstr ""
61
 
62
+ #: admin/settings.php:90
63
+ msgid "Lost Password Form"
64
+ msgstr ""
65
+
66
+ #: admin/settings.php:91
67
+ msgid "Reset Password Form"
68
+ msgstr ""
69
+
70
+ #: admin/settings.php:92
71
+ msgid "Comment Form"
72
+ msgstr ""
73
+
74
+ #: admin/settings.php:93
75
+ msgid "bbPress New topic"
76
+ msgstr ""
77
+
78
+ #: admin/settings.php:94
79
+ msgid "bbPress reply to topic"
80
+ msgstr ""
81
+
82
+ #: admin/settings.php:95
83
+ msgid "BuddyPress register"
84
+ msgstr ""
85
+
86
+ #: admin/settings.php:96
87
+ msgid "WooCommerce Checkout"
88
+ msgstr ""
89
+
90
+ #: admin/settings.php:98
91
+ #, php-format
92
+ msgid "For other forms see <a href=\"%s\">Instruction</a>"
93
+ msgstr ""
94
+
95
+ #: admin/settings.php:101
96
+ msgid "Error Message"
97
+ msgstr ""
98
+
99
+ #: admin/settings.php:103
100
+ msgid "Please solve Captcha correctly"
101
+ msgstr ""
102
+
103
+ #: admin/settings.php:106
104
+ msgid "Captcha Language"
105
+ msgstr ""
106
+
107
+ #: admin/settings.php:111
108
  msgid "Auto Detect"
109
  msgstr ""
110
 
111
+ #: admin/settings.php:112
112
  msgid "Arabic"
113
  msgstr ""
114
 
115
+ #: admin/settings.php:113
116
  msgid "Bulgarian"
117
  msgstr ""
118
 
119
+ #: admin/settings.php:114
120
  msgid "Catalan"
121
  msgstr ""
122
 
123
+ #: admin/settings.php:115
124
  msgid "Chinese (Simplified)"
125
  msgstr ""
126
 
127
+ #: admin/settings.php:116
128
  msgid "Chinese (Traditional)"
129
  msgstr ""
130
 
131
+ #: admin/settings.php:117
132
  msgid "Croatian"
133
  msgstr ""
134
 
135
+ #: admin/settings.php:118
136
  msgid "Czech"
137
  msgstr ""
138
 
139
+ #: admin/settings.php:119
140
  msgid "Danish"
141
  msgstr ""
142
 
143
+ #: admin/settings.php:120
144
  msgid "Dutch"
145
  msgstr ""
146
 
147
+ #: admin/settings.php:121
148
  msgid "English (UK)"
149
  msgstr ""
150
 
151
+ #: admin/settings.php:122
152
  msgid "English (US)"
153
  msgstr ""
154
 
155
+ #: admin/settings.php:123
156
  msgid "Filipino"
157
  msgstr ""
158
 
159
+ #: admin/settings.php:124
160
  msgid "Finnish"
161
  msgstr ""
162
 
163
+ #: admin/settings.php:125
164
  msgid "French"
165
  msgstr ""
166
 
167
+ #: admin/settings.php:126
168
  msgid "French (Canadian)"
169
  msgstr ""
170
 
171
+ #: admin/settings.php:127
172
  msgid "German"
173
  msgstr ""
174
 
175
+ #: admin/settings.php:128
176
  msgid "German (Austria)"
177
  msgstr ""
178
 
179
+ #: admin/settings.php:129
180
  msgid "German (Switzerland)"
181
  msgstr ""
182
 
183
+ #: admin/settings.php:130
184
  msgid "Greek"
185
  msgstr ""
186
 
187
+ #: admin/settings.php:131
188
  msgid "Hebrew"
189
  msgstr ""
190
 
191
+ #: admin/settings.php:132
192
  msgid "Hindi"
193
  msgstr ""
194
 
195
+ #: admin/settings.php:133
196
  msgid "Hungarain"
197
  msgstr ""
198
 
199
+ #: admin/settings.php:134
200
  msgid "Indonesian"
201
  msgstr ""
202
 
203
+ #: admin/settings.php:135
204
  msgid "Italian"
205
  msgstr ""
206
 
207
+ #: admin/settings.php:136
208
  msgid "Japanese"
209
  msgstr ""
210
 
211
+ #: admin/settings.php:137
212
  msgid "Korean"
213
  msgstr ""
214
 
215
+ #: admin/settings.php:138
216
  msgid "Latvian"
217
  msgstr ""
218
 
219
+ #: admin/settings.php:139
220
  msgid "Lithuanian"
221
  msgstr ""
222
 
223
+ #: admin/settings.php:140
224
  msgid "Norwegian"
225
  msgstr ""
226
 
227
+ #: admin/settings.php:141
228
  msgid "Persian"
229
  msgstr ""
230
 
231
+ #: admin/settings.php:142
232
  msgid "Polish"
233
  msgstr ""
234
 
235
+ #: admin/settings.php:143
236
  msgid "Portuguese"
237
  msgstr ""
238
 
239
+ #: admin/settings.php:144
240
  msgid "Portuguese (Brazil)"
241
  msgstr ""
242
 
243
+ #: admin/settings.php:145
244
  msgid "Portuguese (Portugal)"
245
  msgstr ""
246
 
247
+ #: admin/settings.php:146
248
  msgid "Romanian"
249
  msgstr ""
250
 
251
+ #: admin/settings.php:147
252
  msgid "Russian"
253
  msgstr ""
254
 
255
+ #: admin/settings.php:148
256
  msgid "Serbian"
257
  msgstr ""
258
 
259
+ #: admin/settings.php:149
260
  msgid "Slovak"
261
  msgstr ""
262
 
263
+ #: admin/settings.php:150
264
  msgid "Slovenian"
265
  msgstr ""
266
 
267
+ #: admin/settings.php:151
268
  msgid "Spanish"
269
  msgstr ""
270
 
271
+ #: admin/settings.php:152
272
  msgid "Spanish (Latin America)"
273
  msgstr ""
274
 
275
+ #: admin/settings.php:153
276
  msgid "Swedish"
277
  msgstr ""
278
 
279
+ #: admin/settings.php:154
280
  msgid "Thai"
281
  msgstr ""
282
 
283
+ #: admin/settings.php:155
284
  msgid "Turkish"
285
  msgstr ""
286
 
287
+ #: admin/settings.php:156
288
  msgid "Ukrainian"
289
  msgstr ""
290
 
291
+ #: admin/settings.php:157
292
  msgid "Vietnamese"
293
  msgstr ""
294
 
295
+ #: admin/settings.php:161
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
296
  msgid "Theme"
297
  msgstr ""
298
 
299
+ #: admin/settings.php:167
300
  msgid "Light"
301
  msgstr ""
302
 
303
+ #: admin/settings.php:168
304
  msgid "Dark"
305
  msgstr ""
306
 
307
+ #: admin/settings.php:172
308
  msgid "Size"
309
  msgstr ""
310
 
311
+ #: admin/settings.php:178
312
  msgid "Normal"
313
  msgstr ""
314
 
315
+ #: admin/settings.php:179
316
  msgid "Compact"
317
  msgstr ""
318
 
319
+ #: admin/settings.php:180
320
  msgid "Invisible"
321
  msgstr ""
322
 
323
+ #: admin/settings.php:182
324
  msgid ""
325
  "For invisible captcha set this as Invisible. Make sure to use site key and "
326
  "secret key for invisible captcha"
327
  msgstr ""
328
 
329
+ #: admin/settings.php:185
330
  msgid "Badge"
331
  msgstr ""
332
 
333
+ #: admin/settings.php:191
334
  msgid "Bottom Right"
335
  msgstr ""
336
 
337
+ #: admin/settings.php:192
338
  msgid "Bottom Left"
339
  msgstr ""
340
 
341
+ #: admin/settings.php:193
342
  msgid "Inline"
343
  msgstr ""
344
 
345
+ #: admin/settings.php:195
346
  msgid "Badge shows for invisible captcha"
347
  msgstr ""
348
 
349
+ #: admin/settings.php:198
350
+ msgid "Failed login Captcha"
351
  msgstr ""
352
 
353
+ #: admin/settings.php:204
354
+ msgid "Show login Captcha after how many failed attempts? 0 = show always"
355
  msgstr ""
356
 
357
+ #: admin/settings.php:207
358
+ msgid "Logged in Hide"
359
  msgstr ""
360
 
361
+ #: admin/settings.php:211
362
  msgid "Hide Captcha for logged in users?"
363
  msgstr ""
364
 
365
+ #: admin/settings.php:214
366
+ msgid "Remove CSS"
367
+ msgstr ""
368
+
369
+ #: admin/settings.php:218
370
  msgid "Remove this plugin's css from login page?"
371
  msgstr ""
372
 
373
+ #: admin/settings.php:219
374
  msgid "This css increase login page width to adjust with Captcha width."
375
  msgstr ""
376
 
377
+ #: admin/settings.php:222
378
+ msgid "No JS Captcha"
379
+ msgstr ""
380
+
381
+ #: admin/settings.php:226
382
  msgid "Show captcha if javascript disabled?"
383
  msgstr ""
384
 
385
+ #: admin/settings.php:227
386
  msgid ""
387
  "If JavaScript is a requirement for your site, we advise that you do NOT "
388
  "check this."
389
  msgstr ""
390
 
391
+ #: admin/settings.php:318
392
+ #, php-format
393
+ msgid "No hook defined for %s"
394
  msgstr ""
395
 
396
+ #: admin/settings.php:341 admin/settings.php:363
397
+ msgid "Advanced noCaptcha & invisible captcha Settings"
 
 
 
398
  msgstr ""
399
 
400
+ #: admin/settings.php:341
401
+ msgid "Advanced noCaptcha & invisible captcha"
402
+ msgstr ""
403
+
404
+ #: admin/settings.php:342
405
+ msgid "Instruction"
406
  msgstr ""
407
 
408
+ #: admin/settings.php:357
409
+ msgid "Settings saved."
410
  msgstr ""
411
 
412
+ #: admin/settings.php:391
413
+ msgid "Plugin Author"
414
  msgstr ""
415
 
416
+ #: admin/settings.php:411
417
  msgid "Advanced noCaptcha reCaptcha Setup Instruction"
418
  msgstr ""
419
 
420
+ #: admin/settings.php:416
421
  #, php-format
422
  msgid ""
423
+ "Get your site key and secret key from <a href=\"%s\" target=\"_blank"
424
+ "\">GOOGLE</a> if you do not have already."
425
  msgstr ""
426
 
427
+ #: admin/settings.php:417
428
+ #, php-format
429
+ msgid "Goto %s page of this plugin and set up as you need. and ENJOY..."
430
  msgstr ""
431
 
432
+ #: admin/settings.php:419
433
  msgid "Implement noCaptcha in Contact Form 7"
434
  msgstr ""
435
 
436
+ #: admin/settings.php:420
437
+ #, php-format
438
+ msgid "To show noCaptcha use %s"
439
  msgstr ""
440
 
441
+ #: admin/settings.php:422
442
  msgid "Implement noCaptcha in WooCommerce"
443
  msgstr ""
444
 
445
+ #: admin/settings.php:423
446
  msgid ""
447
  "If Login Form, Registration Form, Lost Password Form, Reset Password Form is "
448
  "selected in SETTINGS page of this plugin they will show and verify Captcha "
449
  "in WooCommerce respective forms also."
450
  msgstr ""
451
 
452
+ #: admin/settings.php:425
453
  msgid "If you want to implement noCaptcha in any other custom form"
454
  msgstr ""
455
 
456
+ #: admin/settings.php:426
457
+ #, php-format
458
+ msgid "To show noCaptcha in a form use %1$s OR %2$s"
459
  msgstr ""
460
 
461
+ #: admin/settings.php:427
462
+ #, php-format
463
+ msgid "To verify use %s. It will return true on success otherwise false."
464
  msgstr ""
465
 
466
+ #: admin/settings.php:428
467
+ #, php-format
468
+ msgid ""
469
+ "For paid support pleasse visit <a href=\"%s\" target=\"_blank\">Advanced "
470
+ "noCaptcha reCaptcha</a>"
471
+ msgstr ""
472
+
473
+ #: admin/settings.php:448
474
  msgid "Settings"
475
  msgstr ""
476
 
477
+ #: anr-captcha-class.php:100
478
+ msgid "ERROR"
479
+ msgstr ""
480
+
481
+ #: functions.php:31
482
  msgid "<strong>ERROR</strong>: "
483
  msgstr ""
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: shamim51
3
  Tags: recaptcha,nocaptcha,invisible,no captcha,bot,spam,captcha,woocommerce captcha,woocommerce nocaptcha, woocommerce,widget,plugin,sidebar,shortcode,page,posts,comments,google,bbpress,multisite,multiple
4
  Donate link: https://www.paypal.me/hasanshamim
5
  Requires at least: 4.4
6
- Tested up to: 5.0.1
7
- Stable tag: 3.1
8
  Requires PHP: 5.4
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -81,6 +81,16 @@ To show noCaptcha use [anr_nocaptcha g-recaptcha-response]
81
 
82
  == Changelog ==
83
 
 
 
 
 
 
 
 
 
 
 
84
  = 3.1 =
85
 
86
  * Sometimes fatal error if is_admin return true in front-end.
3
  Tags: recaptcha,nocaptcha,invisible,no captcha,bot,spam,captcha,woocommerce captcha,woocommerce nocaptcha, woocommerce,widget,plugin,sidebar,shortcode,page,posts,comments,google,bbpress,multisite,multiple
4
  Donate link: https://www.paypal.me/hasanshamim
5
  Requires at least: 4.4
6
+ Tested up to: 5.0.2
7
+ Stable tag: 4.1
8
  Requires PHP: 5.4
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
81
 
82
  == Changelog ==
83
 
84
+ = 4.1 =
85
+
86
+ * Settings page redesigned.
87
+ * anr_is_form_enabled function added
88
+ * Captcha error show first before username password error. So if captcha is not validated then username password error is not shown.
89
+ * enqueue login css only if normal captcha is shown
90
+ * Enabled forms stored as an array in db. array key is enabled_forms
91
+ * Add class ANR_Settings, removed class anr_admin_class
92
+ * BuddyPress register captcha added
93
+
94
  = 3.1 =
95
 
96
  * Sometimes fatal error if is_admin return true in front-end.