PluginProbe
Hostinger Tools / 2.1.2
Hostinger Tools v2.1.2
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 / class-hostinger-loader.php

class-hostinger-loader.php in Hostinger Tools 2.1.2, at includes/class-hostinger-loader.php

65 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 defined( 'ABSPATH' ) || exit;
4
5 class Hostinger_Loader {
6 protected array $actions;
7 protected array $filters;
8
9 public function __construct() {
10 $this->actions = array();
11 $this->filters = array();
12 }
13
14 public function add_action( string $hook, $component, string $callback, int $priority = 10, int $accepted_args = 1 ) {
15 $this->actions = $this->add( $this->actions, $hook, $component, $callback, $priority, $accepted_args );
16 }
17
18 public function add_filter( string $hook, $component, string $callback, int $priority = 10, int $accepted_args = 1 ) {
19 $this->filters = $this->add( $this->filters, $hook, $component, $callback, $priority, $accepted_args );
20 }
21
22
23 private function add(
24 array $hooks,
25 string $hook,
26 $component,
27 string $callback,
28 int $priority,
29 int $accepted_args
30 ): array {
31 $hooks[] = array(
32 'hook' => $hook,
33 'component' => $component,
34 'callback' => $callback,
35 'priority' => $priority,
36 'accepted_args' => $accepted_args,
37 );
38
39 return $hooks;
40 }
41
42 /**
43 * @return void
44 */
45 public function run(): void {
46 foreach ( $this->filters as $hook ) {
47 add_filter(
48 $hook['hook'],
49 array( $hook['component'], $hook['callback'] ),
50 $hook['priority'],
51 $hook['accepted_args']
52 );
53 }
54
55 foreach ( $this->actions as $hook ) {
56 add_action(
57 $hook['hook'],
58 array( $hook['component'], $hook['callback'] ),
59 $hook['priority'],
60 $hook['accepted_args']
61 );
62 }
63 }
64 }
65