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.
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