wp_headers хук-фильтрWP 2.8.0

Filters the HTTP headers before they're sent to the browser.

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

add_filter( 'wp_headers', 'wp_kama_headers_filter', 10, 2 );

/**
 * Function for `wp_headers` filter-hook.
 * 
 * @param string[] $headers Associative array of headers to be sent.
 * @param WP       $wp      Current WordPress environment instance.
 *
 * @return string[]
 */
function wp_kama_headers_filter( $headers, $wp ){

	// filter...
	return $headers;
}
$headers(string[])
Associative array of headers to be sent.
$wp(WP)
Current WordPress environment instance.

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

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

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

WP::send_headers()
wp_headers
wp-includes/class-wp.php 514
$headers = apply_filters( 'wp_headers', $headers, $this );

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

wp-includes/class-wp-customize-manager.php 1907
add_filter( 'wp_headers', array( $this, 'filter_iframe_security_headers' ) );