File "class-hook-manager.php"

Full path: /home/kosmetik/public_html/wp-content/plugins/woocommerce/vendor/automattic/jetpack-autoloader/src/class-hook-manager.php
File size: 951 B
MIME-type: text/x-php
Charset: utf-8

Download   Open   Edit   Advanced Editor   Back

<?php

class Hook_Manager
{
    private $registered_hooks;
    public function __construct()
    {
        $this->registered_hooks = array();
    }
    public function add_action($tag, $callable, $priority = 10, $accepted_args = 1)
    {
        $this->registered_hooks[$tag][] = array('priority' => $priority, 'callable' => $callable);
        add_action($tag, $callable, $priority, $accepted_args);
    }
    public function add_filter($tag, $callable, $priority = 10, $accepted_args = 1)
    {
        $this->registered_hooks[$tag][] = array('priority' => $priority, 'callable' => $callable);
        add_filter($tag, $callable, $priority, $accepted_args);
    }
    public function reset()
    {
        foreach ($this->registered_hooks as $tag => $hooks) {
            foreach ($hooks as $hook) {
                remove_filter($tag, $hook['callable'], $hook['priority']);
            }
        }
        $this->registered_hooks = array();
    }
}