-
Notifications
You must be signed in to change notification settings - Fork 19
Add Site Health status checks #1106
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
Merged
SteveJonesDev
merged 10 commits into
develop
from
codex/add-wordpress-site-health-integration
Aug 5, 2025
Merged
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
a6a277b
Add Site Health status checks
SteveJonesDev 3e5ccbf
:rotating_light: lint: Fix tabs vs spaces and other spacingg issues
pattonwebz ca4b8f1
Rename badge method for clarity and consistency
pattonwebz 0ff8773
Add translation support for scanned posts count in accessibility checker
pattonwebz eeddef8
Fix more lint spacing issues
pattonwebz c43ac34
Store the scan_stats summary in a cached property
pattonwebz b63e59b
added: method to retrieve issues link and improve stats formatting in…
SteveJonesDev 347dae9
added: post types configuration test to site health checks
SteveJonesDev bd0a9d0
added: unit tests for Site Health Checks functionality
SteveJonesDev 3df2487
Refactor tests for Site Health Checks: improve filter assertion and h…
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,119 @@ | ||
| <?php | ||
| /** | ||
| * Site Health status checks for Accessibility Checker. | ||
| * | ||
| * @since 1.29.0 | ||
| * @package Accessibility_Checker | ||
| */ | ||
|
|
||
| namespace EDAC\Admin\SiteHealth; | ||
|
|
||
| use EDAC\Admin\Scans_Stats; | ||
|
|
||
| /** | ||
| * Adds Site Health tests for Accessibility Checker. | ||
| * | ||
| * @since 1.29.0 | ||
| */ | ||
| class Checks { | ||
|
|
||
| /** | ||
| * Init hooks. | ||
| * | ||
| * @return void | ||
| */ | ||
| public function init_hooks() { | ||
| add_filter( 'site_status_tests', [ $this, 'register_tests' ] ); | ||
| } | ||
|
pattonwebz marked this conversation as resolved.
Outdated
|
||
|
|
||
| /** | ||
| * Register our tests with Site Health. | ||
| * | ||
| * @param array $tests Existing tests. | ||
| * @return array | ||
| */ | ||
| public function register_tests( array $tests ): array { | ||
| $tests['direct']['edac_issues'] = [ | ||
| 'label' => __( 'Accessibility issues', 'accessibility-checker' ), | ||
| 'test' => [ $this, 'test_for_issues' ], | ||
| ]; | ||
|
|
||
| $tests['direct']['edac_scanned'] = [ | ||
| 'label' => __( 'Content checked for accessibility', 'accessibility-checker' ), | ||
| 'test' => [ $this, 'test_content_scanned' ], | ||
| ]; | ||
|
|
||
| return $tests; | ||
| } | ||
|
|
||
| /** | ||
| * Test if there are accessibility issues on the site. | ||
| * | ||
| * @return array | ||
| */ | ||
| public function test_for_issues(): array { | ||
| $stats = ( new Scans_Stats( 60 * 5 ) )->summary(); | ||
|
pattonwebz marked this conversation as resolved.
Outdated
|
||
| $errors = absint( $stats['errors'] ?? 0 ); | ||
| $warnings = absint( $stats['warnings'] ?? 0 ); | ||
|
|
||
| if ( $errors > 0 || $warnings > 0 ) { | ||
| return [ | ||
| 'status' => 'recommended', | ||
| 'label' => __( 'Accessibility issues detected', 'accessibility-checker' ), | ||
| 'description' => sprintf( | ||
| // translators: 1: error count, 2: warning count. | ||
| __( 'Accessibility Checker has detected %1$d errors and %2$d warnings.', 'accessibility-checker' ), | ||
| $errors, | ||
| $warnings | ||
| ), | ||
| 'actions' => sprintf( | ||
| '<p><a href="%1$s" class="button button-primary">%2$s</a></p>', | ||
| esc_url( admin_url( 'admin.php?page=accessibility_checker_issues' ) ), | ||
| esc_html__( 'View issues', 'accessibility-checker' ) | ||
| ), | ||
| 'test' => 'edac_issues', | ||
| ]; | ||
| } | ||
|
|
||
| return [ | ||
| 'status' => 'good', | ||
| 'label' => __( 'No accessibility issues detected', 'accessibility-checker' ), | ||
| 'description' => __( 'Accessibility Checker has not found any issues in scanned content.', 'accessibility-checker' ), | ||
| 'test' => 'edac_issues', | ||
| ]; | ||
| } | ||
|
|
||
| /** | ||
| * Test if any posts have been scanned. | ||
| * | ||
| * @return array | ||
| */ | ||
| public function test_content_scanned(): array { | ||
| $stats = ( new Scans_Stats( 60 * 5 ) )->summary(); | ||
| $scanned = absint( $stats['posts_scanned'] ?? 0 ); | ||
|
|
||
| if ( 0 === $scanned ) { | ||
| return [ | ||
| 'status' => 'recommended', | ||
| 'label' => __( 'Content has not been checked', 'accessibility-checker' ), | ||
| 'description' => __( 'No posts have been scanned yet. Run a full site scan to begin checking your content for accessibility issues.', 'accessibility-checker' ), | ||
| 'actions' => sprintf( | ||
| '<p><a href="%1$s" class="button button-primary">%2$s</a></p>', | ||
| esc_url( admin_url( 'admin.php?page=accessibility_checker_full_site_scan' ) ), | ||
| esc_html__( 'Start full site scan', 'accessibility-checker' ) | ||
| ), | ||
| 'test' => 'edac_scanned', | ||
| ]; | ||
| } | ||
|
|
||
| return [ | ||
| 'status' => 'good', | ||
| 'label' => __( 'Content is being checked', 'accessibility-checker' ), | ||
| 'description' => sprintf( | ||
| _n( 'Accessibility Checker has scanned %d post.', 'Accessibility Checker has scanned %d posts.', $scanned, 'accessibility-checker' ), | ||
| $scanned | ||
| ), | ||
| 'test' => 'edac_scanned', | ||
| ]; | ||
| } | ||
| } | ||
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.