horttcore/wp-plugin

此软件包已被废弃,不再维护。作者建议使用ralfhortt/wp-plugin软件包。

WordPress插件助手

2.0.1 2020-01-09 19:36 UTC

This package is auto-updated.

Last update: 2022-05-30 09:17:08 UTC


README

使用方法

  • 创建插件容器
  • 添加服务
  • 启动插件

安装

composer require ralfhortt/wp-plugin

使用方法

  • 使用具有register方法的类创建服务类
  • 将服务添加到插件工厂

示例

简单示例

<?php
use RalfHortt\Plugin\PluginFactory;

PluginFactory::create()
    ->addService(Service::class)
    ->boot();

高级示例

<?php
use RalfHortt\Plugin\PluginFactory;

PluginFactory::create()
    ->addService(anotherService::class, 'Foo', ['bar'])
    ->boot();

钩子

<?php
use RalfHortt\Plugin\PluginFactory;

PluginFactory::create()
    ->addServiceHook('wp_head', anotherService::class)
    ->boot();

变更日志

v2.1.0 - 2022-05-30

  • 新增:添加addServiceHook方法以定义服务注册的WordPress钩子

v2.0.1 - 2020-01-09

  • 修复:将参数传递给构造函数而不是register方法

v2.0.0 - 2019-12-09

  • 新增:将参数传递给服务注册函数
  • 更改:命名空间更改为RalfHortt\Plugin
  • 更改:将翻译移动到其自己的服务

v1.0.1 - 2019-01-16

  • 更改:PluginFactory返回一个新的Plugin对象而不是一个共享实例

v1.0.0 - 2019-01-15

  • 首次发布