Completed
Pull Request — master (#331)
by Darren
33:16 queued 13:16
created
core/domain/services/assets/CoreAssetManager.php 1 patch
Indentation   +380 added lines, -380 removed lines patch added patch discarded remove patch
@@ -29,396 +29,396 @@
 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
-                'wp-components',
210
-            )
211
-        )->setRequiresTranslation();
212
-
213
-        $this->addJavascript(
214
-            CoreAssetManager::JS_HANDLE_EE_COMPONENTS,
215
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'components'),
216
-            array(
217
-                CoreAssetManager::JS_HANDLE_EE_DATA_STORES,
218
-                CoreAssetManager::JS_HANDLE_EE_HELPERS,
219
-                'wp-components',
220
-            )
221
-        )
222
-        ->setRequiresTranslation();
223
-
224
-        global $wp_version;
225
-        if (version_compare($wp_version, '4.4.0', '>')) {
226
-            //js.api
227
-            $this->addJavascript(
228
-                CoreAssetManager::JS_HANDLE_EE_JS_API,
229
-                EE_LIBRARIES_URL . 'rest_api/assets/js/eejs-api.min.js',
230
-                array(
231
-                    CoreAssetManager::JS_HANDLE_UNDERSCORE,
232
-                    CoreAssetManager::JS_HANDLE_EE_JS_CORE
233
-                )
234
-            );
235
-            $this->registry->addData('eejs_api_nonce', wp_create_nonce('wp_rest'));
236
-            $this->registry->addData(
237
-                'paths',
238
-                array(
239
-                    'rest_route' => rest_url('ee/v4.8.36/'),
240
-                    'collection_endpoints' => EED_Core_Rest_Api::getCollectionRoutesIndexedByModelName(),
241
-                    '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
+				'wp-components',
210
+			)
211
+		)->setRequiresTranslation();
212
+
213
+		$this->addJavascript(
214
+			CoreAssetManager::JS_HANDLE_EE_COMPONENTS,
215
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'components'),
216
+			array(
217
+				CoreAssetManager::JS_HANDLE_EE_DATA_STORES,
218
+				CoreAssetManager::JS_HANDLE_EE_HELPERS,
219
+				'wp-components',
220
+			)
221
+		)
222
+		->setRequiresTranslation();
223
+
224
+		global $wp_version;
225
+		if (version_compare($wp_version, '4.4.0', '>')) {
226
+			//js.api
227
+			$this->addJavascript(
228
+				CoreAssetManager::JS_HANDLE_EE_JS_API,
229
+				EE_LIBRARIES_URL . 'rest_api/assets/js/eejs-api.min.js',
230
+				array(
231
+					CoreAssetManager::JS_HANDLE_UNDERSCORE,
232
+					CoreAssetManager::JS_HANDLE_EE_JS_CORE
233
+				)
234
+			);
235
+			$this->registry->addData('eejs_api_nonce', wp_create_nonce('wp_rest'));
236
+			$this->registry->addData(
237
+				'paths',
238
+				array(
239
+					'rest_route' => rest_url('ee/v4.8.36/'),
240
+					'collection_endpoints' => EED_Core_Rest_Api::getCollectionRoutesIndexedByModelName(),
241
+					'primary_keys' => EED_Core_Rest_Api::getPrimaryKeyNamesIndexedByModelName(),
242 242
 					'site_url' => site_url('/'),
243
-                    'admin_url' => admin_url('/'),
244
-                )
245
-            );
246
-            /** site formatting values **/
247
-            $this->registry->addData(
248
-                'site_formats',
249
-                array(
250
-                    'date_formats' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats()
251
-                )
252
-            );
253
-        }
254
-
255
-        $this->addJavascript(
256
-            CoreAssetManager::JS_HANDLE_EE_CORE,
257
-            EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
258
-            array(CoreAssetManager::JS_HANDLE_JQUERY)
259
-        )
260
-        ->setInlineDataCallback(
261
-            function () {
262
-                wp_localize_script(
263
-                    CoreAssetManager::JS_HANDLE_EE_CORE,
264
-                    CoreAssetManager::JS_HANDLE_EE_I18N,
265
-                    EE_Registry::$i18n_js_strings
266
-                );
267
-            }
268
-        );
269
-    }
270
-
271
-
272
-    /**
273
-     * @since 4.9.62.p
274
-     * @throws DuplicateCollectionIdentifierException
275
-     * @throws InvalidDataTypeException
276
-     * @throws InvalidEntityException
277
-     */
278
-    private function loadCoreCss()
279
-    {
280
-        if ($this->template_config->enable_default_style && ! is_admin()) {
281
-            $this->addStylesheet(
282
-                CoreAssetManager::CSS_HANDLE_EE_DEFAULT,
283
-                is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')
284
-                    ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css'
285
-                    : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css',
286
-                array('dashicons')
287
-            );
288
-            //Load custom style sheet if available
289
-            if ($this->template_config->custom_style_sheet !== null) {
290
-                $this->addStylesheet(
291
-                    CoreAssetManager::CSS_HANDLE_EE_CUSTOM,
292
-                    EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet,
293
-                    array(CoreAssetManager::CSS_HANDLE_EE_DEFAULT)
294
-                );
295
-            }
296
-        }
297
-    }
298
-
299
-
300
-    /**
301
-     * jQuery Validate for form validation
302
-     *
303
-     * @since 4.9.62.p
304
-     * @throws DuplicateCollectionIdentifierException
305
-     * @throws InvalidDataTypeException
306
-     * @throws InvalidEntityException
307
-     */
308
-    private function loadJqueryValidate()
309
-    {
310
-        $this->addJavascript(
311
-            CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE,
312
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js',
313
-            array(CoreAssetManager::JS_HANDLE_JQUERY)
314
-        )
315
-        ->setVersion('1.15.0');
316
-
317
-        $this->addJavascript(
318
-            CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE_EXTRA,
319
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js',
320
-            array(CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE)
321
-        )
322
-        ->setVersion('1.15.0');
323
-    }
324
-
325
-
326
-    /**
327
-     * accounting.js for performing client-side calculations
328
-     *
329
-     * @since 4.9.62.p
330
-     * @throws DuplicateCollectionIdentifierException
331
-     * @throws InvalidDataTypeException
332
-     * @throws InvalidEntityException
333
-     */
334
-    private function loadAccountingJs()
335
-    {
336
-        //accounting.js library
337
-        // @link http://josscrowcroft.github.io/accounting.js/
338
-        $this->addJavascript(
339
-            CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE,
340
-            EE_THIRD_PARTY_URL . 'accounting/accounting.js',
341
-            array(CoreAssetManager::JS_HANDLE_UNDERSCORE)
342
-        )
343
-        ->setVersion('0.3.2');
344
-
345
-        $currency_config = $this->currency_config;
346
-        $this->addJavascript(
347
-            CoreAssetManager::JS_HANDLE_EE_ACCOUNTING,
348
-            EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js',
349
-            array(CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE)
350
-        )
351
-        ->setInlineDataCallback(
352
-            function () use ($currency_config) {
353
-                 wp_localize_script(
354
-                     CoreAssetManager::JS_HANDLE_EE_ACCOUNTING,
355
-                     'EE_ACCOUNTING_CFG',
356
-                     array(
357
-                         'currency' => array(
358
-                             'symbol'    => $currency_config->sign,
359
-                             'format'    => array(
360
-                                 'pos'  => $currency_config->sign_b4 ? '%s%v' : '%v%s',
361
-                                 'neg'  => $currency_config->sign_b4 ? '- %s%v' : '- %v%s',
362
-                                 'zero' => $currency_config->sign_b4 ? '%s--' : '--%s',
363
-                             ),
364
-                             'decimal'   => $currency_config->dec_mrk,
365
-                             'thousand'  => $currency_config->thsnds,
366
-                             'precision' => $currency_config->dec_plc,
367
-                         ),
368
-                         'number'   => array(
369
-                             'precision' => $currency_config->dec_plc,
370
-                             'thousand'  => $currency_config->thsnds,
371
-                             'decimal'   => $currency_config->dec_mrk,
372
-                         ),
373
-                     )
374
-                 );
375
-            }
376
-        )
377
-        ->setVersion();
378
-    }
379
-
380
-
381
-    /**
382
-     * registers assets for cleaning your ears
383
-     *
384
-     * @param JavascriptAsset $script
385
-     */
386
-    public function loadQtipJs(JavascriptAsset $script)
387
-    {
388
-        // qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook,
389
-        // can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' );
390
-        if (
391
-            $script->handle() === CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE
392
-            && apply_filters('FHEE_load_qtip', false)
393
-        ) {
394
-            EEH_Qtip_Loader::instance()->register_and_enqueue();
395
-        }
396
-    }
397
-
398
-
399
-    /**
400
-     * assets that are used in the WordPress admin
401
-     *
402
-     * @since 4.9.62.p
403
-     * @throws DuplicateCollectionIdentifierException
404
-     * @throws InvalidDataTypeException
405
-     * @throws InvalidEntityException
406
-     */
407
-    private function registerAdminAssets()
408
-    {
409
-        $this->addJavascript(
410
-            CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE,
411
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'wp-plugins-page'),
412
-            array(
413
-                CoreAssetManager::JS_HANDLE_JQUERY,
414
-                CoreAssetManager::JS_HANDLE_EE_VENDOR,
415
-            )
416
-        )
417
-        ->setRequiresTranslation();
418
-
419
-        $this->addStylesheet(
420
-            CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE,
421
-            $this->registry->getCssUrl($this->domain->assetNamespace(), 'wp-plugins-page')
422
-        );
423
-    }
243
+					'admin_url' => admin_url('/'),
244
+				)
245
+			);
246
+			/** site formatting values **/
247
+			$this->registry->addData(
248
+				'site_formats',
249
+				array(
250
+					'date_formats' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats()
251
+				)
252
+			);
253
+		}
254
+
255
+		$this->addJavascript(
256
+			CoreAssetManager::JS_HANDLE_EE_CORE,
257
+			EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
258
+			array(CoreAssetManager::JS_HANDLE_JQUERY)
259
+		)
260
+		->setInlineDataCallback(
261
+			function () {
262
+				wp_localize_script(
263
+					CoreAssetManager::JS_HANDLE_EE_CORE,
264
+					CoreAssetManager::JS_HANDLE_EE_I18N,
265
+					EE_Registry::$i18n_js_strings
266
+				);
267
+			}
268
+		);
269
+	}
270
+
271
+
272
+	/**
273
+	 * @since 4.9.62.p
274
+	 * @throws DuplicateCollectionIdentifierException
275
+	 * @throws InvalidDataTypeException
276
+	 * @throws InvalidEntityException
277
+	 */
278
+	private function loadCoreCss()
279
+	{
280
+		if ($this->template_config->enable_default_style && ! is_admin()) {
281
+			$this->addStylesheet(
282
+				CoreAssetManager::CSS_HANDLE_EE_DEFAULT,
283
+				is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')
284
+					? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css'
285
+					: EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css',
286
+				array('dashicons')
287
+			);
288
+			//Load custom style sheet if available
289
+			if ($this->template_config->custom_style_sheet !== null) {
290
+				$this->addStylesheet(
291
+					CoreAssetManager::CSS_HANDLE_EE_CUSTOM,
292
+					EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet,
293
+					array(CoreAssetManager::CSS_HANDLE_EE_DEFAULT)
294
+				);
295
+			}
296
+		}
297
+	}
298
+
299
+
300
+	/**
301
+	 * jQuery Validate for form validation
302
+	 *
303
+	 * @since 4.9.62.p
304
+	 * @throws DuplicateCollectionIdentifierException
305
+	 * @throws InvalidDataTypeException
306
+	 * @throws InvalidEntityException
307
+	 */
308
+	private function loadJqueryValidate()
309
+	{
310
+		$this->addJavascript(
311
+			CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE,
312
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js',
313
+			array(CoreAssetManager::JS_HANDLE_JQUERY)
314
+		)
315
+		->setVersion('1.15.0');
316
+
317
+		$this->addJavascript(
318
+			CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE_EXTRA,
319
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js',
320
+			array(CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE)
321
+		)
322
+		->setVersion('1.15.0');
323
+	}
324
+
325
+
326
+	/**
327
+	 * accounting.js for performing client-side calculations
328
+	 *
329
+	 * @since 4.9.62.p
330
+	 * @throws DuplicateCollectionIdentifierException
331
+	 * @throws InvalidDataTypeException
332
+	 * @throws InvalidEntityException
333
+	 */
334
+	private function loadAccountingJs()
335
+	{
336
+		//accounting.js library
337
+		// @link http://josscrowcroft.github.io/accounting.js/
338
+		$this->addJavascript(
339
+			CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE,
340
+			EE_THIRD_PARTY_URL . 'accounting/accounting.js',
341
+			array(CoreAssetManager::JS_HANDLE_UNDERSCORE)
342
+		)
343
+		->setVersion('0.3.2');
344
+
345
+		$currency_config = $this->currency_config;
346
+		$this->addJavascript(
347
+			CoreAssetManager::JS_HANDLE_EE_ACCOUNTING,
348
+			EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js',
349
+			array(CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE)
350
+		)
351
+		->setInlineDataCallback(
352
+			function () use ($currency_config) {
353
+				 wp_localize_script(
354
+					 CoreAssetManager::JS_HANDLE_EE_ACCOUNTING,
355
+					 'EE_ACCOUNTING_CFG',
356
+					 array(
357
+						 'currency' => array(
358
+							 'symbol'    => $currency_config->sign,
359
+							 'format'    => array(
360
+								 'pos'  => $currency_config->sign_b4 ? '%s%v' : '%v%s',
361
+								 'neg'  => $currency_config->sign_b4 ? '- %s%v' : '- %v%s',
362
+								 'zero' => $currency_config->sign_b4 ? '%s--' : '--%s',
363
+							 ),
364
+							 'decimal'   => $currency_config->dec_mrk,
365
+							 'thousand'  => $currency_config->thsnds,
366
+							 'precision' => $currency_config->dec_plc,
367
+						 ),
368
+						 'number'   => array(
369
+							 'precision' => $currency_config->dec_plc,
370
+							 'thousand'  => $currency_config->thsnds,
371
+							 'decimal'   => $currency_config->dec_mrk,
372
+						 ),
373
+					 )
374
+				 );
375
+			}
376
+		)
377
+		->setVersion();
378
+	}
379
+
380
+
381
+	/**
382
+	 * registers assets for cleaning your ears
383
+	 *
384
+	 * @param JavascriptAsset $script
385
+	 */
386
+	public function loadQtipJs(JavascriptAsset $script)
387
+	{
388
+		// qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook,
389
+		// can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' );
390
+		if (
391
+			$script->handle() === CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE
392
+			&& apply_filters('FHEE_load_qtip', false)
393
+		) {
394
+			EEH_Qtip_Loader::instance()->register_and_enqueue();
395
+		}
396
+	}
397
+
398
+
399
+	/**
400
+	 * assets that are used in the WordPress admin
401
+	 *
402
+	 * @since 4.9.62.p
403
+	 * @throws DuplicateCollectionIdentifierException
404
+	 * @throws InvalidDataTypeException
405
+	 * @throws InvalidEntityException
406
+	 */
407
+	private function registerAdminAssets()
408
+	{
409
+		$this->addJavascript(
410
+			CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE,
411
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'wp-plugins-page'),
412
+			array(
413
+				CoreAssetManager::JS_HANDLE_JQUERY,
414
+				CoreAssetManager::JS_HANDLE_EE_VENDOR,
415
+			)
416
+		)
417
+		->setRequiresTranslation();
418
+
419
+		$this->addStylesheet(
420
+			CoreAssetManager::JS_HANDLE_EE_WP_PLUGINS_PAGE,
421
+			$this->registry->getCssUrl($this->domain->assetNamespace(), 'wp-plugins-page')
422
+		);
423
+	}
424 424
 }
Please login to merge, or discard this patch.