Skip to content

Less File Not Found/Handled in Plugin Using WP-Less  #78

Description

Hello

I am attempting to use WP-Less in my plugin. I am hoping its possible to use WP-LESS in a plugin? This would save me alot of time if its possible. Also does WP-LESS compile less server side or is less handled client side - hopefully its server side.

I have a very simple Plugin that imports WP-LESS and an admin page should show its working by having some text styled. But the text isn't styled and its not finding the main.less file (its says its not found). Below are details of the error and the simple code - see the attached images for the error output and plugin directory structure.

capture2

![capture](https://cloud.githubusercontent.com/assets/10113201/9029031/f3f77c08-39ce-11e5-9635-f28e9b525a45.PNG)

Plugin Code:

/**
*  Plugin Name: TEST Load Less
*  Plugin URI: NA
*  Description: Test Development Plugin
*  Version: 1.0.0
*  Author: NA
*  Author URI: NA
*  License: GPL2
*/ 


add_action('admin_menu', 'TEST_admin_menu');
add_action('admin_init', 'include_less');
add_action('admin_print_scripts', 'include_less');
add_action('admin_print_styles', 'include_less');
add_action('admin_enqueue_scripts', 'TEST_enqueue_scripts');
add_action('wp_enqueue_scripts', 'TEST_enqueue_scripts');

// What action should less be included in? admin_init?
function include_less() {
    require_once( 'wp-less/wp-less.php' );
}

function TEST_admin_menu() {
    include_less();

    add_menu_page('TEST_DEV', 'TEST_DEV', 'administrator', 'TEST_DEV_SLUG', 
                    'show_TEST_page', 
                    plugins_url('images/help.png', __FILE__));
}

function TEST_enqueue_scripts() {

    require_once( 'wp-less/wp-less.php' );
    wp_enqueue_style( 'less-style', plugins_url( '/main.less', __FILE__ ) );
}

function show_TEST_page() {
    ?>
    <div class="wrap">
        <div>
            <p>No styling</p>
            <button class="btn">Abcdef</button>
        </div>

        <div class="my-less-namespace">
            <p>I should have styling from my less file</p>
            <button class="btn">Abcdef</button>
        </div>
        </div>
    <?php
}

?>```


Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions