Skip to content

Commit 3e30fd3

Browse files
committed
improve readme and add option to compress css
1 parent 2e068a2 commit 3e30fd3

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

Readme.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ wp_enqueue_less provides a function to enqueue less stylesheets in WordPress.
66

77
### Composer
88

9-
Composer is the best way to install wp_enqueue_less so you get updates in the future easily.
9+
Composer is the best way to install wp_enqueue_less, so you get updates in the future easily.
1010

1111
```
1212
composer require ed-itsolutions/wp_enqueue_less
1313
```
1414

15-
and then in your `functions.php` of `plugin.php`
15+
and then in your `functions.php` or `plugin.php`
1616

1717
```php
1818
require_once('vendor/autoload.php');
@@ -29,7 +29,7 @@ In your normal `wp_enqueue_scripts` action simply call `wp_enqueue_less`
2929
`wp_enqueue_less` takes 3 arguments.
3030

3131
- _key_ - The key name to use for this stylesheet.
32-
- _filePath_ - The on disk path to the .less file.
32+
- _filePath_ - The on-disk path to the .less file.
3333
- _variables_ - A key->value array of variables to be passed to the less compiler.
3434

3535
```php
@@ -49,4 +49,12 @@ wp_enqueue_less will:
4949
- Compile this less file and write the output to `/wp-content/uploads/less/key-hash.css` (this can be changed with the filter `wp_enqueue_less_css_dir`).
5050
- Record the current hashes of all the less files used and the variables into the database.
5151
- On the next call if none of the hashes have changed it will skip parsing.
52-
- On a daily basis it will clean out its directory of everything but the current hash version of the stylesheet.
52+
- On a daily basis it will clean out its directory of everything but the current hash version of the stylesheet.
53+
54+
### Filters
55+
56+
|Filter|Default|Purpose|
57+
|:-----|:------|:------|
58+
|wp_enqueue_less_css_url|`wp_upload_dir()['baseurl'] . '/less'`|The URL of the directory the compiled css is served from.|
59+
|wp_enqueue_less_css_dir|`wp_upload_dir()['basedir'] . '/less'`|The on-disk directory to serve compiled css from.|
60+
|wp_enqueue_less_compress|`true`|Should wp_enqueue_less compress the outputted css|

wp_enqueue_less.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ function wp_enqueue_less($key, $file, $variables){
3838

3939
if(function_exists('add_action')){
4040
add_action('wp_enqueue_less_compile', function($details, $variables){
41-
$parser = new Less_Parser();
41+
$parser = new Less_Parser(array(
42+
'compress' => apply_filters('wp_enqueue_less_compress', true)
43+
));
4244
$parser->parseFile($details->file, get_template_directory_uri());
4345
$parser->ModifyVars($variables);
4446
$css = $parser->getCss();

0 commit comments

Comments
 (0)