Actions and Filters
This document explains the use of actions and filters in WP Bones. It highlights several key actions, such as {your_plugin_slug}_loaded
, wpbones_console_deploy_start
, wpbones_console_deploy_before_build_assets
, wpbones_console_deploy_after_build_assets
, and wpbones_console_deploy_completed
. These actions allow developers to hook into various points of the plugin lifecycle and perform custom operations, enhancing the flexibility and functionality of WP Bones plugins.
Overview
It is very important to note that WP Bones uses actions and filters at several points.
Actions
{your_plugin_slug}_loaded
/**
* Fired when your plugin is started
*
*/
add_action('{your_plugin_slug}_loaded', function () {
// Do something
});
wpbones_console_deploy_start
/**
* Fired when the deploy command is started
*
* @param object $console Instance of WPBones Console
* @param string $path Destination path
*/
add_action('wpbones_console_deploy_start', function ($console, $path) {
// Do something
}, 10, 2);
wpbones_console_deploy_before_build_assets
/**
* Fired before building assets
*
* @param object $console Instance of WPBones Console
* @param string $path Destination path
*/
add_action('wpbones_console_deploy_before_build_assets', function ($console, $path) {
// Do something
}, 10, 2);
wpbones_console_deploy_after_build_assets
/**
* Fired after building assets
*
* @param object $console Instance of WPBones Console
* @param string $path Destination path
*/
add_action('wpbones_console_deploy_after_build_assets', function ($console, $path) {
// Do something
}, 10, 2);
wpbones_console_deploy_completed
/**
* Fires when the console deploy is completed.
*
* @param mixed $bones This bones command instance.
* @param string $path The deployed path.
*/
do_action('wpbones_console_deploy_completed', $this, $path);
Filters
wpbones_console_deploy_build_assets
/**
* Filter to enable or disable the build assets during the deployment.
*
* @since 1.9.0
* @param bool $buildAssets True to build assets, false to skip the build.
*/
add_filter('wpbones_console_deploy_build_assets', function ($buildAssets) {
return $buildAssets;
});
wpbones_console_deploy_dont_skip_files_folders
/**
* Filter the list of files and folders that won't be skipped during the deployment.
*
* @since 1.9.0
* @param array $array The files and folders are relative to the root of plugin.
*/
add_filter('wpbones_console_deploy_dont_skip_files_folders', function ($array) {
return $array;
});
wpbones_console_deploy_default_skip_files_folders
/**
* Filter the default list of files and folders to skip during the deployment.
* Applied before `wpbones_console_deploy_skip_folders`
*
* @since 1.9.0
* @param array $array The files and folders are relative to the root of plugin.
*/
add_filter('wpbones_console_deploy_default_skip_files_folders', function ($array) {
return $array;
});
wpbones_console_deploy_skip_folders
/**
* Filter the list of files and folders to skip during the deployment.
*
* @param array $array The files and folders are relative to the root of plugin.
* @return array List of folders to skip
*/
add_filter('wpbones_console_deploy_skip_folders', function ($array) {
return $array;
});