Amp_Assets::styles()

Summary

Add custom CSS.


Source

File: src/BigCommerce/Amp/Amp_Assets.php

	public function styles() {
		$debug = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG;

		$post         = get_post();
		$css_file     = $debug ? 'master-amp.css' : 'master-amp.min.css';
		$cart_page_id = intval( get_option( Settings\Sections\Cart::OPTION_CART_PAGE_ID, 0 ) );
		if ( $post->ID === $cart_page_id ) {
			$css_file = $debug ? 'cart-amp.css' : 'cart-amp.min.css';
		}
		$css_src      = $this->directory . 'css/' . $css_file;
		$css_contents = file_get_contents( $css_src );

		// Use absolute URLs for web fonts.
		$css_contents = str_replace( '../fonts', esc_url( $this->asset_directory_url . 'fonts' ), $css_contents );

		// Remove all !important rules.
		$css_contents = str_replace( '!important', '', $css_contents );

		echo $css_contents; // WPCS: XSS okay. CSS loaded from our own CSS file.
	}

User Contributed Notes

You must log in before being able to contribute a note or feedback.