WordPress Zero Spam - Version 5.1.6

Version Description

Download this release

Release Info

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

Code changes from version 5.1.5 to 5.1.6

core/admin/class-admin.php CHANGED
@@ -47,12 +47,14 @@ class Admin {
47
  $user = wp_get_current_user();
48
  $roles = (array) $user->roles;
49
 
50
- if ( ! empty( array_intersect( $roles, $selected_user_roles ) ) ) {
51
- wp_add_dashboard_widget(
52
- 'zerospam_dashboard_widget',
53
- __( 'WordPress Zero Spam', 'zerospam' ),
54
- array( $this, 'dashboard_widget' )
55
- );
 
 
56
  }
57
  }
58
 
47
  $user = wp_get_current_user();
48
  $roles = (array) $user->roles;
49
 
50
+ if ( is_array( $selected_user_roles ) && is_array( $roles ) ) {
51
+ if ( ! empty( array_intersect( $roles, $selected_user_roles ) ) ) {
52
+ wp_add_dashboard_widget(
53
+ 'zerospam_dashboard_widget',
54
+ __( 'WordPress Zero Spam', 'zerospam' ),
55
+ array( $this, 'dashboard_widget' )
56
+ );
57
+ }
58
  }
59
  }
60
 
core/admin/class-settings.php CHANGED
@@ -307,7 +307,7 @@ class Settings {
307
  <?php
308
  foreach ( $args['options'] as $key => $label ) :
309
  $selected = false;
310
- if ( ! empty( $args['multiple'] ) && is_array( $args['value'] ) ) :
311
  if ( in_array( $key, $args['value'], true ) ) :
312
  $selected = true;
313
  endif;
307
  <?php
308
  foreach ( $args['options'] as $key => $label ) :
309
  $selected = false;
310
+ if ( ! empty( $args['value'] ) && ! empty( $args['multiple'] ) && is_array( $args['value'] ) ) :
311
  if ( in_array( $key, $args['value'], true ) ) :
312
  $selected = true;
313
  endif;
core/class-access.php CHANGED
@@ -36,9 +36,13 @@ class Access {
36
 
37
  /**
38
  * Returns true if WordPress Zero Spam should process a submission.
 
 
39
  */
40
- public static function process() {
41
- if ( ( is_admin() && ! wp_doing_ajax() ) || is_user_logged_in() ) {
 
 
42
  return false;
43
  }
44
 
36
 
37
  /**
38
  * Returns true if WordPress Zero Spam should process a submission.
39
+ *
40
+ * @param boolean $ignore_ajax True if AJAX shouldn't be checked.
41
  */
42
+ public static function process( $ignore_ajax = false ) {
43
+ if ( $ignore_ajax && is_admin() || is_user_logged_in() ) {
44
+ return false;
45
+ } elseif ( ! $ignore_ajax && ( is_admin() && ! wp_doing_ajax() ) || is_user_logged_in() ) {
46
  return false;
47
  }
48
 
includes/class-plugin.php CHANGED
@@ -126,9 +126,9 @@ class Plugin {
126
  new Formidable();
127
  }
128
 
129
- /*if ( is_plugin_active( 'fluentform/fluentform.php' ) ) {
130
  new FluentForms();
131
- }*/
132
 
133
  new StopForumSpam();
134
  new ipstack();
126
  new Formidable();
127
  }
128
 
129
+ if ( is_plugin_active( 'fluentform/fluentform.php' ) ) {
130
  new FluentForms();
131
+ }
132
 
133
  new StopForumSpam();
134
  new ipstack();
modules/davidwalsh/assets/js/davidwalsh.js CHANGED
@@ -33,7 +33,7 @@
33
  };
34
 
35
  $(function() {
36
- var selectors = '#commentform, #registerform, .wpforms-form, .wpcf7-form';
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';
37
  if (typeof ZeroSpamDavidWalsh.selectors != "undefined" && ZeroSpamDavidWalsh.selectors ) {
38
  selectors += ',' + ZeroSpamDavidWalsh.selectors
39
  }
modules/davidwalsh/class-davidwalsh.php CHANGED
@@ -32,11 +32,13 @@ class DavidWalsh {
32
  add_action( 'zerospam_wpcf7_enqueue_scripts', array( $this, 'enqueue_script' ) );
33
  add_action( 'zerospam_register_form', array( $this, 'enqueue_script' ) );
34
  add_action( 'zerospam_wpforms_frontend_output', array( $this, 'enqueue_script' ) );
 
35
 
36
  add_filter( 'zerospam_preprocess_comment', array( $this, 'preprocess_comments' ), 10, 1 );
37
  add_filter( 'zerospam_registration_errors', array( $this, 'preprocess_registration' ), 10, 3 );
38
  add_filter( 'zerospam_preprocess_cf7_submission', array( $this, 'preprocess_cf7_submission' ), 10, 2 );
39
  add_action( 'zerospam_preprocess_wpforms_submission', array( $this, 'preprocess_wpforms_submission' ), 10, 1 );
 
40
  }
41
  }
42
 
@@ -47,6 +49,25 @@ class DavidWalsh {
47
  wp_enqueue_script( 'zerospam-davidwalsh' );
48
  }
49
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  /**
51
  * Preprocess CF7 submission.
52
  */
32
  add_action( 'zerospam_wpcf7_enqueue_scripts', array( $this, 'enqueue_script' ) );
33
  add_action( 'zerospam_register_form', array( $this, 'enqueue_script' ) );
34
  add_action( 'zerospam_wpforms_frontend_output', array( $this, 'enqueue_script' ) );
35
+ add_action( 'zerospam_fluentforms_form', array( $this, 'enqueue_script' ) );
36
 
37
  add_filter( 'zerospam_preprocess_comment', array( $this, 'preprocess_comments' ), 10, 1 );
38
  add_filter( 'zerospam_registration_errors', array( $this, 'preprocess_registration' ), 10, 3 );
39
  add_filter( 'zerospam_preprocess_cf7_submission', array( $this, 'preprocess_cf7_submission' ), 10, 2 );
40
  add_action( 'zerospam_preprocess_wpforms_submission', array( $this, 'preprocess_wpforms_submission' ), 10, 1 );
41
+ add_filter( 'zerospam_preprocess_fluentform_submission', array( $this, 'preprocess_fluentform_submission' ), 10, 4 );
42
  }
43
  }
44
 
49
  wp_enqueue_script( 'zerospam-davidwalsh' );
50
  }
51
 
52
+ /**
53
+ * Preprocesses a Fluent Form submission.
54
+ *
55
+ * @param array $errors Array of submission errors.
56
+ * @param array $insert_data submission_data Array.
57
+ * @param array $data $_POST[‘data’] from submission.
58
+ * @param object $form The $form Object.
59
+ */
60
+ public function preprocess_fluentform_submission( $errors, $insert_data, $data, $form ) {
61
+ if ( empty( $data['zerospam_david_walsh_key'] ) || self::get_davidwalsh() !== $data['zerospam_david_walsh_key'] ) {
62
+ // Failed the David Walsh check.
63
+ $error_message = \ZeroSpam\Core\Utilities::detection_message( 'fluentforms_spam_message' );
64
+
65
+ $errors['zerospam_david_walsh'] = $error_message;
66
+ }
67
+
68
+ return $errors;
69
+ }
70
+
71
  /**
72
  * Preprocess CF7 submission.
73
  */
modules/fluentforms/class-fluentforms.php CHANGED
@@ -7,8 +7,6 @@
7
 
8
  namespace ZeroSpam\Modules\FluentForms;
9
 
10
- use ZeroSpam;
11
-
12
  // Security Note: Blocks direct access to the plugin PHP files.
13
  defined( 'ABSPATH' ) || die();
14
 
@@ -24,11 +22,167 @@ class FluentForms {
24
  add_filter( 'zerospam_settings', array( $this, 'settings' ) );
25
  add_filter( 'zerospam_types', array( $this, 'types' ), 10, 1 );
26
 
27
- if ( 'enabled' === ZeroSpam\Core\Settings::get_settings( 'verify_fluentforms' ) && ZeroSpam\Core\Access::process() ) {
28
- // @TODO
 
 
 
 
 
 
 
 
 
 
29
  }
30
  }
31
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  /**
33
  * Add to the types array
34
  *
7
 
8
  namespace ZeroSpam\Modules\FluentForms;
9
 
 
 
10
  // Security Note: Blocks direct access to the plugin PHP files.
11
  defined( 'ABSPATH' ) || die();
12
 
22
  add_filter( 'zerospam_settings', array( $this, 'settings' ) );
23
  add_filter( 'zerospam_types', array( $this, 'types' ), 10, 1 );
24
 
25
+ if ( 'enabled' === \ZeroSpam\Core\Settings::get_settings( 'verify_fluentforms' ) && \ZeroSpam\Core\Access::process() ) {
26
+ // Fires before a Fluent Form is rendered.
27
+ add_action( 'fluentform_load_form_assets', array( $this, 'before_form_render' ), 10 );
28
+
29
+ // Adds Zero Spam's honeypot field.
30
+ add_filter( 'fluentform_rendering_form', array( $this, 'render_form' ), 10, 1 );
31
+
32
+ // Processes the form.
33
+ add_action( 'fluentform_before_insert_submission', array( $this, 'process_form' ), 10, 3 );
34
+
35
+ // Validates email addresses.
36
+ add_filter( 'fluentform_validate_input_item_input_email', array( $this, 'validate_email' ), 10, 5 );
37
  }
38
  }
39
 
40
+ /**
41
+ * Fires before a form is rendered.
42
+ */
43
+ public function before_form_render() {
44
+ do_action( 'zerospam_fluentforms_form' );
45
+ }
46
+
47
+ /**
48
+ * Adds Zero Spam's custom form fields.
49
+ *
50
+ * @see https://fluentforms.com/docs/fluentform_rendering_form/
51
+ *
52
+ * @param $form The $form Object.
53
+ */
54
+ public function render_form( $form ) {
55
+ // Add Zero Spam's honeypot field.
56
+ $honeypot_field_name = \ZeroSpam\Core\Utilities::get_honeypot();
57
+
58
+ $form->fields['fields'][] = array(
59
+ 'element' => 'input_hidden',
60
+ 'attributes' => array(
61
+ 'type' => 'hidden',
62
+ 'name' => $honeypot_field_name,
63
+ 'value' => '',
64
+ ),
65
+ );
66
+
67
+ return $form;
68
+ }
69
+
70
+ /**
71
+ * Processes a Fluent Form submission after it's validation is completed.
72
+ *
73
+ * @see https://fluentforms.com/docs/fluentform_before_insert_submission/
74
+ *
75
+ * @param array $insert_data submission_data Array.
76
+ * @param array $data $_POST[‘data’] from submission.
77
+ * @param object $form The $form Object.
78
+ */
79
+ public function process_form( $insert_data, $data, $form ) {
80
+ $error_message = \ZeroSpam\Core\Utilities::detection_message( 'fluentforms_spam_message' );
81
+
82
+ // Check Zero Spam's honeypot field.
83
+ $honeypot_field_name = \ZeroSpam\Core\Utilities::get_honeypot();
84
+
85
+ // Create the details array for logging & sharing data.
86
+ $details = array(
87
+ 'insert_data' => $insert_data,
88
+ 'data' => $data,
89
+ 'form' => array(
90
+ 'id' => $form->id,
91
+ 'title' => $form->title,
92
+ ),
93
+ );
94
+
95
+ if ( ! isset( $data[ $honeypot_field_name ] ) || ! empty( $data[ $honeypot_field_name ] ) ) {
96
+ // Failed the honeypot check.
97
+ $details['failed'] = 'honeypot';
98
+
99
+ // Log the detection if enabled.
100
+ if ( 'enabled' === \ZeroSpam\Core\Settings::get_settings( 'log_blocked_fluentforms' ) ) {
101
+ \ZeroSpam\Includes\DB::log( 'fluent_form', $details );
102
+ }
103
+
104
+ // Share the detection if enabled.
105
+ if ( 'enabled' === \ZeroSpam\Core\Settings::get_settings( 'share_data' ) ) {
106
+ $details['type'] = 'fluent_form';
107
+ do_action( 'zerospam_share_detection', $details );
108
+ }
109
+
110
+ wp_send_json(
111
+ array(
112
+ 'errors' => array(
113
+ 'zerospam_honeypot' => $error_message,
114
+ ),
115
+ ),
116
+ 422
117
+ );
118
+ }
119
+
120
+ // Fire hook for additional validation (ex. David Walsh script).
121
+ $errors = apply_filters( 'zerospam_preprocess_fluentform_submission', array(), $insert_data, $data, $form );
122
+
123
+ if ( ! empty( $errors ) ) {
124
+ $errors_array = array();
125
+ foreach ( $errors as $key => $message ) {
126
+ $errors_array[ $key ] = $message;
127
+
128
+ $details['failed'] = str_replace( 'zerospam_', '', $key );
129
+
130
+ // Log the detection if enabled.
131
+ if ( 'enabled' === \ZeroSpam\Core\Settings::get_settings( 'log_blocked_fluentforms' ) ) {
132
+ \ZeroSpam\Includes\DB::log( 'fluent_form', $details );
133
+ }
134
+
135
+ // Share the detection if enabled.
136
+ if ( 'enabled' === \ZeroSpam\Core\Settings::get_settings( 'share_data' ) ) {
137
+ $details['type'] = 'fluent_form';
138
+ do_action( 'zerospam_share_detection', $details );
139
+ }
140
+ }
141
+
142
+ wp_send_json(
143
+ array(
144
+ 'errors' => $errors_array,
145
+ ),
146
+ 422
147
+ );
148
+ }
149
+ }
150
+
151
+ /**
152
+ * Validates email inputs.
153
+ *
154
+ * @see https://fluentforms.com/docs/fluentform_validate_input_item_input_text/
155
+ *
156
+ * @param string $error Error message.
157
+ * @param array $field Contains the fill field settings.
158
+ * @param array $form_data Contains all the user input values as key pair.
159
+ * @param array $fields All fields of the form.
160
+ * @param object $form The $form Object.
161
+ */
162
+ public function validate_email( $error, $field, $form_data, $fields, $form ) {
163
+ $error_message = \ZeroSpam\Core\Utilities::detection_message( 'fluentforms_spam_message' );
164
+ $blocked_email_domains = \ZeroSpam\Core\Utilities::blocked_email_domains();
165
+
166
+ if ( ! $blocked_email_domains ) {
167
+ return $error;
168
+ }
169
+
170
+ $field_name = $field['name'];
171
+ if ( empty( $form_data[ $field_name ] ) ) {
172
+ return $error;
173
+ }
174
+
175
+ $email_address = explode( '@', $form_data[ $field_name ] );
176
+ $email_domain = array_pop( $email_address );
177
+
178
+ if ( in_array( $email_domain, $blocked_email_domains, true ) ) {
179
+ return array( $error_message );
180
+ }
181
+
182
+ return $error;
183
+ }
184
+
185
+
186
  /**
187
  * Add to the types array
188
  *
readme.txt CHANGED
@@ -5,7 +5,7 @@ Donate link: https://www.zerospam.org/subscribe/
5
  Requires at least: 5.2
6
  Tested up to: 5.8.1
7
  Requires PHP: 7.3
8
- Stable tag: 5.1.5
9
  License: GNU GPLv3
10
  License URI: https://choosealicense.com/licenses/gpl-3.0/
11
 
@@ -37,6 +37,7 @@ Quit forcing people to answer questions or confusing captchas to prove they're n
37
  * [Contact Form 7](https://wordpress.org/plugins/contact-form-7/) submissions
38
  * [WPForms](https://wordpress.org/plugins/wpforms-lite/) submissions
39
  * [Formidable Form Builder](https://wordpress.org/plugins/formidable/) submissions
 
40
  * and can be easily integrated into any existing theme or plugin
41
 
42
  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.
@@ -83,6 +84,11 @@ For more information & developer documentation, see the [plugin’s website](htt
83
 
84
  == Changelog ==
85
 
 
 
 
 
 
86
  = v5.1.5 =
87
 
88
  * feat(dashboard widget): resolves #275, added the ability to control the dashboard widget visibility
5
  Requires at least: 5.2
6
  Tested up to: 5.8.1
7
  Requires PHP: 7.3
8
+ Stable tag: 5.1.6
9
  License: GNU GPLv3
10
  License URI: https://choosealicense.com/licenses/gpl-3.0/
11
 
37
  * [Contact Form 7](https://wordpress.org/plugins/contact-form-7/) submissions
38
  * [WPForms](https://wordpress.org/plugins/wpforms-lite/) submissions
39
  * [Formidable Form Builder](https://wordpress.org/plugins/formidable/) submissions
40
+ * [Fluent Forms](https://wordpress.org/plugins/fluentform/) submissions
41
  * and can be easily integrated into any existing theme or plugin
42
 
43
  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.
84
 
85
  == Changelog ==
86
 
87
+ = v5.1.6 =
88
+
89
+ * feat(fluent forms): resolves #276, fluent forms is now supported
90
+ * fix(php notice): resolves #277, fix for array_intersect(): Argument #2 must be of type array, bool
91
+
92
  = v5.1.5 =
93
 
94
  * feat(dashboard widget): resolves #275, added the ability to control the dashboard widget visibility
wordpress-zero-spam.php CHANGED
@@ -13,7 +13,7 @@
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.1.5
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.1.5' );
35
 
36
  if ( defined( 'ZEROSPAM_DEVELOPMENT_URL' ) ) {
37
  define( 'ZEROSPAM_URL', ZEROSPAM_DEVELOPMENT_URL );
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.1.6
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.1.6' );
35
 
36
  if ( defined( 'ZEROSPAM_DEVELOPMENT_URL' ) ) {
37
  define( 'ZEROSPAM_URL', ZEROSPAM_DEVELOPMENT_URL );