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
Add NCC trickery #487
base: trunk
Are you sure you want to change the base?
Add NCC trickery #487
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't actually test, just a straight ol' code review.
@@ -68,59 +173,156 @@ public function cmd_blocks_decode( array $pos_args, array $assoc_args ): void { | |||
'post_content' => $content, | |||
] | |||
); | |||
WP_CLI::log( sprintf( 'Decoded blocks in %s', get_permalink( $post->ID ) ) ); | |||
$this->logger->log( $logfile, sprintf( 'Decoded blocks in ID %d %s', $post->ID, get_permalink( $post->ID ) ), Logger::SUCCESS ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To prevent false positives, I think we should change this to $updated = wp_update_post(...); if ( $updated) { $this->logger->log(...);
And only increment $decoded_posts_counter
if $updated === true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I've updated both places.
wp_update_post( | ||
[ | ||
'ID' => $post->ID, | ||
'post_content' => $content, | ||
] | ||
); | ||
WP_CLI::log( sprintf( 'Encoded blocks in %s', get_permalink( $post->ID ) ) ); | ||
$this->logger->log( $logfile, sprintf( 'Encoded blocks in post ID %d %s', $post->ID, get_permalink( $post->ID ) ), Logger::SUCCESS ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to comment from above, it'd be good to only display this information, if in fact we can confirm that wp_update_post
was truly successful.
This adds support for args in the block encode/decode commands:
There is a new command that "nudges" posts to be picked up by the NCC - it just inserts a line break at the top of posts that start with
<!--
that would otherwise not get picked up by the NCC.How to test
wp newspack-content-migrator transform-blocks-encode --num-items=50
. The output will tell you next steps. It's also logged to file.wp newspack-content-migrator transform-blocks-nudge --num-items=30 --post-types=post,page