Make WordPress Core

Changeset 34202


Ignore:
Timestamp:
09/15/2015 03:58:04 PM (9 years ago)
Author:
wonderboymusic
Message:

Don't redirect to the Term list table after submitting the form on the Edit Term page.

Props chiragswadia, UmeshSingla, rhyswynne, afercia.
Fixes #17455.

Location:
trunk/src/wp-admin
Files:
1 added
3 edited

Legend:

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

    r32974 r34202  
    4949    do_action( 'edit_tag_form_pre', $tag );
    5050}
     51
     52/**
     53 * Use with caution, see http://codex.wordpress.org/Function_Reference/wp_reset_vars
     54 */
     55wp_reset_vars( array( 'wp_http_referer' ) );
     56
     57$wp_http_referer = remove_query_arg( array( 'action', 'message', 'tag_ID' ), $wp_http_referer );
     58
     59/** Also used by Edit Tags */
     60require_once( ABSPATH . 'wp-admin/includes/edit-tag-messages.php' );
     61
    5162/**
    5263 * Fires before the Edit Term form for all taxonomies.
     
    6475<div class="wrap">
    6576<h1><?php echo $tax->labels->edit_item; ?></h1>
     77
     78<?php if ( $message ) : ?>
     79<div id="message" class="updated">
     80    <p><strong><?php echo $message; ?></strong></p>
     81    <?php if ( $wp_http_referer ) { ?>
     82    <p><a href="<?php echo esc_url( $wp_http_referer ); ?>"><?php printf( __( '&larr; Back to %s' ), $tax->labels->name ); ?></a></p>
     83    <?php } else { ?>
     84    <p><a href="<?php echo esc_url( wp_get_referer() ); ?>"><?php printf( __( '&larr; Back to %s' ), $tax->labels->name ); ?></a></p>
     85    <?php } ?>
     86</div>
     87<?php endif; ?>
     88
    6689<div id="ajax-response"></div>
     90
    6791<form name="edittag" id="edittag" method="post" action="edit-tags.php" class="validate"
    6892<?php
  • trunk/src/wp-admin/edit-tags.php

    r33917 r34202  
    5252
    5353$location = false;
     54$referer = wp_get_referer();
    5455
    5556switch ( $wp_list_table->current_action() ) {
     
    7273        $location .= '&post_type=' . $post_type;
    7374
    74     if ( $referer = wp_get_original_referer() ) {
    75         if ( false !== strpos( $referer, 'edit-tags.php' ) )
    76             $location = $referer;
     75    if ( $referer && false !== strpos( $referer, 'edit-tags.php' ) ) {
     76        $location = $referer;
    7777    }
    7878
     
    8888    if ( 'post' != $post_type )
    8989        $location .= '&post_type=' . $post_type;
    90     if ( $referer = wp_get_referer() ) {
    91         if ( false !== strpos( $referer, 'edit-tags.php' ) )
    92             $location = $referer;
     90
     91    if ( $referer && false !== strpos( $referer, 'edit-tags.php' ) ) {
     92        $location = $referer;
    9393    }
    9494
     
    133133    if ( 'post' != $post_type )
    134134        $location .= '&post_type=' . $post_type;
    135     if ( $referer = wp_get_referer() ) {
    136         if ( false !== strpos( $referer, 'edit-tags.php' ) )
    137             $location = $referer;
     135    if ( $referer && false !== strpos( $referer, 'edit-tags.php' ) ) {
     136        $location = $referer;
    138137    }
    139138
     
    178177        $location .= '&post_type=' . $post_type;
    179178
    180     if ( $referer = wp_get_original_referer() ) {
    181         if ( false !== strpos( $referer, 'edit-tags.php' ) )
    182             $location = $referer;
     179    if ( $referer && false !== strpos( $referer, 'edit-tags.php' ) ) {
     180        $location = $referer;
    183181    }
    184182
     
    286284}
    287285
    288 $messages = array();
    289 $messages['_item'] = array(
    290     0 => '', // Unused. Messages start at index 1.
    291     1 => __( 'Item added.' ),
    292     2 => __( 'Item deleted.' ),
    293     3 => __( 'Item updated.' ),
    294     4 => __( 'Item not added.' ),
    295     5 => __( 'Item not updated.' ),
    296     6 => __( 'Items deleted.' )
    297 );
    298 $messages['category'] = array(
    299     0 => '', // Unused. Messages start at index 1.
    300     1 => __( 'Category added.' ),
    301     2 => __( 'Category deleted.' ),
    302     3 => __( 'Category updated.' ),
    303     4 => __( 'Category not added.' ),
    304     5 => __( 'Category not updated.' ),
    305     6 => __( 'Categories deleted.' )
    306 );
    307 $messages['post_tag'] = array(
    308     0 => '', // Unused. Messages start at index 1.
    309     1 => __( 'Tag added.' ),
    310     2 => __( 'Tag deleted.' ),
    311     3 => __( 'Tag updated.' ),
    312     4 => __( 'Tag not added.' ),
    313     5 => __( 'Tag not updated.' ),
    314     6 => __( 'Tags deleted.' )
    315 );
    316 
    317 /**
    318  * Filter the messages displayed when a tag is updated.
    319  *
    320  * @since 3.7.0
    321  *
    322  * @param array $messages The messages to be displayed.
    323  */
    324 $messages = apply_filters( 'term_updated_messages', $messages );
    325 
    326 $message = false;
    327 if ( isset( $_REQUEST['message'] ) && ( $msg = (int) $_REQUEST['message'] ) ) {
    328     if ( isset( $messages[ $taxonomy ][ $msg ] ) )
    329         $message = $messages[ $taxonomy ][ $msg ];
    330     elseif ( ! isset( $messages[ $taxonomy ] ) && isset( $messages['_item'][ $msg ] ) )
    331         $message = $messages['_item'][ $msg ];
    332 }
     286/** Also used by the Edit Tag  form */
     287require_once( ABSPATH . 'wp-admin/includes/edit-tag-messages.php' );
    333288
    334289$class = ( isset( $_REQUEST['error'] ) ) ? 'error' : 'updated';
  • trunk/src/wp-admin/includes/class-wp-terms-list-table.php

    r34059 r34202  
    360360
    361361        $qe_data = get_term( $tag->term_id, $taxonomy, OBJECT, 'edit' );
    362         $edit_link = esc_url( get_edit_term_link( $tag->term_id, $taxonomy, $this->screen->post_type ) );
    363 
    364         $out = '<strong><a class="row-title" href="' . $edit_link . '" title="' . esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $name ) ) . '">' . $name . '</a></strong><br />';
     362
     363        $uri = ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ? wp_get_referer() : $_SERVER['REQUEST_URI'];
     364
     365        $edit_link = add_query_arg(
     366            'wp_http_referer',
     367            urlencode( wp_unslash( $uri ) ),
     368            get_edit_term_link( $tag->term_id, $taxonomy, $this->screen->post_type )
     369        );
     370
     371        $out = '<strong><a class="row-title" href="' . esc_url( $edit_link ) . '" title="' . esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $name ) ) . '">' . $name . '</a></strong><br />';
    365372
    366373        $out .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">';
     
    406413        $default_term = get_option( 'default_' . $taxonomy );
    407414
    408         $edit_link = esc_url( get_edit_term_link( $tag->term_id, $taxonomy, $this->screen->post_type ) );
     415        $uri = ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ? wp_get_referer() : $_SERVER['REQUEST_URI'];
     416
     417        $edit_link = add_query_arg(
     418            'wp_http_referer',
     419            urlencode( wp_unslash( $uri ) ),
     420            get_edit_term_link( $tag->term_id, $taxonomy, $this->screen->post_type )
     421        );
    409422
    410423        $actions = array();
    411424        if ( current_user_can( $tax->cap->edit_terms ) ) {
    412             $actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';
     425            $actions['edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit' ) . '</a>';
    413426            $actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __( 'Quick&nbsp;Edit' ) . '</a>';
    414427        }
Note: See TracChangeset for help on using the changeset viewer.