A Javascript version of the actions and filters used in PHP in WordPress for WP Bones.
This package works with a WordPress plugin written with WP Bones framework library.
You can install third party packages by using:
php bones require wpbones/actions-and-filters-js
I advise to use this command instead of composer require
because doing this an automatic renaming will done.
You can use composer to install this package:
composer require wpbones/actions-and-filters-js
You may also to add "wpbones/actions-and-filters-js": "^1.0"
in the composer.json
file of your plugin:
"require": {
"php": ">=7.4",
"wpbones/wpbones": "~0.8",
"wpbones/actions-and-filters-js": "~1.0"
},
and run
composer install
Alternatively, you can get the single files src/resources/assets/js/actions-and-filters.js
in your WP Bones plugin and compile it with gulp
.
Also, you can get pre-compiled minified version src/public/js/actions-and-filters.min.js
.
You can use the provider to enqueue the styles.
public function index()
{
// enqueue the minified version
ActionsAndFiltersJSProvider::enqueueScripts();
// ...
}
This is a static class autoloaded by composer. You can use it to enqueue or get the styles path:
// enqueue the minified version
ActionsAndFiltersJSProvider::enqueueScripts();
// enqueue the flat version
ActionsAndFiltersJSProvider::enqueueScripts( false );
// return the absolute path of the minified css
ActionsAndFiltersJSProvider::js();
// return the absolute path of the flat css
ActionsAndFiltersJSProvider::js();
Let's an example:
wpbones_add_action( 'my-action', function() { alert( "Hello" ) } );
...
wpbones_do_action( 'my-action' );
This Javascript version works in the same way than PHP version in WordPress.