| @@ -4,90 +4,63 @@ | ||
| 4 | 4 | |
| 5 | 5 | defined( 'ABSPATH' ) || exit; |
| 6 | 6 | |
| 7 | 7 | class Loader { |
| 8 | - protected array $actions; | |
| 9 | - protected array $filters; | |
| 8 | + protected array $actions; | |
| 9 | + protected array $filters; | |
| 10 | 10 | |
| 11 | - public function __construct() { | |
| 12 | - $this->actions = array(); | |
| 13 | - $this->filters = array(); | |
| 14 | - } | |
| 11 | + public function __construct() { | |
| 12 | + $this->actions = array(); | |
| 13 | + $this->filters = array(); | |
| 14 | + } | |
| 15 | 15 | |
| 16 | - /** | |
| 17 | - * @param string $hook | |
| 18 | - * @param mixed $component | |
| 19 | - * @param string $callback | |
| 20 | - * @param int $priority | |
| 21 | - * @param int $accepted_args | |
| 22 | - * | |
| 23 | - * @return void | |
| 24 | - */ | |
| 25 | - public function add_action( string $hook, $component, string $callback, int $priority = 10, int $accepted_args = 1 ) { | |
| 26 | - $this->actions = $this->add( $this->actions, $hook, $component, $callback, $priority, $accepted_args ); | |
| 27 | - } | |
| 16 | + public function add_action( string $hook, $component, string $callback, int $priority = 10, int $accepted_args = 1 ) { | |
| 17 | + $this->actions = $this->add( $this->actions, $hook, $component, $callback, $priority, $accepted_args ); | |
| 18 | + } | |
| 28 | 19 | |
| 29 | - /** | |
| 30 | - * @param string $hook | |
| 31 | - * @param mixed $component | |
| 32 | - * @param string $callback | |
| 33 | - * @param int $priority | |
| 34 | - * @param int $accepted_args | |
| 35 | - * | |
| 36 | - * @return void | |
| 37 | - */ | |
| 38 | - public function add_filter( string $hook, $component, string $callback, int $priority = 10, int $accepted_args = 1 ) { | |
| 39 | - $this->filters = $this->add( $this->filters, $hook, $component, $callback, $priority, $accepted_args ); | |
| 40 | - } | |
| 20 | + public function add_filter( string $hook, $component, string $callback, int $priority = 10, int $accepted_args = 1 ) { | |
| 21 | + $this->filters = $this->add( $this->filters, $hook, $component, $callback, $priority, $accepted_args ); | |
| 22 | + } | |
| 41 | 23 | |
| 42 | - /** | |
| 43 | - * @param array $hooks | |
| 44 | - * @param string $hook | |
| 45 | - * @param mixed $component | |
| 46 | - * @param string $callback | |
| 47 | - * @param int $priority | |
| 48 | - * @param int $accepted_args | |
| 49 | - * | |
| 50 | - * @return array | |
| 51 | - */ | |
| 52 | - private function add( | |
| 53 | - array $hooks, | |
| 54 | - string $hook, | |
| 55 | - $component, | |
| 56 | - string $callback, | |
| 57 | - int $priority, | |
| 58 | - int $accepted_args | |
| 59 | - ): array { | |
| 60 | - $hooks[] = array( | |
| 61 | - 'hook' => $hook, | |
| 62 | - 'component' => $component, | |
| 63 | - 'callback' => $callback, | |
| 64 | - 'priority' => $priority, | |
| 65 | - 'accepted_args' => $accepted_args, | |
| 66 | - ); | |
| 67 | 24 | |
| 68 | - return $hooks; | |
| 69 | - } | |
| 25 | + private function add( | |
| 26 | + array $hooks, | |
| 27 | + string $hook, | |
| 28 | + $component, | |
| 29 | + string $callback, | |
| 30 | + int $priority, | |
| 31 | + int $accepted_args | |
| 32 | + ): array { | |
| 33 | + $hooks[] = array( | |
| 34 | + 'hook' => $hook, | |
| 35 | + 'component' => $component, | |
| 36 | + 'callback' => $callback, | |
| 37 | + 'priority' => $priority, | |
| 38 | + 'accepted_args' => $accepted_args, | |
| 39 | + ); | |
| 70 | 40 | |
| 71 | - /** | |
| 72 | - * @return void | |
| 73 | - */ | |
| 74 | - public function run(): void { | |
| 75 | - foreach ( $this->filters as $hook ) { | |
| 76 | - add_filter( | |
| 77 | - $hook['hook'], | |
| 78 | - array( $hook['component'], $hook['callback'] ), | |
| 79 | - $hook['priority'], | |
| 80 | - $hook['accepted_args'] | |
| 81 | - ); | |
| 82 | - } | |
| 41 | + return $hooks; | |
| 42 | + } | |
| 83 | 43 | |
| 84 | - foreach ( $this->actions as $hook ) { | |
| 85 | - add_action( | |
| 86 | - $hook['hook'], | |
| 87 | - array( $hook['component'], $hook['callback'] ), | |
| 88 | - $hook['priority'], | |
| 89 | - $hook['accepted_args'] | |
| 90 | - ); | |
| 91 | - } | |
| 92 | - } | |
| 44 | + /** | |
| 45 | + * @return void | |
| 46 | + */ | |
| 47 | + public function run(): void { | |
| 48 | + foreach ( $this->filters as $hook ) { | |
| 49 | + add_filter( | |
| 50 | + $hook['hook'], | |
| 51 | + array( $hook['component'], $hook['callback'] ), | |
| 52 | + $hook['priority'], | |
| 53 | + $hook['accepted_args'] | |
| 54 | + ); | |
| 55 | + } | |
| 56 | + | |
| 57 | + foreach ( $this->actions as $hook ) { | |
| 58 | + add_action( | |
| 59 | + $hook['hook'], | |
| 60 | + array( $hook['component'], $hook['callback'] ), | |
| 61 | + $hook['priority'], | |
| 62 | + $hook['accepted_args'] | |
| 63 | + ); | |
| 64 | + } | |
| 65 | + } | |
| 93 | 66 | } |