johnbillion/wp-hooks
最新稳定版本:1.11.0
Composer 安装命令:
composer require johnbillion/wp-hooks
包简介
All the actions and filters from WordPress core in machine-readable JSON format.
README 文档
README
All the actions and filters from WordPress core in machine-readable JSON format.
Last updated for WordPress 6.9.
Installation
- As a Composer package for use in PHP:
composer require wp-hooks/wordpress-core
- As an npm package for use in JavaScript or TypeScript:
npm install @wp-hooks/wordpress-core
Usage in PHP
// Get hooks as JSON: $actions_json = file_get_contents( 'vendor/wp-hooks/wordpress-core/hooks/actions.json' ); $filters_json = file_get_contents( 'vendor/wp-hooks/wordpress-core/hooks/filters.json' ); // Convert hooks to PHP: $actions = json_decode( $actions_json, true )['hooks']; $filters = json_decode( $filters_json, true )['hooks']; // Search for filters matching a string: $search = 'permalink'; $results = array_filter( $filters, function( array $hook ) use ( $search ) { return ( strpos( $hook['name'], $search ) !== false ); } ); var_dump( $results );
Usage in JavaScript
// Get hooks as array of objects: const actions = require('@wp-hooks/wordpress-core/hooks/actions.json').hooks; const filters = require('@wp-hooks/wordpress-core/hooks/filters.json').hooks; // Search for actions matching a string: const search = 'menu'; const results = actions.filter( hook => ( hook.name.match( search ) !== null ) ); console.log(results);
Importing in TypeScript
import { hooks as actions } from '@wp-hooks/wordpress-core/hooks/actions.json'; import { hooks as filters } from '@wp-hooks/wordpress-core/hooks/filters.json';
Interfaces for the components of the hooks can be imported too, if you need them:
import { Hooks, Hook, Doc, Tags, Tag } from '@wp-hooks/wordpress-core/interface';
Actions, Filters, and Schemas
- The actions can be found in hooks/actions.json
- The filters can be found in hooks/filters.json
- The JSON schema can be found in hooks/schema.json
- The TypeScript interfaces can be found in interface/index.d.ts
What can I use this for?
Anything that needs programmatic access to a list of available hooks, for example:
- Autocomplete WordPress action and filter names in VS Code
- Autocomplete WordPress action and filter names in Vim
- WordPress plugin for Psalm
Regenerating the Hook Files
Change the roots/wordpress-full version in composer.json to one of:
- The required major version, such as
6.8 dev-mainfor nightlies prior to RC- An RC version, such as
6.9-RC1
Install the dependencies:
npm i && composer i
Then run:
composer generate
During generation, a change and data integrity issues are saved in CHANGELOG.md and ISSUES.md respectively.
Hook Files for Plugins
Do you want the same hook files for your favourite plugins? The hook files in this repo are generated using wp-hooks-generator. It can generate hook files for WordPress plugins and themes as well as core.
Sponsors
The time that I spend maintaining this library and others is in part sponsored by:
Plus all my kind sponsors on GitHub:
Click here to find out about supporting my open source tools and plugins.
johnbillion/wp-hooks 适用场景与选型建议
johnbillion/wp-hooks 是一款 基于 Shell 开发的 Composer 扩展包,目前已累计 145.38k 次下载、GitHub Stars 达 123, 最近一次更新时间为 2019 年 10 月 28 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 johnbillion/wp-hooks 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 johnbillion/wp-hooks 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 145.38k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 123
- 点击次数: 20
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0-or-later
- 更新时间: 2019-10-28