Make WordPress Core

Changeset 42633


Ignore:
Timestamp:
02/01/2018 03:05:50 PM (7 years ago)
Author:
SergeyBiryukov
Message:

Canonical: Add $x_redirect_by parameter to wp_redirect() that allows applications doing the redirect to identify themselves.

This complements the x_redirect_by filter added in [42408].

Props NathanAtmoz, johnbillion.
Fixes #42313.

Location:
trunk
Files:
2 edited

Legend:

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

    r42409 r42633  
    11901190     * @global bool $is_IIS
    11911191     *
    1192      * @param string $location The path or URL to redirect to.
    1193      * @param int    $status   Optional. HTTP response status code to use. Default '302' (Moved Temporarily).
     1192     * @param string $location      The path or URL to redirect to.
     1193     * @param int    $status        Optional. HTTP response status code to use. Default '302' (Moved Temporarily).
     1194     * @param string $x_redirect_by Optional. The application doing the redirect. Default 'WordPress'.
    11941195     * @return bool False if the redirect was cancelled, true otherwise.
    11951196     */
    1196     function wp_redirect( $location, $status = 302 ) {
     1197    function wp_redirect( $location, $status = 302, $x_redirect_by = 'WordPress' ) {
    11971198        global $is_IIS;
    11981199
     
    12381239         * @param string $location      The path to redirect to.
    12391240         */
    1240         $x_redirect_by = apply_filters( 'x_redirect_by', 'WordPress', $status, $location );
     1241        $x_redirect_by = apply_filters( 'x_redirect_by', $x_redirect_by, $status, $location );
    12411242        if ( is_string( $x_redirect_by ) ) {
    12421243            header( "X-Redirect-By: $x_redirect_by" );
  • trunk/tests/phpunit/tests/pluggable.php

    r42343 r42633  
    177177            'wp_redirect'                     => array(
    178178                'location',
    179                 'status' => 302,
     179                'status'        => 302,
     180                'x_redirect_by' => 'WordPress',
    180181            ),
    181182            'wp_sanitize_redirect'            => array( 'location' ),
Note: See TracChangeset for help on using the changeset viewer.