Support » Plugins » WP Less & Buddypress – less file enqueued, but isn't processed

  • I’m bootstrapping in the WP-Less plugin within a theme I am developing for my client. All works perfectly throughout the standard portions of my site by hooking into the ‘wp’ action:

    if ( ! function_exists( 'rfros_enqueue_less' ) ) {
    	function rfros_enqueue_less() {
    		wp_enqueue_style('themestyles', THEMEDIRURL.'/less/_theme.less', array(), '1.0.0', 'screen, projection');
    		wp_enqueue_style('themestyles-responsive', THEMEDIRURL.'/less/_responsive.less', array('themestyles'), '1.0.0', 'screen, projection');

    However, this doesn’t behave the same way when on a Buddypress page/etc of my site. The file is enqueued (I can see the reference in my source code), but isn’t processed. I’ve tried hooking into 'bp_actions', but with no luck. Is there another action I can hook into?

Viewing 5 replies - 1 through 5 (of 5 total)
  • @mercime


    Volunteer Moderator

    For BuddyPress as well as WordPress themes, enqueue styles and scripts via wp_enqueue_scripts e.g.
    add_action( 'wp_enqueue_scripts', 'rfros_enqueue_less');

    WP Less will not compile the css when called within the wp_enqueue_scripts hook, unfortunately

    I have the same problem basically, I have a custom plugin that I want to use LESS with as well. Using the WP-Less plugin is great, and my index.php of my plugin will load the style just fine using this:

    wp_enqueue_style('featured-stories-style'); // WP-Less plugin must be activated to parse LESS files

    But if I try to call the enqueue function within the function of one of my plugin pages then I get nothing.

    function enqueue_less() {
    		wp_enqueue_style('featured-stories-style',KMP_PLUGIN_URL.'/modules/featured-post/featured-post.less', array(), '', 'screen, projection');

    Any additional thoughts as to how to approach this? I want it this way because I don’t want the LESS file enqueued until my plugin function is called (which is only on the home page).

    Any body else have some thoughts on this. Still yet to find a solution myself and I’m running out of ideas for this.



    Volunteer Moderator

    If you can’t enqueue, then you could override the parent theme’s function which enqueues the bp-default stylesheet then just render your child theme’s stylesheet as you want

    To override bp-default theme’s enqueue function, add this to your child theme’s functions.php

    if ( !function_exists( 'bp_dtheme_enqueue_styles' ) ) :
         function bp_dtheme_enqueue_styles() {}

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘WP Less & Buddypress – less file enqueued, but isn't processed’ is closed to new replies.