Last active
January 21, 2018 08:17
-
-
Save peterwilsoncc/33b67ace4a3e7571af9af99b76649e5e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
Excuses where is "pwcc_style_cached" func? and why "var_dump"? :-D
tnx