diff --git a/.distignore b/.distignore index 022e7a7..10440b1 100644 --- a/.distignore +++ b/.distignore @@ -15,4 +15,5 @@ /package.json /package-lock.json /phpcs.xml +/phpstan.neon /phpunit.xml diff --git a/.gitattributes b/.gitattributes index d0f8b5b..ad1e8ff 100644 --- a/.gitattributes +++ b/.gitattributes @@ -11,4 +11,5 @@ composer.lock export-ignore CONTRIBUTING.md export-ignore package.json export-ignore phpcs.xml export-ignore +phpstan.neon export-ignore phpunit.xml export-ignore diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 949a72c..55b43bc 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -5,10 +5,10 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php: [ '5.6', '7.4', '8.0', '8.2', '8.4' ] + php: [ '7.4', '8.0', '8.2', '8.4', '8.5' ] steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: fetch-depth: 0 - name: Setup PHP @@ -25,7 +25,7 @@ jobs: sed -i "s# README.md.tmp && mv README.md.tmp README.md - name: WordPress.org plugin asset/readme update diff --git a/.github/workflows/wordpress-plugin-check.yml b/.github/workflows/wordpress-plugin-check.yml index a5596c0..aa9f8dd 100644 --- a/.github/workflows/wordpress-plugin-check.yml +++ b/.github/workflows/wordpress-plugin-check.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Package plugin run: | diff --git a/.github/workflows/wordpress-plugin-deploy.yml b/.github/workflows/wordpress-plugin-deploy.yml index b8395bc..a95eb20 100644 --- a/.github/workflows/wordpress-plugin-deploy.yml +++ b/.github/workflows/wordpress-plugin-deploy.yml @@ -9,7 +9,7 @@ jobs: name: New tag runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Clean README.md run: tail -n +6 README.md > README.md.tmp && mv README.md.tmp README.md - name: WordPress Plugin Deploy diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8e24a86..56017dd 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -110,7 +110,7 @@ The coverage is not yet perfect, but be invited to write tests for methods not y This project, as part of the WordPress ecosystem adheres to the [WordPress Coding Standards](https://codex.wordpress.org/WordPress_Coding_Standards). Please make sure that you are at least roughly familiar with those guidelines. -The code style is automatically checked for commits (including pull requests) using [PHP CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer). +The code style is automatically checked for commits (including pull requests) using [PHP CodeSniffer](https://github.com/PHPCSStandards/PHP_CodeSniffer). You can check your code against the configured ruleset yourself by running `./vendor/bin/phpcs --standard=phpcs.xml your-edited-file.php` (assuming `composer install` has been executed) or the Robo task `robo test:cs` for a complete scan. diff --git a/README.md b/README.md index 5e9773b..67856c6 100644 --- a/README.md +++ b/README.md @@ -5,10 +5,10 @@ # Statify Filter # * Contributors: stklcode -* Requires at least: 4.7 -* Tested up to: 6.8 -* Requires PHP: 5.5 -* Stable tag: 1.7.2 +* Requires at least: 5.1 +* Tested up to: 7.0 +* Requires PHP: 7.4 +* Stable tag: 1.8.0 * License: GPLv2 or later * License URI: https://www.gnu.org/licenses/gpl-2.0.html @@ -55,8 +55,8 @@ The plugin is capable of handling multisite installations. * Goto _Settings_ -> _Statify Filter_ to configure the plugin ### Requirements ### -* PHP 5.5 or above -* WordPress 4.7 or above +* PHP 7.4 or above +* WordPress 5.1 or above * _Statify_ plugin installed and activated (1.5 or above) ## Frequently Asked Questions ## @@ -92,9 +92,13 @@ Same for IPv6 prefixes like _2001:db8:a0b:12f0::/64_. ## Screenshots ## 1. Statify Filter settings page +2. Statify Filter settings page (continued) ## Upgrade Notice ## +### 1.8.0 ### +This release maintenance update that raises the minimum requirements to WordPress 5.1 and PHP 7.4. + ### 1.7.2 ### This is a bugfix release to restore the manual cleanup function that was broken since 1.7.0. @@ -107,6 +111,12 @@ This is a service release with primarily internal rework. Tested up to 6.4 and P ## Changelog +### 1.8.0 / 24.05.2026 ### +* Minimum required WordPress version is 5.1 +* Minimum required PHP version is 7.4 +* Declared compatibility with WordPress 7.0 +* Various internal code improvements + ### 1.7.2 / 06.06.2024 ### * Restore manual database cleanup functionality diff --git a/assets/screenshot-1.png b/assets/screenshot-1.png index b03eb2c..e13ea05 100644 Binary files a/assets/screenshot-1.png and b/assets/screenshot-1.png differ diff --git a/assets/screenshot-2.png b/assets/screenshot-2.png new file mode 100644 index 0000000..0a41f71 Binary files /dev/null and b/assets/screenshot-2.png differ diff --git a/composer.json b/composer.json index 065a00c..4432586 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "stklcode/statify-blacklist", - "version": "1.7.2", + "version": "1.8.0", "description": "A filter extension for the famous Statify WordPress plugin", "keywords": [ "wordpress", @@ -18,17 +18,19 @@ ], "type": "wordpress-plugin", "require": { - "php": ">=5.5", - "composer/installers": "~v1.12|~v2.3" + "php": ">=7.4", + "composer/installers": "~v2.3" }, "require-dev": { - "dealerdirect/phpcodesniffer-composer-installer": "^v1.0", - "phpunit/phpunit": "^5|^6|^7|^8|^9", - "phpunit/php-code-coverage": "*", + "dealerdirect/phpcodesniffer-composer-installer": "^v1.2", + "phpunit/phpunit": "^8|^9", "slowprog/composer-copy-file": "~0.3", - "squizlabs/php_codesniffer": "^3.12", + "squizlabs/php_codesniffer": "^3.13", + "szepeviktor/phpstan-wordpress": "^v2.0", + "phpstan/extension-installer": "^1.4", + "phpstan/phpstan": "^2.1", "phpcompatibility/phpcompatibility-wp": "^2.1", - "wp-coding-standards/wpcs": "^3.1" + "wp-coding-standards/wpcs": "^3.3" }, "scripts": { "test-all": [ @@ -43,12 +45,16 @@ ], "fix-cs": [ "phpcbf --standard=phpcs.xml" + ], + "phpstan": [ + "phpstan analyse --memory-limit=1G" ] }, "config": { "allow-plugins": { "composer/installers": true, - "dealerdirect/phpcodesniffer-composer-installer": true + "dealerdirect/phpcodesniffer-composer-installer": true, + "phpstan/extension-installer": true } } } diff --git a/inc/class-statifyblacklist-admin.php b/inc/class-statifyblacklist-admin.php index 023321b..7ceb4f6 100644 --- a/inc/class-statifyblacklist-admin.php +++ b/inc/class-statifyblacklist-admin.php @@ -26,7 +26,7 @@ class StatifyBlacklist_Admin extends StatifyBlacklist { * * @since 1.5.0 */ - public static function init() { + public static function init(): void { // Add actions. add_action( 'wpmu_new_blog', array( 'StatifyBlacklist_System', 'install_site' ) ); add_action( 'delete_blog', array( 'StatifyBlacklist_System', 'uninstall_site' ) ); @@ -36,10 +36,7 @@ public static function init() { add_action( 'network_admin_menu', array( 'StatifyBlacklist_Admin', 'add_menu_page' ) ); add_filter( 'network_admin_plugin_action_links', - array( - 'StatifyBlacklist_Admin', - 'plugin_actions_links', - ), + array( 'StatifyBlacklist_Admin', 'plugin_actions_links' ), 10, 2 ); @@ -55,7 +52,7 @@ public static function init() { * * @since 1.0.0 */ - public static function add_menu_page() { + public static function add_menu_page(): void { $title = __( 'Statify Filter', 'statify-blacklist' ); if ( self::$multisite ) { add_options_page( @@ -79,14 +76,14 @@ public static function add_menu_page() { /** * Add plugin meta links * - * @param array $links Registered links. - * @param string $file The filename. + * @param string[] $links Registered links. + * @param string $file The filename. * - * @return array Merged links. + * @return string[] Merged links. * * @since 1.0.0 */ - public static function plugin_meta_link( $links, $file ) { + public static function plugin_meta_link( array $links, string $file ): array { if ( STATIFYBLACKLIST_BASE === $file ) { $links[] = 'GitHub'; } @@ -97,14 +94,14 @@ public static function plugin_meta_link( $links, $file ) { /** * Add plugin action links. * - * @param array $links Registered links. - * @param string $file The filename. + * @param string[] $links Registered links. + * @param string $file The filename. * - * @return array Merged links. + * @return string[] Merged links. * * @since 1.0.0 */ - public static function plugin_actions_links( $links, $file ) { + public static function plugin_actions_links( array $links, string $file ): array { $base = self::$multisite ? network_admin_url( 'settings.php' ) : admin_url( 'options-general.php' ); if ( STATIFYBLACKLIST_BASE === $file && current_user_can( 'manage_options' ) ) { @@ -124,13 +121,13 @@ public static function plugin_actions_links( $links, $file ) { * * @global wpdb $wpdb WordPress database. */ - public static function cleanup_database() { + public static function cleanup_database(): void { // Check user permissions. - if ( ! current_user_can( 'manage_options' ) && ! ( defined( 'DOING_CRON' ) && DOING_CRON ) ) { + if ( ! current_user_can( 'manage_options' ) && ! wp_doing_cron() ) { die( esc_html__( 'Are you sure you want to do this?', 'statify-blacklist' ) ); } - if ( defined( 'DOING_CRON' ) && DOING_CRON ) { + if ( wp_doing_cron() ) { $clean_ref = ( 1 === self::$options['referer']['cron'] ); $clean_trg = ( 1 === self::$options['target']['cron'] ); } else { @@ -200,13 +197,13 @@ public static function cleanup_database() { /** * Sanitize URLs and remove empty results. * - * @param array $urls given array of URLs. + * @param string[] $urls given array of URLs. * - * @return array sanitized array. + * @return string[] sanitized array. * * @since 1.1.1 */ - private static function sanitize_urls( $urls ) { + private static function sanitize_urls( array $urls ): array { return array_flip( array_filter( array_map( diff --git a/inc/class-statifyblacklist-settings.php b/inc/class-statifyblacklist-settings.php index 3944816..a33fc66 100644 --- a/inc/class-statifyblacklist-settings.php +++ b/inc/class-statifyblacklist-settings.php @@ -20,7 +20,7 @@ class StatifyBlacklist_Settings extends StatifyBlacklist { * * @return void */ - public static function register_settings() { + public static function register_settings(): void { register_setting( 'statify-blacklist', 'statify-blacklist', @@ -34,7 +34,7 @@ public static function register_settings() { add_settings_section( 'statifyblacklist-referer', __( 'Referer filter', 'statify-blacklist' ), - null, + array( __CLASS__, 'section_referer' ), 'statify-blacklist' ); add_settings_field( @@ -72,7 +72,7 @@ public static function register_settings() { add_settings_section( 'statifyblacklist-target', __( 'Target filter', 'statify-blacklist' ), - null, + array( __CLASS__, 'section_target' ), 'statify-blacklist' ); add_settings_field( @@ -110,7 +110,7 @@ public static function register_settings() { add_settings_section( 'statifyblacklist-ip', __( 'IP filter', 'statify-blacklist' ), - null, + array( __CLASS__, 'section_ip' ), 'statify-blacklist' ); add_settings_field( @@ -133,7 +133,7 @@ public static function register_settings() { add_settings_section( 'statifyblacklist-ua', __( 'User agent filter', 'statify-blacklist' ), - null, + array( __CLASS__, 'section_ua' ), 'statify-blacklist' ); add_settings_field( @@ -166,7 +166,7 @@ public static function register_settings() { * * @return void */ - public static function create_settings_page() { + public static function create_settings_page(): void { ?>

@@ -220,12 +220,23 @@ public static function create_settings_page() { * phpcs:disable Squiz.PHP.EmbeddedPhp.ContentAfterEnd */ + /** + * Options section for referer filters. + * + * @return void + */ + public static function section_referer(): void { + print '

'; + esc_html_e( 'These filter rules are applied to the origin URL of the request.', 'statify-blacklist' ); + print '

'; + } + /** * Option for activating the live referer filter. * * @return void */ - public static function option_referer_active() { + public static function option_referer_active(): void { ?>
@@ -245,7 +256,7 @@ public static function option_referer_active() { * * @return void */ - public static function option_referer_cron() { + public static function option_referer_cron(): void { ?>
@@ -265,7 +276,7 @@ public static function option_referer_cron() { * * @return void */ - public static function option_referer_regexp() { + public static function option_referer_regexp(): void { ?>