WordPress Zero Spam - Version 4.8.0

Version Description

  • Added filter & seach options to admin tables
  • Various performance enhancements
  • Added ability to whitelist IP addresses
Download this release

Release Info

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

Code changes from version 4.7.1 to 4.8.0

assets/css/admin-blocked-ips.css CHANGED
@@ -1,12 +1,7 @@
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-top: 10px;
9
- padding: 20px;
10
  }
11
 
12
  .wpzerospam-add-ip-container-highlight {
1
  .wpzerospam-add-ip-container {
2
  align-items: center;
 
 
 
3
  display: flex;
4
  flex-wrap: wrap;
 
 
5
  }
6
 
7
  .wpzerospam-add-ip-container-highlight {
assets/css/admin.css CHANGED
@@ -5,6 +5,7 @@
5
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
6
  display: flex;
7
  flex-wrap: wrap;
 
8
  padding: 20px;
9
  }
10
 
5
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
6
  display: flex;
7
  flex-wrap: wrap;
8
+ margin-bottom: 10px;
9
  padding: 20px;
10
  }
11
 
classes/class-wpzerospam-blacklisted-table.php CHANGED
@@ -49,6 +49,31 @@ class WPZeroSpam_Blacklisted_Table extends WP_List_Table {
49
  return $sortable_columns;
50
  }
51
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  // Checkbox column
53
  function column_cb( $item ){
54
  return sprintf(
@@ -178,20 +203,49 @@ class WPZeroSpam_Blacklisted_Table extends WP_List_Table {
178
  $hidden = $this->get_hidden_columns();
179
  $sortable = $this->get_sortable_columns();
180
 
181
- $data = wpzerospam_get_blacklist();
182
- usort( $data, [ &$this, 'sort_data' ] );
183
-
184
  $per_page = 50;
185
  $current_page = $this->get_pagenum();
186
- $total_items = count( $data );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
187
 
188
  $this->set_pagination_args([
189
  'total_items' => $total_items,
190
- 'per_page' => $per_page
 
 
 
191
  ]);
192
 
193
- $data = array_slice ( $data, ( ( $current_page - 1 ) * $per_page ), $per_page );
194
-
195
  $this->_column_headers = [ $columns, $hidden, $sortable ];
196
  $this->items = $data;
197
  }
49
  return $sortable_columns;
50
  }
51
 
52
+ function extra_tablenav( $which ) {
53
+ global $cat_id;
54
+
55
+ if ( 'top' !== $which ) {
56
+ return;
57
+ }
58
+ ?>
59
+ <div class="alignleft actions">
60
+ <?php
61
+ echo '<label class="screen-reader-text" for="filter-by-service">' . __( 'Filter by service' ) . '</label>';
62
+ $current_service = ! empty( $_POST['service'] ) ? sanitize_text_field( $_POST['service'] ) : false;
63
+ ?>
64
+ <select name="service" id="filter-by-service">
65
+ <option value=""><?php _e( 'All services', 'wpzerospam' ); ?></option>
66
+ <option<?php if ( $current_service == 'botscout' ): ?> selected="selected" <?php endif; ?> value="botscout"><?php _e( 'BotScout', 'wpzerospam' ); ?></option>
67
+ <option<?php if ( $current_service == 'stopforumspam' ): ?> selected="selected" <?php endif; ?> value="stopforumspam"><?php _e( 'Stop Forum Spam', 'wpzerospam' ); ?></option>
68
+ <option<?php if ( $current_service == 'zerospam' ): ?> selected="selected" <?php endif; ?> value="zerospam"><?php _e( 'Zero Spam', 'wpzerospam' ); ?></option>
69
+ </select>
70
+ <?php
71
+ submit_button( __( 'Filter' ), '', 'filter_action', false );
72
+ ?>
73
+ </div>
74
+ <?php
75
+ }
76
+
77
  // Checkbox column
78
  function column_cb( $item ){
79
  return sprintf(
203
  $hidden = $this->get_hidden_columns();
204
  $sortable = $this->get_sortable_columns();
205
 
 
 
 
206
  $per_page = 50;
207
  $current_page = $this->get_pagenum();
208
+ $offset = $per_page * ( $current_page - 1 );
209
+ $order = ! empty( $_REQUEST['order'] ) ? sanitize_text_field( $_REQUEST['order'] ) : 'desc';
210
+ $orderby = ! empty( $_REQUEST['orderby'] ) ? sanitize_text_field( $_REQUEST['orderby'] ) : 'last_updated';
211
+
212
+ $user_ip = ! empty( $_POST['s'] ) ? sanitize_text_field( $_REQUEST['s'] ) : false;
213
+ $blacklist_service = ! empty( $_POST['service'] ) ? sanitize_text_field( $_REQUEST['service'] ) : false;
214
+
215
+ $query_args = [
216
+ 'limit' => $per_page,
217
+ 'offset' => $offset,
218
+ 'order' => $order,
219
+ 'orderby' => $orderby
220
+ ];
221
+
222
+ if ( $blacklist_service || $user_ip ) {
223
+ $query_args['where'] = [];
224
+
225
+ if ( $blacklist_service ) {
226
+ $query_args['where']['blacklist_service'] = $blacklist_service;
227
+ }
228
+
229
+ if ( $user_ip ) {
230
+ $query_args['where']['user_ip'] = $user_ip;
231
+ }
232
+ }
233
+
234
+ $data = wpzerospam_query( 'blacklist', $query_args );
235
+ if ( ! $data ) { return false; }
236
+
237
+ usort( $data, [ &$this, 'sort_data' ] );
238
+
239
+ $total_items = wpzerospam_query( 'blacklist', $query_args, true );
240
 
241
  $this->set_pagination_args([
242
  'total_items' => $total_items,
243
+ 'per_page' => $per_page,
244
+ 'total_pages' => ceil( $total_items / $per_page ),
245
+ 'orderby' => $orderby,
246
+ 'order' => $order
247
  ]);
248
 
 
 
249
  $this->_column_headers = [ $columns, $hidden, $sortable ];
250
  $this->items = $data;
251
  }
classes/class-wpzerospam-blocked-ip-table.php CHANGED
@@ -55,6 +55,30 @@ class WPZeroSpam_Blocked_IP_Table extends WP_List_Table {
55
  return $sortable_columns;
56
  }
57
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  // Checkbox column
59
  function column_cb( $item ){
60
  return sprintf(
@@ -159,20 +183,49 @@ class WPZeroSpam_Blocked_IP_Table extends WP_List_Table {
159
  $hidden = $this->get_hidden_columns();
160
  $sortable = $this->get_sortable_columns();
161
 
162
- $data = wpzerospam_get_blocked_ips();
163
- usort( $data, [ &$this, 'sort_data' ] );
164
-
165
  $per_page = 50;
166
  $current_page = $this->get_pagenum();
167
- $total_items = count( $data );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
168
 
169
  $this->set_pagination_args([
170
  'total_items' => $total_items,
171
- 'per_page' => $per_page
 
 
 
172
  ]);
173
 
174
- $data = array_slice ( $data, ( ( $current_page - 1 ) * $per_page ), $per_page );
175
-
176
  $this->_column_headers = [ $columns, $hidden, $sortable ];
177
  $this->items = $data;
178
  }
55
  return $sortable_columns;
56
  }
57
 
58
+ function extra_tablenav( $which ) {
59
+ global $cat_id;
60
+
61
+ if ( 'top' !== $which ) {
62
+ return;
63
+ }
64
+ ?>
65
+ <div class="alignleft actions">
66
+ <?php
67
+ echo '<label class="screen-reader-text" for="filter-by-type">' . __( 'Filter by type' ) . '</label>';
68
+ $current_type = ! empty( $_POST['type'] ) ? sanitize_text_field( $_POST['type'] ) : false;
69
+ ?>
70
+ <select name="type" id="filter-by-type">
71
+ <option value=""><?php _e( 'All types', 'wpzerospam' ); ?></option>
72
+ <option<?php if ( $current_type == 'permanent' ): ?> selected="selected" <?php endif; ?> value="permanent"><?php _e( 'Permanent', 'wpzerospam' ); ?></option>
73
+ <option<?php if ( $current_type == 'temporary' ): ?> selected="selected" <?php endif; ?> value="temporary"><?php _e( 'Temporary', 'wpzerospam' ); ?></option>
74
+ </select>
75
+ <?php
76
+ submit_button( __( 'Filter' ), '', 'filter_action', false );
77
+ ?>
78
+ </div>
79
+ <?php
80
+ }
81
+
82
  // Checkbox column
83
  function column_cb( $item ){
84
  return sprintf(
183
  $hidden = $this->get_hidden_columns();
184
  $sortable = $this->get_sortable_columns();
185
 
 
 
 
186
  $per_page = 50;
187
  $current_page = $this->get_pagenum();
188
+ $offset = $per_page * ( $current_page - 1 );
189
+ $order = ! empty( $_REQUEST['order'] ) ? sanitize_text_field( $_REQUEST['order'] ) : 'desc';
190
+ $orderby = ! empty( $_REQUEST['orderby'] ) ? sanitize_text_field( $_REQUEST['orderby'] ) : 'date_added';
191
+
192
+ $user_ip = ! empty( $_POST['s'] ) ? sanitize_text_field( $_REQUEST['s'] ) : false;
193
+ $blocked_type = ! empty( $_POST['type'] ) ? sanitize_text_field( $_REQUEST['type'] ) : false;
194
+
195
+ $query_args = [
196
+ 'limit' => $per_page,
197
+ 'offset' => $offset,
198
+ 'order' => $order,
199
+ 'orderby' => $orderby
200
+ ];
201
+
202
+ if ( $blocked_type || $user_ip ) {
203
+ $query_args['where'] = [];
204
+
205
+ if ( $blocked_type ) {
206
+ $query_args['where']['blocked_type'] = $blocked_type;
207
+ }
208
+
209
+ if ( $user_ip ) {
210
+ $query_args['where']['user_ip'] = $user_ip;
211
+ }
212
+ }
213
+
214
+ $data = wpzerospam_query( 'blocked', $query_args );
215
+ if ( ! $data ) { return false; }
216
+
217
+ usort( $data, [ &$this, 'sort_data' ] );
218
+
219
+ $total_items = wpzerospam_query( 'blocked', $query_args, true );
220
 
221
  $this->set_pagination_args([
222
  'total_items' => $total_items,
223
+ 'per_page' => $per_page,
224
+ 'total_pages' => ceil( $total_items / $per_page ),
225
+ 'orderby' => $orderby,
226
+ 'order' => $order
227
  ]);
228
 
 
 
229
  $this->_column_headers = [ $columns, $hidden, $sortable ];
230
  $this->items = $data;
231
  }
classes/class-wpzerospam-log-table.php CHANGED
@@ -76,7 +76,7 @@ class WPZeroSpam_Log_Table extends WP_List_Table {
76
  <?php endforeach; ?>
77
  </select>
78
  <?php
79
- submit_button( __( 'Filter' ), '', 'filter_action', false, array( 'id' => 'post-query-submit' ) );
80
  ?>
81
  </div>
82
  <?php
@@ -431,20 +431,34 @@ class WPZeroSpam_Log_Table extends WP_List_Table {
431
  $order = ! empty( $_REQUEST['order'] ) ? sanitize_text_field( $_REQUEST['order'] ) : 'desc';
432
  $orderby = ! empty( $_REQUEST['orderby'] ) ? sanitize_text_field( $_REQUEST['orderby'] ) : 'date_recorded';
433
 
434
- $type = ! empty( $_POST['type'] ) ? sanitize_text_field( $_REQUEST['type'] ) : false;
 
435
 
436
- $data = wpzerospam_get_log([
437
  'limit' => $per_page,
438
  'offset' => $offset,
439
  'order' => $order,
440
- 'orderby' => $orderby,
441
- 'type' => $type
442
- ]);
 
 
 
 
 
 
 
 
 
 
 
 
 
443
  if ( ! $data ) { return false; }
444
 
445
  usort( $data, [ &$this, 'sort_data' ] );
446
 
447
- $total_items = wpzerospam_get_log( 'total' );
448
 
449
  $this->set_pagination_args([
450
  'total_items' => $total_items,
@@ -454,8 +468,6 @@ class WPZeroSpam_Log_Table extends WP_List_Table {
454
  'order' => $order
455
  ]);
456
 
457
- //$data = array_slice ( $data, ( ( $current_page - 1 ) * $per_page ), $per_page );
458
-
459
  $this->_column_headers = [ $columns, $hidden, $sortable ];
460
  $this->items = $data;
461
  }
76
  <?php endforeach; ?>
77
  </select>
78
  <?php
79
+ submit_button( __( 'Filter' ), '', 'filter_action', false );
80
  ?>
81
  </div>
82
  <?php
431
  $order = ! empty( $_REQUEST['order'] ) ? sanitize_text_field( $_REQUEST['order'] ) : 'desc';
432
  $orderby = ! empty( $_REQUEST['orderby'] ) ? sanitize_text_field( $_REQUEST['orderby'] ) : 'date_recorded';
433
 
434
+ $log_type = ! empty( $_POST['type'] ) ? sanitize_text_field( $_REQUEST['type'] ) : false;
435
+ $user_ip = ! empty( $_POST['s'] ) ? sanitize_text_field( $_REQUEST['s'] ) : false;
436
 
437
+ $query_args = [
438
  'limit' => $per_page,
439
  'offset' => $offset,
440
  'order' => $order,
441
+ 'orderby' => $orderby
442
+ ];
443
+
444
+ if ( $log_type || $user_ip ) {
445
+ $query_args['where'] = [];
446
+
447
+ if ( $log_type ) {
448
+ $query_args['where']['log_type'] = $log_type;
449
+ }
450
+
451
+ if ( $user_ip ) {
452
+ $query_args['where']['user_ip'] = $user_ip;
453
+ }
454
+ }
455
+
456
+ $data = wpzerospam_query( 'log', $query_args );
457
  if ( ! $data ) { return false; }
458
 
459
  usort( $data, [ &$this, 'sort_data' ] );
460
 
461
+ $total_items = wpzerospam_query( 'log', $query_args, true );
462
 
463
  $this->set_pagination_args([
464
  'total_items' => $total_items,
468
  'order' => $order
469
  ]);
470
 
 
 
471
  $this->_column_headers = [ $columns, $hidden, $sortable ];
472
  $this->items = $data;
473
  }
inc/admin.php CHANGED
@@ -13,7 +13,7 @@ function wpzerospam_admin_menu() {
13
  'manage_options',
14
  'wordpress-zero-spam',
15
  'wpzerospam_dashboard',
16
- 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB3aWR0aD0iNTEycHgiIGhlaWdodD0iNDc4cHgiIHZpZXdCb3g9IjAgMCA1MTIgNDc4IiB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPgogICAgPCEtLSBHZW5lcmF0b3I6IFNrZXRjaCA1OCAoODQ2NjMpIC0gaHR0cHM6Ly9za2V0Y2guY29tIC0tPgogICAgPHRpdGxlPlJlY3RhbmdsZTwvdGl0bGU+CiAgICA8ZGVzYz5DcmVhdGVkIHdpdGggU2tldGNoLjwvZGVzYz4KICAgIDxnIGlkPSJQYWdlLTEiIHN0cm9rZT0ibm9uZSIgc3Ryb2tlLXdpZHRoPSIxIiBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPgogICAgICAgIDxwYXRoIGQ9Ik0xNSwxMTIgTDI1Ni4yMjAwNTIsMTEyIEwyNTYuMjIwMDUyLDExMiBMMjU2LjIyMDA1MiwxNSBDMjU2LjIyMDA1Miw2LjcxNTcyODc1IDI2Mi45MzU3ODEsLTUuNTgzNjMxNDJlLTE1IDI3MS4yMjAwNTIsMCBMNDE2LDAgQzQyNC4yODQyNzEsLTMuMDk1MzQzOTdlLTE0IDQzMSw2LjcxNTcyODc1IDQzMSwxNSBMNDMxLDExMiBMNDMxLDExMiBMNDk3LDExMiBDNTA1LjI4NDI3MSwxMTIgNTEyLDExOC43MTU3MjkgNTEyLDEyNyBMNTEyLDQ2MyBDNTEyLDQ3MS4yODQyNzEgNTA1LjI4NDI3MSw0NzggNDk3LDQ3OCBMMTUsNDc4IEM2LjcxNTcyODc1LDQ3OCAxLjAxNDUzMDYzZS0xNSw0NzEuMjg0MjcxIDAsNDYzIEwwLDEyNyBDNi4zNDMzODAzMmUtMTUsMTE4LjcxNTcyOSA2LjcxNTcyODc1LDExMiAxNSwxMTIgWiIgaWQ9IlJlY3RhbmdsZSIgZmlsbD0iIzYzMDAwRCI+PC9wYXRoPgogICAgPC9nPgo8L3N2Zz4='
17
  );
18
 
19
  add_submenu_page(
@@ -69,7 +69,7 @@ function wpzerospam_spam_detections_page() {
69
  <div class="wrap">
70
  <h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
71
 
72
- <?php require plugin_dir_path( WORDPRESS_ZERO_SPAM ) . '/inc/callout.php'; ?>
73
 
74
  <?php
75
  /**
@@ -91,10 +91,8 @@ function wpzerospam_spam_detections_page() {
91
  ?>
92
  <form id="log-table" method="post">
93
  <?php wp_nonce_field( 'wpzerospam_nonce', 'wpzerospam_nonce' ); ?>
94
-
95
- <?php # Current page ?>
96
  <input type="hidden" name="paged" value="<?php echo $paged; ?>" />
97
-
98
  <?php $table_data->display(); ?>
99
  </form>
100
  </div>
@@ -107,7 +105,7 @@ function wpzerospam_blacklist_page() {
107
  <div class="wrap">
108
  <h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
109
 
110
- <?php require plugin_dir_path( WORDPRESS_ZERO_SPAM ) . '/inc/callout.php'; ?>
111
 
112
  <?php
113
  /**
@@ -129,10 +127,8 @@ function wpzerospam_blacklist_page() {
129
  ?>
130
  <form id="log-table" method="post">
131
  <?php wp_nonce_field( 'wpzerospam_nonce', 'wpzerospam_nonce' ); ?>
132
-
133
- <?php # Current page ?>
134
  <input type="hidden" name="paged" value="<?php echo $paged; ?>" />
135
-
136
  <?php $table_data->display(); ?>
137
  </form>
138
  </div>
@@ -198,7 +194,7 @@ function wpzerospam_blocked_ips_page() {
198
  <div class="wrap">
199
  <h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
200
 
201
- <?php require plugin_dir_path( WORDPRESS_ZERO_SPAM ) . '/inc/callout.php'; ?>
202
 
203
  <?php if ( ! empty( $_GET['error'] ) ): ?>
204
  <div class="notice notice-error is-dismissible">
@@ -284,10 +280,8 @@ function wpzerospam_blocked_ips_page() {
284
  ?>
285
  <form id="log-table" method="post">
286
  <?php wp_nonce_field( 'wpzerospam_nonce', 'wpzerospam_nonce' ); ?>
287
-
288
- <?php # Current page ?>
289
  <input type="hidden" name="paged" value="<?php echo $paged; ?>" />
290
-
291
  <?php $table_data->display(); ?>
292
  </form>
293
  </div>
@@ -306,7 +300,7 @@ function wpzerospam_dashboard() {
306
  <div class="wrap">
307
  <h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
308
 
309
- <?php require plugin_dir_path( WORDPRESS_ZERO_SPAM ) . '/inc/callout.php'; ?>
310
 
311
  <h2><?php _e( 'Statistics', 'wpzerospam' ); ?></h2>
312
  <div class="wpzerospam-boxes">
@@ -325,7 +319,7 @@ function wpzerospam_options_page() {
325
  <div class="wrap">
326
  <h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
327
 
328
- <?php require plugin_dir_path( WORDPRESS_ZERO_SPAM ) . '/inc/callout.php'; ?>
329
 
330
  <form action="options.php" method="post">
331
  <?php
@@ -353,6 +347,23 @@ function wpzerospam_validate_options( $input ) {
353
  if ( empty( $input['botscout_api'] ) ) { $input['botscout'] = false; }
354
  if ( empty( $input['auto_block_permanently'] ) ) { $input['auto_block_permanently'] = 3; }
355
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
356
  if ( empty( $input['verify_cf7'] ) ) {
357
  $input['verify_cf7'] = 'disabled';
358
  }
@@ -708,6 +719,15 @@ function wpzerospam_admin_init() {
708
  ]
709
  ]);
710
  }
 
 
 
 
 
 
 
 
 
711
  }
712
  add_action( 'admin_init', 'wpzerospam_admin_init' );
713
 
@@ -723,6 +743,9 @@ function wpzerospam_spam_checks_cb() {
723
  function wpzerospam_onsite_cb() {
724
  }
725
 
 
 
 
726
  function wpzerospam_field_cb( $args ) {
727
  $options = wpzerospam_options();
728
 
13
  'manage_options',
14
  'wordpress-zero-spam',
15
  'wpzerospam_dashboard',
16
+ 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB3aWR0aD0iNTEycHgiIGhlaWdodD0iNDc4cHgiIHZpZXdCb3g9IjAgMCA1MTIgNDc4IiB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPgogICAgPCEtLSBHZW5lcmF0b3I6IFNrZXRjaCA1OCAoODQ2NjMpIC0gaHR0cHM6Ly9za2V0Y2guY29tIC0tPgogICAgPHRpdGxlPmljb248L3RpdGxlPgogICAgPGRlc2M+Q3JlYXRlZCB3aXRoIFNrZXRjaC48L2Rlc2M+CiAgICA8ZyBpZD0iUGFnZS0xIiBzdHJva2U9Im5vbmUiIHN0cm9rZS13aWR0aD0iMSIgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj4KICAgICAgICA8ZyBpZD0iaWNvbiIgZmlsbD0iI0ExQTVBOSIgZmlsbC1ydWxlPSJub256ZXJvIj4KICAgICAgICAgICAgPHBhdGggZD0iTTE1LDExMiBMMjU2LjIyMDA1MiwxMTIgTDI1Ni4yMjAwNTIsMTEyIEwyNTYuMjIwMDUyLDE1IEMyNTYuMjIwMDUyLDYuNzE1NzI4NzUgMjYyLjkzNTc4MSwwIDI3MS4yMjAwNTIsMCBMNDE2LDAgQzQyNC4yODQyNzEsMCA0MzEsNi43MTU3Mjg3NSA0MzEsMTUgTDQzMSwxMTIgTDQzMSwxMTIgTDQ5NywxMTIgQzUwNS4yODQyNzEsMTEyIDUxMiwxMTguNzE1NzI5IDUxMiwxMjcgTDUxMiw0NjMgQzUxMiw0NzEuMjg0MjcxIDUwNS4yODQyNzEsNDc4IDQ5Nyw0NzggTDE1LDQ3OCBDNi43MTU3Mjg3NSw0NzggMCw0NzEuMjg0MjcxIDAsNDYzIEwwLDEyNyBDMCwxMTguNzE1NzI5IDYuNzE1NzI4NzUsMTEyIDE1LDExMiBaIiBpZD0iUmVjdGFuZ2xlIj48L3BhdGg+CiAgICAgICAgPC9nPgogICAgPC9nPgo8L3N2Zz4='
17
  );
18
 
19
  add_submenu_page(
69
  <div class="wrap">
70
  <h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
71
 
72
+ <?php require plugin_dir_path( WORDPRESS_ZERO_SPAM ) . '/templates/callout.php'; ?>
73
 
74
  <?php
75
  /**
91
  ?>
92
  <form id="log-table" method="post">
93
  <?php wp_nonce_field( 'wpzerospam_nonce', 'wpzerospam_nonce' ); ?>
 
 
94
  <input type="hidden" name="paged" value="<?php echo $paged; ?>" />
95
+ <?php $table_data->search_box( __( 'Search IPs', 'wpzerospam' ), 'search-ip' ); ?>
96
  <?php $table_data->display(); ?>
97
  </form>
98
  </div>
105
  <div class="wrap">
106
  <h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
107
 
108
+ <?php require plugin_dir_path( WORDPRESS_ZERO_SPAM ) . '/templates/callout.php'; ?>
109
 
110
  <?php
111
  /**
127
  ?>
128
  <form id="log-table" method="post">
129
  <?php wp_nonce_field( 'wpzerospam_nonce', 'wpzerospam_nonce' ); ?>
 
 
130
  <input type="hidden" name="paged" value="<?php echo $paged; ?>" />
131
+ <?php $table_data->search_box( __( 'Search IPs', 'wpzerospam' ), 'search-ip' ); ?>
132
  <?php $table_data->display(); ?>
133
  </form>
134
  </div>
194
  <div class="wrap">
195
  <h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
196
 
197
+ <?php require plugin_dir_path( WORDPRESS_ZERO_SPAM ) . '/templates/callout.php'; ?>
198
 
199
  <?php if ( ! empty( $_GET['error'] ) ): ?>
200
  <div class="notice notice-error is-dismissible">
280
  ?>
281
  <form id="log-table" method="post">
282
  <?php wp_nonce_field( 'wpzerospam_nonce', 'wpzerospam_nonce' ); ?>
 
 
283
  <input type="hidden" name="paged" value="<?php echo $paged; ?>" />
284
+ <?php $table_data->search_box( __( 'Search IPs', 'wpzerospam' ), 'search-ip' ); ?>
285
  <?php $table_data->display(); ?>
286
  </form>
287
  </div>
300
  <div class="wrap">
301
  <h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
302
 
303
+ <?php require plugin_dir_path( WORDPRESS_ZERO_SPAM ) . '/templates/callout.php'; ?>
304
 
305
  <h2><?php _e( 'Statistics', 'wpzerospam' ); ?></h2>
306
  <div class="wpzerospam-boxes">
319
  <div class="wrap">
320
  <h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
321
 
322
+ <?php require plugin_dir_path( WORDPRESS_ZERO_SPAM ) . '/templates/callout.php'; ?>
323
 
324
  <form action="options.php" method="post">
325
  <?php
347
  if ( empty( $input['botscout_api'] ) ) { $input['botscout'] = false; }
348
  if ( empty( $input['auto_block_permanently'] ) ) { $input['auto_block_permanently'] = 3; }
349
 
350
+ if ( empty( $input['ip_whitelist'] ) ) {
351
+ $input['ip_whitelist'] = '';
352
+ } else {
353
+ $whitelist = explode( PHP_EOL, $input['ip_whitelist'] );
354
+ $cleaned_whitelist = '';
355
+ foreach( $whitelist as $k => $whitelisted_ip ) {
356
+ $whitelisted_ip = trim( $whitelisted_ip );
357
+
358
+ if ( rest_is_ip_address( $whitelisted_ip ) ) {
359
+ if ( $cleaned_whitelist ) { $cleaned_whitelist .= "\n"; }
360
+ $cleaned_whitelist .= $whitelisted_ip;
361
+ }
362
+ }
363
+
364
+ $input['ip_whitelist'] = $cleaned_whitelist;
365
+ }
366
+
367
  if ( empty( $input['verify_cf7'] ) ) {
368
  $input['verify_cf7'] = 'disabled';
369
  }
719
  ]
720
  ]);
721
  }
722
+
723
+ // IP whitelist
724
+ add_settings_field( 'ip_whitelist', __( 'IP Whitelist', 'wpzerospam' ), 'wpzerospam_field_cb', 'wpzerospam', 'wpzerospam_general_settings', [
725
+ 'label_for' => 'ip_whitelist',
726
+ 'type' => 'textarea',
727
+ 'class' => 'large-text',
728
+ 'desc' => 'Enter IPs that should be whitelisted (IPs that should never be blocked), one per line.',
729
+ 'placeholder' => __( 'e.g. xxx.xxx.x.x', 'wpzerospam' )
730
+ ]);
731
  }
732
  add_action( 'admin_init', 'wpzerospam_admin_init' );
733
 
743
  function wpzerospam_onsite_cb() {
744
  }
745
 
746
+ function wpzerospam_whitelist_cb() {
747
+ }
748
+
749
  function wpzerospam_field_cb( $args ) {
750
  $options = wpzerospam_options();
751
 
inc/helpers.php CHANGED
@@ -11,6 +11,83 @@
11
  */
12
  require plugin_dir_path( WORDPRESS_ZERO_SPAM ) . '/inc/locations.php';
13
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  /**
15
  * Handles what happens when spam is detected
16
  */
@@ -469,8 +546,8 @@ if ( ! function_exists( 'wpzerospam_options' ) ) {
469
  if ( empty( $options['verify_registrations'] ) ) { $options['verify_registrations'] = 'enabled'; }
470
  if ( empty( $options['log_blocked_ips'] ) ) { $options['log_blocked_ips'] = 'disabled'; }
471
  if ( empty( $options['auto_block_permanently'] ) ) { $options['auto_block_permanently'] = 3; }
472
-
473
  if ( empty( $options['botscout_api'] ) ) { $options['botscout_api'] = false; }
 
474
 
475
  if ( empty( $options['verify_cf7'] ) ) {
476
  $options['verify_cf7'] = 'enabled';
@@ -611,6 +688,17 @@ if ( ! function_exists( 'wpzerospam_check_access' ) ) {
611
  $ip = wpzerospam_ip();
612
  $access['ip'] = $ip;
613
 
 
 
 
 
 
 
 
 
 
 
 
614
  // Check if the current user's IP address has been blocked
615
  $is_blocked = wpzerospam_get_blocked_ips( $ip );
616
  if ( ! $is_blocked ) {
11
  */
12
  require plugin_dir_path( WORDPRESS_ZERO_SPAM ) . '/inc/locations.php';
13
 
14
+ /**
15
+ * Query the database
16
+ */
17
+ if ( ! function_exists( 'wpzerospam_query' ) ) {
18
+ function wpzerospam_query( $table, $args = [], $return_total = false ) {
19
+ global $wpdb;
20
+
21
+ $sql = 'SELECT';
22
+
23
+ if ( ! $return_total ) {
24
+ if ( ! empty( $args['select'] ) ) {
25
+ $sql .= ' ' . implode( ',', $args['select'] );
26
+ } else {
27
+ $sql .= ' *';
28
+ }
29
+ } else {
30
+ $sql .= ' COUNT(*)';
31
+ }
32
+
33
+ $sql .= ' FROM ' . wpzerospam_tables( $table );
34
+
35
+ if ( ! empty( $args['where'] ) ) {
36
+ $sql .= ' WHERE';
37
+ $cnt = 0;
38
+ foreach( $args['where'] as $k => $v ) {
39
+ if ( $cnt ) {
40
+ $sql .= ' AND ';
41
+ } else {
42
+ $sql .= ' ';
43
+ }
44
+
45
+ if ( is_int( $v ) ) {
46
+ $sql .= $k . ' = ' . $v;
47
+ } else {
48
+ $sql .= $k . ' = "' . $v . '"';
49
+ }
50
+
51
+ $cnt++;
52
+ }
53
+ }
54
+
55
+ if ( ! empty( $args['orderby'] ) ) {
56
+ $sql .= ' ORDER BY ' . $args['orderby'];
57
+ }
58
+
59
+ if ( ! empty( $args['order'] ) ) {
60
+ $sql .= ' ' . $args['order'];
61
+ }
62
+
63
+ if ( ! $return_total ) {
64
+ if ( ! empty( $args['limit'] ) ) {
65
+ $sql .= ' LIMIT ' . $args['limit'];
66
+ }
67
+
68
+ if ( ! empty( $args['offset'] ) ) {
69
+ $sql .= ', ' . $args['offset'];
70
+ }
71
+ }
72
+
73
+ if ( ! $return_total ) {
74
+ return $wpdb->get_results( $sql );
75
+ } else {
76
+ return $wpdb->get_var( $sql );
77
+ }
78
+ }
79
+ }
80
+
81
+
82
+
83
+
84
+
85
+
86
+
87
+
88
+
89
+
90
+
91
  /**
92
  * Handles what happens when spam is detected
93
  */
546
  if ( empty( $options['verify_registrations'] ) ) { $options['verify_registrations'] = 'enabled'; }
547
  if ( empty( $options['log_blocked_ips'] ) ) { $options['log_blocked_ips'] = 'disabled'; }
548
  if ( empty( $options['auto_block_permanently'] ) ) { $options['auto_block_permanently'] = 3; }
 
549
  if ( empty( $options['botscout_api'] ) ) { $options['botscout_api'] = false; }
550
+ if ( empty( $options['ip_whitelist'] ) ) { $options['ip_whitelist'] = false; }
551
 
552
  if ( empty( $options['verify_cf7'] ) ) {
553
  $options['verify_cf7'] = 'enabled';
688
  $ip = wpzerospam_ip();
689
  $access['ip'] = $ip;
690
 
691
+ // Check whitelist
692
+ $whitelist = $options['ip_whitelist'];
693
+ if ( $whitelist ) {
694
+ $whitelist = explode( PHP_EOL, $whitelist );
695
+ foreach( $whitelist as $k => $whitelisted_ip ) {
696
+ if ( $ip == $whitelisted_ip ) {
697
+ return $access;
698
+ }
699
+ }
700
+ }
701
+
702
  // Check if the current user's IP address has been blocked
703
  $is_blocked = wpzerospam_get_blocked_ips( $ip );
704
  if ( ! $is_blocked ) {
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.7.1
9
  License: GNU GPLv3
10
  License URI: https://choosealicense.com/licenses/gpl-3.0/
11
 
@@ -23,11 +23,13 @@ WordPress Zero Spam blocks spam submissions including comments, registrations an
23
  * **No moderation queues**, spam isn't a administrators' problem
24
  * **Blocks 99.9% of spam** submissions
25
  * **Blocks spammy IPs** from ever seeing your site
26
- * **Checks known spam blacklists** ([Stop Forum Spam](https://www.stopforumspam.com/), [BotScout](https://botscout.com/))
27
  * **Auto-block IPs** when a spam detection is triggered
28
  * **Manually block IPs** either temporarily or permanently
29
  * **Developer-friendly**, integrate with any theme, plugin or form
30
  * **Detailed logging** to catch & block recurring spammers
 
 
31
  * **Advanced settings** for complete control over spammers
32
  * **Charts &amp; statistics** for easy to understand spam analytics
33
 
@@ -117,6 +119,12 @@ Yes, that's what does the magic and keeps spam bots out.
117
 
118
  == Changelog ==
119
 
 
 
 
 
 
 
120
  = 4.7.1 =
121
 
122
  * Update to the WP Zero Spam API
5
  Requires at least: 5.2
6
  Tested up to: 5.4.2
7
  Requires PHP: 7.1
8
+ Stable tag: 4.8.0
9
  License: GNU GPLv3
10
  License URI: https://choosealicense.com/licenses/gpl-3.0/
11
 
23
  * **No moderation queues**, spam isn't a administrators' problem
24
  * **Blocks 99.9% of spam** submissions
25
  * **Blocks spammy IPs** from ever seeing your site
26
+ * **Checks spam blacklists** ([Zero Spam](https://zerospam.org), [Stop Forum Spam](https://www.stopforumspam.com/), [BotScout](https://botscout.com/))
27
  * **Auto-block IPs** when a spam detection is triggered
28
  * **Manually block IPs** either temporarily or permanently
29
  * **Developer-friendly**, integrate with any theme, plugin or form
30
  * **Detailed logging** to catch & block recurring spammers
31
+ * **Geolocate IP addresses** to see where spammers are coming from
32
+ * **Whitelist IPs** to avoid getting blocked
33
  * **Advanced settings** for complete control over spammers
34
  * **Charts &amp; statistics** for easy to understand spam analytics
35
 
119
 
120
  == Changelog ==
121
 
122
+ = 4.8.0 =
123
+
124
+ * Added filter & seach options to admin tables
125
+ * Various performance enhancements
126
+ * Added ability to whitelist IP addresses
127
+
128
  = 4.7.1 =
129
 
130
  * Update to the WP Zero Spam API
{inc → templates}/callout.php RENAMED
@@ -11,6 +11,7 @@
11
  <div class="wpzerospam-callout-content">
12
  <h2><?php _e( 'Are you a fan of the <a href="https://benmarshall.me/wordpress-zero-spam/?utm_source=wordpress_zero_spam&utm_medium=settings_page&utm_campaign=admin" target="_blank">WordPress Zero Spam</a> plugin? Show your support.', 'wpzerospam' ); ?></h2>
13
  <p><?php _e( 'Help support the continued development of the WordPress Zero Spam plugin by <a href="https://benmarshall.me/donate?utm_source=wordpress_zero_spam&utm_medium=settings_page&utm_campaign=admin" target="_blank">donating today</a>. Your donation goes towards the time it takes to develop new features &amp; updates, but also helps provide pro bono work for nonprofits. <a href="https://benmarshall.me/donate?utm_source=wordpress_zero_spam&utm_medium=settings_page&utm_campaign=admin" target="_blank">Learn more</a>.', 'wpzerospam' ); ?></p>
 
14
  </div>
15
  <div class="wpzerospam-callout-actions">
16
  <a href="https://github.com/bmarshall511/wordpress-zero-spam/issues" class="button" target="_blank"><?php _e( 'Submit Bug/Feature Request' ); ?></a>
@@ -18,3 +19,5 @@
18
  <a href="https://benmarshall.me/donate?utm_source=wordpress_zero_spam&utm_medium=settings_page&utm_campaign=admin" class="button button-primary" target="_blank"><?php _e( 'Show your Support &mdash; Donate' ); ?></a>
19
  </div>
20
  </div>
 
 
11
  <div class="wpzerospam-callout-content">
12
  <h2><?php _e( 'Are you a fan of the <a href="https://benmarshall.me/wordpress-zero-spam/?utm_source=wordpress_zero_spam&utm_medium=settings_page&utm_campaign=admin" target="_blank">WordPress Zero Spam</a> plugin? Show your support.', 'wpzerospam' ); ?></h2>
13
  <p><?php _e( 'Help support the continued development of the WordPress Zero Spam plugin by <a href="https://benmarshall.me/donate?utm_source=wordpress_zero_spam&utm_medium=settings_page&utm_campaign=admin" target="_blank">donating today</a>. Your donation goes towards the time it takes to develop new features &amp; updates, but also helps provide pro bono work for nonprofits. <a href="https://benmarshall.me/donate?utm_source=wordpress_zero_spam&utm_medium=settings_page&utm_campaign=admin" target="_blank">Learn more</a>.', 'wpzerospam' ); ?></p>
14
+ <p><strong><?php _e( 'For the latest updates,', 'wpzerospam' ); ?></strong> <a href="https://twitter.com/ZeroSpamOrg" target="_blank" rel="noopener noreferrer"><?php _e( 'follow us on Twitter', 'wpzerospam' ); ?></a>, <a href="https://www.facebook.com/zerospamorg/" target="_blank" rel="noopener noreferrer"><?php _e( 'Facebook', 'wpzerospam' ); ?></a>, <?php _e( 'or', 'wpzerospam' ); ?> <a href="https://zerospam.org/" target="_blank" rel="noopener noreferrer"><?php _e( 'visit our website', 'wpzerospam' ); ?></a>.</p>
15
  </div>
16
  <div class="wpzerospam-callout-actions">
17
  <a href="https://github.com/bmarshall511/wordpress-zero-spam/issues" class="button" target="_blank"><?php _e( 'Submit Bug/Feature Request' ); ?></a>
19
  <a href="https://benmarshall.me/donate?utm_source=wordpress_zero_spam&utm_medium=settings_page&utm_campaign=admin" class="button button-primary" target="_blank"><?php _e( 'Show your Support &mdash; Donate' ); ?></a>
20
  </div>
21
  </div>
22
+
23
+ <p style="font-size: 1rem;"><strong><?php _e( 'Your IP Address:', 'wpzerospam' ); ?>:</strong> <code><?php echo wpzerospam_ip(); ?></code></p>
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.7.1
17
  * Requires at least: 5.2
18
  * Requires PHP: 7.2
19
  * Author: Ben Marshall
@@ -31,7 +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.2' );
34
- define( 'WORDPRESS_ZERO_SPAM_VERSION', '4.7.1' );
35
 
36
  /**
37
  * Helpers
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.8.0
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.2' );
34
+ define( 'WORDPRESS_ZERO_SPAM_VERSION', '4.8.0' );
35
 
36
  /**
37
  * Helpers