Completed
Pull Request — Gutenberg/master (#582)
by Darren
13:26
created
core/domain/services/assets/CoreAssetManager.php 2 patches
Indentation   +424 added lines, -424 removed lines patch added patch discarded remove patch
@@ -29,445 +29,445 @@
 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
-                    'currency_config' => $this->getCurrencySettings(),
257
-                )
258
-            );
259
-            /** site formatting values **/
260
-            $this->registry->addData(
261
-                'site_formats',
262
-                array(
263
-                    'date_formats' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats()
264
-                )
265
-            );
266
-        }
267
-
268
-        $this->addJavascript(
269
-            CoreAssetManager::JS_HANDLE_EE_CORE,
270
-            EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
271
-            array(CoreAssetManager::JS_HANDLE_JQUERY)
272
-        )
273
-        ->setInlineDataCallback(
274
-            function () {
275
-                wp_localize_script(
276
-                    CoreAssetManager::JS_HANDLE_EE_CORE,
277
-                    CoreAssetManager::JS_HANDLE_EE_I18N,
278
-                    EE_Registry::$i18n_js_strings
279
-                );
280
-            }
281
-        );
282
-    }
283
-
284
-
285
-    /**
286
-     * Returns configuration data for the accounting-js library.
287
-     * @since $VID:$
288
-     * @return array
289
-     */
290
-    private function getAccountingSettings() {
291
-        return array(
292
-            'currency' => array(
293
-                'symbol'    => $this->currency_config->sign,
294
-                'format'    => array(
295
-                    'pos'  => $this->currency_config->sign_b4 ? '%s%v' : '%v%s',
296
-                    'neg'  => $this->currency_config->sign_b4 ? '- %s%v' : '- %v%s',
297
-                    'zero' => $this->currency_config->sign_b4 ? '%s--' : '--%s',
298
-                ),
299
-                'decimal'   => $this->currency_config->dec_mrk,
300
-                'thousand'  => $this->currency_config->thsnds,
301
-                'precision' => $this->currency_config->dec_plc,
302
-            ),
303
-            'number'   => array(
304
-                'precision' => $this->currency_config->dec_plc,
305
-                'thousand'  => $this->currency_config->thsnds,
306
-                'decimal'   => $this->currency_config->dec_mrk,
307
-            ),
308
-        );
309
-    }
310
-
311
-
312
-    /**
313
-     * Returns configuration data for the js Currency VO.
314
-     * @sinc $VID:$
315
-     * @return array
316
-     */
317
-    private function getCurrencySettings()
318
-    {
319
-        return array(
320
-            'code' => $this->currency_config->code,
321
-            'singularLabel' => $this->currency_config->name,
322
-            'pluralLabel' => $this->currency_config->plural,
323
-            'sign' => $this->currency_config->sign,
324
-            'signB4' => $this->currency_config->sign_b4,
325
-            'decimalPlaces' => $this->currency_config->dec_plc,
326
-            'decimalMark' => $this->currency_config->dec_mrk,
327
-            'thousandsSeparator' => $this->currency_config->thsnds,
328
-        );
329
-    }
330
-
331
-
332
-    /**
333
-     * @since 4.9.62.p
334
-     * @throws DuplicateCollectionIdentifierException
335
-     * @throws InvalidDataTypeException
336
-     * @throws InvalidEntityException
337
-     */
338
-    private function loadCoreCss()
339
-    {
340
-        if ($this->template_config->enable_default_style && ! is_admin()) {
341
-            $this->addStylesheet(
342
-                CoreAssetManager::CSS_HANDLE_EE_DEFAULT,
343
-                is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')
344
-                    ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css'
345
-                    : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css',
346
-                array('dashicons')
347
-            );
348
-            //Load custom style sheet if available
349
-            if ($this->template_config->custom_style_sheet !== null) {
350
-                $this->addStylesheet(
351
-                    CoreAssetManager::CSS_HANDLE_EE_CUSTOM,
352
-                    EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet,
353
-                    array(CoreAssetManager::CSS_HANDLE_EE_DEFAULT)
354
-                );
355
-            }
356
-        }
357
-        $this->addStylesheet(
358
-            CoreAssetManager::CSS_HANDLE_EE_COMPONENTS,
359
-            $this->registry->getCssUrl(
360
-                $this->domain->assetNamespace(),
361
-                'components'
362
-            )
363
-        );
364
-    }
365
-
366
-
367
-    /**
368
-     * jQuery Validate for form validation
369
-     *
370
-     * @since 4.9.62.p
371
-     * @throws DuplicateCollectionIdentifierException
372
-     * @throws InvalidDataTypeException
373
-     * @throws InvalidEntityException
374
-     */
375
-    private function loadJqueryValidate()
376
-    {
377
-        $this->addJavascript(
378
-            CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE,
379
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js',
380
-            array(CoreAssetManager::JS_HANDLE_JQUERY)
381
-        )
382
-        ->setVersion('1.15.0');
383
-
384
-        $this->addJavascript(
385
-            CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE_EXTRA,
386
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js',
387
-            array(CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE)
388
-        )
389
-        ->setVersion('1.15.0');
390
-    }
391
-
392
-
393
-    /**
394
-     * accounting.js for performing client-side calculations
395
-     *
396
-     * @since 4.9.62.p
397
-     * @throws DuplicateCollectionIdentifierException
398
-     * @throws InvalidDataTypeException
399
-     * @throws InvalidEntityException
400
-     */
401
-    private function loadAccountingJs()
402
-    {
403
-        //accounting.js library
404
-        // @link http://josscrowcroft.github.io/accounting.js/
405
-        $this->addJavascript(
406
-            CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE,
407
-            EE_THIRD_PARTY_URL . 'accounting/accounting.js',
408
-            array(CoreAssetManager::JS_HANDLE_UNDERSCORE)
409
-        )
410
-        ->setVersion('0.3.2');
411
-
412
-        $this->addJavascript(
413
-            CoreAssetManager::JS_HANDLE_EE_ACCOUNTING,
414
-            EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js',
415
-            array(CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE)
416
-        )
417
-        ->setInlineDataCallback(
418
-            function () {
419
-                 wp_localize_script(
420
-                     CoreAssetManager::JS_HANDLE_EE_ACCOUNTING,
421
-                     'EE_ACCOUNTING_CFG',
422
-                     $this->getAccountingSettings()
423
-                 );
424
-            }
425
-        )
426
-        ->setVersion();
427
-    }
428
-
429
-
430
-    /**
431
-     * registers assets for cleaning your ears
432
-     *
433
-     * @param JavascriptAsset $script
434
-     */
435
-    public function loadQtipJs(JavascriptAsset $script)
436
-    {
437
-        // qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook,
438
-        // can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' );
439
-        if (
440
-            $script->handle() === CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE
441
-            && apply_filters('FHEE_load_qtip', false)
442
-        ) {
443
-            EEH_Qtip_Loader::instance()->register_and_enqueue();
444
-        }
445
-    }
446
-
447
-
448
-    /**
449
-     * assets that are used in the WordPress admin
450
-     *
451
-     * @since 4.9.62.p
452
-     * @throws DuplicateCollectionIdentifierException
453
-     * @throws InvalidDataTypeException
454
-     * @throws InvalidEntityException
455
-     */
456
-    private function registerAdminAssets()
457
-    {
458
-        $this->addJavascript(
459
-            CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE,
460
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'wp-plugins-page'),
461
-            array(
462
-                CoreAssetManager::JS_HANDLE_JQUERY,
463
-                CoreAssetManager::JS_HANDLE_EE_VENDOR,
464
-            )
465
-        )
466
-        ->setRequiresTranslation();
467
-
468
-        $this->addStylesheet(
469
-            CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE,
470
-            $this->registry->getCssUrl($this->domain->assetNamespace(), 'wp-plugins-page')
471
-        );
472
-    }
255
+					'admin_url' => admin_url('/'),
256
+					'currency_config' => $this->getCurrencySettings(),
257
+				)
258
+			);
259
+			/** site formatting values **/
260
+			$this->registry->addData(
261
+				'site_formats',
262
+				array(
263
+					'date_formats' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats()
264
+				)
265
+			);
266
+		}
267
+
268
+		$this->addJavascript(
269
+			CoreAssetManager::JS_HANDLE_EE_CORE,
270
+			EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
271
+			array(CoreAssetManager::JS_HANDLE_JQUERY)
272
+		)
273
+		->setInlineDataCallback(
274
+			function () {
275
+				wp_localize_script(
276
+					CoreAssetManager::JS_HANDLE_EE_CORE,
277
+					CoreAssetManager::JS_HANDLE_EE_I18N,
278
+					EE_Registry::$i18n_js_strings
279
+				);
280
+			}
281
+		);
282
+	}
283
+
284
+
285
+	/**
286
+	 * Returns configuration data for the accounting-js library.
287
+	 * @since $VID:$
288
+	 * @return array
289
+	 */
290
+	private function getAccountingSettings() {
291
+		return array(
292
+			'currency' => array(
293
+				'symbol'    => $this->currency_config->sign,
294
+				'format'    => array(
295
+					'pos'  => $this->currency_config->sign_b4 ? '%s%v' : '%v%s',
296
+					'neg'  => $this->currency_config->sign_b4 ? '- %s%v' : '- %v%s',
297
+					'zero' => $this->currency_config->sign_b4 ? '%s--' : '--%s',
298
+				),
299
+				'decimal'   => $this->currency_config->dec_mrk,
300
+				'thousand'  => $this->currency_config->thsnds,
301
+				'precision' => $this->currency_config->dec_plc,
302
+			),
303
+			'number'   => array(
304
+				'precision' => $this->currency_config->dec_plc,
305
+				'thousand'  => $this->currency_config->thsnds,
306
+				'decimal'   => $this->currency_config->dec_mrk,
307
+			),
308
+		);
309
+	}
310
+
311
+
312
+	/**
313
+	 * Returns configuration data for the js Currency VO.
314
+	 * @sinc $VID:$
315
+	 * @return array
316
+	 */
317
+	private function getCurrencySettings()
318
+	{
319
+		return array(
320
+			'code' => $this->currency_config->code,
321
+			'singularLabel' => $this->currency_config->name,
322
+			'pluralLabel' => $this->currency_config->plural,
323
+			'sign' => $this->currency_config->sign,
324
+			'signB4' => $this->currency_config->sign_b4,
325
+			'decimalPlaces' => $this->currency_config->dec_plc,
326
+			'decimalMark' => $this->currency_config->dec_mrk,
327
+			'thousandsSeparator' => $this->currency_config->thsnds,
328
+		);
329
+	}
330
+
331
+
332
+	/**
333
+	 * @since 4.9.62.p
334
+	 * @throws DuplicateCollectionIdentifierException
335
+	 * @throws InvalidDataTypeException
336
+	 * @throws InvalidEntityException
337
+	 */
338
+	private function loadCoreCss()
339
+	{
340
+		if ($this->template_config->enable_default_style && ! is_admin()) {
341
+			$this->addStylesheet(
342
+				CoreAssetManager::CSS_HANDLE_EE_DEFAULT,
343
+				is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')
344
+					? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css'
345
+					: EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css',
346
+				array('dashicons')
347
+			);
348
+			//Load custom style sheet if available
349
+			if ($this->template_config->custom_style_sheet !== null) {
350
+				$this->addStylesheet(
351
+					CoreAssetManager::CSS_HANDLE_EE_CUSTOM,
352
+					EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet,
353
+					array(CoreAssetManager::CSS_HANDLE_EE_DEFAULT)
354
+				);
355
+			}
356
+		}
357
+		$this->addStylesheet(
358
+			CoreAssetManager::CSS_HANDLE_EE_COMPONENTS,
359
+			$this->registry->getCssUrl(
360
+				$this->domain->assetNamespace(),
361
+				'components'
362
+			)
363
+		);
364
+	}
365
+
366
+
367
+	/**
368
+	 * jQuery Validate for form validation
369
+	 *
370
+	 * @since 4.9.62.p
371
+	 * @throws DuplicateCollectionIdentifierException
372
+	 * @throws InvalidDataTypeException
373
+	 * @throws InvalidEntityException
374
+	 */
375
+	private function loadJqueryValidate()
376
+	{
377
+		$this->addJavascript(
378
+			CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE,
379
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js',
380
+			array(CoreAssetManager::JS_HANDLE_JQUERY)
381
+		)
382
+		->setVersion('1.15.0');
383
+
384
+		$this->addJavascript(
385
+			CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE_EXTRA,
386
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js',
387
+			array(CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE)
388
+		)
389
+		->setVersion('1.15.0');
390
+	}
391
+
392
+
393
+	/**
394
+	 * accounting.js for performing client-side calculations
395
+	 *
396
+	 * @since 4.9.62.p
397
+	 * @throws DuplicateCollectionIdentifierException
398
+	 * @throws InvalidDataTypeException
399
+	 * @throws InvalidEntityException
400
+	 */
401
+	private function loadAccountingJs()
402
+	{
403
+		//accounting.js library
404
+		// @link http://josscrowcroft.github.io/accounting.js/
405
+		$this->addJavascript(
406
+			CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE,
407
+			EE_THIRD_PARTY_URL . 'accounting/accounting.js',
408
+			array(CoreAssetManager::JS_HANDLE_UNDERSCORE)
409
+		)
410
+		->setVersion('0.3.2');
411
+
412
+		$this->addJavascript(
413
+			CoreAssetManager::JS_HANDLE_EE_ACCOUNTING,
414
+			EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js',
415
+			array(CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE)
416
+		)
417
+		->setInlineDataCallback(
418
+			function () {
419
+				 wp_localize_script(
420
+					 CoreAssetManager::JS_HANDLE_EE_ACCOUNTING,
421
+					 'EE_ACCOUNTING_CFG',
422
+					 $this->getAccountingSettings()
423
+				 );
424
+			}
425
+		)
426
+		->setVersion();
427
+	}
428
+
429
+
430
+	/**
431
+	 * registers assets for cleaning your ears
432
+	 *
433
+	 * @param JavascriptAsset $script
434
+	 */
435
+	public function loadQtipJs(JavascriptAsset $script)
436
+	{
437
+		// qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook,
438
+		// can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' );
439
+		if (
440
+			$script->handle() === CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE
441
+			&& apply_filters('FHEE_load_qtip', false)
442
+		) {
443
+			EEH_Qtip_Loader::instance()->register_and_enqueue();
444
+		}
445
+	}
446
+
447
+
448
+	/**
449
+	 * assets that are used in the WordPress admin
450
+	 *
451
+	 * @since 4.9.62.p
452
+	 * @throws DuplicateCollectionIdentifierException
453
+	 * @throws InvalidDataTypeException
454
+	 * @throws InvalidEntityException
455
+	 */
456
+	private function registerAdminAssets()
457
+	{
458
+		$this->addJavascript(
459
+			CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE,
460
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'wp-plugins-page'),
461
+			array(
462
+				CoreAssetManager::JS_HANDLE_JQUERY,
463
+				CoreAssetManager::JS_HANDLE_EE_VENDOR,
464
+			)
465
+		)
466
+		->setRequiresTranslation();
467
+
468
+		$this->addStylesheet(
469
+			CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE,
470
+			$this->registry->getCssUrl($this->domain->assetNamespace(), 'wp-plugins-page')
471
+		);
472
+	}
473 473
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
             //js.api
239 239
             $this->addJavascript(
240 240
                 CoreAssetManager::JS_HANDLE_EE_JS_API,
241
-                EE_LIBRARIES_URL . 'rest_api/assets/js/eejs-api.min.js',
241
+                EE_LIBRARIES_URL.'rest_api/assets/js/eejs-api.min.js',
242 242
                 array(
243 243
                     CoreAssetManager::JS_HANDLE_UNDERSCORE,
244 244
                     CoreAssetManager::JS_HANDLE_EE_JS_CORE
@@ -267,11 +267,11 @@  discard block
 block discarded – undo
267 267
 
268 268
         $this->addJavascript(
269 269
             CoreAssetManager::JS_HANDLE_EE_CORE,
270
-            EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
270
+            EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js',
271 271
             array(CoreAssetManager::JS_HANDLE_JQUERY)
272 272
         )
273 273
         ->setInlineDataCallback(
274
-            function () {
274
+            function() {
275 275
                 wp_localize_script(
276 276
                     CoreAssetManager::JS_HANDLE_EE_CORE,
277 277
                     CoreAssetManager::JS_HANDLE_EE_I18N,
@@ -340,16 +340,16 @@  discard block
 block discarded – undo
340 340
         if ($this->template_config->enable_default_style && ! is_admin()) {
341 341
             $this->addStylesheet(
342 342
                 CoreAssetManager::CSS_HANDLE_EE_DEFAULT,
343
-                is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')
343
+                is_readable(EVENT_ESPRESSO_UPLOAD_DIR.'css/style.css')
344 344
                     ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css'
345
-                    : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css',
345
+                    : EE_GLOBAL_ASSETS_URL.'css/espresso_default.css',
346 346
                 array('dashicons')
347 347
             );
348 348
             //Load custom style sheet if available
349 349
             if ($this->template_config->custom_style_sheet !== null) {
350 350
                 $this->addStylesheet(
351 351
                     CoreAssetManager::CSS_HANDLE_EE_CUSTOM,
352
-                    EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet,
352
+                    EVENT_ESPRESSO_UPLOAD_URL.'css/'.$this->template_config->custom_style_sheet,
353 353
                     array(CoreAssetManager::CSS_HANDLE_EE_DEFAULT)
354 354
                 );
355 355
             }
@@ -376,14 +376,14 @@  discard block
 block discarded – undo
376 376
     {
377 377
         $this->addJavascript(
378 378
             CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE,
379
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js',
379
+            EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.min.js',
380 380
             array(CoreAssetManager::JS_HANDLE_JQUERY)
381 381
         )
382 382
         ->setVersion('1.15.0');
383 383
 
384 384
         $this->addJavascript(
385 385
             CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE_EXTRA,
386
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js',
386
+            EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.additional-methods.min.js',
387 387
             array(CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE)
388 388
         )
389 389
         ->setVersion('1.15.0');
@@ -404,18 +404,18 @@  discard block
 block discarded – undo
404 404
         // @link http://josscrowcroft.github.io/accounting.js/
405 405
         $this->addJavascript(
406 406
             CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE,
407
-            EE_THIRD_PARTY_URL . 'accounting/accounting.js',
407
+            EE_THIRD_PARTY_URL.'accounting/accounting.js',
408 408
             array(CoreAssetManager::JS_HANDLE_UNDERSCORE)
409 409
         )
410 410
         ->setVersion('0.3.2');
411 411
 
412 412
         $this->addJavascript(
413 413
             CoreAssetManager::JS_HANDLE_EE_ACCOUNTING,
414
-            EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js',
414
+            EE_GLOBAL_ASSETS_URL.'scripts/ee-accounting-config.js',
415 415
             array(CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE)
416 416
         )
417 417
         ->setInlineDataCallback(
418
-            function () {
418
+            function() {
419 419
                  wp_localize_script(
420 420
                      CoreAssetManager::JS_HANDLE_EE_ACCOUNTING,
421 421
                      'EE_ACCOUNTING_CFG',
Please login to merge, or discard this patch.