Constants
2 weeks ago
Contracts
2 weeks ago
Hooks
2 weeks ago
Models
2 weeks ago
BaseHook.php
2 weeks ago
HookServiceProvider.php
2 weeks ago
Menu.php
2 weeks ago
User.php
2 weeks ago
UserMeta.php
2 weeks ago
BaseHook.php
70 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Base hook subscriber with sensible defaults for WordPress action and filter registration. |
| 5 | * Implements HookSubscriber with standard priority and accepted-args values for concrete hook classes. |
| 6 | * Reduces boilerplate when wiring framework integrations into WordPress lifecycle events. |
| 7 | * Subclasses must implement: - get_name() - get_type() - handle() |
| 8 | * This class also defines constants for hook types: ACTION and FILTER. |
| 9 | * |
| 10 | * @package Framework |
| 11 | * @subpackage Wordpress |
| 12 | * @since 1.0.0 |
| 13 | */ |
| 14 | namespace Kirki\Framework\Wordpress; |
| 15 | |
| 16 | \defined('ABSPATH') || exit; |
| 17 | use Kirki\Framework\Wordpress\Contracts\HookSubscriber; |
| 18 | abstract class BaseHook implements HookSubscriber |
| 19 | { |
| 20 | /** |
| 21 | * Get the priority for this hook. Can be overridden by subclasses. |
| 22 | * |
| 23 | * @return int Hook priority. Lower numbers correspond to earlier execution. |
| 24 | * |
| 25 | * @since 1.0.0 |
| 26 | */ |
| 27 | public function get_priority() |
| 28 | { |
| 29 | return 10; |
| 30 | } |
| 31 | /** |
| 32 | * Get the number of arguments accepted by the hook callback. |
| 33 | * Can be overridden by subclasses. |
| 34 | * |
| 35 | * @return int Number of accepted arguments. |
| 36 | * |
| 37 | * @since 1.0.0 |
| 38 | */ |
| 39 | public function get_args_count() |
| 40 | { |
| 41 | return 1; |
| 42 | } |
| 43 | /** |
| 44 | * Get the name. |
| 45 | * |
| 46 | * @return mixed |
| 47 | * |
| 48 | * @since 1.0.0 |
| 49 | */ |
| 50 | public abstract function get_name(); |
| 51 | /** |
| 52 | * Get the type. |
| 53 | * |
| 54 | * @return mixed |
| 55 | * |
| 56 | * @since 1.0.0 |
| 57 | */ |
| 58 | public abstract function get_type(); |
| 59 | /** |
| 60 | * Handle. |
| 61 | * |
| 62 | * @param mixed $args The positional arguments. |
| 63 | * |
| 64 | * @return void |
| 65 | * |
| 66 | * @since 1.0.0 |
| 67 | */ |
| 68 | public abstract function handle(...$args); |
| 69 | } |
| 70 |