SweepPress, both Lite/Free and Pro versions, includes support for running sweeping tasks via WP-CLI. The plugin registers one main CLI command
sweeppress and several subcommands. For the main command and all subcommands, you can use the WP-CLI help command to get more information and usage examples.
SweepPress command and subcommands all support various global parameters WP-CLI implements, and these are listed in WP-CLI documentation and via help command WP-CLI uses.
Getting started with the command
To get started, type:
And you will get the list of available subcommands.
WP-CLI has additional helpful notes about the usage, so check out some of the responses to get more information. Make sure to also use the help command to get more information.
list will show all available sweepers (sweepers that don’t have anything to sweep are not listed), with the number of tasks and estimated number of records for removal, and the total estimated size for removal.
This command has one more use: list individual tasks for each sweeper by adding the sweeper’s name to the list command sequence. You should use task names from the first list results table.
So, if you get results for a task that has post types, like the example above, you will see in individual post types as tasks.
This subcommand will run all available sweepers and will return sweeping results. This subcommand will not run every available sweeper! Some sweepers must be run only manually to avoid running them too often (some sweepers can be demanding). Here are the typical results returned by this subcommand.
The results are displayed with the same format for all other sweeper subcommands, showing basic status information, records removed, space recovered, sweepers and tasks, and a quick overview of all run sweepers’ status. Again, the records removed and space recovered are estimated values because it is impossible to actually get the exact state of the database due to the caching and other optimizations done by the database server.
This subcommand allows you to run one or more sweepers listed in the command sequence, and it will run all available tasks for listed sweepers. Each sweeper is listed with the space separation like this:
wp sweeppress sweep <sweeper-name> <sweeper-name> <sweeper-name> ...
This final sweeping subcommand allows you to run a single sweeper with one or more tasks as arguments. The sweeper is a required argument, and you need to specify one or more tasks by task name (again, consult the results from the
wp sweeppress sweeper sweeper-name <task-name> <task-name> ...
In the future, it is possible that more settings and subcommands will be added to enhance the process further.