Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update minimum supported PHP version to 7.2 #36

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php: [ '5.6', '7.4', '8.0', '8.1', '8.2', '8.3' ]
php: [ '7.4', '8.0', '8.1', '8.2', '8.3' ]
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* Contributors: stklcode
* Requires at least: 4.7
* Tested up to: 6.5
* Requires PHP: 5.5
* Requires PHP: 7.2
* Stable tag: 1.7.1
* License: GPLv2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@
],
"type": "wordpress-plugin",
"require": {
"php": ">=5.5",
"composer/installers": "~v1.12|~v2.2"
"php": ">=7.2",
"composer/installers": "~v2.2"
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^v1.0",
"phpunit/phpunit": "^5|^6|^7|^8|^9",
"phpunit/phpunit": "^8|^9",
"phpunit/php-code-coverage": "*",
"slowprog/composer-copy-file": "~0.3",
"squizlabs/php_codesniffer": "^3.9",
"phpcompatibility/phpcompatibility-wp": "^2.1",
"wp-coding-standards/wpcs": "^3.0"
"wp-coding-standards/wpcs": "^3.1"
},
"scripts": {
"test-all": [
Expand Down
12 changes: 6 additions & 6 deletions inc/class-statifyblacklist-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ) );
Expand Down Expand Up @@ -55,7 +55,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(
Expand Down Expand Up @@ -86,7 +86,7 @@ public static function add_menu_page() {
*
* @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[] = '<a href="https://github.com/stklcode/statify-blacklist">GitHub</a>';
}
Expand All @@ -104,7 +104,7 @@ public static function plugin_meta_link( $links, $file ) {
*
* @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' ) ) {
Expand All @@ -124,7 +124,7 @@ 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 ) ) {
die( esc_html__( 'Are you sure you want to do this?', 'statify-blacklist' ) );
Expand Down Expand Up @@ -206,7 +206,7 @@ public static function cleanup_database() {
*
* @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(
Expand Down
46 changes: 23 additions & 23 deletions inc/class-statifyblacklist-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -166,7 +166,7 @@ public static function register_settings() {
*
* @return void
*/
public static function create_settings_page() {
public static function create_settings_page(): void {
?>
<div class="wrap">
<h1><?php esc_html_e( 'Statify Filter', 'statify-blacklist' ); ?></h1>
Expand Down Expand Up @@ -203,7 +203,7 @@ public static function create_settings_page() {
*
* @return void
*/
public static function option_referer_active() {
public static function option_referer_active(): void {
?>
<fieldset>
<legend class="screen-reader-text"><?php esc_html_e( 'Activate live filter', 'statify-blacklist' ); ?></legend>
Expand All @@ -223,7 +223,7 @@ public static function option_referer_active() {
*
* @return void
*/
public static function option_referer_cron() {
public static function option_referer_cron(): void {
?>
<fieldset>
<legend class="screen-reader-text"><?php esc_html_e( 'CronJob execution', 'statify-blacklist' ); ?></legend>
Expand All @@ -243,7 +243,7 @@ public static function option_referer_cron() {
*
* @return void
*/
public static function option_referer_regexp() {
public static function option_referer_regexp(): void {
?>
<select id="statifyblacklist-referer-regexp" name="statify-blacklist[referer][regexp]">
<option value="<?php print esc_attr( StatifyBlacklist::MODE_NORMAL ); ?>" <?php selected( StatifyBlacklist::$options['referer']['regexp'], StatifyBlacklist::MODE_NORMAL ); ?>>
Expand Down Expand Up @@ -274,7 +274,7 @@ public static function option_referer_regexp() {
*
* @return void
*/
public static function option_referer_blacklist() {
public static function option_referer_blacklist(): void {
?>
<textarea id="statifyblacklist-referer-blacklist" name="statify-blacklist[referer][blacklist]" cols="40" rows="5"><?php
print esc_html( implode( "\r\n", array_keys( StatifyBlacklist::$options['referer']['blacklist'] ) ) );
Expand All @@ -290,7 +290,7 @@ public static function option_referer_blacklist() {
*
* @return void
*/
public static function option_target_active() {
public static function option_target_active(): void {
?>
<fieldset>
<legend class="screen-reader-text"><?php esc_html_e( 'Activate live filter', 'statify-blacklist' ); ?></legend>
Expand All @@ -310,7 +310,7 @@ public static function option_target_active() {
*
* @return void
*/
public static function option_target_cron() {
public static function option_target_cron(): void {
?>
<fieldset>
<legend class="screen-reader-text"><?php esc_html_e( 'CronJob execution', 'statify-blacklist' ); ?></legend>
Expand All @@ -330,7 +330,7 @@ public static function option_target_cron() {
*
* @return void
*/
public static function option_target_regexp() {
public static function option_target_regexp(): void {
?>
<select id="statifyblacklist-target-regexp" name="statify-blacklist[target][regexp]">
<option value="<?php print esc_attr( StatifyBlacklist::MODE_NORMAL ); ?>" <?php selected( StatifyBlacklist::$options['target']['regexp'], StatifyBlacklist::MODE_NORMAL ); ?>>
Expand All @@ -356,7 +356,7 @@ public static function option_target_regexp() {
*
* @return void
*/
public static function option_target_blacklist() {
public static function option_target_blacklist(): void {
?>
<textarea id="statifyblacklist-target-blacklist" name="statify-blacklist[target][blacklist]" cols="40" rows="5"><?php
print esc_html( implode( "\r\n", array_keys( StatifyBlacklist::$options['target']['blacklist'] ) ) );
Expand All @@ -372,7 +372,7 @@ public static function option_target_blacklist() {
*
* @return void
*/
public static function option_ip_active() {
public static function option_ip_active(): void {
?>
<fieldset>
<legend class="screen-reader-text"><?php esc_html_e( 'Activate live filter', 'statify-blacklist' ); ?></legend>
Expand All @@ -394,7 +394,7 @@ public static function option_ip_active() {
*
* @return void
*/
public static function option_ip_blacklist() {
public static function option_ip_blacklist(): void {
?>
<textarea id="statifyblacklist-ip-blacklist" name="statify-blacklist[ip][blacklist]" cols="40" rows="5"><?php
print esc_html( implode( "\r\n", StatifyBlacklist::$options['ip']['blacklist'] ) );
Expand All @@ -411,7 +411,7 @@ public static function option_ip_blacklist() {
*
* @return void
*/
public static function option_ua_active() {
public static function option_ua_active(): void {
?>
<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 ); ?>>
Expand All @@ -431,7 +431,7 @@ public static function option_ua_active() {
*
* @return void
*/
public static function option_ua_regexp() {
public static function option_ua_regexp(): void {
?>
<select id="statifyblacklist-ua-regexp" name="statify-blacklist[ua][regexp]">
<option value="<?php print esc_attr( StatifyBlacklist::MODE_NORMAL ); ?>" <?php selected( StatifyBlacklist::$options['ua']['regexp'], StatifyBlacklist::MODE_NORMAL ); ?>>
Expand Down Expand Up @@ -462,7 +462,7 @@ public static function option_ua_regexp() {
*
* @return void
*/
public static function option_ua_blacklist() {
public static function option_ua_blacklist(): void {
?>
<textarea name="statify-blacklist[ua][blacklist]" id="statifyblacklist-ua-blacklist" cols="40" rows="5"><?php
print esc_html( implode( "\r\n", StatifyBlacklist::$options['ua']['blacklist'] ) );
Expand All @@ -481,7 +481,7 @@ public static function option_ua_blacklist() {
*
* @return array Validated and sanitized options.
*/
public static function sanitize_options( $options ) {
public static function sanitize_options( array $options ): array {
// Extract filter lists from multi-line inputs.
$referer = self::parse_multiline_option( $options['referer']['blacklist'] );
$target = self::parse_multiline_option( $options['target']['blacklist'] );
Expand Down Expand Up @@ -531,7 +531,7 @@ public static function sanitize_options( $options ) {
*
* @since 1.7.0
*/
private static function sanitize_referer_options( &$options ) {
private static function sanitize_referer_options( array &$options ): void {
$referer_given = $options['blacklist'];
$referer_invalid = array();
if ( StatifyBlacklist::MODE_NORMAL === $options['regexp'] ) {
Expand Down Expand Up @@ -574,7 +574,7 @@ private static function sanitize_referer_options( &$options ) {
*
* @since 1.7.0
*/
private static function sanitize_target_options( &$options ) {
private static function sanitize_target_options( array &$options ): void {
$target_given = $options['blacklist'];
$target_sanitized = $target_given;
if ( StatifyBlacklist::MODE_REGEX === $options['regexp'] || StatifyBlacklist::MODE_REGEX_CI === $options['regexp'] ) {
Expand Down Expand Up @@ -604,7 +604,7 @@ private static function sanitize_target_options( &$options ) {
*
* @since 1.7.0
*/
private static function sanitize_ip_options( &$options ) {
private static function sanitize_ip_options( array &$options ): void {
$given_ip = $options['blacklist'];
$sanitized_ip = self::sanitize_ips( $given_ip );
$ip_diff = array_diff( $given_ip, $sanitized_ip );
Expand Down Expand Up @@ -632,7 +632,7 @@ private static function sanitize_ip_options( &$options ) {
* @since 1.1.1
* @since 1.7.0 moved from StatifyBlacklist_Admin to StatifyBlacklist_Settings.
*/
private static function sanitize_urls( $urls ) {
private static function sanitize_urls( array $urls ): array {
return array_flip(
array_filter(
array_map(
Expand All @@ -655,7 +655,7 @@ function ( $r ) {
* @since 1.4.0
* @since 1.7.0 moved from StatifyBlacklist_Admin to StatifyBlacklist_Settings.
*/
private static function sanitize_ips( $ips ) {
private static function sanitize_ips( array $ips ): array {
return array_values(
array_unique(
array_filter(
Expand Down Expand Up @@ -691,7 +691,7 @@ function ( $ip ) {
* @since 1.5.0 #13
* @since 1.7.0 moved from StatifyBlacklist_Admin to StatifyBlacklist_Settings.
*/
private static function sanitize_regex( $expressions ) {
private static function sanitize_regex( array $expressions ): array {
return array_filter(
array_flip( $expressions ),
function ( $re ) {
Expand All @@ -710,7 +710,7 @@ function ( $re ) {
*
* @return array Parsed options.
*/
private static function parse_multiline_option( $raw ) {
private static function parse_multiline_option( string $raw ): array {
if ( empty( trim( $raw ) ) ) {
return array();
} else {
Expand Down
14 changes: 7 additions & 7 deletions inc/class-statifyblacklist-system.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class StatifyBlacklist_System extends StatifyBlacklist {
*
* @return void
*/
public static function install( $network_wide = false ) {
public static function install( bool $network_wide = false ): void {
// Create tables for each site in a network.
if ( $network_wide && is_multisite() ) {
if ( function_exists( 'get_sites' ) ) {
Expand Down Expand Up @@ -66,8 +66,8 @@ public static function install( $network_wide = false ) {
*
* @return void
*/
public static function install_site( $site_id ) {
switch_to_blog( (int) $site_id );
public static function install_site( int $site_id ): void {
switch_to_blog( $site_id );
add_option(
'statify-blacklist',
self::default_options()
Expand All @@ -83,7 +83,7 @@ public static function install_site( $site_id ) {
*
* @return void
*/
public static function uninstall() {
public static function uninstall(): void {
if ( is_multisite() ) {
$old = get_current_blog_id();

Expand Down Expand Up @@ -117,9 +117,9 @@ public static function uninstall() {
*
* @return void
*/
public static function uninstall_site( $site_id ) {
public static function uninstall_site( int $site_id ): void {
$old = get_current_blog_id();
switch_to_blog( (int) $site_id );
switch_to_blog( $site_id );
delete_option( 'statify-blacklist' );
switch_to_blog( $old );
}
Expand All @@ -131,7 +131,7 @@ public static function uninstall_site( $site_id ) {
*
* @return void
*/
public static function upgrade() {
public static function upgrade(): void {
self::update_options();
// Check if config array is not associative (pre 1.2.0).
if ( array_keys( self::$options['referer'] ) === range( 0, count( self::$options['referer'] ) - 1 ) ) {
Expand Down
Loading