Skip to content

Instantly share code, notes, and snippets.

@hellofromtonya
Last active July 12, 2017 00:40
Show Gist options
  • Save hellofromtonya/288b3eb354e2c09d7ba2844344190001 to your computer and use it in GitHub Desktop.
Save hellofromtonya/288b3eb354e2c09d7ba2844344190001 to your computer and use it in GitHub Desktop.
Loading the theme's minified stylesheet
<?php
// code left out for brevity
add_filter( 'stylesheet_uri', 'change_theme_stylesheet_uri_to_min_version', 9999, 2 );
/**
* Change the theme's stylesheet URI to minified version when not
* in development/debug mode.
*
* @since 1.0.0
*
* @param string $stylesheet_uri Stylesheet URI for the current theme/child theme.
* @param string $stylesheet_dir_uri Stylesheet directory URI for the current theme/child theme.
*
* @return string
*/
function change_theme_stylesheet_uri_to_min_version( $stylesheet_uri, $stylesheet_dir_uri ) {
if ( site_is_in_debug_mode() ) {
return $stylesheet_uri;
}
return $stylesheet_dir_uri . '/style.min.css';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment