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