1 | <?php |
||
24 | abstract class AbstractDependencyHandler implements DependencyHandlerInterface { |
||
25 | |||
26 | use FunctionInvokerTrait; |
||
27 | |||
28 | /** |
||
29 | * Register the dependency's assets. |
||
30 | * |
||
31 | * @since 0.1.0 |
||
32 | * |
||
33 | * @param array|null $args Optional. Array of arguments that is |
||
34 | * passed to the registration function. |
||
35 | * @throws InvalidArgumentException If the register function could not be |
||
36 | * called. |
||
37 | */ |
||
38 | public function register( $args = null ) { |
||
41 | |||
42 | /** |
||
43 | * Get the name of the function that is used for registering the dependency. |
||
44 | * |
||
45 | * @since 0.1.0 |
||
46 | * |
||
47 | * @return string Function name. |
||
48 | */ |
||
49 | abstract protected function get_register_function(); |
||
50 | |||
51 | /** |
||
52 | * Enqueue the dependency's assets. |
||
53 | * |
||
54 | * @since 0.1.0 |
||
55 | * |
||
56 | * @param array|null $args Optional. Array of arguments that is |
||
57 | * passed to the enqueueing function. |
||
58 | * @throws InvalidArgumentException If the register function could not be |
||
59 | * called. |
||
60 | */ |
||
61 | public function enqueue( $args = null ) { |
||
69 | |||
70 | /** |
||
71 | * Get the name of the function that is used for enqueueing the dependency. |
||
72 | * |
||
73 | * @since 0.1.0 |
||
74 | * |
||
75 | * @return string Function name. |
||
76 | */ |
||
77 | abstract protected function get_enqueue_function(); |
||
78 | |||
79 | /** |
||
80 | * Maybe enqueue a dependency that has been registered outside of the |
||
81 | * Dependency Manager. |
||
82 | * |
||
83 | * @since 0.2.3 |
||
84 | * |
||
85 | * @param string $handle Handle of the dependency to enqueue. |
||
86 | * @return bool Whether the handle was found or not. |
||
87 | */ |
||
88 | public function maybe_enqueue( $handle ) { |
||
100 | |||
101 | /** |
||
102 | * Check whether a specific handle has been enqueued. |
||
103 | * |
||
104 | * @since 0.3.3 |
||
105 | * |
||
106 | * @param string $handle The handle to check |
||
107 | * @return bool Whether it is enqueued or not. |
||
108 | */ |
||
109 | abstract public function is_enqueued( $handle ); |
||
110 | |||
111 | /** |
||
112 | * Check whether a specific handle has been registered. |
||
113 | * |
||
114 | * @since 0.2.3 |
||
115 | * @since 0.3.3 Publicly accessible. |
||
116 | * |
||
117 | * @param string $handle The handle to check |
||
118 | * @return bool Whether it is registered or not. |
||
119 | */ |
||
120 | abstract public function is_registered( $handle ); |
||
121 | } |
||
122 |