Ticket #15416: garyc40-15416-revised.patch
File garyc40-15416-revised.patch, 3.5 KB (added by , 12 years ago) |
---|
-
wp-admin/edit-comments.php
13 13 14 14 $wp_list_table = get_list_table('WP_Comments_List_Table'); 15 15 $wp_list_table->check_permissions(); 16 $pagenum = $wp_list_table->get_pagenum(); 16 17 17 18 $doaction = $wp_list_table->current_action(); 18 19 … … 37 38 $approved = $unapproved = $spammed = $unspammed = $trashed = $untrashed = $deleted = 0; 38 39 $redirect_to = remove_query_arg( array( 'trashed', 'untrashed', 'deleted', 'spammed', 'unspammed', 'approved', 'unapproved', 'ids' ), wp_get_referer() ); 39 40 41 // Fix the problem with wrong page number. This happens when the user use the javascript 42 // pagination feature to navigate to a certain page, then does some bulk actions there, 43 // he will be redirected back to te original page number instead of the navigated one. 44 $redirect_to = add_query_arg( 'paged', $pagenum, $redirect_to ); 45 40 46 foreach ( $comment_ids as $comment_id ) { // Check the permissions on each 41 47 if ( !current_user_can( 'edit_comment', $comment_id ) ) 42 48 continue; … … 99 105 100 106 $wp_list_table->prepare_items(); 101 107 108 // redirect to the last page if the page number is larger than the total number of pages 109 // this can happen when all the items in the last page are deleted, for example 110 $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); 111 if ( $pagenum > $total_pages && $total_pages > 0 ) { 112 wp_redirect( add_query_arg( 'paged', $total_pages ) ); 113 exit; 114 } 115 102 116 wp_enqueue_script('admin-comments'); 103 117 enqueue_comment_hotkeys_js(); 104 118 -
wp-admin/edit.php
10 10 require_once( './admin.php' ); 11 11 $wp_list_table = get_list_table('WP_Posts_List_Table'); 12 12 $wp_list_table->check_permissions(); 13 $pagenum = $wp_list_table->get_pagenum(); 13 14 14 15 // Back-compat for viewing comments of an entry 15 16 foreach ( array( 'p', 'attachment_id', 'page_id' ) as $_redirect ) { … … 26 27 if ( $doaction ) { 27 28 check_admin_referer('bulk-posts'); 28 29 $sendback = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'ids'), wp_get_referer() ); 30 31 // Fix the problem with wrong page number. This happens when the user use the javascript 32 // pagination feature to navigate to a certain page, then does some bulk actions there, 33 // he will be redirected back to te original page number instead of the navigated one. 34 $sendback = add_query_arg( 'paged', $pagenum, $sendback ); 29 35 30 36 if ( strpos($sendback, 'post.php') !== false ) 31 37 $sendback = admin_url($post_new_file); … … 60 66 61 67 $trashed++; 62 68 } 63 $sendback = add_query_arg( array('trashed' => $trashed, 'ids' => join(',', $post_ids) ), $sendback );69 $sendback = add_query_arg( array('trashed' => $trashed, 'ids' => join(',', $post_ids) ), $sendback ); 64 70 break; 65 71 case 'untrash': 66 72 $untrashed = 0; … … 127 133 128 134 $wp_list_table->prepare_items(); 129 135 136 // redirect to the last page if the page number is larger than the total number of pages 137 // this can happen when all the items in the last page are deleted, for example 138 $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); 139 if ( $pagenum > $total_pages && $total_pages > 0 ) { 140 wp_redirect( add_query_arg( 'paged', $total_pages ) ); 141 exit; 142 } 143 130 144 wp_enqueue_script('inline-edit-post'); 131 145 132 146 $title = $post_type_object->labels->name;