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.
Built from https://develop.svn.wordpress.org/trunk@38750


git-svn-id: http://core.svn.wordpress.org/trunk@38693 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Dominik Schilling 2016-10-07 19:39:29 +00:00
parent ae2ff33c91
commit 0dcd49e6fc
2 changed files with 14 additions and 43 deletions

View File

@ -61,11 +61,14 @@ get_current_screen()->set_screen_reader_content( array(
$location = false;
$referer = wp_get_referer();
if ( ! $referer ) { // For POST requests.
$referer = wp_unslash( $_SERVER['REQUEST_URI'] );
}
$referer = remove_query_arg( array( '_wp_http_referer', '_wpnonce', 'error', 'message' ), $referer );
switch ( $wp_list_table->current_action() ) {
case 'add-tag':
check_admin_referer( 'add-tag', '_wpnonce_add-tag' );
if ( ! current_user_can( $tax->cap->edit_terms ) ) {
@ -77,30 +80,14 @@ case 'add-tag':
}
$ret = wp_insert_term( $_POST['tag-name'], $taxonomy, $_POST );
$location = 'edit-tags.php?taxonomy=' . $taxonomy;
if ( 'post' != $post_type )
$location .= '&post_type=' . $post_type;
if ( $referer && false !== strpos( $referer, 'edit-tags.php' ) ) {
$location = $referer;
}
if ( $ret && !is_wp_error( $ret ) )
$location = add_query_arg( 'message', 1, $location );
else
$location = add_query_arg( array( 'error' => true, 'message' => 4 ), $location );
$location = add_query_arg( array( 'error' => true, 'message' => 4 ), $referer );
break;
case 'delete':
$location = 'edit-tags.php?taxonomy=' . $taxonomy;
if ( 'post' != $post_type )
$location .= '&post_type=' . $post_type;
if ( $referer && false !== strpos( $referer, 'edit-tags.php' ) ) {
$location = $referer;
}
if ( ! isset( $_REQUEST['tag_ID'] ) ) {
break;
}
@ -118,7 +105,7 @@ case 'delete':
wp_delete_term( $tag_ID, $taxonomy );
$location = add_query_arg( 'message', 2, $location );
$location = add_query_arg( 'message', 2, $referer );
break;
@ -138,14 +125,7 @@ case 'bulk-delete':
wp_delete_term( $tag_ID, $taxonomy );
}
$location = 'edit-tags.php?taxonomy=' . $taxonomy;
if ( 'post' != $post_type )
$location .= '&post_type=' . $post_type;
if ( $referer && false !== strpos( $referer, 'edit-tags.php' ) ) {
$location = $referer;
}
$location = add_query_arg( 'message', 6, $location );
$location = add_query_arg( 'message', 6, $referer );
break;
@ -182,18 +162,11 @@ case 'editedtag':
$ret = wp_update_term( $tag_ID, $taxonomy, $_POST );
$location = 'edit-tags.php?taxonomy=' . $taxonomy;
if ( 'post' != $post_type )
$location .= '&post_type=' . $post_type;
if ( $referer && false !== strpos( $referer, 'edit-tags.php' ) ) {
$location = $referer;
if ( $ret && ! is_wp_error( $ret ) ) {
$location = add_query_arg( 'message', 3, $referer );
} else {
$location = add_query_arg( array( 'error' => true, 'message' => 5 ), $referer );
}
if ( $ret && !is_wp_error( $ret ) )
$location = add_query_arg( 'message', 3, $location );
else
$location = add_query_arg( array( 'error' => true, 'message' => 5 ), $location );
break;
default:
if ( ! $wp_list_table->current_action() || ! isset( $_REQUEST['delete_tags'] ) ) {
@ -218,13 +191,11 @@ default:
}
if ( ! $location && ! empty( $_REQUEST['_wp_http_referer'] ) ) {
$location = remove_query_arg( array('_wp_http_referer', '_wpnonce'), wp_unslash($_SERVER['REQUEST_URI']) );
$location = remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), wp_unslash( $_SERVER['REQUEST_URI'] ) );
}
if ( $location ) {
if ( ! empty( $_REQUEST['paged'] ) ) {
$location = add_query_arg( 'paged', (int) $_REQUEST['paged'], $location );
}
$location = add_query_arg( 'paged', $pagenum, $location ); // $pagenum takes care of $total_pages.
/**
* Filters the taxonomy redirect destination URL.

View File

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