Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
/**
* Register assets required by the theme.
*/
function pwcc_register_assets() {
wp_register_style(
'pwcc-styles',
get_stylesheet_uri(),
array(),
'1.0'
);
wp_style_add_data( 'pwcc-styles', 'pwcc_h2_push', true );
}
add_action( 'wp', 'pwcc_register_assets' );
/**
* Add HTTP Link headers required by server push.
*/
function pwcc_server_push() {
global $wp_styles;
foreach ( $wp_styles->registered as $style ) {
if ( ! empty( $style->extra ) && $style->extra['pwcc_h2_push'] ) {
header( 'Link: <' . esc_url_raw( $style->src ) . '>; rel=preload; as=style' );
pwcc_style_cached( $style->handle );
}
}
var_dump( $wp_styles );
}
add_action( 'wp','pwcc_server_push', 20 );
@RaminMT

This comment has been minimized.

Copy link

RaminMT commented Jan 21, 2018

Hi,
Excuses where is "pwcc_style_cached" func? and why "var_dump"? :-D

tnx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.