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

WP authors migration command - post type argument. #122

Merged
merged 10 commits into from
Sep 14, 2023
10 changes: 10 additions & 0 deletions inc/cli/class-migrate-command.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ class Migrate_Command extends WP_CLI_Command {
* - false
* ---
*
* [--post-type=<post-type>]
* : Post type, or comma separated list of post types.
* ---
* default: post
* ---
*
* ## EXAMPLES
*
* wp authorship migrate wp-authors --dry-run=true
Expand Down Expand Up @@ -79,6 +85,9 @@ public function wp_authors( $args, $assoc_args ) : void {
WP_CLI::warning( 'Overwriting of previous Authorship data is set to true.' );
}

$post_types = explode( ',', $assoc_args['post-type'] );
WP_CLI::line( sprintf( 'Updating post types: %s', implode( ', ', $post_types ) ) );

$tax_query = $overwrite ? [] : [
[
'taxonomy' => 'authorship',
Expand All @@ -93,6 +102,7 @@ public function wp_authors( $args, $assoc_args ) : void {
$posts = get_posts( [
'posts_per_page' => $posts_per_page,
'paged' => $paged,
'post_type' => $post_types,
'post_status' => 'any',
'ignore_sticky_posts' => true,
'suppress_filters' => false,
Expand Down