WordPress.org

Ready to get started?Download WordPress

Forums

WP-LESS
[resolved] WP 3.4 (13 posts)

  1. wpcsphil
    Member
    Posted 1 year ago #

    Hello all,

    Have a client whose previous developer was using wp-less. She just upgraded on her own to 3.4 and the plugin didn't care for that. I didn't built the site (complicated) and not sure that there was no core changes and or such and hoping to not have to try rolling it back.

    Anyone have any idea how to get it working again? Seems maybe it would work if I could just trick the plugin into thinking it's 3.3, but couldn't figure it out.

    Any ideas???

    Thanks!

    Philip

    http://wordpress.org/extend/plugins/wp-less/

  2. dotmagic
    Member
    Posted 1 year ago #

    I have no idea why so many say its broken with 3.4.x.
    I'm using it with WP 3.4.1 and it works fine. Anyway, you can disable the plugin and compile the .less file to .css, then change the line in funcions.php to include it in your theme, thats all.

    I use Simpless for compile the less file. Once you know about less you won't miss it anymore ;-)

  3. idosius
    Member
    Posted 1 year ago #

    It doesn't work for me either on WordPress 3.4.2, running on Windows XAMPP. I'm developing a theme with the WordPress Roots theme. I created an app.less file and tried to write some code in it, but the output isn't compiled to CSS.

    Is there any debug info that could help?

  4. idosius
    Member
    Posted 1 year ago #

    I investigated further and noticed several issues:

    1. Roots theme uses the wp_enqueue_scripts action. It says here to use the wp action. Why is that so? Why doesn't it work with the wp_enqueue_scripts hook?
    2. In the Roots theme there are some htaccess tricks to put all the stylesheets into /assets/css. It seems the WP-LESS plugin needs the full wp-content path to the file. Is this a bug? Any workarounds?
  5. idosius
    Member
    Posted 1 year ago #

    Update - got it to work with the following code:

    function roots_enqueue_less() {
      wp_enqueue_style('roots_app', '/themes/mytheme/assets/css/app.less', array(), '', 'screen, projection');
    }
    
    add_action('wp', 'roots_enqueue_less');
    1. Full path following wp-content
    2. Using wp as the action

    In my opinion it should also work with wp_enqueue_scripts action and with the /assets trick.

  6. oncletom
    Member
    Plugin Author

    Posted 1 year ago #

    Do you still encounter the problem?

    I don't see any change with WP 3.4.x.

    Can you all copy/paste how you enqueue your CSS?

    Thanks :-)

  7. idosius
    Member
    Posted 1 year ago #

    As I wrote above - the enqueued LESS file only works when it's added to the 'wp' hook. When it's added to 'wp_enqueue_scripts' it doesn't work. At least not with the Roots theme:
    http://www.rootstheme.com/

  8. oncletom
    Member
    Plugin Author

    Posted 1 year ago #

    wp_enqueue_scripts is far too late for a hook to make this working at the moment.

    I've described the Processing Workflow on the project wiki.

    I guess I could delay the LESS processing to the wp_print_styles action, in a low priority.

  9. idosius
    Member
    Posted 1 year ago #

    Sorry, I meant wp_enqueue_style. Might want to change the instructions here: http://wordpress.org/extend/plugins/wp-less/faq/

  10. oncletom
    Member
    Plugin Author

    Posted 1 year ago #

    I've digged in the code: they enqueue CSS files on wp_enqueue_scripts, which is AFTER wp action and before wp_print_styles.

    They recommend to compile files as yourtheme/style.css.
    Anyway, their way of registering CSS is not very handy, especially as it forces the browser to load 4 CSS files… which is counterproductive for performances.

    What I would do

    
    add_action('wp_enqueue_scripts', 'customize_roots_css', 200);
    add_action('init', 'my_less_styles');
    
    function customize_roots_css(){
      wp_dequeue_style('roots_bootstrap');
      wp_dequeue_style('roots_bootstrap_responsive');
      wp_dequeue_style('roots_app');
      wp_dequeue_style('roots_child');
    }
    
    function my_less_styles(){
      wp_enqueue_style('theme_main', get_stylesheet_directory_uri() . '/style.less');
    }
    
    

    Use @import to load bootstrap, responsive and roots CSS (if needed) to compile that in 1 working file.

  11. oncletom
    Member
    Plugin Author

    Posted 1 year ago #

    Problem finally addressed by a contribution — https://github.com/oncletom/wp-less/pull/18

    Lands in 1.5.0.

  12. paulrudy
    Member
    Posted 1 year ago #

    THANK YOU. This works in roots theme now.

  13. oncletom
    Member
    Plugin Author

    Posted 1 year ago #

    Cool, nice to hear that :-)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.