Changeset 11749 for trunk/wp-admin/edit-pages.php
- Timestamp:
- 07/30/2009 01:39:34 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/wp-admin/edit-pages.php (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/edit-pages.php
r11743 r11749 11 11 12 12 // Handle bulk actions 13 if ( isset($_GET['action']) && ( -1 != $_GET['action'] || -1 != $_GET['action2'] ) ) { 14 $doaction = ( -1 != $_GET['action'] ) ? $_GET['action'] : $_GET['action2']; 13 if ( isset($_GET['doaction']) || isset($_GET['doaction2']) || isset($_GET['delete_all']) || isset($_GET['delete_all2']) ) { 14 check_admin_referer('bulk-pages'); 15 16 if (isset($_GET['delete_all']) || isset($_GET['delete_all2'])) { 17 $post_status = $wpdb->escape($_GET['post_status']); 18 $post_ids = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = '$post_status'" ); 19 $doaction = 'delete'; 20 } elseif (($_GET['action'] != -1 || $_GET['action2'] != -1) && isset($_GET['post'])) { 21 $post_ids = $_GET['post']; 22 $doaction = ($_GET['action'] != -1) ? $_GET['action'] : $_GET['action2']; 23 } else wp_redirect($_SERVER['HTTP_REFERER']); 15 24 16 25 switch ( $doaction ) { 26 case 'trash': 27 $trashed = 0; 28 foreach( (array) $post_ids as $post_id ) { 29 if ( !current_user_can('delete_page', $post_id) ) 30 wp_die( __('You are not allowed to move this page to the trash.') ); 31 32 if ( !wp_trash_post($post_id) ) 33 wp_die( __('Error in moving to trash...') ); 34 35 $trashed++; 36 } 37 break; 38 case 'untrash': 39 $untrashed = 0; 40 foreach( (array) $post_ids as $post_id ) { 41 if ( !current_user_can('delete_page', $post_id) ) 42 wp_die( __('You are not allowed to remove this page from the trash.') ); 43 44 if ( !wp_untrash_post($post_id) ) 45 wp_die( __('Error in removing from trash...') ); 46 47 $untrashed++; 48 } 49 break; 17 50 case 'delete': 18 if ( isset($_GET['post']) && ! isset($_GET['bulk_edit']) && (isset($_GET['doaction']) || isset($_GET['doaction2'])) ) { 19 check_admin_referer('bulk-pages'); 20 $deleted = 0; 21 foreach( (array) $_GET['post'] as $post_id_del ) { 22 $post_del = & get_post($post_id_del); 23 24 if ( !current_user_can('delete_page', $post_id_del) ) 25 wp_die( __('You are not allowed to delete this page.') ); 26 27 if ( $post_del->post_type == 'attachment' ) { 28 if ( ! wp_delete_attachment($post_id_del) ) 29 wp_die( __('Error in deleting...') ); 30 } else { 31 if ( !wp_delete_post($post_id_del) ) 32 wp_die( __('Error in deleting...') ); 33 } 34 $deleted++; 51 $deleted = 0; 52 foreach( (array) $post_ids as $post_id_del ) { 53 $post_del = & get_post($post_id_del); 54 55 if ( !current_user_can('delete_page', $post_id_del) ) 56 wp_die( __('You are not allowed to delete this page.') ); 57 58 if ( $post_del->post_type == 'attachment' ) { 59 if ( ! wp_delete_attachment($post_id_del) ) 60 wp_die( __('Error in deleting...') ); 61 } else { 62 if ( !wp_delete_post($post_id_del) ) 63 wp_die( __('Error in deleting...') ); 35 64 } 65 $deleted++; 36 66 } 37 67 break; 38 68 case 'edit': 39 if ( isset($_GET['post']) && isset($_GET['bulk_edit']) ) { 40 check_admin_referer('bulk-pages'); 41 42 if ( -1 == $_GET['_status'] ) { 43 $_GET['post_status'] = null; 44 unset($_GET['_status'], $_GET['post_status']); 45 } else { 46 $_GET['post_status'] = $_GET['_status']; 47 } 48 49 $done = bulk_edit_posts($_GET); 69 if ( -1 == $_GET['_status'] ) { 70 $_GET['post_status'] = null; 71 unset($_GET['_status'], $_GET['post_status']); 72 } else { 73 $_GET['post_status'] = $_GET['_status']; 50 74 } 75 76 $done = bulk_edit_posts($_GET); 51 77 break; 52 78 } … … 63 89 if ( isset($deleted) ) 64 90 $sendback = add_query_arg('deleted', $deleted, $sendback); 91 elseif ( isset($trashed) ) 92 $sendback = add_query_arg('trashed', $trashed, $sendback); 93 elseif ( isset($untrashed) ) 94 $sendback = add_query_arg('untrashed', $untrashed, $sendback); 65 95 wp_redirect($sendback); 66 96 exit(); … … 80 110 'pending' => array(_x('Pending Review', 'page'), __('Pending pages'), _nx_noop('Pending Review <span class="count">(%s)</span>', 'Pending Review <span class="count">(%s)</span>', 'page')), 81 111 'draft' => array(_x('Draft', 'page'), _x('Drafts', 'manage posts header'), _nx_noop('Draft <span class="count">(%s)</span>', 'Drafts <span class="count">(%s)</span>', 'page')), 82 'private' => array(_x('Private', 'page'), __('Private pages'), _nx_noop('Private <span class="count">(%s)</span>', 'Private <span class="count">(%s)</span>', 'page')) 112 'private' => array(_x('Private', 'page'), __('Private pages'), _nx_noop('Private <span class="count">(%s)</span>', 'Private <span class="count">(%s)</span>', 'page')), 113 'trash' => array(_x('Trash', 'page'), __('Trash pages'), _nx_noop('Trash <span class="count">(%s)</span>', 'Trash <span class="count">(%s)</span>', 'page')) 83 114 ); 84 115 … … 112 143 </h2> 113 144 114 <?php if ( isset($_GET['locked']) || isset($_GET['skipped']) || isset($_GET['updated']) || isset($_GET['deleted']) ) { ?>145 <?php if ( isset($_GET['locked']) || isset($_GET['skipped']) || isset($_GET['updated']) || isset($_GET['deleted']) || isset($_GET['trashed']) || isset($_GET['untrashed']) ) { ?> 115 146 <div id="message" class="updated fade"><p> 116 147 <?php if ( isset($_GET['updated']) && (int) $_GET['updated'] ) { … … 118 149 unset($_GET['updated']); 119 150 } 120 121 151 if ( isset($_GET['skipped']) && (int) $_GET['skipped'] ) { 122 152 printf( _n( '%s page not updated, invalid parent page specified.', '%s pages not updated, invalid parent page specified.', $_GET['skipped'] ), number_format_i18n( $_GET['skipped'] ) ); 123 153 unset($_GET['skipped']); 124 154 } 125 126 155 if ( isset($_GET['locked']) && (int) $_GET['locked'] ) { 127 156 printf( _n( '%s page not updated, somebody is editing it.', '%s pages not updated, somebody is editing them.', $_GET['locked'] ), number_format_i18n( $_GET['skipped'] ) ); 128 157 unset($_GET['locked']); 129 158 } 130 131 159 if ( isset($_GET['deleted']) && (int) $_GET['deleted'] ) { 132 printf( _n( 'Page deleted.', '%s pagesdeleted.', $_GET['deleted'] ), number_format_i18n( $_GET['deleted'] ) );160 printf( _n( 'Page permanently deleted.', '%s pages permanently deleted.', $_GET['deleted'] ), number_format_i18n( $_GET['deleted'] ) ); 133 161 unset($_GET['deleted']); 134 162 } 135 $_SERVER['REQUEST_URI'] = remove_query_arg( array('locked', 'skipped', 'updated', 'deleted'), $_SERVER['REQUEST_URI'] ); 163 if ( isset($_GET['trashed']) && (int) $_GET['trashed'] ) { 164 printf( _n( 'Page moved to the trash.', '%s pages moved to the trash.', $_GET['trashed'] ), number_format_i18n( $_GET['trashed'] ) ); 165 unset($_GET['trashed']); 166 } 167 if ( isset($_GET['untrashed']) && (int) $_GET['untrashed'] ) { 168 printf( _n( 'Page removed from the trash.', '%s pages removed from the trash.', $_GET['untrashed'] ), number_format_i18n( $_GET['untrashed'] ) ); 169 unset($_GET['untrashed']); 170 } 171 $_SERVER['REQUEST_URI'] = remove_query_arg( array('locked', 'skipped', 'updated', 'deleted', 'trashed', 'untrashed'), $_SERVER['REQUEST_URI'] ); 136 172 ?> 137 173 </p></div> … … 151 187 $status_links = array(); 152 188 $num_posts = wp_count_posts('page', 'readable'); 153 $total_posts = array_sum( (array) $num_posts ) ;189 $total_posts = array_sum( (array) $num_posts ) - $num_posts->trash; 154 190 $class = empty($_GET['post_status']) ? ' class="current"' : ''; 155 191 $status_links[] = "<li><a href='edit-pages.php'$class>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_posts, 'pages' ), number_format_i18n( $total_posts ) ) . '</a>'; … … 213 249 <select name="action"> 214 250 <option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option> 251 <?php if ($_GET['post_status'] == 'trash') { ?> 252 <option value="untrash"><?php _e('Restore'); ?></option> 253 <option value="delete"><?php _e('Delete Permanently'); ?></option> 254 <?php } else { ?> 215 255 <option value="edit"><?php _e('Edit'); ?></option> 216 <option value="delete"><?php _e('Delete'); ?></option> 256 <option value="trash"><?php _e('Move to Trash'); ?></option> 257 <?php } ?> 217 258 </select> 218 259 <input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" /> 219 260 <?php wp_nonce_field('bulk-pages'); ?> 261 <?php if ($_GET['post_status'] == 'trash') { ?> 262 <input type="submit" name="delete_all" id="delete_all" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" /> 263 <?php } ?> 220 264 </div> 221 265 … … 252 296 <select name="action2"> 253 297 <option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option> 298 <?php if ($_GET['post_status'] == 'trash') { ?> 299 <option value="untrash"><?php _e('Restore'); ?></option> 300 <option value="delete"><?php _e('Delete Permanently'); ?></option> 301 <?php } else { ?> 254 302 <option value="edit"><?php _e('Edit'); ?></option> 255 <option value="delete"><?php _e('Delete'); ?></option> 303 <option value="trash"><?php _e('Move to Trash'); ?></option> 304 <?php } ?> 256 305 </select> 257 306 <input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" /> 307 <?php if ($_GET['post_status'] == 'trash') { ?> 308 <input type="submit" name="delete_all2" id="delete_all2" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" /> 309 <?php } ?> 258 310 </div> 259 311
Note: See TracChangeset
for help on using the changeset viewer.