What is the wp doctor command in WP-CLI?
wp doctor lets you easily run a series of configurable checks to diagnose what’s ailing with WordPress.
wp doctor, your team has to rely on their memory to manually debug problems. With
wp doctor, your team saves hours identifying the health of your WordPress installs by codifying diagnosis procedures as a series of checks to run with WP-CLI. It comes with dozens of checks out of the box.
|autoload-options-size||Warns when autoloaded options size exceeds the threshold of 900 kb.|
|constant-savequeries-falsy||Confirms expected state of the SAVEQUERIES constant.|
|constant-wp-debug-falsy||Confirms expected state of the WP_DEBUG constant.|
|core-update||Errors when new WordPress minor release is available; warns for a major release.|
|core-verify-checksums||Verifies WordPress files against published checksums; errors on failure.|
|cron-count||Errors when there’s an excess of 50 total cron jobs registered.|
|cron-duplicates||Errors when there’s an excess of 10 duplicate cron jobs registered.|
|file-eval||Checks files on the filesystem for regex pattern |
|option-blog-public||Confirms the expected value of the ‘blog_public’ option.|
|plugin-active-count||Warns when there are greater than 80 plugins activated.|
|plugin-deactivated||Warns when greater than 40% of plugins are deactivated.|
|plugin-update||Warns when there are plugin updates available.|
|theme-update||Warns when there are theme updates available.|
Which wp doctor commands are the most useful?
wp doctor check --all
This command will run all wp doctor commands at once
This command will check if the autoload options size is over 900kb. If you have an autoload options size larger than 2.6MB, it will cause site issues.
wp doctor check cron-count
This command will check if there is more than 50 cron job on a site.
wp doctor cron-duplicates
This command will warn if there are more than 10 duplicate cron job registered on a site.
wp doctor plugin-active-count
This command will warn if there are more than 80 activate plugins on a site.
What custom commands can you run with wp doctor?
You can create your own doctor.yml files. In this example, we want to check that MainWP Child plugin and the Classic Editor plugin are installed and active, but that the Hello Dolly plugin is uninstalled on a site.
The example yml file would look like this.
To run the plugin status yml file, the command would be:
wp doctor check --config=plugin-status.yml --all
This command would show if the two defined plugins are active and if the other plugin was uninstalled.
To create your own custom doctor.yml file, this post has a number of tips.
All of the
wp doctor commands used in this post are in this Gist.
In summary, wp doctor has many powerful commands that can be used to find if a site has autoload options which need to be optimized, if they have more than 50 cron jobs setup, or if they have duplicate cron jobs setup.