Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Cannot register LESS variables using document method in version 1.7+ #63

Description

@thewebists

In the new version of the plugin @fabrizim has set the compiler to initalize at 'init' priority 1, however the documented method for registering variables uses the functions.php file, which is executed BEFORE the 'init' action in the page life-cycle.

This results in the following error:

Fatal error: Call to a member function setVariables() on a non-object in /bedrock/web/app/plugins/wp-less/lib/Plugin.class.php on line 319

The solution was to call the variable registration with a hook after the init@1:

add_action('init', 'tws_redux_to_less_vars', 2); // The WP-LESS compiler is instantiated in 'init' priority 1.

function tws_redux_to_less_vars() {
    // Pass LESS variables from reduxlessvars option to the LESS plugin class
    if (class_exists('WPLessPlugin')){
        $less = WPLessPlugin::getInstance();
        $less->setVariables(get_option('reduxlessvars'));
    }
}

I think the plugin documentation needs to be updated to reflect this. I have a feeling other plugin components (e.g. function registration) might face a similar issue.

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