From 2deb9565c0b761a651f94ee706f129cc38162de5 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Thu, 10 Sep 2015 16:46:38 +0000 Subject: [PATCH] When deleting via User List Table, don't prompt for re-attribution if the user(s) do(es) not have any posts. Props rajnikmit, wojtek.szkutnik, benjmay, wonderboymusic. Fixes #6405. git-svn-id: https://develop.svn.wordpress.org/trunk@34000 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/user.php | 19 +++++++++++ src/wp-admin/users.php | 61 +++++++++++++++------------------- 2 files changed, 46 insertions(+), 34 deletions(-) diff --git a/src/wp-admin/includes/user.php b/src/wp-admin/includes/user.php index 729ec1848d..22064602f6 100644 --- a/src/wp-admin/includes/user.php +++ b/src/wp-admin/includes/user.php @@ -446,3 +446,22 @@ function default_password_nag() { printf( '' . __('No thanks, do not remind me again') . '', '?default_password_nag=0' ); echo '

'; } + +/** + * @since 3.5.0 + * @access private + */ +function delete_users_add_js() { ?> + + - -current_action() ) { /* Bulk Dropdown menu Role changes */ @@ -215,7 +196,15 @@ case 'delete': else $userids = array_map( 'intval', (array) $_REQUEST['users'] ); - add_action( 'admin_head', 'delete_users_add_js' ); + $users_posts = new WP_Query( array( + 'post_type' => 'any', + 'author' => implode( ',', $userids ), + 'posts_per_page' => 1 + ) ); + + if ( $users_posts->have_posts() ) { + add_action( 'admin_head', 'delete_users_add_js' ); + } include( ABSPATH . 'wp-admin/admin-header.php' ); ?> @@ -251,20 +240,24 @@ case 'delete': } ?> - - -

- -

- -
    -
  • -
  • - ' . __( 'Attribute all content to:' ) . ' '; - wp_dropdown_users( array( 'name' => 'reassign_user', 'exclude' => array_diff( $userids, array($current_user->ID) ) ) ); ?>
  • -
- have_posts() ) : ?> + + + +

+ +

+ +
    +
  • +
  • + ' . __( 'Attribute all content to:' ) . ' '; + wp_dropdown_users( array( 'name' => 'reassign_user', 'exclude' => array_diff( $userids, array($current_user->ID) ) ) ); ?>
  • +
+