Advanced noCaptcha & invisible Captcha - Version 1.2

Version Description

  • Now captcha size can be changed.
  • bbPress New topic added
  • bbPress reply to topic added
  • XMLRPC_REQUEST Check
  • Some bug fix.
Download this release

Release Info

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

Code changes from version 1.1 to 1.2

admin/anr-admin-class.php CHANGED
@@ -102,7 +102,9 @@ if (!class_exists('anr_admin_class'))
102
  __( 'Registration Form', 'anr' ) => 'registration',
103
  __( 'Lost Password Form', 'anr' ) => 'lost_password',
104
  __( 'Reset Password Form', 'anr' ) => 'reset_password',
105
- __( 'Comment Form', 'anr' ) => 'comment'
 
 
106
 
107
  );
108
 
@@ -145,6 +147,12 @@ if (!class_exists('anr_admin_class'))
145
  <option value='light' ".selected(anr_get_option('theme'), 'light',false).">Light</option>
146
  <option value='dark' ".selected(anr_get_option('theme'), 'dark',false).">Dark</option>
147
 
 
 
 
 
 
 
148
  </select></td></tr>
149
  <tr><td>".__("Error Message", 'anr')."</td><td><input type='text' size = '40' name='error_message' value='".anr_get_option('error_message', '<strong>ERROR</strong>: Please solve Captcha correctly.')."' /></td></tr>
150
 
@@ -152,21 +160,22 @@ if (!class_exists('anr_admin_class'))
152
 
153
  foreach ( $locations as $location => $slug ) {
154
 
155
- echo "<ul colspan='2'><input type='checkbox' name='$slug' value='1' ".checked(anr_get_option($slug), '1', false)." /> $location</ul>";
156
 
157
  }
158
  if ( function_exists('fepcf_plugin_activate'))
159
- echo "<ul colspan='2'><input type='checkbox' name='fep_contact_form' value='1' ".checked(anr_get_option('fep_contact_form'), '1', false)." /> FEP Contact Form</ul>";
160
  else
161
- echo "<ul colspan='2'><input type='checkbox' name='fep_contact_form' disabled value='1' ".checked(anr_get_option('fep_contact_form'), '1', false)." /> FEP Contact Form (is not installed) <a href='https://wordpress.org/plugins/fep-contact-form/' target='_blank'>Install Now</a></ul>";
162
 
163
  echo "<ul colspan='2'> For other forms see <a href='".esc_url(admin_url( 'admin.php?page=anr-instruction' ))."'>Instruction</a></ul>";
164
  echo "</td></tr>";
165
 
166
  do_action('anr_admin_setting_form');
167
 
168
- echo "<tr><td colspan='2'><input type='checkbox' name='loggedin_hide' value='1' ".checked(anr_get_option('loggedin_hide'), '1', false)." /> ".__("Hide Captcha for logged in users?", 'anr')."</td></tr>
169
- <tr><td colspan='2'><input type='checkbox' name='no_js' value='1' ".checked(anr_get_option('no_js'), '1', false)." /> ".__("Show captcha if javascript disabled?", 'anr')."<br/><small>".__("If JavaScript is a requirement for your site, we advise that you do NOT check this", 'anr')."</small></td></tr>
 
170
  <tr><td colspan='2'><span><input class='button-primary' type='submit' name='anr-admin-settings-submit' value='".__("Save Options", 'anr')."' /></span></td><td><input type='hidden' name='token' value='$token' /></td></tr>
171
  </table>
172
  </form>
@@ -214,9 +223,7 @@ function anr_admin_sidebar()
214
  if ( !wp_verify_nonce($options['token'], 'anr-admin-settings'))
215
  $errors->add('invalidToken', __('Sorry, your nonce did not verify!', 'anr'));
216
 
217
- do_action('anr_action_admin_setting_before_save', $errors);
218
-
219
- $options = apply_filters('anr_filter_admin_setting_before_save',$options);
220
  //var_dump($options);
221
 
222
  if (count($errors->get_error_codes())==0){
102
  __( 'Registration Form', 'anr' ) => 'registration',
103
  __( 'Lost Password Form', 'anr' ) => 'lost_password',
104
  __( 'Reset Password Form', 'anr' ) => 'reset_password',
105
+ __( 'Comment Form', 'anr' ) => 'comment',
106
+ __( 'bbPress New topic', 'anr' ) => 'bb_new',
107
+ __( 'bbPress reply to topic', 'anr' )=> 'bb_reply',
108
 
109
  );
110
 
147
  <option value='light' ".selected(anr_get_option('theme'), 'light',false).">Light</option>
148
  <option value='dark' ".selected(anr_get_option('theme'), 'dark',false).">Dark</option>
149
 
150
+ </select></td></tr>
151
+ <tr><td>".__("Size", 'anr')."</td><td><select name='size'>
152
+
153
+ <option value='normal' ".selected(anr_get_option('size'), 'normal',false).">Normal</option>
154
+ <option value='compact' ".selected(anr_get_option('size'), 'compact',false).">Compact</option>
155
+
156
  </select></td></tr>
157
  <tr><td>".__("Error Message", 'anr')."</td><td><input type='text' size = '40' name='error_message' value='".anr_get_option('error_message', '<strong>ERROR</strong>: Please solve Captcha correctly.')."' /></td></tr>
158
 
160
 
161
  foreach ( $locations as $location => $slug ) {
162
 
163
+ echo "<ul colspan='2'><label><input type='checkbox' name='$slug' value='1' ".checked(anr_get_option($slug), '1', false)." /> $location</label></ul>";
164
 
165
  }
166
  if ( function_exists('fepcf_plugin_activate'))
167
+ echo "<ul colspan='2'><label><input type='checkbox' name='fep_contact_form' value='1' ".checked(anr_get_option('fep_contact_form'), '1', false)." /> FEP Contact Form</label></ul>";
168
  else
169
+ echo "<ul colspan='2'><label><input type='checkbox' name='fep_contact_form' disabled value='1' ".checked(anr_get_option('fep_contact_form'), '1', false)." /> FEP Contact Form (is not installed) <a href='https://wordpress.org/plugins/fep-contact-form/' target='_blank'>Install Now</a></label></ul>";
170
 
171
  echo "<ul colspan='2'> For other forms see <a href='".esc_url(admin_url( 'admin.php?page=anr-instruction' ))."'>Instruction</a></ul>";
172
  echo "</td></tr>";
173
 
174
  do_action('anr_admin_setting_form');
175
 
176
+ echo "<tr><td colspan='2'><label><input type='checkbox' name='loggedin_hide' value='1' ".checked(anr_get_option('loggedin_hide'), '1', false)." /> ".__("Hide Captcha for logged in users?", 'anr')."</label></td></tr>
177
+ <tr><td colspan='2'><label><input type='checkbox' name='remove_css' value='1' ".checked(anr_get_option('remove_css'), '1', false)." /> ".__("Remove this plugin's css from login page?", 'anr')."<br/><small>".__("This css increase login page width to adjust with Captcha width.", 'anr')."</small></label></td></tr>
178
+ <tr><td colspan='2'><label><input type='checkbox' name='no_js' value='1' ".checked(anr_get_option('no_js'), '1', false)." /> ".__("Show captcha if javascript disabled?", 'anr')."<br/><small>".__("If JavaScript is a requirement for your site, we advise that you do NOT check this.", 'anr')."</small></label></td></tr>
179
  <tr><td colspan='2'><span><input class='button-primary' type='submit' name='anr-admin-settings-submit' value='".__("Save Options", 'anr')."' /></span></td><td><input type='hidden' name='token' value='$token' /></td></tr>
180
  </table>
181
  </form>
223
  if ( !wp_verify_nonce($options['token'], 'anr-admin-settings'))
224
  $errors->add('invalidToken', __('Sorry, your nonce did not verify!', 'anr'));
225
 
226
+ $options = apply_filters('anr_filter_admin_setting_before_save', $options, $errors);
 
 
227
  //var_dump($options);
228
 
229
  if (count($errors->get_error_codes())==0){
advanced-nocaptcha-recaptcha.php CHANGED
@@ -2,15 +2,14 @@
2
  /*
3
  Plugin Name: Advanced noCaptcha reCaptcha
4
  Plugin URI: https://shamimbiplob.wordpress.com/contact-us/
5
- Description: Show noCaptcha in Login, Register, Lost Password, Reset Password, Comment Form (after Comment textarea before submit button). Also can implement in any other form easily.
6
- Version: 1.1
7
  Author: Shamim
8
  Author URI: https://shamimbiplob.wordpress.com/contact-us/
9
  Text Domain: anr
10
  License: GPLv2 or later
11
  */
12
  //DEFINE
13
- global $wpdb;
14
  define('ANR_PLUGIN_DIR',plugin_dir_path( __FILE__ ));
15
  define('ANR_PLUGIN_URL',plugins_url().'/advanced-nocaptcha-recaptcha/');
16
 
2
  /*
3
  Plugin Name: Advanced noCaptcha reCaptcha
4
  Plugin URI: https://shamimbiplob.wordpress.com/contact-us/
5
+ Description: Show noCaptcha in Comment Form (after Comment textarea before submit button), Contact Form 7, bbPress, Login, Register, Lost Password, Reset Password. Also can implement in any other form easily.
6
+ Version: 1.2
7
  Author: Shamim
8
  Author URI: https://shamimbiplob.wordpress.com/contact-us/
9
  Text Domain: anr
10
  License: GPLv2 or later
11
  */
12
  //DEFINE
 
13
  define('ANR_PLUGIN_DIR',plugin_dir_path( __FILE__ ));
14
  define('ANR_PLUGIN_URL',plugins_url().'/advanced-nocaptcha-recaptcha/');
15
 
anr-captcha-class.php CHANGED
@@ -21,9 +21,9 @@ if (!class_exists('anr_captcha_class'))
21
  add_action ('fepcf_action_message_before_send', array(&$this, 'fepcf_verify'));
22
  }
23
 
24
- if ( '1' == anr_get_option( 'login' )) {
25
  add_action ('login_form', array(&$this, 'form_field'), 99);
26
- add_filter ('wp_authenticate_user', array(&$this, 'login_verify'), 10, 2 );
27
  }
28
 
29
  if ( '1' == anr_get_option( 'registration' )) {
@@ -43,13 +43,23 @@ if (!class_exists('anr_captcha_class'))
43
 
44
  if ( '1' == anr_get_option( 'comment' )) {
45
  add_filter ('comment_form_field_comment', array(&$this, 'comment_form_field') );
46
- add_action ('pre_comment_on_post', array(&$this, 'comment_verify') );
47
  }
48
 
49
  if ( function_exists( 'wpcf7_add_shortcode' )) {
50
  wpcf7_add_shortcode('anr_nocaptcha', array(&$this, 'wpcf7_form_field'), true);
51
  add_filter('wpcf7_validate_anr_nocaptcha', array(&$this, 'wpcf7_verify'), 10, 2);
52
  }
 
 
 
 
 
 
 
 
 
 
53
  }
54
 
55
 
@@ -60,7 +70,7 @@ if (!class_exists('anr_captcha_class'))
60
  if ( is_user_logged_in() && $loggedin_hide )
61
  return;
62
 
63
- echo anr_captcha_form_field( false );
64
 
65
  }
66
 
@@ -98,7 +108,7 @@ if (!class_exists('anr_captcha_class'))
98
  $errors->add('anr_error', $error_message);
99
  }
100
 
101
- function login_verify ( $user, $password )
102
  {
103
  if ( ! $this->verify() ) {
104
  $error_message = anr_get_option( 'error_message' );
@@ -138,13 +148,15 @@ if (!class_exists('anr_captcha_class'))
138
  }
139
  }
140
 
141
- function comment_verify( $comment_post_ID )
142
  {
143
 
144
  if ( ! $this->verify() ) {
145
- $error_message = anr_get_option( 'error_message' );
146
- wp_die( $error_message, 200 );
147
- }
 
 
148
  }
149
 
150
  function wpcf7_form_field( $tags )
@@ -178,6 +190,24 @@ if (!class_exists('anr_captcha_class'))
178
 
179
  return $result;
180
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
181
 
182
 
183
 
21
  add_action ('fepcf_action_message_before_send', array(&$this, 'fepcf_verify'));
22
  }
23
 
24
+ if ( '1' == anr_get_option( 'login' ) && !defined('XMLRPC_REQUEST')) {
25
  add_action ('login_form', array(&$this, 'form_field'), 99);
26
+ add_filter ('authenticate', array(&$this, 'login_verify'), 999 );
27
  }
28
 
29
  if ( '1' == anr_get_option( 'registration' )) {
43
 
44
  if ( '1' == anr_get_option( 'comment' )) {
45
  add_filter ('comment_form_field_comment', array(&$this, 'comment_form_field') );
46
+ add_filter ('preprocess_comment', array(&$this, 'comment_verify') );
47
  }
48
 
49
  if ( function_exists( 'wpcf7_add_shortcode' )) {
50
  wpcf7_add_shortcode('anr_nocaptcha', array(&$this, 'wpcf7_form_field'), true);
51
  add_filter('wpcf7_validate_anr_nocaptcha', array(&$this, 'wpcf7_verify'), 10, 2);
52
  }
53
+
54
+ if ( '1' == anr_get_option( 'bb_new' )) {
55
+ add_action ('bbp_theme_before_topic_form_submit_wrapper', array(&$this, 'form_field'), 99);
56
+ add_action ('bbp_new_topic_pre_extras', array(&$this, 'bb_new_verify') );
57
+ }
58
+
59
+ if ( '1' == anr_get_option( 'bb_reply' )) {
60
+ add_action ('bbp_theme_before_reply_form_submit_wrapper', array(&$this, 'form_field'), 99);
61
+ add_action ('bbp_new_reply_pre_extras', array(&$this, 'bb_reply_verify'), 10, 2 );
62
+ }
63
  }
64
 
65
 
70
  if ( is_user_logged_in() && $loggedin_hide )
71
  return;
72
 
73
+ anr_captcha_form_field();
74
 
75
  }
76
 
108
  $errors->add('anr_error', $error_message);
109
  }
110
 
111
+ function login_verify ( $user )
112
  {
113
  if ( ! $this->verify() ) {
114
  $error_message = anr_get_option( 'error_message' );
148
  }
149
  }
150
 
151
+ function comment_verify( $commentdata )
152
  {
153
 
154
  if ( ! $this->verify() ) {
155
+ $error_message = anr_get_option( 'error_message' );
156
+ wp_die( $error_message, 200 );
157
+ }
158
+
159
+ return $commentdata;
160
  }
161
 
162
  function wpcf7_form_field( $tags )
190
 
191
  return $result;
192
  }
193
+
194
+ function bb_new_verify( $forum_id )
195
+ {
196
+
197
+ if ( ! $this->verify() ) {
198
+ $error_message = anr_get_option( 'error_message' );
199
+ bbp_add_error('anr_error', $error_message);
200
+ }
201
+ }
202
+
203
+ function bb_reply_verify( $topic_id, $forum_id )
204
+ {
205
+
206
+ if ( ! $this->verify() ) {
207
+ $error_message = anr_get_option( 'error_message' );
208
+ bbp_add_error('anr_error', $error_message);
209
+ }
210
+ }
211
 
212
 
213
 
functions.php CHANGED
@@ -30,19 +30,22 @@ function anr_enqueue_scripts()
30
  if ( $language )
31
  $lang = "?hl=$language";
32
 
33
- wp_register_script( 'anr-google-recaptcha-script', "https://www.google.com/recaptcha/api.js$lang", array(), '1.1', true );
34
 
35
  }
36
 
37
  function anr_login_enqueue_scripts()
38
  {
39
  $language = trim(anr_get_option( 'language' ));
 
40
 
41
  $lang = "";
42
  if ( $language )
43
  $lang = "?hl=$language";
44
 
45
- wp_register_script( 'anr-google-recaptcha-script', "https://www.google.com/recaptcha/api.js$lang", array(), '1.1', true );
 
 
46
  wp_enqueue_style( 'anr-login-style', ANR_PLUGIN_URL . 'style/style.css' );
47
 
48
  }
@@ -71,12 +74,25 @@ function anr_include_require_files()
71
  function anr_captcha_form_field( $echo = true )
72
  {
73
  $site_key = trim(anr_get_option( 'site_key' ));
74
- $theme = anr_get_option( 'theme' );
 
75
  $no_js = anr_get_option( 'no_js' );
76
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  wp_enqueue_script('anr-google-recaptcha-script');
78
 
79
- $field = "<div class='g-recaptcha' data-sitekey='$site_key' data-theme='$theme'></div>";
80
 
81
  if ( $no_js == 1 )
82
  {
@@ -135,11 +151,8 @@ function anr_verify_captcha()
135
  return false;
136
 
137
  $result = json_decode( $request_body, true );
138
- if ( !isset($result['success']) || !$result['success'] )
139
- return false;
140
-
141
- if ( true == $result['success'] )
142
- return true;
143
 
144
  return false;
145
  }
30
  if ( $language )
31
  $lang = "?hl=$language";
32
 
33
+ wp_register_script( 'anr-google-recaptcha-script', "https://www.google.com/recaptcha/api.js$lang", array(), '2.0', true );
34
 
35
  }
36
 
37
  function anr_login_enqueue_scripts()
38
  {
39
  $language = trim(anr_get_option( 'language' ));
40
+ $remove_css = trim(anr_get_option( 'remove_css' ));
41
 
42
  $lang = "";
43
  if ( $language )
44
  $lang = "?hl=$language";
45
 
46
+ wp_register_script( 'anr-google-recaptcha-script', "https://www.google.com/recaptcha/api.js$lang", array(), '2.0', true );
47
+
48
+ if ( !$remove_css )
49
  wp_enqueue_style( 'anr-login-style', ANR_PLUGIN_URL . 'style/style.css' );
50
 
51
  }
74
  function anr_captcha_form_field( $echo = true )
75
  {
76
  $site_key = trim(anr_get_option( 'site_key' ));
77
+ $theme = anr_get_option( 'theme', 'light' );
78
+ $size = anr_get_option( 'size', 'normal' );
79
  $no_js = anr_get_option( 'no_js' );
80
 
81
+ if ( !wp_script_is( 'anr-google-recaptcha-script', 'registered' ) )
82
+ {
83
+ $language = trim(anr_get_option( 'language' ));
84
+
85
+ $lang = "";
86
+ if ( $language )
87
+ $lang = "?hl=$language";
88
+
89
+ wp_register_script( 'anr-google-recaptcha-script', "https://www.google.com/recaptcha/api.js$lang", array(), '2.0', true );
90
+
91
+ }
92
+
93
  wp_enqueue_script('anr-google-recaptcha-script');
94
 
95
+ $field = "<div class='g-recaptcha' data-sitekey='$site_key' data-theme='$theme' data-size='$size'></div>";
96
 
97
  if ( $no_js == 1 )
98
  {
151
  return false;
152
 
153
  $result = json_decode( $request_body, true );
154
+ if ( isset($result['success']) && true == $result['success'] )
155
+ return true;
 
 
 
156
 
157
  return false;
158
  }
readme.txt CHANGED
@@ -1,18 +1,18 @@
1
  === Advanced noCaptcha reCaptcha ===
2
  Contributors: shamim51
3
- Tags: recaptcha,nocaptcha,no captcha,bot,spam,captcha,contact form 7 captcha,widget,plugin,sidebar,shortcode,page,posts,comments,google
4
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=4HKBQ3QFSCPHJ&lc=US&item_name=Front%20End%20PM&item_number=Front%20End%20PM&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted
5
  Requires at least: 2.8
6
- Tested up to: 4.2.2
7
  Stable tag: trunk
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
- Show noCaptcha in Comment Form (after Comment textarea before submit button), Contact Form 7, Login, Register, Lost Password, Reset Password.
12
 
13
  == Description ==
14
 
15
- Show noCaptcha in Comment Form (after Comment textarea before submit button), Contact Form 7, Login, Register, Lost Password, Reset Password. Also can implement in any other form easily.
16
 
17
  = Show noCaptcha on =
18
 
@@ -23,11 +23,14 @@ Show noCaptcha in Comment Form (after Comment textarea before submit button), Co
23
  * Lost Password
24
  * Reset Password
25
  * FEP Contact Form
 
 
26
 
27
  = Options =
28
 
29
  * Language can be changed
30
  * Theme can be changed
 
31
  * Error message can be changed
32
  * Option to show/hide captcha for logged in users
33
  * Captcha will show if javascript disabled also (optional)
@@ -57,12 +60,28 @@ Yes. this plugin is translate ready. But If your language is not available you c
57
 
58
  == Changelog ==
59
 
 
 
 
 
 
 
 
 
60
  = 1.1 =
61
 
62
  * Initial release.
63
 
64
  == Upgrade Notice ==
65
 
 
 
 
 
 
 
 
 
66
  = 1.1 =
67
 
68
  * Initial release.
1
  === Advanced noCaptcha reCaptcha ===
2
  Contributors: shamim51
3
+ Tags: recaptcha,nocaptcha,no captcha,bot,spam,captcha,contact form 7 captcha,widget,plugin,sidebar,shortcode,page,posts,comments,google,bbpress
4
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=4HKBQ3QFSCPHJ&lc=US&item_name=Front%20End%20PM&item_number=Front%20End%20PM&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted
5
  Requires at least: 2.8
6
+ Tested up to: 4.3
7
  Stable tag: trunk
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
+ Show noCaptcha in Comment Form (after Comment textarea before submit button), Contact Form 7, bbpress, Login, Register, Lost Password, Reset Password.
12
 
13
  == Description ==
14
 
15
+ Show noCaptcha in Comment Form (after Comment textarea before submit button), Contact Form 7, bbPress, Login, Register, Lost Password, Reset Password. Also can implement in any other form easily.
16
 
17
  = Show noCaptcha on =
18
 
23
  * Lost Password
24
  * Reset Password
25
  * FEP Contact Form
26
+ * bbPress New topic
27
+ * bbPress reply to topic
28
 
29
  = Options =
30
 
31
  * Language can be changed
32
  * Theme can be changed
33
+ * Size can be changed
34
  * Error message can be changed
35
  * Option to show/hide captcha for logged in users
36
  * Captcha will show if javascript disabled also (optional)
60
 
61
  == Changelog ==
62
 
63
+ = 1.2 =
64
+
65
+ * Now captcha size can be changed.
66
+ * bbPress New topic added
67
+ * bbPress reply to topic added
68
+ * XMLRPC_REQUEST Check
69
+ * Some bug fix.
70
+
71
  = 1.1 =
72
 
73
  * Initial release.
74
 
75
  == Upgrade Notice ==
76
 
77
+ = 1.2 =
78
+
79
+ * Now captcha size can be changed.
80
+ * bbPress New topic added
81
+ * bbPress reply to topic added
82
+ * XMLRPC_REQUEST Check
83
+ * Some bug fix.
84
+
85
  = 1.1 =
86
 
87
  * Initial release.