Skip to content

Instantly share code, notes, and snippets.

@simplethemes
Created January 17, 2013 05:12
Show Gist options
  • Select an option

  • Save simplethemes/4553826 to your computer and use it in GitHub Desktop.

Select an option

Save simplethemes/4553826 to your computer and use it in GitHub Desktop.

Revisions

  1. simplethemes created this gist Jan 17, 2013.
    32 changes: 32 additions & 0 deletions minify-theme.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    /*-----------------------------------------------------------------------------------*/
    // 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');