{"id":26518742,"url":"https://github.com/roborourke/wp-less","last_synced_at":"2025-06-30T23:10:54.587Z","repository":{"id":2012143,"uuid":"2946986","full_name":"roborourke/wp-less","owner":"roborourke","description":"Provides a LESS compiler compatible with wp_enqueue_style() for rapid CSS development in themes and plugins.","archived":false,"fork":false,"pushed_at":"2017-09-07T09:37:05.000Z","size":72,"stargazers_count":217,"open_issues_count":18,"forks_count":54,"subscribers_count":21,"default_branch":"master","last_synced_at":"2025-03-21T10:02:11.390Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/roborourke.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"license.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-12-09T11:58:17.000Z","updated_at":"2024-08-30T19:10:44.000Z","dependencies_parsed_at":"2022-08-22T09:30:33.699Z","dependency_job_id":null,"html_url":"https://github.com/roborourke/wp-less","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/roborourke/wp-less","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roborourke%2Fwp-less","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roborourke%2Fwp-less/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roborourke%2Fwp-less/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roborourke%2Fwp-less/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/roborourke","download_url":"https://codeload.github.com/roborourke/wp-less/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roborourke%2Fwp-less/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262864258,"owners_count":23376461,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-21T10:02:03.788Z","updated_at":"2025-06-30T23:10:54.559Z","avatar_url":"https://github.com/roborourke.png","language":"PHP","funding_links":[],"categories":["PHP"],"sub_categories":[],"readme":"# Enable LESS CSS in WordPress\n\nLESS is an abstraction layer that adds some very powerful features to CSS. It\nwill speed up your development process and make your life that much easier. Find\nout more from the links below and then head on back.\n\nThe addon allows you to write and edit `.less` files directly and\nhave WordPress do the job of compiling and caching the resulting CSS. It\neliminates the extra step of having to compile the `.less` files into CSS yourself\nbefore deploying them.\n\n## Installation:\n\nIf you are using git to clone the repository, do the following:\n\n    git clone git://github.com/sanchothefat/wp-less.git wp-less\n\nIf you are downloading the `.zip` or `.tar`, don't forget to download the [lessphp\ndependency too](https://github.com/leafo/lessphp) and copy it into the `vendor/leafo/lessphp`\ndirectory.\n\nThen install the lessphp dependency using:\n\n    composer install\n\nAlternatively, add \"icit/wp-less\" as a requirement to your composer.json, and add this git repository e.g.:\n\n    {\n        \"repositories\": [\n            {\n                \"type\": \"git\",\n                \"url\": \"https://github.com/sanchothefat/wp-less.git\"\n            }\n        ],\n        \"require\": {\n            \"icit/wp-less\": \"dev-master\"\n        }\n    }\n\n## Usage:\n\nYou can either install the script as a standard plugin or use it as an include within a theme or plugin.\n\nFor use with themes add the following lines to your functions.php:\n\n```php\n\u003c?php\n\n// Include the class (unless you are using the script as a plugin)\nrequire_once( 'wp-less/wp-less.php' );\n\n// enqueue a .less style sheet\nif ( ! is_admin() )\n    wp_enqueue_style( 'style', get_stylesheet_directory_uri() . '/style.less' );\n\n// you can also use .less files as mce editor style sheets\nadd_editor_style( 'editor-style.less' );\n\n```\n\nAny registered styles with the `.less` suffix will be compiled and the file URL rewritten.\n\nYou won't need a link to your main style sheet in `header.php`. Just make sure\nthat `wp_head()` is called in the document head.\n\nAll the standard LESS features are supported as well as `@import` rules anywhere\nwithin the file.\n\n### Passing in variables from PHP\n\nYou can pass variables into your `.less` files using the `less_vars` hook or with the\nfunctions defined in the PHP Interface section:\n\n```php\n\u003c?php\n\n// pass variables into all .less files\nadd_filter( 'less_vars', 'my_less_vars', 10, 2 );\nfunction my_less_vars( $vars, $handle ) {\n    // $handle is a reference to the handle used with wp_enqueue_style()\n    $vars[ 'color' ] = '#000000';\n    return $vars;\n}\n\n?\u003e\n```\n\nWithin your `.less` files you can use the variable as if you had declared it in the stylesheet.\nFor e.g.:\n\n```css\nbody { color: @color; }\n```\n\n### Default variables\n\n*There are 2 default variables* you can use without worrying about the above code:\n\n**`@themeurl`** is the URL of the current theme directory:\n\n```css\nbody { background-image: url(@{themeurl}/images/background.png); }\n```\n\n*`@lessurl`** is the URL of the enqueued LESS file (this does not change inside imported files):\n\n```css\n.plugin-title { background-image: url(@{lessurl}/images/icon.png); }\n```\n\n`@lessurl` is useful in those cases where you have .less files inside plugins or\nother non theme folder locations.\n\nIt is important to use these because you can't use relative paths - the compiled CSS is\nstored in the uploads folder as it is the only place you can guarantee being\nable to write to in any given WordPress installation. As a result relative URLs will\nbreak.\n\n### PHP interface\n\n`register_less_function()` allows you to create additional less compiler functions\nfor use in your stylesheet without having to touch the `lessc` class yourself.\n\n```php\nregister_less_function( 'double', function( $args ) {\n    list( $type, $value, $unit ) = $args;\n\treturn array( $type, $value*2, $unit );\n} );\n```\n\n`unregister_less_function()` works in a similar way but unregisters any compiler\nfunctions passed to it by name.\n\n```php\nunregister_less_function( 'double' );\n```\n\n`add_less_var()` makes it easy to create or modify variables passed into the\ncompiler. Both arguments should be a string, as `lessc` will work out the type of\nvariable it is.\n\n```php\nadd_less_var( 'brandcolour', '#ec6704' );\n```\n\n`remove_less_var()` is the inverse of `add_less_var()` and only requires the\nvariable name to remove.\n\n```php\nremove_less_var( 'brandcolour' );\n```\n\n## Further Reading\n\n[Read the LESS.js documentation here](http://lesscss.org/).\n\nRead the documentation [specific to the PHP parser here](http://leafo.net/lessphp/docs/).\n\n\n## Contributors\n\nBig massive thanks to those whose contributions and discussion has helped to improve the plugin.\n\n* [Tom Willmot](https://github.com/willmot)\n* [Franz Josef Kaiser](https://github.com/franz-josef-kaiser)\n* [Rarst](https://github.com/rarst)\n\n## License\n\nThe software is licensed under the [MIT Licence](http://www.opensource.org/licenses/mit-license.php).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froborourke%2Fwp-less","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Froborourke%2Fwp-less","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froborourke%2Fwp-less/lists"}