While a plugin is (in WordPress) some kind of functionality or tool, a package is a collection of at least one or more modules. When it comes to WordPress development, packages help to deal with certain kind of development topics. So does the package we developed and which we want to introduce today, as it’s available for free on GitHub. The WordPress composer package Inpsyde Assets allows to deal with scripts and styles in a WordPress site.
The WordPress Composer Package Inpsyde Assets
The package is an OOP wrapper and allows to register and enqueue scripts and styles in a WordPress site in different locations.
The minimum requirements to use this package are PHP 7+ and WordPress latest-2. In case you want to install the package for development, via Composer, Inpsyde Assets also requires:
- phpunit/phpunit (BSD-3-Clause)
- brain/monkey (MIT)
Simply install the package via Composer:
When using Assets in your theme or plugin, you can simply access the Inpsyde\Assets\AssetManager by hooking into the setup-hook.
When using Assets in your theme or plugin, you can simply access the
Inpsyde\Assets\AssetManager by hooking into the setup-hook.
This way you can start registering your assets:
Instead of creating instances by hand, it’s sometimes easier to use configuration via array or file to manage your specific assets.
In your application you can create all assets from that file by using the
There are two main classes delivered:
Inpsyde\Assets\Style– dealing with CSS-files.
Each instance requires a
int $location and optionally a configuration via
Following configurations are available:
|dependencies||array||||x||x||all defined depending handles|
|location||int||falls back to ||x||x||depending on location of the
|version||string||x||x||version of the given asset|
|enqueue||bool/callable||x||x||is the asset only registered or also enqueued|
|data||array/callable||x||x||additional data assigned to the asset|
|filters||callable||x||x||an array of
|x||x||The handler which will be used to register/enqueue the Asset|
|localize||array/callable||x||localized array of data attached to
|inFooter||bool||x||defines if the current
|media||string||x||type of media for the
By default the package comes with predefined locations of assets:
To avoid duplicated registration of Assets in different locations such as backend and frontend, it is possible to add multiple locations via bitwise operator
Additional Information about WordPress Composer Package Inpsyde Assets
You can use some
OutputFilters which are specified to manipulate the output of the
style_loader_tag. Check out which
OutputFilter Inpsyde Assets provides and, moreover, how to create your own filter in GitHub.
If you have questions or feedback, simply leave a comment and we’ll answer. 🙂