WordPress.org

Make WordPress Core

Changeset 38750


Ignore:
Timestamp:
10/07/2016 07:38:03 PM (20 months ago)
Author:
ocean90
Message:

Taxonomy: Don't drop term order and current page when bulk deleting terms.

  • Removes special handling for edit-tags.php which is no longer required because of term.php. Related: [34202] and [36308].
  • Sets $referer to $_SERVER['REQUEST_URI'] because wp_get_referer() returns false if $_SERVER['REQUEST_URI'] === $_REQUEST['_wp_http_referer'].
  • Sets paged always to $pagenum which is the value of $wp_list_table->get_pagenum();. This avoids an additional redirect when you delete an item which was previously on the last page.

Fixes #38194.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/edit-tags.php

    r38735 r38750  
    6262$location = false;
    6363$referer = wp_get_referer();
     64if ( ! $referer ) { // For POST requests.
     65    $referer = wp_unslash( $_SERVER['REQUEST_URI'] );
     66}
     67$referer = remove_query_arg( array( '_wp_http_referer', '_wpnonce', 'error', 'message' ), $referer );
    6468
    6569switch ( $wp_list_table->current_action() ) {
    6670
    6771case 'add-tag':
    68 
    6972    check_admin_referer( 'add-tag', '_wpnonce_add-tag' );
    7073
     
    7881
    7982    $ret = wp_insert_term( $_POST['tag-name'], $taxonomy, $_POST );
    80     $location = 'edit-tags.php?taxonomy=' . $taxonomy;
    81     if ( 'post' != $post_type )
    82         $location .= '&post_type=' . $post_type;
    83 
    84     if ( $referer && false !== strpos( $referer, 'edit-tags.php' ) ) {
    85         $location = $referer;
    86     }
    87 
    8883    if ( $ret && !is_wp_error( $ret ) )
    8984        $location = add_query_arg( 'message', 1, $location );
    9085    else
    91         $location = add_query_arg( array( 'error' => true, 'message' => 4 ), $location );
     86        $location = add_query_arg( array( 'error' => true, 'message' => 4 ), $referer );
    9287
    9388    break;
    9489
    9590case 'delete':
    96     $location = 'edit-tags.php?taxonomy=' . $taxonomy;
    97     if ( 'post' != $post_type )
    98         $location .= '&post_type=' . $post_type;
    99 
    100     if ( $referer && false !== strpos( $referer, 'edit-tags.php' ) ) {
    101         $location = $referer;
    102     }
    103 
    10491    if ( ! isset( $_REQUEST['tag_ID'] ) ) {
    10592        break;
     
    119106    wp_delete_term( $tag_ID, $taxonomy );
    120107
    121     $location = add_query_arg( 'message', 2, $location );
     108    $location = add_query_arg( 'message', 2, $referer );
    122109
    123110    break;
     
    139126    }
    140127
    141     $location = 'edit-tags.php?taxonomy=' . $taxonomy;
    142     if ( 'post' != $post_type )
    143         $location .= '&post_type=' . $post_type;
    144     if ( $referer && false !== strpos( $referer, 'edit-tags.php' ) ) {
    145         $location = $referer;
    146     }
    147 
    148     $location = add_query_arg( 'message', 6, $location );
     128    $location = add_query_arg( 'message', 6, $referer );
    149129
    150130    break;
     
    183163    $ret = wp_update_term( $tag_ID, $taxonomy, $_POST );
    184164
    185     $location = 'edit-tags.php?taxonomy=' . $taxonomy;
    186     if ( 'post' != $post_type )
    187         $location .= '&post_type=' . $post_type;
    188 
    189     if ( $referer && false !== strpos( $referer, 'edit-tags.php' ) ) {
    190         $location = $referer;
    191     }
    192 
    193     if ( $ret && !is_wp_error( $ret ) )
    194         $location = add_query_arg( 'message', 3, $location );
    195     else
    196         $location = add_query_arg( array( 'error' => true, 'message' => 5 ), $location );
     165    if ( $ret && ! is_wp_error( $ret ) ) {
     166        $location = add_query_arg( 'message', 3, $referer );
     167    } else {
     168        $location = add_query_arg( array( 'error' => true, 'message' => 5 ), $referer );
     169    }
    197170    break;
    198171default:
     
    219192
    220193if ( ! $location && ! empty( $_REQUEST['_wp_http_referer'] ) ) {
    221     $location = remove_query_arg( array('_wp_http_referer', '_wpnonce'), wp_unslash($_SERVER['REQUEST_URI']) );
     194    $location = remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), wp_unslash( $_SERVER['REQUEST_URI'] ) );
    222195}
    223196
    224197if ( $location ) {
    225     if ( ! empty( $_REQUEST['paged'] ) ) {
    226         $location = add_query_arg( 'paged', (int) $_REQUEST['paged'], $location );
    227     }
     198    $location = add_query_arg( 'paged', $pagenum, $location ); // $pagenum takes care of $total_pages.
    228199
    229200    /**
Note: See TracChangeset for help on using the changeset viewer.