Skip to content

Instantly share code, notes, and snippets.

@verticalgrain
Created September 8, 2017 16:55
Show Gist options
  • Save verticalgrain/173b8d4d9f186a9ed35c932f345d2c5b to your computer and use it in GitHub Desktop.
Save verticalgrain/173b8d4d9f186a9ed35c932f345d2c5b to your computer and use it in GitHub Desktop.
AMP inline styles
/**
* Add additional styles for our AMP template. AMP requires inline styles.
*/
public static function amp_additional_css_styles() {
global $post;
$css = str_replace( 'STYLESHEET_DIRECTORY', get_stylesheet_directory_uri(), wpcom_vip_file_get_contents( get_stylesheet_directory_uri() . '/assets/css/amp.min.css', 3, 60 ) );
echo ESPN_AMP::sanitize_meta_css( $css );
}
/**
* Sanitize CSS that appears in the document <head>.
*
* @param string $css The CSS string to sanitize.
* @param string $post The sanitized CSS.
*/
public static function sanitize_meta_css( $css ) {
$css = stripslashes( $css );
$css = wp_strip_all_tags( $css );
return $css;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment