承接 offsetwp/hook-wordpress 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

offsetwp/hook-wordpress

最新稳定版本:1.0.1

Composer 安装命令:

composer require offsetwp/hook-wordpress

包简介

Typed, secure, and maintainable WordPress Core action and filter hooks

README 文档

README

OffsetWP Hook WordPress OffsetWP Hook WordPress

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;
	}
}

统计信息

  • 总下载量: 23
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-12-18

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固