Make WordPress Core

Ticket #15416: garyc40-15416-revised.patch

File garyc40-15416-revised.patch, 3.5 KB (added by garyc40, 12 years ago)

removed prop changes from patch

  • wp-admin/edit-comments.php

     
    1313
    1414$wp_list_table = get_list_table('WP_Comments_List_Table');
    1515$wp_list_table->check_permissions();
     16$pagenum = $wp_list_table->get_pagenum();
    1617
    1718$doaction = $wp_list_table->current_action();
    1819
     
    3738        $approved = $unapproved = $spammed = $unspammed = $trashed = $untrashed = $deleted = 0;
    3839        $redirect_to = remove_query_arg( array( 'trashed', 'untrashed', 'deleted', 'spammed', 'unspammed', 'approved', 'unapproved', 'ids' ), wp_get_referer() );
    3940
     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
    4046        foreach ( $comment_ids as $comment_id ) { // Check the permissions on each
    4147                if ( !current_user_can( 'edit_comment', $comment_id ) )
    4248                        continue;
     
    99105
    100106$wp_list_table->prepare_items();
    101107
     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' );
     111if ( $pagenum > $total_pages && $total_pages > 0 ) {
     112        wp_redirect( add_query_arg( 'paged', $total_pages ) );
     113        exit;
     114}
     115
    102116wp_enqueue_script('admin-comments');
    103117enqueue_comment_hotkeys_js();
    104118
  • wp-admin/edit.php

     
    1010require_once( './admin.php' );                 
    1111$wp_list_table = get_list_table('WP_Posts_List_Table');
    1212$wp_list_table->check_permissions();
     13$pagenum = $wp_list_table->get_pagenum();
    1314
    1415// Back-compat for viewing comments of an entry
    1516foreach ( array( 'p', 'attachment_id', 'page_id' ) as $_redirect ) {
     
    2627if ( $doaction ) {
    2728        check_admin_referer('bulk-posts');
    2829        $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 );
    2935
    3036        if ( strpos($sendback, 'post.php') !== false )
    3137                $sendback = admin_url($post_new_file);
     
    6066
    6167                                $trashed++;
    6268                        }
    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 );
    6470                        break;
    6571                case 'untrash':
    6672                        $untrashed = 0;
     
    127133
    128134$wp_list_table->prepare_items();
    129135
     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' );
     139if ( $pagenum > $total_pages && $total_pages > 0 ) {
     140        wp_redirect( add_query_arg( 'paged', $total_pages ) );
     141        exit;
     142}
     143
    130144wp_enqueue_script('inline-edit-post');
    131145
    132146$title = $post_type_object->labels->name;