Version Description
Download this release
Release Info
Developer | bmarshall511 |
Plugin | WordPress Zero Spam |
Version | 5.3.0 |
Comparing to | |
See all releases |
Code changes from version 5.2.15 to 5.3.0
- modules/class-zerospam.php +49 -21
- modules/woocommerce/class-woocommerce.php +4 -1
- readme.txt +7 -2
- uninstall.php +2 -0
- wordpress-zero-spam.php +2 -2
modules/class-zerospam.php
CHANGED
@@ -18,7 +18,7 @@ class Zero_Spam {
|
|
18 |
/**
|
19 |
* The zerospam.org API endpoint
|
20 |
*/
|
21 |
-
const API_ENDPOINT = ZEROSPAM_URL . 'wp-json/
|
22 |
|
23 |
/**
|
24 |
* Constructor
|
@@ -199,14 +199,15 @@ class Zero_Spam {
|
|
199 |
* Global API data.
|
200 |
*/
|
201 |
public function global_api_data() {
|
202 |
-
$api_data
|
203 |
-
$api_data['
|
204 |
-
$api_data['
|
205 |
-
$api_data['wp_version']
|
206 |
-
$api_data['
|
207 |
-
$api_data['
|
208 |
-
$api_data['
|
209 |
-
$api_data['
|
|
|
210 |
|
211 |
return $api_data;
|
212 |
}
|
@@ -217,7 +218,20 @@ class Zero_Spam {
|
|
217 |
* @param array $data Contains all detection details.
|
218 |
*/
|
219 |
public function share_detection( $data ) {
|
220 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
221 |
|
222 |
$ip = \ZeroSpam\Core\User::get_ip();
|
223 |
|
@@ -225,29 +239,43 @@ class Zero_Spam {
|
|
225 |
return false;
|
226 |
}
|
227 |
|
|
|
|
|
|
|
|
|
|
|
|
|
228 |
$api_data = array(
|
229 |
-
'
|
230 |
-
'
|
231 |
-
'
|
232 |
);
|
233 |
|
234 |
-
//
|
235 |
-
|
236 |
-
$api_data['
|
237 |
-
}
|
238 |
|
239 |
-
|
240 |
-
|
|
|
|
|
241 |
|
|
|
242 |
$global_data = self::global_api_data();
|
243 |
$api_data = array_merge( $api_data, $global_data );
|
244 |
|
245 |
// Send the data to zerospam.org.
|
246 |
$args = array(
|
247 |
-
'body' => $api_data,
|
248 |
);
|
249 |
|
250 |
-
wp_remote_post( $endpoint, $args );
|
|
|
|
|
|
|
|
|
|
|
|
|
251 |
}
|
252 |
|
253 |
/**
|
18 |
/**
|
19 |
* The zerospam.org API endpoint
|
20 |
*/
|
21 |
+
const API_ENDPOINT = ZEROSPAM_URL . 'wp-json/zero-spam-store/v1/';
|
22 |
|
23 |
/**
|
24 |
* Constructor
|
199 |
* Global API data.
|
200 |
*/
|
201 |
public function global_api_data() {
|
202 |
+
$api_data = array();
|
203 |
+
$api_data['reporter_email'] = sanitize_email( get_bloginfo( 'admin_email' ) );
|
204 |
+
$api_data['domain'] = esc_url( site_url() );
|
205 |
+
$api_data['wp_version'] = sanitize_text_field( get_bloginfo( 'version' ) );
|
206 |
+
$api_data['wp_admin_email'] = sanitize_email( get_bloginfo( 'admin_email' ) );
|
207 |
+
$api_data['wp_zero_spam_version'] = sanitize_text_field( ZEROSPAM_VERSION );
|
208 |
+
$api_data['wp_language'] = sanitize_text_field( strtolower( get_bloginfo( 'language' ) ) );
|
209 |
+
$api_data['wp_site_name'] = sanitize_text_field( get_bloginfo( 'name' ) );
|
210 |
+
$api_data['wp_site_tagline'] = sanitize_text_field( get_bloginfo( 'description' ) );
|
211 |
|
212 |
return $api_data;
|
213 |
}
|
218 |
* @param array $data Contains all detection details.
|
219 |
*/
|
220 |
public function share_detection( $data ) {
|
221 |
+
// Check to make sure a report hasn't been submitted recently.
|
222 |
+
$last_api_report_submitted = get_site_option( 'zero_spam_last_api_request' );
|
223 |
+
|
224 |
+
if ( $last_api_report_submitted ) {
|
225 |
+
$last_api_report_submitted = new \DateTime( $last_api_report_submitted );
|
226 |
+
$current_time = new \DateTime();
|
227 |
+
|
228 |
+
$minutes_diff = $last_api_report_submitted->diff( $current_time );
|
229 |
+
if ( $minutes_diff->i < 5 ) {
|
230 |
+
//return false;
|
231 |
+
}
|
232 |
+
}
|
233 |
+
|
234 |
+
$endpoint = self::API_ENDPOINT . 'submit-report/';
|
235 |
|
236 |
$ip = \ZeroSpam\Core\User::get_ip();
|
237 |
|
239 |
return false;
|
240 |
}
|
241 |
|
242 |
+
// Define the data to send to the report API.
|
243 |
+
$compliant = sanitize_text_field( $data['type'] );
|
244 |
+
if ( ! empty( $data['failed'] ) ) {
|
245 |
+
$compliant .= ' - ' . sanitize_text_field( $data['failed'] );
|
246 |
+
}
|
247 |
+
|
248 |
$api_data = array(
|
249 |
+
'report_type' => 'ip_address',
|
250 |
+
'ip_address' => sanitize_text_field( $ip ),
|
251 |
+
'compliant' => sanitize_text_field( $compliant ),
|
252 |
);
|
253 |
|
254 |
+
// Add specially defined data to the API report.
|
255 |
+
if ( ! empty( $data['comment_author_email'] ) ) {
|
256 |
+
$api_data['email_address'] = sanitize_email( $data['comment_author_email'] );
|
|
|
257 |
|
258 |
+
if ( ! empty( $data['comment_author'] ) ) {
|
259 |
+
$api_data['email_name'] = sanitize_text_field( $data['comment_author'] );
|
260 |
+
}
|
261 |
+
}
|
262 |
|
263 |
+
// Add data that should be included in every API report.
|
264 |
$global_data = self::global_api_data();
|
265 |
$api_data = array_merge( $api_data, $global_data );
|
266 |
|
267 |
// Send the data to zerospam.org.
|
268 |
$args = array(
|
269 |
+
'body' => array( 'data' => $api_data ),
|
270 |
);
|
271 |
|
272 |
+
$response = wp_remote_post( $endpoint, $args );
|
273 |
+
|
274 |
+
if ( is_wp_error( $response ) ) {
|
275 |
+
//echo $response->get_error_message();
|
276 |
+
}
|
277 |
+
|
278 |
+
update_site_option( 'zero_spam_last_api_request', current_time( 'mysql' ) );
|
279 |
}
|
280 |
|
281 |
/**
|
modules/woocommerce/class-woocommerce.php
CHANGED
@@ -109,6 +109,9 @@ class WooCommerce {
|
|
109 |
add_action( 'woocommerce_register_form', array( $this, 'add_honeypot_field' ) );
|
110 |
add_action( 'woocommerce_register_form', array( $this, 'add_scripts' ) );
|
111 |
add_action( 'woocommerce_register_post', array( $this, 'process_registration' ), 10, 3 );
|
|
|
|
|
|
|
112 |
}
|
113 |
}
|
114 |
|
@@ -132,7 +135,7 @@ class WooCommerce {
|
|
132 |
// Only add scripts to the appropriate pages.
|
133 |
if ( 'enabled' === \ZeroSpam\Core\Settings::get_settings( 'davidwalsh' ) ) {
|
134 |
wp_enqueue_script( 'zerospam-davidwalsh' );
|
135 |
-
wp_add_inline_script( 'zerospam-davidwalsh', 'jQuery(".woocommerce-form-register").ZeroSpamDavidWalsh();' );
|
136 |
}
|
137 |
}
|
138 |
|
109 |
add_action( 'woocommerce_register_form', array( $this, 'add_honeypot_field' ) );
|
110 |
add_action( 'woocommerce_register_form', array( $this, 'add_scripts' ) );
|
111 |
add_action( 'woocommerce_register_post', array( $this, 'process_registration' ), 10, 3 );
|
112 |
+
|
113 |
+
add_action( 'woocommerce_before_checkout_form', array( $this, 'add_scripts' ) );
|
114 |
+
add_action( 'woocommerce_after_order_notes', array( $this, 'add_honeypot_field' ), 10 );
|
115 |
}
|
116 |
}
|
117 |
|
135 |
// Only add scripts to the appropriate pages.
|
136 |
if ( 'enabled' === \ZeroSpam\Core\Settings::get_settings( 'davidwalsh' ) ) {
|
137 |
wp_enqueue_script( 'zerospam-davidwalsh' );
|
138 |
+
wp_add_inline_script( 'zerospam-davidwalsh', 'jQuery(".woocommerce-form-register, .woocommerce-checkout").ZeroSpamDavidWalsh();' );
|
139 |
}
|
140 |
}
|
141 |
|
readme.txt
CHANGED
@@ -3,9 +3,9 @@ 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.9.
|
7 |
Requires PHP: 7.3
|
8 |
-
Stable tag: 5.
|
9 |
License: GNU GPLv3
|
10 |
License URI: https://choosealicense.com/licenses/gpl-3.0/
|
11 |
|
@@ -106,6 +106,11 @@ If hosting with Pantheon, see their [known issues page](https://pantheon.io/docs
|
|
106 |
|
107 |
== Changelog ==
|
108 |
|
|
|
|
|
|
|
|
|
|
|
109 |
= v5.2.15 =
|
110 |
|
111 |
* feat(ukraine): we'll no longer provide protection for .ru, .su, and .by domains & will display a banner of support for the ukrainian people on those sites - united with ukraine
|
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.9.2
|
7 |
Requires PHP: 7.3
|
8 |
+
Stable tag: 5.3.0
|
9 |
License: GNU GPLv3
|
10 |
License URI: https://choosealicense.com/licenses/gpl-3.0/
|
11 |
|
106 |
|
107 |
== Changelog ==
|
108 |
|
109 |
+
= v5.3.0 =
|
110 |
+
|
111 |
+
* fix(woocommerce): fix for spam getting triggered during woo checkout with create account checked, resolves #313
|
112 |
+
* refactor(zero spam api): performance improvements when sharing detections
|
113 |
+
|
114 |
= v5.2.15 =
|
115 |
|
116 |
* feat(ukraine): we'll no longer provide protection for .ru, .su, and .by domains & will display a banner of support for the ukrainian people on those sites - united with ukraine
|
uninstall.php
CHANGED
@@ -29,6 +29,7 @@ if ( is_multisite() ) {
|
|
29 |
delete_option( 'zerospam_db_version' );
|
30 |
delete_option( 'zerospam_configured' );
|
31 |
delete_option( 'zerospam_davidwalsh' );
|
|
|
32 |
|
33 |
foreach ( $tables as $key => $table ) {
|
34 |
// @codingStandardsIgnoreLine
|
@@ -43,6 +44,7 @@ if ( is_multisite() ) {
|
|
43 |
delete_option( 'zerospam_db_version' );
|
44 |
delete_option( 'zerospam_configured' );
|
45 |
delete_option( 'zerospam_davidwalsh' );
|
|
|
46 |
|
47 |
foreach ( $tables as $key => $table ) {
|
48 |
// @codingStandardsIgnoreLine
|
29 |
delete_option( 'zerospam_db_version' );
|
30 |
delete_option( 'zerospam_configured' );
|
31 |
delete_option( 'zerospam_davidwalsh' );
|
32 |
+
delete_option( 'zero_spam_last_api_report' );
|
33 |
|
34 |
foreach ( $tables as $key => $table ) {
|
35 |
// @codingStandardsIgnoreLine
|
44 |
delete_option( 'zerospam_db_version' );
|
45 |
delete_option( 'zerospam_configured' );
|
46 |
delete_option( 'zerospam_davidwalsh' );
|
47 |
+
delete_option( 'zero_spam_last_api_report' );
|
48 |
|
49 |
foreach ( $tables as $key => $table ) {
|
50 |
// @codingStandardsIgnoreLine
|
wordpress-zero-spam.php
CHANGED
@@ -13,7 +13,7 @@
|
|
13 |
* Plugin Name: Zero Spam for WordPress
|
14 |
* Plugin URI: https://www.highfivery.com/projects/zero-spam/
|
15 |
* Description: Tired of all the ineffective WordPress anti-spam & security plugins? Zero Spam for WordPress makes blocking spam & malicious activity a cinch. <strong>Just activate, configure, and say goodbye to spam.</strong>
|
16 |
-
* Version: 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.
|
35 |
|
36 |
if ( defined( 'ZEROSPAM_DEVELOPMENT_URL' ) ) {
|
37 |
define( 'ZEROSPAM_URL', ZEROSPAM_DEVELOPMENT_URL );
|
13 |
* Plugin Name: Zero Spam for WordPress
|
14 |
* Plugin URI: https://www.highfivery.com/projects/zero-spam/
|
15 |
* Description: Tired of all the ineffective WordPress anti-spam & security plugins? Zero Spam for WordPress makes blocking spam & malicious activity a cinch. <strong>Just activate, configure, and say goodbye to spam.</strong>
|
16 |
+
* Version: 5.3.0
|
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.3.0' );
|
35 |
|
36 |
if ( defined( 'ZEROSPAM_DEVELOPMENT_URL' ) ) {
|
37 |
define( 'ZEROSPAM_URL', ZEROSPAM_DEVELOPMENT_URL );
|