WordPress Zero Spam - Version 4.3.4

Version Description

  • Fixed issue with adding/updating IP addresses manually
  • Fixed PHP notice for missing submission data on the log chart
  • Fixed PHP notice for "Undefined index: log_blocked_ips". See #191
  • Updated the admin scripts to only login on the plugin admin pages
  • Fixed an issue with default add-on plugin options being disabled on first save. See #192
Download this release

Release Info

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

Code changes from version 4.3.3 to 4.3.4

classes/class-wpzerospam-log-table.php CHANGED
@@ -152,179 +152,181 @@ class WPZeroSpam_Log_Table extends WP_List_Table {
152
  echo '</div>';
153
  }
154
 
155
- foreach( $item->submission_data as $key => $value ):
156
- if ( ! $value ) { continue; }
157
- switch( $key ):
158
- case 'comment_post_ID':
159
- $post = get_post( $value );
160
- echo '<div class="wpzerospam-details-item">';
161
- if ( ! $post ) { echo 'N/A'; } else {
162
- echo '<div class="wpzerospam-details-label">' . __( 'Comment Post', 'wpzerospam' ) . '</div>';
163
- echo '<div class="wpzerospam-details-data"><a href="' . get_the_permalink( $value ) . '">' . get_the_title( $value ) . '</a></div>';
164
- }
165
- echo '</div>';
166
- break;
167
- case 'comment_author':
168
- $author_shown = true;
169
- echo '<div class="wpzerospam-details-item">';
170
- echo '<div class="wpzerospam-details-label">' . __( 'Author', 'wpzerospam' ) . '</div>';
171
- echo '<div class="wpzerospam-details-data">' . $value . '</div>';
172
- echo '</div>';
173
- break;
174
- case 'comment_author_email':
175
- $author_email = true;
176
- echo '<div class="wpzerospam-details-item">';
177
- echo '<div class="wpzerospam-details-label">' . __( 'Email', 'wpzerospam' ) . '</div>';
178
- echo '<div class="wpzerospam-details-data">' . $value . '</div>';
179
- echo '</div>';
180
- break;
181
- case 'comment_author_url':
182
- $author_url= true;
183
- echo '<div class="wpzerospam-details-item">';
184
- echo '<div class="wpzerospam-details-label">' . __( 'Website', 'wpzerospam' ) . '</div>';
185
- echo '<div class="wpzerospam-details-data">' . $value . '</div>';
186
- echo '</div>';
187
- break;
188
- case 'comment_content':
189
- echo '<div class="wpzerospam-details-item">';
190
- echo '<div class="wpzerospam-details-label">' . __( 'Comment', 'wpzerospam' ) . '</div>';
191
- echo '<div class="wpzerospam-details-data">' . sanitize_text_field( $value ) . '</div>';
192
- echo '</div>';
193
- break;
194
- case 'comment_type':
195
- echo '<div class="wpzerospam-details-item">';
196
- echo '<div class="wpzerospam-details-label">' . __( 'Comment Type', 'wpzerospam' ) . '</div>';
197
- echo '<div class="wpzerospam-details-data">' . $value . '</div>';
198
- echo '</div>';
199
- break;
200
- case 'comment_parent':
201
- echo '<div class="wpzerospam-details-item">';
202
- echo '<div class="wpzerospam-details-label">' . __( 'Comment Parent ID', 'wpzerospam' ) . '</div>';
203
- echo '<div class="wpzerospam-details-data">' . '<a href="' . get_comment_link( $value ) . '">' . $value . '</a>' . '</div>';
204
- echo '</div>';
205
- break;
206
- case 'comment_as_submitted':
207
- foreach( $value as $k => $v ):
208
- if ( ! $v ) { continue; }
209
-
210
- switch( $k ):
211
- case 'comment_author':
212
- if ( empty( $author_shown ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
213
  echo '<div class="wpzerospam-details-item">';
214
- echo '<div class="wpzerospam-details-label">' . __( 'Author', 'wpzerospam' ) . '</div>';
 
 
 
 
 
 
 
 
 
 
 
 
215
  echo '<div class="wpzerospam-details-data">' . $v . '</div>';
216
  echo '</div>';
217
- }
218
- break;
219
- case 'comment_author_email':
220
- if ( empty( $author_email ) ) {
221
  echo '<div class="wpzerospam-details-item">';
222
- echo '<div class="wpzerospam-details-label">' . __( 'Email', 'wpzerospam' ) . '</div>';
223
  echo '<div class="wpzerospam-details-data">' . $v . '</div>';
224
  echo '</div>';
225
- }
226
- break;
227
- case 'comment_author_url':
228
- if ( empty( $author_url ) ) {
229
  echo '<div class="wpzerospam-details-item">';
230
- echo '<div class="wpzerospam-details-label">' . __( 'Website', 'wpzerospam' ) . '</div>';
231
  echo '<div class="wpzerospam-details-data">' . $v . '</div>';
232
  echo '</div>';
233
- }
234
- break;
235
- case 'comment_content':
236
- echo '<div class="wpzerospam-details-item">';
237
- echo '<div class="wpzerospam-details-label">' . __( 'Comment', 'wpzerospam' ) . '</div>';
238
- echo '<div class="wpzerospam-details-data">' . sanitize_text_field( $v ) . '</div>';
239
- echo '</div>';
240
- break;
241
- case 'user_ip':
242
- echo '<div class="wpzerospam-details-item">';
243
- echo '<div class="wpzerospam-details-label">' . __( 'User IP', 'wpzerospam' ) . '</div>';
244
- echo '<div class="wpzerospam-details-data"><a href="https://whatismyipaddress.com/ip/' . $item->user_ip .'" target="_blank" rel="noopener noreferrer">' . $v . '</a></div>';
245
- echo '</div>';
246
- break;
247
- case 'user_agent':
248
- echo '<div class="wpzerospam-details-item">';
249
- echo '<div class="wpzerospam-details-label">' . __( 'User Agent', 'wpzerospam' ) . '</div>';
250
- echo '<div class="wpzerospam-details-data">' . $v . '</div>';
251
- echo '</div>';
252
- break;
253
- case 'blog':
254
- echo '<div class="wpzerospam-details-item">';
255
- echo '<div class="wpzerospam-details-label">' . __( 'Site', 'wpzerospam' ) . '</div>';
256
- echo '<div class="wpzerospam-details-data">' . $v . '</div>';
257
- echo '</div>';
258
- break;
259
- case 'blog_lang':
260
- echo '<div class="wpzerospam-details-item">';
261
- echo '<div class="wpzerospam-details-label">' . __( 'Site Language', 'wpzerospam' ) . '</div>';
262
- echo '<div class="wpzerospam-details-data">' . $v . '</div>';
263
- echo '</div>';
264
- break;
265
- case 'blog_charset':
266
- echo '<div class="wpzerospam-details-item">';
267
- echo '<div class="wpzerospam-details-label">' . __( 'Site Charset', 'wpzerospam' ) . '</div>';
268
- echo '<div class="wpzerospam-details-data">' . $v . '</div>';
269
- echo '</div>';
270
- break;
271
- case 'permalink':
272
- echo '<div class="wpzerospam-details-item">';
273
- echo '<div class="wpzerospam-details-label">' . __( 'Permalink', 'wpzerospam' ) . '</div>';
274
- echo '<div class="wpzerospam-details-data">' . '<a href="' . $v . '" target="_blank">' . $v . '</a>' . '</div>';
275
- echo '</div>';
276
- break;
277
- default:
278
- echo '<div class="wpzerospam-details-item">';
279
- echo $k . ' - ';
280
- print_r( $v );
281
- echo '</div>';
282
- endswitch;
283
- endforeach;
284
- break;
285
- case 'akismet_result':
286
- echo '<div class="wpzerospam-details-item">';
287
- echo '<div class="wpzerospam-details-label">' . __( 'Akismet Result', 'wpzerospam' ) . '</div>';
288
- echo '<div class="wpzerospam-details-data">' . $value . '</div>';
289
- echo '</div>';
290
- break;
291
- case 'akismet_pro_tip':
292
- echo '<div class="wpzerospam-details-item">';
293
- echo '<div class="wpzerospam-details-label">' . __( 'Akismet Pro Tip', 'wpzerospam' ) . '</div>';
294
- echo '<div class="wpzerospam-details-data">' . $value . '</div>';
295
- echo '</div>';
296
- break;
297
- case 'sanitized_user_login':
298
- echo '<div class="wpzerospam-details-item">';
299
- echo '<div class="wpzerospam-details-label">' . __( 'Sanitized User Login', 'wpzerospam' ) . '</div>';
300
- echo '<div class="wpzerospam-details-data">' . $value . '</div>';
301
- echo '</div>';
302
- break;
303
- case 'user_email':
304
- echo '<div class="wpzerospam-details-item">';
305
- echo '<div class="wpzerospam-details-label">' . __( 'User Email', 'wpzerospam' ) . '</div>';
306
- echo '<div class="wpzerospam-details-data">' . $value . '</div>';
307
- echo '</div>';
308
- break;
309
- case 'errors':
310
- echo '<div class="wpzerospam-details-item">';
311
- echo '<div class="wpzerospam-details-label">' . __( 'Errors', 'wpzerospam' ) . '</div>';
312
- echo '<div class="wpzerospam-details-data">' . json_encode( $value ) . '</div>';
313
- echo '</div>';
314
- break;
315
- case 'reason':
316
- echo '<div class="wpzerospam-details-item">';
317
- echo '<div class="wpzerospam-details-label">' . __( 'Reason', 'wpzerospam' ) . '</div>';
318
- echo '<div class="wpzerospam-details-data">' . $value . '</div>';
319
- echo '</div>';
320
- break;
321
- default:
322
- echo '<div class="wpzerospam-details-item">';
323
- echo '<div class="wpzerospam-details-label">' . $key . '</div>';
324
- echo '<div class="wpzerospam-details-data">' . json_encode( $value ) . '</div>';
325
- echo '</div>';
326
- endswitch;
327
- endforeach;
328
  ?>
329
  </div>
330
  </div>
152
  echo '</div>';
153
  }
154
 
155
+ if ( ! empty( $item->submission_data ) ) {
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">' . sanitize_text_field( $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">' . sanitize_text_field( $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 'akismet_pro_tip':
293
+ echo '<div class="wpzerospam-details-item">';
294
+ echo '<div class="wpzerospam-details-label">' . __( 'Akismet Pro Tip', 'wpzerospam' ) . '</div>';
295
+ echo '<div class="wpzerospam-details-data">' . $value . '</div>';
296
+ echo '</div>';
297
+ break;
298
+ case 'sanitized_user_login':
299
+ echo '<div class="wpzerospam-details-item">';
300
+ echo '<div class="wpzerospam-details-label">' . __( 'Sanitized User Login', 'wpzerospam' ) . '</div>';
301
+ echo '<div class="wpzerospam-details-data">' . $value . '</div>';
302
+ echo '</div>';
303
+ break;
304
+ case 'user_email':
305
+ echo '<div class="wpzerospam-details-item">';
306
+ echo '<div class="wpzerospam-details-label">' . __( 'User Email', 'wpzerospam' ) . '</div>';
307
+ echo '<div class="wpzerospam-details-data">' . $value . '</div>';
308
+ echo '</div>';
309
+ break;
310
+ case 'errors':
311
+ echo '<div class="wpzerospam-details-item">';
312
+ echo '<div class="wpzerospam-details-label">' . __( 'Errors', 'wpzerospam' ) . '</div>';
313
+ echo '<div class="wpzerospam-details-data">' . json_encode( $value ) . '</div>';
314
+ echo '</div>';
315
+ break;
316
+ case 'reason':
317
+ echo '<div class="wpzerospam-details-item">';
318
+ echo '<div class="wpzerospam-details-label">' . __( 'Reason', 'wpzerospam' ) . '</div>';
319
+ echo '<div class="wpzerospam-details-data">' . $value . '</div>';
320
+ echo '</div>';
321
+ break;
322
+ default:
323
+ echo '<div class="wpzerospam-details-item">';
324
+ echo '<div class="wpzerospam-details-label">' . $key . '</div>';
325
+ echo '<div class="wpzerospam-details-data">' . json_encode( $value ) . '</div>';
326
+ echo '</div>';
327
+ endswitch;
328
+ endforeach;
329
+ };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
330
  ?>
331
  </div>
332
  </div>
inc/admin.php CHANGED
@@ -56,6 +56,7 @@ function wpzerospam_add_blocked_ip_action() {
56
  }
57
 
58
  $data = [ 'blocked_type' => $type ];
 
59
  if ( $reason ) {
60
  $data['reason'] = $reason;
61
  } else {
@@ -268,21 +269,54 @@ function wpzerospam_validate_options( $input ) {
268
  if ( empty( $input['log_spam'] ) ) { $input['log_spam'] = 'disabled'; }
269
  if ( empty( $input['verify_comments'] ) ) { $input['verify_comments'] = 'disabled'; }
270
  if ( empty( $input['verify_registrations'] ) ) { $input['verify_registrations'] = 'disabled'; }
271
- if ( empty( $input['verify_cf7'] ) ) { $input['verify_cf7'] = 'disabled'; }
272
- if ( empty( $input['verify_gform'] ) ) { $input['verify_gform'] = 'disabled'; }
273
- if ( empty( $input['verify_ninja_forms'] ) ) { $input['verify_ninja_forms'] = 'disabled'; }
274
- if ( empty( $input['verify_bp_registrations'] ) ) { $input['verify_bp_registrations'] = 'disabled'; }
275
- if ( empty( $input['verify_wpforms'] ) ) { $input['verify_wpforms'] = 'disabled'; }
276
  if ( empty( $input['log_blocked_ips'] ) ) { $input['log_blocked_ips'] = 'disabled'; }
277
  if ( empty( $input['auto_block_ips'] ) ) { $input['auto_block_ips'] = 'disabled'; }
278
  if ( empty( $input['auto_block_period'] ) ) { $input['auto_block_period'] = 0; }
279
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
280
  return $input;
281
  }
282
 
 
 
 
 
 
 
 
 
 
 
 
 
283
  function wpzerospam_admin_init() {
284
  $options = wpzerospam_options();
285
 
 
 
 
286
  register_setting( 'wpzerospam', 'wpzerospam', 'wpzerospam_validate_options' );
287
 
288
  add_settings_section( 'wpzerospam_general_settings', __( 'General Settings', 'wpzerospam' ), 'wpzerospam_general_settings_cb', 'wpzerospam' );
56
  }
57
 
58
  $data = [ 'blocked_type' => $type ];
59
+
60
  if ( $reason ) {
61
  $data['reason'] = $reason;
62
  } else {
269
  if ( empty( $input['log_spam'] ) ) { $input['log_spam'] = 'disabled'; }
270
  if ( empty( $input['verify_comments'] ) ) { $input['verify_comments'] = 'disabled'; }
271
  if ( empty( $input['verify_registrations'] ) ) { $input['verify_registrations'] = 'disabled'; }
 
 
 
 
 
272
  if ( empty( $input['log_blocked_ips'] ) ) { $input['log_blocked_ips'] = 'disabled'; }
273
  if ( empty( $input['auto_block_ips'] ) ) { $input['auto_block_ips'] = 'disabled'; }
274
  if ( empty( $input['auto_block_period'] ) ) { $input['auto_block_period'] = 0; }
275
 
276
+
277
+ if ( is_plugin_active( 'contact-form-7/wp-contact-form-7.php' ) && empty( $input['verify_cf7'] ) ) {
278
+ $input['verify_cf7'] = 'disabled';
279
+ }
280
+
281
+ if ( is_plugin_active( 'gravityforms/gravityforms.php' ) && empty( $input['verify_gform'] ) ) {
282
+ $input['verify_gform'] = 'disabled';
283
+ }
284
+
285
+ if ( is_plugin_active( 'ninja-forms/ninja-forms.php' ) && empty( $input['verify_ninja_forms'] ) ) {
286
+ $input['verify_ninja_forms'] = 'disabled';
287
+ }
288
+
289
+ if ( function_exists( 'bp_is_active' ) && empty( $input['verify_bp_registrations'] ) ) {
290
+ $input['verify_bp_registrations'] = 'disabled';
291
+ }
292
+
293
+ if (
294
+ ( is_plugin_active( 'wpforms/wpforms.php' ) || is_plugin_active( 'wpforms-lite/wpforms.php') ) &&
295
+ empty( $input['verify_wpforms'] )
296
+ ) {
297
+ $input['verify_wpforms'] = 'disabled';
298
+ }
299
  return $input;
300
  }
301
 
302
+ /**
303
+ * Add settings link to plugin description
304
+ */
305
+ function wpzerospam_admin_action_links( $actions, $plugin_file, $plugin_data, $context ) {
306
+ $links = [
307
+ 'settings' => '<a href="' . admin_url( 'admin.php?page=wordpress-zero-spam-settings' ) . '">' . __( 'Settings' ) . '</a>'
308
+ ];
309
+
310
+ return array_merge( $links, $actions );
311
+ }
312
+
313
+
314
  function wpzerospam_admin_init() {
315
  $options = wpzerospam_options();
316
 
317
+ // Add settings link to plugin description
318
+ add_filter( 'plugin_action_links_' . plugin_basename( WORDPRESS_ZERO_SPAM ), 'wpzerospam_admin_action_links', 10, 4 );
319
+
320
  register_setting( 'wpzerospam', 'wpzerospam', 'wpzerospam_validate_options' );
321
 
322
  add_settings_section( 'wpzerospam_general_settings', __( 'General Settings', 'wpzerospam' ), 'wpzerospam_general_settings_cb', 'wpzerospam' );
inc/helpers.php CHANGED
@@ -131,6 +131,10 @@ if ( ! function_exists( 'wpzerospam_update_blocked_ip' ) ) {
131
  // IP exists, update accordingly
132
  $update = [];
133
 
 
 
 
 
134
  if ( $record['start_block'] && $record['start_block'] != $check->start_block ) {
135
  $update['start_block'] = $record['start_block'];
136
  }
@@ -139,8 +143,8 @@ if ( ! function_exists( 'wpzerospam_update_blocked_ip' ) ) {
139
  $update['end_block'] = $record['end_block'];
140
  }
141
 
142
- if ( $record['reason'] && strpos( $check->reason, $record['reason'] ) === false ) {
143
- $update['reason'] = $check->reason . ', ' . $record['reason'];
144
  }
145
 
146
  if ( $update ) {
@@ -277,26 +281,22 @@ if ( ! function_exists( 'wpzerospam_get_blocked_ips' ) ) {
277
  * Adds a access attempt from a blocked user
278
  */
279
  if ( ! function_exists( 'wpzerospam_attempt_blocked' ) ) {
280
- function wpzerospam_attempt_blocked( $data ) {
281
  global $wpdb;
282
 
283
- $options = wpzerospam_options();
284
-
285
- if ( ! empty( $data['ip'] ) ) {
286
- $ip_address = $data['ip'];
287
- } else {
288
- $ip_address = wpzerospam_ip();
289
- }
290
 
291
- $blocked = wpzerospam_get_blocked_ips( $ip_address );
292
- if ( $blocked ) {
293
- $attempts = $blocked->attempts;
 
294
  $attempts++;
295
 
296
  $wpdb->update( wpzerospam_tables( 'blocked' ), [
297
  'attempts' => $attempts
298
  ], [
299
- 'blocked_id' => $blocked->blocked_id
300
  ]);
301
  }
302
 
@@ -333,6 +333,7 @@ if ( ! function_exists( 'wpzerospam_options' ) ) {
333
  if ( empty( $options['log_spam'] ) ) { $options['log_spam'] = 'disabled'; }
334
  if ( empty( $options['verify_comments'] ) ) { $options['verify_comments'] = 'enabled'; }
335
  if ( empty( $options['verify_registrations'] ) ) { $options['verify_registrations'] = 'enabled'; }
 
336
 
337
  if ( empty( $options['verify_cf7'] ) && is_plugin_active( 'contact-form-7/wp-contact-form-7.php' ) ) {
338
  $options['verify_cf7'] = 'enabled';
131
  // IP exists, update accordingly
132
  $update = [];
133
 
134
+ if ( $record['blocked_type'] && $record['blocked_type'] != $check->blocked_type ) {
135
+ $update['blocked_type'] = $record['blocked_type'];
136
+ }
137
+
138
  if ( $record['start_block'] && $record['start_block'] != $check->start_block ) {
139
  $update['start_block'] = $record['start_block'];
140
  }
143
  $update['end_block'] = $record['end_block'];
144
  }
145
 
146
+ if ( $record['reason'] && $record['reason'] != $check->reason ) {
147
+ $update['reason'] = $record['reason'];
148
  }
149
 
150
  if ( $update ) {
281
  * Adds a access attempt from a blocked user
282
  */
283
  if ( ! function_exists( 'wpzerospam_attempt_blocked' ) ) {
284
+ function wpzerospam_attempt_blocked( $reason ) {
285
  global $wpdb;
286
 
287
+ $options = wpzerospam_options();
288
+ $ip_address = wpzerospam_ip();
 
 
 
 
 
289
 
290
+ $is_blocked = wpzerospam_get_blocked_ips( $ip_address );
291
+ if ( $is_blocked ) {
292
+ // IP already exists in the database
293
+ $attempts = $is_blocked->attempts;
294
  $attempts++;
295
 
296
  $wpdb->update( wpzerospam_tables( 'blocked' ), [
297
  'attempts' => $attempts
298
  ], [
299
+ 'blocked_id' => $is_blocked->blocked_id
300
  ]);
301
  }
302
 
333
  if ( empty( $options['log_spam'] ) ) { $options['log_spam'] = 'disabled'; }
334
  if ( empty( $options['verify_comments'] ) ) { $options['verify_comments'] = 'enabled'; }
335
  if ( empty( $options['verify_registrations'] ) ) { $options['verify_registrations'] = 'enabled'; }
336
+ if ( empty( $options['log_blocked_ips'] ) ) { $options['log_blocked_ips'] = 'disabled'; }
337
 
338
  if ( empty( $options['verify_cf7'] ) && is_plugin_active( 'contact-form-7/wp-contact-form-7.php' ) ) {
339
  $options['verify_cf7'] = 'enabled';
inc/scripts.php CHANGED
@@ -9,13 +9,20 @@
9
  /**
10
  * Add admin scripts
11
  */
12
- function wpzerospam_admin_scripts() {
13
  $plugin = get_plugin_data( WORDPRESS_ZERO_SPAM );
14
 
15
- wp_enqueue_style( 'wpzerospam-admin', plugin_dir_url( WORDPRESS_ZERO_SPAM ) . '/assets/css/admin.css', false, $plugin['Version'] );
16
- wp_enqueue_script( 'wpzerospam-admin', plugin_dir_url( WORDPRESS_ZERO_SPAM ) . '/assets/js/admin.js', [ 'jquery' ], $plugin['Version'], true );
17
- wp_enqueue_style( 'wpzerospam-charts', plugin_dir_url( WORDPRESS_ZERO_SPAM ) . '/assets/css/Chart.min.css', false, '2.9.3' );
18
- wp_enqueue_script( 'wpzerospam-charts', plugin_dir_url( WORDPRESS_ZERO_SPAM ) . '/assets/js/Chart.bundle.min.js', [], '2.9.3' );
 
 
 
 
 
 
 
19
  }
20
  add_action( 'admin_enqueue_scripts', 'wpzerospam_admin_scripts' );
21
 
9
  /**
10
  * Add admin scripts
11
  */
12
+ function wpzerospam_admin_scripts( $hook_suffix ) {
13
  $plugin = get_plugin_data( WORDPRESS_ZERO_SPAM );
14
 
15
+ $admin_pages = [ 'toplevel_page_wordpress-zero-spam', 'wp-zero-spam_page_wordpress-zero-spam-blocked-ips' ];
16
+
17
+ if (
18
+ ! empty( $hook_suffix ) &&
19
+ in_array( $hook_suffix, $admin_pages )
20
+ ) {
21
+ wp_enqueue_style( 'wpzerospam-admin', plugin_dir_url( WORDPRESS_ZERO_SPAM ) . '/assets/css/admin.css', false, $plugin['Version'] );
22
+ wp_enqueue_script( 'wpzerospam-admin', plugin_dir_url( WORDPRESS_ZERO_SPAM ) . '/assets/js/admin.js', [ 'jquery' ], $plugin['Version'], true );
23
+ wp_enqueue_style( 'wpzerospam-charts', plugin_dir_url( WORDPRESS_ZERO_SPAM ) . '/assets/css/Chart.min.css', false, '2.9.3' );
24
+ wp_enqueue_script( 'wpzerospam-charts', plugin_dir_url( WORDPRESS_ZERO_SPAM ) . '/assets/js/Chart.bundle.min.js', [], '2.9.3' );
25
+ }
26
  }
27
  add_action( 'admin_enqueue_scripts', 'wpzerospam_admin_scripts' );
28
 
readme.txt CHANGED
@@ -5,7 +5,7 @@ Donate link: https://benmarshall.me/donate/?utm_source=wordpress_zero_spam&utm_m
5
  Requires at least: 5.2
6
  Tested up to: 5.4.2
7
  Requires PHP: 7.1
8
- Stable tag: 4.3.3
9
  License: GNU GPLv3
10
  License URI: https://choosealicense.com/licenses/gpl-3.0/
11
 
@@ -88,6 +88,14 @@ Yes, that's what does the magic and keeps spam bots out.
88
 
89
  == Changelog ==
90
 
 
 
 
 
 
 
 
 
91
  = 4.3.3 =
92
 
93
  * Fix for `REFERRER_ANALYTICS` unknown constant
5
  Requires at least: 5.2
6
  Tested up to: 5.4.2
7
  Requires PHP: 7.1
8
+ Stable tag: 4.3.4
9
  License: GNU GPLv3
10
  License URI: https://choosealicense.com/licenses/gpl-3.0/
11
 
88
 
89
  == Changelog ==
90
 
91
+ = 4.3.4 =
92
+
93
+ * Fixed issue with adding/updating IP addresses manually
94
+ * Fixed PHP notice for missing submission data on the log chart
95
+ * Fixed PHP notice for "Undefined index: log_blocked_ips". See [#191](https://github.com/bmarshall511/wordpress-zero-spam/issues/191)
96
+ * Updated the admin scripts to only login on the plugin admin pages
97
+ * Fixed an issue with default add-on plugin options being disabled on first save. See [#192](https://github.com/bmarshall511/wordpress-zero-spam/issues/192)
98
+
99
  = 4.3.3 =
100
 
101
  * Fix for `REFERRER_ANALYTICS` unknown constant
templates/ip-list.php CHANGED
@@ -6,7 +6,7 @@
6
  * @since 1.0.0
7
  */
8
 
9
- $chart_limit = 15;
10
  ?>
11
  <div class="wpzerospam-box">
12
  <h3><?php _e( 'Most Spam by IP Address', 'wpzerospam' ); ?></h3>
6
  * @since 1.0.0
7
  */
8
 
9
+ $chart_limit = 20;
10
  ?>
11
  <div class="wpzerospam-box">
12
  <h3><?php _e( 'Most Spam by IP Address', 'wpzerospam' ); ?></h3>
wordpress-zero-spam.php CHANGED
@@ -13,7 +13,7 @@
13
  * Plugin Name: WordPress Zero Spam
14
  * Plugin URI: https://benmarshall.me/wordpress-zero-spam
15
  * Description: Tired of all the useless and bloated WordPress spam plugins? The WordPress Zero Spam plugin makes blocking spam a cinch. <strong>Just install, activate and say goodbye to spam.</strong> Based on work by <a href="http://davidwalsh.name/wordpress-comment-spam" target="_blank">David Walsh</a>.
16
- * Version: 4.3.3
17
  * Requires at least: 5.2
18
  * Requires PHP: 7.2
19
  * Author: Ben Marshall
@@ -130,10 +130,7 @@ if ( ! function_exists( 'wpzerospam_template_redirect' ) ) {
130
  $access = wpzerospam_check_access();
131
 
132
  if ( ! $access['access'] ) {
133
- wpzerospam_attempt_blocked([
134
- 'reason' => $access['reason'],
135
- 'ip' => $access['ip']
136
- ]);
137
  }
138
  }
139
  }
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.4
17
  * Requires at least: 5.2
18
  * Requires PHP: 7.2
19
  * Author: Ben Marshall
130
  $access = wpzerospam_check_access();
131
 
132
  if ( ! $access['access'] ) {
133
+ wpzerospam_attempt_blocked( $access['reason'] );
 
 
 
134
  }
135
  }
136
  }