定制 pollora/hook 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

pollora/hook

Composer 安装命令:

composer require pollora/hook

包简介

A modern PHP package for WordPress hook (action/filter) management with callback resolution and reflection caching

README 文档

README

A modern PHP package for WordPress hook (action/filter) management with callback resolution and reflection caching.

Installation

composer require pollora/hook

Quick Start

use Pollora\Hook\Action;
use Pollora\Hook\Filter;

$action = new Action;
$filter = new Filter;

// Register action
$action->add('init', function () {
    // runs on WordPress init
});

// Register filter
$filter->add('the_content', function (string $content): string {
    return $content . '<p>Appended!</p>';
});

// Execute action
$action->do('my_custom_action', $arg1, $arg2);

// Apply filter
$filtered = $filter->apply('my_filter', $value);

// Remove hook
$action->remove('init', $callback);

Pollora framework users: When the framework is available, prefer the Laravel facades Pollora\Support\Facades\Action and Pollora\Support\Facades\Filter for full DI container support. A notice is emitted if you use the standalone classes within the framework.

Class-based Callbacks

// Class with method matching hook name (StudlyCase convention)
$action->add('wp_loaded', MyInitializer::class);
// Resolves to [new MyInitializer, 'wpLoaded']

// With dependency injection
$action->setCallbackResolver($myResolver);
$action->add('wp_loaded', MyInitializer::class);
// Resolves via $myResolver->resolve(MyInitializer::class)

Documentation

See docs/hooks.md for full documentation.

Testing

composer test

License

GPL-2.0-or-later

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2026-07-02

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固