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