• this is how to compile the bootstrap 3 less files, including caching, so the file is only recompiled when a less file has changed:


    function my_enqueue_scripts(){
    $less_files = array( get_stylesheet_directory() . '/less/bootstrap.less' => '/mysite/' );
    $options = array( 'cache_dir' => get_stylesheet_directory() . '/lesscache' );
    $css_file_name = Less_Cache::Get( $less_files, $options );
    wp_enqueue_style( 'bootstrap', get_stylesheet_directory_uri() . '/lesscache/'.$css_file_name);
    }
    // Uncomment this to add a additional scripts
    add_action( 'wp_enqueue_scripts', 'my_enqueue_scripts' );

    if you want to use bootstrap variables in your own less file (which you probably do), simply stick this on top

    @import “/less/bootstrap.less”;

    and process your own less file instead of bootstrap.less.

    you dont need anything else, just install the plugin and above code.

    and check here to see detailled explanation:
    https://github.com/oyejorge/less.php

    greets and thanks for this great plugin! less just became much more… useful. (after the trusty wp-less plugin failed compiling bootstrap 3)

    https://www.ads-software.com/plugins/lessphp/

  • The topic ‘This is how to cache and enqueue (eg. bootstrap):’ is closed to new replies.