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

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

Built from https://develop.svn.wordpress.org/trunk@34202


git-svn-id: http://core.svn.wordpress.org/trunk@34166 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2015-09-15 15:59:42 +00:00
parent b07b68490f
commit ff3ae0e747
5 changed files with 112 additions and 62 deletions

View File

@ -48,6 +48,17 @@ if ( 'category' == $taxonomy ) {
*/
do_action( 'edit_tag_form_pre', $tag );
}
/**
* Use with caution, see http://codex.wordpress.org/Function_Reference/wp_reset_vars
*/
wp_reset_vars( array( 'wp_http_referer' ) );
$wp_http_referer = remove_query_arg( array( 'action', 'message', 'tag_ID' ), $wp_http_referer );
/** Also used by Edit Tags */
require_once( ABSPATH . 'wp-admin/includes/edit-tag-messages.php' );
/**
* Fires before the Edit Term form for all taxonomies.
*
@ -63,7 +74,20 @@ do_action( "{$taxonomy}_pre_edit_form", $tag, $taxonomy ); ?>
<div class="wrap">
<h1><?php echo $tax->labels->edit_item; ?></h1>
<?php if ( $message ) : ?>
<div id="message" class="updated">
<p><strong><?php echo $message; ?></strong></p>
<?php if ( $wp_http_referer ) { ?>
<p><a href="<?php echo esc_url( $wp_http_referer ); ?>"><?php printf( __( '&larr; Back to %s' ), $tax->labels->name ); ?></a></p>
<?php } else { ?>
<p><a href="<?php echo esc_url( wp_get_referer() ); ?>"><?php printf( __( '&larr; Back to %s' ), $tax->labels->name ); ?></a></p>
<?php } ?>
</div>
<?php endif; ?>
<div id="ajax-response"></div>
<form name="edittag" id="edittag" method="post" action="edit-tags.php" class="validate"
<?php
/**

View File

@ -51,6 +51,7 @@ if ( 'post' != $post_type ) {
add_screen_option( 'per_page', array( 'default' => 20, 'option' => 'edit_' . $tax->name . '_per_page' ) );
$location = false;
$referer = wp_get_referer();
switch ( $wp_list_table->current_action() ) {
@ -71,9 +72,8 @@ case 'add-tag':
if ( 'post' != $post_type )
$location .= '&post_type=' . $post_type;
if ( $referer = wp_get_original_referer() ) {
if ( false !== strpos( $referer, 'edit-tags.php' ) )
$location = $referer;
if ( $referer && false !== strpos( $referer, 'edit-tags.php' ) ) {
$location = $referer;
}
if ( $ret && !is_wp_error( $ret ) )
@ -87,9 +87,9 @@ case 'delete':
$location = 'edit-tags.php?taxonomy=' . $taxonomy;
if ( 'post' != $post_type )
$location .= '&post_type=' . $post_type;
if ( $referer = wp_get_referer() ) {
if ( false !== strpos( $referer, 'edit-tags.php' ) )
$location = $referer;
if ( $referer && false !== strpos( $referer, 'edit-tags.php' ) ) {
$location = $referer;
}
if ( ! isset( $_REQUEST['tag_ID'] ) ) {
@ -132,9 +132,8 @@ case 'bulk-delete':
$location = 'edit-tags.php?taxonomy=' . $taxonomy;
if ( 'post' != $post_type )
$location .= '&post_type=' . $post_type;
if ( $referer = wp_get_referer() ) {
if ( false !== strpos( $referer, 'edit-tags.php' ) )
$location = $referer;
if ( $referer && false !== strpos( $referer, 'edit-tags.php' ) ) {
$location = $referer;
}
$location = add_query_arg( 'message', 6, $location );
@ -177,9 +176,8 @@ case 'editedtag':
if ( 'post' != $post_type )
$location .= '&post_type=' . $post_type;
if ( $referer = wp_get_original_referer() ) {
if ( false !== strpos( $referer, 'edit-tags.php' ) )
$location = $referer;
if ( $referer && false !== strpos( $referer, 'edit-tags.php' ) ) {
$location = $referer;
}
if ( $ret && !is_wp_error( $ret ) )
@ -285,51 +283,8 @@ if ( ! current_user_can( $tax->cap->edit_terms ) ) {
);
}
$messages = array();
$messages['_item'] = array(
0 => '', // Unused. Messages start at index 1.
1 => __( 'Item added.' ),
2 => __( 'Item deleted.' ),
3 => __( 'Item updated.' ),
4 => __( 'Item not added.' ),
5 => __( 'Item not updated.' ),
6 => __( 'Items deleted.' )
);
$messages['category'] = array(
0 => '', // Unused. Messages start at index 1.
1 => __( 'Category added.' ),
2 => __( 'Category deleted.' ),
3 => __( 'Category updated.' ),
4 => __( 'Category not added.' ),
5 => __( 'Category not updated.' ),
6 => __( 'Categories deleted.' )
);
$messages['post_tag'] = array(
0 => '', // Unused. Messages start at index 1.
1 => __( 'Tag added.' ),
2 => __( 'Tag deleted.' ),
3 => __( 'Tag updated.' ),
4 => __( 'Tag not added.' ),
5 => __( 'Tag not updated.' ),
6 => __( 'Tags deleted.' )
);
/**
* Filter the messages displayed when a tag is updated.
*
* @since 3.7.0
*
* @param array $messages The messages to be displayed.
*/
$messages = apply_filters( 'term_updated_messages', $messages );
$message = false;
if ( isset( $_REQUEST['message'] ) && ( $msg = (int) $_REQUEST['message'] ) ) {
if ( isset( $messages[ $taxonomy ][ $msg ] ) )
$message = $messages[ $taxonomy ][ $msg ];
elseif ( ! isset( $messages[ $taxonomy ] ) && isset( $messages['_item'][ $msg ] ) )
$message = $messages['_item'][ $msg ];
}
/** Also used by the Edit Tag form */
require_once( ABSPATH . 'wp-admin/includes/edit-tag-messages.php' );
$class = ( isset( $_REQUEST['error'] ) ) ? 'error' : 'updated';

View File

@ -359,9 +359,16 @@ class WP_Terms_List_Table extends WP_List_Table {
$name = apply_filters( 'term_name', $pad . ' ' . $tag->name, $tag );
$qe_data = get_term( $tag->term_id, $taxonomy, OBJECT, 'edit' );
$edit_link = esc_url( get_edit_term_link( $tag->term_id, $taxonomy, $this->screen->post_type ) );
$out = '<strong><a class="row-title" href="' . $edit_link . '" title="' . esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $name ) ) . '">' . $name . '</a></strong><br />';
$uri = ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ? wp_get_referer() : $_SERVER['REQUEST_URI'];
$edit_link = add_query_arg(
'wp_http_referer',
urlencode( wp_unslash( $uri ) ),
get_edit_term_link( $tag->term_id, $taxonomy, $this->screen->post_type )
);
$out = '<strong><a class="row-title" href="' . esc_url( $edit_link ) . '" title="' . esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $name ) ) . '">' . $name . '</a></strong><br />';
$out .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">';
$out .= '<div class="name">' . $qe_data->name . '</div>';
@ -405,11 +412,17 @@ class WP_Terms_List_Table extends WP_List_Table {
$tax = get_taxonomy( $taxonomy );
$default_term = get_option( 'default_' . $taxonomy );
$edit_link = esc_url( get_edit_term_link( $tag->term_id, $taxonomy, $this->screen->post_type ) );
$uri = ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ? wp_get_referer() : $_SERVER['REQUEST_URI'];
$edit_link = add_query_arg(
'wp_http_referer',
urlencode( wp_unslash( $uri ) ),
get_edit_term_link( $tag->term_id, $taxonomy, $this->screen->post_type )
);
$actions = array();
if ( current_user_can( $tax->cap->edit_terms ) ) {
$actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';
$actions['edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit' ) . '</a>';
$actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __( 'Quick&nbsp;Edit' ) . '</a>';
}
if ( current_user_can( $tax->cap->delete_terms ) && $tag->term_id != $default_term )

View File

@ -0,0 +1,58 @@
<?php
/**
* Edit Tags Administration: Messages
*
* @package WordPress
* @subpackage Administration
* @since 4.4.0
*/
$messages = array();
// 0 = unused. Messages start at index 1.
$messages['_item'] = array(
0 => '',
1 => __( 'Item added.' ),
2 => __( 'Item deleted.' ),
3 => __( 'Item updated.' ),
4 => __( 'Item not added.' ),
5 => __( 'Item not updated.' ),
6 => __( 'Items deleted.' ),
);
$messages['category'] = array(
0 => '',
1 => __( 'Category added.' ),
2 => __( 'Category deleted.' ),
3 => __( 'Category updated.' ),
4 => __( 'Category not added.' ),
5 => __( 'Category not updated.' ),
6 => __( 'Categories deleted.' ),
);
$messages['post_tag'] = array(
0 => '',
1 => __( 'Tag added.' ),
2 => __( 'Tag deleted.' ),
3 => __( 'Tag updated.' ),
4 => __( 'Tag not added.' ),
5 => __( 'Tag not updated.' ),
6 => __( 'Tags deleted.' ),
);
/**
* Filter the messages displayed when a tag is updated.
*
* @since 3.7.0
*
* @param array $messages The messages to be displayed.
*/
$messages = apply_filters( 'term_updated_messages', $messages );
$message = false;
if ( isset( $_REQUEST['message'] ) && ( $msg = (int) $_REQUEST['message'] ) ) {
if ( isset( $messages[ $taxonomy ][ $msg ] ) ) {
$message = $messages[ $taxonomy ][ $msg ];
} elseif ( ! isset( $messages[ $taxonomy ] ) && isset( $messages['_item'][ $msg ] ) ) {
$message = $messages['_item'][ $msg ];
}
}

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.4-alpha-34201';
$wp_version = '4.4-alpha-34202';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.