Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update WP_CLI::line() to WP_CLI::log() #699

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions classes/class-wpcom-liveblog-wp-cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function fix_archive( $args, $assoc_args ) {
$is_dryrun = ( isset( $assoc_args['dryrun'] ) ) ? true : false;

// find all liveblogs
WP_CLI::line( 'Finding All Live Blog Entries..' );
WP_CLI::log( 'Finding All Live Blog Entries..' );

$posts = new WP_Query(
array(
Expand All @@ -41,15 +41,15 @@ public function fix_archive( $args, $assoc_args ) {
$current_liveblog = 0;

//Feedback to the user
WP_CLI::line( 'Found ' . $total_liveblogs . ' Live Blogs.' );
WP_CLI::log( 'Found ' . $total_liveblogs . ' Live Blogs.' );

foreach ( $posts->posts as $post ) {

//Increment the count so we get a more human readable index, inital value becomes 1 rather than 0.
$current_liveblog ++;

//Tell the user what we are doing, but lets colour this one se we can see its a new Liveblog in the console output.
WP_CLI::line( WP_CLI::colorize( "%4 Processing Liveblog {$current_liveblog} of {$total_liveblogs} %n" ) );
WP_CLI::log( WP_CLI::colorize( "%4 Processing Liveblog {$current_liveblog} of {$total_liveblogs} %n" ) );

//Define the post ID
$post_id = $post->ID;
Expand Down Expand Up @@ -78,7 +78,7 @@ public function fix_archive( $args, $assoc_args ) {
if ( count( $edit_entries ) > 0 ) {

// SHow the User how many Edited Entries we've found.
WP_CLI::line( 'Found ' . count( $edit_entries ) . ' edited entries..' );
WP_CLI::log( 'Found ' . count( $edit_entries ) . ' edited entries..' );

foreach ( $edit_entries as $edit_entry ) {
$entry_id = $edit_entry->get_id();
Expand All @@ -87,7 +87,7 @@ public function fix_archive( $args, $assoc_args ) {
if ( in_array( $edit_entry->replaces, $correct_ids, true ) ) {

//The edited entry is accurate so we dont need to do anything.
WP_CLI::line( 'No action required.. skipping Entry ' . $entry_id );
WP_CLI::log( 'No action required.. skipping Entry ' . $entry_id );
continue;

} else {
Expand All @@ -99,7 +99,7 @@ public function fix_archive( $args, $assoc_args ) {
if ( $correct_ids[ $i ] < $entry_id ) {

//The edited entry needs updating to reflect the correct ID's
WP_CLI::line( 'Correcting Entry ' . $entry_id . '...' );
WP_CLI::log( 'Correcting Entry ' . $entry_id . '...' );

// If this isnt a dry run we can run the database Update.
if ( false === $is_dryrun ) {
Expand Down Expand Up @@ -151,7 +151,7 @@ public function fix_archive( $args, $assoc_args ) {
$replaced = 0;

//THe edited entry is accurate so we dont need to do anything.
WP_CLI::line( 'Total of ' . count( $entries_replace ) . ' need action..' );
WP_CLI::log( 'Total of ' . count( $entries_replace ) . ' need action..' );

foreach ( $entries_replace as $entry_replace ) {

Expand All @@ -167,15 +167,15 @@ public function fix_archive( $args, $assoc_args ) {
}

//Lets update the user with what we are doing.
WP_CLI::line( 'Replaced Content in ' . $replaced . ' Entry(ies) so far..' );
WP_CLI::log( 'Replaced Content in ' . $replaced . ' Entry(ies) so far..' );

$replaced++;
}
}

//If we have a dry run flag lets just output what we would be looking to do on a live run.
if ( true === $is_dryrun ) {
WP_CLI::line( 'Found ' . count( $edit_entries ) . ' Edited Entries on Post ID ' . $post_id );
WP_CLI::log( 'Found ' . count( $edit_entries ) . ' Edited Entries on Post ID ' . $post_id );
}
}

Expand Down Expand Up @@ -239,7 +239,7 @@ function ( $matches ) {
}

public static function help() {
WP_CLI::line(
WP_CLI::log(
<<<HELP
usage: wp liveblog readme_for_github
Converts the readme.txt to real markdown to be used as a README.md
Expand Down
Loading