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