定制 krypton/hooks 二次开发

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

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

krypton/hooks

最新稳定版本:0.0.1-alpha

Composer 安装命令:

composer require krypton/hooks

包简介

A hook system for PHP

README 文档

README

The PHP Hooks Class is a fork of the WordPress filters hook system rolled in to a class to be ported into any php based system

  • This class is heavily based on the WordPress plugin API and most (if not all) of the code comes from there.

How to install?

composer require krypton/hooks

How to use?

We start with a simple example ...

<?php

use Krypton\Hooks\Hooks;

function print_user_save()
{
    echo "User is Saved";
}

function print_user_added()
{
    echo "User is Added to the System";
}

$hooks = Hooks::getInstance();

$hooks->getAction()->add($hooks->getFilter(), 'user_save', 'print_user_save');

$hooks->getAction()->add($hooks->getFilter(), 'user_save', 'print_user_added');

$hooks->getFilter()->add('uppercase', 'strtoupper');

then all that is left for you is to call the hooked function when you want anywhere in your application, EX:

<?php

$hooks = Hooks::getInstance();

echo '<div id="extra_header">';

echo $hooks->getFilter()->apply('uppercase', 'taranjeet');

$hooks->getAction()->do($hooks->getFilter(), 'user_save');

echo '</div>';

License

Since this class is derived from the WordPress Plugin API so are the license and they are GPL http://www.gnu.org/licenses/gpl.html

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL-3.0
  • 更新时间: 2023-06-02