WordPress.org

Make WordPress Core

Changeset 33849


Ignore:
Timestamp:
09/02/2015 11:28:11 AM (4 years ago)
Author:
johnbillion
Message:

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

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/customize.php

    r33599 r33849  
    2222if ( $return ) {
    2323    $return = wp_unslash( $return );
     24    $return = remove_query_arg( wp_removable_query_args(), $return );
    2425    $return = wp_validate_redirect( $return );
    2526}
  • trunk/src/wp-admin/includes/misc.php

    r33770 r33849  
    866866 */
    867867function wp_admin_canonical_url() {
    868     $removable_query_args = array(
    869         'message', 'settings-updated', 'saved',
    870         'update', 'updated', 'activated',
    871         'activate', 'deactivate', 'locked',
    872         'deleted', 'trashed', 'untrashed',
    873         'enabled', 'disabled', 'skipped',
    874         'spammed', 'unspammed',
    875         'error',
    876     );
    877 
    878     /**
    879      * Filter the list of URL parameters to remove.
    880      *
    881      * @since 4.2.0
    882      *
    883      * @param array $removable_query_args An array of parameters to remove from the URL.
    884      */
    885     $removable_query_args = apply_filters( 'removable_query_args', $removable_query_args );
     868    $removable_query_args = wp_removable_query_args();
    886869
    887870    if ( empty( $removable_query_args ) ) {
  • trunk/src/wp-includes/functions.php

    r33747 r33849  
    823823    }
    824824    return add_query_arg( $key, false, $query );
     825}
     826
     827/**
     828 * Returns an array of single-use query variable names that can be removed from a URL.
     829 *
     830 * @since 4.4.0
     831 *
     832 * @return array An array of parameters to remove from the URL.
     833 */
     834function wp_removable_query_args() {
     835    $removable_query_args = array(
     836        'activate',
     837        'activated',
     838        'approved',
     839        'deactivate',
     840        'deleted',
     841        'disabled',
     842        'enabled',
     843        'error',
     844        'locked',
     845        'message',
     846        'same',
     847        'saved',
     848        'settings-updated',
     849        'skipped',
     850        'spammed',
     851        'trashed',
     852        'unspammed',
     853        'untrashed',
     854        'update',
     855        'updated',
     856    );
     857
     858    /**
     859     * Filter the list of query variables to remove.
     860     *
     861     * @since 4.2.0
     862     *
     863     * @param array $removable_query_args An array of query variables to remove from a URL.
     864     */
     865    return apply_filters( 'removable_query_args', $removable_query_args );
    825866}
    826867
Note: See TracChangeset for help on using the changeset viewer.