thom4parisot / wp-less

WordPress plugin which seemlessly compiles, caches and rebuilds your LESS stylesheets.
https://wordpress.org/plugins/wp-less/
88 stars 40 forks source link

Inject After ALL Stylesheets #97

Closed TaylorFoster90 closed 8 years ago

TaylorFoster90 commented 8 years ago

I cannot seem to inject the CSS file that is being compiled into the head AFTER all theme CSS files. I have tried using the $deps parameter for wp_enqueue_style() but it breaks and won't even inject my new CSS into head. Would love a way to make sure it loads last so I don't have to keep using !important rules.

thom4parisot commented 8 years ago

but it breaks

What do you mean by this? Assuming there is no issue with the plugin, wp_enqueue_style queuing order should be respected. Can you eventually share the portion of code where you do your calls to wp_enqueue_style?

TaylorFoster90 commented 8 years ago
add_action('init', 'theme_enqueue_styles');

function theme_enqueue_styles() {
    $deps = array(get_template_directory_uri()."/framework/css/site/stacks/integrity-light.css");
    wp_enqueue_style('theme-main', get_stylesheet_directory_uri().'/less/main.less', $deps);
}

I am trying to inject my stylesheet after the parent theme stylesheet. But running the above code does not even inject the new stylesheet at all.

thom4parisot commented 8 years ago

Try this instead:

add_action('init', 'theme_enqueue_styles');

function theme_enqueue_styles() {
    wp_enqueue_style('integrity', get_template_directory_uri()."/framework/css/site/stacks/integrity-light.css");
    wp_enqueue_style('theme-main', get_stylesheet_directory_uri().'/less/main.less', array('integrity'));
}

According to wp doc, deps is an array of handles of any stylesheet that this stylesheet depends on; stylesheets that must be loaded before this stylesheet. false if there are no dependencies.

Otherwise best would be to make the requirement explicit and to import integrity-light.css in your main.less file :-)

TaylorFoster90 commented 8 years ago

Thank you so much! Did't know I needed to explicitly re-inject the pre-existing CSS files. Working just fine now! =]