Requests_Hooks

Handles adding and dispatching events.

Defined (1)

The class is defined in the following location(s).

/wp-includes/Requests/Hooks.php  
  1. class Requests_Hooks implements Requests_Hooker { 
  2. /** 
  3. * Registered callbacks for each hook 
  4. * @var array 
  5. */ 
  6. protected $hooks = array(); 
  7.  
  8. /** 
  9. * Constructor 
  10. */ 
  11. public function __construct() { 
  12. // pass 
  13.  
  14. /** 
  15. * Register a callback for a hook 
  16. * @param string $hook Hook name 
  17. * @param callback $callback Function/method to call on event 
  18. * @param int $priority Priority number. <0 is executed earlier, >0 is executed later 
  19. */ 
  20. public function register($hook, $callback, $priority = 0) { 
  21. if (!isset($this->hooks[$hook])) { 
  22. $this->hooks[$hook] = array(); 
  23. if (!isset($this->hooks[$hook][$priority])) { 
  24. $this->hooks[$hook][$priority] = array(); 
  25.  
  26. $this->hooks[$hook][$priority][] = $callback; 
  27.  
  28. /** 
  29. * Dispatch a message 
  30. * @param string $hook Hook name 
  31. * @param array $parameters Parameters to pass to callbacks 
  32. * @return boolean Successfulness 
  33. */ 
  34. public function dispatch($hook, $parameters = array()) { 
  35. if (empty($this->hooks[$hook])) { 
  36. return false; 
  37.  
  38. foreach ($this->hooks[$hook] as $priority => $hooked) { 
  39. foreach ($hooked as $callback) { 
  40. call_user_func_array($callback, $parameters); 
  41.  
  42. return true;