Edit File by line
/home/barbar84/public_h.../wp-inclu.../Requests
File: Hooks.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Handles adding and dispatching events
[2] Fix | Delete
*
[3] Fix | Delete
* @package Requests
[4] Fix | Delete
* @subpackage Utilities
[5] Fix | Delete
*/
[6] Fix | Delete
[7] Fix | Delete
/**
[8] Fix | Delete
* Handles adding and dispatching events
[9] Fix | Delete
*
[10] Fix | Delete
* @package Requests
[11] Fix | Delete
* @subpackage Utilities
[12] Fix | Delete
*/
[13] Fix | Delete
class Requests_Hooks implements Requests_Hooker {
[14] Fix | Delete
/**
[15] Fix | Delete
* Registered callbacks for each hook
[16] Fix | Delete
*
[17] Fix | Delete
* @var array
[18] Fix | Delete
*/
[19] Fix | Delete
protected $hooks = array();
[20] Fix | Delete
[21] Fix | Delete
/**
[22] Fix | Delete
* Constructor
[23] Fix | Delete
*/
[24] Fix | Delete
public function __construct() {
[25] Fix | Delete
// pass
[26] Fix | Delete
}
[27] Fix | Delete
[28] Fix | Delete
/**
[29] Fix | Delete
* Register a callback for a hook
[30] Fix | Delete
*
[31] Fix | Delete
* @param string $hook Hook name
[32] Fix | Delete
* @param callback $callback Function/method to call on event
[33] Fix | Delete
* @param int $priority Priority number. <0 is executed earlier, >0 is executed later
[34] Fix | Delete
*/
[35] Fix | Delete
public function register($hook, $callback, $priority = 0) {
[36] Fix | Delete
if (!isset($this->hooks[$hook])) {
[37] Fix | Delete
$this->hooks[$hook] = array();
[38] Fix | Delete
}
[39] Fix | Delete
if (!isset($this->hooks[$hook][$priority])) {
[40] Fix | Delete
$this->hooks[$hook][$priority] = array();
[41] Fix | Delete
}
[42] Fix | Delete
[43] Fix | Delete
$this->hooks[$hook][$priority][] = $callback;
[44] Fix | Delete
}
[45] Fix | Delete
[46] Fix | Delete
/**
[47] Fix | Delete
* Dispatch a message
[48] Fix | Delete
*
[49] Fix | Delete
* @param string $hook Hook name
[50] Fix | Delete
* @param array $parameters Parameters to pass to callbacks
[51] Fix | Delete
* @return boolean Successfulness
[52] Fix | Delete
*/
[53] Fix | Delete
public function dispatch($hook, $parameters = array()) {
[54] Fix | Delete
if (empty($this->hooks[$hook])) {
[55] Fix | Delete
return false;
[56] Fix | Delete
}
[57] Fix | Delete
[58] Fix | Delete
foreach ($this->hooks[$hook] as $priority => $hooked) {
[59] Fix | Delete
foreach ($hooked as $callback) {
[60] Fix | Delete
call_user_func_array($callback, $parameters);
[61] Fix | Delete
}
[62] Fix | Delete
}
[63] Fix | Delete
[64] Fix | Delete
return true;
[65] Fix | Delete
}
[66] Fix | Delete
[67] Fix | Delete
public function __wakeup() {
[68] Fix | Delete
throw new \LogicException( __CLASS__ . ' should never be unserialized' );
[69] Fix | Delete
}
[70] Fix | Delete
}
[71] Fix | Delete
[72] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function