PluginProbe
Discount Rules for WooCommerce – Disco | Dynamic Pricing, Conditions, Bulk, Bundle, BOGO / 1.4.14
Discount Rules for WooCommerce – Disco | Dynamic Pricing, Conditions, Bulk, Bundle, BOGO v1.4.14
1.4.14 1.4.13 1.4.12 1.4.11 1.4.10 1.4.9 1.4.8 1.4.7 1.4.6 1.4.5 1.4.4 1.4.3 1.4.2 1.4.1 1.4.0 1.3.54 1.3.53 1.3.52 1.3.51 1.3.50 1.3.49 1.3.48 1.3.47 1.3.46 1.3.45 All 177 releases
disco / vendor / inpsyde / assets / src / Asset.php

Asset.php in Discount Rules for WooCommerce – Disco | Dynamic Pricing, Conditions, Bulk, Bundle, BOGO 1.4.14, at vendor/inpsyde/assets/src/Asset.php

199 lines 4.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /*
4 * This file is part of the Assets package.
5 *
6 * (c) Inpsyde GmbH
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 namespace Inpsyde\Assets;
13
14 use Inpsyde\Assets\Handler\AssetHandler;
15 use Inpsyde\Assets\OutputFilter\AssetOutputFilter;
16
17 interface Asset
18 {
19 // Location types
20 public const FRONTEND = 2;
21 public const BACKEND = 4;
22 public const CUSTOMIZER = 8;
23 public const LOGIN = 16;
24 public const BLOCK_EDITOR_ASSETS = 32;
25 public const BLOCK_ASSETS = 64;
26 public const CUSTOMIZER_PREVIEW = 128;
27 public const ACTIVATE = 256;
28 // Hooks
29 public const HOOK_FRONTEND = 'wp_enqueue_scripts';
30 public const HOOK_BACKEND = 'admin_enqueue_scripts';
31 public const HOOK_LOGIN = 'login_enqueue_scripts';
32 public const HOOK_CUSTOMIZER = 'customize_controls_enqueue_scripts';
33 public const HOOK_CUSTOMIZER_PREVIEW = 'customize_preview_init';
34 public const HOOK_BLOCK_ASSETS = 'enqueue_block_assets';
35 public const HOOK_BLOCK_EDITOR_ASSETS = 'enqueue_block_editor_assets';
36 public const HOOK_ACTIVATE = 'activate_wp_head';
37 /**
38 * Hooks to Locations map
39 * @var array<string,int>
40 */
41 public const HOOK_TO_LOCATION = [
42 Asset::HOOK_FRONTEND => Asset::FRONTEND,
43 Asset::HOOK_BACKEND => Asset::BACKEND,
44 Asset::HOOK_LOGIN => Asset::LOGIN,
45 Asset::HOOK_CUSTOMIZER => Asset::CUSTOMIZER,
46 Asset::HOOK_CUSTOMIZER_PREVIEW => Asset::CUSTOMIZER_PREVIEW,
47 Asset::HOOK_BLOCK_ASSETS => Asset::BLOCK_ASSETS,
48 Asset::HOOK_BLOCK_EDITOR_ASSETS => Asset::BLOCK_EDITOR_ASSETS,
49 Asset::HOOK_ACTIVATE => Asset::ACTIVATE,
50 ];
51
52 /**
53 * Contains the full url to file.
54 *
55 * @return string
56 */
57 public function url(): string;
58
59 /**
60 * Returns the full file path to the asset.
61 *
62 * @return string
63 */
64 public function filePath(): string;
65
66 /**
67 * Define the full filePath to the Asset.
68 *
69 * @param string $filePath
70 *
71 * @return static
72 */
73 public function withFilePath(string $filePath): Asset;
74
75 /**
76 * Name of the given asset.
77 *
78 * @return string
79 */
80 public function handle(): string;
81
82 /**
83 * A list of handle-dependencies.
84 *
85 * @return string[]
86 */
87 public function dependencies(): array;
88
89 /**
90 * @param string ...$dependencies
91 *
92 * @return static
93 */
94 public function withDependencies(string ...$dependencies): Asset;
95
96 /**
97 * The current version of the asset.
98 *
99 * @return string|null
100 */
101 public function version(): ?string;
102
103 /**
104 * @param string $version
105 *
106 * @return static
107 */
108 public function withVersion(string $version): Asset;
109
110 /**
111 * @return bool
112 */
113 public function enqueue(): bool;
114
115 /**
116 * @param bool|callable $enqueue
117 *
118 * @return static
119 *
120 * phpcs:disable Inpsyde.CodeQuality.ArgumentTypeDeclaration.NoArgumentType
121 */
122 public function canEnqueue($enqueue): Asset;
123
124 /**
125 * Location where the asset is enqueued.
126 *
127 * @return int
128 *
129 * @example Asset::FRONTEND | Asset::BACKEND
130 * @example Asset::FRONTEND
131 */
132 public function location(): int;
133
134 /**
135 * Define a location based on Asset location types.
136 *
137 * @param int $location
138 *
139 * @return static
140 */
141 public function forLocation(int $location): Asset;
142
143 /**
144 * A list of assigned output filters to change the rendered tag.
145 *
146 * @return callable[]|AssetOutputFilter[]|class-string<AssetOutputFilter>[]
147 */
148 public function filters(): array;
149
150 /**
151 * @param callable|class-string<AssetOutputFilter> ...$filters
152 *
153 * @return static
154 */
155 public function withFilters(...$filters): Asset;
156
157 /**
158 * Name of the handler class to register and enqueue the asset.
159 *
160 * @return class-string<AssetHandler>
161 */
162 public function handler(): string;
163
164 /**
165 * @param class-string<AssetHandler> $handler
166 *
167 * @return static
168 */
169 public function useHandler(string $handler): Asset;
170
171 /**
172 * @return array
173 */
174 public function data(): array;
175
176 /**
177 * Add a conditional tag for your Asset.
178 *
179 * @param string $condition
180 *
181 * @return static
182 *
183 * @see https://developer.wordpress.org/reference/functions/wp_script_add_data/#comment-1007
184 */
185 public function withCondition(string $condition): Asset;
186
187 /**
188 * @return array<string, mixed>
189 */
190 public function attributes(): array;
191
192 /**
193 * @param array<string, mixed> $attributes
194 *
195 * @return Asset
196 */
197 public function withAttributes(array $attributes): Asset;
198 }
199