WordPress.org

Ready to get started?Download WordPress

Forums

WP Less & Buddypress - less file enqueued, but isn't processed (6 posts)

  1. rfros
    Member
    Posted 2 years ago #

    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');
    	}
    }
    add_action('wp','rfros_enqueue_less');

    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?

  2. @mercime
    Volunteer Moderator
    Posted 2 years ago #

    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');

  3. rfros
    Member
    Posted 2 years ago #

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

  4. Xtremefaith
    Member
    Posted 2 years ago #

    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_register_style('featured-stories-style',KMP_PLUGIN_URL.'/modules/featured-post/featured-post.less',array(),'1.0',FALSE);
    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');
    	}
    	add_action('wp','enqueue_less');

    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).

  5. Xtremefaith
    Member
    Posted 2 years ago #

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

  6. @mercime
    Volunteer Moderator
    Posted 2 years ago #

    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() {}
    endif;

Topic Closed

This topic has been closed to new replies.

About this Topic