Skip to content

Instantly share code, notes, and snippets.

@simplethemes
Created January 17, 2013 05:12
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simplethemes/4553826 to your computer and use it in GitHub Desktop.
Save simplethemes/4553826 to your computer and use it in GitHub Desktop.
minify WordPress theme styles.
/*-----------------------------------------------------------------------------------*/
// Register and Minify Core Stylesheets
/*-----------------------------------------------------------------------------------*/
function st_registerstyles() {
// minify folder name (must be in your wp root).
$minpath = '/min';
// define directories
$child_theme = str_replace(site_url().'/wp-content/themes/', '', get_bloginfo('stylesheet_directory'));
$parent_theme = str_replace(site_url().'/wp-content/themes/', '', get_bloginfo('template_directory'));
$preset_style = of_get_option('layout_style');
$minify = array(
$parent_theme.'/css/skeleton-r.css',
$parent_theme.'/css/formalize.css',
$parent_theme.'/css/flexslider.css',
$parent_theme.'/superfish.css',
$parent_theme.'/layout.css',
// minify breaks when using @import so we use the parent theme version.
// to use the child theme version, copy the styles (only the styles) into child-theme/style.css
// make sure to leave the child theme style.css header in tact.
$parent_theme.'/style.css',
$child_theme.'/'.$preset_style.'.css'
);
$stylesheets = join( ',', $minify );
wp_enqueue_style('theme-styles', $wpsite.$minpath.'/b=wp-content/themes&f='.$stylesheets, NULL, NULL, NULL, 'screen, projection');
}
add_action('get_header', 'st_registerstyles');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment