Last active
July 13, 2016 00:57
-
-
Save johnregan3/b72d71b86c6fdbc2ee245ed4aa36f4e4 to your computer and use it in GitHub Desktop.
Registering Component Scripts for AMP Extensions with the WP AMP plugin
This file contains hidden or 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 | |
/** | |
* Include AMP component scripts. | |
* | |
* Be sure to only register the scripts for the extensions | |
* that you really need to reduce page load times. | |
* | |
* @filter amp_post_template_data | |
* | |
* @param array $data Input from filter. | |
* | |
* @return array | |
*/ | |
public function xwp_amp_component_scripts( $data ) { | |
$custom_component_scripts = array( | |
'amp-sidebar' => 'https://cdn.ampproject.org/v0/amp-sidebar-0.1.js'; | |
'amp-social-share' => 'https://cdn.ampproject.org/v0/amp-social-share-0.1.js'; | |
'amp-carousel' => 'https://cdn.ampproject.org/v0/amp-carousel-0.1.js'; | |
'amp-audio' => 'https://cdn.ampproject.org/v0/amp-audio-0.1.js'; | |
'amp-brightcove' => 'https://cdn.ampproject.org/v0/amp-brightcove-0.1.js'; | |
); | |
$data['component_scripts'] = array_merge( $data['component_scripts'], $custom_component_scripts ); | |
return $data; | |
} | |
add_filter( 'amp_post_template_data', xwp_amp_component_scripts ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment