From 606b6d15f1db6e9b5859ab3e33045537a9927816 Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Wed, 2 Sep 2015 11:29:23 +0000 Subject: [PATCH] Introduce `wp_removable_query_args()`, which returns an array of single-use query variables which can be removed from a URL. Also applies the function to the return URL when the Customizer is closed. Fixes #32692 Props swissspidy, Mte90 Built from https://develop.svn.wordpress.org/trunk@33849 git-svn-id: http://core.svn.wordpress.org/trunk@33817 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/customize.php | 1 + wp-admin/includes/misc.php | 19 +----------------- wp-includes/functions.php | 41 ++++++++++++++++++++++++++++++++++++++ wp-includes/version.php | 2 +- 4 files changed, 44 insertions(+), 19 deletions(-) diff --git a/wp-admin/customize.php b/wp-admin/customize.php index 6ee2de007a..bfc96233eb 100644 --- a/wp-admin/customize.php +++ b/wp-admin/customize.php @@ -21,6 +21,7 @@ $url = wp_unslash( $url ); $url = wp_validate_redirect( $url, home_url( '/' ) ); if ( $return ) { $return = wp_unslash( $return ); + $return = remove_query_arg( wp_removable_query_args(), $return ); $return = wp_validate_redirect( $return ); } if ( ! $return ) { diff --git a/wp-admin/includes/misc.php b/wp-admin/includes/misc.php index 83e7548175..d65d22b2d7 100644 --- a/wp-admin/includes/misc.php +++ b/wp-admin/includes/misc.php @@ -865,24 +865,7 @@ function post_form_autocomplete_off() { * @since 4.2.0 */ function wp_admin_canonical_url() { - $removable_query_args = array( - 'message', 'settings-updated', 'saved', - 'update', 'updated', 'activated', - 'activate', 'deactivate', 'locked', - 'deleted', 'trashed', 'untrashed', - 'enabled', 'disabled', 'skipped', - 'spammed', 'unspammed', - 'error', - ); - - /** - * Filter the list of URL parameters to remove. - * - * @since 4.2.0 - * - * @param array $removable_query_args An array of parameters to remove from the URL. - */ - $removable_query_args = apply_filters( 'removable_query_args', $removable_query_args ); + $removable_query_args = wp_removable_query_args(); if ( empty( $removable_query_args ) ) { return; diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 006cb6cb7e..9206f9bffd 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -824,6 +824,47 @@ function remove_query_arg( $key, $query = false ) { return add_query_arg( $key, false, $query ); } +/** + * Returns an array of single-use query variable names that can be removed from a URL. + * + * @since 4.4.0 + * + * @return array An array of parameters to remove from the URL. + */ +function wp_removable_query_args() { + $removable_query_args = array( + 'activate', + 'activated', + 'approved', + 'deactivate', + 'deleted', + 'disabled', + 'enabled', + 'error', + 'locked', + 'message', + 'same', + 'saved', + 'settings-updated', + 'skipped', + 'spammed', + 'trashed', + 'unspammed', + 'untrashed', + 'update', + 'updated', + ); + + /** + * Filter the list of query variables to remove. + * + * @since 4.2.0 + * + * @param array $removable_query_args An array of query variables to remove from a URL. + */ + return apply_filters( 'removable_query_args', $removable_query_args ); +} + /** * Walks the array while sanitizing the contents. * diff --git a/wp-includes/version.php b/wp-includes/version.php index ac0bd5fb8f..d19a8d1297 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.4-alpha-33848'; +$wp_version = '4.4-alpha-33849'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.