Skip to content

Commit

Permalink
Improve debug info when updating posts
Browse files Browse the repository at this point in the history
Show the slug also.
  • Loading branch information
nylen committed Feb 26, 2020
1 parent 45d4777 commit 9e25b76
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions wp-content/mu-plugins/markdown-sync/inc/class-importer.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,27 +231,29 @@ public function import_all_markdown() {
$q = new WP_Query( array(
'post_type' => $this->get_post_type(),
'post_status' => 'publish',
'fields' => 'ids',
'posts_per_page' => $this->posts_per_page,
) );
$ids = $q->posts;
$success = 0;
foreach( $ids as $id ) {
$ret = $this->update_post_from_markdown_source( $id );
foreach( $q->posts as $post ) {
$ret = $this->update_post_from_markdown_source( $post->ID );
if ( class_exists( 'WP_CLI' ) ) {
if ( is_wp_error( $ret ) ) {
WP_CLI::warning( $ret->get_error_message() );
} elseif ( false === $ret ) {
WP_CLI::log( "No updates for {$id}" );
WP_CLI::log(
"No updates for post {$post->ID} ('{$post->post_name}')"
);
$success++;
} else {
WP_CLI::log( "Updated {$id} from markdown source" );
WP_CLI::log(
"Updated post {$post->ID} ('{$post->post_name}')"
);
$success++;
}
}
}
if ( class_exists( 'WP_CLI' ) ) {
$total = count( $ids );
$total = count( $q->posts );
WP_CLI::success( "Successfully updated {$success} of {$total} pages." );
}
}
Expand Down

0 comments on commit 9e25b76

Please sign in to comment.