WordPress Zero Spam - Version 4.3.10

Version Description

  • Updated get_plugin_data calls to use a constant. See #196
  • Added additional country regions for geolocation lookup
  • Renamed 'addons' to 'integrations'
  • Fixed issue with WPForm spam detections
  • Fix for plugin deactivation from v3 to v4 upgrade
Download this release

Release Info

Developer bmarshall511
Plugin Icon 128x128 WordPress Zero Spam
Version 4.3.10
Comparing to
See all releases

Code changes from version 4.3.9 to 4.3.10

addons/wpforms.php DELETED
@@ -1,29 +0,0 @@
1
- <?php
2
- /**
3
- * Handles checking submitted WPForms submissions
4
- *
5
- * @package WordPressZeroSpam
6
- * @since 4.1.0
7
- */
8
-
9
- /**
10
- * Validation for WPForms submissions
11
- */
12
- if ( ! function_exists( 'wpzerospam_wpforms_process_honeypot' ) ) {
13
- function wpzerospam_wpforms_process_honeypot( $honeypot, $fields, $entry, $form_data ) {
14
- if ( is_user_logged_in() || wpzerospam_key_check() ) {
15
- return $honeypot;
16
- }
17
-
18
- do_action( 'wpzerospam_wpform_spam' );
19
-
20
- $data = [
21
- 'honeypot' => $honeypot,
22
- 'fields' => $fields,
23
- 'entry' => $entry,
24
- 'form_data' => $form_data
25
- ];
26
- wpzerospam_spam_detected( 'wpform', $data );
27
- }
28
- }
29
- add_filter( 'wpforms_process_honeypot', 'wpzerospam_wpforms_process_honeypot', 10, 4 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/css/admin-blocked-ips.css CHANGED
@@ -1,11 +1,31 @@
1
  .wpzerospam-add-ip-container {
2
  align-items: center;
 
 
 
3
  display: flex;
4
  flex-wrap: wrap;
5
  margin-left: -10px;
6
  margin-right: -10px;
 
7
  }
8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  .wpzerospam-add-ip-container h2,
10
  .wpzerospam-add-ip-field,
11
  .wpzerospam-add-ip-submit {
@@ -35,3 +55,8 @@
35
  #wpzerospam-add-ip-field-reason {
36
  flex-grow: 1;
37
  }
 
 
 
 
 
1
  .wpzerospam-add-ip-container {
2
  align-items: center;
3
+ background: #fff;
4
+ border: 1px solid #ccd0d4;
5
+ box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
6
  display: flex;
7
  flex-wrap: wrap;
8
  margin-left: -10px;
9
  margin-right: -10px;
10
+ padding: 20px;
11
  }
12
 
13
+ .wpzerospam-add-ip-container-highlight {
14
+ animation: wpzerospam-highlight 2s;
15
+ animation-fill-mode: forwards;
16
+ }
17
+
18
+ @keyframes wpzerospam-highlight {
19
+ 0% {
20
+ background: #fff;
21
+ }
22
+
23
+ 100% {
24
+ background: #FFF4DC;
25
+ }
26
+ }
27
+
28
+
29
  .wpzerospam-add-ip-container h2,
30
  .wpzerospam-add-ip-field,
31
  .wpzerospam-add-ip-submit {
55
  #wpzerospam-add-ip-field-reason {
56
  flex-grow: 1;
57
  }
58
+
59
+ #wpzerospam-add-ip-field-submit {
60
+ margin-top: 10px;
61
+ width: auto;
62
+ }
assets/js/{addons/wpzerospam-addon-cf7.js → integrations/wpzerospam-integration-cf7.js} RENAMED
@@ -1,7 +1,7 @@
1
  /**
2
  * WordPress Zero Spam addon for handling core CF7 submissions.
3
  */
4
- WordPressZeroSpamAddons.cf7 = {
5
  init: function() {
6
  // Make sure the WordPress Zero Spam key is available.
7
  if ( typeof wpzerospam.key == "undefined" ) { return; }
@@ -16,6 +16,12 @@ WordPressZeroSpamAddons.cf7 = {
16
  return true;
17
  }
18
 
 
 
 
 
 
 
19
  // Triggered when the comment form is submitted
20
  jQuery( ".wpcf7-submit", $form ).click( function() {
21
  // Make sure the WordPress Zero Spam key isn't already on the form, if
@@ -36,5 +42,5 @@ WordPressZeroSpamAddons.cf7 = {
36
  }
37
 
38
  jQuery(function() {
39
- WordPressZeroSpamAddons.cf7.init();
40
  });
1
  /**
2
  * WordPress Zero Spam addon for handling core CF7 submissions.
3
  */
4
+ WordPressZeroSpamIntegrations.cf7 = {
5
  init: function() {
6
  // Make sure the WordPress Zero Spam key is available.
7
  if ( typeof wpzerospam.key == "undefined" ) { return; }
16
  return true;
17
  }
18
 
19
+ console.log(
20
+ 'WordPress Zero Spam located ' + $form.length + ' CF7 form(s) (.wpcf7-form)'
21
+ );
22
+
23
+ $form.attr( 'data-wpzerospam', 'protected' );
24
+
25
  // Triggered when the comment form is submitted
26
  jQuery( ".wpcf7-submit", $form ).click( function() {
27
  // Make sure the WordPress Zero Spam key isn't already on the form, if
42
  }
43
 
44
  jQuery(function() {
45
+ WordPressZeroSpamIntegrations.cf7.init();
46
  });
assets/js/{addons/wpzerospam-addon-comments.js → integrations/wpzerospam-integration-comments.js} RENAMED
@@ -1,7 +1,7 @@
1
  /**
2
  * WordPress Zero Spam addon for handling core comment submissions.
3
  */
4
- WordPressZeroSpamAddons.comments = {
5
  init: function() {
6
  // Make sure the WordPress Zero Spam key is available.
7
  if ( typeof wpzerospam.key == "undefined" ) { return; }
@@ -16,6 +16,12 @@ WordPressZeroSpamAddons.comments = {
16
  return true;
17
  }
18
 
 
 
 
 
 
 
19
  // Triggered when the comment form is submitted
20
  $form.on( "submit", function() {
21
  // Make sure the WordPress Zero Spam key isn't already on the form, if
@@ -36,5 +42,5 @@ WordPressZeroSpamAddons.comments = {
36
  }
37
 
38
  jQuery(function() {
39
- WordPressZeroSpamAddons.comments.init();
40
  });
1
  /**
2
  * WordPress Zero Spam addon for handling core comment submissions.
3
  */
4
+ WordPressZeroSpamIntegrations.comments = {
5
  init: function() {
6
  // Make sure the WordPress Zero Spam key is available.
7
  if ( typeof wpzerospam.key == "undefined" ) { return; }
16
  return true;
17
  }
18
 
19
+ console.log(
20
+ 'WordPress Zero Spam located ' + $form.length + ' comment form(s) (#commentform)'
21
+ );
22
+
23
+ $form.attr( 'data-wpzerospam', 'protected' );
24
+
25
  // Triggered when the comment form is submitted
26
  $form.on( "submit", function() {
27
  // Make sure the WordPress Zero Spam key isn't already on the form, if
42
  }
43
 
44
  jQuery(function() {
45
+ WordPressZeroSpamIntegrations.comments.init();
46
  });
assets/js/{addons/wpzerospam-addon-registrations.js → integrations/wpzerospam-integration-registrations.js} RENAMED
@@ -1,7 +1,7 @@
1
  /**
2
- * WordPress Zero Spam addon for handling core comment submissions.
3
  */
4
- WordPressZeroSpamAddons.registrations = {
5
  init: function() {
6
  // Make sure the WordPress Zero Spam key is available.
7
  if ( typeof wpzerospam.key == "undefined" ) { return; }
@@ -16,6 +16,12 @@ WordPressZeroSpamAddons.registrations = {
16
  return true;
17
  }
18
 
 
 
 
 
 
 
19
  // Triggered when the comment form is submitted
20
  $form.on( "submit", function() {
21
  // Make sure the WordPress Zero Spam key isn't already on the form, if
@@ -36,5 +42,5 @@ WordPressZeroSpamAddons.registrations = {
36
  }
37
 
38
  jQuery(function() {
39
- WordPressZeroSpamAddons.registrations.init();
40
  });
1
  /**
2
+ * WordPress Zero Spam integration for handling core comment submissions.
3
  */
4
+ WordPressZeroSpamIntegrations.registrations = {
5
  init: function() {
6
  // Make sure the WordPress Zero Spam key is available.
7
  if ( typeof wpzerospam.key == "undefined" ) { return; }
16
  return true;
17
  }
18
 
19
+ console.log(
20
+ 'WordPress Zero Spam located ' + $form.length + ' registration form(s) (#registerform)'
21
+ );
22
+
23
+ $form.attr( 'data-wpzerospam', 'protected' );
24
+
25
  // Triggered when the comment form is submitted
26
  $form.on( "submit", function() {
27
  // Make sure the WordPress Zero Spam key isn't already on the form, if
42
  }
43
 
44
  jQuery(function() {
45
+ WordPressZeroSpamIntegrations.registrations.init();
46
  });
assets/js/integrations/wpzerospam-integration-wpforms.js ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * WordPress Zero Spam integration for handling WP forms.
3
+ */
4
+ WordPressZeroSpamIntegrations.wpforms = {
5
+ init: function() {
6
+ // Make sure the WordPress Zero Spam key is available.
7
+ if ( typeof wpzerospam.key == "undefined" ) { return; }
8
+
9
+ var $form = jQuery( '.wpforms-form' );
10
+
11
+ // If the form can't be found & should be, send a message to the console.
12
+ if ( ! $form.length ) {
13
+ console.log(
14
+ 'WordPress Zero Spam was unable to locate a WP Form (.wpforms-form)'
15
+ );
16
+ return true;
17
+ }
18
+
19
+ console.log(
20
+ 'WordPress Zero Spam located ' + $form.length + ' WP Form(s) (.wpforms-form)'
21
+ );
22
+
23
+ $form.attr( 'data-wpzerospam', 'protected' );
24
+
25
+ // Triggered when the comment form is submitted
26
+ $form.on( "submit", function() {
27
+ // Make sure the WordPress Zero Spam key isn't already on the form, if
28
+ // not, add it.
29
+ if ( ! jQuery( '[name="wpzerospam_key"]', jQuery( this ) ).length ) {
30
+ jQuery( "<input>" )
31
+ .attr( "type", "hidden" )
32
+ .attr( "name", "wpzerospam_key" )
33
+ .attr( "value", wpzerospam.key )
34
+ .appendTo( jQuery(this) );
35
+ } else {
36
+ jQuery( '[name="wpzerospam_key"]', jQuery( this ) ).value( wpzerospam.key );
37
+ }
38
+
39
+ return true;
40
+ });
41
+ }
42
+ }
43
+
44
+ jQuery(function() {
45
+ WordPressZeroSpamIntegrations.wpforms.init();
46
+ });
assets/js/wpzerospam.js CHANGED
@@ -36,8 +36,8 @@ var WordPressZeroSpam = {
36
  }
37
  };
38
 
39
- // Will hold the enqueues addons on request.
40
- var WordPressZeroSpamAddons = {};
41
 
42
  jQuery(function() {
43
  WordPressZeroSpam.init();
36
  }
37
  };
38
 
39
+ // Will hold the enqueues integrations on request.
40
+ var WordPressZeroSpamIntegrations = {};
41
 
42
  jQuery(function() {
43
  WordPressZeroSpam.init();
classes/class-wpzerospam-log-table.php CHANGED
@@ -36,6 +36,7 @@ class WPZeroSpam_Log_Table extends WP_List_Table {
36
  'region' => __( 'Region', 'wpzerospam' ),
37
  'city' => __( 'City', 'wpzerospam' ),
38
  'details' => __( 'Details', 'wpzerospam' ),
 
39
  ];
40
 
41
  return $columns;
@@ -67,6 +68,9 @@ class WPZeroSpam_Log_Table extends WP_List_Table {
67
  // Render column
68
  function column_default( $item, $column_name ) {
69
  switch( $column_name ) {
 
 
 
70
  case 'log_id':
71
  return $item->log_id;
72
  break;
36
  'region' => __( 'Region', 'wpzerospam' ),
37
  'city' => __( 'City', 'wpzerospam' ),
38
  'details' => __( 'Details', 'wpzerospam' ),
39
+ 'actions' => __( 'Block IP', 'wpzerospam' ),
40
  ];
41
 
42
  return $columns;
68
  // Render column
69
  function column_default( $item, $column_name ) {
70
  switch( $column_name ) {
71
+ case 'actions':
72
+ return '<a href="' . admin_url( 'admin.php?page=wordpress-zero-spam-blocked-ips&ip=' . $item->user_ip ) . '" class="button">' . __( 'Configure IP Block', 'wpzerospam' ) . '</a>';
73
+ break;
74
  case 'log_id':
75
  return $item->log_id;
76
  break;
inc/admin.php CHANGED
@@ -121,11 +121,17 @@ function wpzerospam_blocked_ips_page() {
121
  <?php endif; ?>
122
  <form method="post" action="<?php echo admin_url( 'admin.php' ); ?>">
123
  <input type="hidden" name="action" value="add_blocked_ip" />
124
- <div class="wpzerospam-add-ip-container">
125
  <h2><?php _e( 'Add Blocked IP', 'wpzerospam' ); ?></h2>
126
  <div class="wpzerospam-add-ip-field">
127
  <label for="blocked-ip"><?php _e( 'IP Address', 'wpzerospam' ); ?></label>
128
- <input type="text" id="blocked-ip" name="blocked_ip" value="" placeholder="e.g. xxx.xxx.x.x" />
 
 
 
 
 
 
129
  </div>
130
  <div class="wpzerospam-add-ip-field">
131
  <label for="blocked-type"><?php _e( 'Type', 'wpzerospam' ); ?></label>
@@ -146,8 +152,10 @@ function wpzerospam_blocked_ips_page() {
146
  <label for="blocked-end-date"><?php _e( 'End Date', 'wpzerospam' ); ?></label>
147
  <input type="datetime-local" id="blocked-end-date" name="blocked_end_date" value="" placeholder="<?php _e( 'Optional', 'wpzerospam' ); ?>" />
148
  </div>
 
 
 
149
  </div>
150
- <p style="margin-bottom: 2rem;"><input type="submit" class="button button-primary" value="<?php _e( 'Add Blocked IP', 'wpzerospam' ); ?>" /></p>
151
  </form>
152
 
153
 
121
  <?php endif; ?>
122
  <form method="post" action="<?php echo admin_url( 'admin.php' ); ?>">
123
  <input type="hidden" name="action" value="add_blocked_ip" />
124
+ <div class="wpzerospam-add-ip-container<?php if( ! empty( $_REQUEST['ip'] ) ): ?> wpzerospam-add-ip-container-highlight<?php endif; ?>">
125
  <h2><?php _e( 'Add Blocked IP', 'wpzerospam' ); ?></h2>
126
  <div class="wpzerospam-add-ip-field">
127
  <label for="blocked-ip"><?php _e( 'IP Address', 'wpzerospam' ); ?></label>
128
+ <input
129
+ type="text"
130
+ id="blocked-ip"
131
+ name="blocked_ip"
132
+ value="<?php if( ! empty( $_REQUEST['ip'] ) ): echo esc_attr( $_REQUEST['ip'] ); endif; ?>"
133
+ placeholder="e.g. xxx.xxx.x.x"
134
+ />
135
  </div>
136
  <div class="wpzerospam-add-ip-field">
137
  <label for="blocked-type"><?php _e( 'Type', 'wpzerospam' ); ?></label>
152
  <label for="blocked-end-date"><?php _e( 'End Date', 'wpzerospam' ); ?></label>
153
  <input type="datetime-local" id="blocked-end-date" name="blocked_end_date" value="" placeholder="<?php _e( 'Optional', 'wpzerospam' ); ?>" />
154
  </div>
155
+ <div class="wpzerospam-add-ip-field" id="wpzerospam-add-ip-field-submit">
156
+ <input type="submit" class="button button-primary" value="<?php _e( 'Add Blocked IP', 'wpzerospam' ); ?>" />
157
+ </div>
158
  </div>
 
159
  </form>
160
 
161
 
inc/locations.php CHANGED
@@ -323,7 +323,47 @@ if ( ! function_exists( 'wpzerospam_get_location' ) ) {
323
  ],
324
  'CA' => [
325
  'name' => 'Canada',
326
- 'regions' => []
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
327
  ],
328
  'CV' => [
329
  'name' => 'Cape Verde',
323
  ],
324
  'CA' => [
325
  'name' => 'Canada',
326
+ 'regions' => [
327
+ 'AB' => [
328
+ 'name' => 'Alberta'
329
+ ],
330
+ 'BC' => [
331
+ 'name' => 'British Columbia'
332
+ ],
333
+ 'MB' => [
334
+ 'name' => 'Manitoba'
335
+ ],
336
+ 'NB' => [
337
+ 'name' => 'New Brunswick'
338
+ ],
339
+ 'NL' => [
340
+ 'name' => 'Newfoundland and Labrador'
341
+ ],
342
+ 'NS' => [
343
+ 'name' => 'Nova Scotia'
344
+ ],
345
+ 'ON' => [
346
+ 'name' => 'Ontario'
347
+ ],
348
+ 'PE' => [
349
+ 'name' => 'Prince Edward Island'
350
+ ],
351
+ 'QC' => [
352
+ 'name' => 'Quebec'
353
+ ],
354
+ 'SK' => [
355
+ 'name' => 'Saskatchewan'
356
+ ],
357
+ 'NT' => [
358
+ 'name' => 'Northwest Territories'
359
+ ],
360
+ 'NU' => [
361
+ 'name' => 'Nunavut'
362
+ ],
363
+ 'YT' => [
364
+ 'name' => 'Yukon'
365
+ ]
366
+ ]
367
  ],
368
  'CV' => [
369
  'name' => 'Cape Verde',
inc/scripts.php CHANGED
@@ -11,12 +11,6 @@
11
  */
12
  if ( ! function_exists( 'wpzerospam_admin_scripts' ) ) {
13
  function wpzerospam_admin_scripts( $hook_suffix ) {
14
- // Retrieve the current plugin data (used to get the scripts version)
15
- if( ! function_exists('get_plugin_data') ) {
16
- require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
17
- }
18
- $plugin = get_plugin_data( WORDPRESS_ZERO_SPAM );
19
-
20
  // Handle registering & enqueuing scripts based on the current admin page
21
  switch( $hook_suffix ) {
22
  case 'toplevel_page_wordpress-zero-spam':
@@ -44,7 +38,7 @@ if ( ! function_exists( 'wpzerospam_admin_scripts' ) ) {
44
  plugin_dir_url( WORDPRESS_ZERO_SPAM ) .
45
  '/assets/js/admin-dashboard.js',
46
  [ 'jquery', 'wpzerospam-charts' ],
47
- $plugin['Version'],
48
  true
49
  );
50
 
@@ -54,7 +48,7 @@ if ( ! function_exists( 'wpzerospam_admin_scripts' ) ) {
54
  plugin_dir_url( WORDPRESS_ZERO_SPAM ) .
55
  '/assets/css/admin-dashboard.css',
56
  false,
57
- $plugin['Version']
58
  );
59
  break;
60
  case 'wp-zero-spam_page_wordpress-zero-spam-blocked-ips':
@@ -64,7 +58,7 @@ if ( ! function_exists( 'wpzerospam_admin_scripts' ) ) {
64
  plugin_dir_url( WORDPRESS_ZERO_SPAM ) .
65
  '/assets/js/admin-blocked-ips.js',
66
  [ 'jquery' ],
67
- $plugin['Version'],
68
  true
69
  );
70
 
@@ -74,7 +68,7 @@ if ( ! function_exists( 'wpzerospam_admin_scripts' ) ) {
74
  plugin_dir_url( WORDPRESS_ZERO_SPAM ) .
75
  '/assets/css/admin-blocked-ips.css',
76
  false,
77
- $plugin['Version']
78
  );
79
  break;
80
  }
@@ -87,12 +81,6 @@ add_action( 'admin_enqueue_scripts', 'wpzerospam_admin_scripts' );
87
  */
88
  if ( ! function_exists( 'wpzerospam_enqueue_scripts' ) ) {
89
  function wpzerospam_enqueue_scripts() {
90
- // Retrieve the current plugin data (used to get the scripts version)
91
- if( ! function_exists('get_plugin_data') ) {
92
- require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
93
- }
94
- $plugin = get_plugin_data( WORDPRESS_ZERO_SPAM );
95
-
96
  // Load the JS that contains the WordPressZeroSpam oject, needed on all
97
  // pages
98
  wp_enqueue_script(
@@ -100,7 +88,7 @@ if ( ! function_exists( 'wpzerospam_enqueue_scripts' ) ) {
100
  plugin_dir_url( WORDPRESS_ZERO_SPAM ) .
101
  '/assets/js/wpzerospam.js',
102
  [ 'jquery' ],
103
- $plugin['Version'],
104
  true
105
  );
106
 
11
  */
12
  if ( ! function_exists( 'wpzerospam_admin_scripts' ) ) {
13
  function wpzerospam_admin_scripts( $hook_suffix ) {
 
 
 
 
 
 
14
  // Handle registering & enqueuing scripts based on the current admin page
15
  switch( $hook_suffix ) {
16
  case 'toplevel_page_wordpress-zero-spam':
38
  plugin_dir_url( WORDPRESS_ZERO_SPAM ) .
39
  '/assets/js/admin-dashboard.js',
40
  [ 'jquery', 'wpzerospam-charts' ],
41
+ WORDPRESS_ZERO_SPAM_VERSION,
42
  true
43
  );
44
 
48
  plugin_dir_url( WORDPRESS_ZERO_SPAM ) .
49
  '/assets/css/admin-dashboard.css',
50
  false,
51
+ WORDPRESS_ZERO_SPAM_VERSION
52
  );
53
  break;
54
  case 'wp-zero-spam_page_wordpress-zero-spam-blocked-ips':
58
  plugin_dir_url( WORDPRESS_ZERO_SPAM ) .
59
  '/assets/js/admin-blocked-ips.js',
60
  [ 'jquery' ],
61
+ WORDPRESS_ZERO_SPAM_VERSION,
62
  true
63
  );
64
 
68
  plugin_dir_url( WORDPRESS_ZERO_SPAM ) .
69
  '/assets/css/admin-blocked-ips.css',
70
  false,
71
+ WORDPRESS_ZERO_SPAM_VERSION
72
  );
73
  break;
74
  }
81
  */
82
  if ( ! function_exists( 'wpzerospam_enqueue_scripts' ) ) {
83
  function wpzerospam_enqueue_scripts() {
 
 
 
 
 
 
84
  // Load the JS that contains the WordPressZeroSpam oject, needed on all
85
  // pages
86
  wp_enqueue_script(
88
  plugin_dir_url( WORDPRESS_ZERO_SPAM ) .
89
  '/assets/js/wpzerospam.js',
90
  [ 'jquery' ],
91
+ WORDPRESS_ZERO_SPAM_VERSION,
92
  true
93
  );
94
 
inc/updates.php CHANGED
@@ -16,6 +16,25 @@
16
  add_action( 'admin_init', function() {
17
  $options = wpzerospam_options();
18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  if ( ! empty( $options['blocked_ips'] ) ) {
20
  // IPs found, transfer them to the database
21
  foreach( $options['blocked_ips'] as $key => $ip ) {
16
  add_action( 'admin_init', function() {
17
  $options = wpzerospam_options();
18
 
19
+ if( ! function_exists( 'is_plugin_active' ) ) {
20
+ require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
21
+ }
22
+
23
+ // Deactive deprecated versions of the plugin & activate the new one
24
+ if (
25
+ is_plugin_active( 'zero-spam/zero-spam.php' ) &&
26
+ function_exists( 'deactivate_plugins' )
27
+ ) {
28
+ deactivate_plugins( 'zero-spam/zero-spam.php', false, true );
29
+ }
30
+
31
+ if (
32
+ ! is_plugin_active( 'zero-spam/wordpress-zero-spam.php' ) &&
33
+ function_exists( 'activate_plugin' )
34
+ ) {
35
+ activate_plugin( 'zero-spam/wordpress-zero-spam.php', '', true );
36
+ }
37
+
38
  if ( ! empty( $options['blocked_ips'] ) ) {
39
  // IPs found, transfer them to the database
40
  foreach( $options['blocked_ips'] as $key => $ip ) {
{addons → integrations}/buddypress.php RENAMED
File without changes
{addons → integrations}/comments.php RENAMED
@@ -37,19 +37,13 @@ if ( ! function_exists( 'wpzerospam_comment_form' ) ) {
37
  $options = get_option( 'wpzerospam' );
38
  if ( 'enabled' != $options['verify_comments'] ) { return; }
39
 
40
- // Retrieve the current plugin data (used to get the scripts version)
41
- if( ! function_exists('get_plugin_data') ) {
42
- require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
43
- }
44
- $plugin = get_plugin_data( WORDPRESS_ZERO_SPAM );
45
-
46
- // WordPress Zero Spam comment addon
47
  wp_enqueue_script(
48
- 'wpzerospam-addon-comments',
49
  plugin_dir_url( WORDPRESS_ZERO_SPAM ) .
50
- '/assets/js/addons/wpzerospam-addon-comments.js',
51
  [ 'wpzerospam' ],
52
- $plugin['Version'],
53
  true
54
  );
55
  }
37
  $options = get_option( 'wpzerospam' );
38
  if ( 'enabled' != $options['verify_comments'] ) { return; }
39
 
40
+ // WordPress Zero Spam comment integration
 
 
 
 
 
 
41
  wp_enqueue_script(
42
+ 'wpzerospam-integration-comments',
43
  plugin_dir_url( WORDPRESS_ZERO_SPAM ) .
44
+ '/assets/js/integrations/wpzerospam-integration-comments.js',
45
  [ 'wpzerospam' ],
46
+ WORDPRESS_ZERO_SPAM_VERSION,
47
  true
48
  );
49
  }
{addons → integrations}/contact-form-7.php RENAMED
@@ -27,18 +27,12 @@ add_action( 'wpcf7_validate', 'wpzerospam_wpcf7_validate' );
27
  */
28
  if ( ! function_exists( 'wpzerospam_cf7' ) ) {
29
  function wpzerospam_cf7() {
30
- // Retrieve the current plugin data (used to get the scripts version)
31
- if( ! function_exists('get_plugin_data') ) {
32
- require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
33
- }
34
- $plugin = get_plugin_data( WORDPRESS_ZERO_SPAM );
35
-
36
  wp_enqueue_script(
37
- 'wpzerospam-addon-cf7',
38
  plugin_dir_url( WORDPRESS_ZERO_SPAM ) .
39
- '/assets/js/addons/wpzerospam-addon-cf7.js',
40
  [ 'wpzerospam' ],
41
- $plugin['Version'],
42
  true
43
  );
44
  }
27
  */
28
  if ( ! function_exists( 'wpzerospam_cf7' ) ) {
29
  function wpzerospam_cf7() {
 
 
 
 
 
 
30
  wp_enqueue_script(
31
+ 'wpzerospam-integration-cf7',
32
  plugin_dir_url( WORDPRESS_ZERO_SPAM ) .
33
+ '/assets/js/integrations/wpzerospam-integration-cf7.js',
34
  [ 'wpzerospam' ],
35
+ WORDPRESS_ZERO_SPAM_VERSION,
36
  true
37
  );
38
  }
{addons → integrations}/gravity-forms.php RENAMED
File without changes
{addons → integrations}/ninja-forms.php RENAMED
File without changes
{addons → integrations}/registration.php RENAMED
@@ -40,19 +40,13 @@ if ( ! function_exists( 'wpzerospam_registration_form' ) ) {
40
  $options = get_option( 'wpzerospam' );
41
  if ( 'enabled' != $options['verify_registrations'] ) { return; }
42
 
43
- // Retrieve the current plugin data (used to get the scripts version)
44
- if( ! function_exists('get_plugin_data') ) {
45
- require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
46
- }
47
- $plugin = get_plugin_data( WORDPRESS_ZERO_SPAM );
48
-
49
- // WordPress Zero Spam registration addon
50
  wp_enqueue_script(
51
- 'wpzerospam-addon-registrations',
52
  plugin_dir_url( WORDPRESS_ZERO_SPAM ) .
53
- '/assets/js/addons/wpzerospam-addon-registrations.js',
54
  [ 'wpzerospam' ],
55
- $plugin['Version'],
56
  true
57
  );
58
  }
40
  $options = get_option( 'wpzerospam' );
41
  if ( 'enabled' != $options['verify_registrations'] ) { return; }
42
 
43
+ // WordPress Zero Spam registration integration
 
 
 
 
 
 
44
  wp_enqueue_script(
45
+ 'wpzerospam-integration-registrations',
46
  plugin_dir_url( WORDPRESS_ZERO_SPAM ) .
47
+ '/assets/js/integrations/wpzerospam-integration-registrations.js',
48
  [ 'wpzerospam' ],
49
+ WORDPRESS_ZERO_SPAM_VERSION,
50
  true
51
  );
52
  }
integrations/wpforms.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Handles checking submitted WPForms submissions
4
+ *
5
+ * @package WordPressZeroSpam
6
+ * @since 4.1.0
7
+ */
8
+
9
+ /**
10
+ * Validation for WPForms submissions
11
+ *
12
+ * @link https://wpforms.com/developers/wpforms_process_before/
13
+ */
14
+ if ( ! function_exists( 'wpzerospam_wpforms_process_before' ) ) {
15
+ function wpzerospam_wpforms_process_before( $entry, $form_data ) {
16
+ if ( is_user_logged_in() || wpzerospam_key_check() ) {
17
+ return;
18
+ }
19
+
20
+ do_action( 'wpzerospam_wpform_spam' );
21
+
22
+ $data = [
23
+ 'entry' => $entry,
24
+ 'form_data' => $form_data
25
+ ];
26
+ wpzerospam_spam_detected( 'wpform', $data );
27
+ }
28
+ }
29
+ add_action( 'wpforms_process_before', 'wpzerospam_wpforms_process_before', 10, 2 );
30
+
31
+ /**
32
+ * Enqueue the CF7 form JS
33
+ */
34
+ if ( ! function_exists( 'wpzerospam_wpforms' ) ) {
35
+ function wpzerospam_wpforms() {
36
+ wp_enqueue_script(
37
+ 'wpzerospam-integration-wpforms',
38
+ plugin_dir_url( WORDPRESS_ZERO_SPAM ) .
39
+ '/assets/js/integrations/wpzerospam-integration-wpforms.js',
40
+ [ 'wpzerospam' ],
41
+ WORDPRESS_ZERO_SPAM_VERSION,
42
+ true
43
+ );
44
+ }
45
+ }
46
+ add_action( 'wpforms_frontend_output_before', 'wpzerospam_wpforms' );
readme.txt CHANGED
@@ -5,7 +5,7 @@ Donate link: https://benmarshall.me/donate/?utm_source=wordpress_zero_spam&utm_m
5
  Requires at least: 5.2
6
  Tested up to: 5.4.2
7
  Requires PHP: 7.1
8
- Stable tag: 4.3.9
9
  License: GNU GPLv3
10
  License URI: https://choosealicense.com/licenses/gpl-3.0/
11
 
@@ -92,6 +92,14 @@ Yes, that's what does the magic and keeps spam bots out.
92
 
93
  == Changelog ==
94
 
 
 
 
 
 
 
 
 
95
  = 4.3.9 =
96
 
97
  * Fix for `Notice: Undefined index: verify_ninja_form`. See [#195](https://github.com/bmarshall511/wordpress-zero-spam/issues/195)
5
  Requires at least: 5.2
6
  Tested up to: 5.4.2
7
  Requires PHP: 7.1
8
+ Stable tag: 4.3.10
9
  License: GNU GPLv3
10
  License URI: https://choosealicense.com/licenses/gpl-3.0/
11
 
92
 
93
  == Changelog ==
94
 
95
+ = 4.3.10 =
96
+
97
+ * Updated get_plugin_data calls to use a constant. See [#196](https://github.com/bmarshall511/wordpress-zero-spam/issues/196)
98
+ * Added additional country regions for geolocation lookup
99
+ * Renamed 'addons' to 'integrations'
100
+ * Fixed issue with WPForm spam detections
101
+ * Fix for plugin deactivation from v3 to v4 upgrade
102
+
103
  = 4.3.9 =
104
 
105
  * Fix for `Notice: Undefined index: verify_ninja_form`. See [#195](https://github.com/bmarshall511/wordpress-zero-spam/issues/195)
wordpress-zero-spam.php CHANGED
@@ -13,7 +13,7 @@
13
  * Plugin Name: WordPress Zero Spam
14
  * Plugin URI: https://benmarshall.me/wordpress-zero-spam
15
  * Description: Tired of all the useless and bloated WordPress spam plugins? The WordPress Zero Spam plugin makes blocking spam a cinch. <strong>Just install, activate and say goodbye to spam.</strong> Based on work by <a href="http://davidwalsh.name/wordpress-comment-spam" target="_blank">David Walsh</a>.
16
- * Version: 4.3.9
17
  * Requires at least: 5.2
18
  * Requires PHP: 7.2
19
  * Author: Ben Marshall
@@ -31,6 +31,7 @@ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
31
  // Define plugin constants
32
  define( 'WORDPRESS_ZERO_SPAM', __FILE__ );
33
  define( 'WORDPRESS_ZERO_SPAM_DB_VERSION', '0.1' );
 
34
 
35
  /**
36
  * Helpers
@@ -109,29 +110,29 @@ require plugin_dir_path( WORDPRESS_ZERO_SPAM ) . '/inc/scripts.php';
109
  require plugin_dir_path( WORDPRESS_ZERO_SPAM ) . '/inc/admin.php';
110
 
111
  /**
112
- * Below are the includes for individual spam check addons
113
  */
114
- require plugin_dir_path( WORDPRESS_ZERO_SPAM ) . '/addons/comments.php';
115
- require plugin_dir_path( WORDPRESS_ZERO_SPAM ) . '/addons/registration.php';
116
 
117
  if ( wpzerospam_plugin_integration_enabled( 'cf7' ) ) {
118
- require plugin_dir_path( WORDPRESS_ZERO_SPAM ) . '/addons/contact-form-7.php';
119
  }
120
 
121
  if ( wpzerospam_plugin_integration_enabled( 'gforms' ) ) {
122
- require plugin_dir_path( WORDPRESS_ZERO_SPAM ) . '/addons/gravity-forms.php';
123
  }
124
 
125
  if ( wpzerospam_plugin_integration_enabled( 'ninja_forms' ) ) {
126
- require plugin_dir_path( WORDPRESS_ZERO_SPAM ) . '/addons/ninja-forms.php';
127
  }
128
 
129
  if ( wpzerospam_plugin_integration_enabled( 'bp_registrations' ) ) {
130
- require plugin_dir_path( WORDPRESS_ZERO_SPAM ) . '/addons/buddypress.php';
131
  }
132
 
133
  if ( wpzerospam_plugin_integration_enabled( 'wpforms' ) ) {
134
- require plugin_dir_path( WORDPRESS_ZERO_SPAM ) . '/addons/wpforms.php';
135
  }
136
 
137
  /**
13
  * Plugin Name: WordPress Zero Spam
14
  * Plugin URI: https://benmarshall.me/wordpress-zero-spam
15
  * Description: Tired of all the useless and bloated WordPress spam plugins? The WordPress Zero Spam plugin makes blocking spam a cinch. <strong>Just install, activate and say goodbye to spam.</strong> Based on work by <a href="http://davidwalsh.name/wordpress-comment-spam" target="_blank">David Walsh</a>.
16
+ * Version: 4.3.10
17
  * Requires at least: 5.2
18
  * Requires PHP: 7.2
19
  * Author: Ben Marshall
31
  // Define plugin constants
32
  define( 'WORDPRESS_ZERO_SPAM', __FILE__ );
33
  define( 'WORDPRESS_ZERO_SPAM_DB_VERSION', '0.1' );
34
+ define( 'WORDPRESS_ZERO_SPAM_VERSION', '4.3.10' );
35
 
36
  /**
37
  * Helpers
110
  require plugin_dir_path( WORDPRESS_ZERO_SPAM ) . '/inc/admin.php';
111
 
112
  /**
113
+ * Below are the includes for individual spam check integrations
114
  */
115
+ require plugin_dir_path( WORDPRESS_ZERO_SPAM ) . '/integrations/comments.php';
116
+ require plugin_dir_path( WORDPRESS_ZERO_SPAM ) . '/integrations/registration.php';
117
 
118
  if ( wpzerospam_plugin_integration_enabled( 'cf7' ) ) {
119
+ require plugin_dir_path( WORDPRESS_ZERO_SPAM ) . '/integrations/contact-form-7.php';
120
  }
121
 
122
  if ( wpzerospam_plugin_integration_enabled( 'gforms' ) ) {
123
+ require plugin_dir_path( WORDPRESS_ZERO_SPAM ) . '/integrations/gravity-forms.php';
124
  }
125
 
126
  if ( wpzerospam_plugin_integration_enabled( 'ninja_forms' ) ) {
127
+ require plugin_dir_path( WORDPRESS_ZERO_SPAM ) . '/integrations/ninja-forms.php';
128
  }
129
 
130
  if ( wpzerospam_plugin_integration_enabled( 'bp_registrations' ) ) {
131
+ require plugin_dir_path( WORDPRESS_ZERO_SPAM ) . '/integrations/buddypress.php';
132
  }
133
 
134
  if ( wpzerospam_plugin_integration_enabled( 'wpforms' ) ) {
135
+ require plugin_dir_path( WORDPRESS_ZERO_SPAM ) . '/integrations/wpforms.php';
136
  }
137
 
138
  /**