Skip to content

Commit

Permalink
Merge branch 'master' into change-wording-for-options
Browse files Browse the repository at this point in the history
  • Loading branch information
florianbrinkmann committed Jul 22, 2021
2 parents d212fb4 + 550ec54 commit 2f03098
Show file tree
Hide file tree
Showing 11 changed files with 86 additions and 37 deletions.
1 change: 1 addition & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,4 @@ jobs:
composer install
npm install
composer lint-all
composer cs
53 changes: 48 additions & 5 deletions antispam_bee.php
Original file line number Diff line number Diff line change
Expand Up @@ -1792,11 +1792,41 @@ private static function _is_country_spam( $ip ) {
return false;
}

$response = wp_safe_remote_head(
/**
* Filter to hook into the `_is_country_spam` functionality, to implement for example a custom IP check.
*
* @since 2.10.0
*
* @param null $is_country_spam The `is_country_spam` result.
* @param string $ip The IP address.
* @param array $white The list of whitelisted country codes.
* @param array $black The list of blacklisted country codes.
*
* @return null|boolean The `is_country_spam` result or null.
*/
$is_country_spam = apply_filters( 'antispam_bee_is_country_spam', null, $ip, $white, $black );

if ( is_bool( $is_country_spam ) ) {
return $is_country_spam;
}

/**
* Filters the IPLocate API key. With this filter, you can add your own IPLocate API key.
*
* @since 2.10.0
*
* @param string The current IPLocate API key. Default is `null`.
*
* @return string The changed IPLocate API key or null.
*/
$apikey = apply_filters( 'antispam_bee_country_spam_apikey', '' );

$response = wp_safe_remote_get(
esc_url_raw(
sprintf(
'https://api.ip2country.info/ip?%s',
self::_anonymize_ip( $ip )
'https://www.iplocate.io/api/lookup/%s?apikey=%s',
self::_anonymize_ip( $ip ),
$apikey
),
'https'
)
Expand All @@ -1810,7 +1840,20 @@ private static function _is_country_spam( $ip ) {
return false;
}

$country = (string) wp_remote_retrieve_header( $response, 'x-country-code' );
$body = (string) wp_remote_retrieve_body( $response );

$json = json_decode( $body, true );

// Check if response is valid json.
if ( ! is_array( $json ) ) {
return false;
}

if ( empty( $json['country_code'] ) ) {
return false;
}

$country = strtoupper( $json['country_code'] );

if ( empty( $country ) || strlen( $country ) !== 2 ) {
return false;
Expand Down Expand Up @@ -1907,7 +1950,7 @@ private static function _is_lang_spam( $comment_content ) {
* enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.
* Do not translate into your own language.
*/
if ( strpos( _x( 'words', 'Word count type. Do not translate!' ), 'characters' ) === 0 && preg_match( '/^utf\-?8$/i', get_option( 'blog_charset' ) ) ) {
if ( strpos( _x( 'words', 'Word count type. Do not translate!' ), 'characters' ) === 0 && preg_match( '/^utf\-?8$/i', get_option( 'blog_charset' ) ) ) { // phpcs:ignore WordPress.WP.I18n.MissingArgDomain
preg_match_all( '/./u', $text, $words_array );
if ( isset( $words_array[0] ) ) {
$word_count = count( $words_array[0] );
Expand Down
2 changes: 1 addition & 1 deletion css/dashboard.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ab_chart {
color: #a0a5aa;
color: #a7aaad;
height: 140px;
margin: 0 -4px;
text-align: center;
Expand Down
31 changes: 10 additions & 21 deletions css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,6 @@

/* @end group */

/* @group Browse Happy */

.browsehappy {
margin: 0 0 20px;
padding: 10px;
border: 1px solid #e66f00;
text-align: center;
}

/* @end group */

/* @group Columns */

.ab-wrap {
Expand All @@ -48,7 +37,7 @@
font-size: 18px;
font-weight: normal;
line-height: 20px;
color: #23282d;
color: #1d2327;
}

.ab-column h3.icon::before {
Expand All @@ -57,7 +46,7 @@
right: 20px;
speak: none;
width: 1em;
color: #8e959c;
color: #8c8f94;
position: absolute;
text-align: center;
-webkit-font-smoothing: antialiased;
Expand All @@ -78,7 +67,7 @@

.ab-column h6 {
clear: both;
color: #555d66;
color: #3c434a;
margin: 0 0 20px;
font-weight: normal;
font-size: 13px;
Expand All @@ -93,7 +82,7 @@
.ab-column select {
font-size: 13px;
text-align: center;
background: #f8f8f9;
background: #f6f7f7;
}

.ab-column input[type="number"] {
Expand All @@ -120,7 +109,7 @@

.ab-column input[type="text"] + label,
.ab-column select + label {
color: #8e959c;
color: #8c8f94;
margin: 0 0 0 7px;
display: inline-block;
text-transform: uppercase;
Expand Down Expand Up @@ -159,11 +148,11 @@
display: inline-block;
font-size: 14px;
max-width: 286px;
color: #23282d;
color: #1d2327;
}

.ab-column > ul > li label span {
color: #555d66;
color: #3c434a;
display: block;
font-size: 13px;
line-height: 16px;
Expand Down Expand Up @@ -195,7 +184,7 @@

.ab-column.ab-arrow > ul > li::after {
bottom: -22px;
border-color: #f1f1f1 transparent;
border-color: #f0f0f1 transparent;
}

.ab-column.ab-join > ul > li::before {
Expand Down Expand Up @@ -231,11 +220,11 @@
}

.ab-column--submit-service p:first-of-type {
border-top: 1px solid #e0e5e9;
border-top: 1px solid #dcdcde;
}

.ab-column--submit-service p:last-of-type {
border-bottom: 1px solid #e0e5e9;
border-bottom: 1px solid #dcdcde;
}

.ab-column--submit-service .button {
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ services:
links:
- db
ports:
- "8081:80"
- "8088:80"
volumes:
- .:/var/www/html/wp-content/plugins/antispam-bee
restart: always
Expand Down
5 changes: 0 additions & 5 deletions inc/gui.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,6 @@ public static function options_page() { ?>

<?php $options = self::get_options(); ?>
<div class="ab-wrap">
<!--[if lt IE 9]>
<p class="browsehappy">
<a href="http://browsehappy.com">Browse Happy</a>
</p>
<![endif]-->

<div class="ab-column ab-arrow">
<h3 class="icon">
Expand Down
6 changes: 3 additions & 3 deletions js/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
leftgutter = 0,
bottomgutter = 22,
topgutter = 22,
color = '#0073aa',
color = '#135e96',
r = Raphael( 'ab_chart', width, height ),
txt = { font: 'bold 12px "Open Sans", sans-serif', fill: '#32373c' },
txt = { font: 'bold 12px "Open Sans", sans-serif', fill: '#1d2327' },
X = ( width - leftgutter * 2 ) / labels.length,
max = Math.max.apply( Math, data ),
Y = ( height - bottomgutter - topgutter ) / max;
Expand All @@ -28,7 +28,7 @@
.attr(
{
font: 'normal 10px "Open Sans", sans-serif',
fill: '#b4b9be',
fill: '#a7aaad',
}
);

Expand Down
2 changes: 2 additions & 0 deletions log.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
1
1
12 changes: 12 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@
<exclude name="WordPress.Files.FileName.InvalidClassFileName"/>
<exclude name="WordPress.Files.FileName.NotHyphenatedLowercase"/>
</rule>
<rule ref="WordPress.NamingConventions.PrefixAllGlobals">
<properties>
<!-- Value: replace the function, class, and variable prefixes used. Separate multiple prefixes with a comma. -->
<property name="prefixes" type="array" value="Antispam_Bee,ab_"/>
</properties>
</rule>
<rule ref="WordPress.WP.I18n">
<properties>
<!-- Value: replace the text domain used. Separate multiple prefixes with a comma. -->
<property name="text_domain" type="array" value="antispam-bee"/>
</properties>
</rule>

<!-- Include sniffs for PHP cross-version compatibility. -->
<config name="testVersion" value="5.2-"/>
Expand Down
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Antispam Bee #
* Contributors: pluginkollektiv, websupporter, schlessera, zodiac1978, swissspidy, krafit, kau-boy, florianbrinkmann
* Contributors: pluginkollektiv, websupporter, schlessera, zodiac1978, swissspidy, krafit, kau-boy, florianbrinkmann, pfefferle
* Tags: anti-spam, antispam, block spam, comment, comments, comment spam, pingback, spam, spam filter, trackback, GDPR
* Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=TD4AMD2D8EMZW
* Requires at least: 4.5
Expand Down
7 changes: 7 additions & 0 deletions tests/Acceptance/Behat/failed-steps/basics-4.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<head><title>404 Not Found</title><style>
body { background-color: #fcfcfc; color: #333333; margin: 0; padding:0; }
h1 { font-size: 1.5em; font-weight: normal; background-color: #9999cc; min-height:2em; line-height:2em; border-bottom: 1px inset black; margin: 0; }
h1, p { padding-left: 10px; }
code.url { background-color: #eeeeee; font-family:monospace; padding:0 2px;}
</style>
</head><body><h1>Not Found</h1><p>The requested resource <code class="url">/wp-login.php?redirect_to=http%3A%2F%2Flocalhost%3A8080%2F</code> was not found on this server.</p></body>

0 comments on commit 2f03098

Please sign in to comment.