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