WordPress.org

Make WordPress Core

Ticket #16356: garyc40.16356.diff

File garyc40.16356.diff, 4.1 KB (added by garyc40, 4 years ago)

fix redirection inconsistencies in edit-tags.php, users.php, network/users.php

  • wp-admin/edit-tags.php

    diff --git wp-admin/edit-tags.php wp-admin/edit-tags.php
    index 13534de..eaec36c 100644
    if ( !current_user_can( $tax->cap->manage_terms ) ) 
    1313        wp_die( __( 'Cheatin’ uh?' ) ); 
    1414 
    1515$wp_list_table = _get_list_table('WP_Terms_List_Table'); 
     16$pagenum = $wp_list_table->get_pagenum(); 
    1617 
    1718$title = $tax->labels->name; 
    1819 
    case 'editedtag': 
    148149break; 
    149150 
    150151default: 
    151  
    152152if ( ! empty($_REQUEST['_wp_http_referer']) ) { 
    153          wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) ); 
    154          exit; 
     153        $location = remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ); 
     154 
     155        if ( ! empty( $_REQUEST['paged'] ) ) 
     156                $location = add_query_arg( 'paged', $_REQUEST['paged'] ); 
     157         
     158        wp_redirect( $location ); 
     159        exit; 
    155160} 
    156161 
    157162$wp_list_table->prepare_items(); 
     163$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); 
     164 
     165if ( $pagenum > $total_pages ) { 
     166        wp_redirect( add_query_arg( 'paged', $total_pages ) ); 
     167        exit; 
     168} 
    158169 
    159170wp_enqueue_script('admin-tags'); 
    160171if ( current_user_can($tax->cap->edit_terms) ) 
  • wp-admin/network/edit.php

    diff --git wp-admin/network/edit.php wp-admin/network/edit.php
    index 1e06e49..9d680b4 100644
    switch ( $_GET['action'] ) { 
    427427 
    428428                        wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => $userfunction ), wp_get_referer() ) ); 
    429429                } else { 
    430                         wp_redirect( network_admin_url( 'users.php' ) ); 
     430                        $location = network_admin_url( 'users.php' ); 
     431 
     432                        if ( ! empty( $_REQUEST['paged'] ) ) 
     433                                $location = add_query_arg( 'paged', $_REQUEST['paged'], $location ); 
     434                        wp_redirect( $location ); 
    431435                } 
    432436                exit(); 
    433437        break; 
  • wp-admin/network/users.php

    diff --git wp-admin/network/users.php wp-admin/network/users.php
    index eb59670..c87bfd3 100644
    if ( ! current_user_can( 'manage_network_users' ) ) 
    1717        wp_die( __( 'You do not have permission to access this page.' ) ); 
    1818 
    1919$wp_list_table = _get_list_table('WP_MS_Users_List_Table'); 
     20$pagenum = $wp_list_table->get_pagenum(); 
    2021$wp_list_table->prepare_items(); 
     22$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); 
    2123 
     24if ( $pagenum > $total_pages ) { 
     25        wp_redirect( add_query_arg( 'paged', $total_pages ) ); 
     26        exit; 
     27} 
    2228$title = __( 'Users' ); 
    2329$parent_file = 'users.php'; 
    2430 
  • wp-admin/users.php

    diff --git wp-admin/users.php wp-admin/users.php
    index 8f08211..78d9ad8 100644
    if ( ! current_user_can( 'list_users' ) ) 
    1313        wp_die( __( 'Cheatin’ uh?' ) ); 
    1414 
    1515$wp_list_table = _get_list_table('WP_Users_List_Table'); 
    16  
     16$pagenum = $wp_list_table->get_pagenum(); 
    1717$title = __('Users'); 
    1818$parent_file = 'users.php'; 
    1919 
    default: 
    290290        } 
    291291 
    292292        $wp_list_table->prepare_items(); 
    293  
     293        $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); 
     294        if ( $pagenum > $total_pages ) { 
     295                wp_redirect( add_query_arg( 'paged', $total_pages ) ); 
     296                exit; 
     297        } 
    294298        include('./admin-header.php'); 
    295299 
    296300        $messages = array(); 
  • wp-includes/user.php

    diff --git wp-includes/user.php wp-includes/user.php
    index e39d19e..2a1a101 100644
    class WP_User_Query { 
    542542         */ 
    543543        function query() { 
    544544                global $wpdb; 
    545  
     545                 
    546546                if ( is_array( $this->query_vars['fields'] ) || 'all' == $this->query_vars['fields'] ) { 
    547547                        $this->results = $wpdb->get_results("SELECT $this->query_fields $this->query_from $this->query_where $this->query_orderby $this->query_limit"); 
    548548                } else { 
    549549                        $this->results = $wpdb->get_col("SELECT $this->query_fields $this->query_from $this->query_where $this->query_orderby $this->query_limit"); 
    550550                } 
     551                 
     552                if ( $this->query_vars['count_total'] ) 
     553                        $this->total_users = $wpdb->get_var("SELECT COUNT(*) $this->query_from $this->query_where"); 
    551554 
    552555                if ( !$this->results ) 
    553556                        return; 
    554557 
    555                 if ( $this->query_vars['count_total'] ) 
    556                         $this->total_users = $wpdb->get_var("SELECT COUNT(*) $this->query_from $this->query_where"); 
    557  
    558558                if ( 'all_with_meta' == $this->query_vars['fields'] ) { 
    559559                        cache_users( $this->results ); 
    560560