diff --git a/php/class-wp-cli.php b/php/class-wp-cli.php index b5123c15..0205270a 100644 --- a/php/class-wp-cli.php +++ b/php/class-wp-cli.php @@ -205,12 +205,11 @@ public function assign_coauthors( $args, $assoc_args ) { /** * Assign posts associated with a WordPress user to a co-author - * Only apply the changes if there aren't yet co-authors associated with the post * * @since 3.0 * * @subcommand assign-user-to-coauthor - * @synopsis --user_login= --coauthor= + * @synopsis --user_login= --coauthor= [--append_coauthors] */ public function assign_user_to_coauthor( $args, $assoc_args ) { global $coauthors_plus, $wpdb; @@ -218,6 +217,7 @@ public function assign_user_to_coauthor( $args, $assoc_args ) { $defaults = array( 'user_login' => '', 'coauthor' => '', + 'append_coauthors' => false, ); $assoc_args = wp_parse_args( $assoc_args, $defaults ); @@ -237,7 +237,7 @@ public function assign_user_to_coauthor( $args, $assoc_args ) { $affected = 0; foreach ( $posts as $post_id ) { $coauthors = cap_get_coauthor_terms_for_post( $post_id ); - if ( ! empty( $coauthors ) ) { + if ( ! empty( $coauthors ) && ! $assoc_args['append_coauthors'] ) { WP_CLI::line( sprintf( __( 'Skipping - Post #%d already has co-authors assigned: %s', 'co-authors-plus' ), $post_id, @@ -246,7 +246,7 @@ public function assign_user_to_coauthor( $args, $assoc_args ) { continue; } - $coauthors_plus->add_coauthors( $post_id, array( $coauthor->user_login ) ); + $coauthors_plus->add_coauthors( $post_id, array( $coauthor->user_login ), true ); WP_CLI::line( sprintf( __( "Updating - Adding %s's byline to post #%d", 'co-authors-plus' ), $coauthor->user_login, $post_id ) ); $affected++; if ( $affected && 0 === $affected % 100 ) {