Permalink
Browse files

cli: When refreshing author terms, also create new terms for users th…

…at don't have them
  • Loading branch information...
danielbachhuber committed Jan 4, 2013
1 parent c9c1a04 commit 0dc033804af52fb838098b312750fefebe1754e3
Showing with 9 additions and 0 deletions.
  1. +9 −0 php/class-wp-cli.php
View
@@ -429,6 +429,15 @@ public function update_author_terms() {
$new_count = get_term_by( 'id', $author_term->term_id, $coauthors_plus->coauthor_taxonomy )->count;
WP_CLI::line( "Term {$author_term->slug} ({$author_term->term_id}) changed from {$old_count} to {$new_count} and the description was refreshed" );
}
+ // Create author terms for any users that don't have them
+ $users = get_users();
+ foreach( $users as $user ) {
+ $term = $coauthors_plus->get_author_term( $user );
+ if ( empty( $term ) || empty( $term->description ) ) {
+ $coauthors_plus->update_author_term( $user );
+ WP_CLI::line( "Created author term for {$user->user_login}" );
+ }
+ }
WP_CLI::success( "All done" );
}

0 comments on commit 0dc0338

Please sign in to comment.