Compare commits

..

No commits in common. "stable" and "v1.7.0" have entirely different histories.

11 changed files with 39 additions and 140 deletions

View File

@ -1,9 +1,7 @@
/.git /.git
/.github /.github
/assets /assets
/dist
/test /test
/vendor
/.distignore /.distignore
/.editorconfig /.editorconfig
/.gitattributes /.gitattributes

1
.gitattributes vendored
View File

@ -1,6 +1,5 @@
/.github export-ignore /.github export-ignore
/assets export-ignore /assets export-ignore
/dist export-ignore
/test export-ignore /test export-ignore
.distignore export-ignore .distignore export-ignore
.gitattributes export-ignore .gitattributes export-ignore

View File

@ -5,7 +5,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
matrix: matrix:
php: [ '5.6', '7.4', '8.0', '8.2', '8.4' ] php: [ '5.6', '7.4', '8.0', '8.1', '8.2', '8.3' ]
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
@ -15,7 +15,6 @@ jobs:
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@v2
with: with:
php-version: ${{ matrix.php }} php-version: ${{ matrix.php }}
coverage: xdebug
tools: composer tools: composer
- name: Install - name: Install
run: composer install --no-interaction run: composer install --no-interaction
@ -24,7 +23,7 @@ jobs:
composer test composer test
sed -i "s#<file name=\"${GITHUB_WORKSPACE}#<file name=\"/github/workspace#g" tests-clover.xml sed -i "s#<file name=\"${GITHUB_WORKSPACE}#<file name=\"/github/workspace#g" tests-clover.xml
- name: Analyze with SonarCloud - name: Analyze with SonarCloud
if: matrix.php == '8.2' && env.SONAR_TOKEN != '' if: matrix.php == '8.2'
uses: sonarsource/sonarcloud-github-action@master uses: sonarsource/sonarcloud-github-action@master
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@ -1,23 +0,0 @@
name: Plugin check
on:
push:
branches: [ 'stable', 'release/*' ]
pull_request:
branches: [ 'stable' ]
jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Package plugin
run: |
mkdir -p ./dist
tail -n +6 README.md > README.md.tmp && mv README.md.tmp README.md
rsync -rc --exclude-from=.distignore ./ ./dist/statify-blacklist --delete --delete-excluded
- name: Check WP plugin
uses: wordpress/plugin-check-action@v1
with:
build-dir: ./dist/statify-blacklist

View File

@ -1,25 +1,23 @@
[![CI](https://github.com/stklcode/statify-blacklist/actions/workflows/test.yml/badge.svg?branch=stable)](https://github.com/stklcode/statify-blacklist/actions/workflows/test.yml) [![Build Status](https://github.com/stklcode/statify-blacklist/actions/workflows/test.yml/badge.svg?branch=stable)](https://github.com/stklcode/statify-blacklist/actions/workflows/test.yml?query=branch%3Astable)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=stklcode%3Astatify-blacklist&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=stklcode%3Astatify-blacklist) [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=stklcode%3Astatify-blacklist&metric=alert_status)](https://sonarcloud.io/dashboard?id=stklcode%3Astatify-blacklist)
[![Packagist Version](https://img.shields.io/packagist/v/stklcode/statify-blacklist)](https://packagist.org/packages/stklcode/statify-blacklist) [![Packagist Version](https://img.shields.io/packagist/v/stklcode/statify-blacklist.svg)](https://packagist.org/packages/stklcode/statify-blacklist)
[![License](https://img.shields.io/badge/license-GPL%20v2-blue.svg)](https://github.com/stklcode/statify-blacklist/blob/stable/LICENSE.md) [![License](https://img.shields.io/badge/license-GPL%20v2-blue.svg)](https://github.com/stklcode/statify-blacklist/blob/stable/LICENSE.md)
# Statify Filter # # Statify Filter #
* Contributors: stklcode * Contributors: Stefan Kalscheuer
* Requires at least: 4.7 * Requires at least: 4.7
* Tested up to: 6.8 * Tested up to: 6.4
* Requires PHP: 5.5 * Requires PHP: 5.5
* Stable tag: 1.7.2 * Stable tag: 1.7.0
* License: GPLv2 or later * License: GPLv2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html * License URI: https://www.gnu.org/licenses/gpl-2.0.html
Filter extension for the famous Statify WordPress plugin.
## Description ## ## Description ##
A filter extension for the famous [Statify](https://wordpress.org/plugins/statify/) WordPress plugin. A filter extension for the famous [Statify](https://wordpress.org/plugins/statify/) WordPress plugin.
This plugin adds customizable filters to Statify to allow blocking of referer spam or internal interactions. This plugin adds customizable filters to Statify to allow blocking of referer spam or internal interactions.
### Features ### ### Features ##
#### Referer Filter #### #### Referer Filter ####
Add a list of domains (for simplicity only second-level, e.g. _example.com_ which blocks _everything.example.com_). Add a list of domains (for simplicity only second-level, e.g. _example.com_ which blocks _everything.example.com_).
@ -95,26 +93,11 @@ Same for IPv6 prefixes like _2001:db8:a0b:12f0::/64_.
## Upgrade Notice ## ## Upgrade Notice ##
### 1.7.2 ###
This is a bugfix release to restore the manual cleanup function that was broken since 1.7.0.
### 1.7.1 ###
This is a service release with minor corrections. Recommended for all users. Tested up to 6.5.
### 1.7.0 ### ### 1.7.0 ###
This is a service release with primarily internal rework. Tested up to 6.4 and PHP 8.3. This is a service release with primarily internal rework. Tested up to 6.4 and PHP 8.3.
## Changelog ## Changelog ##
### 1.7.2 / 06.06.2024 ###
* Restore manual database cleanup functionality
### 1.7.1 / 24.03.2024 ###
* Fix HTML syntax for checkboxes on settings page
* Simplify some internal control structures
* Add plugin dependency to Statify
* Declared compatibility with WordPress 6.5
### 1.7.0 / 11.03.2024 ### ### 1.7.0 / 11.03.2024 ###
* Internal rework of plugin settings * Internal rework of plugin settings

View File

@ -1,36 +0,0 @@
{
"$schema": "https://playground.wordpress.net/blueprint-schema.json",
"landingPage": "/wp-admin/options-general.php?page=statify-blacklist",
"features": {
"networking": true
},
"steps": [
{
"step": "login",
"username": "admin",
"password": "password"
},
{
"step": "installPlugin",
"pluginData": {
"resource": "wordpress.org/plugins",
"slug": "statify"
}
},
{
"step": "activatePlugin",
"pluginPath": "statify/statify.php"
},
{
"step": "installPlugin",
"pluginData": {
"resource": "wordpress.org/plugins",
"slug": "statify-blacklist"
}
},
{
"step": "activatePlugin",
"pluginPath": "statify-blacklist/statify-blacklist.php"
}
]
}

View File

@ -1,6 +1,6 @@
{ {
"name": "stklcode/statify-blacklist", "name": "stklcode/statify-blacklist",
"version": "1.7.2", "version": "1.7.0",
"description": "A filter extension for the famous Statify WordPress plugin", "description": "A filter extension for the famous Statify WordPress plugin",
"keywords": [ "keywords": [
"wordpress", "wordpress",
@ -19,16 +19,16 @@
"type": "wordpress-plugin", "type": "wordpress-plugin",
"require": { "require": {
"php": ">=5.5", "php": ">=5.5",
"composer/installers": "~v1.12|~v2.3" "composer/installers": "~v1.12|~v2.2"
}, },
"require-dev": { "require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^v1.0", "dealerdirect/phpcodesniffer-composer-installer": "^v1.0",
"phpunit/phpunit": "^5|^6|^7|^8|^9", "phpunit/phpunit": "^5|^6|^7|^8|^9",
"phpunit/php-code-coverage": "*", "phpunit/php-code-coverage": "*",
"slowprog/composer-copy-file": "~0.3", "slowprog/composer-copy-file": "~0.3",
"squizlabs/php_codesniffer": "^3.12", "squizlabs/php_codesniffer": "^3.9",
"phpcompatibility/phpcompatibility-wp": "^2.1", "phpcompatibility/phpcompatibility-wp": "^2.1",
"wp-coding-standards/wpcs": "^3.1" "wp-coding-standards/wpcs": "^3.0"
}, },
"scripts": { "scripts": {
"test-all": [ "test-all": [

View File

@ -8,7 +8,7 @@
* @since 1.7.0 * @since 1.7.0
*/ */
// Quit if accessed directly. // Quit if accessed directly..
defined( 'ABSPATH' ) || exit; defined( 'ABSPATH' ) || exit;
/** /**
@ -170,27 +170,6 @@ class StatifyBlacklist_Settings extends StatifyBlacklist {
?> ?>
<div class="wrap"> <div class="wrap">
<h1><?php esc_html_e( 'Statify Filter', 'statify-blacklist' ); ?></h1> <h1><?php esc_html_e( 'Statify Filter', 'statify-blacklist' ); ?></h1>
<?php
if ( isset( $_SERVER['REQUEST_METHOD'] ) && 'POST' === $_SERVER['REQUEST_METHOD'] && ! empty( $_POST['cleanup'] ) ) {
// Database cleanup requested.
if ( isset( $_REQUEST['_wpnonce'] ) && wp_verify_nonce( sanitize_key( $_REQUEST['_wpnonce'] ), 'statify-blacklist-options' ) ) {
// Nonce verification successful, proceed with cleanup.
StatifyBlacklist_Admin::cleanup_database();
?>
<div class="notice notice-success is-dismissible">
<p><?php esc_html_e( 'Database cleanup successful', 'statify-blacklist' ); ?></p>
</div>
<?php
} else {
// Nonce verification failed.
?>
<div class="notice notice-error is-dismissible">
<p><?php esc_html_e( 'Database cleanup request failed', 'statify-blacklist' ); ?></p>
</div>
<?php
}
}
?>
<form id="statify-settings" method="post" action="options.php"> <form id="statify-settings" method="post" action="options.php">
<?php <?php
@ -199,8 +178,7 @@ class StatifyBlacklist_Settings extends StatifyBlacklist {
submit_button(); submit_button();
?> ?>
<hr> <hr>
<input class="button-secondary" type="submit" name="cleanup" <input class="button-secondary" type="submit" name="cleanUp"
formaction=""
value="<?php esc_html_e( 'CleanUp Database', 'statify-blacklist' ); ?>" value="<?php esc_html_e( 'CleanUp Database', 'statify-blacklist' ); ?>"
onclick="return confirm('<?php echo esc_js( __( 'Do you really want to apply filters to database? This cannot be undone.', 'statify-blacklist' ) ); ?>');"> onclick="return confirm('<?php echo esc_js( __( 'Do you really want to apply filters to database? This cannot be undone.', 'statify-blacklist' ) ); ?>');">
<p class="description"> <p class="description">
@ -230,7 +208,7 @@ class StatifyBlacklist_Settings extends StatifyBlacklist {
<fieldset> <fieldset>
<legend class="screen-reader-text"><?php esc_html_e( 'Activate live filter', 'statify-blacklist' ); ?></legend> <legend class="screen-reader-text"><?php esc_html_e( 'Activate live filter', 'statify-blacklist' ); ?></legend>
<label for="statifyblacklist-referer-active"> <label for="statifyblacklist-referer-active">
<input id="statifyblacklist-referer-active" name="statify-blacklist[referer][active]" type="checkbox" value="1" <?php checked( StatifyBlacklist::$options['referer']['active'], 1 ); ?>> <input id="statifyblacklist-referer-active" name="statify-blacklist[referer][active]" type="checkbox" value="1" <?php checked( StatifyBlacklist::$options['referer']['active'], 1 ); ?>">
<?php esc_html_e( 'Activate', 'statify-blacklist' ); ?> <?php esc_html_e( 'Activate', 'statify-blacklist' ); ?>
</label> </label>
<p class="description"> <p class="description">
@ -250,7 +228,7 @@ class StatifyBlacklist_Settings extends StatifyBlacklist {
<fieldset> <fieldset>
<legend class="screen-reader-text"><?php esc_html_e( 'CronJob execution', 'statify-blacklist' ); ?></legend> <legend class="screen-reader-text"><?php esc_html_e( 'CronJob execution', 'statify-blacklist' ); ?></legend>
<label for="statifyblacklist-referer-cron"> <label for="statifyblacklist-referer-cron">
<input id="statifyblacklist-referer-cron" name="statify-blacklist[referer][cron]" type="checkbox" value="1" <?php checked( StatifyBlacklist::$options['referer']['cron'], 1 ); ?>> <input id="statifyblacklist-referer-cron" name="statify-blacklist[referer][cron]" type="checkbox" value="1" <?php checked( StatifyBlacklist::$options['referer']['cron'], 1 ); ?>">
<?php esc_html_e( 'Activate', 'statify-blacklist' ); ?> <?php esc_html_e( 'Activate', 'statify-blacklist' ); ?>
</label> </label>
<p class="description"> <p class="description">
@ -317,7 +295,7 @@ class StatifyBlacklist_Settings extends StatifyBlacklist {
<fieldset> <fieldset>
<legend class="screen-reader-text"><?php esc_html_e( 'Activate live filter', 'statify-blacklist' ); ?></legend> <legend class="screen-reader-text"><?php esc_html_e( 'Activate live filter', 'statify-blacklist' ); ?></legend>
<label for="statifyblacklist-target-active"> <label for="statifyblacklist-target-active">
<input id="statifyblacklist-target-active" name="statify-blacklist[target][active]" type="checkbox" value="1" <?php checked( StatifyBlacklist::$options['target']['active'], 1 ); ?>> <input id="statifyblacklist-target-active" name="statify-blacklist[target][active]" type="checkbox" value="1" <?php checked( StatifyBlacklist::$options['target']['active'], 1 ); ?>">
<?php esc_html_e( 'Activate', 'statify-blacklist' ); ?> <?php esc_html_e( 'Activate', 'statify-blacklist' ); ?>
</label> </label>
<p class="description"> <p class="description">
@ -337,7 +315,7 @@ class StatifyBlacklist_Settings extends StatifyBlacklist {
<fieldset> <fieldset>
<legend class="screen-reader-text"><?php esc_html_e( 'CronJob execution', 'statify-blacklist' ); ?></legend> <legend class="screen-reader-text"><?php esc_html_e( 'CronJob execution', 'statify-blacklist' ); ?></legend>
<label for="statifyblacklist-target-cron"> <label for="statifyblacklist-target-cron">
<input id="statifyblacklist-target-cron" name="statify-blacklist[target][cron]" type="checkbox" value="1" <?php checked( StatifyBlacklist::$options['target']['cron'], 1 ); ?>> <input id="statifyblacklist-target-cron" name="statify-blacklist[target][cron]" type="checkbox" value="1" <?php checked( StatifyBlacklist::$options['target']['cron'], 1 ); ?>">
<?php esc_html_e( 'Activate', 'statify-blacklist' ); ?> <?php esc_html_e( 'Activate', 'statify-blacklist' ); ?>
</label> </label>
<p class="description"> <p class="description">
@ -399,7 +377,7 @@ class StatifyBlacklist_Settings extends StatifyBlacklist {
<fieldset> <fieldset>
<legend class="screen-reader-text"><?php esc_html_e( 'Activate live filter', 'statify-blacklist' ); ?></legend> <legend class="screen-reader-text"><?php esc_html_e( 'Activate live filter', 'statify-blacklist' ); ?></legend>
<label for="statifyblacklist-ip-active"> <label for="statifyblacklist-ip-active">
<input id="statifyblacklist-ip-active" name="statify-blacklist[ip][active]" type="checkbox" value="1" <?php checked( StatifyBlacklist::$options['ip']['active'], 1 ); ?>> <input id="statifyblacklist-ip-active" name="statify-blacklist[ip][active]" type="checkbox" value="1" <?php checked( StatifyBlacklist::$options['ip']['active'], 1 ); ?>">
<?php esc_html_e( 'Activate', 'statify-blacklist' ); ?> <?php esc_html_e( 'Activate', 'statify-blacklist' ); ?>
</label> </label>
<p class="description"> <p class="description">
@ -436,7 +414,7 @@ class StatifyBlacklist_Settings extends StatifyBlacklist {
public static function option_ua_active() { public static function option_ua_active() {
?> ?>
<label for="statifyblacklist-ua-active"> <label for="statifyblacklist-ua-active">
<input id="statifyblacklist-ua-active" name="statify-blacklist[ua][active]" type="checkbox" value="1" <?php checked( StatifyBlacklist::$options['ua']['active'], 1 ); ?>> <input id="statifyblacklist-ua-active" name="statify-blacklist[ua][active]" type="checkbox" value="1" <?php checked( StatifyBlacklist::$options['ua']['active'], 1 ); ?>">
<?php esc_html_e( 'Activate', 'statify-blacklist' ); ?> <?php esc_html_e( 'Activate', 'statify-blacklist' ); ?>
</label> </label>
@ -597,13 +575,14 @@ class StatifyBlacklist_Settings extends StatifyBlacklist {
* @since 1.7.0 * @since 1.7.0
*/ */
private static function sanitize_target_options( &$options ) { private static function sanitize_target_options( &$options ) {
$target_given = $options['blacklist']; $target_given = $options['blacklist'];
$target_sanitized = $target_given; $target_invalid = array();
if ( StatifyBlacklist::MODE_REGEX === $options['regexp'] || StatifyBlacklist::MODE_REGEX_CI === $options['regexp'] ) { if ( StatifyBlacklist::MODE_REGEX === $options['regexp'] || StatifyBlacklist::MODE_REGEX_CI === $options['regexp'] ) {
$target_sanitized = $target_given;
// Check regular expressions. // Check regular expressions.
$target_invalid = self::sanitize_regex( $target_given ); $target_invalid = self::sanitize_regex( $target_given );
} else { } else {
$target_invalid = array(); $target_sanitized = $target_given;
} }
$options['blacklist'] = $target_sanitized; $options['blacklist'] = $target_sanitized;

View File

@ -89,6 +89,9 @@ class StatifyBlacklist_System extends StatifyBlacklist {
if ( function_exists( 'get_sites' ) ) { if ( function_exists( 'get_sites' ) ) {
$sites = get_sites(); $sites = get_sites();
} elseif ( function_exists( 'wp_get_sites' ) ) {
// phpcs:ignore WordPress.WP.DeprecatedFunctions.wp_get_sitesFound -- Legacy support for WP < 4.6.
$sites = wp_get_sites();
} else { } else {
return; return;
} }
@ -186,7 +189,7 @@ class StatifyBlacklist_System extends StatifyBlacklist {
); );
} elseif ( ! isset( $options['ua']['blacklist'] ) ) { } elseif ( ! isset( $options['ua']['blacklist'] ) ) {
$options['ua']['blacklist'] = array(); $options['ua']['blacklist'] = array();
} else { } elseif ( isset( $options['ua'] ) ) {
// User agent strings got stored incorrectly in 1.6.0 - luckily the version was not updated, either. // User agent strings got stored incorrectly in 1.6.0 - luckily the version was not updated, either.
$options['ua']['blacklist'] = array_flip( $options['ua']['blacklist'] ); $options['ua']['blacklist'] = array_flip( $options['ua']['blacklist'] );
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "statify-blacklist", "name": "statify-blacklist",
"version": "1.7.2", "version": "1.7.0",
"description": "A filter extension for the famous Statify WordPress plugin", "description": "A filter extension for the famous Statify WordPress plugin",
"author": "Stefan Kalscheuer", "author": "Stefan Kalscheuer",
"license": "GPL-2.0+" "license": "GPL-2.0+"

View File

@ -7,17 +7,14 @@
* @license GPL-2.0+ * @license GPL-2.0+
* *
* @wordpress-plugin * @wordpress-plugin
* Plugin Name: Statify Filter * Plugin Name: Statify Filter
* Plugin URI: https://wordpress.org/plugins/statify-blacklist/ * Plugin URI: https://wordpress.org/plugins/statify-blacklist/
* Description: Extension for the Statify plugin to add customizable filters. (formerly "Statify Blacklist") * Description: Extension for the Statify plugin to add customizable filters. (formerly "Statify Blacklist)
* Version: 1.7.2 * Version: 1.7.0
* Requires at least: 4.7 * Author: Stefan Kalscheuer (@stklcode)
* Requires PHP: 5.5 * Author URI: https://www.stklcode.de
* Requires Plugins: statify * Text Domain: statify-blacklist
* Author: Stefan Kalscheuer (@stklcode) * License: GPLv2 or later
* Author URI: https://www.stklcode.de
* Text Domain: statify-blacklist
* License: GPLv2 or later
* *
* Statify Filter is free software: you can redistribute it and/or modify * Statify Filter is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by