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

Updated packages. Bumped tested up to 6.6. #62

Merged
merged 6 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

### [3.0.1] - 2024-09-19

* Enhancement: Updated required packages
derpaschi marked this conversation as resolved.
Show resolved Hide resolved

### [3.0.0] - 2022-03-17

* Fixed: Replace use of jQuery to avoid deprecation warnings.
* Changed: Requires at least PHP 7.4 and WordPress 6.0.

Expand Down
74 changes: 36 additions & 38 deletions classes/class-wp-widget-disable.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class WP_Widget_Disable {
/**
* Adds hooks.
*/
public function add_hooks() {
public function add_hooks(): void {
add_action( 'init', [ $this, 'load_textdomain' ] );

// Add the options page and menu item.
Expand Down Expand Up @@ -85,7 +85,7 @@ public function add_hooks() {
*
* @return string The URL to the plugin directory.
*/
protected function get_url() {
protected function get_url(): string {
return plugin_dir_url( __DIR__ );
}

Expand All @@ -94,7 +94,7 @@ protected function get_url() {
*
* @return string The absolute path to the plugin directory.
*/
protected function get_path() {
protected function get_path(): string {
return plugin_dir_path( __DIR__ );
}

Expand All @@ -105,14 +105,14 @@ protected function get_path() {
*
* @return string The plugin basename.
*/
protected function get_basename() {
protected function get_basename(): string {
return plugin_basename( $this->get_path() . 'wp-widget-disable.php' );
}

/**
* Initializes the plugin, registers textdomain, etc.
*/
public function load_textdomain() {
public function load_textdomain(): void {
load_plugin_textdomain( 'wp-widget-disable' );
}

Expand All @@ -121,7 +121,7 @@ public function load_textdomain() {
*
* @since 1.0.0
*/
public function admin_menu() {
public function admin_menu(): void {
if ( is_network_admin() ) {
$this->page_hook = add_submenu_page(
'settings.php',
Expand Down Expand Up @@ -151,7 +151,7 @@ public function admin_menu() {
*
* @since 2.0.0
*/
public function settings_page_load_callback() {
public function settings_page_load_callback(): void {
$key = md5( $_SERVER['HTTP_USER_AGENT'] );
add_filter( 'pre_site_transient_browser_' . $key, '__return_null' );

Expand All @@ -166,7 +166,7 @@ public function settings_page_load_callback() {
*
* @since 1.6.0
*/
public function settings_page_callback() {
public function settings_page_callback(): void {
include trailingslashit( $this->get_path() ) . 'views/admin.php';
}

Expand All @@ -175,7 +175,7 @@ public function settings_page_callback() {
*
* @since 1.7.0
*/
public function settings_errors() {
public function settings_errors(): void {
settings_errors( 'wp-widget-disable' );
}

Expand All @@ -186,7 +186,7 @@ public function settings_errors() {
*
* @return bool True if settings errors exist, false if not.
*/
public function has_settings_errors() {
public function has_settings_errors(): bool {
return count( get_settings_errors( 'wp-widget-disable' ) ) > 0;
}

Expand All @@ -199,7 +199,7 @@ public function has_settings_errors() {
*
* @since 1.9.0
*/
public function save_network_options() {
public function save_network_options(): void {
$data = [];

// phpcs:disable WordPress.Security.NonceVerification
Expand Down Expand Up @@ -234,10 +234,10 @@ public function save_network_options() {
*
* @since 1.0.0
*
* @param array $links Plugin action links.
* @return array
* @param mixed[] $links Plugin action links.
* @return mixed[]
*/
public function plugin_action_links( array $links ) {
public function plugin_action_links( array $links ): array {
$settings_url = add_query_arg(
[ 'page' => 'wp-widget-disable' ],
admin_url( 'themes.php' )
Expand Down Expand Up @@ -265,7 +265,7 @@ public function plugin_action_links( array $links ) {
/**
* Set the default sidebar widgets.
*/
public function set_default_sidebar_widgets() {
public function set_default_sidebar_widgets(): void {
$widgets = [];

if ( ! empty( $GLOBALS['wp_widget_factory'] ) ) {
Expand All @@ -283,9 +283,9 @@ public function set_default_sidebar_widgets() {
/**
* Get the default dashboard widgets.
*
* @return array Sidebar widgets.
* @return mixed[] Sidebar widgets.
*/
protected function get_default_dashboard_widgets() {
protected function get_default_dashboard_widgets(): array {
global $wp_meta_boxes;

$screen = is_network_admin() ? 'dashboard-network' : 'dashboard';
Expand Down Expand Up @@ -337,7 +337,7 @@ protected function get_default_dashboard_widgets() {
*
* @since 1.0.0
*/
public function disable_sidebar_widgets() {
public function disable_sidebar_widgets(): void {
$widgets = (array) get_option( $this->sidebar_widgets_option, [] );
if ( ! empty( $widgets ) ) {
foreach ( array_keys( $widgets ) as $widget_class ) {
Expand All @@ -351,9 +351,9 @@ public function disable_sidebar_widgets() {
*
* @since 2.0.0
*
* @return array List of disabled widget IDs.
* @return mixed[] List of disabled widget IDs.
*/
protected function get_disabled_dashboard_widgets() {
protected function get_disabled_dashboard_widgets(): array {
$widgets = (array) get_option( $this->dashboard_widgets_option, [] );

if ( is_network_admin() ) {
Expand All @@ -371,7 +371,7 @@ protected function get_disabled_dashboard_widgets() {
*
* @since 2.0.0
*/
public function disable_dashboard_widgets_with_remote_requests() {
public function disable_dashboard_widgets_with_remote_requests(): void {
$widgets = $this->get_disabled_dashboard_widgets();

if ( ! $widgets ) {
Expand Down Expand Up @@ -403,7 +403,7 @@ public function disable_dashboard_widgets_with_remote_requests() {
*
* @since 1.0.0
*/
public function disable_dashboard_widgets() {
public function disable_dashboard_widgets(): void {
$widgets = $this->get_disabled_dashboard_widgets();

if ( ! $widgets ) {
Expand Down Expand Up @@ -438,10 +438,10 @@ public function disable_dashboard_widgets() {
*
* @since 1.0.0
*
* @param array $input Sidebar widgets to disable.
* @return array
* @param mixed[] $input Sidebar widgets to disable.
* @return mixed[]
*/
public function sanitize_sidebar_widgets( $input ) {
public function sanitize_sidebar_widgets( ?array $input ): array { // phpcs:ignore Squiz.Commenting.FunctionComment.IncorrectTypeHint -- mixed is not a valid type hint in PHP 7.4.
// If there are settings errors the input was already sanitized.
// See https://core.trac.wordpress.org/ticket/21989.
if ( $this->has_settings_errors() ) {
Expand Down Expand Up @@ -498,10 +498,10 @@ public function sanitize_sidebar_widgets( $input ) {
*
* @since 1.0.0
*
* @param array $input Dashboards widgets to disable.
* @return array
* @param mixed[] $input Dashboards widgets to disable.
* @return mixed[]
*/
public function sanitize_dashboard_widgets( $input ) {
public function sanitize_dashboard_widgets( ?array $input ): array { // phpcs:ignore Squiz.Commenting.FunctionComment.IncorrectTypeHint -- mixed is not a valid type hint in PHP 7.4.
// If there are settings errors the input was already sanitized.
// See https://core.trac.wordpress.org/ticket/21989.
if ( $this->has_settings_errors() ) {
Expand Down Expand Up @@ -558,7 +558,7 @@ public function sanitize_dashboard_widgets( $input ) {
*
* @since 1.0.0
*/
public function register_settings() {
public function register_settings(): void {
register_setting(
$this->sidebar_widgets_option,
$this->sidebar_widgets_option,
Expand All @@ -568,7 +568,7 @@ public function register_settings() {
add_settings_section(
'widget_disable_widget_section',
__( 'Disable Sidebar Widgets', 'wp-widget-disable' ),
function () {
function (): void {
echo '<p>';
_e( 'Choose the sidebar widgets you would like to disable. Note that developers can still display widgets using PHP.', 'wp-widget-disable' );
echo '</p>';
Expand All @@ -593,7 +593,7 @@ function () {
add_settings_section(
'widget_disable_dashboard_section',
__( 'Disable Dashboard Widgets', 'wp-widget-disable' ),
function () {
function (): void {
echo '<p>';
_e( 'Choose the dashboard widgets you would like to disable.', 'wp-widget-disable' );
echo '</p>';
Expand All @@ -615,7 +615,7 @@ function () {
*
* @since 1.0.0
*/
public function render_sidebar_checkboxes() {
public function render_sidebar_checkboxes(): void {
$widgets = $this->sidebar_widgets;

$widgets = wp_list_sort( $widgets, [ 'name' => 'ASC' ], null, true );
Expand Down Expand Up @@ -663,7 +663,7 @@ public function render_sidebar_checkboxes() {
*
* @since 1.0.0
*/
public function render_dashboard_checkboxes() {
public function render_dashboard_checkboxes(): void {
$widgets = $this->get_default_dashboard_widgets();

$flat_widgets = [];
Expand Down Expand Up @@ -796,10 +796,8 @@ public function render_dashboard_checkboxes() {

/**
* Check if block editor is enabled for widgets.
*
* @return bool
*/
public function use_widgets_block_editor() {
public function use_widgets_block_editor(): bool {
if ( function_exists( 'wp_use_widgets_block_editor' ) ) {
return wp_use_widgets_block_editor();
}
Expand All @@ -809,9 +807,9 @@ public function use_widgets_block_editor() {
/**
* Get list of widgets to hide from legacy widget block.
*
* @return array
* @return mixed[]
*/
public function get_widgets_to_hide_from_legacy_widget_block() {
public function get_widgets_to_hide_from_legacy_widget_block(): array {
if ( function_exists( 'get_legacy_widget_block_editor_settings' ) ) {
return get_legacy_widget_block_editor_settings()['widgetTypesToHideFromLegacyWidgetBlock'];
}
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.7 || ^1.0",
"phpunit/phpunit": "^5 || ^7",
"wearerequired/coding-standards": "^1.6",
"phpunit/phpunit": "^7 || ^9",
"wearerequired/coding-standards": "^5.0",
"yoast/phpunit-polyfills": "^1.0"
},
"minimum-stability": "dev",
Expand Down
5 changes: 5 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

<file>.</file>

<!-- The minimum supported WordPress version for all sniffs which use it. -->
<config name="minimum_supported_wp_version" value="6.0"/>
<!-- The minimum PHP requirement. -->
<config name="testVersion" value="7.4-"/>

<rule ref="Required">
<!-- Exclude till plugin minimum PHP version increases to 7.0. -->
<exclude name="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator"/>
Expand Down
8 changes: 6 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Widget Disable #
Contributors: wearerequired, neverything, swissspidy, ocean90, grapplerulrich
Contributors: wearerequired, neverything, swissspidy, ocean90, grapplerulrich, hubersen
Tags: widgets, admin, dashboard, sidebar widgets, dashboard widgets, disable widgets
Requires at least: 6.0
Tested up to: 6.2
Tested up to: 6.6
Requires PHP: 7.4
Stable tag: 3.0.0
License: GPLv2 or later
Expand Down Expand Up @@ -44,6 +44,10 @@ Developed by [required](https://required.com/ "Team of experienced web professio

## Changelog

### 3.0.1 - 2024-09-19

* Enhancement: Updated required packages
derpaschi marked this conversation as resolved.
Show resolved Hide resolved

### 3.0.0 - 2023-03-26

* Fixed: Replace use of jQuery to avoid deprecation warnings.
Expand Down
4 changes: 2 additions & 2 deletions wp-widget-disable.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
* Plugin Name: Widget Disable
* Plugin URI: https://required.com/services/wordpress-plugins/wp-widget-disable/
* Description: Disable sidebar and dashboard widgets with an easy to use interface. Simply use the checkboxes provided under <strong>Appearance -> Disable Widgets</strong> and select the widgets you'd like to hide.
* Version: 3.0.0
* Version: 3.0.1
* Requires at least: 6.0
* Requires PHP: 7.4
* Author: required
* Author URI: https://required.com
* License: GPLv2+
* Text Domain: wp-widget-disable
*
* Copyright (c) 2015-2023 required (email: [email protected])
* Copyright (c) 2015-2024 required (email: [email protected])
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2 or, at
Expand Down
Loading