diff --git a/php/class-coauthors-guest-authors.php b/php/class-coauthors-guest-authors.php index 3c351884..2dd1678e 100644 --- a/php/class-coauthors-guest-authors.php +++ b/php/class-coauthors-guest-authors.php @@ -463,13 +463,34 @@ function view_guest_authors_list() { wp_die( esc_html( sprintf( __( "%s can't be deleted because it doesn't exist.", 'co-authors-plus' ), $this->labels['singular'] ) ) ); } + // get post count + global $coauthors_plus; + $term = $coauthors_plus->get_author_term( $guest_author ); + if ( $term ) { + $count = $term->count; + } else { + $count = 0; + } + echo '
'; echo '

'; echo '

' . esc_html( sprintf( __( 'Delete %s', 'co-authors-plus ' ), $this->labels['plural'] ) ) . '

'; echo '

' . esc_html( sprintf( __( 'You have specified this %s for deletion:', 'co-authors-plus' ), strtolower( $this->labels['singular'] ) ) ) . '

'; echo '

#' . esc_html( $guest_author->ID . ': ' . $guest_author->display_name ) . '

'; - echo '

' . esc_html( sprintf( __( 'What should be done with posts assigned to this %s?', 'co-authors-plus' ), strtolower( $this->labels['singular'] ) ) ) . '

'; - echo '

' . esc_html( sprintf( __( "Note: If you'd like to delete the %s and all of their posts, you should delete their posts first and then come back to delete the %s.", 'co-authors-plus' ), strtolower( $this->labels['singular'] ), strtolower( $this->labels['singular'] ) ) ) . '

'; + + if ( $count === 0 ) { + $post_count_message = '

' . esc_html( sprintf( __( 'There are %d posts associated with this guest author.', 'co-authors-plus' ), $count, strtolower( $this->labels['singular'] ) ) ) . '

'; + } + else if ( $count === 1 ) { + $post_count_message = '

' . esc_html( sprintf( __( 'There is %d post associated with this guest author. What should be done with the post assigned to this %s?', 'co-authors-plus' ), $count, strtolower( $this->labels['singular'] ) ) ) . '

'; + } + else { + $post_count_message = '

' . esc_html( sprintf( __( 'There are %d posts associated with this guest author. What should be done with the posts assigned to this %s?', 'co-authors-plus' ), $count, strtolower( $this->labels['singular'] ) ) ) . '

'; + } + echo $post_count_message; + if ( $count > 0 ) { + echo '

' . esc_html( sprintf( __( "Note: If you'd like to delete the %s and all of their posts, you should delete their posts first and then come back to delete the %s.", 'co-authors-plus' ), strtolower( $this->labels['singular'] ), strtolower( $this->labels['singular'] ) ) ) . '

'; + } echo '
'; // Hidden stuffs echo ''; @@ -477,22 +498,30 @@ function view_guest_authors_list() { echo ''; echo '
    '; // Reassign to another user - echo '
  • '; - echo ''; - echo '
  • '; - // Leave mapped to a linked account - if ( get_user_by( 'login', $guest_author->linked_account ) ) { - echo '
  • '; + if ( $count > 0 ) { + echo '
  • '; + echo ''; + echo '
  • '; + // Leave mapped to a linked account + if ( get_user_by( 'login', $guest_author->linked_account ) ) { + echo '
  • '; + } + // Remove bylines from the posts + echo '  ' . esc_html__( 'Remove byline from posts (but leave each post in its current status).', 'co-authors-plus' ); + } + else { + echo ''; } - // Remove bylines from the posts - echo '
  • '; echo '
'; - submit_button( __( 'Confirm Deletion', 'co-authors-plus' ), 'secondary', 'submit', true, array( 'disabled' => 'disabled' ) ); + if ( $count === 0 ) { + submit_button( __( 'Confirm Deletion', 'co-authors-plus' ), 'secondary', 'submit', true ); + } + else { + submit_button( __( 'Confirm Deletion', 'co-authors-plus' ), 'secondary', 'submit', true, array( 'disabled' => 'disabled' ) ); + } echo '
'; echo '
'; } else {