offsetwp/hook-wordpress
Composer 安装命令:
composer require offsetwp/hook-wordpress
包简介
Typed, secure, and maintainable WordPress Core action and filter hooks
README 文档
README
OffsetWP Hook
Typed, secure, and maintainable WordPress Core action and filter hooks
About OffsetWP WordPress
WordPress makes extensive use of hooks for its internal functioning. Unfortunately, the way it was developed makes it difficult to work with hook data:
- the callback is public and accessible by any other function
- to find out the returned parameters, you have to consult the documentation
- no auto-completion
OffsetWP Hook provides ready-to-use wrappers for native WordPress hooks. The wrappers already include the exact callback signatures, allowing for optimal autocompletion in your IDE.
Installation
composer require offsetwp/hook
Basic usage
use OffsetWP\Hook\WordPress\Filter\WPAdminFooterTextFilter; new class extends WPAdminFooterTextFilter { protected function handle( $text ) { return 'Made with love by OffsetWP | ' . $text; } };
Hook with a dynamique name
use OffsetWP\Hook\WordPress\Filter\WPGetMetaTypeMetadataFilter; new class extends WPGetMetaTypeMetadataFilter { public string $hook_name = 'get_post_metadata'; // 'get_{$meta_type}_metadata' protected function handle( $value, $object_id, $meta_key, $single, $meta_type ) { return $value; } };
Advanced usage
With more substantial development, it may be necessary for your hooks to use dependencies. All of this is possible, depending on your needs:
use OffsetWP\Hook\WordPress\Filter\WPAdminFooterTextFilter; new class extends WPAdminFooterTextFilter { public function __construct( private $myServiceName = 'CustomService' ) { return parent::__construct(); } protected function handle( $text ) { return $this->myServiceName . ' | ' . $text; } }
offsetwp/hook-wordpress 适用场景与选型建议
offsetwp/hook-wordpress 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 23 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 12 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「wordpress」 「HOOK」 「offsetwp」 「add_action」 「add_filter」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 offsetwp/hook-wordpress 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 offsetwp/hook-wordpress 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 offsetwp/hook-wordpress 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Easily manage git hooks in your composer config
A system for organizing WordPress hooks
Composer plugin for running post-install/post-update scripts of your project's dependencies
GitHub Webhook Listener with plugin-based API for creating your own triggerered actions
A simple pre commit git file
Marussia hook implementation
统计信息
- 总下载量: 23
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 17
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-12-18

