allowed_redirect_hosts
Filter HookDescription
Filters the list of allowed hosts to redirect to.Hook Information
File Location |
wp-includes/pluggable.php
View on GitHub
|
Hook Type | Filter |
Line Number | 1640 |
Hook Parameters
Type | Name | Description |
---|---|---|
string[]
|
$hosts
|
An array of allowed host names. |
string
|
$host
|
The host name of the redirect destination; empty string if not set. |
Usage Examples
Basic Usage
<?php
// Hook into allowed_redirect_hosts
add_filter('allowed_redirect_hosts', 'my_custom_filter', 10, 2);
function my_custom_filter($hosts, $host) {
// Your custom filtering logic here
return $hosts;
}
Source Code Context
wp-includes/pluggable.php:1640
- How this hook is used in WordPress core
<?php
1635 * @since 2.3.0
1636 *
1637 * @param string[] $hosts An array of allowed host names.
1638 * @param string $host The host name of the redirect destination; empty string if not set.
1639 */
1640 $allowed_hosts = (array) apply_filters( 'allowed_redirect_hosts', array( $wpp['host'] ), isset( $lp['host'] ) ? $lp['host'] : '' );
1641
1642 if ( isset( $lp['host'] ) && ( ! in_array( $lp['host'], $allowed_hosts, true ) && strtolower( $wpp['host'] ) !== $lp['host'] ) ) {
1643 $location = $fallback_url;
1644 }
1645
PHP Documentation
<?php
/**
* Filters the list of allowed hosts to redirect to.
*
* @since 2.3.0
*
* @param string[] $hosts An array of allowed host names.
* @param string $host The host name of the redirect destination; empty string if not set.
*/
Quick Info
- Hook Type: Filter
- Parameters: 2
- File: wp-includes/pluggable.php
Related Hooks
Related hooks will be displayed here in future updates.