From 95ef3d1d280f664b709cf32821cbe01d70f47d69 Mon Sep 17 00:00:00 2001 From: Erick Hitter <git-contrib@ethitter.com> Date: Thu, 14 Sep 2017 16:46:28 -0700 Subject: [PATCH] Fix how redirects are handled, as the current approach mangles queries by sending incorrect args --- includes/class-main.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/includes/class-main.php b/includes/class-main.php index b68c949..68672c2 100644 --- a/includes/class-main.php +++ b/includes/class-main.php @@ -245,18 +245,19 @@ class Main { * @param array $extra_keys Optional. Array of additional action keys to remove from redirect URL. */ public static function do_admin_redirect( $return_key, $succeeded = false, $extra_keys = array() ) { - $redirect = wp_unslash( $_SERVER['REQUEST_URI'] ); + $redirect = wp_get_referer(); + + if ( ! $redirect ) { + $redirect = wp_unslash( $_SERVER['REQUEST_URI'] ); + $redirect = remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), $redirect ); + } // Remove arguments that could re-trigger this bulk action. - $action_keys = array( '_wp_http_referer', '_wpnonce', 'action', 'action2', 'bulk_edit' ); + // Taken from wp-admin/edit.php. + $action_keys = array( 'action', 'action2', 'tags_input', 'post_author', 'comment_status', 'ping_status', '_status', 'post', 'bulk_edit', 'post_view' ); $action_keys = array_merge( $action_keys, $extra_keys ); $redirect = remove_query_arg( $action_keys, $redirect ); - // Also remove bulk action's arguments, to avoid a resubmit - $args = array( 'post', 'sticky', '_status' ); - $args = array_merge( $args, self::get_supported_vars() ); - $redirect = remove_query_arg( $args, $redirect ); - // Add a flag for the admin notice. $redirect = add_query_arg( $return_key, $succeeded ? 1 : -1, $redirect ); -- GitLab