I've seen wp_headers
and send_headers
both used before for the same thing and I'm wondering how you're suppose to know which one to use and when...
On the send_headers
codex page there's an example of adding the X-UA-Compatible: IE=edge,chrome=1
for Internet Explorer backward compatibility since the meta tag often fails on intranet sites if loaded too late.
This is what the send_headers
example looks like:
add_action( 'send_headers', 'add_header_xua' );
function add_header_xua() {
header( 'X-UA-Compatible: IE=edge,chrome=1' );
}
However wp_headers
can also do this:
apply_filters ( 'wp_headers', array $headers, WP $this )
add_filter( 'wp_headers', 'wpieeam_headers' );
function wpieeam_headers($headers) {
if (!is_admin()) {
$headers['X-UA-Compatible'] = 'IE=edge,chrome=1';
}
return $headers;
}
Update: I actually just noticed that a conversation on this more or less started on a similar question a couple years ago...
Also, does send_headers have to do with only the front end? I've seen wp_headers do checks like this:
if ( isset($_SERVER['HTTP_USER_AGENT']) && (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false) )
and
if (!is_admin())
so I'm thinking that maybe send_headers
doesn't have to make those checks...