The recent release of Accessibility Checker Free v1.15.0 (changelog on WP.org) added three helpful WP-CLI commands that we believe experienced WordPress users and developers will find helpful. In this article, we will expand on what this enhancement means and the intention behind adding Accessibility Checker WP-CLI support.
A Quick Primer on WP-CLI
The WordPress Command Line Interface, or WP-CLI, is a tool that allows users to manage and maintain WordPress sites without having to use the back-end dashboard at all. Instead of using a traditional browser interface, you can perform various tasks simply by typing in the appropriate commands. Managing themes and plugins, running updates, changing settings, and more can be done through the command line.
Organizations that need to manage very large numbers of WordPress sites efficiently, or that need to perform complex batch operations or automations, will likely utilize WP-CLI at some point in those processes. They do this to save time and to preserve computational resources. To learn more about the core capabilities of WP-CLI, review the official WP-CLI Handbook.
Why We Added Accessibility Checker WP-CLI Support
One piece of feedback we’ve gotten repeatedly about Accessibility Checker is that while having accessibility reporting directly inside the WordPress dashboard is incredibly valuable, organizations sometimes want to surface that information in other areas of their operation. Our objective with this initial set of enhancements is to lay the groundwork for deeper integrations and allow organizations that manage large numbers of sites to pull data from Accessibility Checker scans efficiently.
With this initial set of WP-CLI commands, developers and power users can pull accessibility stats by individual page/post, or for the full site. They can also apply filters to get on the information they want, and nothing they don’t. While this improvement is definitely more developer-focused, it is also a step towards creating integration capabilities in the software for non-developers.
Accessibility Checker WP-CLI Commands List
With the release of Accessibility Checker Free v1.15.0, the following three WP-CLI commands (along with a series of command filters) have been introduced.
The ‘get-stats’ Command
This command is used to get the Accessibility Checker stats about a specific post/page. If the post_id passed exists and has stats then they will be returned as a JSON-formatted string of results.
Example
The ‘get-stats’ command requires you to enter the post-id number, as shown in the example below.
wp accessibility-checker get-stats 911
Entering this command, if the post-id is valid, will output a list of stats that Accessibility Checker has stored for that post ID. This will include passed tests, errors, warnings, ignored count, contrast errors, content and readability scores, and whether a simplified summary is present.
You can also filter this command to include on the stats you want by adding ‘–stat=’ to the command, as shown in the example below.
wp accessibility-checker get-stats 911 --stat='errors,warnings'
The ‘get-site-stats’ Command
This command gets the Accessibility Checker stats for the entire site. It returns a JSON-formatted string similar to the standard ‘get-stats’ command, only with more information.
Example
The ‘get-site-stats’ command can be entered as-is. Since it is for the full site, there is no need to enter a post ID or any other parameters. Below is an example of this command.
wp accessibility-checker get-site-stats
We do have the ability to filter the data that this command returns. Using the same ‘–stat=’ command will modify the results that get returned, as shown in the example below.
wp accessibility-checker get-site-stats --stat="cached_at_formatted,distinct_errors,distinct_warnings,contrast_errors"
The ‘delete-stats’ Command
This command is used to delete all Accessibility Checker stats related a specific post-ID. If the post_id exists, this command will permanently wipe the stats from it. Once stats are deleted they can’t be restored, and the post will need to be scanned again to generate new results.
Below is an example of that command for a random post ID number.
wp accessibility-checker delete-stats 911
Clear Cache Flag
If changes are made to the site and you need to be sure that you’re getting the latest numbers, we’ve included a ‘–clear-cache’ flag that can be appended to Accessibility Checker WP-CLI commands. Below is an example of that in action.
wp accessibility-checker get-site-stats --stat="cached_at_formatted,distinct_errors,distinct_warnings,contrast_errors" --clear-cache
Stay Tuned for More Improvements
We are constantly working on improving Accessibility Checker. The best way to stay up to speed is to sign up for our Focus State Newsletter, where we highlight new bug fixes and enhancements that are released in our software, along with timely accessibility news, events, and other resources.
Article continued below.
Stay on top of web accessibility news and best practices.
Join our email list to get notified of changes to website accessibility laws, WordPress accessibility resources, and accessibility webinar invitations in your inbox.