PluginProbe
Packeta / 2.1
Packeta v2.1
2.3.2 2.3.1 trunk 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.3.0 1.3.1 1.3.2 1.4 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 All 56 releases
packeta / src / Packetery / Module / Framework / HookTrait.php

HookTrait.php in Packeta 2.1, at src/Packetery/Module/Framework/HookTrait.php

63 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 * Trait HookTrait.
4 *
5 * @package Packetery
6 */
7
8 declare( strict_types=1 );
9
10 namespace Packetery\Module\Framework;
11
12 /**
13 * Trait HookTrait.
14 *
15 * @package Packetery
16 */
17 trait HookTrait {
18 public function addAction( string $hookName, callable $callback, int $priority = 10, int $acceptedArgs = 1 ): ?bool {
19 return add_action( $hookName, $callback, $priority, $acceptedArgs );
20 }
21
22 public function addFilter( string $hookName, callable $callback, int $priority = 10, int $acceptedArgs = 1 ): void {
23 add_filter( $hookName, $callback, $priority, $acceptedArgs );
24 }
25
26 /**
27 * Applies filters.
28 *
29 * @param string $hookName Hook name.
30 * @param mixed $value Value.
31 * @param mixed ...$args Arguments.
32 *
33 * @return mixed
34 */
35 public function applyFilters( string $hookName, $value, ...$args ) {
36 /**
37 * Bridged function call.
38 *
39 * @since 1.7.7
40 */
41 return apply_filters( $hookName, $value, ...$args );
42 }
43
44 /**
45 * Tells if action was performed.
46 *
47 * @param string $hookName Name of hook.
48 *
49 * @return int
50 */
51 public function didAction( string $hookName ): int {
52 return did_action( $hookName );
53 }
54
55 public function registerDeactivationHook( string $file, callable $callback ): void {
56 register_deactivation_hook( $file, $callback );
57 }
58
59 public function registerActivationHook( string $file, callable $callback ): void {
60 register_activation_hook( $file, $callback );
61 }
62 }
63