File tree Expand file tree Collapse file tree 2 files changed +11
-6
lines changed
Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ before_script:
3030script :
3131- phpunit
3232after_success :
33- - sed -i -e "s/nightly/${TRAVIS_TAG}/" self-hosted-wordpress-plugin-on-github .php
33+ - sed -i -e "s/nightly/${TRAVIS_TAG}/" http2-server-push .php
3434- curl https://raw.githubusercontent.com/miya0001/auto-build/master/auto-build.sh | bash
3535deploy :
3636 provider : releases
Original file line number Diff line number Diff line change 88 * @param $items array
99 */
1010function send_http2_link_header ( $ items ) {
11- $ items = apply_filters ( ' http2_server_push_items ' , $ items );
11+ $ links = array ( );
1212 foreach ( $ items as $ as => $ urls ) {
1313 foreach ( $ urls as $ url ) {
14- $ link = sprintf (
14+ $ links [] = sprintf (
1515 '<%s>; rel=preload; as=%s ' ,
1616 esc_url_raw ( $ url ),
1717 $ as
1818 );
19- header ( "Link: " . $ link , false );
2019 }
2120 }
21+
22+ if ( $ links ) {
23+ header ( "Link: " . implode ( ", " , $ links ), false );
24+ }
2225}
2326
2427/**
@@ -27,10 +30,12 @@ function send_http2_link_header( $items ) {
2730 * @return array An array of URLs.
2831 */
2932function get_enqueued_items () {
30- return array (
33+ $ items = array (
3134 'style ' => get_urls ( wp_styles () ),
3235 'script ' => get_urls ( wp_scripts () ),
3336 );
37+
38+ return apply_filters ( 'http2_server_push_items ' , $ items );
3439}
3540
3641/**
@@ -52,7 +57,7 @@ function get_urls( $wp_links ) {
5257
5358 $ urls = array ();
5459 foreach ( $ to_do as $ handle ) {
55- if ( ! empty ( $ links [ $ handle ] ) && $ links [ $ handle ]->src ) {
60+ if ( ! empty ( $ links [ $ handle ] ) && $ links [ $ handle ]->src && is_string ( $ links [ $ handle ]-> src ) ) {
5661 $ src = $ links [ $ handle ]->src ;
5762 if ( preg_match ( "#^http://# " , $ src ) ) {
5863 continue ;
You can’t perform that action at this time.
0 commit comments