Changeset 11749 for trunk/wp-admin/edit.php
- Timestamp:
- 07/30/2009 01:39:34 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/edit.php
r11743 r11749 19 19 20 20 // Handle bulk actions 21 if ( isset($_GET['action']) && ( -1 != $_GET['action'] || -1 != $_GET['action2'] ) ) { 22 $doaction = ( -1 != $_GET['action'] ) ? $_GET['action'] : $_GET['action2']; 23 21 if ( isset($_GET['doaction']) || isset($_GET['doaction2']) || isset($_GET['delete_all']) || isset($_GET['delete_all2']) ) { 22 check_admin_referer('bulk-posts'); 23 24 if (isset($_GET['delete_all']) || isset($_GET['delete_all2'])) { 25 $post_status = $wpdb->escape($_GET['post_status']); 26 $post_ids = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_type='post' AND post_status = '$post_status'" ); 27 $doaction = 'delete'; 28 } elseif (($_GET['action'] != -1 || $_GET['action2'] != -1) && isset($_GET['post'])) { 29 $post_ids = $_GET['post']; 30 $doaction = ($_GET['action'] != -1) ? $_GET['action'] : $_GET['action2']; 31 } else wp_redirect($_SERVER['HTTP_REFERER']); 32 24 33 switch ( $doaction ) { 34 case 'trash': 35 $trashed = 0; 36 foreach( (array) $post_ids as $post_id ) { 37 $post_del = & get_post($post_id); 38 39 if ( !current_user_can('delete_post', $post_id_del) ) 40 wp_die( __('You are not allowed to move this post to the trash.') ); 41 42 if ( !wp_trash_post($post_id) ) 43 wp_die( __('Error in moving to trash...') ); 44 45 $trashed++; 46 } 47 break; 48 case 'untrash': 49 $untrashed = 0; 50 foreach( (array) $post_ids as $post_id ) { 51 $post_del = & get_post($post_id); 52 53 if ( !current_user_can('delete_post', $post_id_del) ) 54 wp_die( __('You are not allowed to remove this post from the trash.') ); 55 56 if ( !wp_untrash_post($post_id) ) 57 wp_die( __('Error in removing from trash...') ); 58 59 $untrashed++; 60 } 61 break; 25 62 case 'delete': 26 if ( isset($_GET['post']) && ! isset($_GET['bulk_edit']) && (isset($_GET['doaction']) || isset($_GET['doaction2'])) ) { 27 check_admin_referer('bulk-posts'); 28 $deleted = 0; 29 foreach( (array) $_GET['post'] as $post_id_del ) { 30 $post_del = & get_post($post_id_del); 31 32 if ( !current_user_can('delete_post', $post_id_del) ) 33 wp_die( __('You are not allowed to delete this post.') ); 34 35 if ( $post_del->post_type == 'attachment' ) { 36 if ( ! wp_delete_attachment($post_id_del) ) 37 wp_die( __('Error in deleting...') ); 38 } else { 39 if ( !wp_delete_post($post_id_del) ) 40 wp_die( __('Error in deleting...') ); 41 } 42 $deleted++; 63 $deleted = 0; 64 foreach( (array) $post_ids as $post_id_del ) { 65 $post_del = & get_post($post_id_del); 66 67 if ( !current_user_can('delete_post', $post_id_del) ) 68 wp_die( __('You are not allowed to delete this post.') ); 69 70 if ( $post_del->post_type == 'attachment' ) { 71 if ( ! wp_delete_attachment($post_id_del) ) 72 wp_die( __('Error in deleting...') ); 73 } else { 74 if ( !wp_delete_post($post_id_del) ) 75 wp_die( __('Error in deleting...') ); 43 76 } 77 $deleted++; 44 78 } 45 79 break; 46 80 case 'edit': 47 if ( isset($_GET['post']) && isset($_GET['bulk_edit']) ) { 48 check_admin_referer('bulk-posts'); 49 50 if ( -1 == $_GET['_status'] ) { 51 $_GET['post_status'] = null; 52 unset($_GET['_status'], $_GET['post_status']); 53 } else { 54 $_GET['post_status'] = $_GET['_status']; 55 } 56 57 $done = bulk_edit_posts($_GET); 81 if ( -1 == $_GET['_status'] ) { 82 $_GET['post_status'] = null; 83 unset($_GET['_status'], $_GET['post_status']); 84 } else { 85 $_GET['post_status'] = $_GET['_status']; 58 86 } 87 88 $done = bulk_edit_posts($_GET); 59 89 break; 60 90 } … … 71 101 if ( isset($deleted) ) 72 102 $sendback = add_query_arg('deleted', $deleted, $sendback); 103 elseif ( isset($trashed) ) 104 $sendback = add_query_arg('trashed', $trashed, $sendback); 105 elseif ( isset($untrashed) ) 106 $sendback = add_query_arg('untrashed', $untrashed, $sendback); 73 107 wp_redirect($sendback); 74 108 exit(); … … 108 142 endif; ?> 109 143 110 <?php if ( isset($_GET['locked']) || isset($_GET['skipped']) || isset($_GET['updated']) || isset($_GET['deleted']) ) { ?>144 <?php if ( isset($_GET['locked']) || isset($_GET['skipped']) || isset($_GET['updated']) || isset($_GET['deleted']) || isset($_GET['trashed']) || isset($_GET['untrashed']) ) { ?> 111 145 <div id="message" class="updated fade"><p> 112 146 <?php if ( isset($_GET['updated']) && (int) $_GET['updated'] ) { … … 124 158 125 159 if ( isset($_GET['deleted']) && (int) $_GET['deleted'] ) { 126 printf( _n( 'Post deleted.', '%s postsdeleted.', $_GET['deleted'] ), number_format_i18n( $_GET['deleted'] ) );160 printf( _n( 'Post permanently deleted.', '%s posts permanently deleted.', $_GET['deleted'] ), number_format_i18n( $_GET['deleted'] ) ); 127 161 unset($_GET['deleted']); 162 } 163 164 if ( isset($_GET['trashed']) && (int) $_GET['trashed'] ) { 165 printf( _n( 'Post moved to the trash.', '%s posts moved to the trash.', $_GET['trashed'] ), number_format_i18n( $_GET['trashed'] ) ); 166 unset($_GET['deleted']); 167 } 168 169 if ( isset($_GET['untrashed']) && (int) $_GET['untrashed'] ) { 170 printf( _n( 'Post removed from the trash.', '%s posts removed from the trash.', $_GET['untrashed'] ), number_format_i18n( $_GET['untrashed'] ) ); 171 unset($_GET['undeleted']); 128 172 } 129 173 … … 140 184 $status_links = array(); 141 185 $num_posts = wp_count_posts( 'post', 'readable' ); 142 $total_posts = array_sum( (array) $num_posts ) ;186 $total_posts = array_sum( (array) $num_posts ) - $num_posts->trash; 143 187 $class = empty( $_GET['post_status'] ) ? ' class="current"' : ''; 144 188 $status_links[] = "<li><a href='edit.php' $class>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_posts, 'posts' ), number_format_i18n( $total_posts ) ) . '</a>'; … … 191 235 <select name="action"> 192 236 <option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option> 237 <?php if ($_GET['post_status'] == 'trash') { ?> 238 <option value="untrash"><?php _e('Restore'); ?></option> 239 <option value="delete"><?php _e('Delete Permanently'); ?></option> 240 <?php } else { ?> 193 241 <option value="edit"><?php _e('Edit'); ?></option> 194 <option value="delete"><?php _e('Delete'); ?></option> 242 <option value="trash"><?php _e('Move to Trash'); ?></option> 243 <?php } ?> 195 244 </select> 196 245 <input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" /> … … 236 285 ?> 237 286 <input type="submit" id="post-query-submit" value="<?php esc_attr_e('Filter'); ?>" class="button-secondary" /> 238 287 <?php } if ( $_GET['post_status'] == 'trash' ) { ?> 288 <input type="submit" name="delete_all" id="delete_all" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" /> 239 289 <?php } ?> 240 290 </div> … … 271 321 <select name="action2"> 272 322 <option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option> 323 <?php if ( $_GET['post_status'] == 'trash' ) { ?> 324 <option value="untrash"><?php _e('Restore'); ?></option> 325 <option value="delete"><?php _e('Delete Permanently'); ?></option> 326 <?php } else { ?> 273 327 <option value="edit"><?php _e('Edit'); ?></option> 274 <option value="delete"><?php _e('Delete'); ?></option> 328 <option value="trash"><?php _e('Move to Trash'); ?></option> 329 <?php } ?> 275 330 </select> 276 331 <input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" /> 332 <?php if ( $_GET['post_status'] == 'trash' ) { ?> 333 <input type="submit" name="delete_all2" id="delete_all2" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" /> 334 <?php } ?> 277 335 <br class="clear" /> 278 336 </div>
Note: See TracChangeset
for help on using the changeset viewer.