WordPress.org

Make WordPress Core

Ticket #23730: 23730.diff

File 23730.diff, 2.9 KB (added by benjmay, 14 months ago)
  • wp-admin/users.php

     
    8282function delete_users_add_js() { ?> 
    8383<script> 
    8484jQuery(document).ready( function($) { 
    85         var submit = $('#submit').prop('disabled', true); 
    86         $('input[name=delete_option]').one('change', function() { 
    87                 submit.prop('disabled', false); 
    88         }); 
    89         $('#reassign_user').focus( function() { 
    90                 $('#delete_option1').prop('checked', true).trigger('change'); 
    91         }); 
     85        if( $('#delete_option_hidden').length == 0 ) { 
     86                var submit = $('#submit').prop('disabled', true); 
     87                $('input[name=delete_option]').one('change', function() { 
     88                        submit.prop('disabled', false); 
     89                }); 
     90                $('#reassign_user').focus( function() { 
     91                        $('#delete_option1').prop('checked', true).trigger('change'); 
     92                }); 
     93        } 
    9294}); 
    9395</script> 
    9496<?php 
     
    209211        else 
    210212                $userids = array_map( 'intval', (array) $_REQUEST['users'] ); 
    211213 
     214        $users_posts = new WP_Query( array( 'post_type' => 'any', 'author' => implode( ',', $userids ) ) ); 
     215 
    212216        add_action( 'admin_head', 'delete_users_add_js' ); 
    213217 
    214218        include ('admin-header.php'); 
     
    241245        ?> 
    242246        </ul> 
    243247<?php if ( $go_delete ) : ?> 
    244         <fieldset><p><legend><?php echo _n( 'What should be done with posts owned by this user?', 'What should be done with posts owned by these users?', $go_delete ); ?></legend></p> 
    245         <ul style="list-style:none;"> 
    246                 <li><label><input type="radio" id="delete_option0" name="delete_option" value="delete" /> 
    247                 <?php _e('Delete all posts.'); ?></label></li> 
    248                 <li><input type="radio" id="delete_option1" name="delete_option" value="reassign" /> 
    249                 <?php echo '<label for="delete_option1">' . __( 'Attribute all posts to:' ) . '</label> '; 
    250                 wp_dropdown_users( array( 'name' => 'reassign_user', 'exclude' => array_diff( $userids, array($current_user->ID) ) ) ); ?></li> 
    251         </ul></fieldset> 
     248        <?php if( ! $users_posts->have_posts() ) : ?> 
     249                <input type="hidden" id="delete_option_hidden" name="delete_option" value="delete" /> 
     250        <?php else: ?> 
     251                <fieldset><p><legend><?php echo _n( 'What should be done with posts owned by this user?', 'What should be done with posts owned by these users?', $go_delete ); ?></legend></p> 
     252                <ul style="list-style:none;"> 
     253                        <li><label><input type="radio" id="delete_option0" name="delete_option" value="delete" /> 
     254                        <?php _e('Delete all posts.'); ?></label></li> 
     255                        <li><input type="radio" id="delete_option1" name="delete_option" value="reassign" /> 
     256                        <?php echo '<label for="delete_option1">' . __( 'Attribute all posts to:' ) . '</label> '; 
     257                        wp_dropdown_users( array( 'name' => 'reassign_user', 'exclude' => array_diff( $userids, array($current_user->ID) ) ) ); ?></li> 
     258                </ul></fieldset> 
     259        <?php endif; ?> 
    252260        <input type="hidden" name="action" value="dodelete" /> 
    253261        <?php submit_button( __('Confirm Deletion'), 'secondary' ); ?> 
    254262<?php else : ?>