*/ class Action { /** * Hook a function or method to a specific filter action. * * @param $tag * @param string $function * @param int $priority * @param int $acceptedArgs */ public static function hook($tag, $function, $priority = 10, $acceptedArgs = 1) { if (!function_exists('add_filter')) { require_once ABSPATH . '/wp-includes/plugin.php'; } add_filter($tag, function (...$args) use ($function) { return app()->call($function, $args); }, $priority, $acceptedArgs); } /** * Run all filters hooked to
$tag
on the given
$value
. * * @param string $tag tag to run * @param mixed $value value to run filters on * @param array ...$params extra params to pass to filters * * @return mixed */ public static function filter($tag, $value, ...$params) { return apply_filters($tag, $value, ...$params); } /** * Execute functions hooked on a specific action hook. * * @param string $tag name of the action to be executed * @param array $params parameters to pass to the hooked functions */ public static function trigger($tag, ...$params) { return do_action($tag, ...$params); } }