定制 j10o/whenthen 二次开发

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

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

j10o/whenthen

Composer 安装命令:

composer require j10o/whenthen

包简介

A drop-in package for wrapping WordPress' add_action and do_action(soon)

README 文档

README

WhenThen

A drop-in package for wrapping WordPress' add_action and do_action(soon) :octocat:

A Glimpse

$wp_event = new \WhenThen\MiddleWare\Event();
$wp_event->when( $hook = array( 'name' => 'wp' ) )->then( function(){
    echo '𝙷𝚎𝚕𝚕𝚘, 𝚆𝚘𝚛𝚍𝙿𝚛𝚎𝚜𝚜';
});

Basic usage

Via composer

Do composer require j10o/whenthen

Or locate your project's composer.json then add j10o/whenthen": "dev-main" in require property.

For example:

{
    "require": {
        "j10o/whenthen": "dev-main"
    }
}

In your plugin's main file include the vendor autoload.

// Require Composer's autoload file.
require __DIR__ . '/vendor/autoload.php';

// Create new event object.
$wp_event = new \WhenThen\MiddleWare\Event();

// Similar to add_action stuff with WordPress.
$wp_loaded = array(
    'name' => 'wp',
    'priority' => 10,
    'num_args' => 1
);

// Same here.
$footer_loaded = array(
    'name' => 'wp_footer',
    'priority' => 10,
);

// Closure function to call when something happen.
$do_this_thing_1 = function($query_vars) {
    error_log( var_export( $query_vars, true ) );
};

// Another closure function to call when something happen.
$do_this_thing_2 = function() {
    echo 'I am in footer.';
};

// Listen to the event.
$wp_event->when( $wp_loaded )->then( $do_this_thing_1 );

// Another one.
$wp_event->when( $footer_loaded )->then( $do_this_thing_2 );

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL-3.0-only
  • 更新时间: 2022-11-23

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固