PluginProbe
Hostinger Tools / 2.1.9
Hostinger Tools v2.1.9
3.0.77 3.0.76 3.0.75 3.0.74 3.0.73 3.0.72 3.0.71 3.0.70 3.0.69 3.0.68 3.0.67 3.0.66 1.8.1 1.8.2 1.8.3 1.9.1 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.1 2.0.4 All 108 releases
hostinger / includes / Loader.php

Loader.php in Hostinger Tools 2.1.9, at includes/Loader.php

67 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Hostinger;
4
5 defined( 'ABSPATH' ) || exit;
6
7 class Loader {
8 protected array $actions;
9 protected array $filters;
10
11 public function __construct() {
12 $this->actions = array();
13 $this->filters = array();
14 }
15
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 }
19
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 }
23
24
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 );
40
41 return $hooks;
42 }
43
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 }
66 }
67