From 49b8ccec79641c49728fb67f2c3475b718e1f84b Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Thu, 10 Sep 2015 16:47:24 +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. Built from https://develop.svn.wordpress.org/trunk@34000 git-svn-id: http://core.svn.wordpress.org/trunk@33969 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/user.php | 19 ++++++++++++ wp-admin/users.php | 61 +++++++++++++++++--------------------- wp-includes/version.php | 2 +- 3 files changed, 47 insertions(+), 35 deletions(-) diff --git a/wp-admin/includes/user.php b/wp-admin/includes/user.php index 729ec1848d..22064602f6 100644 --- a/wp-admin/includes/user.php +++ b/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) ) ) ); ?>
  • +
+