Created
September 16, 2019 16:42
-
-
Save Oceas/76ee6e7dbf1bec56c1833bdf0d218591 to your computer and use it in GitHub Desktop.
WP-CLI 101 Progress Bar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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. | |
$progress->tick(); | |
} | |
$progress->finish(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment