Skip to content

WP‐CLI Commands

William Patton edited this page Oct 3, 2025 · 12 revisions

The plugin includes a few handy WP-CLI commands inside of it for getting access to the Accessibility Checker stats about posts or the site.

There are currently 5 commands. All that commands are subcommands of accessibility-checker root.

  • wp accessibility-checker cleanup-orphaned-issues [--batch=<batch>] [--sleep=<sleep>]
  • wp accessibility-checker delete-stats [<post_id>]
  • wp accessibility-checker get-site-stats [--stat=<stat>...] [--clear-cache]
  • wp accessibility-checker get-stats [<post_id>] [--stat=<stat>...]
  • wp accessibility-checker license --action=<action> [--key=<key>]

Additionally, a shorthand version of the root command is added for convenience. You can replace wp accessibility-checker with simpley wp edac instead.

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.

wp accessibility-checker get-stats 911

Screenshot from 2024-07-17 13-16-11

Success: {
    "passed_tests": 93,
    "errors": 1,
    "warnings": 2,
    "ignored": 1,
    "contrast_errors": 0,
    "content_grade": 12,
    "readability": "12th",
    "simplified_summary": false
}

Filtering the results with --stat

You can filter the returned results by any of the valid keys exposed in the command. Pass them as a list the flag, for example to get errors and warnings only use --stat="errors,warnings".

wp accessibility-checker get-stats 911 --stat='errors,warnings'

Screenshot from 2024-07-17 13-17-26

Success: {
    "errors": 1,
    "warnings": 2
}

The delete-stats command.

This command is used to delete the Accessibility Checker stats about a specific post/page. If the post_id passed exist then it will clear the stats from it. Once stats are deleted they can't be restored, you have to scan the post again to generate new scan results.

wp accessibility-checker delete-stats 911

Screenshot from 2024-07-17 13-22-07

Success: Stats of 911 deleted.

The get-site-stats command.

This command gets the Accessibility Checker stats for the entire site. It returns a JSON-formatted string. This data is not directly exposed in the plugin UI at the moment so it may be the most useful command for site owners or maintainers since it collates and displays data not otherwise visible as a group.

wp accessibility-checker get-site-stats

Screenshot from 2025-06-30 18-03-03

Success: {
    "scannable_posts_count": 71,
    "rule_count": 43,
    "tests_count": 3053,
    "scannable_post_types_count": 2,
    "public_post_types_count": 9,
    "posts_scanned": 71,
    "is_truncated": false,
    "posts_with_issues": 71,
    "rules_failed": 35,
    "rules_passed": 8,
    "passed_percentage": 18.6,
    "warnings": 294,
    "distinct_warnings": 172,
    "contrast_errors": 5,
    "distinct_contrast_errors": 5,
    "errors": 877,
    "distinct_errors": 237,
    "errors_without_contrast": 872,
    "distinct_errors_without_contrast": 232,
    "ignored": 0,
    "distinct_ignored": 0,
    "posts_without_issues": 0,
    "avg_issues_per_post": 16.49,
    "avg_issue_density_percentage": 6.62,
    "fullscan_running": false,
    "fullscan_state": "completed",
    "fullscan_completed_at": 1751302072,
    "cache_id": "edac_scans_stats_1.25.0_100000_summary",
    "cached_at": 1751302072,
    "expires_at": 1751388472,
    "cache_hit": true,
    "scannable_posts_count_formatted": "71",
    "rule_count_formatted": "43",
    "tests_count_formatted": "3,053",
    "scannable_post_types_count_formatted": "2",
    "public_post_types_count_formatted": "9",
    "posts_scanned_formatted": "71",
    "posts_with_issues_formatted": "71",
    "rules_failed_formatted": "35",
    "rules_passed_formatted": "8",
    "warnings_formatted": "294",
    "distinct_warnings_formatted": "172",
    "contrast_errors_formatted": "5",
    "distinct_contrast_errors_formatted": "5",
    "errors_formatted": "877",
    "distinct_errors_formatted": "237",
    "errors_without_contrast_formatted": "872",
    "distinct_errors_without_contrast_formatted": "232",
    "ignored_formatted": "0",
    "distinct_ignored_formatted": "0",
    "posts_without_issues_formatted": "0",
    "avg_issues_per_post_formatted": "16",
    "fullscan_completed_at_formatted": "June 30, 2025 at 4:47 pm",
    "passed_percentage_formatted": "18.6%",
    "avg_issue_density_percentage_formatted": 6.62,
    "cached_at_formatted": "June 30, 2025 at 4:47 pm"
}

Filtering the result with --stat

You can filter the results to show only the keys you are interested in with the --stat command.

wp accessibility-checker get-site-stats --stat="cached_at_formatted,distinct_errors,distinct_warnings,contrast_errors"

Screenshot from 2024-07-17 15-32-49

Success: {
    "cached_at_formatted": "June 17, 2024 at 2:32 pm",
    "distinct_errors": 103,
    "distinct_warnings": 59,
    "contrast_errors": 3
}

Ensuring you get the latest stats after changes with --clear-cache

If you make changes to the site and need to check the latest numbers there may be times where you see cached data rather than latest. The command returns a value to show the last cache time and you can clear the cache with the --clear-cache flag, noticing the time change.

wp accessibility-checker get-site-stats --stat="cached_at_formatted,distinct_errors,distinct_warnings,contrast_errors" --clear-cache

Screenshot from 2024-07-17 15-32-58

Success: {
    "cached_at_formatted": "June 17, 2024 at 2:32 pm",
    "distinct_errors": 103,
    "distinct_warnings": 59,
    "contrast_errors": 3
}

Parsing the stats programatically.

If you need to integrate stats to your dashboard in some way then you can programatically parse the command results.

Using PHP you can pass the output through code like this to get a PHP array where $stats is the output captured from running the command:

$stats_array = json_decode(
	html_entity_decode(
		str_replace( 'Success: ', '', $stats )
	),
	true
);

The cleanup-orphaned-issues command.

Accessibility Checker plugin has a feature which handled cleaning up orphaned issues where the post IDs don't exist anymore.

It runs once a day but there may be times you want to run it on demand. A CLI command is provided for those time with a few configuration flags.

By default it will process batches of 50 posts. You can increase or reduce that number as needed. You can also set a sleep value which will add a sleep gap of that many seconds between deletions (useful on servers that may be under stress or have limited resources).

wp accessibility-checker cleanup-orphaned-issues
Screenshot from 2025-09-09 16-06-54
root@4ef3d30ad06c:/var/www/html# wp accessibility-checker cleanup-orphaned-issues
Found 8 orphaned post IDs
 - Deleting issues for post ID: 999996
 - Deleting issues for post ID: 999995
 - Deleting issues for post ID: 999994
 - Deleting issues for post ID: 999993
 - Deleting issues for post ID: 999974
 - Deleting issues for post ID: 999935
 - Deleting issues for post ID: 999911
 - Deleting issues for post ID: 999915
Success: Orphaned issues cleanup complete. 8 post(s) processed.

You can alter the batch size to be larger or smaller and add a sleep (set in seconds, you can use 2 or part seconds like 0.5 for a half second.

wp accessibility-checker cleanup-orphaned-issues --batch=5 --sleep=2
Screenshot from 2025-09-09 16-09-29
root@4ef3d30ad06c:/var/www/html# wp accessibility-checker cleanup-orphaned-issues --batch=5 --sleep=2
Found 5 orphaned post IDs
 - Deleting issues for post ID: 999996
 - Deleting issues for post ID: 999995
 - Deleting issues for post ID: 999994
 - Deleting issues for post ID: 999993
 - Deleting issues for post ID: 999974
Success: Orphaned issues cleanup complete. 5 post(s) processed.

The license command.

If you have the pro plugin installed then you will have a license command as well. This command is used to activate, deactivate or check the status of a licence.

It accepts 2 parameters.

  • An --action flag which is required for all operations. It can be one of activate, deactivate or status.
  • The --key flat which is an optional flag but must be used for activations.

Activating a License

wp accessibility-checker license --action=activate --key=123456789123456789123456789132456789

If successful will result in a message like this:

Success: License activated successfully.

If not successful will return an error with a general indication what the issue was. If the error is returned from the license server that will be shown.

There was an error.
{
    "success": false,
    "message": "missing",
    "status": "invalid"
}
Error: missing
wp accessibility-checker license --action=deactivate

Results in output like this when the license was deactivated.

Success: License deactivated successfully.

If there is no license key stored on the site an error will be thrown.

Error: No license key provided and no stored key found for deactivation.

Getting the status

The status of a key can be checked as well. A valid key will return valid, no key will return unknown. Other status may also be returned like invalid, expired etc. These values map directly to the values returned from the license server.

Note: When the values are returned the message will always include Success if it was able to determine a value. Even if that value indicates invalid license or expired. The indicator is implying the command succeeded.

wp accessibility-checker license --action=status

A valid license:

Success: License status: valid

No license:

Success: License status: unknown

Deleting all issues for posts that are in draft status

A few times we have been asked to skip drafts in the scanner or to help find issues for only published posts. We can use the default wp-cli commands to find all posts in draft status and pipe that through to the plugin's stats delete command to clear out any issues for any post in draft status.

wp post list --post_type=any --post_status=draft --format=ids | xargs -n1 wp accessibility-checker delete-stats

Clone this wiki locally