Make WordPress Core

Ticket #26758: 26758.2.patch

File 26758.2.patch, 5.1 KB (added by afercia, 9 years ago)
  • src/wp-admin/edit-tag-form.php

     
    4848         */
    4949        do_action( 'edit_tag_form_pre', $tag );
    5050}
     51
    5152/**
     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$messages = array();
     60// 0 = unused. Messages start at index 1.
     61$messages['_item'] = array(
     62        0 => '',
     63        1 => __( 'Item added.' ),
     64        2 => __( 'Item deleted.' ),
     65        3 => __( 'Item updated.' ),
     66        4 => __( 'Item not added.' ),
     67        5 => __( 'Item not updated.' ),
     68        6 => __( 'Items deleted.' ),
     69);
     70$messages['category'] = array(
     71        0 => '',
     72        1 => __( 'Category added.' ),
     73        2 => __( 'Category deleted.' ),
     74        3 => __( 'Category updated.' ),
     75        4 => __( 'Category not added.' ),
     76        5 => __( 'Category not updated.' ),
     77        6 => __( 'Categories deleted.' ),
     78);
     79$messages['post_tag'] = array(
     80        0 => '',
     81        1 => __( 'Tag added.' ),
     82        2 => __( 'Tag deleted.' ),
     83        3 => __( 'Tag updated.' ),
     84        4 => __( 'Tag not added.' ),
     85        5 => __( 'Tag not updated.' ),
     86        6 => __( 'Tags deleted.' ),
     87);
     88
     89
     90/**
     91 * Filter the messages displayed when a tag is updated.
     92 *
     93 * @since 4.1.0
     94 *
     95 * @param array $messages The messages to be displayed.
     96 */
     97$messages = apply_filters( 'term_updated_messages', $messages );
     98
     99$message = false;
     100if ( isset( $_REQUEST['message'] ) && ( $msg = (int) $_REQUEST['message'] ) ) {
     101        if ( isset( $messages[ $taxonomy ][ $msg ] ) ) {
     102                $message = $messages[ $taxonomy ][ $msg ];
     103        } elseif ( ! isset( $messages[ $taxonomy ] ) && isset( $messages['_item'][ $msg ] ) ) {
     104                $message = $messages['_item'][ $msg ];
     105        }
     106}
     107
     108
     109/**
    52110 * Fires before the Edit Term form for all taxonomies.
    53111 *
    54112 * The dynamic portion of the hook name, `$taxonomy`, refers to
     
    63121
    64122<div class="wrap">
    65123<h1><?php echo $tax->labels->edit_item; ?></h1>
     124
     125<?php if ( $message ) : ?>
     126<div id="message" class="updated">
     127        <p><strong><?php echo $message; ?></strong></p>
     128        <?php if ( $wp_http_referer ) { ?>
     129        <p><a href="<?php echo esc_url( $wp_http_referer ); ?>"><?php printf( __( '&larr; Back to %s' ), $tax->labels->name ); ?></a></p>
     130        <?php } else { ?>
     131        <p><a href="<?php echo esc_url( wp_get_referer() ); ?>"><?php printf( __( '&larr; Back to %s' ), $tax->labels->name ); ?></a></p>
     132        <?php } ?>
     133</div>
     134<?php endif; ?>
     135
    66136<div id="ajax-response"></div>
     137
    67138<form name="edittag" id="edittag" method="post" action="edit-tags.php" class="validate"
    68139<?php
    69140/**
  • src/wp-admin/edit-tags.php

     
    7171        if ( 'post' != $post_type )
    7272                $location .= '&post_type=' . $post_type;
    7373
    74         if ( $referer = wp_get_original_referer() ) {
     74        if ( $referer = wp_get_referer() ) {
    7575                if ( false !== strpos( $referer, 'edit-tags.php' ) )
    7676                        $location = $referer;
    7777        }
     
    177177        if ( 'post' != $post_type )
    178178                $location .= '&post_type=' . $post_type;
    179179
    180         if ( $referer = wp_get_original_referer() ) {
     180        if ( $referer = wp_get_referer() ) {
    181181                if ( false !== strpos( $referer, 'edit-tags.php' ) )
    182182                        $location = $referer;
    183183        }
  • src/wp-admin/includes/class-wp-terms-list-table.php

     
    359359                $name = apply_filters( 'term_name', $pad . ' ' . $tag->name, $tag );
    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 ) );
    363362
     363                $doing_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX;
     364
     365                $uri = $doing_ajax ? wp_get_referer() : $_SERVER['REQUEST_URI'];
     366
     367                $edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $uri ) ), get_edit_term_link( $tag->term_id, $taxonomy, $this->screen->post_type ) ) );
     368
    364369                $out = '<strong><a class="row-title" href="' . $edit_link . '" title="' . esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $name ) ) . '">' . $name . '</a></strong><br />';
    365370
    366371                $out .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">';
     
    405410                $tax = get_taxonomy( $taxonomy );
    406411                $default_term = get_option( 'default_' . $taxonomy );
    407412
    408                 $edit_link = esc_url( get_edit_term_link( $tag->term_id, $taxonomy, $this->screen->post_type ) );
     413                $doing_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX;
    409414
     415                $uri = $doing_ajax ? wp_get_referer() : $_SERVER['REQUEST_URI'];
     416
     417                $edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $uri ) ), get_edit_term_link( $tag->term_id, $taxonomy, $this->screen->post_type ) ) );
     418
    410419                $actions = array();
    411420                if ( current_user_can( $tax->cap->edit_terms ) ) {
    412421                        $actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';