tombroucke/wp-fluent-hooks
Composer 安装命令:
composer require tombroucke/wp-fluent-hooks
包简介
A small utility package that provides a modern, fluent interface for adding WordPress action and filter hooks. Chain methods to build your hooks in a more expressive and readable way.
README 文档
README
Filters
Basic usage:
Filter::hook('the_title') ->register(fn ($title) => strtoupper($title));
With priority and argument count:
Filter::hook('save_post') ->args(3) // Default 1 ->priority(11) // Default 10 ->register(function ($postId, $post, $update) { // Do something });
Actions
Action and Filter share the same API and can be used interchangeably.
Action::hook('init') ->register(function () { // Do something });
Aliases
Assign an alias to reference the hook later:
Action::hook('body_class') ->alias('my_custom_body_class') ->register(fn ($classes) => array_merge($classes, ['custom-class']));
Deregistering
Remove a registered hook by its alias:
Action::deregister('my_custom_body_class');
If you didn't define an alias, retrieve the auto-generated one from the registered instance:
$filter = Filter::hook('the_title') ->register(fn ($title) => strtoupper($title)); $alias = $filter->getAlias(); Filter::deregister($alias);
统计信息
- 总下载量: 9
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 11
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2026-04-30