Skip to content

Instantly share code, notes, and snippets.

@homanp
Last active October 10, 2019 19:49
Show Gist options
  • Save homanp/9c709e3653037a3c1e7400e247725d04 to your computer and use it in GitHub Desktop.
Save homanp/9c709e3653037a3c1e7400e247725d04 to your computer and use it in GitHub Desktop.
function start_wp_head_buffer() {
ob_start();
}
add_action('wp_head','start_wp_head_buffer',0);
function end_wp_head_buffer() {
$in = ob_get_clean();
echo $in; // output to head-tag
}
add_action('wp_head','end_wp_head_buffer', PHP_INT_MAX);
add_action('rest_api_init', function () {
register_rest_route( 'hs/v1', 'header',array(
'methods' => 'GET',
'callback' => 'end_wp_head_buffer'
));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment