/** * actually register the hook on wordpress * @param string $event * @param array $callback * @param int $priority * @param int $acceptedArgs * @param Pressor\Proxy\Proxy $proxy */ protected function bind($event, array $callback, $priority, $acceptedArgs, Proxy $proxy = null) { if ($proxy) { $proxy->addAction($event, $callback, $priority, $acceptedArgs); return; } add_action($event, $callback, $priority, $acceptedArgs); }
/** * register the hook with wordpress * @param Pressor\Contracts\Proxy\Proxy $proxy * @throws LogicException */ public function register(Proxy $proxy = null) { $event = $this->event; $callback = $this->callback; $priority = $this->priority; if ($proxy) { $success = $proxy->removeFilter($event, $callback, $priority); } else { $success = remove_filter($event, $callback, $priority); } if (!$success) { throw new \LogicException('Hook on event [' . $event . '] for callback [' . $callback . '] with priority [' . $priority . '] could not be removed'); } }