Docs: Improve docblock for `$x_redirect_by` param in `wp_redirect()`.

The `$x_redirect_by` parameter is supported by `wp_redirect()` and `wp_safe_redirect()` to set the `X-Redirect-By` header.
It can be modified via the `x_redirect_by` filter.

This updates the docblock to clarify that `false` can be passed to disable sending the header, which was previously undocumented behavior.

Props kkmuffme, swissspidy.
Fixes #60209.
Built from https://develop.svn.wordpress.org/trunk@57693


git-svn-id: http://core.svn.wordpress.org/trunk@57194 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Pascal Birchler 2024-02-22 10:58:12 +00:00
parent 299b8ee2a1
commit 292af16439
2 changed files with 10 additions and 10 deletions

View File

@ -1377,9 +1377,9 @@ if ( ! function_exists( 'wp_redirect' ) ) :
* *
* @global bool $is_IIS * @global bool $is_IIS
* *
* @param string $location The path or URL to redirect to. * @param string $location The path or URL to redirect to.
* @param int $status Optional. HTTP response status code to use. Default '302' (Moved Temporarily). * @param int $status Optional. HTTP response status code to use. Default '302' (Moved Temporarily).
* @param string $x_redirect_by Optional. The application doing the redirect. Default 'WordPress'. * @param string|false $x_redirect_by Optional. The application doing the redirect or false to omit. Default 'WordPress'.
* @return bool False if the redirect was canceled, true otherwise. * @return bool False if the redirect was canceled, true otherwise.
*/ */
function wp_redirect( $location, $status = 302, $x_redirect_by = 'WordPress' ) { function wp_redirect( $location, $status = 302, $x_redirect_by = 'WordPress' ) {
@ -1426,9 +1426,9 @@ if ( ! function_exists( 'wp_redirect' ) ) :
* *
* @since 5.1.0 * @since 5.1.0
* *
* @param string $x_redirect_by The application doing the redirect. * @param string|false $x_redirect_by The application doing the redirect or false to omit the header.
* @param int $status Status code to use. * @param int $status Status code to use.
* @param string $location The path to redirect to. * @param string $location The path to redirect to.
*/ */
$x_redirect_by = apply_filters( 'x_redirect_by', $x_redirect_by, $status, $location ); $x_redirect_by = apply_filters( 'x_redirect_by', $x_redirect_by, $status, $location );
if ( is_string( $x_redirect_by ) ) { if ( is_string( $x_redirect_by ) ) {
@ -1520,9 +1520,9 @@ if ( ! function_exists( 'wp_safe_redirect' ) ) :
* @since 2.3.0 * @since 2.3.0
* @since 5.1.0 The return value from wp_redirect() is now passed on, and the `$x_redirect_by` parameter was added. * @since 5.1.0 The return value from wp_redirect() is now passed on, and the `$x_redirect_by` parameter was added.
* *
* @param string $location The path or URL to redirect to. * @param string $location The path or URL to redirect to.
* @param int $status Optional. HTTP response status code to use. Default '302' (Moved Temporarily). * @param int $status Optional. HTTP response status code to use. Default '302' (Moved Temporarily).
* @param string $x_redirect_by Optional. The application doing the redirect. Default 'WordPress'. * @param string|false $x_redirect_by Optional. The application doing the redirect or false to omit. Default 'WordPress'.
* @return bool False if the redirect was canceled, true otherwise. * @return bool False if the redirect was canceled, true otherwise.
*/ */
function wp_safe_redirect( $location, $status = 302, $x_redirect_by = 'WordPress' ) { function wp_safe_redirect( $location, $status = 302, $x_redirect_by = 'WordPress' ) {

View File

@ -16,7 +16,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '6.5-beta2-57692'; $wp_version = '6.5-beta2-57693';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.