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.
Update: Additional commands have been added in later releases. Those are documented here as well.
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
The ‘cleanup-orphaned-issues` Command
This command is used to run the routine to cleanup any issues that have managed to get orphaned in the database. That routine does run on it’s own once a day but you may want to run it manually which is what the command is used for.
You can give it custom batch sizes (the default is 50) and a sleep time that it will wait between deletions. The sleep timer default is 0, you can pass partial seconds like 0.5 for a half second.
wp accessibility-checker cleanup-orphaned-issues --batch=5 --sleep=0.5
The `license
` Command
This command exists in the pro plugin only. If you have Accessibility Checker Pro installed you can manage your key with the cli.
There are 3 actions you can call: activate
, deactivate
and status
.
wp accessibility checker --action=activate --key=123456789123456789123456789132456789
The status action will let you know if your key is valid
, unknown
in case of no key stored on the site or a few other status like expired
.
When you use the activate
action you must pass a key. The command will either result in a success message telling you it was activated. Or output an error telling you why it didn’t activate.
When the deactivate
action is used no key is required to be passed. It will clear any currently stored key from the site as well as deactivate the domain from the license server.