Created
June 16, 2017 17:00
-
-
Save theMikeD/f002f696f365aff7c8252f6365cc7d5e to your computer and use it in GitHub Desktop.
Used to insert a CSS file <link> tag once no matter how often it's called. HTTP/2 inline CSS is why I wrote this.
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 | |
// This is defined somewhere high up in functions.php | |
// $GLOBALS['cnmd_inline_css_record'] = array(); | |
/** | |
* Used to shoot out css files in-line, and only once per file. Uses the CSS ID as an | |
* index into an array to prevent dupes. | |
* | |
* @param $handle | |
* @param $path | |
* | |
* @return string | |
*/ | |
function cnmd_get_inline_css_file( $handle, $path ) { | |
if ( !isset($GLOBALS['cnmd_inline_css_record'][$handle] ) ) { | |
$GLOBALS['cnmd_inline_css_record'][$handle] = true; | |
return '<link rel="stylesheet" id="' . $handle . '" href="' . $path . '" media="all">'; | |
} | |
return ''; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment