| 1 |
<?php namespace WeDevs\ERP\Framework\Traits; |
| 2 |
|
| 3 |
/** |
| 4 |
* Class Hooker |
| 5 |
* |
| 6 |
* @package WeDevs\ERP\Framework\Traits |
| 7 |
*/ |
| 8 |
trait Hooker { |
| 9 |
|
| 10 |
/** |
| 11 |
* Hooks a function on to a specific action. |
| 12 |
* |
| 13 |
* @param $tag |
| 14 |
* @param $function |
| 15 |
* @param int $priority |
| 16 |
* @param int $accepted_args |
| 17 |
*/ |
| 18 |
public function action( $tag, $function, $priority = 10, $accepted_args = 1 ) { |
| 19 |
add_action( $tag, [ $this, $function ], $priority, $accepted_args ); |
| 20 |
} |
| 21 |
|
| 22 |
/** |
| 23 |
* Hooks a function on to a specific filter. |
| 24 |
* |
| 25 |
* @param $tag |
| 26 |
* @param $function |
| 27 |
* @param int $priority |
| 28 |
* @param int $accepted_args |
| 29 |
*/ |
| 30 |
public function filter( $tag, $function, $priority = 10, $accepted_args = 1 ) { |
| 31 |
add_filter( $tag, [ $this, $function ], $priority, $accepted_args ); |
| 32 |
} |
| 33 |
} |