PluginProbe
Hostinger Tools / 1.9.4
Hostinger Tools v1.9.4
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 1.9.4, at includes/class-hostinger-loader.php

57 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 = [];
11 $this->filters = [];
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[] = [
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( $hook['hook'], [ $hook['component'], $hook['callback'] ], $hook['priority'],
48 $hook['accepted_args'] );
49 }
50
51 foreach ( $this->actions as $hook ) {
52 add_action( $hook['hook'], [ $hook['component'], $hook['callback'] ], $hook['priority'],
53 $hook['accepted_args'] );
54 }
55 }
56 }
57