-
Notifications
You must be signed in to change notification settings - Fork 19
Feature: add Equalize Digital tab to WP 7.0+ Plugins screen #1720
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
Draft
SteveJonesDev
wants to merge
7
commits into
develop
Choose a base branch
from
claude/sleepy-haslett-08c6bd
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
19777b0
Feature: add Equalize Digital tab to WP 7.0+ Plugins screen
SteveJonesDev 5400218
Fix: address review comments on Plugin_List_Tab
SteveJonesDev 09e8cee
Fix: move Plugin_List_Tab to EqualizeDigital\AccessibilityChecker\Adm…
SteveJonesDev 876680a
Fix: return plain text from get_status_text, not HTML
SteveJonesDev fff698d
Tweak: raise minimum Equalize Digital plugins for tab to 3
SteveJonesDev 5db81c7
Simplify: replace _nx with __ in get_status_text
SteveJonesDev 2e22f62
Fix: correct typo in translation function in get_status_text
SteveJonesDev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,123 @@ | ||
| <?php | ||
| /** | ||
| * Plugin List Tab class file for the Accessibility Checker plugin. | ||
| * | ||
| * @package Accessibility_Checker | ||
| */ | ||
|
|
||
| namespace EDAC\Admin; | ||
|
|
||
| if ( ! defined( 'ABSPATH' ) ) { | ||
| exit; | ||
| } | ||
|
|
||
| /** | ||
| * Registers an "Equalize Digital" tab on the WordPress Plugins screen. | ||
| * | ||
| * The tab appears when 2 or more Equalize Digital plugins are installed, | ||
| * using the plugins_list and plugins_list_status_text filters added in WP 7.0. | ||
| * | ||
| * @since 1.43.0 | ||
| */ | ||
| class Plugin_List_Tab { | ||
|
|
||
| /** | ||
| * Minimum number of Equalize Digital plugins required to show the tab. | ||
| * | ||
| * @var int | ||
| */ | ||
| const MINIMUM_FOR_TAB = 2; | ||
|
|
||
| /** | ||
| * The status slug used for the Equalize Digital tab. | ||
| * | ||
| * @var string | ||
| */ | ||
| const STATUS_SLUG = 'equalize-digital'; | ||
|
|
||
| /** | ||
| * Initialize hooks. | ||
| * | ||
| * @since 1.43.0 | ||
| * | ||
| * @return void | ||
| */ | ||
| public function init_hooks(): void { | ||
| global $wp_version; | ||
|
|
||
| if ( \version_compare( $wp_version, '7.0-alpha0', '<' ) ) { | ||
| return; | ||
| } | ||
|
|
||
| add_filter( 'plugins_list', [ $this, 'filter_plugins_list' ] ); | ||
| add_filter( 'plugins_list_status_text', [ $this, 'get_status_text' ], 10, 3 ); | ||
| } | ||
|
|
||
| /** | ||
| * Filters the plugins list to add an Equalize Digital group. | ||
| * | ||
| * Only adds the group when 2 or more Equalize Digital plugins are installed. | ||
| * | ||
| * @since 1.43.0 | ||
| * | ||
| * @param array<string, array<string, array<string, string>>> $plugins The plugins list keyed by status. | ||
| * | ||
| * @return array<string, array<string, array<string, string>>> The filtered plugins list. | ||
| */ | ||
| public function filter_plugins_list( $plugins ) { | ||
| if ( ! \is_array( $plugins ) || ! isset( $plugins['all'] ) ) { | ||
| return $plugins; | ||
| } | ||
|
SteveJonesDev marked this conversation as resolved.
Outdated
|
||
|
|
||
| $equalize_digital_plugins = []; | ||
| foreach ( $plugins['all'] as $plugin_file => $plugin_data ) { | ||
| if ( $this->is_equalize_digital_plugin( $plugin_data ) ) { | ||
| $equalize_digital_plugins[ $plugin_file ] = $plugin_data; | ||
| } | ||
| } | ||
|
|
||
| if ( \count( $equalize_digital_plugins ) < self::MINIMUM_FOR_TAB ) { | ||
| return $plugins; | ||
| } | ||
|
|
||
| $plugins[ self::STATUS_SLUG ] = $equalize_digital_plugins; | ||
|
|
||
| return $plugins; | ||
| } | ||
|
|
||
| /** | ||
| * Returns the label text for the Equalize Digital tab. | ||
| * | ||
| * @since 1.43.0 | ||
| * | ||
| * @param string $text The current status text. | ||
| * @param int $count The number of plugins with this status. | ||
| * @param string $type The status type slug. | ||
| * | ||
| * @return string The status text. | ||
| */ | ||
| public function get_status_text( $text, $count, $type ) { | ||
| if ( self::STATUS_SLUG !== $type ) { | ||
| return $text; | ||
| } | ||
|
|
||
| return \_nx( 'Equalize Digital', 'Equalize Digital', $count, 'plugin status', 'accessibility-checker' ); | ||
|
SteveJonesDev marked this conversation as resolved.
Outdated
SteveJonesDev marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
| /** | ||
| * Determines whether a plugin belongs to Equalize Digital. | ||
| * | ||
| * @since 1.43.0 | ||
| * | ||
| * @param array<string, string> $plugin_data The plugin header data. | ||
| * | ||
| * @return bool | ||
| */ | ||
| private function is_equalize_digital_plugin( $plugin_data ): bool { | ||
| if ( ! \is_array( $plugin_data ) || empty( $plugin_data['AuthorURI'] ) ) { | ||
| return false; | ||
| } | ||
|
|
||
| return false !== \strpos( $plugin_data['AuthorURI'], 'equalizedigital.com' ); | ||
|
SteveJonesDev marked this conversation as resolved.
Outdated
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.