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