WordPress Zero Spam - Version 4.10.1

Version Description

  • Fix - PHP notice Warning: array_merge(): Expected parameter 2 to be an array, bool given in /wp-content/plugins/zero-spam/classes/class-wordpress-zero-spam.php on line 532. See https://wordpress.org/support/topic/warning-array_merge-14/#post-13319702.
  • Fix - StopForumSpam & BotScout being queried even if the options are disabled. See https://wordpress.org/support/topic/api-timeout/#post-13323551.
  • Enhancement - Moved the security functions into the new WordPress_Zero_Spam_Security class.
  • Enhancement - General code clean-up & documentation.
Download this release

Release Info

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

Code changes from version 4.10.0 to 4.10.1

classes/class-wpzerospam-comments.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * WordPress Zero Spam comments class.
4
+ *
5
+ * @package WordPressZeroSpam
6
+ */
7
+
8
+ // Security Note: Blocks direct access to the plugin PHP files.
9
+ defined( 'ABSPATH' ) || die();
10
+
11
+ /**
12
+ * WordPress Zero Spam comments class.
13
+ */
14
+ class WPZeroSpam_Comments {
15
+
16
+ }
classes/class-wpzerospam-security.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * WordPress Zero Spam security class.
4
+ *
5
+ * @package WordPressZeroSpam
6
+ */
7
+
8
+ // Security Note: Blocks direct access to the plugin PHP files.
9
+ defined( 'ABSPATH' ) || die();
10
+
11
+ /**
12
+ * WordPress Zero Spam security class.
13
+ */
14
+ class WPZeroSpam_Security {
15
+ /**
16
+ * Class constructor.
17
+ */
18
+ public function __construct() {
19
+ // Removes the meta generator tag.
20
+ add_action( 'after_setup_theme', array( $this, 'after_setup_theme' ) );
21
+ }
22
+
23
+ /**
24
+ * Removes the meta generator tag.
25
+ */
26
+ public function after_setup_theme() {
27
+ // Remove the meta generator tag.
28
+ remove_action( 'wp_head', 'wp_generator' );
29
+ add_filter(
30
+ 'the_generator',
31
+ function() {
32
+ return '';
33
+ }
34
+ );
35
+ }
36
+ }
classes/{class-wordpress-zero-spam.php → class-wpzerospam.php} RENAMED
@@ -11,7 +11,7 @@ defined( 'ABSPATH' ) || die();
11
  /**
12
  * WordPress Zero Spam class.
13
  */
14
- class WordPress_Zero_Spam {
15
  /**
16
  * Contains all plugin options.
17
  *
@@ -31,6 +31,7 @@ class WordPress_Zero_Spam {
31
  'log_spam' => false,
32
  'log_blocked_ips' => false,
33
  'share_detections' => true,
 
34
  'stopforumspam_confidence_min' => 20,
35
  'botscout_count_min' => 5,
36
  'botscout_api' => false,
@@ -66,16 +67,40 @@ class WordPress_Zero_Spam {
66
  * Class constructor.
67
  */
68
  public function __construct() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
  // Triggered on the WP init action.
70
  add_action( 'init', array( $this, 'wp_init' ) );
71
 
72
  // Triggered on the WP wp_footer action.
73
  add_action( 'wp_footer', array( $this, 'wp_footer' ) );
74
 
 
 
 
75
  // Handles IPs that have been denied access.
76
  add_action( 'template_redirect', array( $this, 'access_check' ) );
77
  }
78
 
 
 
 
 
 
 
 
79
  /**
80
  * Checks is an IP is safe (i.e. from a known bot or crawler)
81
  */
@@ -105,6 +130,10 @@ class WordPress_Zero_Spam {
105
  'ia_archiver',
106
  );
107
 
 
 
 
 
108
  $ip_host = gethostbyaddr( $this->current_user_ip );
109
  $user_agent = ! empty( $_SERVER['HTTP_USER_AGENT'] ) ? esc_html( $_SERVER['HTTP_USER_AGENT'] ) : false;
110
 
@@ -144,6 +173,10 @@ class WordPress_Zero_Spam {
144
  'attempts' => false,
145
  );
146
 
 
 
 
 
147
  // Ignore logged in users.
148
  if ( is_user_logged_in() ) {
149
  $access['access_checked'] = 'authenticated';
@@ -366,7 +399,9 @@ class WordPress_Zero_Spam {
366
  }
367
 
368
  /**
369
- * Returns the current URL.
 
 
370
  */
371
  public function get_current_url() {
372
  global $wp;
@@ -375,7 +410,9 @@ class WordPress_Zero_Spam {
375
  }
376
 
377
  /**
378
- * Retreives an IP geolocation.
 
 
379
  */
380
  public function get_ip_geolocation( $ip ) {
381
  if ( empty( $this->options['ipstack_api'] ) ) {
@@ -498,15 +535,6 @@ class WordPress_Zero_Spam {
498
  * Triggered on the WP init action.
499
  */
500
  public function wp_init() {
501
- global $wpdb;
502
-
503
- // Set the database tables.
504
- $this->tables = array(
505
- 'log' => $wpdb->prefix . 'wpzerospam_log',
506
- 'blocked' => $wpdb->prefix . 'wpzerospam_blocked',
507
- 'blacklist' => $wpdb->prefix . 'wpzerospam_blacklist',
508
- );
509
-
510
  // Set the plugin options.
511
  $this->options = $this->get_options();
512
  if ( empty( $this->options['blocked_message'] ) ) {
@@ -528,8 +556,13 @@ class WordPress_Zero_Spam {
528
  * Returns the saved plugin options.
529
  */
530
  public function get_options() {
 
 
 
 
 
531
  $options = $this->default_options;
532
- $options = array_merge( $options, get_option( 'wpzerospam' ) );
533
  $options = apply_filters( 'wpzerospam_options', $options );
534
 
535
  return $options;
@@ -621,10 +654,11 @@ class WordPress_Zero_Spam {
621
  }
622
 
623
  /**
624
- * Gets an IP from an API.
625
  *
626
  * @param string $ip IP address to query.
627
- * @param string $api The API to query.
 
628
  */
629
  public function get_ip_from_api( $ip, $api ) {
630
  $cache_key = sanitize_title( $api . '_' . $ip );
@@ -633,6 +667,10 @@ class WordPress_Zero_Spam {
633
  if ( false === $data ) {
634
  switch ( $api ) {
635
  case 'stopforumspam':
 
 
 
 
636
  $api_url = 'https://api.stopforumspam.org/api?';
637
  $params = array(
638
  'ip' => $ip,
@@ -640,6 +678,10 @@ class WordPress_Zero_Spam {
640
  );
641
  break;
642
  case 'botscout':
 
 
 
 
643
  $api_url = 'https://botscout.com/test/?';
644
  $params = array(
645
  'ip' => $ip,
@@ -712,9 +754,10 @@ class WordPress_Zero_Spam {
712
  }
713
 
714
  /**
715
- * Checks if an IP has been blacklisted.
716
  *
717
  * @param string $ip The IP address to check.
 
718
  */
719
  public function get_blacklisted_ip( $ip ) {
720
  $blacklisted_ip = $this->table_query(
@@ -744,9 +787,10 @@ class WordPress_Zero_Spam {
744
  }
745
 
746
  /**
747
- * Checks if an IP has been blocked.
748
  *
749
  * @param string $ip The IP address to check.
 
750
  */
751
  public function get_blocked_ip( $ip ) {
752
  $blocked_ip = $this->table_query(
@@ -852,6 +896,8 @@ class WordPress_Zero_Spam {
852
 
853
  /**
854
  * Returns the whitelisted IPs.
 
 
855
  */
856
  public function get_whitelisted_ips() {
857
  $whitelist = explode( PHP_EOL, $this->options['ip_whitelist'] );
11
  /**
12
  * WordPress Zero Spam class.
13
  */
14
+ class WPZeroSpam {
15
  /**
16
  * Contains all plugin options.
17
  *
31
  'log_spam' => false,
32
  'log_blocked_ips' => false,
33
  'share_detections' => true,
34
+ 'stop_forum_spam' => 'enabled',
35
  'stopforumspam_confidence_min' => 20,
36
  'botscout_count_min' => 5,
37
  'botscout_api' => false,
67
  * Class constructor.
68
  */
69
  public function __construct() {
70
+ global $wpdb;
71
+
72
+ // Set the database tables.
73
+ $this->tables = array(
74
+ 'log' => $wpdb->prefix . 'wpzerospam_log',
75
+ 'blocked' => $wpdb->prefix . 'wpzerospam_blocked',
76
+ 'blacklist' => $wpdb->prefix . 'wpzerospam_blacklist',
77
+ );
78
+ }
79
+
80
+ /**
81
+ * Initializes the plugin.
82
+ */
83
+ public function initialize() {
84
  // Triggered on the WP init action.
85
  add_action( 'init', array( $this, 'wp_init' ) );
86
 
87
  // Triggered on the WP wp_footer action.
88
  add_action( 'wp_footer', array( $this, 'wp_footer' ) );
89
 
90
+ // Triggered on he WP plugins_loaded action.
91
+ add_action( 'plugins_loaded', array( $this, 'plugins_loaded' ) );
92
+
93
  // Handles IPs that have been denied access.
94
  add_action( 'template_redirect', array( $this, 'access_check' ) );
95
  }
96
 
97
+ /**
98
+ * Loads the plugin text domain.
99
+ */
100
+ public function plugins_loaded() {
101
+ load_plugin_textdomain( 'zero-spam', '', basename( dirname( WORDPRESS_ZERO_SPAM ) ) . '/languages/' );
102
+ }
103
+
104
  /**
105
  * Checks is an IP is safe (i.e. from a known bot or crawler)
106
  */
130
  'ia_archiver',
131
  );
132
 
133
+ if ( ! $this->current_user_ip ) {
134
+ return false;
135
+ }
136
+
137
  $ip_host = gethostbyaddr( $this->current_user_ip );
138
  $user_agent = ! empty( $_SERVER['HTTP_USER_AGENT'] ) ? esc_html( $_SERVER['HTTP_USER_AGENT'] ) : false;
139
 
173
  'attempts' => false,
174
  );
175
 
176
+ if ( ! $ip ) {
177
+ return $access;
178
+ }
179
+
180
  // Ignore logged in users.
181
  if ( is_user_logged_in() ) {
182
  $access['access_checked'] = 'authenticated';
399
  }
400
 
401
  /**
402
+ * Returns the current page URL.
403
+ *
404
+ * @return string The current page URL.
405
  */
406
  public function get_current_url() {
407
  global $wp;
410
  }
411
 
412
  /**
413
+ * Retrieves an IP geolocation.
414
+ *
415
+ * @param string $ip The IP to get geolocation information for.
416
  */
417
  public function get_ip_geolocation( $ip ) {
418
  if ( empty( $this->options['ipstack_api'] ) ) {
535
  * Triggered on the WP init action.
536
  */
537
  public function wp_init() {
 
 
 
 
 
 
 
 
 
538
  // Set the plugin options.
539
  $this->options = $this->get_options();
540
  if ( empty( $this->options['blocked_message'] ) ) {
556
  * Returns the saved plugin options.
557
  */
558
  public function get_options() {
559
+ $saved_options = get_option( 'wpzerospam' );
560
+ if ( ! $saved_options || ! is_array( $saved_options ) ) {
561
+ $saved_options = array();
562
+ }
563
+
564
  $options = $this->default_options;
565
+ $options = array_merge( $options, $saved_options );
566
  $options = apply_filters( 'wpzerospam_options', $options );
567
 
568
  return $options;
654
  }
655
 
656
  /**
657
+ * Checks an IP using a third-party API.
658
  *
659
  * @param string $ip IP address to query.
660
+ * @param string $api The API to query. stopforumspam | botscout.
661
+ * @return array The API query result.
662
  */
663
  public function get_ip_from_api( $ip, $api ) {
664
  $cache_key = sanitize_title( $api . '_' . $ip );
667
  if ( false === $data ) {
668
  switch ( $api ) {
669
  case 'stopforumspam':
670
+ if ( 'enabled' !== $this->options['stop_forum_spam'] ) {
671
+ return false;
672
+ }
673
+
674
  $api_url = 'https://api.stopforumspam.org/api?';
675
  $params = array(
676
  'ip' => $ip,
678
  );
679
  break;
680
  case 'botscout':
681
+ if ( ! $this->options['botscout_api'] ) {
682
+ return false;
683
+ }
684
+
685
  $api_url = 'https://botscout.com/test/?';
686
  $params = array(
687
  'ip' => $ip,
754
  }
755
 
756
  /**
757
+ * Checks if an IP has been blacklisted & returns the record if found.
758
  *
759
  * @param string $ip The IP address to check.
760
+ * @return array|false The blacklisted API record or false if not found.
761
  */
762
  public function get_blacklisted_ip( $ip ) {
763
  $blacklisted_ip = $this->table_query(
787
  }
788
 
789
  /**
790
+ * Checks if an IP has been blocked & returns the record if found.
791
  *
792
  * @param string $ip The IP address to check.
793
+ * @return array|false The blocked API record or false if not found.
794
  */
795
  public function get_blocked_ip( $ip ) {
796
  $blocked_ip = $this->table_query(
896
 
897
  /**
898
  * Returns the whitelisted IPs.
899
+ *
900
+ * @return array Array of whitelisted IP addresses defined in the plugin settings.
901
  */
902
  public function get_whitelisted_ips() {
903
  $whitelist = explode( PHP_EOL, $this->options['ip_whitelist'] );
inc/helpers.php CHANGED
@@ -100,7 +100,8 @@ function wpzerospam_share_detection( $data ) {
100
 
101
  // Setup the request parameters.
102
  $request_args = [
103
- 'method' => 'POST',
 
104
  'body' => [
105
  'ip' => $data['ip'],
106
  'type' => $data['type'],
100
 
101
  // Setup the request parameters.
102
  $request_args = [
103
+ 'method' => 'POST',
104
+ 'timeout' => 100,
105
  'body' => [
106
  'ip' => $data['ip'],
107
  'type' => $data['type'],
inc/install.php CHANGED
@@ -1,33 +1,45 @@
1
  <?php
2
  /**
3
- * Install plugin tables
 
 
 
 
 
 
 
 
 
4
  */
5
  function wpzerospam_install() {
6
- global $wpdb;
7
 
8
- $charset_collate = $wpdb->get_charset_collate();
9
- $installed_db_version = get_option( 'wpzerospam_db_version' );
 
10
 
11
- if ( $installed_db_version != WORDPRESS_ZERO_SPAM_DB_VERSION ) {
12
- $log_table = wpzerospam_tables( 'log' );
13
- $blocked_table = wpzerospam_tables( 'blocked' );
14
- $blacklist_table = wpzerospam_tables( 'blacklist' );
15
 
16
- $sql = "CREATE TABLE $log_table (
17
  log_id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
18
  log_type VARCHAR(255) NOT NULL,
19
  user_ip VARCHAR(39) NOT NULL,
20
  date_recorded DATETIME NOT NULL,
21
  page_url VARCHAR(255) NULL DEFAULT NULL,
22
  submission_data LONGTEXT NULL DEFAULT NULL,
23
- country VARCHAR(2) NULL DEFAULT NULL,
24
- region VARCHAR(255) NULL DEFAULT NULL,
 
 
25
  city VARCHAR(255) NULL DEFAULT NULL,
26
  latitude VARCHAR(255) NULL DEFAULT NULL,
27
  longitude VARCHAR(255) NULL DEFAULT NULL,
28
  PRIMARY KEY (`log_id`)) $charset_collate;";
29
 
30
- $sql .= "CREATE TABLE $blocked_table (
31
  blocked_id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
32
  blocked_type ENUM('permanent','temporary') NOT NULL DEFAULT 'temporary',
33
  user_ip VARCHAR(39) NOT NULL,
@@ -38,7 +50,7 @@ function wpzerospam_install() {
38
  attempts BIGINT UNSIGNED NOT NULL,
39
  PRIMARY KEY (`blocked_id`)) $charset_collate;";
40
 
41
- $sql .= "CREATE TABLE $blacklist_table (
42
  blacklist_id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
43
  user_ip VARCHAR(39) NOT NULL,
44
  last_updated DATETIME NOT NULL,
@@ -47,19 +59,19 @@ function wpzerospam_install() {
47
  blacklist_data LONGTEXT NULL DEFAULT NULL,
48
  PRIMARY KEY (`blacklist_id`)) $charset_collate;";
49
 
50
- require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
51
- dbDelta( $sql );
52
 
53
- if ( $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE %s", $blocked_table ) ) === $blocked_table ) {
54
- $wpdb->query( "DELETE t1 FROM $blocked_table AS t1 JOIN $blocked_table AS t2 ON t2.blocked_id = t1.blocked_id WHERE t1.blocked_id < t2.blocked_id AND t1.user_ip = t2.user_ip" );
55
- }
56
 
57
- if ( $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE %s", $blacklist_table ) ) === $blacklist_table ) {
58
- $wpdb->query( "DELETE t1 FROM $blacklist_table AS t1 JOIN $blacklist_table AS t2 ON t2.blacklist_id = t1.blacklist_id WHERE t1.blacklist_id < t2.blacklist_id AND t1.user_ip = t2.user_ip" );
59
- }
60
 
61
- update_option( 'wpzerospam_db_version', WORDPRESS_ZERO_SPAM_DB_VERSION );
62
- }
63
  }
64
  register_activation_hook( WORDPRESS_ZERO_SPAM, 'wpzerospam_install' );
65
 
@@ -67,10 +79,8 @@ register_activation_hook( WORDPRESS_ZERO_SPAM, 'wpzerospam_install' );
67
  * Check to ensure the database tables have been installed
68
  */
69
  function wpzerospam_db_check() {
70
- load_plugin_textdomain( 'zero-spam', FALSE, basename( dirname( WORDPRESS_ZERO_SPAM ) ) . '/languages/' );
71
-
72
- if ( get_site_option( 'wpzerospam_db_version' ) != WORDPRESS_ZERO_SPAM_DB_VERSION ) {
73
- wpzerospam_install();
74
- }
75
  }
76
  add_action( 'plugins_loaded', 'wpzerospam_db_check' );
1
  <?php
2
  /**
3
+ * Install plugin tables.
4
+ *
5
+ * @package WordPressZeroSpam
6
+ */
7
+
8
+ // Security Note: Blocks direct access to the plugin PHP files.
9
+ defined( 'ABSPATH' ) || die();
10
+
11
+ /**
12
+ * Installs the plugin tables.
13
  */
14
  function wpzerospam_install() {
15
+ global $wpdb;
16
 
17
+ $wordpress_zero_spam = new WPZeroSpam();
18
+ $charset_collate = $wpdb->get_charset_collate();
19
+ $installed_db_version = get_option( 'wpzerospam_db_version' );
20
 
21
+ if ( WORDPRESS_ZERO_SPAM_DB_VERSION !== $installed_db_version ) {
22
+ $log_table = wpzerospam_tables( 'log' );
23
+ $blocked_table = wpzerospam_tables( 'blocked' );
24
+ $blacklist_table = wpzerospam_tables( 'blacklist' );
25
 
26
+ $sql = 'CREATE TABLE ' . $wordpress_zero_spam->tables['log'] . " (
27
  log_id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
28
  log_type VARCHAR(255) NOT NULL,
29
  user_ip VARCHAR(39) NOT NULL,
30
  date_recorded DATETIME NOT NULL,
31
  page_url VARCHAR(255) NULL DEFAULT NULL,
32
  submission_data LONGTEXT NULL DEFAULT NULL,
33
+ country VARCHAR(2) NULL DEFAULT NULL,
34
+ country_name VARCHAR(255) NULL DEFAULT NULL,
35
+ region VARCHAR(255) NULL DEFAULT NULL,
36
+ region_name VARCHAR(255) NULL DEFAULT NULL,
37
  city VARCHAR(255) NULL DEFAULT NULL,
38
  latitude VARCHAR(255) NULL DEFAULT NULL,
39
  longitude VARCHAR(255) NULL DEFAULT NULL,
40
  PRIMARY KEY (`log_id`)) $charset_collate;";
41
 
42
+ $sql .= 'CREATE TABLE ' . $wordpress_zero_spam->tables['blocked'] . " (
43
  blocked_id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
44
  blocked_type ENUM('permanent','temporary') NOT NULL DEFAULT 'temporary',
45
  user_ip VARCHAR(39) NOT NULL,
50
  attempts BIGINT UNSIGNED NOT NULL,
51
  PRIMARY KEY (`blocked_id`)) $charset_collate;";
52
 
53
+ $sql .= 'CREATE TABLE ' . $wordpress_zero_spam->tables['blacklist'] . " (
54
  blacklist_id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
55
  user_ip VARCHAR(39) NOT NULL,
56
  last_updated DATETIME NOT NULL,
59
  blacklist_data LONGTEXT NULL DEFAULT NULL,
60
  PRIMARY KEY (`blacklist_id`)) $charset_collate;";
61
 
62
+ require_once ABSPATH . 'wp-admin/includes/upgrade.php';
63
+ dbDelta( $sql );
64
 
65
+ if ( $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s', $blocked_table ) ) === $blocked_table ) {
66
+ $wpdb->query( "DELETE t1 FROM $blocked_table AS t1 JOIN $blocked_table AS t2 ON t2.blocked_id = t1.blocked_id WHERE t1.blocked_id < t2.blocked_id AND t1.user_ip = t2.user_ip" );
67
+ }
68
 
69
+ if ( $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s', $blacklist_table ) ) === $blacklist_table ) {
70
+ $wpdb->query( "DELETE t1 FROM $blacklist_table AS t1 JOIN $blacklist_table AS t2 ON t2.blacklist_id = t1.blacklist_id WHERE t1.blacklist_id < t2.blacklist_id AND t1.user_ip = t2.user_ip" );
71
+ }
72
 
73
+ update_option( 'wpzerospam_db_version', WORDPRESS_ZERO_SPAM_DB_VERSION );
74
+ }
75
  }
76
  register_activation_hook( WORDPRESS_ZERO_SPAM, 'wpzerospam_install' );
77
 
79
  * Check to ensure the database tables have been installed
80
  */
81
  function wpzerospam_db_check() {
82
+ if ( WORDPRESS_ZERO_SPAM_DB_VERSION !== get_site_option( 'wpzerospam_db_version' ) ) {
83
+ wpzerospam_install();
84
+ }
 
 
85
  }
86
  add_action( 'plugins_loaded', 'wpzerospam_db_check' );
inc/security.php DELETED
@@ -1,37 +0,0 @@
1
- <?php
2
- /**
3
- * Action & filter hooks to boost site security
4
- *
5
- * @package WordPressZeroSpam
6
- * @since 4.9.7
7
- */
8
-
9
- /**
10
- * WordPress filter hooks
11
- */
12
- if ( ! function_exists( 'wpzerospam_filter_hooks' ) ) {
13
- function wpzerospam_filter_hooks() {
14
- $options = wpzerospam_options();
15
-
16
- add_filter( 'the_generator', 'wpzerospam_remove_generator' );
17
- }
18
- }
19
-
20
- /**
21
- * WordPress action hooks
22
- */
23
- if ( ! function_exists( 'wpzerospam_action_hooks' ) ) {
24
- function wpzerospam_action_hooks() {
25
- // Remove the generator meta tag
26
- remove_action( 'wp_head', 'wp_generator' );
27
- }
28
- }
29
-
30
- add_action( 'after_setup_theme', 'wpzerospam_filter_hooks' );
31
- add_action( 'after_setup_theme', 'wpzerospam_action_hooks' );
32
-
33
- if ( ! function_exists( 'wpzerospam_remove_generator' ) ) {
34
- function wpzerospam_remove_generator() {
35
- return '';
36
- }
37
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/uninstall.php CHANGED
@@ -1,43 +1,50 @@
1
  <?php
2
  /**
3
  * Handles uninstalling the plugin
 
 
4
  */
5
- if ( ! function_exists( 'wpzerospam_uninstall' ) ) {
6
- function wpzerospam_uninstall() {
7
- global $wpdb;
8
-
9
- if ( is_multisite() ) {
10
- $blogs = $wpdb->get_results( "SELECT blog_id FROM {$wpdb->blogs}", ARRAY_A );
11
-
12
- if ( $blogs ) {
13
- foreach ( $blogs as $blog ) {
14
- switch_to_blog( $blog['blog_id'] );
15
-
16
- delete_option( 'wpzerospam' );
17
- delete_option( 'wpzerospam_key' );
18
- delete_option( 'wpzerospam_honeypot' );
19
- delete_option( 'wpzerospam_db_version' );
20
- delete_option( 'wpzerospam_update_version' );
21
-
22
- $tables = wpzerospam_tables();
23
- foreach( $tables as $key => $table ) {
24
- $wpdb->query( "DROP TABLE IF EXISTS $table" );
25
- }
26
- }
27
- restore_current_blog();
28
- }
29
- } else {
30
- delete_option( 'wpzerospam' );
31
- delete_option( 'wpzerospam_key' );
32
- delete_option( 'wpzerospam_honeypot' );
33
- delete_option( 'wpzerospam_db_version' );
34
- delete_option( 'wpzerospam_update_version' );
35
-
36
- $tables = wpzerospam_tables();
37
- foreach( $tables as $key => $table ) {
38
- $wpdb->query( "DROP TABLE IF EXISTS $table" );
39
- }
40
- }
41
- }
 
 
 
 
 
42
  }
43
  register_uninstall_hook( WORDPRESS_ZERO_SPAM, 'wpzerospam_uninstall' );
1
  <?php
2
  /**
3
  * Handles uninstalling the plugin
4
+ *
5
+ * @package WordPressZeroSpam
6
  */
7
+
8
+ // Security Note: Blocks direct access to the plugin PHP files.
9
+ defined( 'ABSPATH' ) || die();
10
+
11
+ /**
12
+ * Fired when the plugin is deleted.
13
+ */
14
+ function wpzerospam_uninstall() {
15
+ global $wpdb;
16
+
17
+ $wordpress_zero_spam = new WPZeroSpam();
18
+
19
+ if ( is_multisite() ) {
20
+ $blogs = $wpdb->get_results( "SELECT blog_id FROM {$wpdb->blogs}", ARRAY_A );
21
+
22
+ if ( $blogs ) {
23
+ foreach ( $blogs as $blog ) {
24
+ switch_to_blog( $blog['blog_id'] );
25
+
26
+ delete_option( 'wpzerospam' );
27
+ delete_option( 'wpzerospam_key' );
28
+ delete_option( 'wpzerospam_honeypot' );
29
+ delete_option( 'wpzerospam_db_version' );
30
+ delete_option( 'wpzerospam_update_version' );
31
+
32
+ foreach ( $wordpress_zero_spam->tables as $key => $table ) {
33
+ $wpdb->query( "DROP TABLE IF EXISTS $table" );
34
+ }
35
+ }
36
+ restore_current_blog();
37
+ }
38
+ } else {
39
+ delete_option( 'wpzerospam' );
40
+ delete_option( 'wpzerospam_key' );
41
+ delete_option( 'wpzerospam_honeypot' );
42
+ delete_option( 'wpzerospam_db_version' );
43
+ delete_option( 'wpzerospam_update_version' );
44
+
45
+ foreach ( $wordpress_zero_spam->tables as $key => $table ) {
46
+ $wpdb->query( "DROP TABLE IF EXISTS $table" );
47
+ }
48
+ }
49
  }
50
  register_uninstall_hook( WORDPRESS_ZERO_SPAM, 'wpzerospam_uninstall' );
readme.txt CHANGED
@@ -5,7 +5,7 @@ Donate link: https://www.benmarshall.me/donate/?utm_source=wordpress_zero_spam&u
5
  Requires at least: 5.2
6
  Tested up to: 5.5
7
  Requires PHP: 7.1
8
- Stable tag: 4.10.0
9
  License: GNU GPLv3
10
  License URI: https://choosealicense.com/licenses/gpl-3.0/
11
 
@@ -63,9 +63,9 @@ WordPress Zero Spam is free and open source. It’s the perfect solution to stop
63
  To help you get started and learn just how to integrate with WordPress Zero Spam, visit the [plugin's documentation](https://www.benmarshall.me/wordpress-zero-spam/?utm_source=wordpress.org&utm_medium=plugin&utm_campaign=wordpress_zero_spam).
64
 
65
 
66
- = Help test & become a contributor =
67
 
68
- Help test future releases and contribute on the [WordPress Zero Spam GitHub Repository](https://github.com/bmarshall511/wordpress-zero-spam).
69
 
70
  = Plugin Support =
71
 
@@ -75,7 +75,7 @@ Help test future releases and contribute on the [WordPress Zero Spam GitHub Repo
75
 
76
  = WordPress Zero Spam needs your support =
77
 
78
- **WordPress Zero Spam is free — completely free & always will be.** It is hard to continue development and support for this free plugin without contributions from users like you. If you enjoy using WordPress Zero Spam and find it useful, please consider making a [donation](https://www.benmarshall.me/donate/?utm_source=wordpress.org&utm_medium=plugin&utm_campaign=wordpress_zero_spam). Your donation will help encourage and support the plugins continued development and better user support.
79
 
80
  * Like our [Facebook Page](https://www.facebook.com/zerospamorg/)
81
  * Follow us on [Twitter](https://www.facebook.com/zerospamorg)
@@ -147,6 +147,13 @@ Yes. One of the many techniques WordPress Zero Spam employs requires JavaScript
147
 
148
  == Changelog ==
149
 
 
 
 
 
 
 
 
150
  = 4.10.0 =
151
 
152
  * Enhancement - Various performance improvements & caching added.
5
  Requires at least: 5.2
6
  Tested up to: 5.5
7
  Requires PHP: 7.1
8
+ Stable tag: 4.10.1
9
  License: GNU GPLv3
10
  License URI: https://choosealicense.com/licenses/gpl-3.0/
11
 
63
  To help you get started and learn just how to integrate with WordPress Zero Spam, visit the [plugin's documentation](https://www.benmarshall.me/wordpress-zero-spam/?utm_source=wordpress.org&utm_medium=plugin&utm_campaign=wordpress_zero_spam).
64
 
65
 
66
+ = Help test & contribute to WordPress Zero Spam =
67
 
68
+ WordPress Zero Spam can only stay up-to-date and bug-free with the help of contributors and testers. You can help test upcoming releases and contribute by forking the project on [GitHub](https://github.com/bmarshall511/wordpress-zero-spam).
69
 
70
  = Plugin Support =
71
 
75
 
76
  = WordPress Zero Spam needs your support =
77
 
78
+ **WordPress Zero Spam is free — completely free & always will be.** It's hard to continue development and provide support without contributions. If you find using WordPress Zero Spam useful, please consider making a [donation](https://www.benmarshall.me/donate/?utm_source=wordpress.org&utm_medium=plugin&utm_campaign=wordpress_zero_spam). Your donation will help encourage and support the plugin's continued development and user support.
79
 
80
  * Like our [Facebook Page](https://www.facebook.com/zerospamorg/)
81
  * Follow us on [Twitter](https://www.facebook.com/zerospamorg)
147
 
148
  == Changelog ==
149
 
150
+ = 4.10.1 =
151
+
152
+ * Fix - PHP notice `Warning: array_merge(): Expected parameter 2 to be an array, bool given in /wp-content/plugins/zero-spam/classes/class-wordpress-zero-spam.php on line 532`. See https://wordpress.org/support/topic/warning-array_merge-14/#post-13319702.
153
+ * Fix - StopForumSpam & BotScout being queried even if the options are disabled. See https://wordpress.org/support/topic/api-timeout/#post-13323551.
154
+ * Enhancement - Moved the security functions into the new `WordPress_Zero_Spam_Security` class.
155
+ * Enhancement - General code clean-up & documentation.
156
+
157
  = 4.10.0 =
158
 
159
  * Enhancement - Various performance improvements & caching added.
templates/map.php CHANGED
@@ -10,7 +10,7 @@ $options = wpzerospam_options();
10
  <div class="wpzerospam-box wpzerospam-box-map">
11
  <h3><?php _e( 'Spam Detections World Map', 'zero-spam' ); ?></h3>
12
  <div class="inside">
13
- <?php if ( $options['ipstack_api'] ): ?>
14
  <?php
15
  $regions_data = [];
16
  $coords = [];
10
  <div class="wpzerospam-box wpzerospam-box-map">
11
  <h3><?php _e( 'Spam Detections World Map', 'zero-spam' ); ?></h3>
12
  <div class="inside">
13
+ <?php if ( ! empty( $options['ipstack_api'] ) ): ?>
14
  <?php
15
  $regions_data = [];
16
  $coords = [];
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.10.0
17
  * Requires at least: 5.2
18
  * Requires PHP: 7.2
19
  * Author: Ben Marshall
@@ -29,16 +29,40 @@ defined( 'ABSPATH' ) || die();
29
 
30
  // Define plugin constants.
31
  define( 'WORDPRESS_ZERO_SPAM', __FILE__ );
32
- define( 'WORDPRESS_ZERO_SPAM_DB_VERSION', '0.5' );
33
- define( 'WORDPRESS_ZERO_SPAM_VERSION', '4.10.0' );
34
 
35
  /**
36
  * Include the WordPress Zero Spam plugin class.
37
  */
38
- require plugin_dir_path( WORDPRESS_ZERO_SPAM ) . 'classes/class-wordpress-zero-spam.php';
 
 
 
 
 
 
 
 
 
 
39
 
40
  // Initialize the plugin.
41
- $wordpress_zero_spam = new WordPress_Zero_Spam();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
 
43
 
44
 
@@ -64,16 +88,6 @@ require plugin_dir_path( WORDPRESS_ZERO_SPAM ) . 'inc/helpers.php';
64
  */
65
  require plugin_dir_path( WORDPRESS_ZERO_SPAM ) . 'inc/updates.php';
66
 
67
- /**
68
- * Install & upgrade functionality.
69
- */
70
- require plugin_dir_path( WORDPRESS_ZERO_SPAM ) . 'inc/install.php';
71
-
72
- /**
73
- * Uninstall functionality.
74
- */
75
- require plugin_dir_path( WORDPRESS_ZERO_SPAM ) . 'inc/uninstall.php';
76
-
77
  /**
78
  * Plugin CSS & JS scripts.
79
  */
@@ -84,11 +98,6 @@ require plugin_dir_path( WORDPRESS_ZERO_SPAM ) . 'inc/scripts.php';
84
  */
85
  require plugin_dir_path( WORDPRESS_ZERO_SPAM ) . 'inc/admin.php';
86
 
87
- /**
88
- * Action & filter hooks for enhanced site security.
89
- */
90
- require plugin_dir_path( WORDPRESS_ZERO_SPAM ) . 'inc/security.php';
91
-
92
  /**
93
  * Initializes the plugin.
94
  *
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.10.1
17
  * Requires at least: 5.2
18
  * Requires PHP: 7.2
19
  * Author: Ben Marshall
29
 
30
  // Define plugin constants.
31
  define( 'WORDPRESS_ZERO_SPAM', __FILE__ );
32
+ define( 'WORDPRESS_ZERO_SPAM_DB_VERSION', '0.6' );
33
+ define( 'WORDPRESS_ZERO_SPAM_VERSION', '4.10.1' );
34
 
35
  /**
36
  * Include the WordPress Zero Spam plugin class.
37
  */
38
+ require plugin_dir_path( WORDPRESS_ZERO_SPAM ) . 'classes/class-wpzerospam.php';
39
+
40
+ /**
41
+ * Include the WordPress Zero Spam security class.
42
+ */
43
+ require plugin_dir_path( WORDPRESS_ZERO_SPAM ) . 'classes/class-wpzerospam-security.php';
44
+
45
+ /**
46
+ * Include the WordPress Zero Spam comments class.
47
+ */
48
+ require plugin_dir_path( WORDPRESS_ZERO_SPAM ) . 'classes/class-wpzerospam-comments.php';
49
 
50
  // Initialize the plugin.
51
+ $wpzerospam = new WPZeroSpam();
52
+ $wpzerospam_security = new WPZeroSpam_Security();
53
+
54
+ // Fires the plugin WordPress hooks.
55
+ $wpzerospam->initialize();
56
+
57
+ /**
58
+ * Install & upgrade functionality.
59
+ */
60
+ require plugin_dir_path( WORDPRESS_ZERO_SPAM ) . 'inc/install.php';
61
+
62
+ /**
63
+ * Uninstall functionality.
64
+ */
65
+ require plugin_dir_path( WORDPRESS_ZERO_SPAM ) . 'inc/uninstall.php';
66
 
67
 
68
 
88
  */
89
  require plugin_dir_path( WORDPRESS_ZERO_SPAM ) . 'inc/updates.php';
90
 
 
 
 
 
 
 
 
 
 
 
91
  /**
92
  * Plugin CSS & JS scripts.
93
  */
98
  */
99
  require plugin_dir_path( WORDPRESS_ZERO_SPAM ) . 'inc/admin.php';
100
 
 
 
 
 
 
101
  /**
102
  * Initializes the plugin.
103
  *