Completed
Branch Gutenberg/master (d01d23)
by
unknown
10:01
created
core/domain/services/assets/CoreAssetManager.php 1 patch
Indentation   +447 added lines, -447 removed lines patch added patch discarded remove patch
@@ -29,469 +29,469 @@
 block discarded – undo
29 29
 class CoreAssetManager extends AssetManager
30 30
 {
31 31
 
32
-    // WordPress core / Third party JS asset handles
33
-    const JS_HANDLE_JQUERY = 'jquery';
32
+	// WordPress core / Third party JS asset handles
33
+	const JS_HANDLE_JQUERY = 'jquery';
34 34
 
35
-    const JS_HANDLE_JQUERY_VALIDATE = 'jquery-validate';
35
+	const JS_HANDLE_JQUERY_VALIDATE = 'jquery-validate';
36 36
 
37
-    const JS_HANDLE_JQUERY_VALIDATE_EXTRA = 'jquery-validate-extra-methods';
37
+	const JS_HANDLE_JQUERY_VALIDATE_EXTRA = 'jquery-validate-extra-methods';
38 38
 
39
-    const JS_HANDLE_UNDERSCORE = 'underscore';
39
+	const JS_HANDLE_UNDERSCORE = 'underscore';
40 40
 
41
-    const JS_HANDLE_ACCOUNTING_CORE = 'ee-accounting-core';
41
+	const JS_HANDLE_ACCOUNTING_CORE = 'ee-accounting-core';
42 42
 
43
-    // EE JS assets handles
44
-    const JS_HANDLE_EE_MANIFEST = 'ee-manifest';
43
+	// EE JS assets handles
44
+	const JS_HANDLE_EE_MANIFEST = 'ee-manifest';
45 45
 
46
-    const JS_HANDLE_EE_JS_CORE = 'eejs-core';
46
+	const JS_HANDLE_EE_JS_CORE = 'eejs-core';
47 47
 
48
-    const JS_HANDLE_EE_VENDOR = 'eventespresso-vendor';
48
+	const JS_HANDLE_EE_VENDOR = 'eventespresso-vendor';
49 49
 
50
-    const JS_HANDLE_EE_DATA_STORES = 'eventespresso-data-stores';
50
+	const JS_HANDLE_EE_DATA_STORES = 'eventespresso-data-stores';
51 51
 
52
-    const JS_HANDLE_EE_HELPERS = 'eventespresso-helpers';
52
+	const JS_HANDLE_EE_HELPERS = 'eventespresso-helpers';
53 53
 
54
-    const JS_HANDLE_EE_MODEL = 'eventespresso-model';
54
+	const JS_HANDLE_EE_MODEL = 'eventespresso-model';
55 55
 
56
-    const JS_HANDLE_EE_VALUE_OBJECTS = 'eventespresso-value-objects';
56
+	const JS_HANDLE_EE_VALUE_OBJECTS = 'eventespresso-value-objects';
57 57
 
58
-    const JS_HANDLE_EE_HOC_COMPONENTS = 'eventespresso-hoc-components';
58
+	const JS_HANDLE_EE_HOC_COMPONENTS = 'eventespresso-hoc-components';
59 59
 
60
-    const JS_HANDLE_EE_COMPONENTS = 'eventespresso-components';
60
+	const JS_HANDLE_EE_COMPONENTS = 'eventespresso-components';
61 61
 
62
-    const JS_HANDLE_EE_VALIDATORS = 'eventespresso-validators';
62
+	const JS_HANDLE_EE_VALIDATORS = 'eventespresso-validators';
63 63
 
64
-    const JS_HANDLE_EE_JS_API = 'eejs-api';
64
+	const JS_HANDLE_EE_JS_API = 'eejs-api';
65 65
 
66
-    const JS_HANDLE_EE_CORE = 'espresso_core';
66
+	const JS_HANDLE_EE_CORE = 'espresso_core';
67 67
 
68
-    const JS_HANDLE_EE_I18N = 'eei18n';
68
+	const JS_HANDLE_EE_I18N = 'eei18n';
69 69
 
70
-    const JS_HANDLE_EE_ACCOUNTING = 'ee-accounting';
71
-
72
-    const JS_HANDLE_EE_WP_PLUGINS_PAGE = 'ee-wp-plugins-page';
73
-
74
-    // EE CSS assets handles
75
-    const CSS_HANDLE_EE_DEFAULT = 'espresso_default';
76
-
77
-    const CSS_HANDLE_EE_CUSTOM = 'espresso_custom_css';
78
-
79
-    const CSS_HANDLE_EE_COMPONENTS = 'eventespresso-components';
80
-
81
-    /**
82
-     * @var EE_Currency_Config $currency_config
83
-     */
84
-    protected $currency_config;
85
-
86
-    /**
87
-     * @var EE_Template_Config $template_config
88
-     */
89
-    protected $template_config;
90
-
91
-
92
-    /**
93
-     * CoreAssetRegister constructor.
94
-     *
95
-     * @param AssetCollection    $assets
96
-     * @param EE_Currency_Config $currency_config
97
-     * @param EE_Template_Config $template_config
98
-     * @param DomainInterface    $domain
99
-     * @param Registry           $registry
100
-     */
101
-    public function __construct(
102
-        AssetCollection $assets,
103
-        EE_Currency_Config $currency_config,
104
-        EE_Template_Config $template_config,
105
-        DomainInterface $domain,
106
-        Registry $registry
107
-    ) {
108
-        $this->currency_config = $currency_config;
109
-        $this->template_config = $template_config;
110
-        parent::__construct($domain, $assets, $registry);
111
-    }
112
-
113
-
114
-    /**
115
-     * @since 4.9.62.p
116
-     * @throws DuplicateCollectionIdentifierException
117
-     * @throws InvalidArgumentException
118
-     * @throws InvalidDataTypeException
119
-     * @throws InvalidEntityException
120
-     */
121
-    public function addAssets()
122
-    {
123
-        $this->addJavascriptFiles();
124
-        $this->addStylesheetFiles();
125
-    }
126
-
127
-
128
-    /**
129
-     * @since 4.9.62.p
130
-     * @throws DuplicateCollectionIdentifierException
131
-     * @throws InvalidArgumentException
132
-     * @throws InvalidDataTypeException
133
-     * @throws InvalidEntityException
134
-     */
135
-    public function addJavascriptFiles()
136
-    {
137
-        $this->loadCoreJs();
138
-        $this->loadJqueryValidate();
139
-        $this->loadAccountingJs();
140
-        add_action(
141
-            'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__before_script',
142
-            array($this, 'loadQtipJs')
143
-        );
144
-        $this->registerAdminAssets();
145
-    }
146
-
147
-
148
-    /**
149
-     * @since 4.9.62.p
150
-     * @throws DuplicateCollectionIdentifierException
151
-     * @throws InvalidDataTypeException
152
-     * @throws InvalidEntityException
153
-     */
154
-    public function addStylesheetFiles()
155
-    {
156
-        $this->loadCoreCss();
157
-    }
158
-
159
-
160
-    /**
161
-     * core default javascript
162
-     *
163
-     * @since 4.9.62.p
164
-     * @throws DuplicateCollectionIdentifierException
165
-     * @throws InvalidArgumentException
166
-     * @throws InvalidDataTypeException
167
-     * @throws InvalidEntityException
168
-     */
169
-    private function loadCoreJs()
170
-    {
171
-        $this->addJavascript(
172
-            CoreAssetManager::JS_HANDLE_EE_MANIFEST,
173
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'manifest')
174
-        );
175
-
176
-        $this->addJavascript(
177
-            CoreAssetManager::JS_HANDLE_EE_JS_CORE,
178
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'eejs'),
179
-            array(CoreAssetManager::JS_HANDLE_EE_MANIFEST)
180
-        )
181
-        ->setHasInlineData();
182
-
183
-        $this->addJavascript(
184
-            CoreAssetManager::JS_HANDLE_EE_VENDOR,
185
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'vendor'),
186
-            array(CoreAssetManager::JS_HANDLE_EE_JS_CORE)
187
-        );
188
-
189
-        $this->addJavascript(
190
-            CoreAssetManager::JS_HANDLE_EE_VALIDATORS,
191
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'validators')
192
-        )->setRequiresTranslation();
193
-
194
-        $this->addJavascript(
195
-            CoreAssetManager::JS_HANDLE_EE_HELPERS,
196
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'helpers'),
197
-            array(
198
-                CoreAssetManager::JS_HANDLE_EE_VALIDATORS
199
-            )
200
-        )->setRequiresTranslation();
201
-
202
-        $this->addJavascript(
203
-            CoreAssetManager::JS_HANDLE_EE_MODEL,
204
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'model'),
205
-            array(
206
-                CoreAssetManager::JS_HANDLE_EE_HELPERS
207
-            )
208
-        )->setRequiresTranslation();
209
-
210
-        $this->addJavascript(
211
-            CoreAssetManager::JS_HANDLE_EE_VALUE_OBJECTS,
212
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'valueObjects'),
213
-            array(
214
-                CoreAssetManager::JS_HANDLE_EE_MODEL
215
-            )
216
-        )->setRequiresTranslation();
217
-
218
-        $this->addJavascript(
219
-            CoreAssetManager::JS_HANDLE_EE_DATA_STORES,
220
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'data-stores'),
221
-            array(
222
-                CoreAssetManager::JS_HANDLE_EE_VENDOR,
223
-                'wp-data',
224
-                'wp-api-request',
225
-                CoreAssetManager::JS_HANDLE_EE_VALUE_OBJECTS
226
-            )
227
-        )
228
-             ->setRequiresTranslation();
229
-
230
-        $this->addJavascript(
231
-            CoreAssetManager::JS_HANDLE_EE_HOC_COMPONENTS,
232
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'hocComponents'),
233
-            array(
234
-                CoreAssetManager::JS_HANDLE_EE_DATA_STORES,
235
-                CoreAssetManager::JS_HANDLE_EE_VALUE_OBJECTS,
236
-                'wp-components',
237
-            )
238
-        )->setRequiresTranslation();
239
-
240
-        $this->addJavascript(
241
-            CoreAssetManager::JS_HANDLE_EE_COMPONENTS,
242
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'components'),
243
-            array(
244
-                CoreAssetManager::JS_HANDLE_EE_DATA_STORES,
245
-                CoreAssetManager::JS_HANDLE_EE_VALUE_OBJECTS,
246
-                'wp-components',
247
-            )
248
-        )
249
-        ->setRequiresTranslation();
250
-
251
-        $this->registry->addData('eejs_api_nonce', wp_create_nonce('wp_rest'));
252
-        $this->registry->addData(
253
-            'paths',
254
-            array(
255
-                'rest_route' => rest_url('ee/v4.8.36/'),
256
-                'collection_endpoints' => EED_Core_Rest_Api::getCollectionRoutesIndexedByModelName(),
257
-                'primary_keys' => EED_Core_Rest_Api::getPrimaryKeyNamesIndexedByModelName(),
258
-                'site_url' => site_url('/'),
259
-                'admin_url' => admin_url('/'),
260
-            )
261
-        );
262
-        /** site formatting values **/
263
-        $this->registry->addData(
264
-            'site_formats',
265
-            array(
266
-                'date_formats' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats()
267
-            )
268
-        );
269
-        /** currency data **/
270
-        $this->registry->addData(
271
-            'currency_config',
272
-            $this->getCurrencySettings()
273
-        );
274
-        /** site timezone */
275
-        $this->registry->addData(
276
-            'default_timezone',
277
-            array(
278
-                'pretty' => EEH_DTT_Helper::get_timezone_string_for_display(),
279
-                'string' => get_option('timezone_string'),
280
-                'offset' => EEH_DTT_Helper::get_site_timezone_gmt_offset(),
281
-            )
282
-        );
283
-        /** site locale (user locale if user logged in) */
284
-        $this->registry->addData(
285
-            'locale',
286
-            array(
287
-                'user' => get_user_locale(),
288
-                'site' => get_locale()
289
-            )
290
-        );
291
-
292
-        $this->addJavascript(
293
-            CoreAssetManager::JS_HANDLE_EE_CORE,
294
-            EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
295
-            array(CoreAssetManager::JS_HANDLE_JQUERY)
296
-        )
297
-        ->setInlineDataCallback(
298
-            function () {
299
-                wp_localize_script(
300
-                    CoreAssetManager::JS_HANDLE_EE_CORE,
301
-                    CoreAssetManager::JS_HANDLE_EE_I18N,
302
-                    EE_Registry::$i18n_js_strings
303
-                );
304
-            }
305
-        );
306
-    }
307
-
308
-
309
-    /**
310
-     * Returns configuration data for the accounting-js library.
311
-     * @since $VID:$
312
-     * @return array
313
-     */
314
-    private function getAccountingSettings() {
315
-        return array(
316
-            'currency' => array(
317
-                'symbol'    => $this->currency_config->sign,
318
-                'format'    => array(
319
-                    'pos'  => $this->currency_config->sign_b4 ? '%s%v' : '%v%s',
320
-                    'neg'  => $this->currency_config->sign_b4 ? '- %s%v' : '- %v%s',
321
-                    'zero' => $this->currency_config->sign_b4 ? '%s--' : '--%s',
322
-                ),
323
-                'decimal'   => $this->currency_config->dec_mrk,
324
-                'thousand'  => $this->currency_config->thsnds,
325
-                'precision' => $this->currency_config->dec_plc,
326
-            ),
327
-            'number'   => array(
328
-                'precision' => $this->currency_config->dec_plc,
329
-                'thousand'  => $this->currency_config->thsnds,
330
-                'decimal'   => $this->currency_config->dec_mrk,
331
-            ),
332
-        );
333
-    }
334
-
335
-
336
-    /**
337
-     * Returns configuration data for the js Currency VO.
338
-     * @sinc $VID:$
339
-     * @return array
340
-     */
341
-    private function getCurrencySettings()
342
-    {
343
-        return array(
344
-            'code' => $this->currency_config->code,
345
-            'singularLabel' => $this->currency_config->name,
346
-            'pluralLabel' => $this->currency_config->plural,
347
-            'sign' => $this->currency_config->sign,
348
-            'signB4' => $this->currency_config->sign_b4,
349
-            'decimalPlaces' => $this->currency_config->dec_plc,
350
-            'decimalMark' => $this->currency_config->dec_mrk,
351
-            'thousandsSeparator' => $this->currency_config->thsnds,
352
-        );
353
-    }
354
-
355
-
356
-    /**
357
-     * @since 4.9.62.p
358
-     * @throws DuplicateCollectionIdentifierException
359
-     * @throws InvalidDataTypeException
360
-     * @throws InvalidEntityException
361
-     */
362
-    private function loadCoreCss()
363
-    {
364
-        if ($this->template_config->enable_default_style && ! is_admin()) {
365
-            $this->addStylesheet(
366
-                CoreAssetManager::CSS_HANDLE_EE_DEFAULT,
367
-                is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')
368
-                    ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css'
369
-                    : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css',
370
-                array('dashicons')
371
-            );
372
-            //Load custom style sheet if available
373
-            if ($this->template_config->custom_style_sheet !== null) {
374
-                $this->addStylesheet(
375
-                    CoreAssetManager::CSS_HANDLE_EE_CUSTOM,
376
-                    EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet,
377
-                    array(CoreAssetManager::CSS_HANDLE_EE_DEFAULT)
378
-                );
379
-            }
380
-        }
381
-        $this->addStylesheet(
382
-            CoreAssetManager::CSS_HANDLE_EE_COMPONENTS,
383
-            $this->registry->getCssUrl(
384
-                $this->domain->assetNamespace(),
385
-                'components'
386
-            )
387
-        );
388
-    }
389
-
390
-
391
-    /**
392
-     * jQuery Validate for form validation
393
-     *
394
-     * @since 4.9.62.p
395
-     * @throws DuplicateCollectionIdentifierException
396
-     * @throws InvalidDataTypeException
397
-     * @throws InvalidEntityException
398
-     */
399
-    private function loadJqueryValidate()
400
-    {
401
-        $this->addJavascript(
402
-            CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE,
403
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js',
404
-            array(CoreAssetManager::JS_HANDLE_JQUERY)
405
-        )
406
-        ->setVersion('1.15.0');
407
-
408
-        $this->addJavascript(
409
-            CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE_EXTRA,
410
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js',
411
-            array(CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE)
412
-        )
413
-        ->setVersion('1.15.0');
414
-    }
415
-
416
-
417
-    /**
418
-     * accounting.js for performing client-side calculations
419
-     *
420
-     * @since 4.9.62.p
421
-     * @throws DuplicateCollectionIdentifierException
422
-     * @throws InvalidDataTypeException
423
-     * @throws InvalidEntityException
424
-     */
425
-    private function loadAccountingJs()
426
-    {
427
-        //accounting.js library
428
-        // @link http://josscrowcroft.github.io/accounting.js/
429
-        $this->addJavascript(
430
-            CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE,
431
-            EE_THIRD_PARTY_URL . 'accounting/accounting.js',
432
-            array(CoreAssetManager::JS_HANDLE_UNDERSCORE)
433
-        )
434
-        ->setVersion('0.3.2');
435
-
436
-        $this->addJavascript(
437
-            CoreAssetManager::JS_HANDLE_EE_ACCOUNTING,
438
-            EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js',
439
-            array(CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE)
440
-        )
441
-        ->setInlineDataCallback(
442
-            function () {
443
-                 wp_localize_script(
444
-                     CoreAssetManager::JS_HANDLE_EE_ACCOUNTING,
445
-                     'EE_ACCOUNTING_CFG',
446
-                     $this->getAccountingSettings()
447
-                 );
448
-            }
449
-        )
450
-        ->setVersion();
451
-    }
452
-
453
-
454
-    /**
455
-     * registers assets for cleaning your ears
456
-     *
457
-     * @param JavascriptAsset $script
458
-     */
459
-    public function loadQtipJs(JavascriptAsset $script)
460
-    {
461
-        // qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook,
462
-        // can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' );
463
-        if (
464
-            $script->handle() === CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE
465
-            && apply_filters('FHEE_load_qtip', false)
466
-        ) {
467
-            EEH_Qtip_Loader::instance()->register_and_enqueue();
468
-        }
469
-    }
470
-
471
-
472
-    /**
473
-     * assets that are used in the WordPress admin
474
-     *
475
-     * @since 4.9.62.p
476
-     * @throws DuplicateCollectionIdentifierException
477
-     * @throws InvalidDataTypeException
478
-     * @throws InvalidEntityException
479
-     */
480
-    private function registerAdminAssets()
481
-    {
482
-        $this->addJavascript(
483
-            CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE,
484
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'wp-plugins-page'),
485
-            array(
486
-                CoreAssetManager::JS_HANDLE_JQUERY,
487
-                CoreAssetManager::JS_HANDLE_EE_VENDOR,
488
-            )
489
-        )
490
-        ->setRequiresTranslation();
491
-
492
-        $this->addStylesheet(
493
-            CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE,
494
-            $this->registry->getCssUrl($this->domain->assetNamespace(), 'wp-plugins-page')
495
-        );
496
-    }
70
+	const JS_HANDLE_EE_ACCOUNTING = 'ee-accounting';
71
+
72
+	const JS_HANDLE_EE_WP_PLUGINS_PAGE = 'ee-wp-plugins-page';
73
+
74
+	// EE CSS assets handles
75
+	const CSS_HANDLE_EE_DEFAULT = 'espresso_default';
76
+
77
+	const CSS_HANDLE_EE_CUSTOM = 'espresso_custom_css';
78
+
79
+	const CSS_HANDLE_EE_COMPONENTS = 'eventespresso-components';
80
+
81
+	/**
82
+	 * @var EE_Currency_Config $currency_config
83
+	 */
84
+	protected $currency_config;
85
+
86
+	/**
87
+	 * @var EE_Template_Config $template_config
88
+	 */
89
+	protected $template_config;
90
+
91
+
92
+	/**
93
+	 * CoreAssetRegister constructor.
94
+	 *
95
+	 * @param AssetCollection    $assets
96
+	 * @param EE_Currency_Config $currency_config
97
+	 * @param EE_Template_Config $template_config
98
+	 * @param DomainInterface    $domain
99
+	 * @param Registry           $registry
100
+	 */
101
+	public function __construct(
102
+		AssetCollection $assets,
103
+		EE_Currency_Config $currency_config,
104
+		EE_Template_Config $template_config,
105
+		DomainInterface $domain,
106
+		Registry $registry
107
+	) {
108
+		$this->currency_config = $currency_config;
109
+		$this->template_config = $template_config;
110
+		parent::__construct($domain, $assets, $registry);
111
+	}
112
+
113
+
114
+	/**
115
+	 * @since 4.9.62.p
116
+	 * @throws DuplicateCollectionIdentifierException
117
+	 * @throws InvalidArgumentException
118
+	 * @throws InvalidDataTypeException
119
+	 * @throws InvalidEntityException
120
+	 */
121
+	public function addAssets()
122
+	{
123
+		$this->addJavascriptFiles();
124
+		$this->addStylesheetFiles();
125
+	}
126
+
127
+
128
+	/**
129
+	 * @since 4.9.62.p
130
+	 * @throws DuplicateCollectionIdentifierException
131
+	 * @throws InvalidArgumentException
132
+	 * @throws InvalidDataTypeException
133
+	 * @throws InvalidEntityException
134
+	 */
135
+	public function addJavascriptFiles()
136
+	{
137
+		$this->loadCoreJs();
138
+		$this->loadJqueryValidate();
139
+		$this->loadAccountingJs();
140
+		add_action(
141
+			'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__before_script',
142
+			array($this, 'loadQtipJs')
143
+		);
144
+		$this->registerAdminAssets();
145
+	}
146
+
147
+
148
+	/**
149
+	 * @since 4.9.62.p
150
+	 * @throws DuplicateCollectionIdentifierException
151
+	 * @throws InvalidDataTypeException
152
+	 * @throws InvalidEntityException
153
+	 */
154
+	public function addStylesheetFiles()
155
+	{
156
+		$this->loadCoreCss();
157
+	}
158
+
159
+
160
+	/**
161
+	 * core default javascript
162
+	 *
163
+	 * @since 4.9.62.p
164
+	 * @throws DuplicateCollectionIdentifierException
165
+	 * @throws InvalidArgumentException
166
+	 * @throws InvalidDataTypeException
167
+	 * @throws InvalidEntityException
168
+	 */
169
+	private function loadCoreJs()
170
+	{
171
+		$this->addJavascript(
172
+			CoreAssetManager::JS_HANDLE_EE_MANIFEST,
173
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'manifest')
174
+		);
175
+
176
+		$this->addJavascript(
177
+			CoreAssetManager::JS_HANDLE_EE_JS_CORE,
178
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'eejs'),
179
+			array(CoreAssetManager::JS_HANDLE_EE_MANIFEST)
180
+		)
181
+		->setHasInlineData();
182
+
183
+		$this->addJavascript(
184
+			CoreAssetManager::JS_HANDLE_EE_VENDOR,
185
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'vendor'),
186
+			array(CoreAssetManager::JS_HANDLE_EE_JS_CORE)
187
+		);
188
+
189
+		$this->addJavascript(
190
+			CoreAssetManager::JS_HANDLE_EE_VALIDATORS,
191
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'validators')
192
+		)->setRequiresTranslation();
193
+
194
+		$this->addJavascript(
195
+			CoreAssetManager::JS_HANDLE_EE_HELPERS,
196
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'helpers'),
197
+			array(
198
+				CoreAssetManager::JS_HANDLE_EE_VALIDATORS
199
+			)
200
+		)->setRequiresTranslation();
201
+
202
+		$this->addJavascript(
203
+			CoreAssetManager::JS_HANDLE_EE_MODEL,
204
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'model'),
205
+			array(
206
+				CoreAssetManager::JS_HANDLE_EE_HELPERS
207
+			)
208
+		)->setRequiresTranslation();
209
+
210
+		$this->addJavascript(
211
+			CoreAssetManager::JS_HANDLE_EE_VALUE_OBJECTS,
212
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'valueObjects'),
213
+			array(
214
+				CoreAssetManager::JS_HANDLE_EE_MODEL
215
+			)
216
+		)->setRequiresTranslation();
217
+
218
+		$this->addJavascript(
219
+			CoreAssetManager::JS_HANDLE_EE_DATA_STORES,
220
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'data-stores'),
221
+			array(
222
+				CoreAssetManager::JS_HANDLE_EE_VENDOR,
223
+				'wp-data',
224
+				'wp-api-request',
225
+				CoreAssetManager::JS_HANDLE_EE_VALUE_OBJECTS
226
+			)
227
+		)
228
+			 ->setRequiresTranslation();
229
+
230
+		$this->addJavascript(
231
+			CoreAssetManager::JS_HANDLE_EE_HOC_COMPONENTS,
232
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'hocComponents'),
233
+			array(
234
+				CoreAssetManager::JS_HANDLE_EE_DATA_STORES,
235
+				CoreAssetManager::JS_HANDLE_EE_VALUE_OBJECTS,
236
+				'wp-components',
237
+			)
238
+		)->setRequiresTranslation();
239
+
240
+		$this->addJavascript(
241
+			CoreAssetManager::JS_HANDLE_EE_COMPONENTS,
242
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'components'),
243
+			array(
244
+				CoreAssetManager::JS_HANDLE_EE_DATA_STORES,
245
+				CoreAssetManager::JS_HANDLE_EE_VALUE_OBJECTS,
246
+				'wp-components',
247
+			)
248
+		)
249
+		->setRequiresTranslation();
250
+
251
+		$this->registry->addData('eejs_api_nonce', wp_create_nonce('wp_rest'));
252
+		$this->registry->addData(
253
+			'paths',
254
+			array(
255
+				'rest_route' => rest_url('ee/v4.8.36/'),
256
+				'collection_endpoints' => EED_Core_Rest_Api::getCollectionRoutesIndexedByModelName(),
257
+				'primary_keys' => EED_Core_Rest_Api::getPrimaryKeyNamesIndexedByModelName(),
258
+				'site_url' => site_url('/'),
259
+				'admin_url' => admin_url('/'),
260
+			)
261
+		);
262
+		/** site formatting values **/
263
+		$this->registry->addData(
264
+			'site_formats',
265
+			array(
266
+				'date_formats' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats()
267
+			)
268
+		);
269
+		/** currency data **/
270
+		$this->registry->addData(
271
+			'currency_config',
272
+			$this->getCurrencySettings()
273
+		);
274
+		/** site timezone */
275
+		$this->registry->addData(
276
+			'default_timezone',
277
+			array(
278
+				'pretty' => EEH_DTT_Helper::get_timezone_string_for_display(),
279
+				'string' => get_option('timezone_string'),
280
+				'offset' => EEH_DTT_Helper::get_site_timezone_gmt_offset(),
281
+			)
282
+		);
283
+		/** site locale (user locale if user logged in) */
284
+		$this->registry->addData(
285
+			'locale',
286
+			array(
287
+				'user' => get_user_locale(),
288
+				'site' => get_locale()
289
+			)
290
+		);
291
+
292
+		$this->addJavascript(
293
+			CoreAssetManager::JS_HANDLE_EE_CORE,
294
+			EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
295
+			array(CoreAssetManager::JS_HANDLE_JQUERY)
296
+		)
297
+		->setInlineDataCallback(
298
+			function () {
299
+				wp_localize_script(
300
+					CoreAssetManager::JS_HANDLE_EE_CORE,
301
+					CoreAssetManager::JS_HANDLE_EE_I18N,
302
+					EE_Registry::$i18n_js_strings
303
+				);
304
+			}
305
+		);
306
+	}
307
+
308
+
309
+	/**
310
+	 * Returns configuration data for the accounting-js library.
311
+	 * @since $VID:$
312
+	 * @return array
313
+	 */
314
+	private function getAccountingSettings() {
315
+		return array(
316
+			'currency' => array(
317
+				'symbol'    => $this->currency_config->sign,
318
+				'format'    => array(
319
+					'pos'  => $this->currency_config->sign_b4 ? '%s%v' : '%v%s',
320
+					'neg'  => $this->currency_config->sign_b4 ? '- %s%v' : '- %v%s',
321
+					'zero' => $this->currency_config->sign_b4 ? '%s--' : '--%s',
322
+				),
323
+				'decimal'   => $this->currency_config->dec_mrk,
324
+				'thousand'  => $this->currency_config->thsnds,
325
+				'precision' => $this->currency_config->dec_plc,
326
+			),
327
+			'number'   => array(
328
+				'precision' => $this->currency_config->dec_plc,
329
+				'thousand'  => $this->currency_config->thsnds,
330
+				'decimal'   => $this->currency_config->dec_mrk,
331
+			),
332
+		);
333
+	}
334
+
335
+
336
+	/**
337
+	 * Returns configuration data for the js Currency VO.
338
+	 * @sinc $VID:$
339
+	 * @return array
340
+	 */
341
+	private function getCurrencySettings()
342
+	{
343
+		return array(
344
+			'code' => $this->currency_config->code,
345
+			'singularLabel' => $this->currency_config->name,
346
+			'pluralLabel' => $this->currency_config->plural,
347
+			'sign' => $this->currency_config->sign,
348
+			'signB4' => $this->currency_config->sign_b4,
349
+			'decimalPlaces' => $this->currency_config->dec_plc,
350
+			'decimalMark' => $this->currency_config->dec_mrk,
351
+			'thousandsSeparator' => $this->currency_config->thsnds,
352
+		);
353
+	}
354
+
355
+
356
+	/**
357
+	 * @since 4.9.62.p
358
+	 * @throws DuplicateCollectionIdentifierException
359
+	 * @throws InvalidDataTypeException
360
+	 * @throws InvalidEntityException
361
+	 */
362
+	private function loadCoreCss()
363
+	{
364
+		if ($this->template_config->enable_default_style && ! is_admin()) {
365
+			$this->addStylesheet(
366
+				CoreAssetManager::CSS_HANDLE_EE_DEFAULT,
367
+				is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')
368
+					? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css'
369
+					: EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css',
370
+				array('dashicons')
371
+			);
372
+			//Load custom style sheet if available
373
+			if ($this->template_config->custom_style_sheet !== null) {
374
+				$this->addStylesheet(
375
+					CoreAssetManager::CSS_HANDLE_EE_CUSTOM,
376
+					EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet,
377
+					array(CoreAssetManager::CSS_HANDLE_EE_DEFAULT)
378
+				);
379
+			}
380
+		}
381
+		$this->addStylesheet(
382
+			CoreAssetManager::CSS_HANDLE_EE_COMPONENTS,
383
+			$this->registry->getCssUrl(
384
+				$this->domain->assetNamespace(),
385
+				'components'
386
+			)
387
+		);
388
+	}
389
+
390
+
391
+	/**
392
+	 * jQuery Validate for form validation
393
+	 *
394
+	 * @since 4.9.62.p
395
+	 * @throws DuplicateCollectionIdentifierException
396
+	 * @throws InvalidDataTypeException
397
+	 * @throws InvalidEntityException
398
+	 */
399
+	private function loadJqueryValidate()
400
+	{
401
+		$this->addJavascript(
402
+			CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE,
403
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js',
404
+			array(CoreAssetManager::JS_HANDLE_JQUERY)
405
+		)
406
+		->setVersion('1.15.0');
407
+
408
+		$this->addJavascript(
409
+			CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE_EXTRA,
410
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js',
411
+			array(CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE)
412
+		)
413
+		->setVersion('1.15.0');
414
+	}
415
+
416
+
417
+	/**
418
+	 * accounting.js for performing client-side calculations
419
+	 *
420
+	 * @since 4.9.62.p
421
+	 * @throws DuplicateCollectionIdentifierException
422
+	 * @throws InvalidDataTypeException
423
+	 * @throws InvalidEntityException
424
+	 */
425
+	private function loadAccountingJs()
426
+	{
427
+		//accounting.js library
428
+		// @link http://josscrowcroft.github.io/accounting.js/
429
+		$this->addJavascript(
430
+			CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE,
431
+			EE_THIRD_PARTY_URL . 'accounting/accounting.js',
432
+			array(CoreAssetManager::JS_HANDLE_UNDERSCORE)
433
+		)
434
+		->setVersion('0.3.2');
435
+
436
+		$this->addJavascript(
437
+			CoreAssetManager::JS_HANDLE_EE_ACCOUNTING,
438
+			EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js',
439
+			array(CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE)
440
+		)
441
+		->setInlineDataCallback(
442
+			function () {
443
+				 wp_localize_script(
444
+					 CoreAssetManager::JS_HANDLE_EE_ACCOUNTING,
445
+					 'EE_ACCOUNTING_CFG',
446
+					 $this->getAccountingSettings()
447
+				 );
448
+			}
449
+		)
450
+		->setVersion();
451
+	}
452
+
453
+
454
+	/**
455
+	 * registers assets for cleaning your ears
456
+	 *
457
+	 * @param JavascriptAsset $script
458
+	 */
459
+	public function loadQtipJs(JavascriptAsset $script)
460
+	{
461
+		// qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook,
462
+		// can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' );
463
+		if (
464
+			$script->handle() === CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE
465
+			&& apply_filters('FHEE_load_qtip', false)
466
+		) {
467
+			EEH_Qtip_Loader::instance()->register_and_enqueue();
468
+		}
469
+	}
470
+
471
+
472
+	/**
473
+	 * assets that are used in the WordPress admin
474
+	 *
475
+	 * @since 4.9.62.p
476
+	 * @throws DuplicateCollectionIdentifierException
477
+	 * @throws InvalidDataTypeException
478
+	 * @throws InvalidEntityException
479
+	 */
480
+	private function registerAdminAssets()
481
+	{
482
+		$this->addJavascript(
483
+			CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE,
484
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'wp-plugins-page'),
485
+			array(
486
+				CoreAssetManager::JS_HANDLE_JQUERY,
487
+				CoreAssetManager::JS_HANDLE_EE_VENDOR,
488
+			)
489
+		)
490
+		->setRequiresTranslation();
491
+
492
+		$this->addStylesheet(
493
+			CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE,
494
+			$this->registry->getCssUrl($this->domain->assetNamespace(), 'wp-plugins-page')
495
+		);
496
+	}
497 497
 }
Please login to merge, or discard this patch.