コード例 #1
0
ファイル: Action.php プロジェクト: pressor/framework
 /**
  * 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);
 }
コード例 #2
0
ファイル: Remove.php プロジェクト: pressor/framework
 /**
  * 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');
     }
 }