Make WordPress Core

Changeset 42647


Ignore:
Timestamp:
02/04/2018 04:04:10 PM (7 years ago)
Author:
johnbillion
Message:

Canonical: Add $x_redirect_by parameter to wp_safe_redirect().

See [42633] and [42408].

Fixes #42313.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/pluggable.php

    r42633 r42647  
    11871187     *
    11881188     * @since 1.5.1
     1189     * @since 5.0.0 The `$x_redirect_by` parameter was added.
    11891190     *
    11901191     * @global bool $is_IIS
     
    13241325     *
    13251326     * @since 2.3.0
    1326      * @since 5.0.0 The return value from wp_redirect() is now passed on.
    1327      *
    1328      * @param string $location The path or URL to redirect to.
    1329      * @param int    $status   Optional. HTTP response status code to use. Default '302' (Moved Temporarily).
    1330      * @return bool  $redirect False if the redirect was cancelled, true otherwise.
    1331      */
    1332     function wp_safe_redirect( $location, $status = 302 ) {
     1327     * @since 5.0.0 The return value from wp_redirect() is now passed on, and the `$x_redirect_by` parameter was added.
     1328     *
     1329     * @param string $location      The path or URL to redirect to.
     1330     * @param int    $status        Optional. HTTP response status code to use. Default '302' (Moved Temporarily).
     1331     * @param string $x_redirect_by Optional. The application doing the redirect. Default 'WordPress'.
     1332     * @return bool  $redirect False if the redirect was cancelled, true otherwise.
     1333     */
     1334    function wp_safe_redirect( $location, $status = 302, $x_redirect_by = 'WordPress' ) {
    13331335
    13341336        // Need to look at the URL the way it will end up in wp_redirect()
     
    13451347        $location = wp_validate_redirect( $location, apply_filters( 'wp_safe_redirect_fallback', admin_url(), $status ) );
    13461348
    1347         return wp_redirect( $location, $status );
     1349        return wp_redirect( $location, $status, $x_redirect_by );
    13481350    }
    13491351endif;
  • trunk/tests/phpunit/tests/pluggable.php

    r42633 r42647  
    184184            'wp_safe_redirect'                => array(
    185185                'location',
    186                 'status' => 302,
     186                'status'        => 302,
     187                'x_redirect_by' => 'WordPress',
    187188            ),
    188189            'wp_validate_redirect'            => array(
Note: See TracChangeset for help on using the changeset viewer.