{"id":21611516,"url":"https://github.com/underpin-wp/style-loader","last_synced_at":"2026-05-11T16:36:46.757Z","repository":{"id":48830923,"uuid":"363787128","full_name":"Underpin-WP/style-loader","owner":"Underpin-WP","description":"Style loader for Underpin","archived":false,"fork":false,"pushed_at":"2021-11-23T16:37:03.000Z","size":25,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-08T01:01:52.427Z","etag":null,"topics":["styles","underpin","wordpress"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Underpin-WP.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-05-03T01:21:43.000Z","updated_at":"2021-11-23T16:37:06.000Z","dependencies_parsed_at":"2022-08-24T10:52:14.287Z","dependency_job_id":null,"html_url":"https://github.com/Underpin-WP/style-loader","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Underpin-WP%2Fstyle-loader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Underpin-WP%2Fstyle-loader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Underpin-WP%2Fstyle-loader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Underpin-WP%2Fstyle-loader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Underpin-WP","download_url":"https://codeload.github.com/Underpin-WP/style-loader/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244257304,"owners_count":20424131,"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":["styles","underpin","wordpress"],"created_at":"2024-11-24T21:12:59.668Z","updated_at":"2026-05-11T16:36:46.729Z","avatar_url":"https://github.com/Underpin-WP.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Underpin Style Loader\n\nLoader That assists with adding styles to a WordPress website.\n\n## Installation\n\n### Using Composer\n\n`composer require underpin/loaders/styles`\n\n### Manually\n\nThis plugin uses a built-in autoloader, so as long as it is required _before_\nUnderpin, it should work as-expected.\n\n`require_once(__DIR__ . '/underpin-styles/styles.php');`\n\n## Setup\n\n1. Install Underpin. See [Underpin Docs](https://www.github.com/underpin-wp/underpin)\n1. Register new styles as-needed.\n\n## Example\n\nA very basic example could look something like this.\n\n```php\nunderpin()-\u003estyles()-\u003eadd( 'test', [\n\t'src'         =\u003e 'path/to/style/src',\n\t'name'        =\u003e 'test',\n\t'description' =\u003e 'The description',\n] );\n\n```\n\nAlternatively, you can extend `Style` and reference the extended class directly, like so:\n\n```php\nunderpin()-\u003estyles()-\u003eadd('key','Namespace\\To\\Class');\n```\n\n## Enqueuing Styles\n\nTo enqueue a styles, run the loader and reference the style ID, like so:\n\n```php\nunderpin()-\u003estyle()-\u003eenqueue('test'); // Enqueue the test style\n```\n\n### Enqueuing With Middleware\n\nIn circumstances where you _always_ need to enqueue the style, you can use the provided enqueue middleware.\n\nTo enqueue on admin screens:\n\n```php\nunderpin()-\u003estyles()-\u003eadd( 'test', [\n        'handle'      =\u003e 'test',\n        'src'         =\u003e 'path/to/style/src',\n        'name'        =\u003e 'test',\n        'description' =\u003e 'The description',\n        'middlewares' =\u003e [\n          'Underpin_Styles\\Factories\\Enqueue_Admin_Style'\n        ]\n] );\n```\n\nTo enqueue on the front-end:\n\n```php\nunderpin()-\u003estyles()-\u003eadd( 'test', [\n        'handle'      =\u003e 'test',\n        'src'         =\u003e 'path/to/style/src',\n        'name'        =\u003e 'test',\n        'description' =\u003e 'The description',\n        'middlewares' =\u003e [\n          'Underpin_Styles\\Factories\\Enqueue_Style'\n        ]\n] );\n```\n\nTo enqueue on both front-end and back-end:\n\n```php\nunderpin()-\u003estyles()-\u003eadd( 'test', [\n        'handle'      =\u003e 'test',\n        'src'         =\u003e 'path/to/style/src',\n        'name'        =\u003e 'test',\n        'description' =\u003e 'The description',\n        'middlewares' =\u003e [\n          'Underpin_Styles\\Factories\\Enqueue_Style',\n          'Underpin_Styles\\Factories\\Enqueue_Admin_Style'\n        ]\n] );\n```\n\n### Create Your Own Middleware\n\nThe `middlewares` array uses `Underpin::make_class` to create the class instances. This means that you can pass either:\n\n1. a string that references an instance of `Style_Middleware` (see example above).\n1. An array of arguments to construct an instance of `Style_Middleware` on-the-fly.\n\n```php\nunderpin()-\u003estyles()-\u003eadd( 'test', [\n\t'handle'      =\u003e 'test',\n\t'src'         =\u003e 'path/to/style/src',\n\t'name'        =\u003e 'test',\n\t'description' =\u003e 'The description',\n\t'middlewares' =\u003e [\n\t\t'Underpin_Styles\\Factories\\Enqueue_Style',            // Will enqueue the style on the front end all the time.\n\t\t[                                                     // Will instantiate an instance of Style_Middleware_Instance using the provided arguments\n\t\t\t'name'                =\u003e 'Custom setup params',\n\t\t\t'description'         =\u003e 'Sets up custom parameters specific to this style',\n\t\t\t'priority'            =\u003e 10, // Optional. Default 10.\n\t\t\t'do_actions_callback' =\u003e function ( \\Underpin_Styles\\Abstracts\\Style $loader_item ) {\n\t\t\t\t// Do actions\n\t\t\t},\n\t\t],\n\t],\n] );\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funderpin-wp%2Fstyle-loader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Funderpin-wp%2Fstyle-loader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funderpin-wp%2Fstyle-loader/lists"}