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