miradozk/wordpress-hook

此包的最新版本(1.8)没有可用的许可证信息。

WordPress Hook

1.8 2021-03-26 19:26 UTC

This package is auto-updated.

Last update: 2024-09-27 03:42:10 UTC


README

这个库允许使用 WordPress 的钩子以面向对象的方式工作。

功能

  • 钩子覆盖(add_action, add_filter, 短代码,激活和停用,WP_CLI)
  • 使用自定义服务器进行更新
  • 使用 Monolog 记录日志

示例

<?php
namespace MyPlugin;

use MiradoZk\WordPressHook\Hook;

class Application extends Hook
{
    /**
     * Plugin Repository URL
     *
     * @var string
     */
    protected $hub = 'https://myserver.com/?plugin=';


    public function boot()
    {
        // add_action('save_post', 'callback', 10, 1);
        $this->action('save_post', 'callback', 1, 10);
        
        // add_filter('the_content', 'callback', 10, 1);
        $this->filter('the_content', 'callback', 1, 10);
        
        // register_activation_hook(__FILE__, 'callback');
        $this->install('callback');
        
        // register_deactivation_hook(__FILE__, 'callback');
        $this->uninstall('callback');        
        
        // Log
        $logger = $this->getLogger();
    }
}