dbout/wp-hooks 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

dbout/wp-hooks

最新稳定版本:v1.1.0

Composer 安装命令:

composer require dbout/wp-hooks

包简介

Wordpress hooks manager

README 文档

README

Wordpress library that makes it easier to manage actions and filters.

Latest Stable Version PHP Version

Requirements

The server requirements are basically the same as for WordPress with the addition of a few ones :

To simplify the integration of this library, we recommend using Wordpress with one of the following tools: Bedrock, Themosis or Wordplate.

Installation

Install with composer, in the root of the Wordpress project run:

composer require dbout/wp-hooks

Usage

Via classes

The default use is via classes, the idea of creating a class per hook:

class InitHook extends \Dbout\WpHooks\Hookable\Hookable {

    protected string $hook = 'init';

    public function execute(): void 
    {
        // Do something
    }
}

In the function.php file of your theme, you must now load the hook:

$loader = new \Dbout\WpHooks\HooksLoader();
$loader->add(InitHook::class);

$loader->register();

If you want, you can record several hooks with the loader:

$loader = new \Dbout\WpHooks\HooksLoader();
$loader
    ->add(InitHook::class)
    ->add(RegisterMenus::class)
    ->add(RegisterAssets::class);

$loader->register();

Second methods

Without instance :

\Dbout\WpHooks\Facade\Action::add('init', 'InitHooks@callback');

With custom instance :

\Dbout\WpHooks\Facade\Action::add('init', [new InitHooks(), 'callback']);

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-04-10