Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
WP-CLI 101 Progress Bar
* Displays progress bar to demonstrate progression through a time consuming process.
* @param Array $args Arguments in array format.
* @param Array $assoc_args Key value arguments stored in associated array format.
* @since 1.0.0
* @author Scott Anderson
public function generate_posts_progress_bar( $args, $assoc_args ) {
$desired_posts_to_generate = (int) $args[0];
$progress = \WP_CLI\Utils\make_progress_bar( 'Generating Posts', $desired_posts_to_generate );
for ( $i = 0; $i < $desired_posts_to_generate; $i++ ) {
// Code used to generate a post.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment