WordPress.org

Ready to get started?Download WordPress

Forums

Better WordPress Minify
[resolved] BWPM is minifying child style.css, but not parent? (10 posts)

  1. meeble
    Member
    Posted 1 year ago #

    Hi,

    I'm using WP 3.5RC2, and a child theme based on the new twentytwelve theme. I noticed that BWPM is minifying my child style.css, but ignoring the imported twentytwelve style.css file.

    http://laserlightshows.us

    I'm sure it's something simple.

    side note: any progress on adding html minifying to the plugin?

    Thanks!
    meeble

    http://wordpress.org/extend/plugins/bwp-minify/

  2. Khang Minh
    Member
    Plugin Author

    Posted 1 year ago #

    I don't think the Minify library itself supports that. However, you can enqueue twentytwelve's style.css in your child theme's functions.php instead of importing it inside your child theme's style.css; that way BWP Minify will happily minify twentytwelve's style.css.

  3. meeble
    Member
    Posted 1 year ago #

    Hi,

    Thanks for the response. I think I finally got it working. I do have one question though...

    Here's my site: http://laserlightshows.us

    When looking at my page source, I see two css files:

    <link rel='stylesheet' id='twentytwelve-style-css'  href='http://cf.laserlightshows.us/wp-content/min/?f=wp-content%2Fthemes%2F2012%2Fstyle.css&ver=3.5-RC3' type='text/css' media='all' />
    
    and 
    
    <link rel='stylesheet' type='text/css' media='all' href='http://cf.laserlightshows.us/wp-content/min/?f=wp-content/plugins/contact-form-7/includes/css/styles.css,wp-content/themes/twentytwelve/style.css' />

    why aren't these combined into one file?

    I was also wondering why the slashes in the first URL were being html entity encoded?

    Thanks,
    Devin

  4. meeble
    Member
    Posted 1 year ago #

    actually, now it seems that my child theme's style.css isn't quite working right. It IS loading, but some of my style declarations don't seem to be working now that I've changed the way I'm importing in the parent theme's css. how strange. Could it be that the parent theme css is now being called after the chils theme css, hence overriding it? It is being loaded further down the page, it seems...

  5. meeble
    Member
    Posted 1 year ago #

    ugh, this is so frustrating. Ok, so I took out the @import line from my child style.css file. Then I added this to my functions.php file:

    function theme_styles()
    {
      wp_enqueue_style( 'twentytwelve' );
    }
    add_action('wp_enqueue_scripts', 'theme_styles');

    But all this does is dynamically insert the @import line back into my child style.css which means BWPM isn't minifying it.

  6. meeble
    Member
    Posted 1 year ago #

    Ok, got it working. I ended up putting this in my functions.php file:

    function parent_styles()
    {
        wp_register_style( 'twentytwelve',
        get_template_directory_uri() . '/style.css',
        array(),
        '20121205',
        'all' );
    
      wp_enqueue_style( 'twentytwelve' );
    
    }
    add_action('wp_enqueue_scripts', 'parent_styles',11);
    
    function child_styles()
    {
        wp_register_style( '2012',
        get_stylesheet_directory_uri() . '/style.css',
        array(),
        '20121205',
        'all' );
    
      wp_enqueue_style( '2012' );
    
    remove_action('wp_head', 'wlwmanifest_link');
    remove_action('wp_head', 'wp_generator');
    }
    add_action('wp_enqueue_scripts', 'child_styles',12);

    and I commented this line out of my parent's (twentytwelve) functions.php file:

    wp_enqueue_style( 'twentytwelve-style', get_stylesheet_uri() );

    I hate having to mess around with my parent theme's files, but it works now.

  7. meeble
    Member
    Posted 1 year ago #

    well, after upgrading WP, the functions.php got replaced, which made me realize that this isn't a good solution. I've spent several hours trying to minify the parent twentytwelve css file, but I just can't seem to make it work. Currently, I can get the parent style.css to load in above the child style.css in the html, but as soon as I enable BWPM, it moves the parent style.css further down, which breaks my child css. This really shouldn't be so complicated...

  8. meeble
    Member
    Posted 1 year ago #

    FINALLY!

    this actually works.

    function dequeue_styles() {
        wp_deregister_style( 'twentytwelve-style' );
        wp_dequeue_style( 'twentytwelve-style' );
    }
    add_action( 'wp_print_styles', 'dequeue_styles' );
    
    // enqueue parent stylesheet before child css and minify
    function parent_styles()
    {
    wp_register_style( 'twentytwelve',
    get_template_directory_uri() . '/style.css'
    );
    wp_enqueue_style( 'twentytwelve' );
    }
    add_action('wp_enqueue_scripts', 'parent_styles');
    
    function child_styles()
    {
    wp_register_style( '2012',
    get_stylesheet_directory_uri() . '/style.css'
    );
    wp_enqueue_style( '2012' );
    }
    add_action('wp_enqueue_scripts', 'child_styles');
  9. justinparks
    Member
    Posted 1 year ago #

    I dropped that into the childtheme folder functions.php - works perfectly! Nice work meeble!

  10. Li-An
    Member
    Posted 1 year ago #

    Very interesting. What is the "2012" for ?

    I got it! It's the child theme name :-)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic