dugajean/wp-hook-annotations
Composer 安装命令:
composer require dugajean/wp-hook-annotations
包简介
Use PHP Docblock (annotations) to register WordPress hooks, filters and shortcodes.
README 文档
README
Use PHP Docblock (annotations) to register WordPress hooks, filters and shortcodes.
Requirements
- PHP 7.1+
Install
Via Composer
$ composer require dugajean/wp-hook-annotations
Usage
To automatically wire up your class, simply call the HookRegistry::bootstrap method, like so:
<?php namespace My\CoolNamespace; use Dugajean\WpHookAnnotations\HookRegistry; use Dugajean\WpHookAnnotations\Models\Action; class MyClass { public function __construct(HookRegistry $hookRegistry) { $hookRegistry->bootstrap($this); } /** * @Action(tag="init") */ public function doSomething() { // do something } }
And you're done!
The following annotations can be used:
/** * @Action(tag="the hook name", priority=1, accepted_args=1) * @Filter(tag="the filter name", priority=1, accepted_args=1) * @Shortcode(tag="the shortcode code") */
Testing
$ composer test
License
WP Hook Annotations is released under the MIT License.
统计信息
- 总下载量: 4.26k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-06-01