WordPress Zero Spam - Version 4.3.1

Version Description

  • Fixing plugin version
Download this release

Release Info

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

Code changes from version 4.3.0 to 4.3.1

assets/css/admin.css CHANGED
@@ -25,3 +25,90 @@
25
  font-style: italic;
26
  display: block;
27
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  font-style: italic;
26
  display: block;
27
  }
28
+
29
+ .wpzerospam-add-ip-container {
30
+ align-items: center;
31
+ display: flex;
32
+ flex-wrap: wrap;
33
+ margin-left: -10px;
34
+ margin-right: -10px;
35
+ }
36
+
37
+ .wpzerospam-add-ip-container h2,
38
+ .wpzerospam-add-ip-field,
39
+ .wpzerospam-add-ip-submit {
40
+ margin-left: 10px;
41
+ margin-right: 10px;
42
+ }
43
+
44
+ .wpzerospam-add-ip-container h2 {
45
+ margin-top: 0;
46
+ width: calc(100% - 20px);
47
+ }
48
+
49
+ .wpzerospam-add-ip-container label {
50
+ display: block;
51
+ font-weight: bold;
52
+ }
53
+
54
+ .wpzerospam-add-ip-field {
55
+ width: calc(100% / 5 - 20px);
56
+ }
57
+
58
+ .wpzerospam-add-ip-field input,
59
+ .wpzerospam-add-ip-field select {
60
+ width: 100%;
61
+ }
62
+
63
+ #wpzerospam-add-ip-field-reason {
64
+ flex-grow: 1;
65
+ }
66
+
67
+ .wpzerospam-details-modal {
68
+ background: rgba(0, 0, 0, 0.8);
69
+ cursor: pointer;
70
+ display: none;
71
+ height: 100%;
72
+ left: 0;
73
+ position: fixed;
74
+ top: 0;
75
+ width: 100%;
76
+ z-index: 9;
77
+ }
78
+
79
+ .wpzerospam-details-modal.is-active {
80
+ display: block;
81
+ }
82
+
83
+ .wpzerospam-details-modal-inner {
84
+ background-color: #fff;
85
+ border: 1px solid #ccd0d4;
86
+ border-radius: 5px;
87
+ box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
88
+ cursor: default;
89
+ left: 50%;
90
+ overflow: auto;
91
+ max-height: 500px;
92
+ max-width: 800px;
93
+ padding: 30px;
94
+ position: fixed;
95
+ top: 50%;
96
+ transform: translate(-50%, -50%);
97
+ z-index: 99;
98
+ width: 95%
99
+ }
100
+
101
+ .wpzerospam-details-item {
102
+ display: flex;
103
+ padding: 5px;
104
+ }
105
+
106
+ .wpzerospam-details-label {
107
+ flex-shrink: 0;
108
+ font-weight: bold;
109
+ width: 150px;
110
+ }
111
+
112
+ .wpzerospam-details-data {
113
+ flex-grow: 1;
114
+ }
assets/js/admin.js ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function($) {
2
+ $(function() {
3
+ var $addIPContainer = $(".wpzerospam-add-ip-container");
4
+
5
+ $("#blocked-type", $addIPContainer).change(function() {
6
+ if ( $(this).val() == 'permanent' ) {
7
+ $("#wpzerospam-add-ip-field-start-date").hide();
8
+ $("#wpzerospam-add-ip-field-end-date").hide();
9
+ } else {
10
+ $("#wpzerospam-add-ip-field-start-date").show();
11
+ $("#wpzerospam-add-ip-field-end-date").show();
12
+ }
13
+ });
14
+
15
+ var $detailsTrigger = $( '.wpzerospam-details-trigger' );
16
+ $detailsTrigger.click(function( e ) {
17
+ e.preventDefault();
18
+
19
+ var id = $(this).data('id');
20
+ $('#wpzerospam-details-modal-' + id).addClass( 'is-active' );
21
+ });
22
+
23
+ $('.wpzerospam-details-modal').click(function(){
24
+ $(this).removeClass('is-active');
25
+ });
26
+
27
+ $(".wpzerospam-details-modal .wpzerospam-details-modal-inner").click(function(e) {
28
+ e.stopPropagation();
29
+ });
30
+ });
31
+ })(jQuery);
classes/class-wpzerospam-blocked-ip-table.php CHANGED
@@ -80,20 +80,24 @@ class WPZeroSpam_Blocked_IP_Table extends WP_List_Table {
80
  return date( 'M j, Y g:ia' , strtotime( $item->date_added ) );
81
  break;
82
  case 'start_block':
83
- if ( '0000-00-00 00:00:00' == $item->start_block ) {
84
- $item->start_block = 'N/A';
85
  }
86
 
87
- return $item->start_block;
88
  break;
89
  case 'end_block':
90
- if ( '0000-00-00 00:00:00' == $item->end_block ) {
91
- $item->end_block = 'N/A';
92
  }
93
 
94
- return $item->end_block;
95
  break;
96
  case 'reason':
 
 
 
 
97
  return $item->reason;
98
  break;
99
  case 'attempts':
80
  return date( 'M j, Y g:ia' , strtotime( $item->date_added ) );
81
  break;
82
  case 'start_block':
83
+ if ( ! $item->start_block || '0000-00-00 00:00:00' == $item->start_block || 'permanent' == $item->blocked_type ) {
84
+ return 'N/A';
85
  }
86
 
87
+ return date( 'M j, Y g:ia' , strtotime( $item->start_block ) );
88
  break;
89
  case 'end_block':
90
+ if ( ! $item->end_block || '0000-00-00 00:00:00' == $item->end_block || 'permanent' == $item->blocked_type ) {
91
+ return 'N/A';
92
  }
93
 
94
+ return date( 'M j, Y g:ia' , strtotime( $item->end_block ) );
95
  break;
96
  case 'reason':
97
+ if ( ! $item->reason ) {
98
+ return 'N/A';
99
+ }
100
+
101
  return $item->reason;
102
  break;
103
  case 'attempts':
classes/class-wpzerospam-log-table.php CHANGED
@@ -36,6 +36,7 @@ class WPZeroSpam_Log_Table extends WP_List_Table {
36
  'country' => __( 'Country', 'wpzerospam' ),
37
  'region' => __( 'Region', 'wpzerospam' ),
38
  'city' => __( 'City', 'wpzerospam' ),
 
39
  ];
40
 
41
  return $columns;
@@ -101,6 +102,230 @@ class WPZeroSpam_Log_Table extends WP_List_Table {
101
  }
102
  return $item->city;
103
  break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
104
  }
105
  }
106
 
36
  'country' => __( 'Country', 'wpzerospam' ),
37
  'region' => __( 'Region', 'wpzerospam' ),
38
  'city' => __( 'City', 'wpzerospam' ),
39
+ 'details' => __( 'Details', 'wpzerospam' ),
40
  ];
41
 
42
  return $columns;
102
  }
103
  return $item->city;
104
  break;
105
+ case 'details':
106
+ if ( empty( $item->submission_data ) ) { return __( 'No details available.', 'wpzerospam' ); }
107
+ ob_start();
108
+ ?>
109
+ <button class="button action wpzerospam-details-trigger" data-id="<?php echo $item->log_id; ?>"><?php _e( 'View Details', 'wpzerospam' ); ?></button>
110
+ <div class="wpzerospam-details-modal" id="wpzerospam-details-modal-<?php echo $item->log_id; ?>">
111
+ <div class="wpzerospam-details-modal-inner">
112
+ <?php
113
+ $item->submission_data = json_decode( $item->submission_data, true );
114
+
115
+ echo '<div class="wpzerospam-details-item">';
116
+ echo '<div class="wpzerospam-details-label">' . __( 'Detected Spam IP', 'wpzerospam' ) . '</div>';
117
+ echo '<div class="wpzerospam-details-data">' . '<a href="https://whatismyipaddress.com/ip/' . $item->user_ip .'" target="_blank" rel="noopener noreferrer">' . $item->user_ip . '</a>' . '</div>';
118
+ echo '</div>';
119
+
120
+ echo '<div class="wpzerospam-details-item">';
121
+ echo '<div class="wpzerospam-details-label">' . __( 'Page URL', 'wpzerospam' ) . '</div>';
122
+ echo '<div class="wpzerospam-details-data">' . $item->page_url . '</div>';
123
+ echo '</div>';
124
+
125
+ echo '<div class="wpzerospam-details-item">';
126
+ echo '<div class="wpzerospam-details-label">' . __( 'Date', 'wpzerospam' ) . '</div>';
127
+ echo '<div class="wpzerospam-details-data">' . date( 'M j, Y g:ia' , strtotime( $item->date_recorded ) ) . '</div>';
128
+ echo '</div>';
129
+
130
+ echo '<div class="wpzerospam-details-item">';
131
+ echo '<div class="wpzerospam-details-label">' . __( 'Type', 'wpzerospam' ) . '</div>';
132
+ echo '<div class="wpzerospam-details-data">' . $item->log_type . '</div>';
133
+ echo '</div>';
134
+
135
+ if ( $item->country ) {
136
+ echo '<div class="wpzerospam-details-item">';
137
+ echo '<div class="wpzerospam-details-label">' . __( 'Country', 'wpzerospam' ) . '</div>';
138
+ echo '<div class="wpzerospam-details-data">' . $item->country . '</div>';
139
+ echo '</div>';
140
+ }
141
+
142
+ if ( $item->region ) {
143
+ echo '<div class="wpzerospam-details-item">';
144
+ echo '<div class="wpzerospam-details-label">' . __( 'Region', 'wpzerospam' ) . '</div>';
145
+ echo '<div class="wpzerospam-details-data">' . $item->region . '</div>';
146
+ echo '</div>';
147
+ }
148
+
149
+ if ( $item->city ) {
150
+ echo '<div class="wpzerospam-details-item">';
151
+ echo '<div class="wpzerospam-details-label">' . __( 'City', 'wpzerospam' ) . '</div>';
152
+ echo '<div class="wpzerospam-details-data">' . $item->city . '</div>';
153
+ echo '</div>';
154
+ }
155
+
156
+ foreach( $item->submission_data as $key => $value ):
157
+ if ( ! $value ) { continue; }
158
+ switch( $key ):
159
+ case 'comment_post_ID':
160
+ $post = get_post( $value );
161
+ echo '<div class="wpzerospam-details-item">';
162
+ if ( ! $post ) { echo 'N/A'; } else {
163
+ echo '<div class="wpzerospam-details-label">' . __( 'Comment Post', 'wpzerospam' ) . '</div>';
164
+ echo '<div class="wpzerospam-details-data"><a href="' . get_the_permalink( $value ) . '">' . get_the_title( $value ) . '</a></div>';
165
+ }
166
+ echo '</div>';
167
+ break;
168
+ case 'comment_author':
169
+ $author_shown = true;
170
+ echo '<div class="wpzerospam-details-item">';
171
+ echo '<div class="wpzerospam-details-label">' . __( 'Author', 'wpzerospam' ) . '</div>';
172
+ echo '<div class="wpzerospam-details-data">' . $value . '</div>';
173
+ echo '</div>';
174
+ break;
175
+ case 'comment_author_email':
176
+ $author_email = true;
177
+ echo '<div class="wpzerospam-details-item">';
178
+ echo '<div class="wpzerospam-details-label">' . __( 'Email', 'wpzerospam' ) . '</div>';
179
+ echo '<div class="wpzerospam-details-data">' . $value . '</div>';
180
+ echo '</div>';
181
+ break;
182
+ case 'comment_author_url':
183
+ $author_url= true;
184
+ echo '<div class="wpzerospam-details-item">';
185
+ echo '<div class="wpzerospam-details-label">' . __( 'Website', 'wpzerospam' ) . '</div>';
186
+ echo '<div class="wpzerospam-details-data">' . $value . '</div>';
187
+ echo '</div>';
188
+ break;
189
+ case 'comment_content':
190
+ echo '<div class="wpzerospam-details-item">';
191
+ echo '<div class="wpzerospam-details-label">' . __( 'Comment', 'wpzerospam' ) . '</div>';
192
+ echo '<div class="wpzerospam-details-data">' . $value . '</div>';
193
+ echo '</div>';
194
+ break;
195
+ case 'comment_type':
196
+ echo '<div class="wpzerospam-details-item">';
197
+ echo '<div class="wpzerospam-details-label">' . __( 'Comment Type', 'wpzerospam' ) . '</div>';
198
+ echo '<div class="wpzerospam-details-data">' . $value . '</div>';
199
+ echo '</div>';
200
+ break;
201
+ case 'comment_parent':
202
+ echo '<div class="wpzerospam-details-item">';
203
+ echo '<div class="wpzerospam-details-label">' . __( 'Comment Parent ID', 'wpzerospam' ) . '</div>';
204
+ echo '<div class="wpzerospam-details-data">' . '<a href="' . get_comment_link( $value ) . '">' . $value . '</a>' . '</div>';
205
+ echo '</div>';
206
+ break;
207
+ case 'comment_as_submitted':
208
+ foreach( $value as $k => $v ):
209
+ if ( ! $v ) { continue; }
210
+
211
+ switch( $k ):
212
+ case 'comment_author':
213
+ if ( empty( $author_shown ) ) {
214
+ echo '<div class="wpzerospam-details-item">';
215
+ echo '<div class="wpzerospam-details-label">' . __( 'Author', 'wpzerospam' ) . '</div>';
216
+ echo '<div class="wpzerospam-details-data">' . $v . '</div>';
217
+ echo '</div>';
218
+ }
219
+ break;
220
+ case 'comment_author_email':
221
+ if ( empty( $author_email ) ) {
222
+ echo '<div class="wpzerospam-details-item">';
223
+ echo '<div class="wpzerospam-details-label">' . __( 'Email', 'wpzerospam' ) . '</div>';
224
+ echo '<div class="wpzerospam-details-data">' . $v . '</div>';
225
+ echo '</div>';
226
+ }
227
+ break;
228
+ case 'comment_author_url':
229
+ if ( empty( $author_url ) ) {
230
+ echo '<div class="wpzerospam-details-item">';
231
+ echo '<div class="wpzerospam-details-label">' . __( 'Website', 'wpzerospam' ) . '</div>';
232
+ echo '<div class="wpzerospam-details-data">' . $v . '</div>';
233
+ echo '</div>';
234
+ }
235
+ break;
236
+ case 'comment_content':
237
+ echo '<div class="wpzerospam-details-item">';
238
+ echo '<div class="wpzerospam-details-label">' . __( 'Comment', 'wpzerospam' ) . '</div>';
239
+ echo '<div class="wpzerospam-details-data">' . $v . '</div>';
240
+ echo '</div>';
241
+ break;
242
+ case 'user_ip':
243
+ echo '<div class="wpzerospam-details-item">';
244
+ echo '<div class="wpzerospam-details-label">' . __( 'User IP', 'wpzerospam' ) . '</div>';
245
+ echo '<div class="wpzerospam-details-data"><a href="https://whatismyipaddress.com/ip/' . $item->user_ip .'" target="_blank" rel="noopener noreferrer">' . $v . '</a></div>';
246
+ echo '</div>';
247
+ break;
248
+ case 'user_agent':
249
+ echo '<div class="wpzerospam-details-item">';
250
+ echo '<div class="wpzerospam-details-label">' . __( 'User Agent', 'wpzerospam' ) . '</div>';
251
+ echo '<div class="wpzerospam-details-data">' . $v . '</div>';
252
+ echo '</div>';
253
+ break;
254
+ case 'blog':
255
+ echo '<div class="wpzerospam-details-item">';
256
+ echo '<div class="wpzerospam-details-label">' . __( 'Site', 'wpzerospam' ) . '</div>';
257
+ echo '<div class="wpzerospam-details-data">' . $v . '</div>';
258
+ echo '</div>';
259
+ break;
260
+ case 'blog_lang':
261
+ echo '<div class="wpzerospam-details-item">';
262
+ echo '<div class="wpzerospam-details-label">' . __( 'Site Language', 'wpzerospam' ) . '</div>';
263
+ echo '<div class="wpzerospam-details-data">' . $v . '</div>';
264
+ echo '</div>';
265
+ break;
266
+ case 'blog_charset':
267
+ echo '<div class="wpzerospam-details-item">';
268
+ echo '<div class="wpzerospam-details-label">' . __( 'Site Charset', 'wpzerospam' ) . '</div>';
269
+ echo '<div class="wpzerospam-details-data">' . $v . '</div>';
270
+ echo '</div>';
271
+ break;
272
+ case 'permalink':
273
+ echo '<div class="wpzerospam-details-item">';
274
+ echo '<div class="wpzerospam-details-label">' . __( 'Permalink', 'wpzerospam' ) . '</div>';
275
+ echo '<div class="wpzerospam-details-data">' . '<a href="' . $v . '" target="_blank">' . $v . '</a>' . '</div>';
276
+ echo '</div>';
277
+ break;
278
+ default:
279
+ echo '<div class="wpzerospam-details-item">';
280
+ echo $k . ' - ';
281
+ print_r( $v );
282
+ echo '</div>';
283
+ endswitch;
284
+ endforeach;
285
+ break;
286
+ case 'akismet_result':
287
+ echo '<div class="wpzerospam-details-item">';
288
+ echo '<div class="wpzerospam-details-label">' . __( 'Akismet Result', 'wpzerospam' ) . '</div>';
289
+ echo '<div class="wpzerospam-details-data">' . $value . '</div>';
290
+ echo '</div>';
291
+ break;
292
+ case 'sanitized_user_login':
293
+ echo '<div class="wpzerospam-details-item">';
294
+ echo '<div class="wpzerospam-details-label">' . __( 'Sanitized User Login', 'wpzerospam' ) . '</div>';
295
+ echo '<div class="wpzerospam-details-data">' . $value . '</div>';
296
+ echo '</div>';
297
+ break;
298
+ case 'user_email':
299
+ echo '<div class="wpzerospam-details-item">';
300
+ echo '<div class="wpzerospam-details-label">' . __( 'User Email', 'wpzerospam' ) . '</div>';
301
+ echo '<div class="wpzerospam-details-data">' . $value . '</div>';
302
+ echo '</div>';
303
+ break;
304
+ case 'errors':
305
+ echo '<div class="wpzerospam-details-item">';
306
+ echo '<div class="wpzerospam-details-label">' . __( 'Errors', 'wpzerospam' ) . '</div>';
307
+ echo '<div class="wpzerospam-details-data">' . json_encode( $value ) . '</div>';
308
+ echo '</div>';
309
+ break;
310
+ case 'reason':
311
+ echo '<div class="wpzerospam-details-item">';
312
+ echo '<div class="wpzerospam-details-label">' . __( 'Reason', 'wpzerospam' ) . '</div>';
313
+ echo '<div class="wpzerospam-details-data">' . $value . '</div>';
314
+ echo '</div>';
315
+ break;
316
+ default:
317
+ echo '<div class="wpzerospam-details-item">';
318
+ echo '<div class="wpzerospam-details-label">' . $key . '</div>';
319
+ echo '<div class="wpzerospam-details-data">' . json_encode( $value ) . '</div>';
320
+ echo '</div>';
321
+ endswitch;
322
+ endforeach;
323
+ ?>
324
+ </div>
325
+ </div>
326
+ <?php
327
+ return ob_get_clean();
328
+ break;
329
  }
330
  }
331
 
inc/admin.php CHANGED
@@ -36,11 +36,120 @@ function wpzerospam_admin_menu() {
36
  }
37
  add_action( 'admin_menu', 'wpzerospam_admin_menu' );
38
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
  function wpzerospam_blocked_ips_page() {
40
  if ( ! current_user_can( 'manage_options' ) ) { return; }
41
  ?>
42
  <div class="wrap">
43
  <h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  <?php
45
  /**
46
  * Blocked IP table
@@ -140,6 +249,8 @@ function wpzerospam_validate_options( $input ) {
140
  if ( empty( $input['verify_bp_registrations'] ) ) { $input['verify_bp_registrations'] = 'disabled'; }
141
  if ( empty( $input['verify_wpforms'] ) ) { $input['verify_wpforms'] = 'disabled'; }
142
  if ( empty( $input['log_blocked_ips'] ) ) { $input['log_blocked_ips'] = 'disabled'; }
 
 
143
 
144
  return $input;
145
  }
@@ -152,17 +263,29 @@ function wpzerospam_admin_init() {
152
  add_settings_section( 'wpzerospam_general_settings', __( 'General Settings', 'wpzerospam' ), 'wpzerospam_general_settings_cb', 'wpzerospam' );
153
  add_settings_section( 'wpzerospam_spam_checks', __( 'Spam Checks', 'wpzerospam' ), 'wpzerospam_spam_checks_cb', 'wpzerospam' );
154
 
155
- // Toggle logging of blocked IPs
156
- add_settings_field( 'log_blocked_ips', __( 'Log Blocked IPs', 'wpzerospam' ), 'wpzerospam_field_cb', 'wpzerospam', 'wpzerospam_general_settings', [
157
- 'label_for' => 'log_blocked_ips',
158
  'type' => 'checkbox',
159
  'multi' => false,
160
- 'desc' => 'Enables logging of when IPs are blocked from accessing the site.',
161
  'options' => [
162
  'enabled' => __( 'Enabled', 'wpzerospam' )
163
  ]
164
  ]);
165
 
 
 
 
 
 
 
 
 
 
 
 
 
166
  // How to handle blocks
167
  add_settings_field( 'block_handler', __( 'Blocked IPs', 'wpzerospam' ), 'wpzerospam_field_cb', 'wpzerospam', 'wpzerospam_general_settings', [
168
  'label_for' => 'block_handler',
@@ -225,6 +348,17 @@ function wpzerospam_admin_init() {
225
  ]);
226
  }
227
 
 
 
 
 
 
 
 
 
 
 
 
228
  // Log spam detections
229
  add_settings_field( 'log_spam', __( 'Log Spam Detections', 'wpzerospam' ), 'wpzerospam_field_cb', 'wpzerospam', 'wpzerospam_general_settings', [
230
  'label_for' => 'log_spam',
36
  }
37
  add_action( 'admin_menu', 'wpzerospam_admin_menu' );
38
 
39
+ add_action( 'admin_action_add_blocked_ip', 'wpzerospam_add_blocked_ip_action' );
40
+ function wpzerospam_add_blocked_ip_action() {
41
+ if ( ! empty( $_POST ) ) {
42
+ $ip = sanitize_text_field( $_POST['blocked_ip'] );
43
+ $type = in_array( sanitize_text_field( $_POST['blocked_type'] ), [ 'permanent', 'temporary' ] ) ? sanitize_text_field( $_POST['blocked_type'] ) : false;
44
+ $reason = sanitize_text_field( $_POST['blocked_reason'] );
45
+ $blocked_start_date = sanitize_text_field( $_POST['blocked_start_date'] );
46
+ $blocked_end_date = sanitize_text_field( $_POST['blocked_end_date'] );
47
+
48
+ if ( ! $ip || false === WP_Http::is_ip_address( $ip ) ) {
49
+ wp_redirect( $_SERVER['HTTP_REFERER'] . '&error=1' );
50
+ exit;
51
+ }
52
+
53
+ if ( ! $type ) {
54
+ wp_redirect( $_SERVER['HTTP_REFERER'] . '&error=2' );
55
+ exit;
56
+ }
57
+
58
+ $data = [ 'blocked_type' => $type ];
59
+ if ( $reason ) {
60
+ $data['reason'] = $reason;
61
+ } else {
62
+ $data['reason'] = NULL;
63
+ }
64
+
65
+ if ( $blocked_start_date ) {
66
+ $data['start_block'] = date( 'Y-m-d G:i:s', strtotime( $blocked_start_date ));
67
+ } else {
68
+ $data['start_block'] = NULL;
69
+ }
70
+
71
+ if ( $blocked_end_date ) {
72
+ $data['end_block'] = date( 'Y-m-d G:i:s', strtotime( $blocked_end_date ));
73
+ } else {
74
+ $data['end_block'] = NULL;
75
+ }
76
+
77
+ if ( 'temporary' == $type && ! $data['end_block'] ) {
78
+ wp_redirect( $_SERVER['HTTP_REFERER'] . '&error=3' );
79
+ exit;
80
+ }
81
+
82
+ $data['attempts'] = 0;
83
+
84
+ wpzerospam_update_blocked_ip( $ip, $data );
85
+ }
86
+
87
+ wp_redirect( $_SERVER['HTTP_REFERER'] . '&success=1' );
88
+ exit();
89
+ }
90
+
91
  function wpzerospam_blocked_ips_page() {
92
  if ( ! current_user_can( 'manage_options' ) ) { return; }
93
  ?>
94
  <div class="wrap">
95
  <h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
96
+ <?php if ( ! empty( $_GET['error'] ) ): ?>
97
+ <div class="notice notice-error is-dismissible">
98
+ <p><strong>
99
+ <?php
100
+ switch( $_GET['error'] ):
101
+ case 1:
102
+ _e( 'Please enter a valid IP address.', 'wpzerospam' );
103
+ break;
104
+ case 2:
105
+ _e( 'Please select a valid type.', 'wpzerospam' );
106
+ break;
107
+ case 3:
108
+ _e( 'Please select a date & time when the temporary block should end.', 'wpzerospam' );
109
+ break;
110
+ endswitch;
111
+ ?>
112
+ </strong></p>
113
+ <button type="button" class="notice-dismiss"><span class="screen-reader-text">Dismiss this notice.</span></button>
114
+ </div>
115
+ <?php elseif ( ! empty( $_GET['success'] ) ): ?>
116
+ <div class="notice notice-success is-dismissible">
117
+ <p><strong><?php _e( 'The blocked IP has been successfully added.', 'wpzerospam' ); ?></strong></p>
118
+ <button type="button" class="notice-dismiss"><span class="screen-reader-text">Dismiss this notice.</span></button>
119
+ </div>
120
+ <?php endif; ?>
121
+ <form method="post" action="<?php echo admin_url( 'admin.php' ); ?>">
122
+ <input type="hidden" name="action" value="add_blocked_ip" />
123
+ <div class="wpzerospam-add-ip-container">
124
+ <h2><?php _e( 'Add Blocked IP', 'wpzerospam' ); ?></h2>
125
+ <div class="wpzerospam-add-ip-field">
126
+ <label for="blocked-ip"><?php _e( 'IP Address', 'wpzerospam' ); ?></label>
127
+ <input type="text" id="blocked-ip" name="blocked_ip" value="" placeholder="e.g. xxx.xxx.x.x" />
128
+ </div>
129
+ <div class="wpzerospam-add-ip-field">
130
+ <label for="blocked-type"><?php _e( 'Type', 'wpzerospam' ); ?></label>
131
+ <select id="blocked-type" name="blocked_type">
132
+ <option value="temporary"><?php _e( 'Temporary', 'wpzerospam' ); ?></option>
133
+ <option value="permanent"><?php _e( 'Permanent', 'wpzerospam' ); ?></option>
134
+ </select>
135
+ </div>
136
+ <div class="wpzerospam-add-ip-field" id="wpzerospam-add-ip-field-reason">
137
+ <label for="blocked-reason"><?php _e( 'Reason', 'wpzerospam' ); ?></label>
138
+ <input type="text" id="blocked-reason" name="blocked_reason" value="" placeholder="<?php _e( 'e.g. Spammed form', 'wpzerospam' ); ?>" />
139
+ </div>
140
+ <div class="wpzerospam-add-ip-field" id="wpzerospam-add-ip-field-start-date">
141
+ <label for="blocked-start-date"><?php _e( 'Start Date', 'wpzerospam' ); ?></label>
142
+ <input type="datetime-local" id="blocked-start-date" name="blocked_start_date" value="" placeholder="<?php _e( 'Optional', 'wpzerospam' ); ?>" />
143
+ </div>
144
+ <div class="wpzerospam-add-ip-field" id="wpzerospam-add-ip-field-end-date">
145
+ <label for="blocked-end-date"><?php _e( 'End Date', 'wpzerospam' ); ?></label>
146
+ <input type="datetime-local" id="blocked-end-date" name="blocked_end_date" value="" placeholder="<?php _e( 'Optional', 'wpzerospam' ); ?>" />
147
+ </div>
148
+ </div>
149
+ <p style="margin-bottom: 2rem;"><input type="submit" class="button button-primary" value="<?php _e( 'Add Blocked IP', 'wpzerospam' ); ?>" /></p>
150
+ </form>
151
+
152
+
153
  <?php
154
  /**
155
  * Blocked IP table
249
  if ( empty( $input['verify_bp_registrations'] ) ) { $input['verify_bp_registrations'] = 'disabled'; }
250
  if ( empty( $input['verify_wpforms'] ) ) { $input['verify_wpforms'] = 'disabled'; }
251
  if ( empty( $input['log_blocked_ips'] ) ) { $input['log_blocked_ips'] = 'disabled'; }
252
+ if ( empty( $input['auto_block_ips'] ) ) { $input['auto_block_ips'] = 'disabled'; }
253
+ if ( empty( $input['auto_block_period'] ) ) { $input['auto_block_period'] = 0; }
254
 
255
  return $input;
256
  }
263
  add_settings_section( 'wpzerospam_general_settings', __( 'General Settings', 'wpzerospam' ), 'wpzerospam_general_settings_cb', 'wpzerospam' );
264
  add_settings_section( 'wpzerospam_spam_checks', __( 'Spam Checks', 'wpzerospam' ), 'wpzerospam_spam_checks_cb', 'wpzerospam' );
265
 
266
+ // Determines is spam detected IPs should automatically be blocked
267
+ add_settings_field( 'auto_block_ips', __( 'Auto-block IPs', 'wpzerospam' ), 'wpzerospam_field_cb', 'wpzerospam', 'wpzerospam_general_settings', [
268
+ 'label_for' => 'auto_block_ips',
269
  'type' => 'checkbox',
270
  'multi' => false,
271
+ 'desc' => 'Auto-blocks IPs addresses that trigger a spam detection.',
272
  'options' => [
273
  'enabled' => __( 'Enabled', 'wpzerospam' )
274
  ]
275
  ]);
276
 
277
+ if ( 'enabled' == $options['auto_block_ips'] ) {
278
+ // Number of minutes a IP should be blocked after a auto-block
279
+ add_settings_field( 'auto_block_period', __( 'Auto-block Period', 'wpzerospam' ), 'wpzerospam_field_cb', 'wpzerospam', 'wpzerospam_general_settings', [
280
+ 'label_for' => 'auto_block_period',
281
+ 'type' => 'number',
282
+ 'desc' => 'Number of minutes a user will be blocked from viewing the site after being auto-blocked.',
283
+ 'class' => 'small-text',
284
+ 'placeholder' => '30',
285
+ 'suffix' => __( 'minutes', 'wpzerospam' )
286
+ ]);
287
+ }
288
+
289
  // How to handle blocks
290
  add_settings_field( 'block_handler', __( 'Blocked IPs', 'wpzerospam' ), 'wpzerospam_field_cb', 'wpzerospam', 'wpzerospam_general_settings', [
291
  'label_for' => 'block_handler',
348
  ]);
349
  }
350
 
351
+ // Toggle logging of blocked IPs
352
+ add_settings_field( 'log_blocked_ips', __( 'Log Blocked IPs', 'wpzerospam' ), 'wpzerospam_field_cb', 'wpzerospam', 'wpzerospam_general_settings', [
353
+ 'label_for' => 'log_blocked_ips',
354
+ 'type' => 'checkbox',
355
+ 'multi' => false,
356
+ 'desc' => 'Enables logging of when IPs are blocked from accessing the site.',
357
+ 'options' => [
358
+ 'enabled' => __( 'Enabled', 'wpzerospam' )
359
+ ]
360
+ ]);
361
+
362
  // Log spam detections
363
  add_settings_field( 'log_spam', __( 'Log Spam Detections', 'wpzerospam' ), 'wpzerospam_field_cb', 'wpzerospam', 'wpzerospam_general_settings', [
364
  'label_for' => 'log_spam',
inc/helpers.php CHANGED
@@ -62,6 +62,21 @@ if ( ! function_exists( 'wpzerospam_spam_detected' ) ) {
62
 
63
  wpzerospam_log_spam( $type, $data );
64
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  if ( 'redirect' == $options['spam_handler'] ) {
66
  wp_redirect( esc_url( $options['spam_redirect_url'] ) );
67
  exit();
@@ -86,10 +101,10 @@ if ( ! function_exists( 'wpzerospam_key_check' ) ) {
86
  }
87
 
88
  /**
89
- * Create a log entry if logging is enabled
90
  */
91
- if ( ! function_exists( 'wpzerospam_add_blocked_ip' ) ) {
92
- function wpzerospam_add_blocked_ip( $ip, $args = [] ) {
93
  global $wpdb;
94
 
95
  $options = wpzerospam_options();
@@ -100,12 +115,38 @@ if ( ! function_exists( 'wpzerospam_add_blocked_ip' ) ) {
100
  'start_block' => false,
101
  'end_block' => false,
102
  'reason' => false,
103
- 'attempts' => 0
104
  ]);
105
 
106
  $record['user_ip'] = $ip;
107
 
108
- $wpdb->insert( wpzerospam_tables( 'blocked' ), $record );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109
  }
110
  }
111
 
@@ -118,7 +159,12 @@ if ( ! function_exists( 'wpzerospam_log_spam' ) ) {
118
 
119
  $options = wpzerospam_options();
120
 
121
- if ( 'enabled' != $options['log_spam'] ) {
 
 
 
 
 
122
  // Logging disabled
123
  return false;
124
  }
@@ -249,7 +295,7 @@ if ( ! function_exists( 'wpzerospam_attempt_blocked' ) ) {
249
  ]);
250
  }
251
 
252
- wpzerospam_log_spam( 'denied', $data );
253
 
254
  if ( 'redirect' == $options['block_handler'] ) {
255
  wp_redirect( esc_url( $options['blocked_redirect_url'] ) );
@@ -270,6 +316,8 @@ if ( ! function_exists( 'wpzerospam_options' ) ) {
270
 
271
  $options = get_option( 'wpzerospam' );
272
 
 
 
273
  if ( empty( $options['blocked_redirect_url'] ) ) { $options['blocked_redirect_url'] = 'https://www.google.com'; }
274
  if ( empty( $options['spam_handler'] ) ) { $options['spam_handler'] = '403'; }
275
  if ( empty( $options['block_handler'] ) ) { $options['block_handler'] = '403'; }
@@ -359,9 +407,47 @@ if ( ! function_exists( 'wpzerospam_check_access' ) ) {
359
  return $access;
360
  }
361
 
362
- $access['access'] = false;
363
- $access['ip'] = $ip;
364
- $access['reason'] = $is_blocked->reason;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
365
 
366
  return $access;
367
  }
62
 
63
  wpzerospam_log_spam( $type, $data );
64
 
65
+ // Check if the IP should be auto-blocked
66
+ if ( 'enabled' == $options['auto_block_ips'] ) {
67
+
68
+ $start_block = current_time( 'mysql' );
69
+ $end_block = new DateTime( $start_block );
70
+ $end_block->add( new DateInterval( 'PT' . $options['auto_block_period'] . 'M' ) );
71
+
72
+ wpzerospam_update_blocked_ip( wpzerospam_ip(), [
73
+ 'blocked_type' => 'temporary',
74
+ 'start_block' => $start_block,
75
+ 'end_block' => $end_block->format('Y-m-d G:i:s'),
76
+ 'reason' => $type . ' (auto-blocked)'
77
+ ]);
78
+ }
79
+
80
  if ( 'redirect' == $options['spam_handler'] ) {
81
  wp_redirect( esc_url( $options['spam_redirect_url'] ) );
82
  exit();
101
  }
102
 
103
  /**
104
+ * Add a IP address to the blocked table
105
  */
106
+ if ( ! function_exists( 'wpzerospam_update_blocked_ip' ) ) {
107
+ function wpzerospam_update_blocked_ip( $ip, $args = [] ) {
108
  global $wpdb;
109
 
110
  $options = wpzerospam_options();
115
  'start_block' => false,
116
  'end_block' => false,
117
  'reason' => false,
118
+ 'attempts' => 1
119
  ]);
120
 
121
  $record['user_ip'] = $ip;
122
 
123
+ // First, check if the IP is already in the DB
124
+ $check = wpzerospam_get_blocked_ips( $record['user_ip'] );
125
+ if ( $check ) {
126
+ // IP exists, update accordingly
127
+ $update = [];
128
+
129
+ if ( $record['start_block'] && $record['start_block'] != $check->start_block ) {
130
+ $update['start_block'] = $record['start_block'];
131
+ }
132
+
133
+ if ( $record['end_block'] && $record['end_block'] != $check->end_block ) {
134
+ $update['end_block'] = $record['end_block'];
135
+ }
136
+
137
+ if ( $record['reason'] && strpos( $check->reason, $record['reason'] ) === false ) {
138
+ $update['reason'] = $check->reason . ', ' . $record['reason'];
139
+ }
140
+
141
+ if ( $update ) {
142
+ $wpdb->update( wpzerospam_tables( 'blocked' ), $update, [
143
+ 'blocked_id' => $check->blocked_id
144
+ ]);
145
+ }
146
+ } else {
147
+ // IP doesn't exist, add it
148
+ $wpdb->insert( wpzerospam_tables( 'blocked' ), $record );
149
+ }
150
  }
151
  }
152
 
159
 
160
  $options = wpzerospam_options();
161
 
162
+ // Check if spam logging is enabled, also check if type is 'denied'
163
+ // (blocked IP address) & logging of blocked IPs is enabled.
164
+ if (
165
+ 'enabled' != $options['log_spam'] ||
166
+ ( 'denied' == $type && 'enabled' != $options['log_blocked_ips'] )
167
+ ) {
168
  // Logging disabled
169
  return false;
170
  }
295
  ]);
296
  }
297
 
298
+ wpzerospam_log_spam( 'blocked', $data );
299
 
300
  if ( 'redirect' == $options['block_handler'] ) {
301
  wp_redirect( esc_url( $options['blocked_redirect_url'] ) );
316
 
317
  $options = get_option( 'wpzerospam' );
318
 
319
+ if ( empty( $options['auto_block_ips'] ) ) { $options['auto_block_ips'] = 'disabled'; }
320
+ if ( empty( $options['auto_block_period'] ) ) { $options['auto_block_period'] = 30; }
321
  if ( empty( $options['blocked_redirect_url'] ) ) { $options['blocked_redirect_url'] = 'https://www.google.com'; }
322
  if ( empty( $options['spam_handler'] ) ) { $options['spam_handler'] = '403'; }
323
  if ( empty( $options['block_handler'] ) ) { $options['block_handler'] = '403'; }
407
  return $access;
408
  }
409
 
410
+ if ( 'permanent' == $is_blocked->blocked_type ) {
411
+ $access['access'] = false;
412
+ $access['ip'] = $ip;
413
+ $access['reason'] = $is_blocked->reason;
414
+ } else {
415
+ $todays_date = new DateTime( current_time( 'mysql' ) );
416
+
417
+ if ( ! empty( $is_blocked->start_block ) || ! empty( $is_blocked->end_block ) ) {
418
+ $start_block = ! empty( $is_blocked->start_block ) ? new DateTime( $is_blocked->start_block ): false;
419
+ $end_block = ! empty( $is_blocked->end_block ) ? new DateTime( $is_blocked->end_block ): false;
420
+
421
+ // @TODO - I'm sure there's a better way to handle this
422
+ if (
423
+ $start_block && $end_block &&
424
+ $todays_date->getTimestamp() >= $start_block->getTimestamp() &&
425
+ $todays_date->getTimestamp() <= $end_block->getTimestamp()
426
+ ) {
427
+ $access['access'] = false;
428
+ $access['ip'] = $ip;
429
+ $access['reason'] = $is_blocked->reason;
430
+ } elseif (
431
+ $start_block && ! $end_block &&
432
+ $todays_date->getTimestamp() >= $start_block->getTimestamp()
433
+ ) {
434
+ $access['access'] = false;
435
+ $access['ip'] = $ip;
436
+ $access['reason'] = $is_blocked->reason;
437
+ } elseif (
438
+ ! $start_block && $end_block &&
439
+ $todays_date->getTimestamp() <= $end_block->getTimestamp()
440
+ ) {
441
+ $access['access'] = false;
442
+ $access['ip'] = $ip;
443
+ $access['reason'] = $is_blocked->reason;
444
+ }
445
+ } else {
446
+ $access['access'] = false;
447
+ $access['ip'] = $ip;
448
+ $access['reason'] = $is_blocked->reason;
449
+ }
450
+ }
451
 
452
  return $access;
453
  }
inc/scripts.php CHANGED
@@ -11,6 +11,7 @@
11
  */
12
  function wpzerospam_admin_scripts() {
13
  wp_enqueue_style( 'wpzerospam-admin', plugin_dir_url( WORDPRESS_ZERO_SPAM ) . '/assets/css/admin.css', false, '4.0.0' );
 
14
  }
15
  add_action( 'admin_enqueue_scripts', 'wpzerospam_admin_scripts' );
16
 
11
  */
12
  function wpzerospam_admin_scripts() {
13
  wp_enqueue_style( 'wpzerospam-admin', plugin_dir_url( WORDPRESS_ZERO_SPAM ) . '/assets/css/admin.css', false, '4.0.0' );
14
+ wp_enqueue_script( 'wpzerospam-admin', plugin_dir_url( WORDPRESS_ZERO_SPAM ) . '/assets/js/admin.js', [ 'jquery' ], '4.0.0', true );
15
  }
16
  add_action( 'admin_enqueue_scripts', 'wpzerospam_admin_scripts' );
17
 
inc/updates.php CHANGED
@@ -20,7 +20,7 @@ add_action( 'admin_init', function() {
20
  // IPs found, transfer them to the database
21
  foreach( $options['blocked_ips'] as $key => $ip ) {
22
  if ( ! empty( $ips ) ) {
23
- wpzerospam_add_blocked_ip( $ip['ip_address'], [
24
  'reason' => $ip['reason']
25
  ]);
26
  }
20
  // IPs found, transfer them to the database
21
  foreach( $options['blocked_ips'] as $key => $ip ) {
22
  if ( ! empty( $ips ) ) {
23
+ wpzerospam_update_blocked_ip( $ip['ip_address'], [
24
  'reason' => $ip['reason']
25
  ]);
26
  }
readme.txt CHANGED
@@ -1,11 +1,11 @@
1
  === WordPress Zero Spam ===
2
- Contributors: bmarshall511, jaredatch
3
  Tags: comments, spam, antispam, anti-spam, comment spam, spambot, spammer, spam free, spam blocker, registration spam
4
- Donate link: https://benmarshall.me
5
  Requires at least: 5.2
6
  Tested up to: 5.4.2
7
  Requires PHP: 7.1
8
- Stable tag: 4.2.0
9
  License: GNU GPLv3
10
  License URI: https://choosealicense.com/licenses/gpl-3.0/
11
 
@@ -25,6 +25,8 @@ WordPress Zero Spam was initially built based on the work by [David Walsh](http:
25
  * **No moderation queues**, spam isn't a administrators' problem
26
  * **Blocks 99.9% of spam** submissions
27
  * **Blocks spammy IPs** from ever seeing your site
 
 
28
  * **Developer-friendly** allowing you to integrate with any theme or plugin
29
  * **Detailed logging** to catch & block recurring spammers
30
  * **Advanced settings** for complete control over spammers
@@ -69,6 +71,18 @@ Yes, that's what does the magic and keeps spam bots out.
69
 
70
  == Changelog ==
71
 
 
 
 
 
 
 
 
 
 
 
 
 
72
  = 4.2.0 =
73
 
74
  * Re-implemented logging & added admin pages to prepare for charts & statistics. See [#181](https://github.com/bmarshall511/wordpress-zero-spam/issues/181)
1
  === WordPress Zero Spam ===
2
+ Contributors: bmarshall511, jaredatch, EusebiuOprinoiu
3
  Tags: comments, spam, antispam, anti-spam, comment spam, spambot, spammer, spam free, spam blocker, registration spam
4
+ Donate link: https://benmarshall.me/donate/?utm_source=wordpress_zero_spam&utm_medium=wordpress_repo&utm_campaign=donate
5
  Requires at least: 5.2
6
  Tested up to: 5.4.2
7
  Requires PHP: 7.1
8
+ Stable tag: 4.3.1
9
  License: GNU GPLv3
10
  License URI: https://choosealicense.com/licenses/gpl-3.0/
11
 
25
  * **No moderation queues**, spam isn't a administrators' problem
26
  * **Blocks 99.9% of spam** submissions
27
  * **Blocks spammy IPs** from ever seeing your site
28
+ * **Auto-block IPs** when a spam detection is triggered
29
+ * **Manually block IPs** either temporarily or permanently
30
  * **Developer-friendly** allowing you to integrate with any theme or plugin
31
  * **Detailed logging** to catch & block recurring spammers
32
  * **Advanced settings** for complete control over spammers
71
 
72
  == Changelog ==
73
 
74
+ = 4.3.1 =
75
+
76
+ * Fixing plugin version
77
+
78
+ = 4.3.0 =
79
+
80
+ * Added the ability to manually add blocked IPs. See [#185](https://github.com/bmarshall511/wordpress-zero-spam/issues/185)
81
+ * Fixed the ignored start & end date of blocked IPs
82
+ * Added the ability to auto-block an IP when spam is detected. See [#185](https://github.com/bmarshall511/wordpress-zero-spam/issues/185)
83
+ * Added raw data to spammer log table
84
+ * Added the ability to uninstall options on Multisite. See [#187](https://github.com/bmarshall511/wordpress-zero-spam/pull/187)
85
+
86
  = 4.2.0 =
87
 
88
  * Re-implemented logging & added admin pages to prepare for charts & statistics. See [#181](https://github.com/bmarshall511/wordpress-zero-spam/issues/181)
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.2.0
17
  * Requires at least: 5.2
18
  * Requires PHP: 7.2
19
  * Author: Ben Marshall
@@ -146,13 +146,33 @@ if ( ! function_exists( 'wpzerospam_uninstall' ) ) {
146
  function wpzerospam_uninstall() {
147
  global $wpdb;
148
 
149
- delete_option( 'wpzerospam_key' );
150
- delete_option( 'wpzerospam' );
151
- delete_option( 'wpzerospam_db_version' );
152
-
153
- $tables = wpzerospam_tables();
154
- foreach( $tables as $key => $table ) {
155
- $wpdb->query( "DROP TABLE IF EXISTS $table" );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
156
  }
157
  }
158
  }
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.1
17
  * Requires at least: 5.2
18
  * Requires PHP: 7.2
19
  * Author: Ben Marshall
146
  function wpzerospam_uninstall() {
147
  global $wpdb;
148
 
149
+ if ( is_multisite() ) {
150
+ $blogs = $wpdb->get_results( "SELECT blog_id FROM {$wpdb->blogs}", ARRAY_A );
151
+
152
+ if ( $blogs ) {
153
+ foreach ( $blogs as $blog ) {
154
+ switch_to_blog( $blog['blog_id'] );
155
+
156
+ delete_option( 'wpzerospam' );
157
+ delete_option( 'wpzerospam_key' );
158
+ delete_option( 'wpzerospam_db_version' );
159
+
160
+ $tables = wpzerospam_tables();
161
+ foreach( $tables as $key => $table ) {
162
+ $wpdb->query( "DROP TABLE IF EXISTS $table" );
163
+ }
164
+ }
165
+ restore_current_blog();
166
+ }
167
+ } else {
168
+ delete_option( 'wpzerospam' );
169
+ delete_option( 'wpzerospam_key' );
170
+ delete_option( 'wpzerospam_db_version' );
171
+
172
+ $tables = wpzerospam_tables();
173
+ foreach( $tables as $key => $table ) {
174
+ $wpdb->query( "DROP TABLE IF EXISTS $table" );
175
+ }
176
  }
177
  }
178
  }