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
This commit is contained in:
John Blackbourn 2015-09-02 11:29:23 +00:00
parent 9666aec8d1
commit 606b6d15f1
4 changed files with 44 additions and 19 deletions

View File

@ -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 ) {

View File

@ -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;

View File

@ -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.
*

View File

@ -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.