Completed
Pull Request — Gutenberg/master (#668)
by Darren
28:21 queued 13:43
created
core/domain/services/assets/CoreAssetManager.php 1 patch
Indentation   +437 added lines, -437 removed lines patch added patch discarded remove patch
@@ -29,458 +29,458 @@
 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_DATA_STORES,
189
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'data-stores'),
190
-            array(CoreAssetManager::JS_HANDLE_EE_VENDOR, 'wp-data', 'wp-api-request')
191
-        )
192
-        ->setRequiresTranslation();
193
-
194
-        $this->addJavascript(
195
-            CoreAssetManager::JS_HANDLE_EE_HELPERS,
196
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'helpers')
197
-        )->setRequiresTranslation();
198
-
199
-        $this->addJavascript(
200
-            CoreAssetManager::JS_HANDLE_EE_MODEL,
201
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'model'),
202
-            array(
203
-                CoreAssetManager::JS_HANDLE_EE_HELPERS
204
-            )
205
-        )->setRequiresTranslation();
206
-
207
-        $this->addJavascript(
208
-            CoreAssetManager::JS_HANDLE_EE_VALUE_OBJECTS,
209
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'valueObjects'),
210
-            array(
211
-                CoreAssetManager::JS_HANDLE_EE_MODEL
212
-            )
213
-        )->setRequiresTranslation();
214
-
215
-        $this->addJavascript(
216
-            CoreAssetManager::JS_HANDLE_EE_HOC_COMPONENTS,
217
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'hocComponents'),
218
-            array(
219
-                CoreAssetManager::JS_HANDLE_EE_DATA_STORES,
220
-                CoreAssetManager::JS_HANDLE_EE_VALUE_OBJECTS,
221
-                'wp-components',
222
-            )
223
-        )->setRequiresTranslation();
224
-
225
-        $this->addJavascript(
226
-            CoreAssetManager::JS_HANDLE_EE_COMPONENTS,
227
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'components'),
228
-            array(
229
-                CoreAssetManager::JS_HANDLE_EE_DATA_STORES,
230
-                CoreAssetManager::JS_HANDLE_EE_VALUE_OBJECTS,
231
-                'wp-components',
232
-            )
233
-        )
234
-        ->setRequiresTranslation();
235
-
236
-        global $wp_version;
237
-        if (version_compare($wp_version, '4.4.0', '>')) {
238
-            //js.api
239
-            $this->addJavascript(
240
-                CoreAssetManager::JS_HANDLE_EE_JS_API,
241
-                EE_LIBRARIES_URL . 'rest_api/assets/js/eejs-api.min.js',
242
-                array(
243
-                    CoreAssetManager::JS_HANDLE_UNDERSCORE,
244
-                    CoreAssetManager::JS_HANDLE_EE_JS_CORE
245
-                )
246
-            );
247
-            $this->registry->addData('eejs_api_nonce', wp_create_nonce('wp_rest'));
248
-            $this->registry->addData(
249
-                'paths',
250
-                array(
251
-                    'rest_route' => rest_url('ee/v4.8.36/'),
252
-                    'collection_endpoints' => EED_Core_Rest_Api::getCollectionRoutesIndexedByModelName(),
253
-                    '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_DATA_STORES,
189
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'data-stores'),
190
+			array(CoreAssetManager::JS_HANDLE_EE_VENDOR, 'wp-data', 'wp-api-request')
191
+		)
192
+		->setRequiresTranslation();
193
+
194
+		$this->addJavascript(
195
+			CoreAssetManager::JS_HANDLE_EE_HELPERS,
196
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'helpers')
197
+		)->setRequiresTranslation();
198
+
199
+		$this->addJavascript(
200
+			CoreAssetManager::JS_HANDLE_EE_MODEL,
201
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'model'),
202
+			array(
203
+				CoreAssetManager::JS_HANDLE_EE_HELPERS
204
+			)
205
+		)->setRequiresTranslation();
206
+
207
+		$this->addJavascript(
208
+			CoreAssetManager::JS_HANDLE_EE_VALUE_OBJECTS,
209
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'valueObjects'),
210
+			array(
211
+				CoreAssetManager::JS_HANDLE_EE_MODEL
212
+			)
213
+		)->setRequiresTranslation();
214
+
215
+		$this->addJavascript(
216
+			CoreAssetManager::JS_HANDLE_EE_HOC_COMPONENTS,
217
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'hocComponents'),
218
+			array(
219
+				CoreAssetManager::JS_HANDLE_EE_DATA_STORES,
220
+				CoreAssetManager::JS_HANDLE_EE_VALUE_OBJECTS,
221
+				'wp-components',
222
+			)
223
+		)->setRequiresTranslation();
224
+
225
+		$this->addJavascript(
226
+			CoreAssetManager::JS_HANDLE_EE_COMPONENTS,
227
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'components'),
228
+			array(
229
+				CoreAssetManager::JS_HANDLE_EE_DATA_STORES,
230
+				CoreAssetManager::JS_HANDLE_EE_VALUE_OBJECTS,
231
+				'wp-components',
232
+			)
233
+		)
234
+		->setRequiresTranslation();
235
+
236
+		global $wp_version;
237
+		if (version_compare($wp_version, '4.4.0', '>')) {
238
+			//js.api
239
+			$this->addJavascript(
240
+				CoreAssetManager::JS_HANDLE_EE_JS_API,
241
+				EE_LIBRARIES_URL . 'rest_api/assets/js/eejs-api.min.js',
242
+				array(
243
+					CoreAssetManager::JS_HANDLE_UNDERSCORE,
244
+					CoreAssetManager::JS_HANDLE_EE_JS_CORE
245
+				)
246
+			);
247
+			$this->registry->addData('eejs_api_nonce', wp_create_nonce('wp_rest'));
248
+			$this->registry->addData(
249
+				'paths',
250
+				array(
251
+					'rest_route' => rest_url('ee/v4.8.36/'),
252
+					'collection_endpoints' => EED_Core_Rest_Api::getCollectionRoutesIndexedByModelName(),
253
+					'primary_keys' => EED_Core_Rest_Api::getPrimaryKeyNamesIndexedByModelName(),
254 254
 					'site_url' => site_url('/'),
255
-                    'admin_url' => admin_url('/'),
256
-                )
257
-            );
258
-            /** site formatting values **/
259
-            $this->registry->addData(
260
-                'site_formats',
261
-                array(
262
-                    'date_formats' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats()
263
-                )
264
-            );
265
-            /** currency data **/
266
-            $this->registry->addData(
267
-                'currency_config',
268
-                $this->getCurrencySettings()
269
-            );
270
-            /** site timezone */
271
-            $this->registry->addData(
272
-                'default_timezone',
273
-                array(
274
-                    'pretty' => EEH_DTT_Helper::get_timezone_string_for_display(),
275
-                    'string' => get_option('timezone_string'),
276
-                    'offset' => EEH_DTT_Helper::get_site_timezone_gmt_offset(),
277
-                )
278
-            );
279
-        }
280
-
281
-        $this->addJavascript(
282
-            CoreAssetManager::JS_HANDLE_EE_CORE,
283
-            EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
284
-            array(CoreAssetManager::JS_HANDLE_JQUERY)
285
-        )
286
-        ->setInlineDataCallback(
287
-            function () {
288
-                wp_localize_script(
289
-                    CoreAssetManager::JS_HANDLE_EE_CORE,
290
-                    CoreAssetManager::JS_HANDLE_EE_I18N,
291
-                    EE_Registry::$i18n_js_strings
292
-                );
293
-            }
294
-        );
295
-    }
296
-
297
-
298
-    /**
299
-     * Returns configuration data for the accounting-js library.
300
-     * @since $VID:$
301
-     * @return array
302
-     */
303
-    private function getAccountingSettings() {
304
-        return array(
305
-            'currency' => array(
306
-                'symbol'    => $this->currency_config->sign,
307
-                'format'    => array(
308
-                    'pos'  => $this->currency_config->sign_b4 ? '%s%v' : '%v%s',
309
-                    'neg'  => $this->currency_config->sign_b4 ? '- %s%v' : '- %v%s',
310
-                    'zero' => $this->currency_config->sign_b4 ? '%s--' : '--%s',
311
-                ),
312
-                'decimal'   => $this->currency_config->dec_mrk,
313
-                'thousand'  => $this->currency_config->thsnds,
314
-                'precision' => $this->currency_config->dec_plc,
315
-            ),
316
-            'number'   => array(
317
-                'precision' => $this->currency_config->dec_plc,
318
-                'thousand'  => $this->currency_config->thsnds,
319
-                'decimal'   => $this->currency_config->dec_mrk,
320
-            ),
321
-        );
322
-    }
323
-
324
-
325
-    /**
326
-     * Returns configuration data for the js Currency VO.
327
-     * @sinc $VID:$
328
-     * @return array
329
-     */
330
-    private function getCurrencySettings()
331
-    {
332
-        return array(
333
-            'code' => $this->currency_config->code,
334
-            'singularLabel' => $this->currency_config->name,
335
-            'pluralLabel' => $this->currency_config->plural,
336
-            'sign' => $this->currency_config->sign,
337
-            'signB4' => $this->currency_config->sign_b4,
338
-            'decimalPlaces' => $this->currency_config->dec_plc,
339
-            'decimalMark' => $this->currency_config->dec_mrk,
340
-            'thousandsSeparator' => $this->currency_config->thsnds,
341
-        );
342
-    }
343
-
344
-
345
-    /**
346
-     * @since 4.9.62.p
347
-     * @throws DuplicateCollectionIdentifierException
348
-     * @throws InvalidDataTypeException
349
-     * @throws InvalidEntityException
350
-     */
351
-    private function loadCoreCss()
352
-    {
353
-        if ($this->template_config->enable_default_style && ! is_admin()) {
354
-            $this->addStylesheet(
355
-                CoreAssetManager::CSS_HANDLE_EE_DEFAULT,
356
-                is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')
357
-                    ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css'
358
-                    : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css',
359
-                array('dashicons')
360
-            );
361
-            //Load custom style sheet if available
362
-            if ($this->template_config->custom_style_sheet !== null) {
363
-                $this->addStylesheet(
364
-                    CoreAssetManager::CSS_HANDLE_EE_CUSTOM,
365
-                    EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet,
366
-                    array(CoreAssetManager::CSS_HANDLE_EE_DEFAULT)
367
-                );
368
-            }
369
-        }
370
-        $this->addStylesheet(
371
-            CoreAssetManager::CSS_HANDLE_EE_COMPONENTS,
372
-            $this->registry->getCssUrl(
373
-                $this->domain->assetNamespace(),
374
-                'components'
375
-            )
376
-        );
377
-    }
378
-
379
-
380
-    /**
381
-     * jQuery Validate for form validation
382
-     *
383
-     * @since 4.9.62.p
384
-     * @throws DuplicateCollectionIdentifierException
385
-     * @throws InvalidDataTypeException
386
-     * @throws InvalidEntityException
387
-     */
388
-    private function loadJqueryValidate()
389
-    {
390
-        $this->addJavascript(
391
-            CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE,
392
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js',
393
-            array(CoreAssetManager::JS_HANDLE_JQUERY)
394
-        )
395
-        ->setVersion('1.15.0');
396
-
397
-        $this->addJavascript(
398
-            CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE_EXTRA,
399
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js',
400
-            array(CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE)
401
-        )
402
-        ->setVersion('1.15.0');
403
-    }
404
-
405
-
406
-    /**
407
-     * accounting.js for performing client-side calculations
408
-     *
409
-     * @since 4.9.62.p
410
-     * @throws DuplicateCollectionIdentifierException
411
-     * @throws InvalidDataTypeException
412
-     * @throws InvalidEntityException
413
-     */
414
-    private function loadAccountingJs()
415
-    {
416
-        //accounting.js library
417
-        // @link http://josscrowcroft.github.io/accounting.js/
418
-        $this->addJavascript(
419
-            CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE,
420
-            EE_THIRD_PARTY_URL . 'accounting/accounting.js',
421
-            array(CoreAssetManager::JS_HANDLE_UNDERSCORE)
422
-        )
423
-        ->setVersion('0.3.2');
424
-
425
-        $this->addJavascript(
426
-            CoreAssetManager::JS_HANDLE_EE_ACCOUNTING,
427
-            EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js',
428
-            array(CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE)
429
-        )
430
-        ->setInlineDataCallback(
431
-            function () {
432
-                 wp_localize_script(
433
-                     CoreAssetManager::JS_HANDLE_EE_ACCOUNTING,
434
-                     'EE_ACCOUNTING_CFG',
435
-                     $this->getAccountingSettings()
436
-                 );
437
-            }
438
-        )
439
-        ->setVersion();
440
-    }
441
-
442
-
443
-    /**
444
-     * registers assets for cleaning your ears
445
-     *
446
-     * @param JavascriptAsset $script
447
-     */
448
-    public function loadQtipJs(JavascriptAsset $script)
449
-    {
450
-        // qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook,
451
-        // can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' );
452
-        if (
453
-            $script->handle() === CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE
454
-            && apply_filters('FHEE_load_qtip', false)
455
-        ) {
456
-            EEH_Qtip_Loader::instance()->register_and_enqueue();
457
-        }
458
-    }
459
-
460
-
461
-    /**
462
-     * assets that are used in the WordPress admin
463
-     *
464
-     * @since 4.9.62.p
465
-     * @throws DuplicateCollectionIdentifierException
466
-     * @throws InvalidDataTypeException
467
-     * @throws InvalidEntityException
468
-     */
469
-    private function registerAdminAssets()
470
-    {
471
-        $this->addJavascript(
472
-            CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE,
473
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'wp-plugins-page'),
474
-            array(
475
-                CoreAssetManager::JS_HANDLE_JQUERY,
476
-                CoreAssetManager::JS_HANDLE_EE_VENDOR,
477
-            )
478
-        )
479
-        ->setRequiresTranslation();
480
-
481
-        $this->addStylesheet(
482
-            CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE,
483
-            $this->registry->getCssUrl($this->domain->assetNamespace(), 'wp-plugins-page')
484
-        );
485
-    }
255
+					'admin_url' => admin_url('/'),
256
+				)
257
+			);
258
+			/** site formatting values **/
259
+			$this->registry->addData(
260
+				'site_formats',
261
+				array(
262
+					'date_formats' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats()
263
+				)
264
+			);
265
+			/** currency data **/
266
+			$this->registry->addData(
267
+				'currency_config',
268
+				$this->getCurrencySettings()
269
+			);
270
+			/** site timezone */
271
+			$this->registry->addData(
272
+				'default_timezone',
273
+				array(
274
+					'pretty' => EEH_DTT_Helper::get_timezone_string_for_display(),
275
+					'string' => get_option('timezone_string'),
276
+					'offset' => EEH_DTT_Helper::get_site_timezone_gmt_offset(),
277
+				)
278
+			);
279
+		}
280
+
281
+		$this->addJavascript(
282
+			CoreAssetManager::JS_HANDLE_EE_CORE,
283
+			EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
284
+			array(CoreAssetManager::JS_HANDLE_JQUERY)
285
+		)
286
+		->setInlineDataCallback(
287
+			function () {
288
+				wp_localize_script(
289
+					CoreAssetManager::JS_HANDLE_EE_CORE,
290
+					CoreAssetManager::JS_HANDLE_EE_I18N,
291
+					EE_Registry::$i18n_js_strings
292
+				);
293
+			}
294
+		);
295
+	}
296
+
297
+
298
+	/**
299
+	 * Returns configuration data for the accounting-js library.
300
+	 * @since $VID:$
301
+	 * @return array
302
+	 */
303
+	private function getAccountingSettings() {
304
+		return array(
305
+			'currency' => array(
306
+				'symbol'    => $this->currency_config->sign,
307
+				'format'    => array(
308
+					'pos'  => $this->currency_config->sign_b4 ? '%s%v' : '%v%s',
309
+					'neg'  => $this->currency_config->sign_b4 ? '- %s%v' : '- %v%s',
310
+					'zero' => $this->currency_config->sign_b4 ? '%s--' : '--%s',
311
+				),
312
+				'decimal'   => $this->currency_config->dec_mrk,
313
+				'thousand'  => $this->currency_config->thsnds,
314
+				'precision' => $this->currency_config->dec_plc,
315
+			),
316
+			'number'   => array(
317
+				'precision' => $this->currency_config->dec_plc,
318
+				'thousand'  => $this->currency_config->thsnds,
319
+				'decimal'   => $this->currency_config->dec_mrk,
320
+			),
321
+		);
322
+	}
323
+
324
+
325
+	/**
326
+	 * Returns configuration data for the js Currency VO.
327
+	 * @sinc $VID:$
328
+	 * @return array
329
+	 */
330
+	private function getCurrencySettings()
331
+	{
332
+		return array(
333
+			'code' => $this->currency_config->code,
334
+			'singularLabel' => $this->currency_config->name,
335
+			'pluralLabel' => $this->currency_config->plural,
336
+			'sign' => $this->currency_config->sign,
337
+			'signB4' => $this->currency_config->sign_b4,
338
+			'decimalPlaces' => $this->currency_config->dec_plc,
339
+			'decimalMark' => $this->currency_config->dec_mrk,
340
+			'thousandsSeparator' => $this->currency_config->thsnds,
341
+		);
342
+	}
343
+
344
+
345
+	/**
346
+	 * @since 4.9.62.p
347
+	 * @throws DuplicateCollectionIdentifierException
348
+	 * @throws InvalidDataTypeException
349
+	 * @throws InvalidEntityException
350
+	 */
351
+	private function loadCoreCss()
352
+	{
353
+		if ($this->template_config->enable_default_style && ! is_admin()) {
354
+			$this->addStylesheet(
355
+				CoreAssetManager::CSS_HANDLE_EE_DEFAULT,
356
+				is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')
357
+					? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css'
358
+					: EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css',
359
+				array('dashicons')
360
+			);
361
+			//Load custom style sheet if available
362
+			if ($this->template_config->custom_style_sheet !== null) {
363
+				$this->addStylesheet(
364
+					CoreAssetManager::CSS_HANDLE_EE_CUSTOM,
365
+					EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet,
366
+					array(CoreAssetManager::CSS_HANDLE_EE_DEFAULT)
367
+				);
368
+			}
369
+		}
370
+		$this->addStylesheet(
371
+			CoreAssetManager::CSS_HANDLE_EE_COMPONENTS,
372
+			$this->registry->getCssUrl(
373
+				$this->domain->assetNamespace(),
374
+				'components'
375
+			)
376
+		);
377
+	}
378
+
379
+
380
+	/**
381
+	 * jQuery Validate for form validation
382
+	 *
383
+	 * @since 4.9.62.p
384
+	 * @throws DuplicateCollectionIdentifierException
385
+	 * @throws InvalidDataTypeException
386
+	 * @throws InvalidEntityException
387
+	 */
388
+	private function loadJqueryValidate()
389
+	{
390
+		$this->addJavascript(
391
+			CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE,
392
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js',
393
+			array(CoreAssetManager::JS_HANDLE_JQUERY)
394
+		)
395
+		->setVersion('1.15.0');
396
+
397
+		$this->addJavascript(
398
+			CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE_EXTRA,
399
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js',
400
+			array(CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE)
401
+		)
402
+		->setVersion('1.15.0');
403
+	}
404
+
405
+
406
+	/**
407
+	 * accounting.js for performing client-side calculations
408
+	 *
409
+	 * @since 4.9.62.p
410
+	 * @throws DuplicateCollectionIdentifierException
411
+	 * @throws InvalidDataTypeException
412
+	 * @throws InvalidEntityException
413
+	 */
414
+	private function loadAccountingJs()
415
+	{
416
+		//accounting.js library
417
+		// @link http://josscrowcroft.github.io/accounting.js/
418
+		$this->addJavascript(
419
+			CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE,
420
+			EE_THIRD_PARTY_URL . 'accounting/accounting.js',
421
+			array(CoreAssetManager::JS_HANDLE_UNDERSCORE)
422
+		)
423
+		->setVersion('0.3.2');
424
+
425
+		$this->addJavascript(
426
+			CoreAssetManager::JS_HANDLE_EE_ACCOUNTING,
427
+			EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js',
428
+			array(CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE)
429
+		)
430
+		->setInlineDataCallback(
431
+			function () {
432
+				 wp_localize_script(
433
+					 CoreAssetManager::JS_HANDLE_EE_ACCOUNTING,
434
+					 'EE_ACCOUNTING_CFG',
435
+					 $this->getAccountingSettings()
436
+				 );
437
+			}
438
+		)
439
+		->setVersion();
440
+	}
441
+
442
+
443
+	/**
444
+	 * registers assets for cleaning your ears
445
+	 *
446
+	 * @param JavascriptAsset $script
447
+	 */
448
+	public function loadQtipJs(JavascriptAsset $script)
449
+	{
450
+		// qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook,
451
+		// can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' );
452
+		if (
453
+			$script->handle() === CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE
454
+			&& apply_filters('FHEE_load_qtip', false)
455
+		) {
456
+			EEH_Qtip_Loader::instance()->register_and_enqueue();
457
+		}
458
+	}
459
+
460
+
461
+	/**
462
+	 * assets that are used in the WordPress admin
463
+	 *
464
+	 * @since 4.9.62.p
465
+	 * @throws DuplicateCollectionIdentifierException
466
+	 * @throws InvalidDataTypeException
467
+	 * @throws InvalidEntityException
468
+	 */
469
+	private function registerAdminAssets()
470
+	{
471
+		$this->addJavascript(
472
+			CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE,
473
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'wp-plugins-page'),
474
+			array(
475
+				CoreAssetManager::JS_HANDLE_JQUERY,
476
+				CoreAssetManager::JS_HANDLE_EE_VENDOR,
477
+			)
478
+		)
479
+		->setRequiresTranslation();
480
+
481
+		$this->addStylesheet(
482
+			CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE,
483
+			$this->registry->getCssUrl($this->domain->assetNamespace(), 'wp-plugins-page')
484
+		);
485
+	}
486 486
 }
Please login to merge, or discard this patch.