@@ -20,43 +20,43 @@ |
||
20 | 20 | class ReactAssetManager extends AssetManager |
21 | 21 | { |
22 | 22 | |
23 | - const REACT_VERSION = '17.0.1'; |
|
24 | - |
|
25 | - const JS_HANDLE_REACT = 'react'; |
|
26 | - |
|
27 | - const JS_HANDLE_REACT_DOM = 'react-dom'; |
|
28 | - |
|
29 | - |
|
30 | - /** |
|
31 | - * @throws InvalidDataTypeException |
|
32 | - * @throws InvalidEntityException |
|
33 | - * @throws DuplicateCollectionIdentifierException |
|
34 | - * @throws DomainException |
|
35 | - */ |
|
36 | - public function addAssets() |
|
37 | - { |
|
38 | - // TODO get these values from router |
|
39 | - $is_ee_domain = true; |
|
40 | - $is_blocks_domain = false; |
|
41 | - |
|
42 | - if (!$is_ee_domain || $is_blocks_domain) { |
|
43 | - return; |
|
44 | - } |
|
45 | - |
|
46 | - wp_deregister_script(ReactAssetManager::JS_HANDLE_REACT); |
|
47 | - wp_deregister_script(ReactAssetManager::JS_HANDLE_REACT_DOM); |
|
48 | - |
|
49 | - $this->addVendorJavascript( |
|
50 | - ReactAssetManager::JS_HANDLE_REACT, |
|
51 | - [], |
|
52 | - true, |
|
53 | - ReactAssetManager::REACT_VERSION |
|
54 | - ); |
|
55 | - $this->addVendorJavascript( |
|
56 | - ReactAssetManager::JS_HANDLE_REACT_DOM, |
|
57 | - [ReactAssetManager::JS_HANDLE_REACT], |
|
58 | - true, |
|
59 | - ReactAssetManager::REACT_VERSION |
|
60 | - ); |
|
61 | - } |
|
23 | + const REACT_VERSION = '17.0.1'; |
|
24 | + |
|
25 | + const JS_HANDLE_REACT = 'react'; |
|
26 | + |
|
27 | + const JS_HANDLE_REACT_DOM = 'react-dom'; |
|
28 | + |
|
29 | + |
|
30 | + /** |
|
31 | + * @throws InvalidDataTypeException |
|
32 | + * @throws InvalidEntityException |
|
33 | + * @throws DuplicateCollectionIdentifierException |
|
34 | + * @throws DomainException |
|
35 | + */ |
|
36 | + public function addAssets() |
|
37 | + { |
|
38 | + // TODO get these values from router |
|
39 | + $is_ee_domain = true; |
|
40 | + $is_blocks_domain = false; |
|
41 | + |
|
42 | + if (!$is_ee_domain || $is_blocks_domain) { |
|
43 | + return; |
|
44 | + } |
|
45 | + |
|
46 | + wp_deregister_script(ReactAssetManager::JS_HANDLE_REACT); |
|
47 | + wp_deregister_script(ReactAssetManager::JS_HANDLE_REACT_DOM); |
|
48 | + |
|
49 | + $this->addVendorJavascript( |
|
50 | + ReactAssetManager::JS_HANDLE_REACT, |
|
51 | + [], |
|
52 | + true, |
|
53 | + ReactAssetManager::REACT_VERSION |
|
54 | + ); |
|
55 | + $this->addVendorJavascript( |
|
56 | + ReactAssetManager::JS_HANDLE_REACT_DOM, |
|
57 | + [ReactAssetManager::JS_HANDLE_REACT], |
|
58 | + true, |
|
59 | + ReactAssetManager::REACT_VERSION |
|
60 | + ); |
|
61 | + } |
|
62 | 62 | } |
@@ -39,7 +39,7 @@ |
||
39 | 39 | $is_ee_domain = true; |
40 | 40 | $is_blocks_domain = false; |
41 | 41 | |
42 | - if (!$is_ee_domain || $is_blocks_domain) { |
|
42 | + if ( ! $is_ee_domain || $is_blocks_domain) { |
|
43 | 43 | return; |
44 | 44 | } |
45 | 45 |
@@ -23,332 +23,332 @@ |
||
23 | 23 | abstract class AssetManager implements AssetManagerInterface |
24 | 24 | { |
25 | 25 | |
26 | - /** |
|
27 | - * @var AssetCollection|Asset[] $assets |
|
28 | - */ |
|
29 | - protected $assets; |
|
30 | - |
|
31 | - /** |
|
32 | - * @var DomainInterface |
|
33 | - */ |
|
34 | - protected $domain; |
|
35 | - |
|
36 | - /** |
|
37 | - * @var Registry $registry |
|
38 | - */ |
|
39 | - protected $registry; |
|
40 | - |
|
41 | - |
|
42 | - /** |
|
43 | - * AssetRegister constructor. |
|
44 | - * |
|
45 | - * @param DomainInterface $domain |
|
46 | - * @param AssetCollection $assets |
|
47 | - * @param Registry $registry |
|
48 | - */ |
|
49 | - public function __construct(DomainInterface $domain, AssetCollection $assets, Registry $registry) |
|
50 | - { |
|
51 | - $this->domain = $domain; |
|
52 | - $this->assets = $assets; |
|
53 | - $this->registry = $registry; |
|
54 | - $this->registry->addAssetCollection($assets); |
|
55 | - add_action('wp_enqueue_scripts', array($this, 'addAssets'), 2); |
|
56 | - add_action('admin_enqueue_scripts', array($this, 'addAssets'), 2); |
|
57 | - } |
|
58 | - |
|
59 | - |
|
60 | - /** |
|
61 | - * @return AssetCollection |
|
62 | - */ |
|
63 | - public function getAssets() |
|
64 | - { |
|
65 | - return $this->assets; |
|
66 | - } |
|
67 | - |
|
68 | - |
|
69 | - /** |
|
70 | - * @since 4.9.71.p |
|
71 | - * @return string |
|
72 | - */ |
|
73 | - public function assetNamespace() |
|
74 | - { |
|
75 | - return $this->domain->assetNamespace(); |
|
76 | - } |
|
77 | - |
|
78 | - |
|
79 | - /** |
|
80 | - * @param string $handle |
|
81 | - * @param string $source |
|
82 | - * @param array $dependencies |
|
83 | - * @param bool $load_in_footer |
|
84 | - * @param string $version |
|
85 | - * @return JavascriptAsset |
|
86 | - * @throws DuplicateCollectionIdentifierException |
|
87 | - * @throws InvalidDataTypeException |
|
88 | - * @throws InvalidEntityException |
|
89 | - * @throws DomainException |
|
90 | - * @since 4.9.62.p |
|
91 | - */ |
|
92 | - public function addJavascript( |
|
93 | - $handle, |
|
94 | - $source, |
|
95 | - array $dependencies = array(), |
|
96 | - $load_in_footer = true, |
|
97 | - $version = '' |
|
98 | - ) { |
|
99 | - $asset = new JavascriptAsset( |
|
100 | - $handle, |
|
101 | - $source, |
|
102 | - array_unique($dependencies), |
|
103 | - $load_in_footer, |
|
104 | - $this->domain, |
|
105 | - $version |
|
106 | - ); |
|
107 | - $this->assets->add($asset, $handle); |
|
108 | - return $asset; |
|
109 | - } |
|
110 | - |
|
111 | - |
|
112 | - /** |
|
113 | - * Used to register a javascript asset where everything is dynamically derived from the given handle. |
|
114 | - * |
|
115 | - * @param string $handle |
|
116 | - * @param string|array $extra_dependencies |
|
117 | - * @return JavascriptAsset |
|
118 | - * @throws DuplicateCollectionIdentifierException |
|
119 | - * @throws InvalidDataTypeException |
|
120 | - * @throws InvalidEntityException |
|
121 | - * @throws DomainException |
|
122 | - */ |
|
123 | - public function addJs($handle, $extra_dependencies = []) |
|
124 | - { |
|
125 | - $details = $this->getAssetDetails( |
|
126 | - Asset::TYPE_JS, |
|
127 | - $handle, |
|
128 | - $extra_dependencies |
|
129 | - ); |
|
130 | - $source = $this->registry->getJsUrl($this->domain->assetNamespace(), $handle); |
|
131 | - return $this->addJavascript( |
|
132 | - $handle, |
|
133 | - $source, |
|
134 | - $details['dependencies'], |
|
135 | - true, |
|
136 | - $details['version'] |
|
137 | - ); |
|
138 | - } |
|
139 | - |
|
140 | - |
|
141 | - /** |
|
142 | - * @param string $handle |
|
143 | - * @param array $dependencies |
|
144 | - * @param bool $load_in_footer |
|
145 | - * @param string $version |
|
146 | - * @return JavascriptAsset |
|
147 | - * @throws DomainException |
|
148 | - * @throws DuplicateCollectionIdentifierException |
|
149 | - * @throws InvalidDataTypeException |
|
150 | - * @throws InvalidEntityException |
|
151 | - * @since 4.9.71.p |
|
152 | - */ |
|
153 | - public function addVendorJavascript( |
|
154 | - $handle, |
|
155 | - array $dependencies = array(), |
|
156 | - $load_in_footer = true, |
|
157 | - $version = '' |
|
158 | - ) { |
|
159 | - $dev_suffix = wp_scripts_get_suffix(); |
|
160 | - $vendor_path = $this->domain->pluginUrl() . 'assets/vendor/'; |
|
161 | - return $this->addJavascript( |
|
162 | - $handle, |
|
163 | - "{$vendor_path}{$handle}{$dev_suffix}.js", |
|
164 | - $dependencies, |
|
165 | - $load_in_footer, |
|
166 | - $version |
|
167 | - ); |
|
168 | - } |
|
169 | - |
|
170 | - |
|
171 | - /** |
|
172 | - * @param string $handle |
|
173 | - * @param string $source |
|
174 | - * @param array $dependencies |
|
175 | - * @param string $media |
|
176 | - * @param string $version |
|
177 | - * @return StylesheetAsset |
|
178 | - * @throws DomainException |
|
179 | - * @throws DuplicateCollectionIdentifierException |
|
180 | - * @throws InvalidDataTypeException |
|
181 | - * @throws InvalidEntityException |
|
182 | - * @since 4.9.62.p |
|
183 | - */ |
|
184 | - public function addStylesheet( |
|
185 | - $handle, |
|
186 | - $source, |
|
187 | - array $dependencies = array(), |
|
188 | - $media = 'all', |
|
189 | - $version = '' |
|
190 | - ) { |
|
191 | - $asset = new StylesheetAsset( |
|
192 | - $handle, |
|
193 | - $source, |
|
194 | - array_unique($dependencies), |
|
195 | - $this->domain, |
|
196 | - $media, |
|
197 | - $version |
|
198 | - ); |
|
199 | - $this->assets->add($asset, $handle); |
|
200 | - return $asset; |
|
201 | - } |
|
202 | - |
|
203 | - |
|
204 | - /** |
|
205 | - * Used to register a css asset where everything is dynamically derived from the given handle. |
|
206 | - * |
|
207 | - * @param string $handle |
|
208 | - * @param string|array $extra_dependencies |
|
209 | - * @return StylesheetAsset |
|
210 | - * @throws DuplicateCollectionIdentifierException |
|
211 | - * @throws InvalidDataTypeException |
|
212 | - * @throws InvalidEntityException |
|
213 | - * @throws DomainException |
|
214 | - */ |
|
215 | - public function addCss($handle, $extra_dependencies = []) |
|
216 | - { |
|
217 | - $details = $this->getAssetDetails( |
|
218 | - Asset::TYPE_CSS, |
|
219 | - $handle, |
|
220 | - $extra_dependencies |
|
221 | - ); |
|
222 | - return $this->addStylesheet( |
|
223 | - $handle, |
|
224 | - $this->registry->getCssUrl($this->domain->assetNamespace(), $handle), |
|
225 | - $details['dependencies'], |
|
226 | - 'all', |
|
227 | - $details['version'] |
|
228 | - ); |
|
229 | - } |
|
230 | - |
|
231 | - |
|
232 | - /** |
|
233 | - * @param string $handle |
|
234 | - * @return bool |
|
235 | - * @since 4.9.62.p |
|
236 | - */ |
|
237 | - public function enqueueAsset($handle) |
|
238 | - { |
|
239 | - if ($this->assets->has($handle)) { |
|
240 | - /** @var Asset $asset */ |
|
241 | - $asset = $this->assets->get($handle); |
|
242 | - if ($asset instanceof BrowserAsset && $asset->isRegistered()) { |
|
243 | - $asset->enqueueAsset(); |
|
244 | - return true; |
|
245 | - } |
|
246 | - } |
|
247 | - return false; |
|
248 | - } |
|
249 | - |
|
250 | - |
|
251 | - /** |
|
252 | - * @return void |
|
253 | - * @since $VID:$ |
|
254 | - */ |
|
255 | - public function enqueueBrowserAssets() |
|
256 | - { |
|
257 | - foreach ($this->assets as $asset) { |
|
258 | - if ($asset instanceof BrowserAsset && $asset->isRegistered()) { |
|
259 | - $asset->enqueueAsset(); |
|
260 | - } |
|
261 | - } |
|
262 | - } |
|
263 | - |
|
264 | - |
|
265 | - /** |
|
266 | - * @param string $asset_type |
|
267 | - * @param string $handle |
|
268 | - * @param array $extra_dependencies |
|
269 | - * @return array |
|
270 | - * @since 4.10.2.p |
|
271 | - */ |
|
272 | - private function getAssetDetails($asset_type, $handle, $extra_dependencies = []) |
|
273 | - { |
|
274 | - $getAssetDetails = ''; |
|
275 | - switch ($asset_type) { |
|
276 | - case Asset::TYPE_JS : |
|
277 | - $getAssetDetails = 'getJsAssetDetails'; |
|
278 | - break; |
|
279 | - case Asset::TYPE_CSS : |
|
280 | - $getAssetDetails = 'getCssAssetDetails'; |
|
281 | - break; |
|
282 | - } |
|
283 | - if ($getAssetDetails === '') { |
|
284 | - return ['dependencies' => [], 'version' => '']; |
|
285 | - } |
|
286 | - $details = $this->registry->$getAssetDetails( |
|
287 | - $this->domain->assetNamespace(), |
|
288 | - $handle |
|
289 | - ); |
|
290 | - $details['dependencies'] = isset($details['dependencies']) |
|
291 | - ? $details['dependencies'] |
|
292 | - : []; |
|
293 | - $details['version'] = isset($details['version']) |
|
294 | - ? $details['version'] |
|
295 | - : ''; |
|
296 | - $details['dependencies'] = ! empty($extra_dependencies) |
|
297 | - ? array_merge($details['dependencies'], (array) $extra_dependencies) |
|
298 | - : $details['dependencies']; |
|
299 | - return $details; |
|
300 | - |
|
301 | - } |
|
302 | - |
|
303 | - |
|
304 | - /** |
|
305 | - * @param string $handle |
|
306 | - * @return bool |
|
307 | - * @throws DomainException |
|
308 | - */ |
|
309 | - public function verifyAssetIsRegistered($handle) |
|
310 | - { |
|
311 | - if (wp_script_is($handle, 'registered')) { |
|
312 | - return true; |
|
313 | - } |
|
314 | - if (WP_DEBUG) { |
|
315 | - throw new DomainException( |
|
316 | - sprintf( |
|
317 | - esc_html__( |
|
318 | - 'The "%1$s" script is not registered when it should be!%2$s |
|
26 | + /** |
|
27 | + * @var AssetCollection|Asset[] $assets |
|
28 | + */ |
|
29 | + protected $assets; |
|
30 | + |
|
31 | + /** |
|
32 | + * @var DomainInterface |
|
33 | + */ |
|
34 | + protected $domain; |
|
35 | + |
|
36 | + /** |
|
37 | + * @var Registry $registry |
|
38 | + */ |
|
39 | + protected $registry; |
|
40 | + |
|
41 | + |
|
42 | + /** |
|
43 | + * AssetRegister constructor. |
|
44 | + * |
|
45 | + * @param DomainInterface $domain |
|
46 | + * @param AssetCollection $assets |
|
47 | + * @param Registry $registry |
|
48 | + */ |
|
49 | + public function __construct(DomainInterface $domain, AssetCollection $assets, Registry $registry) |
|
50 | + { |
|
51 | + $this->domain = $domain; |
|
52 | + $this->assets = $assets; |
|
53 | + $this->registry = $registry; |
|
54 | + $this->registry->addAssetCollection($assets); |
|
55 | + add_action('wp_enqueue_scripts', array($this, 'addAssets'), 2); |
|
56 | + add_action('admin_enqueue_scripts', array($this, 'addAssets'), 2); |
|
57 | + } |
|
58 | + |
|
59 | + |
|
60 | + /** |
|
61 | + * @return AssetCollection |
|
62 | + */ |
|
63 | + public function getAssets() |
|
64 | + { |
|
65 | + return $this->assets; |
|
66 | + } |
|
67 | + |
|
68 | + |
|
69 | + /** |
|
70 | + * @since 4.9.71.p |
|
71 | + * @return string |
|
72 | + */ |
|
73 | + public function assetNamespace() |
|
74 | + { |
|
75 | + return $this->domain->assetNamespace(); |
|
76 | + } |
|
77 | + |
|
78 | + |
|
79 | + /** |
|
80 | + * @param string $handle |
|
81 | + * @param string $source |
|
82 | + * @param array $dependencies |
|
83 | + * @param bool $load_in_footer |
|
84 | + * @param string $version |
|
85 | + * @return JavascriptAsset |
|
86 | + * @throws DuplicateCollectionIdentifierException |
|
87 | + * @throws InvalidDataTypeException |
|
88 | + * @throws InvalidEntityException |
|
89 | + * @throws DomainException |
|
90 | + * @since 4.9.62.p |
|
91 | + */ |
|
92 | + public function addJavascript( |
|
93 | + $handle, |
|
94 | + $source, |
|
95 | + array $dependencies = array(), |
|
96 | + $load_in_footer = true, |
|
97 | + $version = '' |
|
98 | + ) { |
|
99 | + $asset = new JavascriptAsset( |
|
100 | + $handle, |
|
101 | + $source, |
|
102 | + array_unique($dependencies), |
|
103 | + $load_in_footer, |
|
104 | + $this->domain, |
|
105 | + $version |
|
106 | + ); |
|
107 | + $this->assets->add($asset, $handle); |
|
108 | + return $asset; |
|
109 | + } |
|
110 | + |
|
111 | + |
|
112 | + /** |
|
113 | + * Used to register a javascript asset where everything is dynamically derived from the given handle. |
|
114 | + * |
|
115 | + * @param string $handle |
|
116 | + * @param string|array $extra_dependencies |
|
117 | + * @return JavascriptAsset |
|
118 | + * @throws DuplicateCollectionIdentifierException |
|
119 | + * @throws InvalidDataTypeException |
|
120 | + * @throws InvalidEntityException |
|
121 | + * @throws DomainException |
|
122 | + */ |
|
123 | + public function addJs($handle, $extra_dependencies = []) |
|
124 | + { |
|
125 | + $details = $this->getAssetDetails( |
|
126 | + Asset::TYPE_JS, |
|
127 | + $handle, |
|
128 | + $extra_dependencies |
|
129 | + ); |
|
130 | + $source = $this->registry->getJsUrl($this->domain->assetNamespace(), $handle); |
|
131 | + return $this->addJavascript( |
|
132 | + $handle, |
|
133 | + $source, |
|
134 | + $details['dependencies'], |
|
135 | + true, |
|
136 | + $details['version'] |
|
137 | + ); |
|
138 | + } |
|
139 | + |
|
140 | + |
|
141 | + /** |
|
142 | + * @param string $handle |
|
143 | + * @param array $dependencies |
|
144 | + * @param bool $load_in_footer |
|
145 | + * @param string $version |
|
146 | + * @return JavascriptAsset |
|
147 | + * @throws DomainException |
|
148 | + * @throws DuplicateCollectionIdentifierException |
|
149 | + * @throws InvalidDataTypeException |
|
150 | + * @throws InvalidEntityException |
|
151 | + * @since 4.9.71.p |
|
152 | + */ |
|
153 | + public function addVendorJavascript( |
|
154 | + $handle, |
|
155 | + array $dependencies = array(), |
|
156 | + $load_in_footer = true, |
|
157 | + $version = '' |
|
158 | + ) { |
|
159 | + $dev_suffix = wp_scripts_get_suffix(); |
|
160 | + $vendor_path = $this->domain->pluginUrl() . 'assets/vendor/'; |
|
161 | + return $this->addJavascript( |
|
162 | + $handle, |
|
163 | + "{$vendor_path}{$handle}{$dev_suffix}.js", |
|
164 | + $dependencies, |
|
165 | + $load_in_footer, |
|
166 | + $version |
|
167 | + ); |
|
168 | + } |
|
169 | + |
|
170 | + |
|
171 | + /** |
|
172 | + * @param string $handle |
|
173 | + * @param string $source |
|
174 | + * @param array $dependencies |
|
175 | + * @param string $media |
|
176 | + * @param string $version |
|
177 | + * @return StylesheetAsset |
|
178 | + * @throws DomainException |
|
179 | + * @throws DuplicateCollectionIdentifierException |
|
180 | + * @throws InvalidDataTypeException |
|
181 | + * @throws InvalidEntityException |
|
182 | + * @since 4.9.62.p |
|
183 | + */ |
|
184 | + public function addStylesheet( |
|
185 | + $handle, |
|
186 | + $source, |
|
187 | + array $dependencies = array(), |
|
188 | + $media = 'all', |
|
189 | + $version = '' |
|
190 | + ) { |
|
191 | + $asset = new StylesheetAsset( |
|
192 | + $handle, |
|
193 | + $source, |
|
194 | + array_unique($dependencies), |
|
195 | + $this->domain, |
|
196 | + $media, |
|
197 | + $version |
|
198 | + ); |
|
199 | + $this->assets->add($asset, $handle); |
|
200 | + return $asset; |
|
201 | + } |
|
202 | + |
|
203 | + |
|
204 | + /** |
|
205 | + * Used to register a css asset where everything is dynamically derived from the given handle. |
|
206 | + * |
|
207 | + * @param string $handle |
|
208 | + * @param string|array $extra_dependencies |
|
209 | + * @return StylesheetAsset |
|
210 | + * @throws DuplicateCollectionIdentifierException |
|
211 | + * @throws InvalidDataTypeException |
|
212 | + * @throws InvalidEntityException |
|
213 | + * @throws DomainException |
|
214 | + */ |
|
215 | + public function addCss($handle, $extra_dependencies = []) |
|
216 | + { |
|
217 | + $details = $this->getAssetDetails( |
|
218 | + Asset::TYPE_CSS, |
|
219 | + $handle, |
|
220 | + $extra_dependencies |
|
221 | + ); |
|
222 | + return $this->addStylesheet( |
|
223 | + $handle, |
|
224 | + $this->registry->getCssUrl($this->domain->assetNamespace(), $handle), |
|
225 | + $details['dependencies'], |
|
226 | + 'all', |
|
227 | + $details['version'] |
|
228 | + ); |
|
229 | + } |
|
230 | + |
|
231 | + |
|
232 | + /** |
|
233 | + * @param string $handle |
|
234 | + * @return bool |
|
235 | + * @since 4.9.62.p |
|
236 | + */ |
|
237 | + public function enqueueAsset($handle) |
|
238 | + { |
|
239 | + if ($this->assets->has($handle)) { |
|
240 | + /** @var Asset $asset */ |
|
241 | + $asset = $this->assets->get($handle); |
|
242 | + if ($asset instanceof BrowserAsset && $asset->isRegistered()) { |
|
243 | + $asset->enqueueAsset(); |
|
244 | + return true; |
|
245 | + } |
|
246 | + } |
|
247 | + return false; |
|
248 | + } |
|
249 | + |
|
250 | + |
|
251 | + /** |
|
252 | + * @return void |
|
253 | + * @since $VID:$ |
|
254 | + */ |
|
255 | + public function enqueueBrowserAssets() |
|
256 | + { |
|
257 | + foreach ($this->assets as $asset) { |
|
258 | + if ($asset instanceof BrowserAsset && $asset->isRegistered()) { |
|
259 | + $asset->enqueueAsset(); |
|
260 | + } |
|
261 | + } |
|
262 | + } |
|
263 | + |
|
264 | + |
|
265 | + /** |
|
266 | + * @param string $asset_type |
|
267 | + * @param string $handle |
|
268 | + * @param array $extra_dependencies |
|
269 | + * @return array |
|
270 | + * @since 4.10.2.p |
|
271 | + */ |
|
272 | + private function getAssetDetails($asset_type, $handle, $extra_dependencies = []) |
|
273 | + { |
|
274 | + $getAssetDetails = ''; |
|
275 | + switch ($asset_type) { |
|
276 | + case Asset::TYPE_JS : |
|
277 | + $getAssetDetails = 'getJsAssetDetails'; |
|
278 | + break; |
|
279 | + case Asset::TYPE_CSS : |
|
280 | + $getAssetDetails = 'getCssAssetDetails'; |
|
281 | + break; |
|
282 | + } |
|
283 | + if ($getAssetDetails === '') { |
|
284 | + return ['dependencies' => [], 'version' => '']; |
|
285 | + } |
|
286 | + $details = $this->registry->$getAssetDetails( |
|
287 | + $this->domain->assetNamespace(), |
|
288 | + $handle |
|
289 | + ); |
|
290 | + $details['dependencies'] = isset($details['dependencies']) |
|
291 | + ? $details['dependencies'] |
|
292 | + : []; |
|
293 | + $details['version'] = isset($details['version']) |
|
294 | + ? $details['version'] |
|
295 | + : ''; |
|
296 | + $details['dependencies'] = ! empty($extra_dependencies) |
|
297 | + ? array_merge($details['dependencies'], (array) $extra_dependencies) |
|
298 | + : $details['dependencies']; |
|
299 | + return $details; |
|
300 | + |
|
301 | + } |
|
302 | + |
|
303 | + |
|
304 | + /** |
|
305 | + * @param string $handle |
|
306 | + * @return bool |
|
307 | + * @throws DomainException |
|
308 | + */ |
|
309 | + public function verifyAssetIsRegistered($handle) |
|
310 | + { |
|
311 | + if (wp_script_is($handle, 'registered')) { |
|
312 | + return true; |
|
313 | + } |
|
314 | + if (WP_DEBUG) { |
|
315 | + throw new DomainException( |
|
316 | + sprintf( |
|
317 | + esc_html__( |
|
318 | + 'The "%1$s" script is not registered when it should be!%2$s |
|
319 | 319 | Are you running the Barista plugin for development purposes? |
320 | 320 | If so, then you need to build the appropriate assets for this domain.%2$s |
321 | 321 | If you are seeing this error on a live website, then you should not have |
322 | 322 | the WP_DEBUG constant in your wp-config.php file set to "true". |
323 | 323 | Please contact Event Espresso support for more information.', |
324 | - 'event_espresso' |
|
325 | - ), |
|
326 | - $handle, |
|
327 | - '<br />' |
|
328 | - ) |
|
329 | - ); |
|
330 | - } |
|
331 | - return false; |
|
332 | - } |
|
333 | - |
|
334 | - |
|
335 | - /**************** deprecated ****************/ |
|
336 | - |
|
337 | - |
|
338 | - /** |
|
339 | - * @return void |
|
340 | - * @deprecated $VID:$ |
|
341 | - */ |
|
342 | - public function addManifestFile() |
|
343 | - { |
|
344 | - } |
|
345 | - |
|
346 | - |
|
347 | - /** |
|
348 | - * @return void |
|
349 | - * @deprecated $VID:$ |
|
350 | - */ |
|
351 | - public function getManifestFile() |
|
352 | - { |
|
353 | - } |
|
324 | + 'event_espresso' |
|
325 | + ), |
|
326 | + $handle, |
|
327 | + '<br />' |
|
328 | + ) |
|
329 | + ); |
|
330 | + } |
|
331 | + return false; |
|
332 | + } |
|
333 | + |
|
334 | + |
|
335 | + /**************** deprecated ****************/ |
|
336 | + |
|
337 | + |
|
338 | + /** |
|
339 | + * @return void |
|
340 | + * @deprecated $VID:$ |
|
341 | + */ |
|
342 | + public function addManifestFile() |
|
343 | + { |
|
344 | + } |
|
345 | + |
|
346 | + |
|
347 | + /** |
|
348 | + * @return void |
|
349 | + * @deprecated $VID:$ |
|
350 | + */ |
|
351 | + public function getManifestFile() |
|
352 | + { |
|
353 | + } |
|
354 | 354 | } |
@@ -157,7 +157,7 @@ |
||
157 | 157 | $version = '' |
158 | 158 | ) { |
159 | 159 | $dev_suffix = wp_scripts_get_suffix(); |
160 | - $vendor_path = $this->domain->pluginUrl() . 'assets/vendor/'; |
|
160 | + $vendor_path = $this->domain->pluginUrl().'assets/vendor/'; |
|
161 | 161 | return $this->addJavascript( |
162 | 162 | $handle, |
163 | 163 | "{$vendor_path}{$handle}{$dev_suffix}.js", |