@@ -32,581 +32,581 @@ |
||
32 | 32 | class CoreAssetManager extends AssetManager |
33 | 33 | { |
34 | 34 | |
35 | - // WordPress core / Third party JS asset handles |
|
36 | - const JS_HANDLE_JQUERY = 'jquery'; |
|
35 | + // WordPress core / Third party JS asset handles |
|
36 | + const JS_HANDLE_JQUERY = 'jquery'; |
|
37 | 37 | |
38 | - const JS_HANDLE_JQUERY_VALIDATE = 'jquery-validate'; |
|
38 | + const JS_HANDLE_JQUERY_VALIDATE = 'jquery-validate'; |
|
39 | 39 | |
40 | - const JS_HANDLE_JQUERY_VALIDATE_EXTRA = 'jquery-validate-extra-methods'; |
|
40 | + const JS_HANDLE_JQUERY_VALIDATE_EXTRA = 'jquery-validate-extra-methods'; |
|
41 | 41 | |
42 | - const JS_HANDLE_UNDERSCORE = 'underscore'; |
|
42 | + const JS_HANDLE_UNDERSCORE = 'underscore'; |
|
43 | 43 | |
44 | - const JS_HANDLE_ACCOUNTING_CORE = 'ee-accounting-core'; |
|
44 | + const JS_HANDLE_ACCOUNTING_CORE = 'ee-accounting-core'; |
|
45 | 45 | |
46 | - /** |
|
47 | - * @since 4.9.71.p |
|
48 | - */ |
|
49 | - const JS_HANDLE_REACT = 'react'; |
|
46 | + /** |
|
47 | + * @since 4.9.71.p |
|
48 | + */ |
|
49 | + const JS_HANDLE_REACT = 'react'; |
|
50 | 50 | |
51 | - /** |
|
52 | - * @since 4.9.71.p |
|
53 | - */ |
|
54 | - const JS_HANDLE_REACT_DOM = 'react-dom'; |
|
51 | + /** |
|
52 | + * @since 4.9.71.p |
|
53 | + */ |
|
54 | + const JS_HANDLE_REACT_DOM = 'react-dom'; |
|
55 | 55 | |
56 | - /** |
|
57 | - * @since 4.9.71.p |
|
58 | - */ |
|
59 | - const JS_HANDLE_LODASH = 'lodash'; |
|
56 | + /** |
|
57 | + * @since 4.9.71.p |
|
58 | + */ |
|
59 | + const JS_HANDLE_LODASH = 'lodash'; |
|
60 | 60 | |
61 | - // EE JS assets handles |
|
62 | - const JS_HANDLE_MANIFEST = 'ee-manifest'; |
|
61 | + // EE JS assets handles |
|
62 | + const JS_HANDLE_MANIFEST = 'ee-manifest'; |
|
63 | 63 | |
64 | - const JS_HANDLE_JS_CORE = 'eejs-core'; |
|
64 | + const JS_HANDLE_JS_CORE = 'eejs-core'; |
|
65 | 65 | |
66 | - const JS_HANDLE_VENDOR = 'eventespresso-vendor'; |
|
66 | + const JS_HANDLE_VENDOR = 'eventespresso-vendor'; |
|
67 | 67 | |
68 | - const JS_HANDLE_DATA_STORES = 'eventespresso-data-stores'; |
|
68 | + const JS_HANDLE_DATA_STORES = 'eventespresso-data-stores'; |
|
69 | 69 | |
70 | - const JS_HANDLE_HELPERS = 'eventespresso-helpers'; |
|
70 | + const JS_HANDLE_HELPERS = 'eventespresso-helpers'; |
|
71 | 71 | |
72 | - const JS_HANDLE_MODEL = 'eventespresso-model'; |
|
72 | + const JS_HANDLE_MODEL = 'eventespresso-model'; |
|
73 | 73 | |
74 | - const JS_HANDLE_VALUE_OBJECTS = 'eventespresso-value-objects'; |
|
74 | + const JS_HANDLE_VALUE_OBJECTS = 'eventespresso-value-objects'; |
|
75 | 75 | |
76 | - const JS_HANDLE_HOCS = 'eventespresso-hocs'; |
|
76 | + const JS_HANDLE_HOCS = 'eventespresso-hocs'; |
|
77 | 77 | |
78 | - const JS_HANDLE_COMPONENTS = 'eventespresso-components'; |
|
78 | + const JS_HANDLE_COMPONENTS = 'eventespresso-components'; |
|
79 | 79 | |
80 | - const JS_HANDLE_HOOKS = 'eventespresso-hooks'; |
|
80 | + const JS_HANDLE_HOOKS = 'eventespresso-hooks'; |
|
81 | 81 | |
82 | - const JS_HANDLE_EDITOR_HOCS = 'eventespresso-editor-hocs'; |
|
82 | + const JS_HANDLE_EDITOR_HOCS = 'eventespresso-editor-hocs'; |
|
83 | 83 | |
84 | - const JS_HANDLE_VALIDATORS = 'eventespresso-validators'; |
|
84 | + const JS_HANDLE_VALIDATORS = 'eventespresso-validators'; |
|
85 | 85 | |
86 | - const JS_HANDLE_CORE = 'espresso_core'; |
|
86 | + const JS_HANDLE_CORE = 'espresso_core'; |
|
87 | 87 | |
88 | - const JS_HANDLE_I18N = 'eei18n'; |
|
88 | + const JS_HANDLE_I18N = 'eei18n'; |
|
89 | 89 | |
90 | - const JS_HANDLE_ACCOUNTING = 'ee-accounting'; |
|
90 | + const JS_HANDLE_ACCOUNTING = 'ee-accounting'; |
|
91 | 91 | |
92 | - const JS_HANDLE_WP_PLUGINS_PAGE = 'ee-wp-plugins-page'; |
|
92 | + const JS_HANDLE_WP_PLUGINS_PAGE = 'ee-wp-plugins-page'; |
|
93 | 93 | |
94 | - // EE CSS assets handles |
|
95 | - const CSS_HANDLE_DEFAULT = 'espresso_default'; |
|
96 | - |
|
97 | - const CSS_HANDLE_CUSTOM = 'espresso_custom_css'; |
|
98 | - |
|
99 | - const CSS_HANDLE_COMPONENTS = 'eventespresso-components'; |
|
100 | - |
|
101 | - const CSS_HANDLE_CORE_CSS_DEFAULT = 'eventespresso-core-css-default'; |
|
102 | - |
|
103 | - /** |
|
104 | - * @var EE_Currency_Config $currency_config |
|
105 | - */ |
|
106 | - protected $currency_config; |
|
107 | - |
|
108 | - /** |
|
109 | - * @var EE_Template_Config $template_config |
|
110 | - */ |
|
111 | - protected $template_config; |
|
112 | - |
|
113 | - |
|
114 | - /** |
|
115 | - * CoreAssetRegister constructor. |
|
116 | - * |
|
117 | - * @param AssetCollection $assets |
|
118 | - * @param EE_Currency_Config $currency_config |
|
119 | - * @param EE_Template_Config $template_config |
|
120 | - * @param DomainInterface $domain |
|
121 | - * @param Registry $registry |
|
122 | - */ |
|
123 | - public function __construct( |
|
124 | - AssetCollection $assets, |
|
125 | - EE_Currency_Config $currency_config, |
|
126 | - EE_Template_Config $template_config, |
|
127 | - DomainInterface $domain, |
|
128 | - Registry $registry |
|
129 | - ) { |
|
130 | - $this->currency_config = $currency_config; |
|
131 | - $this->template_config = $template_config; |
|
132 | - parent::__construct($domain, $assets, $registry); |
|
133 | - } |
|
134 | - |
|
135 | - |
|
136 | - /** |
|
137 | - * @since 4.9.62.p |
|
138 | - * @throws DomainException |
|
139 | - * @throws DuplicateCollectionIdentifierException |
|
140 | - * @throws InvalidArgumentException |
|
141 | - * @throws InvalidDataTypeException |
|
142 | - * @throws InvalidEntityException |
|
143 | - * @throws InvalidInterfaceException |
|
144 | - */ |
|
145 | - public function addAssets() |
|
146 | - { |
|
147 | - $this->addJavascriptFiles(); |
|
148 | - $this->addStylesheetFiles(); |
|
149 | - } |
|
150 | - |
|
151 | - |
|
152 | - /** |
|
153 | - * @since 4.9.62.p |
|
154 | - * @throws DomainException |
|
155 | - * @throws DuplicateCollectionIdentifierException |
|
156 | - * @throws InvalidArgumentException |
|
157 | - * @throws InvalidDataTypeException |
|
158 | - * @throws InvalidEntityException |
|
159 | - * @throws InvalidInterfaceException |
|
160 | - */ |
|
161 | - public function addJavascriptFiles() |
|
162 | - { |
|
163 | - $this->loadCoreJs(); |
|
164 | - $this->loadJqueryValidate(); |
|
165 | - $this->loadAccountingJs(); |
|
166 | - add_action( |
|
167 | - 'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__before_script', |
|
168 | - array($this, 'loadQtipJs') |
|
169 | - ); |
|
170 | - $this->registerAdminAssets(); |
|
171 | - } |
|
172 | - |
|
173 | - |
|
174 | - /** |
|
175 | - * @since 4.9.62.p |
|
176 | - * @throws DuplicateCollectionIdentifierException |
|
177 | - * @throws InvalidDataTypeException |
|
178 | - * @throws InvalidEntityException |
|
179 | - */ |
|
180 | - public function addStylesheetFiles() |
|
181 | - { |
|
182 | - $this->loadCoreCss(); |
|
183 | - } |
|
184 | - |
|
185 | - |
|
186 | - /** |
|
187 | - * core default javascript |
|
188 | - * |
|
189 | - * @since 4.9.62.p |
|
190 | - * @throws DomainException |
|
191 | - * @throws DuplicateCollectionIdentifierException |
|
192 | - * @throws InvalidArgumentException |
|
193 | - * @throws InvalidDataTypeException |
|
194 | - * @throws InvalidEntityException |
|
195 | - * @throws InvalidInterfaceException |
|
196 | - */ |
|
197 | - private function loadCoreJs() |
|
198 | - { |
|
199 | - // conditionally load third-party libraries that WP core MIGHT have. |
|
200 | - $this->registerWpAssets(); |
|
201 | - |
|
202 | - $this->addJavascript( |
|
203 | - CoreAssetManager::JS_HANDLE_MANIFEST, |
|
204 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'manifest') |
|
205 | - ); |
|
206 | - |
|
207 | - $this->addJavascript( |
|
208 | - CoreAssetManager::JS_HANDLE_JS_CORE, |
|
209 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'eejs'), |
|
210 | - array(CoreAssetManager::JS_HANDLE_MANIFEST) |
|
211 | - ) |
|
212 | - ->setHasInlineData(); |
|
213 | - |
|
214 | - $this->addJavascript( |
|
215 | - CoreAssetManager::JS_HANDLE_VENDOR, |
|
216 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'vendor'), |
|
217 | - array( |
|
218 | - CoreAssetManager::JS_HANDLE_JS_CORE, |
|
219 | - CoreAssetManager::JS_HANDLE_REACT, |
|
220 | - CoreAssetManager::JS_HANDLE_REACT_DOM, |
|
221 | - CoreAssetManager::JS_HANDLE_LODASH, |
|
222 | - ) |
|
223 | - ); |
|
224 | - |
|
225 | - $this->addJavascript( |
|
226 | - CoreAssetManager::JS_HANDLE_VALIDATORS, |
|
227 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'validators') |
|
228 | - )->setRequiresTranslation(); |
|
229 | - |
|
230 | - $this->addJavascript( |
|
231 | - CoreAssetManager::JS_HANDLE_HELPERS, |
|
232 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'helpers'), |
|
233 | - array( |
|
234 | - CoreAssetManager::JS_HANDLE_VALIDATORS |
|
235 | - ) |
|
236 | - )->setRequiresTranslation(); |
|
237 | - |
|
238 | - $this->addJavascript( |
|
239 | - CoreAssetManager::JS_HANDLE_MODEL, |
|
240 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'model'), |
|
241 | - array( |
|
242 | - CoreAssetManager::JS_HANDLE_HELPERS, |
|
243 | - CoreAssetManager::JS_HANDLE_VALUE_OBJECTS, |
|
244 | - ) |
|
245 | - )->setRequiresTranslation(); |
|
246 | - |
|
247 | - $this->addJavascript( |
|
248 | - CoreAssetManager::JS_HANDLE_VALUE_OBJECTS, |
|
249 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'valueObjects'), |
|
250 | - array( |
|
251 | - CoreAssetManager::JS_HANDLE_VALIDATORS, |
|
252 | - CoreAssetManager::JS_HANDLE_HELPERS, |
|
253 | - ) |
|
254 | - )->setRequiresTranslation(); |
|
255 | - |
|
256 | - $this->addJavascript( |
|
257 | - CoreAssetManager::JS_HANDLE_DATA_STORES, |
|
258 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'data-stores'), |
|
259 | - array( |
|
260 | - CoreAssetManager::JS_HANDLE_VENDOR, |
|
261 | - 'wp-data', |
|
262 | - 'wp-api-fetch', |
|
263 | - CoreAssetManager::JS_HANDLE_VALUE_OBJECTS, |
|
264 | - CoreAssetManager::JS_HANDLE_MODEL, |
|
265 | - ) |
|
266 | - ) |
|
267 | - ->setRequiresTranslation() |
|
268 | - ->setInlineDataCallback( |
|
269 | - function() { |
|
270 | - wp_add_inline_script( |
|
271 | - CoreAssetManager::JS_HANDLE_DATA_STORES, |
|
272 | - is_admin() |
|
273 | - ? 'wp.apiFetch.use( eejs.middleWares.apiFetch.capsMiddleware( eejs.middleWares.apiFetch.CONTEXT_CAPS_EDIT ) )' |
|
274 | - : 'wp.apiFetch.use( eejs.middleWares.apiFetch.capsMiddleware )' |
|
275 | - ); |
|
276 | - } |
|
277 | - ); |
|
278 | - $this->addJavascript( |
|
279 | - CoreAssetManager::JS_HANDLE_HOOKS, |
|
280 | - $this->registry->getJsUrl( $this->domain->assetNamespace(), 'hooks' ), |
|
281 | - [ |
|
282 | - CoreAssetManager::JS_HANDLE_CORE |
|
283 | - ] |
|
284 | - ); |
|
285 | - |
|
286 | - $this->addJavascript( |
|
287 | - CoreAssetManager::JS_HANDLE_HOCS, |
|
288 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'hocs'), |
|
289 | - array( |
|
290 | - CoreAssetManager::JS_HANDLE_DATA_STORES, |
|
291 | - CoreAssetManager::JS_HANDLE_VALUE_OBJECTS, |
|
292 | - CoreAssetManager::JS_HANDLE_HOOKS, |
|
293 | - 'wp-components', |
|
294 | - ) |
|
295 | - )->setRequiresTranslation(); |
|
296 | - |
|
297 | - $this->addJavascript( |
|
298 | - CoreAssetManager::JS_HANDLE_COMPONENTS, |
|
299 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'components'), |
|
300 | - array( |
|
301 | - CoreAssetManager::JS_HANDLE_DATA_STORES, |
|
302 | - CoreAssetManager::JS_HANDLE_VALUE_OBJECTS, |
|
303 | - CoreAssetManager::JS_HANDLE_HOOKS, |
|
304 | - 'wp-components', |
|
305 | - ) |
|
306 | - ) |
|
307 | - ->setRequiresTranslation(); |
|
308 | - |
|
309 | - $this->addJavascript( |
|
310 | - CoreAssetManager::JS_HANDLE_EDITOR_HOCS, |
|
311 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'editor-hocs'), |
|
312 | - array( |
|
313 | - CoreAssetManager::JS_HANDLE_COMPONENTS |
|
314 | - ) |
|
315 | - )->setRequiresTranslation(); |
|
316 | - |
|
317 | - $this->registry->addData('eejs_api_nonce', wp_create_nonce('wp_rest')); |
|
318 | - $this->registry->addData( |
|
319 | - 'paths', |
|
320 | - array( |
|
321 | - 'base_rest_route' => rest_url(), |
|
322 | - 'rest_route' => rest_url('ee/v4.8.36/'), |
|
323 | - 'collection_endpoints' => EED_Core_Rest_Api::getCollectionRoutesIndexedByModelName(), |
|
324 | - 'primary_keys' => EED_Core_Rest_Api::getPrimaryKeyNamesIndexedByModelName(), |
|
325 | - 'site_url' => site_url('/'), |
|
326 | - 'admin_url' => admin_url('/'), |
|
327 | - ) |
|
328 | - ); |
|
329 | - // Event Espresso brand name |
|
330 | - $this->registry->addData('brandName', Domain::brandName()); |
|
331 | - /** site formatting values **/ |
|
332 | - $this->registry->addData( |
|
333 | - 'site_formats', |
|
334 | - array( |
|
335 | - 'date_formats' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats() |
|
336 | - ) |
|
337 | - ); |
|
338 | - /** currency data **/ |
|
339 | - $this->registry->addData( |
|
340 | - 'currency_config', |
|
341 | - $this->getCurrencySettings() |
|
342 | - ); |
|
343 | - /** site timezone */ |
|
344 | - $this->registry->addData( |
|
345 | - 'default_timezone', |
|
346 | - array( |
|
347 | - 'pretty' => EEH_DTT_Helper::get_timezone_string_for_display(), |
|
348 | - 'string' => get_option('timezone_string'), |
|
349 | - 'offset' => EEH_DTT_Helper::get_site_timezone_gmt_offset(), |
|
350 | - ) |
|
351 | - ); |
|
352 | - /** site locale (user locale if user logged in) */ |
|
353 | - $this->registry->addData( |
|
354 | - 'locale', |
|
355 | - array( |
|
356 | - 'user' => get_user_locale(), |
|
357 | - 'site' => get_locale() |
|
358 | - ) |
|
359 | - ); |
|
360 | - |
|
361 | - $this->addJavascript( |
|
362 | - CoreAssetManager::JS_HANDLE_CORE, |
|
363 | - EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
364 | - array(CoreAssetManager::JS_HANDLE_JQUERY) |
|
365 | - ) |
|
366 | - ->setInlineDataCallback( |
|
367 | - function () { |
|
368 | - wp_localize_script( |
|
369 | - CoreAssetManager::JS_HANDLE_CORE, |
|
370 | - CoreAssetManager::JS_HANDLE_I18N, |
|
371 | - EE_Registry::$i18n_js_strings |
|
372 | - ); |
|
373 | - } |
|
374 | - ); |
|
375 | - } |
|
376 | - |
|
377 | - |
|
378 | - /** |
|
379 | - * Registers vendor files that are bundled with a later version WP but might not be for the current version of |
|
380 | - * WordPress in the running environment. |
|
381 | - * |
|
382 | - * @throws DuplicateCollectionIdentifierException |
|
383 | - * @throws InvalidDataTypeException |
|
384 | - * @throws InvalidEntityException |
|
385 | - * @throws DomainException |
|
386 | - * @since 4.9.71.p |
|
387 | - */ |
|
388 | - private function registerWpAssets() |
|
389 | - { |
|
390 | - global $wp_version; |
|
391 | - if (version_compare($wp_version, '5.0.beta', '>=')) { |
|
392 | - return; |
|
393 | - } |
|
394 | - $this->addVendorJavascript(CoreAssetManager::JS_HANDLE_REACT) |
|
395 | - ->setVersion('16.6.0'); |
|
396 | - $this->addVendorJavascript( |
|
397 | - CoreAssetManager::JS_HANDLE_REACT_DOM, |
|
398 | - array(CoreAssetManager::JS_HANDLE_REACT) |
|
399 | - )->setVersion('16.6.0'); |
|
400 | - $this->addVendorJavascript(CoreAssetManager::JS_HANDLE_LODASH) |
|
401 | - ->setInlineDataCallback( |
|
402 | - function() { |
|
403 | - wp_add_inline_script( |
|
404 | - CoreAssetManager::JS_HANDLE_LODASH, |
|
405 | - 'window.lodash = _.noConflict();' |
|
406 | - ); |
|
407 | - } |
|
408 | - ) |
|
409 | - ->setVersion('4.17.11'); |
|
410 | - } |
|
411 | - |
|
412 | - |
|
413 | - /** |
|
414 | - * Returns configuration data for the accounting-js library. |
|
415 | - * @since 4.9.71.p |
|
416 | - * @return array |
|
417 | - */ |
|
418 | - private function getAccountingSettings() { |
|
419 | - return array( |
|
420 | - 'currency' => array( |
|
421 | - 'symbol' => $this->currency_config->sign, |
|
422 | - 'format' => array( |
|
423 | - 'pos' => $this->currency_config->sign_b4 ? '%s%v' : '%v%s', |
|
424 | - 'neg' => $this->currency_config->sign_b4 ? '- %s%v' : '- %v%s', |
|
425 | - 'zero' => $this->currency_config->sign_b4 ? '%s--' : '--%s', |
|
426 | - ), |
|
427 | - 'decimal' => $this->currency_config->dec_mrk, |
|
428 | - 'thousand' => $this->currency_config->thsnds, |
|
429 | - 'precision' => $this->currency_config->dec_plc, |
|
430 | - ), |
|
431 | - 'number' => array( |
|
432 | - 'precision' => $this->currency_config->dec_plc, |
|
433 | - 'thousand' => $this->currency_config->thsnds, |
|
434 | - 'decimal' => $this->currency_config->dec_mrk, |
|
435 | - ), |
|
436 | - ); |
|
437 | - } |
|
438 | - |
|
439 | - |
|
440 | - /** |
|
441 | - * Returns configuration data for the js Currency VO. |
|
442 | - * @since 4.9.71.p |
|
443 | - * @return array |
|
444 | - */ |
|
445 | - private function getCurrencySettings() |
|
446 | - { |
|
447 | - return array( |
|
448 | - 'code' => $this->currency_config->code, |
|
449 | - 'singularLabel' => $this->currency_config->name, |
|
450 | - 'pluralLabel' => $this->currency_config->plural, |
|
451 | - 'sign' => $this->currency_config->sign, |
|
452 | - 'signB4' => $this->currency_config->sign_b4, |
|
453 | - 'decimalPlaces' => $this->currency_config->dec_plc, |
|
454 | - 'decimalMark' => $this->currency_config->dec_mrk, |
|
455 | - 'thousandsSeparator' => $this->currency_config->thsnds, |
|
456 | - ); |
|
457 | - } |
|
458 | - |
|
459 | - |
|
460 | - /** |
|
461 | - * @since 4.9.62.p |
|
462 | - * @throws DuplicateCollectionIdentifierException |
|
463 | - * @throws InvalidDataTypeException |
|
464 | - * @throws InvalidEntityException |
|
465 | - */ |
|
466 | - private function loadCoreCss() |
|
467 | - { |
|
468 | - if ($this->template_config->enable_default_style && ! is_admin()) { |
|
469 | - $this->addStylesheet( |
|
470 | - CoreAssetManager::CSS_HANDLE_DEFAULT, |
|
471 | - is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css') |
|
472 | - ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css' |
|
473 | - : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', |
|
474 | - array('dashicons') |
|
475 | - ); |
|
476 | - //Load custom style sheet if available |
|
477 | - if ($this->template_config->custom_style_sheet !== null) { |
|
478 | - $this->addStylesheet( |
|
479 | - CoreAssetManager::CSS_HANDLE_CUSTOM, |
|
480 | - EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet, |
|
481 | - array(CoreAssetManager::CSS_HANDLE_DEFAULT) |
|
482 | - ); |
|
483 | - } |
|
484 | - } |
|
485 | - $this->addStylesheet( |
|
486 | - CoreAssetManager::CSS_HANDLE_CORE_CSS_DEFAULT, |
|
487 | - $this->registry->getCssUrl( |
|
488 | - $this->domain->assetNamespace(), |
|
489 | - 'core-default-theme' |
|
490 | - ), |
|
491 | - ['dashicons'] |
|
492 | - ); |
|
493 | - $this->addStylesheet( |
|
494 | - CoreAssetManager::CSS_HANDLE_COMPONENTS, |
|
495 | - $this->registry->getCssUrl( |
|
496 | - $this->domain->assetNamespace(), |
|
497 | - 'components' |
|
498 | - ), |
|
499 | - [CoreAssetManager::CSS_HANDLE_CORE_CSS_DEFAULT, 'wp-components'] |
|
500 | - ); |
|
501 | - } |
|
502 | - |
|
503 | - |
|
504 | - /** |
|
505 | - * jQuery Validate for form validation |
|
506 | - * |
|
507 | - * @since 4.9.62.p |
|
508 | - * @throws DomainException |
|
509 | - * @throws DuplicateCollectionIdentifierException |
|
510 | - * @throws InvalidDataTypeException |
|
511 | - * @throws InvalidEntityException |
|
512 | - */ |
|
513 | - private function loadJqueryValidate() |
|
514 | - { |
|
515 | - $this->addJavascript( |
|
516 | - CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE, |
|
517 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', |
|
518 | - array(CoreAssetManager::JS_HANDLE_JQUERY) |
|
519 | - ) |
|
520 | - ->setVersion('1.15.0'); |
|
521 | - |
|
522 | - $this->addJavascript( |
|
523 | - CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE_EXTRA, |
|
524 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js', |
|
525 | - array(CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE) |
|
526 | - ) |
|
527 | - ->setVersion('1.15.0'); |
|
528 | - } |
|
529 | - |
|
530 | - |
|
531 | - /** |
|
532 | - * accounting.js for performing client-side calculations |
|
533 | - * |
|
534 | - * @since 4.9.62.p |
|
535 | - * @throws DomainException |
|
536 | - * @throws DuplicateCollectionIdentifierException |
|
537 | - * @throws InvalidDataTypeException |
|
538 | - * @throws InvalidEntityException |
|
539 | - */ |
|
540 | - private function loadAccountingJs() |
|
541 | - { |
|
542 | - //accounting.js library |
|
543 | - // @link http://josscrowcroft.github.io/accounting.js/ |
|
544 | - $this->addJavascript( |
|
545 | - CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE, |
|
546 | - EE_THIRD_PARTY_URL . 'accounting/accounting.js', |
|
547 | - array(CoreAssetManager::JS_HANDLE_UNDERSCORE) |
|
548 | - ) |
|
549 | - ->setVersion('0.3.2'); |
|
550 | - |
|
551 | - $this->addJavascript( |
|
552 | - CoreAssetManager::JS_HANDLE_ACCOUNTING, |
|
553 | - EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', |
|
554 | - array(CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE) |
|
555 | - ) |
|
556 | - ->setInlineDataCallback( |
|
557 | - function () { |
|
558 | - wp_localize_script( |
|
559 | - CoreAssetManager::JS_HANDLE_ACCOUNTING, |
|
560 | - 'EE_ACCOUNTING_CFG', |
|
561 | - $this->getAccountingSettings() |
|
562 | - ); |
|
563 | - } |
|
564 | - ) |
|
565 | - ->setVersion(); |
|
566 | - } |
|
567 | - |
|
568 | - |
|
569 | - /** |
|
570 | - * registers assets for cleaning your ears |
|
571 | - * |
|
572 | - * @param JavascriptAsset $script |
|
573 | - */ |
|
574 | - public function loadQtipJs(JavascriptAsset $script) |
|
575 | - { |
|
576 | - // qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook, |
|
577 | - // can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' ); |
|
578 | - if ( |
|
579 | - $script->handle() === CoreAssetManager::JS_HANDLE_WP_PLUGINS_PAGE |
|
580 | - && apply_filters('FHEE_load_qtip', false) |
|
581 | - ) { |
|
582 | - EEH_Qtip_Loader::instance()->register_and_enqueue(); |
|
583 | - } |
|
584 | - } |
|
585 | - |
|
586 | - |
|
587 | - /** |
|
588 | - * assets that are used in the WordPress admin |
|
589 | - * |
|
590 | - * @since 4.9.62.p |
|
591 | - * @throws DuplicateCollectionIdentifierException |
|
592 | - * @throws InvalidDataTypeException |
|
593 | - * @throws InvalidEntityException |
|
594 | - */ |
|
595 | - private function registerAdminAssets() |
|
596 | - { |
|
597 | - $this->addJavascript( |
|
598 | - CoreAssetManager::JS_HANDLE_WP_PLUGINS_PAGE, |
|
599 | - $this->registry->getJsUrl($this->domain->assetNamespace(), 'wp-plugins-page'), |
|
600 | - array( |
|
601 | - CoreAssetManager::JS_HANDLE_JQUERY, |
|
602 | - CoreAssetManager::JS_HANDLE_VENDOR, |
|
603 | - ) |
|
604 | - ) |
|
605 | - ->setRequiresTranslation(); |
|
606 | - |
|
607 | - $this->addStylesheet( |
|
608 | - CoreAssetManager::JS_HANDLE_WP_PLUGINS_PAGE, |
|
609 | - $this->registry->getCssUrl($this->domain->assetNamespace(), 'wp-plugins-page') |
|
610 | - ); |
|
611 | - } |
|
94 | + // EE CSS assets handles |
|
95 | + const CSS_HANDLE_DEFAULT = 'espresso_default'; |
|
96 | + |
|
97 | + const CSS_HANDLE_CUSTOM = 'espresso_custom_css'; |
|
98 | + |
|
99 | + const CSS_HANDLE_COMPONENTS = 'eventespresso-components'; |
|
100 | + |
|
101 | + const CSS_HANDLE_CORE_CSS_DEFAULT = 'eventespresso-core-css-default'; |
|
102 | + |
|
103 | + /** |
|
104 | + * @var EE_Currency_Config $currency_config |
|
105 | + */ |
|
106 | + protected $currency_config; |
|
107 | + |
|
108 | + /** |
|
109 | + * @var EE_Template_Config $template_config |
|
110 | + */ |
|
111 | + protected $template_config; |
|
112 | + |
|
113 | + |
|
114 | + /** |
|
115 | + * CoreAssetRegister constructor. |
|
116 | + * |
|
117 | + * @param AssetCollection $assets |
|
118 | + * @param EE_Currency_Config $currency_config |
|
119 | + * @param EE_Template_Config $template_config |
|
120 | + * @param DomainInterface $domain |
|
121 | + * @param Registry $registry |
|
122 | + */ |
|
123 | + public function __construct( |
|
124 | + AssetCollection $assets, |
|
125 | + EE_Currency_Config $currency_config, |
|
126 | + EE_Template_Config $template_config, |
|
127 | + DomainInterface $domain, |
|
128 | + Registry $registry |
|
129 | + ) { |
|
130 | + $this->currency_config = $currency_config; |
|
131 | + $this->template_config = $template_config; |
|
132 | + parent::__construct($domain, $assets, $registry); |
|
133 | + } |
|
134 | + |
|
135 | + |
|
136 | + /** |
|
137 | + * @since 4.9.62.p |
|
138 | + * @throws DomainException |
|
139 | + * @throws DuplicateCollectionIdentifierException |
|
140 | + * @throws InvalidArgumentException |
|
141 | + * @throws InvalidDataTypeException |
|
142 | + * @throws InvalidEntityException |
|
143 | + * @throws InvalidInterfaceException |
|
144 | + */ |
|
145 | + public function addAssets() |
|
146 | + { |
|
147 | + $this->addJavascriptFiles(); |
|
148 | + $this->addStylesheetFiles(); |
|
149 | + } |
|
150 | + |
|
151 | + |
|
152 | + /** |
|
153 | + * @since 4.9.62.p |
|
154 | + * @throws DomainException |
|
155 | + * @throws DuplicateCollectionIdentifierException |
|
156 | + * @throws InvalidArgumentException |
|
157 | + * @throws InvalidDataTypeException |
|
158 | + * @throws InvalidEntityException |
|
159 | + * @throws InvalidInterfaceException |
|
160 | + */ |
|
161 | + public function addJavascriptFiles() |
|
162 | + { |
|
163 | + $this->loadCoreJs(); |
|
164 | + $this->loadJqueryValidate(); |
|
165 | + $this->loadAccountingJs(); |
|
166 | + add_action( |
|
167 | + 'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__before_script', |
|
168 | + array($this, 'loadQtipJs') |
|
169 | + ); |
|
170 | + $this->registerAdminAssets(); |
|
171 | + } |
|
172 | + |
|
173 | + |
|
174 | + /** |
|
175 | + * @since 4.9.62.p |
|
176 | + * @throws DuplicateCollectionIdentifierException |
|
177 | + * @throws InvalidDataTypeException |
|
178 | + * @throws InvalidEntityException |
|
179 | + */ |
|
180 | + public function addStylesheetFiles() |
|
181 | + { |
|
182 | + $this->loadCoreCss(); |
|
183 | + } |
|
184 | + |
|
185 | + |
|
186 | + /** |
|
187 | + * core default javascript |
|
188 | + * |
|
189 | + * @since 4.9.62.p |
|
190 | + * @throws DomainException |
|
191 | + * @throws DuplicateCollectionIdentifierException |
|
192 | + * @throws InvalidArgumentException |
|
193 | + * @throws InvalidDataTypeException |
|
194 | + * @throws InvalidEntityException |
|
195 | + * @throws InvalidInterfaceException |
|
196 | + */ |
|
197 | + private function loadCoreJs() |
|
198 | + { |
|
199 | + // conditionally load third-party libraries that WP core MIGHT have. |
|
200 | + $this->registerWpAssets(); |
|
201 | + |
|
202 | + $this->addJavascript( |
|
203 | + CoreAssetManager::JS_HANDLE_MANIFEST, |
|
204 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'manifest') |
|
205 | + ); |
|
206 | + |
|
207 | + $this->addJavascript( |
|
208 | + CoreAssetManager::JS_HANDLE_JS_CORE, |
|
209 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'eejs'), |
|
210 | + array(CoreAssetManager::JS_HANDLE_MANIFEST) |
|
211 | + ) |
|
212 | + ->setHasInlineData(); |
|
213 | + |
|
214 | + $this->addJavascript( |
|
215 | + CoreAssetManager::JS_HANDLE_VENDOR, |
|
216 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'vendor'), |
|
217 | + array( |
|
218 | + CoreAssetManager::JS_HANDLE_JS_CORE, |
|
219 | + CoreAssetManager::JS_HANDLE_REACT, |
|
220 | + CoreAssetManager::JS_HANDLE_REACT_DOM, |
|
221 | + CoreAssetManager::JS_HANDLE_LODASH, |
|
222 | + ) |
|
223 | + ); |
|
224 | + |
|
225 | + $this->addJavascript( |
|
226 | + CoreAssetManager::JS_HANDLE_VALIDATORS, |
|
227 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'validators') |
|
228 | + )->setRequiresTranslation(); |
|
229 | + |
|
230 | + $this->addJavascript( |
|
231 | + CoreAssetManager::JS_HANDLE_HELPERS, |
|
232 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'helpers'), |
|
233 | + array( |
|
234 | + CoreAssetManager::JS_HANDLE_VALIDATORS |
|
235 | + ) |
|
236 | + )->setRequiresTranslation(); |
|
237 | + |
|
238 | + $this->addJavascript( |
|
239 | + CoreAssetManager::JS_HANDLE_MODEL, |
|
240 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'model'), |
|
241 | + array( |
|
242 | + CoreAssetManager::JS_HANDLE_HELPERS, |
|
243 | + CoreAssetManager::JS_HANDLE_VALUE_OBJECTS, |
|
244 | + ) |
|
245 | + )->setRequiresTranslation(); |
|
246 | + |
|
247 | + $this->addJavascript( |
|
248 | + CoreAssetManager::JS_HANDLE_VALUE_OBJECTS, |
|
249 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'valueObjects'), |
|
250 | + array( |
|
251 | + CoreAssetManager::JS_HANDLE_VALIDATORS, |
|
252 | + CoreAssetManager::JS_HANDLE_HELPERS, |
|
253 | + ) |
|
254 | + )->setRequiresTranslation(); |
|
255 | + |
|
256 | + $this->addJavascript( |
|
257 | + CoreAssetManager::JS_HANDLE_DATA_STORES, |
|
258 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'data-stores'), |
|
259 | + array( |
|
260 | + CoreAssetManager::JS_HANDLE_VENDOR, |
|
261 | + 'wp-data', |
|
262 | + 'wp-api-fetch', |
|
263 | + CoreAssetManager::JS_HANDLE_VALUE_OBJECTS, |
|
264 | + CoreAssetManager::JS_HANDLE_MODEL, |
|
265 | + ) |
|
266 | + ) |
|
267 | + ->setRequiresTranslation() |
|
268 | + ->setInlineDataCallback( |
|
269 | + function() { |
|
270 | + wp_add_inline_script( |
|
271 | + CoreAssetManager::JS_HANDLE_DATA_STORES, |
|
272 | + is_admin() |
|
273 | + ? 'wp.apiFetch.use( eejs.middleWares.apiFetch.capsMiddleware( eejs.middleWares.apiFetch.CONTEXT_CAPS_EDIT ) )' |
|
274 | + : 'wp.apiFetch.use( eejs.middleWares.apiFetch.capsMiddleware )' |
|
275 | + ); |
|
276 | + } |
|
277 | + ); |
|
278 | + $this->addJavascript( |
|
279 | + CoreAssetManager::JS_HANDLE_HOOKS, |
|
280 | + $this->registry->getJsUrl( $this->domain->assetNamespace(), 'hooks' ), |
|
281 | + [ |
|
282 | + CoreAssetManager::JS_HANDLE_CORE |
|
283 | + ] |
|
284 | + ); |
|
285 | + |
|
286 | + $this->addJavascript( |
|
287 | + CoreAssetManager::JS_HANDLE_HOCS, |
|
288 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'hocs'), |
|
289 | + array( |
|
290 | + CoreAssetManager::JS_HANDLE_DATA_STORES, |
|
291 | + CoreAssetManager::JS_HANDLE_VALUE_OBJECTS, |
|
292 | + CoreAssetManager::JS_HANDLE_HOOKS, |
|
293 | + 'wp-components', |
|
294 | + ) |
|
295 | + )->setRequiresTranslation(); |
|
296 | + |
|
297 | + $this->addJavascript( |
|
298 | + CoreAssetManager::JS_HANDLE_COMPONENTS, |
|
299 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'components'), |
|
300 | + array( |
|
301 | + CoreAssetManager::JS_HANDLE_DATA_STORES, |
|
302 | + CoreAssetManager::JS_HANDLE_VALUE_OBJECTS, |
|
303 | + CoreAssetManager::JS_HANDLE_HOOKS, |
|
304 | + 'wp-components', |
|
305 | + ) |
|
306 | + ) |
|
307 | + ->setRequiresTranslation(); |
|
308 | + |
|
309 | + $this->addJavascript( |
|
310 | + CoreAssetManager::JS_HANDLE_EDITOR_HOCS, |
|
311 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'editor-hocs'), |
|
312 | + array( |
|
313 | + CoreAssetManager::JS_HANDLE_COMPONENTS |
|
314 | + ) |
|
315 | + )->setRequiresTranslation(); |
|
316 | + |
|
317 | + $this->registry->addData('eejs_api_nonce', wp_create_nonce('wp_rest')); |
|
318 | + $this->registry->addData( |
|
319 | + 'paths', |
|
320 | + array( |
|
321 | + 'base_rest_route' => rest_url(), |
|
322 | + 'rest_route' => rest_url('ee/v4.8.36/'), |
|
323 | + 'collection_endpoints' => EED_Core_Rest_Api::getCollectionRoutesIndexedByModelName(), |
|
324 | + 'primary_keys' => EED_Core_Rest_Api::getPrimaryKeyNamesIndexedByModelName(), |
|
325 | + 'site_url' => site_url('/'), |
|
326 | + 'admin_url' => admin_url('/'), |
|
327 | + ) |
|
328 | + ); |
|
329 | + // Event Espresso brand name |
|
330 | + $this->registry->addData('brandName', Domain::brandName()); |
|
331 | + /** site formatting values **/ |
|
332 | + $this->registry->addData( |
|
333 | + 'site_formats', |
|
334 | + array( |
|
335 | + 'date_formats' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats() |
|
336 | + ) |
|
337 | + ); |
|
338 | + /** currency data **/ |
|
339 | + $this->registry->addData( |
|
340 | + 'currency_config', |
|
341 | + $this->getCurrencySettings() |
|
342 | + ); |
|
343 | + /** site timezone */ |
|
344 | + $this->registry->addData( |
|
345 | + 'default_timezone', |
|
346 | + array( |
|
347 | + 'pretty' => EEH_DTT_Helper::get_timezone_string_for_display(), |
|
348 | + 'string' => get_option('timezone_string'), |
|
349 | + 'offset' => EEH_DTT_Helper::get_site_timezone_gmt_offset(), |
|
350 | + ) |
|
351 | + ); |
|
352 | + /** site locale (user locale if user logged in) */ |
|
353 | + $this->registry->addData( |
|
354 | + 'locale', |
|
355 | + array( |
|
356 | + 'user' => get_user_locale(), |
|
357 | + 'site' => get_locale() |
|
358 | + ) |
|
359 | + ); |
|
360 | + |
|
361 | + $this->addJavascript( |
|
362 | + CoreAssetManager::JS_HANDLE_CORE, |
|
363 | + EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
364 | + array(CoreAssetManager::JS_HANDLE_JQUERY) |
|
365 | + ) |
|
366 | + ->setInlineDataCallback( |
|
367 | + function () { |
|
368 | + wp_localize_script( |
|
369 | + CoreAssetManager::JS_HANDLE_CORE, |
|
370 | + CoreAssetManager::JS_HANDLE_I18N, |
|
371 | + EE_Registry::$i18n_js_strings |
|
372 | + ); |
|
373 | + } |
|
374 | + ); |
|
375 | + } |
|
376 | + |
|
377 | + |
|
378 | + /** |
|
379 | + * Registers vendor files that are bundled with a later version WP but might not be for the current version of |
|
380 | + * WordPress in the running environment. |
|
381 | + * |
|
382 | + * @throws DuplicateCollectionIdentifierException |
|
383 | + * @throws InvalidDataTypeException |
|
384 | + * @throws InvalidEntityException |
|
385 | + * @throws DomainException |
|
386 | + * @since 4.9.71.p |
|
387 | + */ |
|
388 | + private function registerWpAssets() |
|
389 | + { |
|
390 | + global $wp_version; |
|
391 | + if (version_compare($wp_version, '5.0.beta', '>=')) { |
|
392 | + return; |
|
393 | + } |
|
394 | + $this->addVendorJavascript(CoreAssetManager::JS_HANDLE_REACT) |
|
395 | + ->setVersion('16.6.0'); |
|
396 | + $this->addVendorJavascript( |
|
397 | + CoreAssetManager::JS_HANDLE_REACT_DOM, |
|
398 | + array(CoreAssetManager::JS_HANDLE_REACT) |
|
399 | + )->setVersion('16.6.0'); |
|
400 | + $this->addVendorJavascript(CoreAssetManager::JS_HANDLE_LODASH) |
|
401 | + ->setInlineDataCallback( |
|
402 | + function() { |
|
403 | + wp_add_inline_script( |
|
404 | + CoreAssetManager::JS_HANDLE_LODASH, |
|
405 | + 'window.lodash = _.noConflict();' |
|
406 | + ); |
|
407 | + } |
|
408 | + ) |
|
409 | + ->setVersion('4.17.11'); |
|
410 | + } |
|
411 | + |
|
412 | + |
|
413 | + /** |
|
414 | + * Returns configuration data for the accounting-js library. |
|
415 | + * @since 4.9.71.p |
|
416 | + * @return array |
|
417 | + */ |
|
418 | + private function getAccountingSettings() { |
|
419 | + return array( |
|
420 | + 'currency' => array( |
|
421 | + 'symbol' => $this->currency_config->sign, |
|
422 | + 'format' => array( |
|
423 | + 'pos' => $this->currency_config->sign_b4 ? '%s%v' : '%v%s', |
|
424 | + 'neg' => $this->currency_config->sign_b4 ? '- %s%v' : '- %v%s', |
|
425 | + 'zero' => $this->currency_config->sign_b4 ? '%s--' : '--%s', |
|
426 | + ), |
|
427 | + 'decimal' => $this->currency_config->dec_mrk, |
|
428 | + 'thousand' => $this->currency_config->thsnds, |
|
429 | + 'precision' => $this->currency_config->dec_plc, |
|
430 | + ), |
|
431 | + 'number' => array( |
|
432 | + 'precision' => $this->currency_config->dec_plc, |
|
433 | + 'thousand' => $this->currency_config->thsnds, |
|
434 | + 'decimal' => $this->currency_config->dec_mrk, |
|
435 | + ), |
|
436 | + ); |
|
437 | + } |
|
438 | + |
|
439 | + |
|
440 | + /** |
|
441 | + * Returns configuration data for the js Currency VO. |
|
442 | + * @since 4.9.71.p |
|
443 | + * @return array |
|
444 | + */ |
|
445 | + private function getCurrencySettings() |
|
446 | + { |
|
447 | + return array( |
|
448 | + 'code' => $this->currency_config->code, |
|
449 | + 'singularLabel' => $this->currency_config->name, |
|
450 | + 'pluralLabel' => $this->currency_config->plural, |
|
451 | + 'sign' => $this->currency_config->sign, |
|
452 | + 'signB4' => $this->currency_config->sign_b4, |
|
453 | + 'decimalPlaces' => $this->currency_config->dec_plc, |
|
454 | + 'decimalMark' => $this->currency_config->dec_mrk, |
|
455 | + 'thousandsSeparator' => $this->currency_config->thsnds, |
|
456 | + ); |
|
457 | + } |
|
458 | + |
|
459 | + |
|
460 | + /** |
|
461 | + * @since 4.9.62.p |
|
462 | + * @throws DuplicateCollectionIdentifierException |
|
463 | + * @throws InvalidDataTypeException |
|
464 | + * @throws InvalidEntityException |
|
465 | + */ |
|
466 | + private function loadCoreCss() |
|
467 | + { |
|
468 | + if ($this->template_config->enable_default_style && ! is_admin()) { |
|
469 | + $this->addStylesheet( |
|
470 | + CoreAssetManager::CSS_HANDLE_DEFAULT, |
|
471 | + is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css') |
|
472 | + ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css' |
|
473 | + : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', |
|
474 | + array('dashicons') |
|
475 | + ); |
|
476 | + //Load custom style sheet if available |
|
477 | + if ($this->template_config->custom_style_sheet !== null) { |
|
478 | + $this->addStylesheet( |
|
479 | + CoreAssetManager::CSS_HANDLE_CUSTOM, |
|
480 | + EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet, |
|
481 | + array(CoreAssetManager::CSS_HANDLE_DEFAULT) |
|
482 | + ); |
|
483 | + } |
|
484 | + } |
|
485 | + $this->addStylesheet( |
|
486 | + CoreAssetManager::CSS_HANDLE_CORE_CSS_DEFAULT, |
|
487 | + $this->registry->getCssUrl( |
|
488 | + $this->domain->assetNamespace(), |
|
489 | + 'core-default-theme' |
|
490 | + ), |
|
491 | + ['dashicons'] |
|
492 | + ); |
|
493 | + $this->addStylesheet( |
|
494 | + CoreAssetManager::CSS_HANDLE_COMPONENTS, |
|
495 | + $this->registry->getCssUrl( |
|
496 | + $this->domain->assetNamespace(), |
|
497 | + 'components' |
|
498 | + ), |
|
499 | + [CoreAssetManager::CSS_HANDLE_CORE_CSS_DEFAULT, 'wp-components'] |
|
500 | + ); |
|
501 | + } |
|
502 | + |
|
503 | + |
|
504 | + /** |
|
505 | + * jQuery Validate for form validation |
|
506 | + * |
|
507 | + * @since 4.9.62.p |
|
508 | + * @throws DomainException |
|
509 | + * @throws DuplicateCollectionIdentifierException |
|
510 | + * @throws InvalidDataTypeException |
|
511 | + * @throws InvalidEntityException |
|
512 | + */ |
|
513 | + private function loadJqueryValidate() |
|
514 | + { |
|
515 | + $this->addJavascript( |
|
516 | + CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE, |
|
517 | + EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', |
|
518 | + array(CoreAssetManager::JS_HANDLE_JQUERY) |
|
519 | + ) |
|
520 | + ->setVersion('1.15.0'); |
|
521 | + |
|
522 | + $this->addJavascript( |
|
523 | + CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE_EXTRA, |
|
524 | + EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js', |
|
525 | + array(CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE) |
|
526 | + ) |
|
527 | + ->setVersion('1.15.0'); |
|
528 | + } |
|
529 | + |
|
530 | + |
|
531 | + /** |
|
532 | + * accounting.js for performing client-side calculations |
|
533 | + * |
|
534 | + * @since 4.9.62.p |
|
535 | + * @throws DomainException |
|
536 | + * @throws DuplicateCollectionIdentifierException |
|
537 | + * @throws InvalidDataTypeException |
|
538 | + * @throws InvalidEntityException |
|
539 | + */ |
|
540 | + private function loadAccountingJs() |
|
541 | + { |
|
542 | + //accounting.js library |
|
543 | + // @link http://josscrowcroft.github.io/accounting.js/ |
|
544 | + $this->addJavascript( |
|
545 | + CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE, |
|
546 | + EE_THIRD_PARTY_URL . 'accounting/accounting.js', |
|
547 | + array(CoreAssetManager::JS_HANDLE_UNDERSCORE) |
|
548 | + ) |
|
549 | + ->setVersion('0.3.2'); |
|
550 | + |
|
551 | + $this->addJavascript( |
|
552 | + CoreAssetManager::JS_HANDLE_ACCOUNTING, |
|
553 | + EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', |
|
554 | + array(CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE) |
|
555 | + ) |
|
556 | + ->setInlineDataCallback( |
|
557 | + function () { |
|
558 | + wp_localize_script( |
|
559 | + CoreAssetManager::JS_HANDLE_ACCOUNTING, |
|
560 | + 'EE_ACCOUNTING_CFG', |
|
561 | + $this->getAccountingSettings() |
|
562 | + ); |
|
563 | + } |
|
564 | + ) |
|
565 | + ->setVersion(); |
|
566 | + } |
|
567 | + |
|
568 | + |
|
569 | + /** |
|
570 | + * registers assets for cleaning your ears |
|
571 | + * |
|
572 | + * @param JavascriptAsset $script |
|
573 | + */ |
|
574 | + public function loadQtipJs(JavascriptAsset $script) |
|
575 | + { |
|
576 | + // qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook, |
|
577 | + // can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' ); |
|
578 | + if ( |
|
579 | + $script->handle() === CoreAssetManager::JS_HANDLE_WP_PLUGINS_PAGE |
|
580 | + && apply_filters('FHEE_load_qtip', false) |
|
581 | + ) { |
|
582 | + EEH_Qtip_Loader::instance()->register_and_enqueue(); |
|
583 | + } |
|
584 | + } |
|
585 | + |
|
586 | + |
|
587 | + /** |
|
588 | + * assets that are used in the WordPress admin |
|
589 | + * |
|
590 | + * @since 4.9.62.p |
|
591 | + * @throws DuplicateCollectionIdentifierException |
|
592 | + * @throws InvalidDataTypeException |
|
593 | + * @throws InvalidEntityException |
|
594 | + */ |
|
595 | + private function registerAdminAssets() |
|
596 | + { |
|
597 | + $this->addJavascript( |
|
598 | + CoreAssetManager::JS_HANDLE_WP_PLUGINS_PAGE, |
|
599 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'wp-plugins-page'), |
|
600 | + array( |
|
601 | + CoreAssetManager::JS_HANDLE_JQUERY, |
|
602 | + CoreAssetManager::JS_HANDLE_VENDOR, |
|
603 | + ) |
|
604 | + ) |
|
605 | + ->setRequiresTranslation(); |
|
606 | + |
|
607 | + $this->addStylesheet( |
|
608 | + CoreAssetManager::JS_HANDLE_WP_PLUGINS_PAGE, |
|
609 | + $this->registry->getCssUrl($this->domain->assetNamespace(), 'wp-plugins-page') |
|
610 | + ); |
|
611 | + } |
|
612 | 612 | } |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | ); |
278 | 278 | $this->addJavascript( |
279 | 279 | CoreAssetManager::JS_HANDLE_HOOKS, |
280 | - $this->registry->getJsUrl( $this->domain->assetNamespace(), 'hooks' ), |
|
280 | + $this->registry->getJsUrl($this->domain->assetNamespace(), 'hooks'), |
|
281 | 281 | [ |
282 | 282 | CoreAssetManager::JS_HANDLE_CORE |
283 | 283 | ] |
@@ -360,11 +360,11 @@ discard block |
||
360 | 360 | |
361 | 361 | $this->addJavascript( |
362 | 362 | CoreAssetManager::JS_HANDLE_CORE, |
363 | - EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
363 | + EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js', |
|
364 | 364 | array(CoreAssetManager::JS_HANDLE_JQUERY) |
365 | 365 | ) |
366 | 366 | ->setInlineDataCallback( |
367 | - function () { |
|
367 | + function() { |
|
368 | 368 | wp_localize_script( |
369 | 369 | CoreAssetManager::JS_HANDLE_CORE, |
370 | 370 | CoreAssetManager::JS_HANDLE_I18N, |
@@ -468,16 +468,16 @@ discard block |
||
468 | 468 | if ($this->template_config->enable_default_style && ! is_admin()) { |
469 | 469 | $this->addStylesheet( |
470 | 470 | CoreAssetManager::CSS_HANDLE_DEFAULT, |
471 | - is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css') |
|
471 | + is_readable(EVENT_ESPRESSO_UPLOAD_DIR.'css/style.css') |
|
472 | 472 | ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css' |
473 | - : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', |
|
473 | + : EE_GLOBAL_ASSETS_URL.'css/espresso_default.css', |
|
474 | 474 | array('dashicons') |
475 | 475 | ); |
476 | 476 | //Load custom style sheet if available |
477 | 477 | if ($this->template_config->custom_style_sheet !== null) { |
478 | 478 | $this->addStylesheet( |
479 | 479 | CoreAssetManager::CSS_HANDLE_CUSTOM, |
480 | - EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet, |
|
480 | + EVENT_ESPRESSO_UPLOAD_URL.'css/'.$this->template_config->custom_style_sheet, |
|
481 | 481 | array(CoreAssetManager::CSS_HANDLE_DEFAULT) |
482 | 482 | ); |
483 | 483 | } |
@@ -514,14 +514,14 @@ discard block |
||
514 | 514 | { |
515 | 515 | $this->addJavascript( |
516 | 516 | CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE, |
517 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', |
|
517 | + EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.min.js', |
|
518 | 518 | array(CoreAssetManager::JS_HANDLE_JQUERY) |
519 | 519 | ) |
520 | 520 | ->setVersion('1.15.0'); |
521 | 521 | |
522 | 522 | $this->addJavascript( |
523 | 523 | CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE_EXTRA, |
524 | - EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js', |
|
524 | + EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.additional-methods.min.js', |
|
525 | 525 | array(CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE) |
526 | 526 | ) |
527 | 527 | ->setVersion('1.15.0'); |
@@ -543,18 +543,18 @@ discard block |
||
543 | 543 | // @link http://josscrowcroft.github.io/accounting.js/ |
544 | 544 | $this->addJavascript( |
545 | 545 | CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE, |
546 | - EE_THIRD_PARTY_URL . 'accounting/accounting.js', |
|
546 | + EE_THIRD_PARTY_URL.'accounting/accounting.js', |
|
547 | 547 | array(CoreAssetManager::JS_HANDLE_UNDERSCORE) |
548 | 548 | ) |
549 | 549 | ->setVersion('0.3.2'); |
550 | 550 | |
551 | 551 | $this->addJavascript( |
552 | 552 | CoreAssetManager::JS_HANDLE_ACCOUNTING, |
553 | - EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', |
|
553 | + EE_GLOBAL_ASSETS_URL.'scripts/ee-accounting-config.js', |
|
554 | 554 | array(CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE) |
555 | 555 | ) |
556 | 556 | ->setInlineDataCallback( |
557 | - function () { |
|
557 | + function() { |
|
558 | 558 | wp_localize_script( |
559 | 559 | CoreAssetManager::JS_HANDLE_ACCOUNTING, |
560 | 560 | 'EE_ACCOUNTING_CFG', |