Changeset 22166 for trunk/wp-admin/users.php
- Timestamp:
- 10/10/2012 02:07:59 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/users.php
r21501 r22166 76 76 $update = ''; 77 77 78 /** 79 * @since 3.5.0 80 * @access private 81 */ 82 function delete_users_add_js() { ?> 83 <script> 84 jQuery(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 }); 90 </script> 91 <?php 92 } 93 78 94 switch ( $wp_list_table->current_action() ) { 79 95 … … 132 148 } 133 149 150 $userids = array_map( 'intval', (array) $_REQUEST['users'] ); 151 152 if ( empty( $_REQUEST['delete_option'] ) ) { 153 $url = self_admin_url( 'users.php?action=delete&users[]=' . implode( '&users[]=', $userids ) . '&error=true' ); 154 $url = str_replace( '&', '&', wp_nonce_url( $url, 'bulk-users' ) ); 155 wp_redirect( $url ); 156 exit; 157 } 158 134 159 if ( ! current_user_can( 'delete_users' ) ) 135 160 wp_die(__('You can’t delete users.')); 136 161 137 $userids = $_REQUEST['users'];138 162 $update = 'del'; 139 163 $delete_count = 0; 140 164 141 foreach ( (array) $userids as $id) { 142 $id = (int) $id; 143 165 foreach ( $userids as $id ) { 144 166 if ( ! current_user_can( 'delete_user', $id ) ) 145 167 wp_die(__( 'You can’t delete that user.' ) ); … … 151 173 switch ( $_REQUEST['delete_option'] ) { 152 174 case 'delete': 153 if ( current_user_can('delete_user', $id) ) 154 wp_delete_user($id); 175 wp_delete_user( $id ); 155 176 break; 156 177 case 'reassign': 157 if ( current_user_can('delete_user', $id) ) 158 wp_delete_user($id, $_REQUEST['reassign_user']); 178 wp_delete_user( $id, $_REQUEST['reassign_user'] ); 159 179 break; 160 180 } … … 183 203 184 204 if ( empty($_REQUEST['users']) ) 185 $userids = array( intval($_REQUEST['user']));205 $userids = array( intval( $_REQUEST['user'] ) ); 186 206 else 187 $userids = (array) $_REQUEST['users']; 207 $userids = array_map( 'intval', (array) $_REQUEST['users'] ); 208 209 add_action( 'admin_head', 'delete_users_add_js' ); 188 210 189 211 include ('admin-header.php'); … … 196 218 <?php screen_icon(); ?> 197 219 <h2><?php _e('Delete Users'); ?></h2> 220 <?php if ( isset( $_REQUEST['error'] ) ) : ?> 221 <div class="error"> 222 <p><strong><?php _e( 'ERROR:' ); ?></strong> <?php _e( 'Please select an option.' ); ?></p> 223 </div> 224 <?php endif; ?> 198 225 <p><?php echo _n( 'You have specified this user for deletion:', 'You have specified these users for deletion:', count( $userids ) ); ?></p> 199 226 <ul> … … 201 228 $go_delete = 0; 202 229 foreach ( $userids as $id ) { 203 $id = (int) $id;204 230 $user = get_userdata( $id ); 205 231 if ( $id == $current_user->ID ) { … … 215 241 <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> 216 242 <ul style="list-style:none;"> 217 <li><label><input type="radio" id="delete_option0" name="delete_option" value="delete" checked="checked"/>243 <li><label><input type="radio" id="delete_option0" name="delete_option" value="delete" /> 218 244 <?php _e('Delete all posts.'); ?></label></li> 219 245 <li><input type="radio" id="delete_option1" name="delete_option" value="reassign" /> 220 <?php echo '<label for="delete_option1">' .__('Attribute all posts to:').'</label>';246 <?php echo '<label for="delete_option1">' . __( 'Attribute all posts to:' ) . '</label> '; 221 247 wp_dropdown_users( array( 'name' => 'reassign_user', 'exclude' => array_diff( $userids, array($current_user->ID) ) ) ); ?></li> 222 248 </ul></fieldset>
Note: See TracChangeset
for help on using the changeset viewer.