at path:
ROOT
/
wp-includes
/
Requests
/
src
/
Hooks.php
run:
R
W
Run
Auth
DIR
2024-09-15 08:00:44
R
W
Run
Cookie
DIR
2024-06-24 17:16:39
R
W
Run
Exception
DIR
2024-09-15 08:01:08
R
W
Run
Proxy
DIR
2024-09-15 08:01:41
R
W
Run
Response
DIR
2024-09-15 08:01:51
R
W
Run
Transport
DIR
2024-09-15 08:02:03
R
W
Run
Utility
DIR
2024-06-24 17:16:39
R
W
Run
Auth.php
860 By
2022-12-15 21:32:17
R
W
Run
Delete
Rename
Autoload.php
9.12 KB
2023-04-05 13:12:26
R
W
Run
Delete
Rename
Capability.php
652 By
2023-04-05 13:12:26
R
W
Run
Delete
Rename
Cookie.php
15.03 KB
2024-09-04 11:48:32
R
W
Run
Delete
Rename
Exception.php
1.09 KB
2022-12-15 21:32:17
R
W
Run
Delete
Rename
HookManager.php
709 By
2022-12-15 21:32:17
R
W
Run
Delete
Rename
Hooks.php
2.96 KB
2023-10-12 12:34:33
R
W
Run
Delete
Rename
IdnaEncoder.php
12.14 KB
2023-04-05 13:12:26
R
W
Run
Delete
Rename
Ipv6.php
5.51 KB
2022-12-15 21:32:17
R
W
Run
Delete
Rename
Iri.php
28.93 KB
2023-10-12 12:34:33
R
W
Run
Delete
Rename
Port.php
1.47 KB
2022-12-15 21:32:17
R
W
Run
Delete
Rename
Proxy.php
867 By
2022-12-15 21:32:17
R
W
Run
Delete
Rename
Requests.php
33.2 KB
2024-09-04 11:48:32
R
W
Run
Delete
Rename
Response.php
4.18 KB
2023-04-05 13:12:26
R
W
Run
Delete
Rename
Session.php
8.89 KB
2023-10-12 12:34:33
R
W
Run
Delete
Rename
Ssl.php
5.3 KB
2022-12-15 21:32:17
R
W
Run
Delete
Rename
Transport.php
1.51 KB
2022-12-15 21:32:17
R
W
Run
Delete
Rename
error_log
4.48 KB
2026-02-05 03:47:01
R
W
Run
Delete
Rename
error_log
up
📄
Hooks.php
Save
<?php /** * Handles adding and dispatching events * * @package Requests\EventDispatcher */ namespace WpOrg\Requests; use WpOrg\Requests\Exception\InvalidArgument; use WpOrg\Requests\HookManager; use WpOrg\Requests\Utility\InputValidator; /** * Handles adding and dispatching events * * @package Requests\EventDispatcher */ class Hooks implements HookManager { /** * Registered callbacks for each hook * * @var array */ protected $hooks = []; /** * Register a callback for a hook * * @param string $hook Hook name * @param callable $callback Function/method to call on event * @param int $priority Priority number. <0 is executed earlier, >0 is executed later * @throws \WpOrg\Requests\Exception\InvalidArgument When the passed $hook argument is not a string. * @throws \WpOrg\Requests\Exception\InvalidArgument When the passed $callback argument is not callable. * @throws \WpOrg\Requests\Exception\InvalidArgument When the passed $priority argument is not an integer. */ public function register($hook, $callback, $priority = 0) { if (is_string($hook) === false) { throw InvalidArgument::create(1, '$hook', 'string', gettype($hook)); } if (is_callable($callback) === false) { throw InvalidArgument::create(2, '$callback', 'callable', gettype($callback)); } if (InputValidator::is_numeric_array_key($priority) === false) { throw InvalidArgument::create(3, '$priority', 'integer', gettype($priority)); } if (!isset($this->hooks[$hook])) { $this->hooks[$hook] = [ $priority => [], ]; } elseif (!isset($this->hooks[$hook][$priority])) { $this->hooks[$hook][$priority] = []; } $this->hooks[$hook][$priority][] = $callback; } /** * Dispatch a message * * @param string $hook Hook name * @param array $parameters Parameters to pass to callbacks * @return boolean Successfulness * @throws \WpOrg\Requests\Exception\InvalidArgument When the passed $hook argument is not a string. * @throws \WpOrg\Requests\Exception\InvalidArgument When the passed $parameters argument is not an array. */ public function dispatch($hook, $parameters = []) { if (is_string($hook) === false) { throw InvalidArgument::create(1, '$hook', 'string', gettype($hook)); } // Check strictly against array, as Array* objects don't work in combination with `call_user_func_array()`. if (is_array($parameters) === false) { throw InvalidArgument::create(2, '$parameters', 'array', gettype($parameters)); } if (empty($this->hooks[$hook])) { return false; } if (!empty($parameters)) { // Strip potential keys from the array to prevent them being interpreted as parameter names in PHP 8.0. $parameters = array_values($parameters); } ksort($this->hooks[$hook]); foreach ($this->hooks[$hook] as $priority => $hooked) { foreach ($hooked as $callback) { $callback(...$parameters); } } return true; } public function __wakeup() { throw new \LogicException( __CLASS__ . ' should never be unserialized' ); } }