Skip to content
Open
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
8 changes: 4 additions & 4 deletions php/class-wp-cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,19 +205,19 @@ 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=<user-login> --coauthor=<coauthor>
* @synopsis --user_login=<user-login> --coauthor=<coauthor> [--append_coauthors]
*/
public function assign_user_to_coauthor( $args, $assoc_args ) {
global $coauthors_plus, $wpdb;

$defaults = array(
'user_login' => '',
'coauthor' => '',
'append_coauthors' => false,
);
$assoc_args = wp_parse_args( $assoc_args, $defaults );

Expand All @@ -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,
Expand All @@ -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 ) {
Expand Down