allowed_redirect_hosts хук-фильтрWP 2.3.0

Filters the list of allowed hosts to redirect to.

Использование

add_filter( 'allowed_redirect_hosts', 'wp_kama_allowed_redirect_hosts_filter', 10, 2 );

/**
 * Function for `allowed_redirect_hosts` filter-hook.
 * 
 * @param string[] $hosts An array of allowed host names.
 * @param string   $host  The host name of the redirect destination; empty string if not set.
 *
 * @return string[]
 */
function wp_kama_allowed_redirect_hosts_filter( $hosts, $host ){

	// filter...
	return $hosts;
}
$hosts(string[])
An array of allowed host names.
$host(строка)
The host name of the redirect destination; empty string if not set.

Список изменений

С версии 2.3.0 Введена.

Где вызывается хук

wp_validate_redirect()
allowed_redirect_hosts
wp-includes/pluggable.php 1625
$allowed_hosts = (array) apply_filters( 'allowed_redirect_hosts', array( $wpp['host'] ), isset( $lp['host'] ) ? $lp['host'] : '' );

Где используется хук в WordPress

wp-includes/ms-default-filters.php 75
add_filter( 'allowed_redirect_hosts', 'redirect_this_site' );