Version Description
Download this release
Release Info
Developer | bmarshall511 |
Plugin | WordPress Zero Spam |
Version | 5.1.2 |
Comparing to | |
See all releases |
Code changes from version 5.1.1 to 5.1.2
- core/admin/class-admin.php +4 -4
- core/admin/tables/class-blockedtable.php +1 -1
- core/admin/tables/class-logtable.php +1 -1
- core/class-access.php +16 -13
- core/class-utilities.php +120 -26
- includes/templates/admin-callout.php +8 -8
- includes/templates/admin-ips.php +1 -1
- includes/templates/admin-modal-details.php +1 -1
- modules/class-ipinfomodule.php +4 -0
- modules/class-zerospam.php +42 -26
- readme.txt +11 -4
- wordpress-zero-spam.php +7 -3
core/admin/class-admin.php
CHANGED
@@ -75,7 +75,7 @@ class Admin {
|
|
75 |
'strong' => array(),
|
76 |
)
|
77 |
),
|
78 |
-
esc_url( '
|
79 |
);
|
80 |
?>
|
81 |
</h3>
|
@@ -97,8 +97,8 @@ class Admin {
|
|
97 |
)
|
98 |
);
|
99 |
?>
|
100 |
-
<a href="
|
101 |
-
<a href="
|
102 |
</div>
|
103 |
<?php
|
104 |
}
|
@@ -125,7 +125,7 @@ class Admin {
|
|
125 |
),
|
126 |
esc_url( admin_url( 'options-general.php?page=wordpress-zero-spam-settings' ) ),
|
127 |
esc_url( admin_url( 'options-general.php?page=wordpress-zero-spam-settings&zerospam-auto-configure=1' ) ),
|
128 |
-
esc_url( '
|
129 |
);
|
130 |
|
131 |
$class = 'notice notice-success';
|
75 |
'strong' => array(),
|
76 |
)
|
77 |
),
|
78 |
+
esc_url( ZEROSPAM_URL . 'subscribe/' )
|
79 |
);
|
80 |
?>
|
81 |
</h3>
|
97 |
)
|
98 |
);
|
99 |
?>
|
100 |
+
<a href="<?php echo esc_url( ZEROSPAM_URL ); ?>subscribe/?utm_source=wordpress_zero_spam&utm_medium=dashboard_widget&utm_campaign=license" target="_blank" rel="noreferrer noopener" class="button button-primary"><?php esc_html_e( 'Get a Zero Spam License', 'zerospam' ); ?></a>
|
101 |
+
<a href="<?php echo esc_url( ZEROSPAM_URL ); ?>?utm_source=wordpress_zero_spam&utm_medium=dashboard_widget&utm_campaign=license" target="_blank" rel="noreferrer noopener" class="button button-secondary"><?php esc_html_e( 'Learn More', 'zerospam' ); ?></a>
|
102 |
</div>
|
103 |
<?php
|
104 |
}
|
125 |
),
|
126 |
esc_url( admin_url( 'options-general.php?page=wordpress-zero-spam-settings' ) ),
|
127 |
esc_url( admin_url( 'options-general.php?page=wordpress-zero-spam-settings&zerospam-auto-configure=1' ) ),
|
128 |
+
esc_url( ZEROSPAM_URL . 'product/premium/' )
|
129 |
);
|
130 |
|
131 |
$class = 'notice notice-success';
|
core/admin/tables/class-blockedtable.php
CHANGED
@@ -45,7 +45,7 @@ class BlockedTable extends WP_List_Table {
|
|
45 |
public function column_default( $item, $column_name ) {
|
46 |
switch ( $column_name ) {
|
47 |
case 'user_ip':
|
48 |
-
return '<a href="
|
49 |
break;
|
50 |
case 'date_added':
|
51 |
case 'start_block':
|
45 |
public function column_default( $item, $column_name ) {
|
46 |
switch ( $column_name ) {
|
47 |
case 'user_ip':
|
48 |
+
return '<a href="' . ZEROSPAM_URL . 'ip-lookup/' . urlencode( $item[ $column_name ] ) .'" target="_blank" rel="noopener noreferrer">' . $item[ $column_name ] . '</a>';
|
49 |
break;
|
50 |
case 'date_added':
|
51 |
case 'start_block':
|
core/admin/tables/class-logtable.php
CHANGED
@@ -64,7 +64,7 @@ class LogTable extends WP_List_Table {
|
|
64 |
return $type;
|
65 |
break;
|
66 |
case 'user_ip':
|
67 |
-
return '<a href="
|
68 |
break;
|
69 |
case 'date_recorded':
|
70 |
return date( 'M j, Y g:ia' , strtotime( $item[ $column_name ] ) );
|
64 |
return $type;
|
65 |
break;
|
66 |
case 'user_ip':
|
67 |
+
return '<a href="' . ZEROSPAM_URL . 'ip-lookup/' . urlencode( $item[ $column_name ] ) .'" target="_blank" rel="noopener noreferrer">' . $item[ $column_name ] . '</a>';
|
68 |
break;
|
69 |
case 'date_recorded':
|
70 |
return date( 'M j, Y g:ia' , strtotime( $item[ $column_name ] ) );
|
core/class-access.php
CHANGED
@@ -165,6 +165,10 @@ class Access {
|
|
165 |
*
|
166 |
* @since 5.0.0
|
167 |
* @access public
|
|
|
|
|
|
|
|
|
168 |
*/
|
169 |
public function check_blocked( $access_checks, $user_ip, $settings ) {
|
170 |
$access_checks['blocked'] = array(
|
@@ -172,8 +176,10 @@ class Access {
|
|
172 |
);
|
173 |
|
174 |
// Check if geolocation information is available, if so, check if blocked.
|
175 |
-
$geolocation_information = ZeroSpam\Core\Utilities::geolocation( $user_ip );
|
176 |
if ( $geolocation_information ) {
|
|
|
|
|
177 |
$location_keys = array(
|
178 |
'country_code',
|
179 |
'region_code',
|
@@ -183,7 +189,7 @@ class Access {
|
|
183 |
|
184 |
foreach ( $location_keys as $key => $loc ) {
|
185 |
if ( ! empty( $geolocation_information[ $loc ] ) ) {
|
186 |
-
$blocked = ZeroSpam\Includes\DB::blocked( $geolocation_information[ $loc ], $loc );
|
187 |
if ( $blocked ) {
|
188 |
$access_checks['blocked'] = self::get_blocked_details( $blocked, 'blocked_' . $loc );
|
189 |
break;
|
@@ -192,19 +198,10 @@ class Access {
|
|
192 |
}
|
193 |
}
|
194 |
|
195 |
-
// Try getting country from Cloudflare.
|
196 |
-
$cloudflare_country_code = ! empty( $_SERVER['HTTP_CF_IPCOUNTRY'] ) ? $_SERVER['HTTP_CF_IPCOUNTRY'] : false;
|
197 |
-
if ( $cloudflare_country_code ) {
|
198 |
-
$blocked = ZeroSpam\Includes\DB::blocked( $cloudflare_country_code, 'country_code' );
|
199 |
-
if ( $blocked ) {
|
200 |
-
$access_checks['blocked'] = self::get_blocked_details( $blocked, 'blocked_country_code' );
|
201 |
-
}
|
202 |
-
}
|
203 |
-
|
204 |
// If passed location blocks, check the IP address.
|
205 |
if ( ! $access_checks['blocked'] ) {
|
206 |
// Check the user's IP access.
|
207 |
-
$blocked = ZeroSpam\Includes\DB::blocked( $user_ip );
|
208 |
if ( $blocked ) {
|
209 |
$access_checks['blocked'] = self::get_blocked_details( $blocked, 'blocked_ip' );
|
210 |
}
|
@@ -234,7 +231,13 @@ class Access {
|
|
234 |
return $access;
|
235 |
}
|
236 |
|
237 |
-
$access_checks = apply_filters(
|
|
|
|
|
|
|
|
|
|
|
|
|
238 |
foreach ( $access_checks as $key => $check ) {
|
239 |
if ( ! empty( $check['blocked'] ) ) {
|
240 |
$access['blocked'] = true;
|
165 |
*
|
166 |
* @since 5.0.0
|
167 |
* @access public
|
168 |
+
*
|
169 |
+
* @param array $access_checks Array of exisiting access checks.
|
170 |
+
* @param string $user_ip The user's IP address.
|
171 |
+
* @param array $settings The plugin settings.
|
172 |
*/
|
173 |
public function check_blocked( $access_checks, $user_ip, $settings ) {
|
174 |
$access_checks['blocked'] = array(
|
176 |
);
|
177 |
|
178 |
// Check if geolocation information is available, if so, check if blocked.
|
179 |
+
$geolocation_information = \ZeroSpam\Core\Utilities::geolocation( $user_ip );
|
180 |
if ( $geolocation_information ) {
|
181 |
+
// Geolocation information available, check the blocked locations.
|
182 |
+
// Available blocked location keys.
|
183 |
$location_keys = array(
|
184 |
'country_code',
|
185 |
'region_code',
|
189 |
|
190 |
foreach ( $location_keys as $key => $loc ) {
|
191 |
if ( ! empty( $geolocation_information[ $loc ] ) ) {
|
192 |
+
$blocked = \ZeroSpam\Includes\DB::blocked( $geolocation_information[ $loc ], $loc );
|
193 |
if ( $blocked ) {
|
194 |
$access_checks['blocked'] = self::get_blocked_details( $blocked, 'blocked_' . $loc );
|
195 |
break;
|
198 |
}
|
199 |
}
|
200 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
201 |
// If passed location blocks, check the IP address.
|
202 |
if ( ! $access_checks['blocked'] ) {
|
203 |
// Check the user's IP access.
|
204 |
+
$blocked = \ZeroSpam\Includes\DB::blocked( $user_ip );
|
205 |
if ( $blocked ) {
|
206 |
$access_checks['blocked'] = self::get_blocked_details( $blocked, 'blocked_ip' );
|
207 |
}
|
231 |
return $access;
|
232 |
}
|
233 |
|
234 |
+
$access_checks = apply_filters(
|
235 |
+
'zerospam_access_checks',
|
236 |
+
array(),
|
237 |
+
$user_ip,
|
238 |
+
$settings
|
239 |
+
);
|
240 |
+
|
241 |
foreach ( $access_checks as $key => $check ) {
|
242 |
if ( ! empty( $check['blocked'] ) ) {
|
243 |
$access['blocked'] = true;
|
core/class-utilities.php
CHANGED
@@ -493,44 +493,138 @@ class Utilities {
|
|
493 |
*
|
494 |
* @since 5.1.1
|
495 |
*
|
496 |
-
* @param string $ip IP address.
|
|
|
497 |
*/
|
498 |
public static function geolocation( $ip ) {
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
507 |
}
|
508 |
|
509 |
-
//
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
514 |
|
515 |
-
|
516 |
-
|
517 |
-
$location_information['country_code'] = $location_information['country'];
|
518 |
-
unset( $location_information['country'] );
|
519 |
}
|
520 |
|
521 |
-
if ( ! empty( $
|
522 |
-
$
|
523 |
-
unset( $location_information['postal'] );
|
524 |
}
|
525 |
|
526 |
-
if ( ! empty( $
|
527 |
-
|
528 |
-
$location_information['region_code'] = $location_information['region'];
|
529 |
-
unset( $location_information['region'] );
|
530 |
}
|
531 |
}
|
532 |
}
|
533 |
|
534 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
535 |
}
|
536 |
}
|
493 |
*
|
494 |
* @since 5.1.1
|
495 |
*
|
496 |
+
* @param string $ip IP address to lookup.
|
497 |
+
* @return boolean|array False if geolocation is unavailable or array of location information.
|
498 |
*/
|
499 |
public static function geolocation( $ip ) {
|
500 |
+
// The standarized location array that will be returned.
|
501 |
+
$location_details = array(
|
502 |
+
'type' => false,
|
503 |
+
'hostname' => false,
|
504 |
+
'timezone' => false,
|
505 |
+
'organization' => false,
|
506 |
+
'continent_code' => false,
|
507 |
+
'continent_name' => false,
|
508 |
+
'country_code' => false,
|
509 |
+
'country_name' => false,
|
510 |
+
'zip' => false,
|
511 |
+
'region_code' => false,
|
512 |
+
'region_name' => false,
|
513 |
+
'city' => false,
|
514 |
+
'latitude' => false,
|
515 |
+
'longitude' => false,
|
516 |
+
);
|
517 |
+
|
518 |
+
// 1. Check for the country code via server variables.
|
519 |
+
if ( ! empty( $_SERVER['HTTP_CF_IPCOUNTRY'] ) ) {
|
520 |
+
// Check Cloudflare.
|
521 |
+
$location_details['country_code'] = sanitize_text_field( wp_unslash( $_SERVER['HTTP_CF_IPCOUNTRY'] ) );
|
522 |
+
} elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_COUNTRY'] ) ) {
|
523 |
+
// Check Cloudways.
|
524 |
+
$location_details['country_code'] = sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_FORWARDED_COUNTRY'] ) );
|
525 |
}
|
526 |
|
527 |
+
// 2. Query the ipstack API.
|
528 |
+
$ipstack_location = \ZeroSpam\Modules\ipstack::get_geolocation( $ip );
|
529 |
+
if ( $ipstack_location ) {
|
530 |
+
// ipstack API key provided, process the response.
|
531 |
+
if ( ! empty( $ipstack_location['error'] ) ) {
|
532 |
+
// ipstack returned an error, log it for future reference.
|
533 |
+
self::log( wp_json_encode( $ipstack_location['error'] ) );
|
534 |
+
} else {
|
535 |
+
// Add available location info to the standarized array.
|
536 |
+
if ( ! empty( $ipstack_location['type'] ) ) {
|
537 |
+
$location_details['type'] = $ipstack_location['type'];
|
538 |
+
}
|
539 |
+
|
540 |
+
if ( ! empty( $ipstack_location['continent_code'] ) ) {
|
541 |
+
$location_details['continent_code'] = $ipstack_location['continent_code'];
|
542 |
+
}
|
543 |
+
|
544 |
+
if ( ! empty( $ipstack_location['continent_name'] ) ) {
|
545 |
+
$location_details['continent_name'] = $ipstack_location['continent_name'];
|
546 |
+
}
|
547 |
+
|
548 |
+
if ( ! empty( $ipstack_location['country_code'] ) ) {
|
549 |
+
$location_details['country_code'] = $ipstack_location['country_code'];
|
550 |
+
}
|
551 |
+
|
552 |
+
if ( ! empty( $ipstack_location['country_name'] ) ) {
|
553 |
+
$location_details['country_name'] = $ipstack_location['country_name'];
|
554 |
+
}
|
555 |
+
|
556 |
+
if ( ! empty( $ipstack_location['region_code'] ) ) {
|
557 |
+
$location_details['region_code'] = $ipstack_location['region_code'];
|
558 |
+
}
|
559 |
+
|
560 |
+
if ( ! empty( $ipstack_location['region_name'] ) ) {
|
561 |
+
$location_details['region_name'] = $ipstack_location['region_name'];
|
562 |
+
}
|
563 |
+
|
564 |
+
if ( ! empty( $ipstack_location['city'] ) ) {
|
565 |
+
$location_details['city'] = $ipstack_location['city'];
|
566 |
+
}
|
567 |
|
568 |
+
if ( ! empty( $ipstack_location['zip'] ) ) {
|
569 |
+
$location_details['zip'] = $ipstack_location['zip'];
|
|
|
|
|
570 |
}
|
571 |
|
572 |
+
if ( ! empty( $ipstack_location['latitude'] ) ) {
|
573 |
+
$location_details['latitude'] = $ipstack_location['latitude'];
|
|
|
574 |
}
|
575 |
|
576 |
+
if ( ! empty( $ipstack_location['longitude'] ) ) {
|
577 |
+
$location_details['longitude'] = $ipstack_location['longitude'];
|
|
|
|
|
578 |
}
|
579 |
}
|
580 |
}
|
581 |
|
582 |
+
// 3. Query the IPinfo API.
|
583 |
+
$ipinfo_location = ZeroSpam\Modules\IPinfoModule::get_geolocation( $ip );
|
584 |
+
if ( $ipinfo_location ) {
|
585 |
+
// IPinfo token provided, process the response.
|
586 |
+
// Add available location info to the standarized array.
|
587 |
+
if ( ! empty( $ipinfo_location['hostname'] ) ) {
|
588 |
+
$location_details['hostname'] = $ipinfo_location['hostname'];
|
589 |
+
}
|
590 |
+
|
591 |
+
if ( ! empty( $ipinfo_location['city'] ) ) {
|
592 |
+
$location_details['city'] = $ipinfo_location['city'];
|
593 |
+
}
|
594 |
+
|
595 |
+
if ( ! empty( $ipinfo_location['region'] ) ) {
|
596 |
+
$location_details['region_name'] = $ipinfo_location['region'];
|
597 |
+
}
|
598 |
+
|
599 |
+
if ( ! empty( $ipinfo_location['country'] ) ) {
|
600 |
+
$location_details['country_code'] = $ipinfo_location['country'];
|
601 |
+
}
|
602 |
+
|
603 |
+
if ( ! empty( $ipinfo_location['org'] ) ) {
|
604 |
+
$location_details['organization'] = $ipinfo_location['org'];
|
605 |
+
}
|
606 |
+
|
607 |
+
if ( ! empty( $ipinfo_location['postal'] ) ) {
|
608 |
+
$location_details['zip'] = $ipinfo_location['postal'];
|
609 |
+
}
|
610 |
+
|
611 |
+
if ( ! empty( $ipinfo_location['timezone'] ) ) {
|
612 |
+
$location_details['timezone'] = $ipinfo_location['timezone'];
|
613 |
+
}
|
614 |
+
|
615 |
+
if ( ! empty( $ipinfo_location['country_name'] ) ) {
|
616 |
+
$location_details['country_name'] = $ipinfo_location['country_name'];
|
617 |
+
}
|
618 |
+
|
619 |
+
if ( ! empty( $ipinfo_location['latitude'] ) ) {
|
620 |
+
$location_details['latitude'] = $ipinfo_location['latitude'];
|
621 |
+
}
|
622 |
+
|
623 |
+
if ( ! empty( $ipinfo_location['longitude'] ) ) {
|
624 |
+
$location_details['longitude'] = $ipinfo_location['longitude'];
|
625 |
+
}
|
626 |
+
}
|
627 |
+
|
628 |
+
return $location_details;
|
629 |
}
|
630 |
}
|
includes/templates/admin-callout.php
CHANGED
@@ -26,7 +26,7 @@ $settings = \ZeroSpam\Core\Settings::get_settings();
|
|
26 |
),
|
27 |
)
|
28 |
),
|
29 |
-
esc_url( '
|
30 |
);
|
31 |
?>
|
32 |
</h2>
|
@@ -45,12 +45,12 @@ $settings = \ZeroSpam\Core\Settings::get_settings();
|
|
45 |
'strong' => array(),
|
46 |
)
|
47 |
),
|
48 |
-
esc_url( '
|
49 |
-
esc_url( '
|
50 |
);
|
51 |
?>
|
52 |
-
<a class="button button-primary" href="
|
53 |
-
<a href="
|
54 |
<?php else : ?>
|
55 |
<h2>
|
56 |
<?php
|
@@ -66,7 +66,7 @@ $settings = \ZeroSpam\Core\Settings::get_settings();
|
|
66 |
),
|
67 |
)
|
68 |
),
|
69 |
-
esc_url( '
|
70 |
);
|
71 |
?>
|
72 |
</h2>
|
@@ -85,7 +85,7 @@ $settings = \ZeroSpam\Core\Settings::get_settings();
|
|
85 |
'strong' => array(),
|
86 |
)
|
87 |
),
|
88 |
-
esc_url( '
|
89 |
);
|
90 |
?>
|
91 |
<?php endif; ?>
|
@@ -93,7 +93,7 @@ $settings = \ZeroSpam\Core\Settings::get_settings();
|
|
93 |
<div class="zerospam-callout-col zerospam-callout-actions">
|
94 |
<ul>
|
95 |
<?php if ( 'enabled' !== $settings['zerospam']['value'] || empty( $settings['zerospam_license']['value'] ) ) : ?>
|
96 |
-
<li><a href="
|
97 |
<?php endif; ?>
|
98 |
<li><a href="https://github.com/bmarshall511/wordpress-zero-spam/issues" target="_blank"><?php esc_html_e( 'Submit a Bug or Feature Request', 'zerospam' ); ?></a></li>
|
99 |
<li><a href="https://github.com/bmarshall511/wordpress-zero-spam/wiki" target="_blank" rel="noreferrer noopener"><?php esc_html_e( 'WordPress Zero Spam Plugin Documentation', 'zerospam' ); ?></a></li>
|
26 |
),
|
27 |
)
|
28 |
),
|
29 |
+
esc_url( ZEROSPAM_URL . 'subscribe/' )
|
30 |
);
|
31 |
?>
|
32 |
</h2>
|
45 |
'strong' => array(),
|
46 |
)
|
47 |
),
|
48 |
+
esc_url( ZEROSPAM_URL . '?utm_source=wordpress_zero_spam&utm_medium=settings_page&utm_campaign=license' ),
|
49 |
+
esc_url( ZEROSPAM_URL . 'subscribe/?utm_source=wordpress_zero_spam&utm_medium=settings_page&utm_campaign=license' )
|
50 |
);
|
51 |
?>
|
52 |
+
<a class="button button-primary" href="<?php echo esc_url( ZEROSPAM_URL ); ?>subscribe/?utm_source=wordpress_zero_spam&utm_medium=settings_page&utm_campaign=license" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Enable Enhanced Protection', 'zerospam' ); ?></a>
|
53 |
+
<a href="<?php echo esc_url( ZEROSPAM_URL ); ?>?utm_source=wordpress_zero_spam&utm_medium=dashboard_widget&utm_campaign=license" target="_blank" rel="noreferrer noopener" class="button button-secondary"><?php esc_html_e( 'Learn More', 'zerospam' ); ?></a>
|
54 |
<?php else : ?>
|
55 |
<h2>
|
56 |
<?php
|
66 |
),
|
67 |
)
|
68 |
),
|
69 |
+
esc_url( ZEROSPAM_URL . '?utm_source=wordpress_zero_spam&utm_medium=settings_page&utm_campaign=license' )
|
70 |
);
|
71 |
?>
|
72 |
</h2>
|
85 |
'strong' => array(),
|
86 |
)
|
87 |
),
|
88 |
+
esc_url( ZEROSPAM_URL . '?utm_source=wordpress_zero_spam&utm_medium=settings_page&utm_campaign=license' )
|
89 |
);
|
90 |
?>
|
91 |
<?php endif; ?>
|
93 |
<div class="zerospam-callout-col zerospam-callout-actions">
|
94 |
<ul>
|
95 |
<?php if ( 'enabled' !== $settings['zerospam']['value'] || empty( $settings['zerospam_license']['value'] ) ) : ?>
|
96 |
+
<li><a href="<?php echo esc_url( ZEROSPAM_URL ); ?>subscribe/?utm_source=wordpress_zero_spam&utm_medium=settings_page&utm_campaign=license" target="_blank"><?php esc_html_e( 'Get a Zero Spam API License', 'zerospam' ); ?></a></li>
|
97 |
<?php endif; ?>
|
98 |
<li><a href="https://github.com/bmarshall511/wordpress-zero-spam/issues" target="_blank"><?php esc_html_e( 'Submit a Bug or Feature Request', 'zerospam' ); ?></a></li>
|
99 |
<li><a href="https://github.com/bmarshall511/wordpress-zero-spam/wiki" target="_blank" rel="noreferrer noopener"><?php esc_html_e( 'WordPress Zero Spam Plugin Documentation', 'zerospam' ); ?></a></li>
|
includes/templates/admin-ips.php
CHANGED
@@ -46,7 +46,7 @@ if ( $ips ) {
|
|
46 |
height="16"
|
47 |
/>
|
48 |
<?php endif; ?>
|
49 |
-
<a href="
|
50 |
<?php echo $ip; ?>
|
51 |
</a>
|
52 |
</span>
|
46 |
height="16"
|
47 |
/>
|
48 |
<?php endif; ?>
|
49 |
+
<a href="<?php echo esc_url( ZEROSPAM_URL ); ?>ip-lookup/<?php echo urlencode( $ip ); ?>" target="_blank" rel="noopener noreferrer">
|
50 |
<?php echo $ip; ?>
|
51 |
</a>
|
52 |
</span>
|
includes/templates/admin-modal-details.php
CHANGED
@@ -18,7 +18,7 @@
|
|
18 |
<ul class="zerospam-modal-list">
|
19 |
<li>
|
20 |
<strong><?php echo __( 'IP Address', 'zerospam' ); ?></strong>
|
21 |
-
<span><?php echo '<a href="
|
22 |
</li>
|
23 |
<li>
|
24 |
<strong><?php echo __( 'Type', 'zerospam' ); ?></strong>
|
18 |
<ul class="zerospam-modal-list">
|
19 |
<li>
|
20 |
<strong><?php echo __( 'IP Address', 'zerospam' ); ?></strong>
|
21 |
+
<span><?php echo '<a href="' . ZEROSPAM_URL . 'ip-lookup/' . urlencode( $item['user_ip'] ) .'" target="_blank" rel="noopener noreferrer">' . $item['user_ip'] . '</a>'; ?></span>
|
22 |
</li>
|
23 |
<li>
|
24 |
<strong><?php echo __( 'Type', 'zerospam' ); ?></strong>
|
modules/class-ipinfomodule.php
CHANGED
@@ -146,10 +146,14 @@ class IPinfoModule {
|
|
146 |
|
147 |
$result = wp_cache_get( $cache_key );
|
148 |
if ( false === $result ) {
|
|
|
|
|
|
|
149 |
$client = new IPinfo( $settings['ipinfo_access_token']['value'] );
|
150 |
$result = $client->getDetails( $ip );
|
151 |
|
152 |
if ( $result ) {
|
|
|
153 |
$expiration = 14 * DAY_IN_SECONDS;
|
154 |
if ( ! empty( $settings['ipinfo_cache']['value'] ) ) {
|
155 |
$expiration = $settings['ipinfo_cache']['value'] * DAY_IN_SECONDS;
|
146 |
|
147 |
$result = wp_cache_get( $cache_key );
|
148 |
if ( false === $result ) {
|
149 |
+
// Load the IPinfo library.
|
150 |
+
require_once ZEROSPAM_PATH . 'vendor/autoload.php';
|
151 |
+
|
152 |
$client = new IPinfo( $settings['ipinfo_access_token']['value'] );
|
153 |
$result = $client->getDetails( $ip );
|
154 |
|
155 |
if ( $result ) {
|
156 |
+
$result = json_decode( wp_json_encode( $result ), true );
|
157 |
$expiration = 14 * DAY_IN_SECONDS;
|
158 |
if ( ! empty( $settings['ipinfo_cache']['value'] ) ) {
|
159 |
$expiration = $settings['ipinfo_cache']['value'] * DAY_IN_SECONDS;
|
modules/class-zerospam.php
CHANGED
@@ -20,8 +20,7 @@ class Zero_Spam {
|
|
20 |
/**
|
21 |
* The zerospam.org API endpoint
|
22 |
*/
|
23 |
-
const API_ENDPOINT = '
|
24 |
-
//const API_ENDPOINT = 'http://localhost:10023/wp-json/zerospam/v1/';
|
25 |
|
26 |
/**
|
27 |
* Constructor
|
@@ -73,7 +72,7 @@ class Zero_Spam {
|
|
73 |
),
|
74 |
)
|
75 |
),
|
76 |
-
esc_url( '
|
77 |
),
|
78 |
'value' => ! empty( $options['zerospam'] ) ? $options['zerospam'] : false,
|
79 |
'recommended' => 'enabled',
|
@@ -93,8 +92,8 @@ class Zero_Spam {
|
|
93 |
),
|
94 |
)
|
95 |
),
|
96 |
-
esc_url(
|
97 |
-
esc_url( '
|
98 |
),
|
99 |
'section' => 'zerospam',
|
100 |
'type' => 'text',
|
@@ -150,7 +149,7 @@ class Zero_Spam {
|
|
150 |
),
|
151 |
)
|
152 |
),
|
153 |
-
esc_url( '
|
154 |
),
|
155 |
'value' => ! empty( $options['zerospam_confidence_min'] ) ? $options['zerospam_confidence_min'] : 30,
|
156 |
'recommended' => 30,
|
@@ -239,32 +238,49 @@ class Zero_Spam {
|
|
239 |
$api_data['user_ip'] = $ip;
|
240 |
|
241 |
// Attempt to get the geolocation information.
|
242 |
-
$api_data['location'] = ZeroSpam\
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
243 |
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
if
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
253 |
'type' => $check_details['type'],
|
254 |
);
|
255 |
|
256 |
// Add additional details if available.
|
257 |
if ( ! empty( $check_details['details'] && is_array( $check_details['details'] ) ) ) {
|
258 |
-
$
|
259 |
-
|
260 |
-
// Add country if not already set and available.
|
261 |
-
if (
|
262 |
-
empty( $api_data['location']['country_code'] ) &&
|
263 |
-
! empty( $details_data['country'] ) &&
|
264 |
-
2 === strlen( $details_data['country'] )
|
265 |
-
) {
|
266 |
-
$api_data['location']['country_code'] = $details_data['country'];
|
267 |
-
}
|
268 |
}
|
269 |
}
|
270 |
}
|
20 |
/**
|
21 |
* The zerospam.org API endpoint
|
22 |
*/
|
23 |
+
const API_ENDPOINT = ZEROSPAM_URL . 'wp-json/zerospam/v1/';
|
|
|
24 |
|
25 |
/**
|
26 |
* Constructor
|
72 |
),
|
73 |
)
|
74 |
),
|
75 |
+
esc_url( ZEROSPAM_URL . '?utm_source=wordpresszerospam&utm_medium=admin_link&utm_campaign=wordpresszerospam' )
|
76 |
),
|
77 |
'value' => ! empty( $options['zerospam'] ) ? $options['zerospam'] : false,
|
78 |
'recommended' => 'enabled',
|
92 |
),
|
93 |
)
|
94 |
),
|
95 |
+
esc_url( ZEROSPAM_URL ),
|
96 |
+
esc_url( ZEROSPAM_URL . 'product/premium/' )
|
97 |
),
|
98 |
'section' => 'zerospam',
|
99 |
'type' => 'text',
|
149 |
),
|
150 |
)
|
151 |
),
|
152 |
+
esc_url( ZEROSPAM_URL . 'spam-blacklist-api/#utm_source=wordpresszerospam&utm_medium=admin_link&utm_campaign=wordpresszerospam' )
|
153 |
),
|
154 |
'value' => ! empty( $options['zerospam_confidence_min'] ) ? $options['zerospam_confidence_min'] : 30,
|
155 |
'recommended' => 30,
|
238 |
$api_data['user_ip'] = $ip;
|
239 |
|
240 |
// Attempt to get the geolocation information.
|
241 |
+
$api_data['location'] = \ZeroSpam\Core\Utilities::geolocation( $ip );
|
242 |
+
|
243 |
+
// Loop through the individual access checks to determine what should be sent.
|
244 |
+
$ignore_failed_reasons = array(
|
245 |
+
'blocked_country_code',
|
246 |
+
'blocked_region_code',
|
247 |
+
'blocked_city',
|
248 |
+
'blocked_zip',
|
249 |
+
);
|
250 |
|
251 |
+
foreach ( $details as $access_check_key => $check_details ) {
|
252 |
+
// Check if the user failed the access check.
|
253 |
+
if ( ! empty( $check_details['blocked'] ) ) {
|
254 |
+
// Check if came from blocked table.
|
255 |
+
if ( 'blocked' === $access_check_key ) {
|
256 |
+
// Check if one of the 'failed' reasons should be shared.
|
257 |
+
if (
|
258 |
+
! empty( $check_details['details'] ) &&
|
259 |
+
! empty( $check_details['details']['failed'] ) &&
|
260 |
+
in_array( $check_details['details']['failed'], $ignore_failed_reasons, true )
|
261 |
+
) {
|
262 |
+
// Doesn't need to be sent.
|
263 |
+
continue;
|
264 |
+
} else {
|
265 |
+
// Send it.
|
266 |
+
$api_data['checks'][ $access_check_key ] = array(
|
267 |
+
'type' => $check_details['type'],
|
268 |
+
);
|
269 |
+
|
270 |
+
// Add additional details if available.
|
271 |
+
if ( ! empty( $check_details['details'] && is_array( $check_details['details'] ) ) ) {
|
272 |
+
//$api_data['checks'][ $access_check_key ]['details']
|
273 |
+
}
|
274 |
+
}
|
275 |
+
} else {
|
276 |
+
// Not from the blocked table, send it.
|
277 |
+
$api_data['checks'][ $access_check_key ] = array(
|
278 |
'type' => $check_details['type'],
|
279 |
);
|
280 |
|
281 |
// Add additional details if available.
|
282 |
if ( ! empty( $check_details['details'] && is_array( $check_details['details'] ) ) ) {
|
283 |
+
//$api_data['checks'][ $access_check_key ]['details']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
284 |
}
|
285 |
}
|
286 |
}
|
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.
|
9 |
License: GNU GPLv3
|
10 |
License URI: https://choosealicense.com/licenses/gpl-3.0/
|
11 |
|
@@ -27,7 +27,7 @@ Quit forcing people to answer questions or confusing captchas to prove they're n
|
|
27 |
* Automatically & manually block IPs temporarily or permanently
|
28 |
* Geolocate IP addresses to see where offenders are coming from
|
29 |
* Block entire countries, regions, zip/postal codes & cities
|
30 |
-
*
|
31 |
* Multiple detection techniques including [David Walsh's solution](https://davidwalsh.name/wordpress-comment-spam)
|
32 |
|
33 |
= WordPress Zero Spam also protects =
|
@@ -65,9 +65,9 @@ For more information & developer documentation, see the [plugin’s website](htt
|
|
65 |
|
66 |
= How do I boost performance of WordPress Zero Spam? =
|
67 |
|
68 |
-
Caching is highly recommended and will prevent repeated calls to third-party API and access checks on each page visit.
|
69 |
|
70 |
-
= What WP-CLI commands are available
|
71 |
|
72 |
* `wp zerospam autoconfigure` — Auto-configures with recommended settings.
|
73 |
* `wp zerospam settings` — Displays all plugin settings.
|
@@ -83,6 +83,13 @@ Caching is highly recommended and will prevent repeated calls to third-party API
|
|
83 |
|
84 |
== Changelog ==
|
85 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
= v5.1.1 =
|
87 |
|
88 |
* feat(geolocation): resolves #270, added support for ipinfo geolocation
|
5 |
Requires at least: 5.2
|
6 |
Tested up to: 5.8.1
|
7 |
Requires PHP: 7.3
|
8 |
+
Stable tag: 5.1.2
|
9 |
License: GNU GPLv3
|
10 |
License URI: https://choosealicense.com/licenses/gpl-3.0/
|
11 |
|
27 |
* Automatically & manually block IPs temporarily or permanently
|
28 |
* Geolocate IP addresses to see where offenders are coming from
|
29 |
* Block entire countries, regions, zip/postal codes & cities
|
30 |
+
* Optional disallowed list using [splorp's Comment Blacklist](https://github.com/splorp/wordpress-comment-blacklist)
|
31 |
* Multiple detection techniques including [David Walsh's solution](https://davidwalsh.name/wordpress-comment-spam)
|
32 |
|
33 |
= WordPress Zero Spam also protects =
|
65 |
|
66 |
= How do I boost performance of WordPress Zero Spam? =
|
67 |
|
68 |
+
**Enabled caching.** Caching is highly recommended and will prevent repeated calls to third-party API and access checks on each page visit.
|
69 |
|
70 |
+
= What WordPress Zero Spam WP-CLI commands are available? =
|
71 |
|
72 |
* `wp zerospam autoconfigure` — Auto-configures with recommended settings.
|
73 |
* `wp zerospam settings` — Displays all plugin settings.
|
83 |
|
84 |
== Changelog ==
|
85 |
|
86 |
+
= v5.1.2 =
|
87 |
+
|
88 |
+
* perf(geolocation): improved performance for geolocation and data sharing
|
89 |
+
* docs(readme): updated readme file
|
90 |
+
* refactor(misc): added some functionality to make debugging easier
|
91 |
+
* fix(ipinfo): resolves #273, loads the ipinfo library only if enabled
|
92 |
+
|
93 |
= v5.1.1 =
|
94 |
|
95 |
* feat(geolocation): resolves #270, added support for ipinfo geolocation
|
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 & malicious activity a cinch. <strong>Just install, activate, configure, and say goodbye to spam.</strong>
|
16 |
-
* Version: 5.1.
|
17 |
* Requires at least: 5.2
|
18 |
* Requires PHP: 7.3
|
19 |
* Author: Highfivery LLC
|
@@ -31,9 +31,13 @@ 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.
|
35 |
|
36 |
-
|
|
|
|
|
|
|
|
|
37 |
|
38 |
add_action( 'plugins_loaded', 'zerospam_load_plugin_textdomain' );
|
39 |
|
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 & malicious activity a cinch. <strong>Just install, activate, configure, and say goodbye to spam.</strong>
|
16 |
+
* Version: 5.1.2
|
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.2' );
|
35 |
|
36 |
+
if ( defined( 'ZEROSPAM_DEVELOPMENT_URL' ) ) {
|
37 |
+
define( 'ZEROSPAM_URL', ZEROSPAM_DEVELOPMENT_URL );
|
38 |
+
} else {
|
39 |
+
define( 'ZEROSPAM_URL', 'https://www.zerospam.org/' );
|
40 |
+
}
|
41 |
|
42 |
add_action( 'plugins_loaded', 'zerospam_load_plugin_textdomain' );
|
43 |
|