WordPress Zero Spam - Version 5.2.4

Version Description

Download this release

Release Info

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

Code changes from version 5.2.3 to 5.2.4

assets/css/admin.css CHANGED
@@ -241,7 +241,10 @@
241
  .zerospam-type-fluent_form::before,
242
  .zerospam-type-wpforms::before,
243
  .zerospam-type-contactform7::before,
244
- .zerospam-type-givewp::before {
 
 
 
245
  background-repeat: no-repeat;
246
  background-size: contain;
247
  content: "";
@@ -283,11 +286,21 @@
283
  background-image: url('../img/icon-cf7.png');
284
  }
285
 
286
- /* Type gicewp */
 
 
 
 
 
287
  .zerospam-type-givewp::before {
288
  background-image: url('../img/icon-givewp.png');
289
  }
290
 
 
 
 
 
 
291
  @media (min-width: 768px) {
292
  .zerospam-callout {
293
  flex-wrap: nowrap;
241
  .zerospam-type-fluent_form::before,
242
  .zerospam-type-wpforms::before,
243
  .zerospam-type-contactform7::before,
244
+ .zerospam-type-givewp::before,
245
+ .zerospam-type-memberpress_registration::before,
246
+ .zerospam-type-mailchimp4wp::before {
247
+ background-position: center;
248
  background-repeat: no-repeat;
249
  background-size: contain;
250
  content: "";
286
  background-image: url('../img/icon-cf7.png');
287
  }
288
 
289
+ /* Type: memberpress_registration */
290
+ .zerospam-type-memberpress_registration::before {
291
+ background-image: url('../img/icon-memberpress.svg');
292
+ }
293
+
294
+ /* Type: givewp */
295
  .zerospam-type-givewp::before {
296
  background-image: url('../img/icon-givewp.png');
297
  }
298
 
299
+ /* Type: mailchimp4wp */
300
+ .zerospam-type-mailchimp4wp::before {
301
+ background-image: url('../img/icon-mc4wp.svg');
302
+ }
303
+
304
  @media (min-width: 768px) {
305
  .zerospam-callout {
306
  flex-wrap: nowrap;
assets/img/icon-mc4wp.svg ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <svg
3
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
4
+ xmlns:cc="http://creativecommons.org/ns#"
5
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
6
+ xmlns:svg="http://www.w3.org/2000/svg"
7
+ xmlns="http://www.w3.org/2000/svg"
8
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
9
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
10
+ width="64"
11
+ height="64"
12
+ viewBox="0 0 64 64"
13
+ version="1.1"
14
+ id="SVGRoot"
15
+ inkscape:version="0.92.4 5da689c313, 2019-01-14"
16
+ sodipodi:docname="mc4wp-logo-white-on-red.svg">
17
+ <g
18
+ inkscape:groupmode="layer"
19
+ id="layer2"
20
+ inkscape:label="Layer 2">
21
+ <circle
22
+ style="opacity:1;fill:#cc4444;fill-opacity:1;stroke:none;stroke-opacity:1"
23
+ id="path5822"
24
+ cx="32"
25
+ cy="32"
26
+ r="32" />
27
+ </g>
28
+ <g
29
+ inkscape:label="Layer 1"
30
+ inkscape:groupmode="layer"
31
+ id="layer1">
32
+ <path
33
+ style="fill:#ffffff;fill-opacity:1;stroke:none;"
34
+ d="m 16,47.324799 c -0.02985,-0.09271 -0.175159,-1.230558 -0.322927,-2.528543 -0.561978,-4.936413 -2.305204,-9.961206 -5.201976,-14.994537 -0.9733359,-1.691234 -0.9585997,-1.750867 0.663154,-2.683422 0.912236,-0.524562 2.279359,-1.38885 3.038049,-1.920641 1.289813,-0.904069 1.486868,-0.821985 3.032878,1.26335 1.278999,1.725178 1.731406,1.998919 1.997727,1.208779 0.407819,-1.209946 4.748289,-4.450438 5.96113,-4.450438 0.465172,0 1.603153,1.364871 2.528847,3.033047 0.925694,1.668177 1.852705,3.03359 2.060024,3.034253 0.580399,0.0019 1.2257,-5.915967 0.808345,-7.413054 -0.293707,-1.053553 0.21226,-1.748685 2.447515,-3.362568 1.549769,-1.118954 3.016679,-2.034461 3.2598,-2.034461 0.243121,0 2.673101,3.413534 5.399956,7.585632 2.726854,4.172097 6.744105,9.861321 8.927221,12.642719 l 3.969305,5.057088 -2.073345,2.191405 c -1.140339,1.205272 -2.429057,2.191404 -2.863817,2.191404 -1.383243,0 -5.331006,-4.389741 -8.999106,-10.006614 -1.954436,-2.992783 -3.753407,-5.455006 -3.997711,-5.471606 -0.244305,-0.0166 -0.44419,2.520101 -0.44419,5.637112 v 5.667295 l -2.62254,1.749768 c -1.442397,0.962371 -2.841596,1.748706 -3.109332,1.747409 -0.267735,-0.0013 -1.285075,-1.687162 -2.260756,-3.746367 -0.97568,-2.059206 -2.342064,-4.351629 -3.036409,-5.094272 l -1.262444,-1.350262 -0.401863,1.893807 c -1.3843,6.523625 -1.59298,6.985894 -3.90308,8.646166 C 17.549496,47.286963 16.173566,47.864041 16,47.324799 Z"
35
+ id="path4520"
36
+ inkscape:connector-curvature="0" />
37
+ </g>
38
+ </svg>
assets/img/icon-memberpress.svg ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <svg width="73px" height="41px" viewBox="0 0 73 41" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
3
+ <title>memberpress-logo-color</title>
4
+ <g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
5
+ <g id="memberpress-logo-color" transform="translate(0.700000, 0.000000)" fill-rule="nonzero">
6
+ <g id="Group">
7
+ <g id="Path">
8
+ <path d="M47.3,17.5 C47.3,13.4 50.6,10.1 54.7,10.1 C58.8,10.1 62.1,13.4 62.1,17.5 L62.1,35 C62.1,37.8 64.4,40 67.1,40 C69.9,40 72.1,37.7 72.1,35 L72.1,17.5 C72.2,7.8 64.4,0 54.7,0 C49.9,0 45.5,2 42.3,5.2 C45.4,8.4 47.3,12.7 47.3,17.5 L47.3,17.5 Z" fill="#20D1CC"></path>
9
+ <path d="M37.3,17.5 C37.3,12.7 39.2,8.4 42.3,5.2 C39.1,2 34.7,0 29.9,0 C25,0 20.6,2 17.5,5.2 C20.6,8.3 22.5,12.7 22.5,17.4 C22.5,13.3 25.8,10 29.9,10 C34,10.1 37.3,13.4 37.3,17.5 L37.3,17.5 Z" fill="#05D0E0"></path>
10
+ <path d="M47.3,35 L47.3,17.5 C47.3,12.7 45.4,8.4 42.3,5.2 C39.2,8.4 37.3,12.7 37.3,17.5 L37.3,35 C37.3,36.4 37.9,37.6 38.8,38.6 C39.7,39.5 41,40.1 42.4,40.1 C45.1,40 47.3,37.7 47.3,35 Z" fill="#01A9B2"></path>
11
+ <path d="M5,0 C2.2,0 -2.66453526e-15,2.3 -2.66453526e-15,5 C-2.66453526e-15,7.8 2.3,10 5,10 C9.1,10 12.4,13.3 12.4,17.4 C12.4,12.6 14.3,8.3 17.4,5.2 C14.3,2 9.9,0 5,0 Z" fill="#0282C9"></path>
12
+ <path d="M12.4,17.4 C12.4,17.4 12.4,17.4 12.4,17.4 L12.4,34.9 C12.4,37.7 14.7,39.9 17.4,39.9 C18.3,39.9 19.1,39.7 19.8,39.3 C21.4,38.4 22.4,36.8 22.4,34.9 L22.4,17.5 C22.4,17.5 22.4,17.5 22.4,17.5 C22.4,12.7 20.5,8.4 17.4,5.3 C14.3,8.4 12.4,12.7 12.4,17.4 Z" fill="#016BB1"></path>
13
+ </g>
14
+ <circle id="Oval" fill="#06429E" cx="5" cy="5" r="5"></circle>
15
+ <circle id="Oval" fill="#01569A" cx="17.4" cy="35" r="5"></circle>
16
+ <circle id="Oval" fill="#008C9D" cx="42.3" cy="35" r="5"></circle>
17
+ <circle id="Oval" fill="#03ABA3" cx="67.2" cy="35" r="5"></circle>
18
+ </g>
19
+ </g>
20
+ </g>
21
+ </svg>
core/admin/class-admin.php CHANGED
@@ -7,8 +7,6 @@
7
 
8
  namespace ZeroSpam\Core\Admin;
9
 
10
- use ZeroSpam\Core\Admin\Admin;
11
-
12
  // Security Note: Blocks direct access to the plugin PHP files.
13
  defined( 'ABSPATH' ) || die();
14
 
@@ -18,11 +16,11 @@ defined( 'ABSPATH' ) || die();
18
  class Admin {
19
 
20
  /**
21
- * Admin constructor
22
  */
23
  public function __construct() {
24
- new Settings();
25
- new Dashboard();
26
 
27
  add_filter( 'plugin_action_links_' . ZEROSPAM_PLUGIN_BASE, array( $this, 'plugin_action_links' ) );
28
  add_filter( 'plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 2 );
@@ -30,8 +28,6 @@ class Admin {
30
  add_action( 'admin_enqueue_scripts', array( $this, 'scripts' ) );
31
  add_action( 'wp_dashboard_setup', array( $this, 'register_dashboard_widget' ) );
32
 
33
- // Check if promotional message should be displayed.
34
-
35
  // Check first-time config.
36
  $configured = get_option( 'zerospam_configured' );
37
  if ( ! $configured ) {
@@ -40,7 +36,7 @@ class Admin {
40
  }
41
 
42
  /**
43
- * Register the admin dashboard widget.
44
  */
45
  public function register_dashboard_widget() {
46
  $selected_user_roles = \ZeroSpam\Core\Settings::get_settings( 'widget_visibility' );
@@ -59,11 +55,11 @@ class Admin {
59
  }
60
 
61
  /**
62
- * Output for the admin dashboard widget.
63
  */
64
  public function dashboard_widget() {
65
  $settings = \ZeroSpam\Core\Settings::get_settings();
66
- $entries = \ZeroSpam\Includes\DB::query( 'log' );
67
 
68
  if ( 'enabled' !== $settings['zerospam']['value'] || empty( $settings['zerospam_license']['value'] ) ) {
69
  ?>
@@ -116,7 +112,7 @@ class Admin {
116
  }
117
 
118
  /**
119
- * Display not configured notice.
120
  */
121
  public function not_configured_notice() {
122
  $message = sprintf(
@@ -141,10 +137,7 @@ class Admin {
141
  }
142
 
143
  /**
144
- * Scripts.
145
- *
146
- * @since 5.0.0
147
- * @access public
148
  */
149
  public function scripts( $hook_suffix ) {
150
  if (
@@ -169,18 +162,13 @@ class Admin {
169
  }
170
 
171
  /**
172
- * Plugin action links.
173
  *
174
  * Adds action links to the plugin list table
175
  *
176
  * Fired by `plugin_action_links` filter.
177
  *
178
- * @since 5.0.0
179
- * @access public
180
- *
181
  * @param array $links An array of plugin action links.
182
- *
183
- * @return array An array of plugin action links.
184
  */
185
  public function plugin_action_links( $links ) {
186
  $settings_link = sprintf( '<a href="%1$s">%2$s</a>', admin_url( 'options-general.php?page=wordpress-zero-spam-settings' ), __( 'Settings', 'zerospam' ) );
@@ -197,21 +185,16 @@ class Admin {
197
  *
198
  * Fired by `plugin_row_meta` filter.
199
  *
200
- * @since 5.0.0
201
- * @access public
202
- *
203
  * @param array $plugin_meta An array of the plugin's metadata, including
204
  * the version, author, author URI, and plugin URI.
205
  * @param string $plugin_file Path to the plugin file, relative to the plugins
206
  * directory.
207
- *
208
- * @return array An array of plugin row meta links.
209
  */
210
  public function plugin_row_meta( $plugin_meta, $plugin_file ) {
211
  if ( ZEROSPAM_PLUGIN_BASE === $plugin_file ) {
212
- $row_meta = [
213
  'docs' => '<a href="https://github.com/bmarshall511/wordpress-zero-spam/wiki" aria-label="' . esc_attr( __( 'View WordPress Zero Spam Documentation', 'zerospam' ) ) . '" target="_blank">' . __( 'Docs & FAQs', 'zerospam' ) . '</a>',
214
- ];
215
 
216
  $plugin_meta = array_merge( $plugin_meta, $row_meta );
217
  }
@@ -226,12 +209,7 @@ class Admin {
226
  *
227
  * Fired by `admin_footer_text` filter.
228
  *
229
- * @since 5.0.0
230
- * @access public
231
- *
232
  * @param string $footer_text The content that will be printed.
233
- *
234
- * @return string The content that will be printed.
235
  */
236
  public function admin_footer_text( $footer_text ) {
237
  $current_screen = get_current_screen();
7
 
8
  namespace ZeroSpam\Core\Admin;
9
 
 
 
10
  // Security Note: Blocks direct access to the plugin PHP files.
11
  defined( 'ABSPATH' ) || die();
12
 
16
  class Admin {
17
 
18
  /**
19
+ * Constructor
20
  */
21
  public function __construct() {
22
+ new \ZeroSpam\Core\Admin\Settings();
23
+ new \ZeroSpam\Core\Admin\Dashboard();
24
 
25
  add_filter( 'plugin_action_links_' . ZEROSPAM_PLUGIN_BASE, array( $this, 'plugin_action_links' ) );
26
  add_filter( 'plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 2 );
28
  add_action( 'admin_enqueue_scripts', array( $this, 'scripts' ) );
29
  add_action( 'wp_dashboard_setup', array( $this, 'register_dashboard_widget' ) );
30
 
 
 
31
  // Check first-time config.
32
  $configured = get_option( 'zerospam_configured' );
33
  if ( ! $configured ) {
36
  }
37
 
38
  /**
39
+ * Register the admin dashboard widget
40
  */
41
  public function register_dashboard_widget() {
42
  $selected_user_roles = \ZeroSpam\Core\Settings::get_settings( 'widget_visibility' );
55
  }
56
 
57
  /**
58
+ * Output for the admin dashboard widget
59
  */
60
  public function dashboard_widget() {
61
  $settings = \ZeroSpam\Core\Settings::get_settings();
62
+ $entries = \ZeroSpam\Includes\DB::query( 'log' );
63
 
64
  if ( 'enabled' !== $settings['zerospam']['value'] || empty( $settings['zerospam_license']['value'] ) ) {
65
  ?>
112
  }
113
 
114
  /**
115
+ * Display not configured notice
116
  */
117
  public function not_configured_notice() {
118
  $message = sprintf(
137
  }
138
 
139
  /**
140
+ * Scripts
 
 
 
141
  */
142
  public function scripts( $hook_suffix ) {
143
  if (
162
  }
163
 
164
  /**
165
+ * Plugin action links
166
  *
167
  * Adds action links to the plugin list table
168
  *
169
  * Fired by `plugin_action_links` filter.
170
  *
 
 
 
171
  * @param array $links An array of plugin action links.
 
 
172
  */
173
  public function plugin_action_links( $links ) {
174
  $settings_link = sprintf( '<a href="%1$s">%2$s</a>', admin_url( 'options-general.php?page=wordpress-zero-spam-settings' ), __( 'Settings', 'zerospam' ) );
185
  *
186
  * Fired by `plugin_row_meta` filter.
187
  *
 
 
 
188
  * @param array $plugin_meta An array of the plugin's metadata, including
189
  * the version, author, author URI, and plugin URI.
190
  * @param string $plugin_file Path to the plugin file, relative to the plugins
191
  * directory.
 
 
192
  */
193
  public function plugin_row_meta( $plugin_meta, $plugin_file ) {
194
  if ( ZEROSPAM_PLUGIN_BASE === $plugin_file ) {
195
+ $row_meta = array(
196
  'docs' => '<a href="https://github.com/bmarshall511/wordpress-zero-spam/wiki" aria-label="' . esc_attr( __( 'View WordPress Zero Spam Documentation', 'zerospam' ) ) . '" target="_blank">' . __( 'Docs & FAQs', 'zerospam' ) . '</a>',
197
+ );
198
 
199
  $plugin_meta = array_merge( $plugin_meta, $row_meta );
200
  }
209
  *
210
  * Fired by `admin_footer_text` filter.
211
  *
 
 
 
212
  * @param string $footer_text The content that will be printed.
 
 
213
  */
214
  public function admin_footer_text( $footer_text ) {
215
  $current_screen = get_current_screen();
core/admin/class-settings.php CHANGED
@@ -13,17 +13,12 @@ use ZeroSpam;
13
  defined( 'ABSPATH' ) || die();
14
 
15
  /**
16
- * Settings.
17
- *
18
- * @since 5.0.0
19
  */
20
  class Settings {
21
 
22
  /**
23
- * Admin constructor.
24
- *
25
- * @since 5.0.0
26
- * @access public
27
  */
28
  public function __construct() {
29
  add_action( 'admin_menu', array( $this, 'admin_menu' ) );
@@ -58,6 +53,13 @@ class Settings {
58
  exit;
59
  }
60
 
 
 
 
 
 
 
 
61
  if ( ! empty( $_REQUEST['zerospam-msg'] ) ) {
62
  add_action(
63
  'admin_notices',
@@ -69,9 +71,7 @@ class Settings {
69
  }
70
 
71
  /**
72
- * Imports settings.
73
- *
74
- * @since 5.1.0
75
  */
76
  public function import_settings() {
77
  $redirect = ! empty( $_POST['redirect'] ) ? esc_url( sanitize_text_field( wp_unslash( $_POST['redirect'] ) ) ) : get_site_url();
@@ -109,7 +109,7 @@ class Settings {
109
  }
110
 
111
  /**
112
- * Regenerates the honeypot ID.
113
  */
114
  public function regenerate_honeypot() {
115
  \ZeroSpam\Core\Utilities::get_honeypot( true );
@@ -130,7 +130,7 @@ class Settings {
130
  }
131
 
132
  /**
133
- * Validates plugin settings before save.
134
  */
135
  public function settings_validation( $input ) {
136
  update_option( 'zerospam_configured', 1 );
@@ -424,73 +424,50 @@ class Settings {
424
  if ( ! current_user_can( 'manage_options' ) ) {
425
  return;
426
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
427
  ?>
428
  <div class="wrap">
429
  <h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
 
430
  <?php require ZEROSPAM_PATH . 'includes/templates/admin-callout.php'; ?>
431
 
432
- <?php if ( ! empty( $_GET['zerospam-error'] ) ): ?>
433
- <div class="notice notice-error is-dismissible">
434
- <p><strong>
435
- <?php
436
- switch( intval( $_GET['zerospam-error'] ) ) :
437
- case 1:
438
- esc_html_e( 'There was a problem importing the settings JSON. Please try again.', 'zerospam' );
439
- break;
440
- endswitch;
441
- ?>
442
- </strong></p>
443
- <button type="button" class="notice-dismiss"><span class="screen-reader-text"><?php esc_html_e( 'Dismiss this notice.', 'zerospam' ); ?></span></button>
444
- </div>
445
- <?php elseif ( ! empty( $_GET['zerospam-success'] ) ): ?>
446
- <div class="notice notice-success is-dismissible">
447
- <p><strong><?php esc_html_e( 'The settings JSON has been successfully imported.', 'zerospam' ); ?></strong></p>
448
- <button type="button" class="notice-dismiss"><span class="screen-reader-text"><?php esc_html_e( 'Dismiss this notice.', 'zerospam' ); ?>.</span></button>
449
- </div>
450
- <?php endif; ?>
451
-
452
- <form action="options.php" method="post">
453
- <?php
454
- // Output security fields for the registered setting "wpzerospam".
455
- settings_fields( 'wpzerospam' );
456
-
457
- echo '<div class="zerospam-settings-tabs">';
458
- // Output setting sections and their fields.
459
- do_settings_sections( 'wpzerospam' );
460
-
461
- // Output save settings button.
462
- submit_button( 'Save Settings' );
463
- ?>
464
- </form>
465
-
466
- <h3><?php esc_html_e( 'Settings Import/Export', 'zerospam' ); ?></h3>
467
- <p><?php esc_html_e( 'Quickly export and import your saved settings into other sites below.', 'zerospam' ); ?></p>
468
- <?php
469
- $settings = ZeroSpam\Core\Settings::get_settings();
470
- $settings_json = array();
471
- foreach ( $settings as $key => $data ) {
472
- if ( isset( $data['value'] ) ) {
473
- $settings_json[ $key ] = $data['value'];
474
- }
475
- }
476
- ?>
477
- <div class="zerospam-export-import-block">
478
- <div class="zerospam-export-import-block-column">
479
- <h4><?php esc_html_e( 'Settings JSON', 'zerospam' ); ?></h4>
480
- <textarea readonly class="large-text code" rows="10"><?php echo wp_json_encode( $settings_json ); ?></textarea>
481
- </div>
482
- <div class="zerospam-export-import-block-column">
483
- <h4><?php esc_html_e( 'Paste the settings JSON to import.', 'zerospam' ); ?></h4>
484
- <form method="post" action="<?php echo esc_url( admin_url( 'admin.php' ) ); ?>" class="zerospam-import-settings-form">
485
- <?php wp_nonce_field( 'import_settings', 'zerospam' ); ?>
486
- <input type="hidden" name="action" value="import_settings" />
487
- <input type="hidden" name="redirect" value="<?php echo esc_url( ZeroSpam\Core\Utilities::current_url() ); ?>" />
488
- <textarea class="large-text code" name="settings" rows="10"></textarea>
489
- <input type="submit" class="button button-primary" value="<?php esc_html_e( 'Import Settings', 'zerospam' ); ?>" />
490
- </form>
491
- </div>
492
- </div>
493
- <?php echo '</div>'; ?>
494
  </div>
495
  <?php
496
  }
13
  defined( 'ABSPATH' ) || die();
14
 
15
  /**
16
+ * Settings
 
 
17
  */
18
  class Settings {
19
 
20
  /**
21
+ * Admin constructor
 
 
 
22
  */
23
  public function __construct() {
24
  add_action( 'admin_menu', array( $this, 'admin_menu' ) );
53
  exit;
54
  }
55
 
56
+ if ( ! empty( $_REQUEST['delete-error-log'] ) ) {
57
+ \ZeroSpam\Core\Utilities::delete_error_log();
58
+
59
+ wp_safe_redirect( admin_url( 'options-general.php?page=wordpress-zero-spam-settings&tab=error&zerospam-msg=The error log has been successfully deleted.' ) );
60
+ exit;
61
+ }
62
+
63
  if ( ! empty( $_REQUEST['zerospam-msg'] ) ) {
64
  add_action(
65
  'admin_notices',
71
  }
72
 
73
  /**
74
+ * Imports settings
 
 
75
  */
76
  public function import_settings() {
77
  $redirect = ! empty( $_POST['redirect'] ) ? esc_url( sanitize_text_field( wp_unslash( $_POST['redirect'] ) ) ) : get_site_url();
109
  }
110
 
111
  /**
112
+ * Regenerates the honeypot ID
113
  */
114
  public function regenerate_honeypot() {
115
  \ZeroSpam\Core\Utilities::get_honeypot( true );
130
  }
131
 
132
  /**
133
+ * Validates plugin settings before save
134
  */
135
  public function settings_validation( $input ) {
136
  update_option( 'zerospam_configured', 1 );
424
  if ( ! current_user_can( 'manage_options' ) ) {
425
  return;
426
  }
427
+
428
+ $base_admin_link = 'options-general.php?page=wordpress-zero-spam-settings';
429
+ // @codingStandardsIgnoreLine
430
+ $current_tab = ! empty( $_REQUEST['tab'] ) ? esc_html( $_REQUEST['tab'] ) : 'settings';
431
+ $admin_tabs = array(
432
+ 'settings' => array(
433
+ 'title' => __( 'Settings', 'zerospam' ),
434
+ 'template' => 'settings',
435
+ ),
436
+ 'export' => array(
437
+ 'title' => __( 'Export/Import Settings', 'zerospam' ),
438
+ 'template' => 'export',
439
+ ),
440
+ 'error' => array(
441
+ 'title' => __( 'Error Log', 'zerospam' ),
442
+ 'template' => 'errors',
443
+ ),
444
+ );
445
  ?>
446
  <div class="wrap">
447
  <h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
448
+
449
  <?php require ZEROSPAM_PATH . 'includes/templates/admin-callout.php'; ?>
450
 
451
+ <nav class="nav-tab-wrapper" style="margin-bottom: 16px;">
452
+ <?php
453
+ foreach ( $admin_tabs as $key => $tab ) :
454
+ $admin_url = admin_url( $base_admin_link . '&amp;tab=' . $key );
455
+ $classes = array( 'nav-tab' );
456
+
457
+ if ( $current_tab === $key ) :
458
+ $classes[] = 'nav-tab-active';
459
+ endif;
460
+ ?>
461
+ <a
462
+ href="<?php echo esc_url( $admin_url ); ?>"
463
+ class="<?php echo esc_attr( implode( ' ', $classes ) ); ?>"
464
+ >
465
+ <?php echo esc_html( $tab['title'] ); ?>
466
+ </a>
467
+ <?php endforeach; ?>
468
+ </nav>
469
+
470
+ <?php require ZEROSPAM_PATH . 'includes/templates/settings/' . $admin_tabs[ $current_tab ]['template'] . '.php'; ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
471
  </div>
472
  <?php
473
  }
core/admin/tables/class-logtable.php CHANGED
@@ -14,17 +14,12 @@ use WP_List_Table;
14
  defined( 'ABSPATH' ) || die();
15
 
16
  /**
17
- * Log table.
18
- *
19
- * @since 5.0.0
20
  */
21
  class LogTable extends WP_List_Table {
22
 
23
  /**
24
- * Log table constructor.
25
- *
26
- * @since 5.0.0
27
- * @access public
28
  */
29
  public function __construct() {
30
  global $status, $page;
@@ -37,10 +32,7 @@ class LogTable extends WP_List_Table {
37
  }
38
 
39
  /**
40
- * Column values.
41
- *
42
- * @since 5.0.0
43
- * @access public
44
  */
45
  public function column_default( $item, $column_name ) {
46
  switch ( $column_name ) {
@@ -69,19 +61,15 @@ class LogTable extends WP_List_Table {
69
  case 'date_recorded':
70
  return gmdate( 'm/d/y g:ia' , strtotime( $item[ $column_name ] ) );
71
  break;
72
- case 'details':
73
  ob_start();
74
  ?>
75
- <button class="button zerospam-details-trigger" data-id="<?php echo esc_attr( $item['log_id'] ); ?>"><?php _e( 'View', 'zerospam' ); ?></button>
76
  <div class="zerospam-modal" id="zerospam-details-<?php echo esc_attr( $item['log_id'] ); ?>">
77
  <button class="zerospam-close-modal" aria-label="<?php echo esc_attr( __( 'Close Modal', 'zerospam' ) ); ?>"></button>
78
  <?php require ZEROSPAM_PATH . 'includes/templates/admin-modal-details.php'; ?>
79
  </div>
80
  <?php
81
- return ob_get_clean();
82
- break;
83
- case 'actions':
84
- ob_start();
85
  $blocked = ZeroSpam\Includes\DB::blocked( $item['user_ip'] );
86
  if ( $blocked ) :
87
  ?>
@@ -93,12 +81,12 @@ class LogTable extends WP_List_Table {
93
  data-end="<?php echo esc_attr( gmdate( 'Y-m-d', strtotime( $blocked['end_block'] ) ) ); ?>T<?php echo esc_attr( gmdate( 'H:i', strtotime( $blocked['end_block'] ) ) ); ?>"
94
  data-type="<?php echo esc_attr( $blocked['blocked_type'] ); ?>"
95
  >
96
- <?php _e( 'Update Block', 'zerospam' ); ?>
97
  </button>
98
  <?php
99
  else :
100
  ?>
101
- <button class="button zerospam-block-trigger" data-ip="<?php echo esc_attr( $item['user_ip'] ); ?>"><?php _e( 'Block IP', 'zerospam' ); ?></button>
102
  <?php
103
  endif;
104
 
@@ -130,10 +118,7 @@ class LogTable extends WP_List_Table {
130
  }
131
 
132
  /**
133
- * Bulk actions.
134
- *
135
- * @since 5.0.0
136
- * @access public
137
  */
138
  public function get_bulk_actions() {
139
  $actions = array(
@@ -145,20 +130,14 @@ class LogTable extends WP_List_Table {
145
  }
146
 
147
  /**
148
- * Hidable columns.
149
- *
150
- * @since 5.0.0
151
- * @access public
152
  */
153
  public function get_hidden_columns() {
154
  return array();
155
  }
156
 
157
  /**
158
- * Prepare log items.
159
- *
160
- * @since 5.0.0
161
- * @access public
162
  */
163
  public function prepare_items( $args = array() ) {
164
  $this->process_bulk_action();
@@ -245,10 +224,7 @@ class LogTable extends WP_List_Table {
245
  }
246
 
247
  /**
248
- * Add more filters.
249
- *
250
- * @since 5.0.0
251
- * @access public
252
  */
253
  public function extra_tablenav( $which ) {
254
  if ( 'top' !== $which ) {
@@ -286,10 +262,7 @@ class LogTable extends WP_List_Table {
286
  }
287
 
288
  /**
289
- * Define table columns.
290
- *
291
- * @since 5.0.0
292
- * @access public
293
  */
294
  public function get_columns() {
295
  $columns = array(
@@ -299,8 +272,6 @@ class LogTable extends WP_List_Table {
299
  'user_ip' => __( 'IP Address', 'zerospam' ),
300
  'country' => __( 'Country', 'zerospam' ),
301
  'region' => __( 'Region', 'zerospam' ),
302
- 'city' => __( 'City', 'zerospam' ),
303
- 'details' => __( 'Details', 'zerospam' ),
304
  'actions' => __( 'Actions', 'zerospam' ),
305
  );
306
 
@@ -308,10 +279,7 @@ class LogTable extends WP_List_Table {
308
  }
309
 
310
  /**
311
- * Sortable columns.
312
- *
313
- * @since 5.0.0
314
- * @access public
315
  */
316
  public function get_sortable_columns() {
317
  $sortable_columns = array(
@@ -320,17 +288,13 @@ class LogTable extends WP_List_Table {
320
  'user_ip' => array( 'user_ip', false ),
321
  'country' => array( 'country', false ),
322
  'region' => array( 'region', false ),
323
- 'city' => array( 'city', false ),
324
  );
325
 
326
  return $sortable_columns;
327
  }
328
 
329
  /**
330
- * Column contact.
331
- *
332
- * @since 5.0.0
333
- * @access public
334
  */
335
  public function column_cb( $item ) {
336
  return sprintf(
@@ -341,10 +305,7 @@ class LogTable extends WP_List_Table {
341
  }
342
 
343
  /**
344
- * Process bulk actions.
345
- *
346
- * @since 5.0.0
347
- * @access public
348
  */
349
  public function process_bulk_action() {
350
  global $wpdb;
14
  defined( 'ABSPATH' ) || die();
15
 
16
  /**
17
+ * Log table
 
 
18
  */
19
  class LogTable extends WP_List_Table {
20
 
21
  /**
22
+ * Constructor
 
 
 
23
  */
24
  public function __construct() {
25
  global $status, $page;
32
  }
33
 
34
  /**
35
+ * Column values
 
 
 
36
  */
37
  public function column_default( $item, $column_name ) {
38
  switch ( $column_name ) {
61
  case 'date_recorded':
62
  return gmdate( 'm/d/y g:ia' , strtotime( $item[ $column_name ] ) );
63
  break;
64
+ case 'actions':
65
  ob_start();
66
  ?>
67
+ <button class="button zerospam-details-trigger" data-id="<?php echo esc_attr( $item['log_id'] ); ?>"><?php esc_html_e( 'Details', 'zerospam' ); ?></button>
68
  <div class="zerospam-modal" id="zerospam-details-<?php echo esc_attr( $item['log_id'] ); ?>">
69
  <button class="zerospam-close-modal" aria-label="<?php echo esc_attr( __( 'Close Modal', 'zerospam' ) ); ?>"></button>
70
  <?php require ZEROSPAM_PATH . 'includes/templates/admin-modal-details.php'; ?>
71
  </div>
72
  <?php
 
 
 
 
73
  $blocked = ZeroSpam\Includes\DB::blocked( $item['user_ip'] );
74
  if ( $blocked ) :
75
  ?>
81
  data-end="<?php echo esc_attr( gmdate( 'Y-m-d', strtotime( $blocked['end_block'] ) ) ); ?>T<?php echo esc_attr( gmdate( 'H:i', strtotime( $blocked['end_block'] ) ) ); ?>"
82
  data-type="<?php echo esc_attr( $blocked['blocked_type'] ); ?>"
83
  >
84
+ <?php esc_html_e( 'Update Block', 'zerospam' ); ?>
85
  </button>
86
  <?php
87
  else :
88
  ?>
89
+ <button class="button zerospam-block-trigger" data-ip="<?php echo esc_attr( $item['user_ip'] ); ?>"><?php esc_html_e( 'Block IP', 'zerospam' ); ?></button>
90
  <?php
91
  endif;
92
 
118
  }
119
 
120
  /**
121
+ * Bulk actions
 
 
 
122
  */
123
  public function get_bulk_actions() {
124
  $actions = array(
130
  }
131
 
132
  /**
133
+ * Hidable columns
 
 
 
134
  */
135
  public function get_hidden_columns() {
136
  return array();
137
  }
138
 
139
  /**
140
+ * Prepare log items
 
 
 
141
  */
142
  public function prepare_items( $args = array() ) {
143
  $this->process_bulk_action();
224
  }
225
 
226
  /**
227
+ * Add more filters
 
 
 
228
  */
229
  public function extra_tablenav( $which ) {
230
  if ( 'top' !== $which ) {
262
  }
263
 
264
  /**
265
+ * Define table columns
 
 
 
266
  */
267
  public function get_columns() {
268
  $columns = array(
272
  'user_ip' => __( 'IP Address', 'zerospam' ),
273
  'country' => __( 'Country', 'zerospam' ),
274
  'region' => __( 'Region', 'zerospam' ),
 
 
275
  'actions' => __( 'Actions', 'zerospam' ),
276
  );
277
 
279
  }
280
 
281
  /**
282
+ * Sortable columns
 
 
 
283
  */
284
  public function get_sortable_columns() {
285
  $sortable_columns = array(
288
  'user_ip' => array( 'user_ip', false ),
289
  'country' => array( 'country', false ),
290
  'region' => array( 'region', false ),
 
291
  );
292
 
293
  return $sortable_columns;
294
  }
295
 
296
  /**
297
+ * Column contact
 
 
 
298
  */
299
  public function column_cb( $item ) {
300
  return sprintf(
305
  }
306
 
307
  /**
308
+ * Process bulk actions
 
 
 
309
  */
310
  public function process_bulk_action() {
311
  global $wpdb;
core/class-access.php CHANGED
@@ -13,21 +13,16 @@ use ZeroSpam;
13
  defined( 'ABSPATH' ) || die();
14
 
15
  /**
16
- * Admin.
17
- *
18
- * Handles access checks.
19
- *
20
- * @since 5.0.0
21
  */
22
  class Access {
23
 
24
  /**
25
- * Access constructor.
26
- *
27
- * @since 5.0.0
28
- * @access private
29
  */
30
  public function __construct() {
 
 
31
  if ( self::process() ) {
32
  add_action( 'template_redirect', array( $this, 'access_check' ), 0 );
33
  add_filter( 'zerospam_access_checks', array( $this, 'check_blocked' ), 0, 3 );
13
  defined( 'ABSPATH' ) || die();
14
 
15
  /**
16
+ * Access
 
 
 
 
17
  */
18
  class Access {
19
 
20
  /**
21
+ * Cnstructor
 
 
 
22
  */
23
  public function __construct() {
24
+ add_filter( 'zerospam_types', array( $this, 'types' ), 10, 1 );
25
+
26
  if ( self::process() ) {
27
  add_action( 'template_redirect', array( $this, 'access_check' ), 0 );
28
  add_filter( 'zerospam_access_checks', array( $this, 'check_blocked' ), 0, 3 );
core/class-utilities.php CHANGED
@@ -57,6 +57,45 @@ class Utilities {
57
  return $array;
58
  }
59
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
  /**
61
  * Returns list of recommended blocked email domains.
62
  */
@@ -72,7 +111,10 @@ class Utilities {
72
  return false;
73
  }
74
 
75
- return explode( "\n", $text );
 
 
 
76
  }
77
 
78
  /**
57
  return $array;
58
  }
59
 
60
+ /**
61
+ * Deletes the error log.
62
+ */
63
+ public static function delete_error_log() {
64
+ $upload_dir = wp_upload_dir();
65
+ $upload_dir = $upload_dir['basedir'];
66
+ $file = $upload_dir . '/zerospam.log';
67
+
68
+ if ( $file_path && file_exists( $file_path ) ) {
69
+ wp_delete_file( $file );
70
+ }
71
+ }
72
+
73
+ /**
74
+ * Returns an array from the Zero Spam error log.
75
+ */
76
+ public static function get_error_log() {
77
+ global $wp_filesystem;
78
+ if ( empty( $wp_filesystem ) ) {
79
+ require_once ABSPATH . '/wp-admin/includes/file.php';
80
+ WP_Filesystem();
81
+ }
82
+
83
+ $upload_dir = wp_upload_dir();
84
+ $upload_dir = $upload_dir['basedir'];
85
+ $file = $upload_dir . '/zerospam.log';
86
+
87
+ if ( $file && file_exists( $file ) ) {
88
+ $text = $wp_filesystem->get_contents( $file );
89
+ if ( ! $text ) {
90
+ return false;
91
+ }
92
+
93
+ return $text;
94
+ }
95
+
96
+ return false;
97
+ }
98
+
99
  /**
100
  * Returns list of recommended blocked email domains.
101
  */
111
  return false;
112
  }
113
 
114
+ $emails_array = explode( "\n", $text );
115
+ $emails_array = array_map( 'trim', $emails_array );
116
+
117
+ return $emails_array;
118
  }
119
 
120
  /**
includes/class-autoloader.php CHANGED
@@ -11,38 +11,34 @@ namespace ZeroSpam;
11
  defined( 'ABSPATH' ) || die();
12
 
13
  /**
14
- * WordPress Zero Spam autoloader
15
  *
16
- * WordPress Zero Spam autoloader handler class is responsible for loading the
17
- * different classes needed to run the plugin.
18
  */
19
  class Autoloader {
20
 
21
  /**
22
- * Default path for autoloader.
23
  *
24
  * @var string
25
  */
26
  private static $default_path;
27
 
28
  /**
29
- * Default namespace for autoloader.
30
  *
31
  * @var string
32
  */
33
  private static $default_namespace;
34
 
35
  /**
36
- * Run autoloader.
37
  *
38
  * Register a function as `__autoload()` implementation.
39
  *
40
- * @param string $default_path
41
- * @param string $default_namespace
42
- *
43
- * @since 5.0.0
44
- * @access public
45
- * @static
46
  */
47
  public static function run( $default_path = '', $default_namespace = '' ) {
48
  if ( '' === $default_path ) {
@@ -60,14 +56,10 @@ class Autoloader {
60
  }
61
 
62
  /**
63
- * Load class.
64
  *
65
  * For a given class name, require the class file.
66
  *
67
- * @since 5.0.0
68
- * @access private
69
- * @static
70
- *
71
  * @param string $relative_class_name Class name.
72
  */
73
  private static function load_class( $relative_class_name ) {
@@ -89,14 +81,10 @@ class Autoloader {
89
  }
90
 
91
  /**
92
- * Autoload.
93
  *
94
  * For a given class, check if it exist and load it.
95
  *
96
- * @since 5.0.0
97
- * @access private
98
- * @static
99
- *
100
  * @param string $class Class name.
101
  */
102
  private static function autoload( $class ) {
@@ -104,7 +92,11 @@ class Autoloader {
104
  return;
105
  }
106
 
107
- $relative_class_name = preg_replace( '/^' . self::$default_namespace . '\\\/', '', $class );
 
 
 
 
108
 
109
  $final_class_name = self::$default_namespace . '\\' . $relative_class_name;
110
 
11
  defined( 'ABSPATH' ) || die();
12
 
13
  /**
14
+ * Plugin autoloader
15
  *
16
+ * Autoloader handler class is responsible for loading the different classes
17
+ * needed to run the plugin.
18
  */
19
  class Autoloader {
20
 
21
  /**
22
+ * Default path for autoloader
23
  *
24
  * @var string
25
  */
26
  private static $default_path;
27
 
28
  /**
29
+ * Default namespace for autoloader
30
  *
31
  * @var string
32
  */
33
  private static $default_namespace;
34
 
35
  /**
36
+ * Run autoloader
37
  *
38
  * Register a function as `__autoload()` implementation.
39
  *
40
+ * @param string $default_path Default class path.
41
+ * @param string $default_namespace Default namespace.
 
 
 
 
42
  */
43
  public static function run( $default_path = '', $default_namespace = '' ) {
44
  if ( '' === $default_path ) {
56
  }
57
 
58
  /**
59
+ * Load class
60
  *
61
  * For a given class name, require the class file.
62
  *
 
 
 
 
63
  * @param string $relative_class_name Class name.
64
  */
65
  private static function load_class( $relative_class_name ) {
81
  }
82
 
83
  /**
84
+ * Autoload
85
  *
86
  * For a given class, check if it exist and load it.
87
  *
 
 
 
 
88
  * @param string $class Class name.
89
  */
90
  private static function autoload( $class ) {
92
  return;
93
  }
94
 
95
+ $relative_class_name = preg_replace(
96
+ '/^' . self::$default_namespace . '\\\/',
97
+ '',
98
+ $class
99
+ );
100
 
101
  $final_class_name = self::$default_namespace . '\\' . $relative_class_name;
102
 
includes/class-cli.php CHANGED
@@ -6,15 +6,15 @@
6
  */
7
  class ZeroSpamCLI {
8
  /**
9
- * Auto-configure the plugin with recommended settings.
10
  */
11
  public function autoconfigure() {
12
  \ZeroSpam\Core\Settings::auto_configure();
13
- WP_CLI::success( 'Zero Spam has been successfully auto-configured using the recommended defaults.' );
14
  }
15
 
16
  /**
17
- * Outputs settings.
18
  */
19
  public function settings() {
20
  $zerospam_settings = \ZeroSpam\Core\Settings::get_settings();
@@ -32,9 +32,9 @@ class ZeroSpamCLI {
32
  }
33
 
34
  /**
35
- * Update a plugin setting(s).
36
  *
37
- * @param array $args Positional arguments.
38
  * @param array $assoc_args Array of settings to update.
39
  */
40
  public function set( $args, $assoc_args ) {
@@ -53,7 +53,7 @@ class ZeroSpamCLI {
53
  }
54
  }
55
  } else {
56
- WP_CLI::error( 'Opps! You didn\'t specify a setting to set (ex. wp zerospam set --share_data=enabled).' );
57
  }
58
  }
59
  }
6
  */
7
  class ZeroSpamCLI {
8
  /**
9
+ * Auto-configure the plugin with recommended settings
10
  */
11
  public function autoconfigure() {
12
  \ZeroSpam\Core\Settings::auto_configure();
13
+ WP_CLI::success( __( 'Zero Spam has been successfully auto-configured using the recommended defaults.', 'zerospam' ) );
14
  }
15
 
16
  /**
17
+ * Outputs settings
18
  */
19
  public function settings() {
20
  $zerospam_settings = \ZeroSpam\Core\Settings::get_settings();
32
  }
33
 
34
  /**
35
+ * Update a plugin setting(s)
36
  *
37
+ * @param array $args Positional arguments.
38
  * @param array $assoc_args Array of settings to update.
39
  */
40
  public function set( $args, $assoc_args ) {
53
  }
54
  }
55
  } else {
56
+ WP_CLI::error( __( 'Opps! You didn\'t specify a setting to set (ex. wp zerospam set --share_data=enabled).', 'zerospam' ) );
57
  }
58
  }
59
  }
includes/class-db.php CHANGED
@@ -1,31 +1,27 @@
1
  <?php
2
  /**
3
- * DB class.
4
  *
5
  * @package ZeroSpam
6
  */
7
 
8
  namespace ZeroSpam\Includes;
9
 
10
- use ZeroSpam;
11
-
12
  // Security Note: Blocks direct access to the plugin PHP files.
13
  defined( 'ABSPATH' ) || die();
14
 
15
  /**
16
- * WordPress Zero Spam DB class.
17
- *
18
- * @since 5.0.0
19
  */
20
  class DB {
21
 
22
- /**
23
- * Current DB version.
24
- */
25
  const DB_VERSION = '0.8';
26
 
27
  /**
28
- * DB tables.
 
 
29
  */
30
  public static $tables = array(
31
  'log' => 'wpzerospam_log',
@@ -34,10 +30,7 @@ class DB {
34
  );
35
 
36
  /**
37
- * DB constructor.
38
- *
39
- * @since 5.0.0
40
- * @access public
41
  */
42
  public function __construct() {
43
  add_action( 'init', array( $this, 'update' ) );
@@ -89,19 +82,20 @@ class DB {
89
  }
90
 
91
  /**
92
- * Returns all blocked IP addresses.
93
  */
94
  public static function get_blocked() {
95
  global $wpdb;
96
 
 
97
  return $wpdb->get_results( 'SELECT * FROM ' . $wpdb->prefix . self::$tables['blocked'], ARRAY_A );
98
  }
99
 
100
  /**
101
- * Adds/returns a blocked IP.
102
  *
103
- * @since 5.0.0
104
- * @access public
105
  */
106
  public static function blocked( $record, $key_type = false ) {
107
  global $wpdb;
@@ -124,6 +118,7 @@ class DB {
124
  if ( $blocked ) {
125
  // Update the record.
126
  $record['date_added'] = current_time( 'mysql' );
 
127
  return $wpdb->update(
128
  $wpdb->prefix . self::$tables['blocked'],
129
  $record,
@@ -134,16 +129,20 @@ class DB {
134
  } else {
135
  // Insert the record.
136
  $record['date_added'] = current_time( 'mysql' );
 
137
  return $wpdb->insert( $wpdb->prefix . self::$tables['blocked'], $record );
138
  }
139
  } elseif ( $key_type ) {
140
  // Get record by key.
 
141
  return $wpdb->get_row( 'SELECT * FROM ' . $wpdb->prefix . self::$tables['blocked'] . ' WHERE key_type = "' . $key_type . '" AND blocked_key = "' . $record . '"', ARRAY_A );
142
  } elseif ( is_int( $record ) ) {
143
  // Get record by ID.
 
144
  return $wpdb->get_row( 'SELECT * FROM ' . $wpdb->prefix . self::$tables['blocked'] . ' WHERE blocked_id = "' . $record . '"', ARRAY_A );
145
  } elseif ( rest_is_ip_address( $record ) ) {
146
  // Get record by IP.
 
147
  return $wpdb->get_row( 'SELECT * FROM ' . $wpdb->prefix . self::$tables['blocked'] . ' WHERE user_ip = "' . $record . '"', ARRAY_A );
148
  }
149
 
@@ -171,12 +170,16 @@ class DB {
171
  * Check the total number of entries and delete the oldest if the maximum
172
  * has been reached.
173
  */
174
- $log_table = $wpdb->prefix . self::$tables['log'];
 
 
175
  $total_entries = $wpdb->get_var( "SELECT COUNT(*) FROM $log_table" );
176
  $maximum_entries = \ZeroSpam\Core\Settings::get_settings( 'max_logs' );
177
 
178
  if ( $total_entries > $maximum_entries ) {
179
  $difference = $total_entries - $maximum_entries;
 
 
180
  $wpdb->query( "DELETE FROM $log_table ORDER BY date_recorded ASC LIMIT $difference" );
181
  }
182
 
@@ -196,14 +199,16 @@ class DB {
196
  }
197
 
198
  /**
199
- * Delete a record.
200
  *
201
- * @since 5.0.0
202
- * @access public
 
203
  */
204
  public static function delete( $table, $key, $value ) {
205
  global $wpdb;
206
 
 
207
  $wpdb->delete(
208
  $wpdb->prefix . self::$tables[ $table ],
209
  array(
@@ -213,22 +218,22 @@ class DB {
213
  }
214
 
215
  /**
216
- * Delete everything in a table.
217
  *
218
- * @since 5.0.0
219
- * @access public
220
  */
221
  public static function delete_all( $table ) {
222
  global $wpdb;
223
 
 
224
  $wpdb->query( "TRUNCATE TABLE " . $wpdb->prefix . self::$tables[ $table ] );
225
  }
226
 
227
  /**
228
- * Query the DB.
229
  *
230
- * @since 5.0.0
231
- * @access public
232
  */
233
  public static function query( $table, $args = array() ) {
234
  global $wpdb;
@@ -266,7 +271,7 @@ class DB {
266
 
267
  if ( is_numeric( $where['value'] ) ) {
268
  $where_stmt .= $where['value'];
269
- } elseif( is_array( $where['value'] ) ) {
270
  $where_stmt .= "('" . implode( "','", $where['value'] ) . "')";
271
  } else {
272
  $where_stmt .= '"' . $where['value'] . '"';
@@ -291,7 +296,7 @@ class DB {
291
  if ( ! empty( $args['offset'] ) ) {
292
  $sql .= ' OFFSET ' . $args['offset'];
293
  }
294
-
295
  return $wpdb->get_results( $sql, ARRAY_A );
296
  }
297
  }
1
  <?php
2
  /**
3
+ * Database class
4
  *
5
  * @package ZeroSpam
6
  */
7
 
8
  namespace ZeroSpam\Includes;
9
 
 
 
10
  // Security Note: Blocks direct access to the plugin PHP files.
11
  defined( 'ABSPATH' ) || die();
12
 
13
  /**
14
+ * Database class
 
 
15
  */
16
  class DB {
17
 
18
+ // Current DB version.
 
 
19
  const DB_VERSION = '0.8';
20
 
21
  /**
22
+ * DB tables
23
+ *
24
+ * @var array $tables List of plugin database tables.
25
  */
26
  public static $tables = array(
27
  'log' => 'wpzerospam_log',
30
  );
31
 
32
  /**
33
+ * Constructor
 
 
 
34
  */
35
  public function __construct() {
36
  add_action( 'init', array( $this, 'update' ) );
82
  }
83
 
84
  /**
85
+ * Returns all blocked IP addresses
86
  */
87
  public static function get_blocked() {
88
  global $wpdb;
89
 
90
+ // @codingStandardsIgnoreLine
91
  return $wpdb->get_results( 'SELECT * FROM ' . $wpdb->prefix . self::$tables['blocked'], ARRAY_A );
92
  }
93
 
94
  /**
95
+ * Adds/returns a blocked IP
96
  *
97
+ * @param array $record Record to add into the database.
98
+ * @param boolean|string $key_type Type of record entry to add.
99
  */
100
  public static function blocked( $record, $key_type = false ) {
101
  global $wpdb;
118
  if ( $blocked ) {
119
  // Update the record.
120
  $record['date_added'] = current_time( 'mysql' );
121
+ // @codingStandardsIgnoreLine
122
  return $wpdb->update(
123
  $wpdb->prefix . self::$tables['blocked'],
124
  $record,
129
  } else {
130
  // Insert the record.
131
  $record['date_added'] = current_time( 'mysql' );
132
+ // @codingStandardsIgnoreLine
133
  return $wpdb->insert( $wpdb->prefix . self::$tables['blocked'], $record );
134
  }
135
  } elseif ( $key_type ) {
136
  // Get record by key.
137
+ // @codingStandardsIgnoreLine
138
  return $wpdb->get_row( 'SELECT * FROM ' . $wpdb->prefix . self::$tables['blocked'] . ' WHERE key_type = "' . $key_type . '" AND blocked_key = "' . $record . '"', ARRAY_A );
139
  } elseif ( is_int( $record ) ) {
140
  // Get record by ID.
141
+ // @codingStandardsIgnoreLine
142
  return $wpdb->get_row( 'SELECT * FROM ' . $wpdb->prefix . self::$tables['blocked'] . ' WHERE blocked_id = "' . $record . '"', ARRAY_A );
143
  } elseif ( rest_is_ip_address( $record ) ) {
144
  // Get record by IP.
145
+ // @codingStandardsIgnoreLine
146
  return $wpdb->get_row( 'SELECT * FROM ' . $wpdb->prefix . self::$tables['blocked'] . ' WHERE user_ip = "' . $record . '"', ARRAY_A );
147
  }
148
 
170
  * Check the total number of entries and delete the oldest if the maximum
171
  * has been reached.
172
  */
173
+ $log_table = $wpdb->prefix . self::$tables['log'];
174
+
175
+ // @codingStandardsIgnoreLine
176
  $total_entries = $wpdb->get_var( "SELECT COUNT(*) FROM $log_table" );
177
  $maximum_entries = \ZeroSpam\Core\Settings::get_settings( 'max_logs' );
178
 
179
  if ( $total_entries > $maximum_entries ) {
180
  $difference = $total_entries - $maximum_entries;
181
+
182
+ // @codingStandardsIgnoreLine
183
  $wpdb->query( "DELETE FROM $log_table ORDER BY date_recorded ASC LIMIT $difference" );
184
  }
185
 
199
  }
200
 
201
  /**
202
+ * Delete a record
203
  *
204
+ * @param string $table Database table key.
205
+ * @param string $key Database record key.
206
+ * @param string $value Database record value.
207
  */
208
  public static function delete( $table, $key, $value ) {
209
  global $wpdb;
210
 
211
+ // @codingStandardsIgnoreLine
212
  $wpdb->delete(
213
  $wpdb->prefix . self::$tables[ $table ],
214
  array(
218
  }
219
 
220
  /**
221
+ * Delete everything in a table
222
  *
223
+ * @param string $table Database table to truncate.
 
224
  */
225
  public static function delete_all( $table ) {
226
  global $wpdb;
227
 
228
+ // @codingStandardsIgnoreLine
229
  $wpdb->query( "TRUNCATE TABLE " . $wpdb->prefix . self::$tables[ $table ] );
230
  }
231
 
232
  /**
233
+ * Query the DB
234
  *
235
+ * @param string $table Database table to query.
236
+ * @param array $args Arguments for the select statement.
237
  */
238
  public static function query( $table, $args = array() ) {
239
  global $wpdb;
271
 
272
  if ( is_numeric( $where['value'] ) ) {
273
  $where_stmt .= $where['value'];
274
+ } elseif ( is_array( $where['value'] ) ) {
275
  $where_stmt .= "('" . implode( "','", $where['value'] ) . "')";
276
  } else {
277
  $where_stmt .= '"' . $where['value'] . '"';
296
  if ( ! empty( $args['offset'] ) ) {
297
  $sql .= ' OFFSET ' . $args['offset'];
298
  }
299
+ // @codingStandardsIgnoreLine
300
  return $wpdb->get_results( $sql, ARRAY_A );
301
  }
302
  }
includes/class-plugin.php CHANGED
@@ -7,25 +7,11 @@
7
 
8
  namespace ZeroSpam;
9
 
10
- use ZeroSpam\Includes\DB;
11
- use ZeroSpam\Core\Access;
12
- use ZeroSpam\Core\User;
13
- use ZeroSpam\Core\Admin\Admin;
14
- use ZeroSpam\Modules\Google;
15
- use ZeroSpam\Modules\Zero_Spam;
16
- use ZeroSpam\Modules\Registration\Registration;
17
- use ZeroSpam\Modules\Comments\Comments;
18
- use ZeroSpam\Modules\ContactForm7\ContactForm7;
19
- use ZeroSpam\Modules\WPForms\WPForms;
20
- use ZeroSpam\Modules\Formidable\Formidable;
21
- use ZeroSpam\Modules\FluentForms\FluentForms;
22
- use ZeroSpam\Modules\DavidWalsh\DavidWalsh;
23
-
24
  // Security Note: Blocks direct access to the plugin PHP files.
25
  defined( 'ABSPATH' ) || die();
26
 
27
  /**
28
- * WordPress Zero Spam plugin
29
  */
30
  class Plugin {
31
 
@@ -62,13 +48,7 @@ class Plugin {
62
  if ( is_null( self::$instance ) ) {
63
  self::$instance = new self();
64
 
65
- /**
66
- * WordPress Zero Spam loaded.
67
- *
68
- * Fires when WordPress Zero Spam was fully loaded and instantiated.
69
- *
70
- * @since 1.0.0
71
- */
72
  do_action( 'zerospam_loaded' );
73
  }
74
 
@@ -82,12 +62,8 @@ class Plugin {
82
  $this->init_components();
83
 
84
  /**
85
- * WordPress Zero Spam init
86
- *
87
  * Fires on WordPress Zero Spam init, after WordPress Zero Spam has finished
88
  * loading but before any headers are sent.
89
- *
90
- * @since 5.0.0
91
  */
92
  do_action( 'zerospam_init' );
93
  }
@@ -100,63 +76,96 @@ class Plugin {
100
  * initialize admin components.
101
  */
102
  private function init_components() {
103
- new Zero_Spam();
104
- new DB();
105
- new Registration();
106
- new Comments();
107
- new DavidWalsh();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
 
 
 
 
 
 
 
 
109
  new \ZeroSpam\Modules\Login\Login();
110
 
 
111
  include_once ABSPATH . 'wp-admin/includes/plugin.php';
112
 
 
113
  if ( is_plugin_active( 'give/give.php' ) ) {
114
  new \ZeroSpam\Modules\Give\Give();
115
  }
116
 
 
117
  if ( is_plugin_active( 'contact-form-7/wp-contact-form-7.php' ) ) {
118
- new ContactForm7();
119
  }
120
 
 
121
  if (
122
  is_plugin_active( 'wpforms-lite/wpforms.php' ) ||
123
  is_plugin_active( 'wpforms/wpforms.php' )
124
  ) {
125
- new WPForms();
126
  }
127
 
 
128
  if ( is_plugin_active( 'formidable/formidable.php' ) ) {
129
- new Formidable();
130
  }
131
 
 
132
  if ( is_plugin_active( 'fluentform/fluentform.php' ) ) {
133
- new FluentForms();
134
  }
135
 
136
- /*if ( is_plugin_active( 'ninja-forms/ninja-forms.php' ) ) {
137
- new \ZeroSpam\Modules\NinjaForms\NinjaForms();
138
- }*/
 
139
 
140
- new \ZeroSpam\Modules\StopForumSpam();
141
- new \ZeroSpam\Modules\ProjectHoneypot();
142
- new \ZeroSpam\Modules\ipstack();
143
- new \ZeroSpam\Modules\IPinfoModule();
144
 
145
- if (
146
- ! is_admin() &&
147
- is_main_query()
148
- ) {
149
- new Access();
150
  }
151
 
 
152
  if ( is_admin() ) {
153
- new Google();
154
- new Admin();
 
 
 
155
  }
156
  }
157
 
158
  /**
159
- * Add to the types array.
 
 
160
  */
161
  public function types( $types ) {
162
  $types['blocked'] = __( 'Blocked', 'zerospam' );
7
 
8
  namespace ZeroSpam;
9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  // Security Note: Blocks direct access to the plugin PHP files.
11
  defined( 'ABSPATH' ) || die();
12
 
13
  /**
14
+ * Main plugin class
15
  */
16
  class Plugin {
17
 
48
  if ( is_null( self::$instance ) ) {
49
  self::$instance = new self();
50
 
51
+ // Fires when WordPress Zero Spam was fully loaded and instantiated.
 
 
 
 
 
 
52
  do_action( 'zerospam_loaded' );
53
  }
54
 
62
  $this->init_components();
63
 
64
  /**
 
 
65
  * Fires on WordPress Zero Spam init, after WordPress Zero Spam has finished
66
  * loading but before any headers are sent.
 
 
67
  */
68
  do_action( 'zerospam_init' );
69
  }
76
  * initialize admin components.
77
  */
78
  private function init_components() {
79
+ // Database functionality.
80
+ new \ZeroSpam\Includes\DB();
81
+
82
+ // Stop Forum Spam module.
83
+ new \ZeroSpam\Modules\StopForumSpam();
84
+
85
+ // Project Honeypot module.
86
+ new \ZeroSpam\Modules\ProjectHoneypot();
87
+
88
+ // Zero Spam module.
89
+ new \ZeroSpam\Modules\Zero_Spam();
90
+
91
+ // ipstack module.
92
+ new \ZeroSpam\Modules\ipstack();
93
+
94
+ // IPinfo module.
95
+ new \ZeroSpam\Modules\IPinfoModule();
96
+
97
+ // David Walsh module.
98
+ new \ZeroSpam\Modules\DavidWalsh\DavidWalsh();
99
 
100
+ // WordPress registration module.
101
+ new \ZeroSpam\Modules\Registration\Registration();
102
+
103
+ // WordPress comments module.
104
+ new \ZeroSpam\Modules\Comments\Comments();
105
+
106
+ // WordPress login module.
107
  new \ZeroSpam\Modules\Login\Login();
108
 
109
+ // Used to check if a plugin is installed & active.
110
  include_once ABSPATH . 'wp-admin/includes/plugin.php';
111
 
112
+ // GiveWP plugin module.
113
  if ( is_plugin_active( 'give/give.php' ) ) {
114
  new \ZeroSpam\Modules\Give\Give();
115
  }
116
 
117
+ // Contact Form 7 plugin module.
118
  if ( is_plugin_active( 'contact-form-7/wp-contact-form-7.php' ) ) {
119
+ new \ZeroSpam\Modules\ContactForm7\ContactForm7();
120
  }
121
 
122
+ // WPForms plugin module.
123
  if (
124
  is_plugin_active( 'wpforms-lite/wpforms.php' ) ||
125
  is_plugin_active( 'wpforms/wpforms.php' )
126
  ) {
127
+ new \ZeroSpam\Modules\WPForms\WPForms();
128
  }
129
 
130
+ // Formidable plugin module.
131
  if ( is_plugin_active( 'formidable/formidable.php' ) ) {
132
+ new \ZeroSpam\Modules\Formidable\Formidable();
133
  }
134
 
135
+ // Fluent Forms plugin module.
136
  if ( is_plugin_active( 'fluentform/fluentform.php' ) ) {
137
+ new \ZeroSpam\Modules\FluentForms\FluentForms();
138
  }
139
 
140
+ // MemberPress plugin module.
141
+ if ( is_plugin_active( 'memberpress/memberpress.php' ) ) {
142
+ new \ZeroSpam\Modules\MemberPress\MemberPress();
143
+ }
144
 
145
+ // Mailchimp for WordPress plugin module.
146
+ if ( is_plugin_active( 'mailchimp-for-wp/mailchimp-for-wp.php' ) ) {
147
+ new \ZeroSpam\Modules\MailchimpForWP\MailchimpForWP();
148
+ }
149
 
150
+ // Preform the firewall access check.
151
+ if ( ! is_admin() && is_main_query() ) {
152
+ new \ZeroSpam\Core\Access();
 
 
153
  }
154
 
155
+ // If in admin, loaded needed classes.
156
  if ( is_admin() ) {
157
+ // Plugin admin module.
158
+ new \ZeroSpam\Core\Admin\Admin();
159
+
160
+ // Google API module.
161
+ new \ZeroSpam\Modules\Google();
162
  }
163
  }
164
 
165
  /**
166
+ * Add to the types array
167
+ *
168
+ * @param array $types Types of detections.
169
  */
170
  public function types( $types ) {
171
  $types['blocked'] = __( 'Blocked', 'zerospam' );
includes/templates/settings/errors.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Settings: Error log template
4
+ *
5
+ * @package ZeroSpam
6
+ */
7
+
8
+ $log = \ZeroSpam\Core\Utilities::get_error_log();
9
+ if ( ! $log ) {
10
+ esc_html_e( 'Yay! No errors have been reported.', 'zerospam' );
11
+ return;
12
+ }
13
+ ?>
14
+
15
+ <textarea readonly class="large-text code" rows="30"><?php echo esc_html( $log ); ?></textarea>
16
+ <a href="<?php echo esc_url( admin_url( 'options-general.php?page=wordpress-zero-spam-settings&amp;tab=error&amp;delete-error-log=1' ) ); ?>" class="button button-primary"><?php esc_html_e( 'Clear Error Log' ); ?></a>
includes/templates/settings/export.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Settings: Export/import template
4
+ *
5
+ * @package ZeroSpam
6
+ */
7
+
8
+ ?>
9
+
10
+ <?php if ( ! empty( $_GET['zerospam-error'] ) ) : ?>
11
+ <div class="notice notice-error is-dismissible">
12
+ <p><strong>
13
+ <?php
14
+ switch( intval( $_GET['zerospam-error'] ) ) :
15
+ case 1:
16
+ esc_html_e( 'There was a problem importing the settings JSON. Please try again.', 'zerospam' );
17
+ break;
18
+ endswitch;
19
+ ?>
20
+ </strong></p>
21
+ <button type="button" class="notice-dismiss"><span class="screen-reader-text"><?php esc_html_e( 'Dismiss this notice.', 'zerospam' ); ?></span></button>
22
+ </div>
23
+ <?php elseif ( ! empty( $_GET['zerospam-success'] ) ) : ?>
24
+ <div class="notice notice-success is-dismissible">
25
+ <p><strong><?php esc_html_e( 'The settings JSON has been successfully imported.', 'zerospam' ); ?></strong></p>
26
+ <button type="button" class="notice-dismiss"><span class="screen-reader-text"><?php esc_html_e( 'Dismiss this notice.', 'zerospam' ); ?>.</span></button>
27
+ </div>
28
+ <?php endif; ?>
29
+
30
+ <h3><?php esc_html_e( 'Settings Import/Export', 'zerospam' ); ?></h3>
31
+ <p><?php esc_html_e( 'Quickly export and import your saved settings into other sites below.', 'zerospam' ); ?></p>
32
+ <?php
33
+ $settings = ZeroSpam\Core\Settings::get_settings();
34
+ $settings_json = array();
35
+ foreach ( $settings as $key => $data ) :
36
+ if ( isset( $data['value'] ) ) :
37
+ $settings_json[ $key ] = $data['value'];
38
+ endif;
39
+ endforeach;
40
+ ?>
41
+ <div class="zerospam-export-import-block">
42
+ <div class="zerospam-export-import-block-column">
43
+ <h4><?php esc_html_e( 'Settings JSON', 'zerospam' ); ?></h4>
44
+ <textarea readonly class="large-text code" rows="10"><?php echo wp_json_encode( $settings_json ); ?></textarea>
45
+ </div>
46
+ <div class="zerospam-export-import-block-column">
47
+ <h4><?php esc_html_e( 'Paste the settings JSON to import.', 'zerospam' ); ?></h4>
48
+ <form method="post" action="<?php echo esc_url( admin_url( 'admin.php' ) ); ?>" class="zerospam-import-settings-form">
49
+ <?php wp_nonce_field( 'import_settings', 'zerospam' ); ?>
50
+ <input type="hidden" name="action" value="import_settings" />
51
+ <input type="hidden" name="redirect" value="<?php echo esc_url( ZeroSpam\Core\Utilities::current_url() ); ?>" />
52
+ <textarea class="large-text code" name="settings" rows="10"></textarea>
53
+ <input type="submit" class="button button-primary" value="<?php esc_html_e( 'Import Settings', 'zerospam' ); ?>" />
54
+ </form>
55
+ </div>
56
+ </div>
includes/templates/settings/settings.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Settings: Export/import template
4
+ *
5
+ * @package ZeroSpam
6
+ */
7
+
8
+ ?>
9
+
10
+ <form action="options.php" method="post">
11
+ <?php
12
+ // Output security fields for the registered setting "wpzerospam".
13
+ settings_fields( 'wpzerospam' );
14
+
15
+ echo '<div class="zerospam-settings-tabs">';
16
+ // Output setting sections and their fields.
17
+ do_settings_sections( 'wpzerospam' );
18
+
19
+ // Output save settings button.
20
+ submit_button( 'Save Settings' );
21
+ ?>
22
+ </form>
modules/comments/class-comments.php CHANGED
@@ -71,6 +71,7 @@ class Comments {
71
  $blocked_email_domains = \ZeroSpam\Core\Settings::get_settings( 'blocked_email_domains' );
72
  if ( $blocked_email_domains ) {
73
  $blocked_email_domains_array = explode( "\n", $blocked_email_domains );
 
74
  $tmp_domain = explode( '@', $commentdata['comment_author_email'] );
75
  $domain = array_pop( $tmp_domain );
76
 
71
  $blocked_email_domains = \ZeroSpam\Core\Settings::get_settings( 'blocked_email_domains' );
72
  if ( $blocked_email_domains ) {
73
  $blocked_email_domains_array = explode( "\n", $blocked_email_domains );
74
+ $blocked_email_domains_array = array_map( 'trim', $blocked_email_domains_array );
75
  $tmp_domain = explode( '@', $commentdata['comment_author_email'] );
76
  $domain = array_pop( $tmp_domain );
77
 
modules/davidwalsh/assets/js/davidwalsh.js CHANGED
@@ -33,7 +33,7 @@
33
  };
34
 
35
  $(function() {
36
- var selectors = '#commentform, #registerform, .wpforms-form, .wpcf7-form, .frm-fluent-form, #loginform, .woocommerce-form-login';
37
  if (typeof ZeroSpamDavidWalsh.selectors != "undefined" && ZeroSpamDavidWalsh.selectors ) {
38
  selectors += ',' + ZeroSpamDavidWalsh.selectors
39
  }
33
  };
34
 
35
  $(function() {
36
+ var selectors = '#commentform, #registerform, .wpforms-form, .wpcf7-form, .frm-fluent-form, #loginform, .woocommerce-form-login, .mepr-signup-form, .mc4wp-form';
37
  if (typeof ZeroSpamDavidWalsh.selectors != "undefined" && ZeroSpamDavidWalsh.selectors ) {
38
  selectors += ',' + ZeroSpamDavidWalsh.selectors
39
  }
modules/davidwalsh/class-davidwalsh.php CHANGED
@@ -34,6 +34,17 @@ class DavidWalsh {
34
  add_action( 'zerospam_wpforms_scripts', array( $this, 'enqueue_script' ) );
35
  add_action( 'zerospam_fluentforms_scripts', array( $this, 'enqueue_script' ) );
36
  add_action( 'zerospam_login_scripts', array( $this, 'enqueue_script' ) );
 
 
 
 
 
 
 
 
 
 
 
37
 
38
  add_filter( 'zerospam_preprocess_comment', array( $this, 'preprocess_comments' ), 10, 1 );
39
  add_filter( 'zerospam_registration_errors', array( $this, 'preprocess_registration' ), 10, 3 );
@@ -41,6 +52,8 @@ class DavidWalsh {
41
  add_filter( 'zerospam_preprocess_wpforms_submission', array( $this, 'preprocess_wpforms_submission' ), 10, 3 );
42
  add_filter( 'zerospam_preprocess_fluentform_submission', array( $this, 'preprocess_fluentform_submission' ), 10, 4 );
43
  add_filter( 'zerospam_preprocess_login_attempt', array( $this, 'preprocess_login_attempt' ), 10, 4 );
 
 
44
  }
45
  }
46
 
@@ -51,6 +64,40 @@ class DavidWalsh {
51
  wp_enqueue_script( 'zerospam-davidwalsh' );
52
  }
53
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  /**
55
  * Preprocesses a login attempt.
56
  *
34
  add_action( 'zerospam_wpforms_scripts', array( $this, 'enqueue_script' ) );
35
  add_action( 'zerospam_fluentforms_scripts', array( $this, 'enqueue_script' ) );
36
  add_action( 'zerospam_login_scripts', array( $this, 'enqueue_script' ) );
37
+ add_action( 'zerospam_mailchimp4wp_scripts', array( $this, 'enqueue_script' ) );
38
+ add_filter(
39
+ 'zerospam_memberpress_scripts',
40
+ function( $scripts ) {
41
+ $scripts[] = 'zerospam-davidwalsh';
42
+
43
+ return $scripts;
44
+ },
45
+ 10,
46
+ 1
47
+ );
48
 
49
  add_filter( 'zerospam_preprocess_comment', array( $this, 'preprocess_comments' ), 10, 1 );
50
  add_filter( 'zerospam_registration_errors', array( $this, 'preprocess_registration' ), 10, 3 );
52
  add_filter( 'zerospam_preprocess_wpforms_submission', array( $this, 'preprocess_wpforms_submission' ), 10, 3 );
53
  add_filter( 'zerospam_preprocess_fluentform_submission', array( $this, 'preprocess_fluentform_submission' ), 10, 4 );
54
  add_filter( 'zerospam_preprocess_login_attempt', array( $this, 'preprocess_login_attempt' ), 10, 4 );
55
+ add_filter( 'zerospam_preprocess_memberpress_registration', array( $this, 'preprocess_memberpress_registration' ), 10, 2 );
56
+ add_filter( 'zerospam_preprocess_mailchimp4wp', array( $this, 'preprocess_mailchimp4wp_registration' ), 10, 2 );
57
  }
58
  }
59
 
64
  wp_enqueue_script( 'zerospam-davidwalsh' );
65
  }
66
 
67
+ /**
68
+ * Preprocesses a Mailchimp form submission.
69
+ *
70
+ * @param array $errors Array of submission errors.
71
+ * @param array $post Form post array.
72
+ */
73
+ public function preprocess_mailchimp4wp_registration( $errors, $post ) {
74
+ if ( empty( $post['zerospam_david_walsh_key'] ) || self::get_davidwalsh() !== $post['zerospam_david_walsh_key'] ) {
75
+ // Failed the David Walsh check.
76
+ $error_message = \ZeroSpam\Core\Utilities::detection_message( 'mailchimp4wp_spam_message' );
77
+
78
+ $errors['zerospam_david_walsh'] = $error_message;
79
+ }
80
+
81
+ return $errors;
82
+ }
83
+
84
+ /**
85
+ * Preprocesses a MemberPress registration submission.
86
+ *
87
+ * @param array $errors Array of submission errors.
88
+ * @param array $post Form post array.
89
+ */
90
+ public function preprocess_memberpress_registration( $errors, $post ) {
91
+ if ( empty( $post['zerospam_david_walsh_key'] ) || self::get_davidwalsh() !== $post['zerospam_david_walsh_key'] ) {
92
+ // Failed the David Walsh check.
93
+ $error_message = \ZeroSpam\Core\Utilities::detection_message( 'memberpress_regsitration_spam_message' );
94
+
95
+ $errors['zerospam_david_walsh'] = $error_message;
96
+ }
97
+
98
+ return $errors;
99
+ }
100
+
101
  /**
102
  * Preprocesses a login attempt.
103
  *
modules/fluentforms/class-fluentforms.php CHANGED
@@ -226,7 +226,7 @@ class FluentForms {
226
  'recommended' => 'enabled',
227
  );
228
 
229
- $message = __( 'You IP has been flagged as spam/malicious.', 'zerospam' );
230
 
231
  $settings['fluentforms_spam_message'] = array(
232
  'title' => __( 'Spam/Malicious Message', 'zerospam' ),
226
  'recommended' => 'enabled',
227
  );
228
 
229
+ $message = __( 'Your IP has been flagged as spam/malicious.', 'zerospam' );
230
 
231
  $settings['fluentforms_spam_message'] = array(
232
  'title' => __( 'Spam/Malicious Message', 'zerospam' ),
modules/login/class-login.php CHANGED
@@ -77,8 +77,6 @@ class Login {
77
  // @codingStandardsIgnoreLine
78
  if ( isset( $_POST[ $honeypot_field_name ] ) && ! empty( $_POST[ $honeypot_field_name ] ) ) {
79
  // Failed the honeypot check.
80
- $details['failed'] = 'honeypot';
81
-
82
  $validation_errors[] = 'honeypot';
83
  }
84
 
@@ -89,8 +87,6 @@ class Login {
89
  if ( ! empty( $errors ) ) {
90
  foreach ( $errors as $key => $message ) {
91
  $validation_errors[] = str_replace( 'zerospam_', '', $key );
92
-
93
- $details['failed'] = str_replace( 'zerospam_', '', $key );
94
  }
95
  }
96
 
@@ -159,7 +155,7 @@ class Login {
159
  'recommended' => 'enabled',
160
  );
161
 
162
- $message = __( 'You have been flagged as spam/malicious by WordPress Zero Spam.', 'zerospam' );
163
 
164
  $settings['login_spam_message'] = array(
165
  'title' => __( 'Spam/Malicious Message', 'zerospam' ),
77
  // @codingStandardsIgnoreLine
78
  if ( isset( $_POST[ $honeypot_field_name ] ) && ! empty( $_POST[ $honeypot_field_name ] ) ) {
79
  // Failed the honeypot check.
 
 
80
  $validation_errors[] = 'honeypot';
81
  }
82
 
87
  if ( ! empty( $errors ) ) {
88
  foreach ( $errors as $key => $message ) {
89
  $validation_errors[] = str_replace( 'zerospam_', '', $key );
 
 
90
  }
91
  }
92
 
155
  'recommended' => 'enabled',
156
  );
157
 
158
+ $message = __( 'Your IP has been flagged as spam/malicious.', 'zerospam' );
159
 
160
  $settings['login_spam_message'] = array(
161
  'title' => __( 'Spam/Malicious Message', 'zerospam' ),
modules/mailchimpforwp/class-mailchimpforwp.php ADDED
@@ -0,0 +1,223 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Mailchimp for WordPress class
4
+ *
5
+ * @package ZeroSpam
6
+ */
7
+
8
+ namespace ZeroSpam\Modules\MailchimpForWP;
9
+
10
+ // Security Note: Blocks direct access to the plugin PHP files.
11
+ defined( 'ABSPATH' ) || die();
12
+
13
+ /**
14
+ * Mailchimp for WordPress class
15
+ */
16
+ class MailchimpForWP {
17
+ /**
18
+ * Constructor
19
+ */
20
+ public function __construct() {
21
+ add_filter( 'zerospam_setting_sections', array( $this, 'sections' ) );
22
+ add_filter( 'zerospam_settings', array( $this, 'settings' ) );
23
+ add_filter( 'zerospam_types', array( $this, 'types' ), 10, 1 );
24
+
25
+ if (
26
+ 'enabled' === \ZeroSpam\Core\Settings::get_settings( 'verify_mailchimp4wp' ) &&
27
+ \ZeroSpam\Core\Access::process()
28
+ ) {
29
+ // Add Zero Spam's honeypot field to the registration form.
30
+ add_filter( 'mc4wp_form_content', array( $this, 'add_honeypot' ), 10, 3 );
31
+
32
+ // Preprocess Mailchimp form submissions.
33
+ add_filter( 'mc4wp_form_errors', array( $this, 'process_form' ), 10, 1 );
34
+
35
+ // Add the error key and message.
36
+ add_filter( 'mc4wp_form_messages', array( $this, 'error_keys' ), 10, 1 );
37
+
38
+ // Add scripts.
39
+ add_action( 'mc4wp_load_form_scripts', array( $this, 'scripts' ), 10 );
40
+ }
41
+ }
42
+
43
+ /**
44
+ * Load the add-on scripts
45
+ */
46
+ public function scripts() {
47
+ do_action( 'zerospam_mailchimp4wp_scripts' );
48
+ }
49
+
50
+ /**
51
+ * Adds Zero Spam's honeypot field
52
+ *
53
+ * @param string $content Form content.
54
+ * @param MC4WP_Form $form Form object.
55
+ * @param MC4WP_Form_Element $element Form element.
56
+ */
57
+ public function add_honeypot( $content, $form, $element ) {
58
+ $content .= \ZeroSpam\Core\Utilities::honeypot_field();
59
+
60
+ return $content;
61
+ }
62
+
63
+ /**
64
+ * Registers an additional Mailchimp for WP error message to match our error
65
+ * code from above.
66
+ *
67
+ * @param array $messages Array of error codes.
68
+ */
69
+ public function error_keys( $messages ) {
70
+ // Get the error message.
71
+ $error_message = \ZeroSpam\Core\Utilities::detection_message( 'mailchimp4wp_spam_message' );
72
+
73
+ $messages['zerospam'] = $error_message;
74
+
75
+ return $messages;
76
+ }
77
+
78
+ /**
79
+ * Processes a Mailchimp form submission.
80
+ *
81
+ * @param array $errors An array of error codes.
82
+ */
83
+ public function process_form( $errors ) {
84
+ // @codingStandardsIgnoreLine
85
+ $post = \ZeroSpam\Core\Utilities::sanitize_array( $_POST );
86
+
87
+ // Create the details array for logging & sharing data.
88
+ $details = array(
89
+ 'post' => $post,
90
+ 'type' => 'mailchimp4wp',
91
+ );
92
+
93
+ // Check Zero Spam's honeypot field.
94
+ $honeypot_field_name = \ZeroSpam\Core\Utilities::get_honeypot();
95
+
96
+ // Begin validation checks.
97
+ $validation_errors = array();
98
+
99
+ if ( isset( $post[ $honeypot_field_name ] ) && ! empty( $post[ $honeypot_field_name ] ) ) {
100
+ // Failed the honeypot check.
101
+ $validation_errors[] = 'honeypot';
102
+ }
103
+
104
+ // Check blocked email domains.
105
+ $blocked_email_domains = \ZeroSpam\Core\Settings::get_settings( 'blocked_email_domains' );
106
+ if ( $blocked_email_domains && ! empty( $post['EMAIL'] ) ) {
107
+ $blocked_email_domains_array = explode( "\n", $blocked_email_domains );
108
+ $blocked_email_domains_array = array_map( 'trim', $blocked_email_domains_array );
109
+ $tmp_domain = explode( '@', $post['EMAIL'] );
110
+ $domain = trim( array_pop( $tmp_domain ) );
111
+
112
+ if ( in_array( $domain, $blocked_email_domains_array, true ) ) {
113
+ // Email domain has been blocked.
114
+ $validation_errors[] = 'blocked_email_domain';
115
+ }
116
+ }
117
+
118
+ // Fire hook for additional validation (ex. David Walsh script).
119
+ // @codingStandardsIgnoreLine
120
+ $filtered_errors = apply_filters( 'zerospam_preprocess_mailchimp4wp', array(), $post );
121
+
122
+ if ( ! empty( $filtered_errors ) ) {
123
+ foreach ( $filtered_errors as $key => $message ) {
124
+ $validation_errors[] = str_replace( 'zerospam_', '', $key );
125
+ }
126
+ }
127
+
128
+ if ( ! empty( $validation_errors ) ) {
129
+ // Failed validations, log & send details if enabled.
130
+ foreach ( $validation_errors as $key => $fail ) {
131
+ $details['failed'] = $fail;
132
+
133
+ // Log the detection if enabled.
134
+ if ( 'enabled' === \ZeroSpam\Core\Settings::get_settings( 'log_blocked_mailchimp4wp' ) ) {
135
+ \ZeroSpam\Includes\DB::log( 'mailchimp4wp', $details );
136
+ }
137
+
138
+ // Share the detection if enabled.
139
+ if ( 'enabled' === \ZeroSpam\Core\Settings::get_settings( 'share_data' ) ) {
140
+ do_action( 'zerospam_share_detection', $details );
141
+ }
142
+ }
143
+
144
+ $errors[] = 'zerospam';
145
+ }
146
+
147
+ return $errors;
148
+ }
149
+
150
+ /**
151
+ * Add to the types array
152
+ *
153
+ * @param array $types Array of available detection types.
154
+ */
155
+ public function types( $types ) {
156
+ $types['mailchimp4wp'] = __( 'Mailchimp for WordPress', 'zerospam' );
157
+
158
+ return $types;
159
+ }
160
+
161
+ /**
162
+ * Admin section
163
+ *
164
+ * @param array $sections Array of available setting sections.
165
+ */
166
+ public function sections( $sections ) {
167
+ $sections['mailchimp4wp'] = array(
168
+ 'title' => __( 'Mailchimp for WordPress Integration', 'zerospam' ),
169
+ );
170
+
171
+ return $sections;
172
+ }
173
+
174
+ /**
175
+ * Admin settings
176
+ *
177
+ * @param array $settings Array of available settings.
178
+ */
179
+ public function settings( $settings ) {
180
+ $options = get_option( 'wpzerospam' );
181
+
182
+ $settings['verify_mailchimp4wp'] = array(
183
+ 'title' => __( 'Protect Forms', 'zerospam' ),
184
+ 'section' => 'mailchimp4wp',
185
+ 'type' => 'checkbox',
186
+ 'options' => array(
187
+ 'enabled' => __( 'Monitor Mailchimp form submissions for malicious or automated spambots.', 'zerospam' ),
188
+ ),
189
+ 'value' => ! empty( $options['verify_mailchimp4wp'] ) ? $options['verify_mailchimp4wp'] : false,
190
+ 'recommended' => 'enabled',
191
+ );
192
+
193
+ $message = __( 'Your IP has been flagged as spam/malicious.', 'zerospam' );
194
+
195
+ $settings['mailchimp4wp_spam_message'] = array(
196
+ 'title' => __( 'Mailchimp Spam/Malicious Message', 'zerospam' ),
197
+ 'desc' => __( 'When Mailchimp form protection is enabled, the message displayed to the user when a submission has been detected as spam/malicious.', 'zerospam' ),
198
+ 'section' => 'mailchimp4wp',
199
+ 'type' => 'text',
200
+ 'field_class' => 'large-text',
201
+ 'placeholder' => $message,
202
+ 'value' => ! empty( $options['mailchimp4wp_spam_message'] ) ? $options['mailchimp4wp_spam_message'] : $message,
203
+ 'recommended' => $message,
204
+ );
205
+
206
+ $settings['log_blocked_mailchimp4wp'] = array(
207
+ 'title' => __( 'Log Blocked Registrations', 'zerospam' ),
208
+ 'section' => 'mailchimp4wp',
209
+ 'type' => 'checkbox',
210
+ 'desc' => wp_kses(
211
+ __( 'Enables logging blocked Mailchimp form submissions. <strong>Recommended for enhanced protection.</strong>', 'zerospam' ),
212
+ array( 'strong' => array() )
213
+ ),
214
+ 'options' => array(
215
+ 'enabled' => __( 'Enabled', 'zerospam' ),
216
+ ),
217
+ 'value' => ! empty( $options['log_blocked_mailchimp4wp'] ) ? $options['log_blocked_mailchimp4wp'] : false,
218
+ 'recommended' => 'enabled',
219
+ );
220
+
221
+ return $settings;
222
+ }
223
+ }
modules/memberpress/class-memberpress.php ADDED
@@ -0,0 +1,207 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * MemberPress class
4
+ *
5
+ * @package ZeroSpam
6
+ */
7
+
8
+ namespace ZeroSpam\Modules\MemberPress;
9
+
10
+ // Security Note: Blocks direct access to the plugin PHP files.
11
+ defined( 'ABSPATH' ) || die();
12
+
13
+ /**
14
+ * MemberPress
15
+ */
16
+ class MemberPress {
17
+ /**
18
+ * Constructor
19
+ */
20
+ public function __construct() {
21
+ add_filter( 'zerospam_setting_sections', array( $this, 'sections' ) );
22
+ add_filter( 'zerospam_settings', array( $this, 'settings' ) );
23
+ add_filter( 'zerospam_types', array( $this, 'types' ), 10, 1 );
24
+
25
+ if (
26
+ 'enabled' === \ZeroSpam\Core\Settings::get_settings( 'verify_memberpress_registration' ) &&
27
+ \ZeroSpam\Core\Access::process()
28
+ ) {
29
+ // Add Zero Spam's honeypot field to the registration form.
30
+ add_action( 'mepr-checkout-before-submit', array( $this, 'add_honeypot' ) );
31
+
32
+ // Preprocess registration form submissions.
33
+ add_filter( 'mepr-validate-signup', array( $this, 'process_form' ) );
34
+
35
+ // Add scripts.
36
+ add_filter( 'mepr-signup-scripts', array( $this, 'scripts' ), 10, 1 );
37
+ }
38
+ }
39
+
40
+ /**
41
+ * Load the add-on scripts
42
+ *
43
+ * @param array $prereqs Script keys.
44
+ */
45
+ public function scripts( $prereqs ) {
46
+ $scripts = apply_filters( 'zerospam_memberpress_scripts', $prereqs );
47
+
48
+ return $scripts;
49
+ }
50
+
51
+ /**
52
+ * Adds Zero Spam's honeypot field.
53
+ */
54
+ public function add_honeypot() {
55
+ // @codingStandardsIgnoreLine
56
+ echo \ZeroSpam\Core\Utilities::honeypot_field();
57
+ }
58
+
59
+ /**
60
+ * Processes a registration submission.
61
+ *
62
+ * @param array $errors Array of errors.
63
+ */
64
+ public function process_form( $errors ) {
65
+ // @codingStandardsIgnoreLine
66
+ $post = \ZeroSpam\Core\Utilities::sanitize_array( $_POST );
67
+
68
+ // Get the error message.
69
+ $error_message = \ZeroSpam\Core\Utilities::detection_message( 'memberpress_regsitration_spam_message' );
70
+
71
+ // Create the details array for logging & sharing data.
72
+ $details = array(
73
+ 'post' => $post,
74
+ 'type' => 'memberpress_registration',
75
+ );
76
+
77
+ // Check Zero Spam's honeypot field.
78
+ $honeypot_field_name = \ZeroSpam\Core\Utilities::get_honeypot();
79
+
80
+ // Begin validation checks.
81
+ $validation_errors = array();
82
+
83
+ if ( isset( $post[ $honeypot_field_name ] ) && ! empty( $post[ $honeypot_field_name ] ) ) {
84
+ // Failed the honeypot check.
85
+ $validation_errors[] = 'honeypot';
86
+ }
87
+
88
+ // Check blocked email domains.
89
+ $blocked_email_domains = \ZeroSpam\Core\Settings::get_settings( 'blocked_email_domains' );
90
+ if ( $blocked_email_domains && ! empty( $post['user_email'] ) ) {
91
+ $blocked_email_domains_array = explode( "\n", $blocked_email_domains );
92
+ $blocked_email_domains_array = array_map( 'trim', $blocked_email_domains_array );
93
+ $tmp_domain = explode( '@', $post['user_email'] );
94
+ $domain = trim( array_pop( $tmp_domain ) );
95
+
96
+ if ( in_array( $domain, $blocked_email_domains_array, true ) ) {
97
+ // Email domain has been blocked.
98
+ $validation_errors[] = 'blocked_email_domain';
99
+ }
100
+ }
101
+
102
+ // Fire hook for additional validation (ex. David Walsh script).
103
+ // @codingStandardsIgnoreLine
104
+ $filtered_errors = apply_filters( 'zerospam_preprocess_memberpress_registration', array(), $post );
105
+
106
+ if ( ! empty( $filtered_errors ) ) {
107
+ foreach ( $filtered_errors as $key => $message ) {
108
+ $validation_errors[] = str_replace( 'zerospam_', '', $key );
109
+ }
110
+ }
111
+
112
+ if ( ! empty( $validation_errors ) ) {
113
+ // Failed validations, log & send details if enabled.
114
+ foreach ( $validation_errors as $key => $fail ) {
115
+ $details['failed'] = $fail;
116
+
117
+ // Log the detection if enabled.
118
+ if ( 'enabled' === \ZeroSpam\Core\Settings::get_settings( 'log_blocked_memberpress_registrations' ) ) {
119
+ \ZeroSpam\Includes\DB::log( 'memberpress_registration', $details );
120
+ }
121
+
122
+ // Share the detection if enabled.
123
+ if ( 'enabled' === \ZeroSpam\Core\Settings::get_settings( 'share_data' ) ) {
124
+ do_action( 'zerospam_share_detection', $details );
125
+ }
126
+ }
127
+
128
+ $errors[] = $error_message;
129
+ }
130
+
131
+ return $errors;
132
+ }
133
+
134
+ /**
135
+ * Add to the types array
136
+ *
137
+ * @param array $types Array of available detection types.
138
+ */
139
+ public function types( $types ) {
140
+ $types['memberpress_registration'] = __( 'MemberPress Registration', 'zerospam' );
141
+
142
+ return $types;
143
+ }
144
+
145
+ /**
146
+ * Admin section
147
+ *
148
+ * @param array $sections Array of available setting sections.
149
+ */
150
+ public function sections( $sections ) {
151
+ $sections['memberpress'] = array(
152
+ 'title' => __( 'MemberPress Integration', 'zerospam' ),
153
+ );
154
+
155
+ return $sections;
156
+ }
157
+
158
+ /**
159
+ * Admin settings
160
+ *
161
+ * @param array $settings Array of available settings.
162
+ */
163
+ public function settings( $settings ) {
164
+ $options = get_option( 'wpzerospam' );
165
+
166
+ $settings['verify_memberpress_registration'] = array(
167
+ 'title' => __( 'Protect Registration Forms', 'zerospam' ),
168
+ 'section' => 'memberpress',
169
+ 'type' => 'checkbox',
170
+ 'options' => array(
171
+ 'enabled' => __( 'Monitor MemberPress registrations for malicious or automated spambots.', 'zerospam' ),
172
+ ),
173
+ 'value' => ! empty( $options['verify_memberpress_registration'] ) ? $options['verify_memberpress_registration'] : false,
174
+ 'recommended' => 'enabled',
175
+ );
176
+
177
+ $message = __( 'Your IP has been flagged as spam/malicious.', 'zerospam' );
178
+
179
+ $settings['memberpress_regsitration_spam_message'] = array(
180
+ 'title' => __( 'Registration Spam/Malicious Message', 'zerospam' ),
181
+ 'desc' => __( 'When registration protection is enabled, the message displayed to the user when a submission has been detected as spam/malicious.', 'zerospam' ),
182
+ 'section' => 'memberpress',
183
+ 'type' => 'text',
184
+ 'field_class' => 'large-text',
185
+ 'placeholder' => $message,
186
+ 'value' => ! empty( $options['memberpress_regsitration_spam_message'] ) ? $options['memberpress_regsitration_spam_message'] : $message,
187
+ 'recommended' => $message,
188
+ );
189
+
190
+ $settings['log_blocked_memberpress_registrations'] = array(
191
+ 'title' => __( 'Log Blocked Registrations', 'zerospam' ),
192
+ 'section' => 'memberpress',
193
+ 'type' => 'checkbox',
194
+ 'desc' => wp_kses(
195
+ __( 'Enables logging blocked registration attempts. <strong>Recommended for enhanced protection.</strong>', 'zerospam' ),
196
+ array( 'strong' => array() )
197
+ ),
198
+ 'options' => array(
199
+ 'enabled' => __( 'Enabled', 'zerospam' ),
200
+ ),
201
+ 'value' => ! empty( $options['log_blocked_memberpress_registrations'] ) ? $options['log_blocked_memberpress_registrations'] : false,
202
+ 'recommended' => 'enabled',
203
+ );
204
+
205
+ return $settings;
206
+ }
207
+ }
modules/ninjaforms/class-ninjaforms.php DELETED
@@ -1,38 +0,0 @@
1
- <?php
2
- /**
3
- * Ninja Forms class
4
- *
5
- * @package ZeroSpam
6
- */
7
-
8
- namespace ZeroSpam\Modules\NinjaForms;
9
-
10
- // Security Note: Blocks direct access to the plugin PHP files.
11
- defined( 'ABSPATH' ) || die();
12
-
13
- /**
14
- * Ninja Forms
15
- */
16
- class NinjaForms {
17
- /**
18
- * Add-on constructor.
19
- */
20
- public function __construct() {
21
- // add_filter( 'ninja_forms_register_fields', array($this, 'register_fields'));
22
-
23
- // Preprocess Ninja Form submissions.
24
- //add_filter( 'ninja_forms_submit_data', array( $this, 'preprocess_form' ), 10, 1 );
25
- }
26
-
27
-
28
- public function add_honeypot( $form_id, $is_preview ) {
29
- return \ZeroSpam\Core\Utilities::honeypot_field();
30
- }
31
-
32
- public function preprocess_form( $form_data ) {
33
- print_r($form_data);
34
- die();
35
-
36
- return $form_data;
37
- }
38
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
modules/registration/class-registration.php CHANGED
@@ -65,6 +65,7 @@ class Registration {
65
  $blocked_email_domains = \ZeroSpam\Core\Settings::get_settings( 'blocked_email_domains' );
66
  if ( $blocked_email_domains ) {
67
  $blocked_email_domains_array = explode( "\n", $blocked_email_domains );
 
68
  $tmp_domain = explode( '@', $user_email );
69
  $domain = array_pop( $tmp_domain );
70
 
65
  $blocked_email_domains = \ZeroSpam\Core\Settings::get_settings( 'blocked_email_domains' );
66
  if ( $blocked_email_domains ) {
67
  $blocked_email_domains_array = explode( "\n", $blocked_email_domains );
68
+ $blocked_email_domains_array = array_map( 'trim', $blocked_email_domains_array );
69
  $tmp_domain = explode( '@', $user_email );
70
  $domain = array_pop( $tmp_domain );
71
 
readme.txt CHANGED
@@ -1,11 +1,11 @@
1
  === WordPress Zero Spam ===
2
- Contributors: bmarshall511,
3
  Tags: protection, firewall, security, spam, spam blocker
4
  Donate link: https://www.zerospam.org/subscribe/
5
  Requires at least: 5.2
6
  Tested up to: 5.8.2
7
  Requires PHP: 7.3
8
- Stable tag: 5.2.3
9
  License: GNU GPLv3
10
  License URI: https://choosealicense.com/licenses/gpl-3.0/
11
 
@@ -39,6 +39,8 @@ Quit forcing people to answer questions or confusing captchas to prove they're n
39
  * [WPForms](https://wordpress.org/plugins/wpforms-lite/) submissions
40
  * [Formidable Form Builder](https://wordpress.org/plugins/formidable/) submissions
41
  * [Fluent Forms](https://wordpress.org/plugins/fluentform/) submissions
 
 
42
  * and can be easily integrated into any existing theme or plugin
43
 
44
  WordPress Zero Spam is great at blocking spam &mdash; as a site owner there's more you can do to [stop WordPress spam](https://www.benmarshall.me/stop-wordpress-spam/) in its tracks.
@@ -94,6 +96,13 @@ If hosting with Pantheon, see their [known issues page](https://pantheon.io/docs
94
 
95
  == Changelog ==
96
 
 
 
 
 
 
 
 
97
  = v5.2.3 =
98
 
99
  * feat(givewp): now support givewp donation forms
1
  === WordPress Zero Spam ===
2
+ Contributors: bmarshall511
3
  Tags: protection, firewall, security, spam, spam blocker
4
  Donate link: https://www.zerospam.org/subscribe/
5
  Requires at least: 5.2
6
  Tested up to: 5.8.2
7
  Requires PHP: 7.3
8
+ Stable tag: 5.2.4
9
  License: GNU GPLv3
10
  License URI: https://choosealicense.com/licenses/gpl-3.0/
11
 
39
  * [WPForms](https://wordpress.org/plugins/wpforms-lite/) submissions
40
  * [Formidable Form Builder](https://wordpress.org/plugins/formidable/) submissions
41
  * [Fluent Forms](https://wordpress.org/plugins/fluentform/) submissions
42
+ * [MemberPress](https://memberpress.com/) registrations
43
+ * [Mailchimp for WordPress](https://wordpress.org/plugins/mailchimp-for-wp/) submissions
44
  * and can be easily integrated into any existing theme or plugin
45
 
46
  WordPress Zero Spam is great at blocking spam &mdash; as a site owner there's more you can do to [stop WordPress spam](https://www.benmarshall.me/stop-wordpress-spam/) in its tracks.
96
 
97
  == Changelog ==
98
 
99
+ = v5.2.4 =
100
+
101
+ * feat(memberpress): resolves #283, now supports memberpress registration forms
102
+ * feat(mailchimp4wp): resolves #121, now supports mailchimp4wp forms
103
+ * refactor(misc): misc. updates to comply with wordpress coding standards.
104
+ * style(admin): misc. admin interface improvements
105
+
106
  = v5.2.3 =
107
 
108
  * feat(givewp): now support givewp donation forms
wordpress-zero-spam.php CHANGED
@@ -12,8 +12,8 @@
12
  * @wordpress-plugin
13
  * Plugin Name: WordPress Zero Spam
14
  * Plugin URI: https://www.highfivery.com/projects/zero-spam/
15
- * Description: Tired of all the worthless and bloated WordPress anti-spam plugins? The WordPress Zero Spam plugin makes blocking spam &amp; malicious activity a cinch. <strong>Just install, activate, configure, and say goodbye to spam.</strong>
16
- * Version: 5.2.3
17
  * Requires at least: 5.2
18
  * Requires PHP: 7.3
19
  * Author: Highfivery LLC
@@ -31,7 +31,7 @@ defined( 'ABSPATH' ) || die();
31
  define( 'ZEROSPAM', __FILE__ );
32
  define( 'ZEROSPAM_PATH', plugin_dir_path( ZEROSPAM ) );
33
  define( 'ZEROSPAM_PLUGIN_BASE', plugin_basename( ZEROSPAM ) );
34
- define( 'ZEROSPAM_VERSION', '5.2.3' );
35
 
36
  if ( defined( 'ZEROSPAM_DEVELOPMENT_URL' ) ) {
37
  define( 'ZEROSPAM_URL', ZEROSPAM_DEVELOPMENT_URL );
@@ -57,7 +57,7 @@ function zerospam_load_plugin_textdomain() {
57
  }
58
 
59
  /**
60
- * WordPress Zero Spam admin notice for minimum PHP version
61
  */
62
  function zerospam_fail_php_version() {
63
  /* translators: %s: PHP version */
@@ -67,7 +67,7 @@ function zerospam_fail_php_version() {
67
  }
68
 
69
  /**
70
- * WordPress Zero Spam admin notice for minimum WordPress version
71
  */
72
  function zerospam_fail_wp_version() {
73
  /* translators: %s: WordPress version */
12
  * @wordpress-plugin
13
  * Plugin Name: WordPress Zero Spam
14
  * Plugin URI: https://www.highfivery.com/projects/zero-spam/
15
+ * Description: Tired of all the worthless and bloated WordPress anti-spam & security plugins? WordPress Zero Spam makes blocking spam &amp; malicious activity a cinch. <strong>Just install, activate, configure, and say goodbye to spam.</strong>
16
+ * Version: 5.2.4
17
  * Requires at least: 5.2
18
  * Requires PHP: 7.3
19
  * Author: Highfivery LLC
31
  define( 'ZEROSPAM', __FILE__ );
32
  define( 'ZEROSPAM_PATH', plugin_dir_path( ZEROSPAM ) );
33
  define( 'ZEROSPAM_PLUGIN_BASE', plugin_basename( ZEROSPAM ) );
34
+ define( 'ZEROSPAM_VERSION', '5.2.4' );
35
 
36
  if ( defined( 'ZEROSPAM_DEVELOPMENT_URL' ) ) {
37
  define( 'ZEROSPAM_URL', ZEROSPAM_DEVELOPMENT_URL );
57
  }
58
 
59
  /**
60
+ * Admin notice for minimum PHP version
61
  */
62
  function zerospam_fail_php_version() {
63
  /* translators: %s: PHP version */
67
  }
68
 
69
  /**
70
+ * Admin notice for minimum WordPress version
71
  */
72
  function zerospam_fail_wp_version() {
73
  /* translators: %s: WordPress version */