Add error count summary to plugin check UI#1180
Open
faisalahammad wants to merge 1 commit intoWordPress:trunkfrom
Open
Add error count summary to plugin check UI#1180faisalahammad wants to merge 1 commit intoWordPress:trunkfrom
faisalahammad wants to merge 1 commit intoWordPress:trunkfrom
Conversation
- Add countResults() function to count total errors and warnings - Update renderResultsMessage() to display detailed counts - Show messages like '3 errors and 2 warnings found' instead of generic 'Errors were found' - Implement proper pluralization (1 error vs 2 errors) - Maintain fallback to default message if no counts available Fixes WordPress#1113
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @mikedin. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
|
||
| // Build the message with counts. | ||
| const errorPart = | ||
| errorCount > 0 |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
This PR adds error and warning count summaries to the plugin check completion message in the admin UI, addressing issue #1113.
Before: Generic message "Errors were found."
After: Specific counts like "3 errors and 2 warnings found."
Problem Statement
When users run plugin checks in wp-admin (Tools > Plugin Check), they see a generic completion message that does not provide any numeric feedback:
This is less helpful than the CLI version, which shows detailed counts. Users requested to see the total number of errors and warnings in the UI summary message.
Solution
I implemented a JavaScript-based counting solution that:
aggregatedResultsobject that already stores all errors and warningsWhy This Approach?
I evaluated three options:
Option 1: Count in JavaScript (Selected)
Option 2: Count in Backend
Option 3: Hybrid
Decision: Option 1 is the best solution because it reuses existing data and keeps changes minimal.
Changes Made
New Function:
countResults()Added a new function to count total errors and warnings from the aggregated results tree:
How it works: Iterates through the nested tree structure (file > line > column > messages) and counts all individual error and warning entries.
Enhanced Function:
renderResultsMessage()Updated the message rendering logic to build dynamic messages with counts:
Before:
After:
How it works:
countResults()when errors existCode Quality
WordPress JavaScript Standards:
@sincetagsBest Practices:
Testing
I have tested this implementation with multiple scenarios:
Test Scenarios
How to Test
Example Output
Success (no errors):
Errors only:
Warnings only:
Mixed errors and warnings:
Files Changed
assets/js/plugin-check-admin.js(+73 lines, -3 lines)Fixes
Fixes #1113
Checklist
Screenshots
Additional Notes
Why not add unit tests?
The project currently has no JavaScript testing infrastructure. This would be a great follow-up PR to add Jest or similar framework for JS testing.
Future enhancements:
Review Focus Areas
When reviewing this PR, please pay attention to: