Changeset 11807 for trunk/wp-admin/edit-pages.php
- Timestamp:
- 08/12/2009 10:57:15 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/edit-pages.php
r11779 r11807 14 14 15 15 // Handle bulk actions 16 if ( isset($_GET['doaction']) || isset($_GET['doaction2']) || isset($_GET['delete_all']) || isset($_GET['delete_all2']) ) {16 if ( isset($_GET['doaction']) || isset($_GET['doaction2']) || isset($_GET['delete_all']) || isset($_GET['delete_all2']) || isset($_GET['bulk_edit']) ) { 17 17 check_admin_referer('bulk-pages'); 18 19 if (isset($_GET['delete_all']) || isset($_GET['delete_all2'])) { 20 $post_status = $wpdb->escape($_GET['post_status']); 21 $post_ids = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = '$post_status'" ); 18 $sendback = wp_get_referer(); 19 20 if ( strpos($sendback, 'page.php') !== false ) 21 $sendback = admin_url('page-new.php'); 22 23 if ( isset($_GET['delete_all']) || isset($_GET['delete_all2']) ) { 24 $post_status = preg_replace('/[^a-z0-9_-]+/i', '', $_GET['post_status']); 25 $post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = %s", $post_status ) ); 22 26 $doaction = 'delete'; 23 } elseif ( ($_GET['action'] != -1 || $_GET['action2'] != -1) && isset($_GET['post'])) {24 $post_ids = $_GET['post'];27 } elseif ( ($_GET['action'] != -1 || $_GET['action2'] != -1) && isset($_GET['post']) ) { 28 $post_ids = array_map( 'intval', (array) $_GET['post'] ); 25 29 $doaction = ($_GET['action'] != -1) ? $_GET['action'] : $_GET['action2']; 26 } else wp_redirect($_SERVER['HTTP_REFERER']); 30 } else { 31 wp_redirect( admin_url('edit-pages.php') ); 32 } 27 33 28 34 switch ( $doaction ) { … … 38 44 $trashed++; 39 45 } 46 $sendback = add_query_arg('trashed', $trashed, $sendback); 40 47 break; 41 48 case 'untrash': … … 43 50 foreach( (array) $post_ids as $post_id ) { 44 51 if ( !current_user_can('delete_page', $post_id) ) 45 wp_die( __('You are not allowed to re move this page from the trash.') );52 wp_die( __('You are not allowed to restore this page from the trash.') ); 46 53 47 54 if ( !wp_untrash_post($post_id) ) 48 wp_die( __('Error in re moving from trash...') );55 wp_die( __('Error in restoring from trash...') ); 49 56 50 57 $untrashed++; 51 58 } 59 $sendback = add_query_arg('untrashed', $untrashed, $sendback); 52 60 break; 53 61 case 'delete': 54 62 $deleted = 0; 55 foreach( (array) $post_ids as $post_id _del) {56 $post_del = & get_post($post_id _del);57 58 if ( !current_user_can('delete_page', $post_id _del) )63 foreach( (array) $post_ids as $post_id ) { 64 $post_del = & get_post($post_id); 65 66 if ( !current_user_can('delete_page', $post_id) ) 59 67 wp_die( __('You are not allowed to delete this page.') ); 60 68 61 69 if ( $post_del->post_type == 'attachment' ) { 62 if ( ! wp_delete_attachment($post_id _del) )70 if ( ! wp_delete_attachment($post_id) ) 63 71 wp_die( __('Error in deleting...') ); 64 72 } else { 65 if ( !wp_delete_post($post_id _del) )73 if ( !wp_delete_post($post_id) ) 66 74 wp_die( __('Error in deleting...') ); 67 75 } 68 76 $deleted++; 69 77 } 78 $sendback = add_query_arg('deleted', $deleted, $sendback); 70 79 break; 71 80 case 'edit': 72 if ( -1 == $_GET['_status'] ) { 73 $_GET['post_status'] = null; 74 unset($_GET['_status'], $_GET['post_status']); 75 } else { 76 $_GET['post_status'] = $_GET['_status']; 81 $_GET['post_type'] = 'page'; 82 $done = bulk_edit_posts($_GET); 83 84 if ( is_array($done) ) { 85 $done['updated'] = count( $done['updated'] ); 86 $done['skipped'] = count( $done['skipped'] ); 87 $done['locked'] = count( $done['locked'] ); 88 $sendback = add_query_arg( $done, $sendback ); 77 89 } 78 79 $done = bulk_edit_posts($_GET);80 90 break; 81 91 } 82 92 83 $sendback = wp_get_referer(); 84 if (strpos($sendback, 'page.php') !== false) $sendback = admin_url('page-new.php'); 85 elseif (strpos($sendback, 'attachments.php') !== false) $sendback = admin_url('attachments.php'); 86 if ( isset($done) ) { 87 $done['updated'] = count( $done['updated'] ); 88 $done['skipped'] = count( $done['skipped'] ); 89 $done['locked'] = count( $done['locked'] ); 90 $sendback = add_query_arg( $done, $sendback ); 91 } 92 if ( isset($deleted) ) 93 $sendback = add_query_arg('deleted', $deleted, $sendback); 94 elseif ( isset($trashed) ) 95 $sendback = add_query_arg('trashed', $trashed, $sendback); 96 elseif ( isset($untrashed) ) 97 $sendback = add_query_arg('untrashed', $untrashed, $sendback); 93 if ( isset($_GET['action']) ) 94 $sendback = remove_query_arg( array('action', 'action2', 'post_parent', 'page_template', 'post_author', 'comment_status', 'ping_status', '_status', 'post', 'bulk_edit', 'post_view', 'post_type'), $sendback ); 95 98 96 wp_redirect($sendback); 99 97 exit(); … … 182 180 endif; ?> 183 181 184 <form id="posts-filter" action=" " method="get">182 <form id="posts-filter" action="<?php echo admin_url('edit-pages.php'); ?>" method="get"> 185 183 <ul class="subsubsub"> 186 184 <?php
Note: See TracChangeset
for help on using the changeset viewer.