themehybrid / hybrid-mix
Hybrid Mix is a helper class for WordPress plugins and themes using Laravel Mix.
Installs: 3 438
Dependents: 1
Suggesters: 0
Security: 0
Stars: 10
Watchers: 3
Forks: 1
Open Issues: 0
Requires
- php: >=5.6
This package is auto-updated.
Last update: 2024-11-29 06:22:52 UTC
README
Hybrid Mix is a class for working with Lavarel Mix. It adds helper methods for quickly grabbing asset files cached in the mix-manifest.json
file.
Requirements
- WordPress 5.7+.
- PHP 5.6+ (preferably 7+).
- Composer for managing PHP dependencies.
Documentation
Create a new instance of the Hybrid\Mix\Mix
class, passing in a file path and file URI to your project's public
folder.
use Hybrid\Mix\Mix; $mix = new Mix( 'public/folder/path', 'public/folder/uri' );
Return the cached asset file URI with an appended ID using the asset()
method:
// Stylesheet: public/folder/uri/css/style.css?id=xxx $mix->asset( 'css/style.css' ); // JavaScript: public/folder/uri/js/app.js?id=xxx $mix->asset( 'js/app.js' );
When using the core WordPress enqueue functions, make sure to set the $ver
parameter to null
(not false
). The id
parameter added to the file URL will serve for cache busting.
// Stylesheet. wp_enqueue_style( $handle, $mix->asset( 'css/style.css' ), $deps, null, $media ); // JavaScript. wp_enqueue_script( $handle, $mix->asset( 'js/app.js' ), $deps, null, $in_footer );
Copyright and License
This project is licensed under the GNU GPL, version 2 or later.
2021 © Justin Tadlock.