thom4parisot / wp-less

WordPress plugin which seemlessly compiles, caches and rebuilds your LESS stylesheets.
https://wordpress.org/plugins/wp-less/
88 stars 40 forks source link

Make package autoloadable #102

Closed mrgrain closed 6 years ago

mrgrain commented 8 years ago

bootstrap-for-theme.php is intended for bundling the plugin with a theme (in a way that prevents multiple loading when the plugin is already present.

You can then redistribute your theme with this loader fearlessly. bootstrap-for-theme.php#L37

To fix the workflow for a theme bundling this plugin, we should support for composer's autload.

I'll create a PR to address this issue.

mrgrain commented 8 years ago

Update: My initial idea was to simply put bootstrap-for-theme.php into composer's autoload section. Whereas this would work for a theme that bundles the plugin and is published to wordpress.org, it will break any other use of the package as the bootstrap file depends on WordPress functionality. I keep digging.

mrgrain commented 8 years ago

More insights: The issue arises because of the nature of the current static class creation method: WPPluginToolkitPlugin::create('WPLess', __FILE__, 'WPLessPlugin'); - it depends on knowing the path to the plugin. This is perfectly fine for many cases, but will break the workflow if you are using a boilerplate like Bedrock when the package will end up in some vendor directory the including theme doesn't know about.

I created a simple wrapper class removing the dependency on the path. Let's discuss in the PR #103