Ticket #19826: 19826.diff
| File 19826.diff, 6.1 KB (added by , 12 years ago) |
|---|
-
wp-admin/edit.php
75 75 76 76 switch ( $doaction ) { 77 77 case 'trash': 78 $trashed = $ locked = 0;78 $trashed = $nottrashed = $locked = 0; 79 79 80 80 foreach( (array) $post_ids as $post_id ) { 81 if ( !current_user_can( 'delete_post', $post_id) ) 82 wp_die( __('You are not allowed to move this item to the Trash.') ); 81 if ( !current_user_can( 'delete_post', $post_id) ) { 82 $nottrashed++; 83 continue; 84 } 83 85 84 86 if ( wp_check_post_lock( $post_id ) ) { 85 87 $locked++; … … 92 94 $trashed++; 93 95 } 94 96 95 $sendback = add_query_arg( array( 'trashed' => $trashed, 'ids' => join(',', $post_ids), 'locked' => $locked ), $sendback );97 $sendback = add_query_arg( array( 'trashed' => $trashed, 'nottrashed' => $nottrashed, 'ids' => join(',', $post_ids), 'locked' => $locked ), $sendback ); 96 98 break; 97 99 case 'untrash': 98 $untrashed = 0;100 $untrashed = $notuntrashed = 0; 99 101 foreach( (array) $post_ids as $post_id ) { 100 if ( !current_user_can( 'delete_post', $post_id) ) 101 wp_die( __('You are not allowed to restore this item from the Trash.') ); 102 if ( !current_user_can( 'delete_post', $post_id) ) { 103 $notuntrashed++; 104 continue; 105 } 102 106 103 107 if ( !wp_untrash_post($post_id) ) 104 108 wp_die( __('Error in restoring from Trash.') ); 105 109 106 110 $untrashed++; 107 111 } 108 $sendback = add_query_arg( 'untrashed', $untrashed, $sendback);112 $sendback = add_query_arg( array( 'untrashed' => $untrashed, 'notuntrashed' => $notuntrashed ), $sendback ); 109 113 break; 110 114 case 'delete': 111 $deleted = 0;115 $deleted = $notdeleted = 0; 112 116 foreach( (array) $post_ids as $post_id ) { 113 117 $post_del = get_post($post_id); 114 118 115 if ( !current_user_can( 'delete_post', $post_id ) ) 116 wp_die( __('You are not allowed to delete this item.') ); 119 if ( !current_user_can( 'delete_post', $post_id ) ) { 120 $notdeleted++; 121 continue; 122 } 117 123 118 124 if ( $post_del->post_type == 'attachment' ) { 119 125 if ( ! wp_delete_attachment($post_id) ) … … 124 130 } 125 131 $deleted++; 126 132 } 127 $sendback = add_query_arg( 'deleted', $deleted, $sendback);133 $sendback = add_query_arg( array( 'deleted' => $deleted, 'notdeleted' => $notdeleted ), $sendback ); 128 134 break; 129 135 case 'edit': 130 136 if ( isset($_REQUEST['bulk_edit']) ) { … … 232 238 'untrashed' => isset( $_REQUEST['untrashed'] ) ? absint( $_REQUEST['untrashed'] ) : 0, 233 239 ); 234 240 241 $bulk_error_counts = array( 242 'notdeleted' => isset( $_REQUEST['notdeleted'] ) ? absint( $_REQUEST['notdeleted'] ) : 0, 243 'nottrashed' => isset( $_REQUEST['nottrashed'] ) ? absint( $_REQUEST['nottrashed'] ) : 0, 244 'notuntrashed' => isset( $_REQUEST['notuntrashed'] ) ? absint( $_REQUEST['notuntrashed'] ) : 0, 245 ); 246 235 247 $bulk_messages = array(); 236 248 $bulk_messages['post'] = array( 237 249 'updated' => _n( '%s post updated.', '%s posts updated.', $bulk_counts['updated'] ), … … 248 260 'untrashed' => _n( '%s page restored from the Trash.', '%s pages restored from the Trash.', $bulk_counts['untrashed'] ), 249 261 ); 250 262 263 $bulk_error_messages = array(); 264 $bulk_error_messages['post'] = array( 265 'notdeleted' => _n( '%s post not permanently deleted.', '%s posts not permanently deleted.', $bulk_error_counts['notdeleted'] ), 266 'nottrashed' => _n( '%s post not moved to the Trash.', '%s posts not moved to the Trash.', $bulk_error_counts['nottrashed'] ), 267 'notuntrashed' => _n( '%s post not restored from the Trash.', '%s posts not restored from the Trash.', $bulk_error_counts['notuntrashed'] ), 268 ); 269 $bulk_error_messages['page'] = array( 270 'notdeleted' => _n( '%s page not permanently deleted.', '%s pages not permanently deleted.', $bulk_error_counts['notdeleted'] ), 271 'nottrashed' => _n( '%s page not moved to the Trash.', '%s pages not moved to the Trash.', $bulk_error_counts['nottrashed'] ), 272 'notuntrashed' => _n( '%s page not restored from the Trash.', '%s pages not restored from the Trash.', $bulk_error_counts['notuntrashed'] ), 273 ); 274 251 275 /** 252 276 * Filter the bulk action updated messages. 253 277 * … … 262 286 $bulk_messages = apply_filters( 'bulk_post_updated_messages', $bulk_messages, $bulk_counts ); 263 287 $bulk_counts = array_filter( $bulk_counts ); 264 288 289 /** This filter documented in wp-admin/edit.php */ 290 $bulk_error_messages = apply_filters( 'bulk_post_updated_messages', $bulk_error_messages, $bulk_error_counts ); 291 $bulk_error_counts = array_filter( $bulk_error_counts ); 292 265 293 require_once( ABSPATH . 'wp-admin/admin-header.php' ); 266 294 ?> 267 295 <div class="wrap"> … … 276 304 <?php 277 305 // If we have a bulk message to issue: 278 306 $messages = array(); 307 $error_messages = array(); 279 308 foreach ( $bulk_counts as $message => $count ) { 280 309 if ( isset( $bulk_messages[ $post_type ][ $message ] ) ) 281 310 $messages[] = sprintf( $bulk_messages[ $post_type ][ $message ], number_format_i18n( $count ) ); … … 287 316 $messages[] = '<a href="' . esc_url( wp_nonce_url( "edit.php?post_type=$post_type&doaction=undo&action=untrash&ids=$ids", "bulk-posts" ) ) . '">' . __('Undo') . '</a>'; 288 317 } 289 318 } 319 foreach ( $bulk_error_counts as $message => $count ) { 320 if ( isset( $bulk_error_messages[ $post_type ][ $message ] ) ) 321 $error_messages[] = sprintf( $bulk_error_messages[ $post_type ][ $message ], number_format_i18n( $count ) ); 322 elseif ( isset( $bulk_error_messages['post'][ $message ] ) ) 323 $error_messages[] = sprintf( $bulk_error_messages['post'][ $message ], number_format_i18n( $count ) ); 324 } 290 325 291 326 if ( $messages ) 292 327 echo '<div id="message" class="updated"><p>' . join( ' ', $messages ) . '</p></div>'; 328 if ( $error_messages ) 329 echo '<div id="errormessage" class="error"><p>' . join( ' ', $error_messages ) . '</p></div>'; 293 330 unset( $messages ); 331 unset( $error_messgaes ); 294 332 295 $_SERVER['REQUEST_URI'] = remove_query_arg( array( 'locked', 'skipped', 'updated', 'deleted', 'trashed', 'untrashed' ), $_SERVER['REQUEST_URI'] );333 $_SERVER['REQUEST_URI'] = remove_query_arg( array( 'locked', 'skipped', 'updated', 'deleted', 'trashed', 'untrashed', 'notdeleted', 'nottrashed', 'notuntrashed' ), $_SERVER['REQUEST_URI'] ); 296 334 ?> 297 335 298 336 <?php $wp_list_table->views(); ?>