Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incompatibility with other plugins that include a class 'lessc' #82

Open
IndigoStarfish opened this issue Jan 30, 2015 · 4 comments
Open
Labels

Comments

@IndigoStarfish
Copy link

class WPLessCompiler extends lessc

If a class lessc is defined in another plugin, and that plugin loads before WP-LESS, the other plugins class will be used. This can cause problems.

Example:
In my project using WP-LESS I'm using the 'wp_less_compiler' filter to switch compilers to less.php (oyejorge) as we are using Bootstraps less framework, which uses syntax unsupported by lessphp (leafo).

The plugin 'all-in-one-event-calendar' includes lessphp (leafo). As the name of this plugin is alphabetically before 'wp-less' it is loaded first, and thus wp-less always uses the lessphp version of lessc. This then causes an exception as it encounters the bootstrap syntax that is unsupported.

(As a workaround, I have installed a plugin called Plugin Organizer, that lets you alter the order that plugins are loaded. Putting WP-LESS first fixes everything).

WP v4.1
WP-LESS v1.7.5
All-in-One Event Calendar by Time.ly v2.1.9

@thom4parisot
Copy link
Owner

Hm, there is a check here https://github.com/oncletom/wp-less/blob/master/lib/Plugin.class.php#L46
It will load less only if it does not already available in the environment.

What was your error message?

@IndigoStarfish
Copy link
Author

Sorry, maybe I wasn't very clear.

As far as I am aware:
lessphp (leafo) cannot be used to compile Bootstrap [syntax error]
less**.**php (oyejorge) can be used to compile Bootstrap

I'm using WP-LESS's wp_less_compiler filter to switch from lessphp to less**.**php [which works great in every other project!] - https://github.com/oncletom/wp-less/blob/master/lib/Plugin.class.php#L68

[However, in this project I need this other plugin...] All-in-One Event Calendar by Time.ly includes lessphp (leafo), and seems to load its version of lessc class before WP-LESS (this seems to happen regardless of plugin load order, contrary to my initial report).

As you pointed out, due to lessc already being loaded by the other plugin WP-LESS will skip loading it's own version, but I need it to load the less**.**php (oyejorge) version, and use that, otherwise Bootstrap won't compile.

All-in-One Event Calendar by Time.ly also does a check to see if a class lessc already exists before loading its own, so the solution is to somehow get WP-LESS to load it version first. I'm guessing All-in-One Event Calendar by Time.ly loads its in an earlier hook or something as changing the plugin load order had no effect.

To get around this at the moment, I have created a simple hackplugin to include /plugins/wp-less/vendor/leafo/lessphp/lessc.inc.php before All-in-One Event Calendar by Time.ly has a chance to load its version.

@ghost
Copy link

ghost commented Apr 7, 2015

I have had a similar issue. What seemed to be happening is that the theme was not being activated full the first time. This resulted in WP-Less trying to process the less files before my theme could specify less.php over lessc. I put an option in my theme so that it requires you to check a box to enable less processing. This way the theme is active and running before WP-Less tries to process Bootstrap. This was with no other extensions installed.

Maybe it is stated somewhere else, but is there a reason that WP-Less prefers lessc? Should it hit the filter first, then check to see if the intended lib is loaded?

@thom4parisot
Copy link
Owner

Well, the compiler is required if lessc is not available in the scope.
Which means that if some plugin already loaded lessc, it is going to use it.

Another safer would be to never extend lessc, and to inject the Less compiler at a constructor level.
The issue is most of its methods are private so I'm not sure it is doable.

Although, I guess we could have some facades (WpLessCompiler requires WpLeafoCompiler which requires lessc etc.) to avoid requiring and extending undesired classes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants