Completed
Pull Request — master (#294)
by Darren
14:19 queued 44s
created
core/services/assets/Registry.php 2 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
         $this->registerManifestFile(
105 105
             self::ASSET_NAMESPACE,
106 106
             $this->domain->distributionAssetsUrl(),
107
-            $this->domain->distributionAssetsPath() . 'build-manifest.json'
107
+            $this->domain->distributionAssetsPath().'build-manifest.json'
108 108
         );
109 109
         add_action('wp_enqueue_scripts', array($this, 'scripts'), 1);
110 110
         add_action('admin_enqueue_scripts', array($this, 'scripts'), 1);
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
             //js.api
150 150
             wp_register_script(
151 151
                 'eejs-api',
152
-                EE_LIBRARIES_URL . 'rest_api/assets/js/eejs-api.min.js',
152
+                EE_LIBRARIES_URL.'rest_api/assets/js/eejs-api.min.js',
153 153
                 array('underscore', 'eejs-core'),
154 154
                 EVENT_ESPRESSO_VERSION,
155 155
                 true
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
             $this->jsdata['eejs_api_nonce'] = wp_create_nonce('wp_rest');
158 158
             $this->jsdata['paths'] = array('rest_route' => rest_url('ee/v4.8.36/'));
159 159
         }
160
-        if (! is_admin()) {
160
+        if ( ! is_admin()) {
161 161
             $this->loadCoreCss();
162 162
         }
163 163
         $this->loadCoreJs();
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
      */
256 256
     public function addTemplate($template_reference, $template_content)
257 257
     {
258
-        if (! isset($this->jsdata['templates'])) {
258
+        if ( ! isset($this->jsdata['templates'])) {
259 259
             $this->jsdata['templates'] = array();
260 260
         }
261 261
         //no overrides allowed.
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
             );
384 384
         }
385 385
         if (filter_var($url_base, FILTER_VALIDATE_URL) === false) {
386
-            if ( WP_DEBUG ) {
386
+            if (WP_DEBUG) {
387 387
                 throw new InvalidArgumentException(
388 388
                     sprintf(
389 389
                         esc_html__(
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
             return;
413 413
         }
414 414
         $this->manifest_data[$namespace] = $this->decodeManifestFile($manifest_file);
415
-        if (! isset($this->manifest_data[$namespace]['url_base'])) {
415
+        if ( ! isset($this->manifest_data[$namespace]['url_base'])) {
416 416
             $this->manifest_data[$namespace]['url_base'] = trailingslashit($url_base);
417 417
         }
418 418
     }
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
      */
430 430
     private function decodeManifestFile($manifest_file)
431 431
     {
432
-        if (! file_exists($manifest_file)) {
432
+        if ( ! file_exists($manifest_file)) {
433 433
             throw new InvalidFilePathException($manifest_file);
434 434
         }
435 435
         return json_decode(file_get_contents($manifest_file), true);
@@ -484,9 +484,9 @@  discard block
 block discarded – undo
484 484
     private function loadCoreCss()
485 485
     {
486 486
         if ($this->template_config->enable_default_style) {
487
-            $default_stylesheet_path = is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')
487
+            $default_stylesheet_path = is_readable(EVENT_ESPRESSO_UPLOAD_DIR.'css/style.css')
488 488
                 ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css'
489
-                : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css';
489
+                : EE_GLOBAL_ASSETS_URL.'css/espresso_default.css';
490 490
             wp_register_style(
491 491
                 'espresso_default',
492 492
                 $default_stylesheet_path,
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
             if ($this->template_config->custom_style_sheet !== null) {
498 498
                 wp_register_style(
499 499
                     'espresso_custom_css',
500
-                    EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet,
500
+                    EVENT_ESPRESSO_UPLOAD_URL.'css/'.$this->template_config->custom_style_sheet,
501 501
                     array('espresso_default'),
502 502
                     EVENT_ESPRESSO_VERSION
503 503
                 );
@@ -515,7 +515,7 @@  discard block
 block discarded – undo
515 515
         // load core js
516 516
         wp_register_script(
517 517
             'espresso_core',
518
-            EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
518
+            EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js',
519 519
             array('jquery'),
520 520
             EVENT_ESPRESSO_VERSION,
521 521
             true
@@ -532,14 +532,14 @@  discard block
 block discarded – undo
532 532
         // register jQuery Validate and additional methods
533 533
         wp_register_script(
534 534
             'jquery-validate',
535
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js',
535
+            EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.min.js',
536 536
             array('jquery'),
537 537
             '1.15.0',
538 538
             true
539 539
         );
540 540
         wp_register_script(
541 541
             'jquery-validate-extra-methods',
542
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js',
542
+            EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.additional-methods.min.js',
543 543
             array('jquery', 'jquery-validate'),
544 544
             '1.15.0',
545 545
             true
@@ -557,14 +557,14 @@  discard block
 block discarded – undo
557 557
         // @link http://josscrowcroft.github.io/accounting.js/
558 558
         wp_register_script(
559 559
             'ee-accounting-core',
560
-            EE_THIRD_PARTY_URL . 'accounting/accounting.js',
560
+            EE_THIRD_PARTY_URL.'accounting/accounting.js',
561 561
             array('underscore'),
562 562
             '0.3.2',
563 563
             true
564 564
         );
565 565
         wp_register_script(
566 566
             'ee-accounting',
567
-            EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js',
567
+            EE_GLOBAL_ASSETS_URL.'scripts/ee-accounting-config.js',
568 568
             array('ee-accounting-core'),
569 569
             EVENT_ESPRESSO_VERSION,
570 570
             true
Please login to merge, or discard this patch.
Indentation   +651 added lines, -651 removed lines patch added patch discarded remove patch
@@ -26,659 +26,659 @@
 block discarded – undo
26 26
 class Registry
27 27
 {
28 28
 
29
-    const ASSET_TYPE_CSS = 'css';
30
-    const ASSET_TYPE_JS = 'js';
31
-    const ASSET_NAMESPACE = 'core';
32
-
33
-    /**
34
-     * @var EE_Template_Config $template_config
35
-     */
36
-    protected $template_config;
37
-
38
-    /**
39
-     * @var EE_Currency_Config $currency_config
40
-     */
41
-    protected $currency_config;
42
-
43
-    /**
44
-     * This holds the jsdata data object that will be exposed on pages that enqueue the `eejs-core` script.
45
-     *
46
-     * @var array
47
-     */
48
-    protected $jsdata = array();
49
-
50
-
51
-    /**
52
-     * This keeps track of all scripts with registered data.  It is used to prevent duplicate data objects setup in the
53
-     * page source.
54
-     * @var array
55
-     */
56
-    protected $script_handles_with_data = array();
57
-
58
-
59
-    /**
60
-     * @var DomainInterface
61
-     */
62
-    protected $domain;
63
-
64
-
65
-
66
-    /**
67
-     * Holds the manifest data obtained from registered manifest files.
68
-     * Manifests are maps of asset chunk name to actual built asset file names.
69
-     * Shape of this array is:
70
-     *
71
-     * array(
72
-     *  'some_namespace_slug' => array(
73
-     *      'some_chunk_name' => array(
74
-     *          'js' => 'filename.js'
75
-     *          'css' => 'filename.js'
76
-     *      ),
77
-     *      'url_base' => 'https://baseurl.com/to/assets
78
-     *  )
79
-     * )
80
-     *
81
-     * @var array
82
-     */
83
-    private $manifest_data = array();
84
-
85
-
86
-    /**
87
-     * Registry constructor.
88
-     * Hooking into WP actions for script registry.
89
-     *
90
-     * @param EE_Template_Config $template_config
91
-     * @param EE_Currency_Config $currency_config
92
-     * @param DomainInterface    $domain
93
-     * @throws InvalidArgumentException
94
-     * @throws InvalidFilePathException
95
-     */
96
-    public function __construct(
97
-        EE_Template_Config $template_config,
98
-        EE_Currency_Config $currency_config,
99
-        DomainInterface $domain
100
-    ) {
101
-        $this->template_config = $template_config;
102
-        $this->currency_config = $currency_config;
103
-        $this->domain = $domain;
104
-        $this->registerManifestFile(
105
-            self::ASSET_NAMESPACE,
106
-            $this->domain->distributionAssetsUrl(),
107
-            $this->domain->distributionAssetsPath() . 'build-manifest.json'
108
-        );
109
-        add_action('wp_enqueue_scripts', array($this, 'scripts'), 1);
110
-        add_action('admin_enqueue_scripts', array($this, 'scripts'), 1);
111
-        add_action('wp_enqueue_scripts', array($this, 'enqueueData'), 2);
112
-        add_action('admin_enqueue_scripts', array($this, 'enqueueData'), 2);
113
-        add_action('wp_print_footer_scripts', array($this, 'enqueueData'), 1);
114
-        add_action('admin_print_footer_scripts', array($this, 'enqueueData'), 1);
115
-    }
116
-
117
-    /**
118
-     * Callback for the WP script actions.
119
-     * Used to register globally accessible core scripts.
120
-     * Also used to add the eejs.data object to the source for any js having eejs-core as a dependency.
121
-     *
122
-     */
123
-    public function scripts()
124
-    {
125
-        global $wp_version;
126
-        wp_register_script(
127
-            'ee-manifest',
128
-            $this->getJsUrl(self::ASSET_NAMESPACE, 'manifest'),
129
-            array(),
130
-            null,
131
-            true
132
-        );
133
-        wp_register_script(
134
-            'eejs-core',
135
-            $this->getJsUrl(self::ASSET_NAMESPACE, 'eejs'),
136
-            array('ee-manifest'),
137
-            null,
138
-            true
139
-        );
140
-        wp_register_script(
141
-            'ee-vendor-react',
142
-            $this->getJsUrl(self::ASSET_NAMESPACE, 'reactVendor'),
143
-            array('eejs-core'),
144
-            null,
145
-            true
146
-        );
147
-        //only run this if WordPress 4.4.0 > is in use.
148
-        if (version_compare($wp_version, '4.4.0', '>')) {
149
-            //js.api
150
-            wp_register_script(
151
-                'eejs-api',
152
-                EE_LIBRARIES_URL . 'rest_api/assets/js/eejs-api.min.js',
153
-                array('underscore', 'eejs-core'),
154
-                EVENT_ESPRESSO_VERSION,
155
-                true
156
-            );
157
-            $this->jsdata['eejs_api_nonce'] = wp_create_nonce('wp_rest');
158
-            $this->jsdata['paths'] = array('rest_route' => rest_url('ee/v4.8.36/'));
159
-        }
160
-        if (! is_admin()) {
161
-            $this->loadCoreCss();
162
-        }
163
-        $this->loadCoreJs();
164
-        $this->loadJqueryValidate();
165
-        $this->loadAccountingJs();
166
-        $this->loadQtipJs();
167
-        $this->registerAdminAssets();
168
-    }
169
-
170
-
171
-
172
-    /**
173
-     * Call back for the script print in frontend and backend.
174
-     * Used to call wp_localize_scripts so that data can be added throughout the runtime until this later hook point.
175
-     *
176
-     * @since 4.9.31.rc.015
177
-     */
178
-    public function enqueueData()
179
-    {
180
-        $this->removeAlreadyRegisteredDataForScriptHandles();
181
-        wp_localize_script('eejs-core', 'eejsdata', array('data' => $this->jsdata));
182
-        wp_localize_script('espresso_core', 'eei18n', EE_Registry::$i18n_js_strings);
183
-        $this->localizeAccountingJs();
184
-        $this->addRegisteredScriptHandlesWithData('eejs-core');
185
-        $this->addRegisteredScriptHandlesWithData('espresso_core');
186
-    }
187
-
188
-
189
-
190
-    /**
191
-     * Used to add data to eejs.data object.
192
-     * Note:  Overriding existing data is not allowed.
193
-     * Data will be accessible as a javascript object when you list `eejs-core` as a dependency for your javascript.
194
-     * If the data you add is something like this:
195
-     *  $this->addData( 'my_plugin_data', array( 'foo' => 'gar' ) );
196
-     * It will be exposed in the page source as:
197
-     *  eejs.data.my_plugin_data.foo == gar
198
-     *
199
-     * @param string       $key   Key used to access your data
200
-     * @param string|array $value Value to attach to key
201
-     * @throws InvalidArgumentException
202
-     */
203
-    public function addData($key, $value)
204
-    {
205
-        if ($this->verifyDataNotExisting($key)) {
206
-            $this->jsdata[$key] = $value;
207
-        }
208
-    }
209
-
210
-
211
-
212
-    /**
213
-     * Similar to addData except this allows for users to push values to an existing key where the values on key are
214
-     * elements in an array.
215
-     * When you use this method, the value you include will be appended to the end of an array on $key.
216
-     * So if the $key was 'test' and you added a value of 'my_data' then it would be represented in the javascript
217
-     * object like this, eejs.data.test = [ my_data,
218
-     * ]
219
-     * If there has already been a scalar value attached to the data object given key, then
220
-     * this will throw an exception.
221
-     *
222
-     * @param string       $key   Key to attach data to.
223
-     * @param string|array $value Value being registered.
224
-     * @throws InvalidArgumentException
225
-     */
226
-    public function pushData($key, $value)
227
-    {
228
-        if (isset($this->jsdata[$key])
229
-            && ! is_array($this->jsdata[$key])
230
-        ) {
231
-            throw new invalidArgumentException(
232
-                sprintf(
233
-                    __(
234
-                        'The value for %1$s is already set and it is not an array. The %2$s method can only be used to
29
+	const ASSET_TYPE_CSS = 'css';
30
+	const ASSET_TYPE_JS = 'js';
31
+	const ASSET_NAMESPACE = 'core';
32
+
33
+	/**
34
+	 * @var EE_Template_Config $template_config
35
+	 */
36
+	protected $template_config;
37
+
38
+	/**
39
+	 * @var EE_Currency_Config $currency_config
40
+	 */
41
+	protected $currency_config;
42
+
43
+	/**
44
+	 * This holds the jsdata data object that will be exposed on pages that enqueue the `eejs-core` script.
45
+	 *
46
+	 * @var array
47
+	 */
48
+	protected $jsdata = array();
49
+
50
+
51
+	/**
52
+	 * This keeps track of all scripts with registered data.  It is used to prevent duplicate data objects setup in the
53
+	 * page source.
54
+	 * @var array
55
+	 */
56
+	protected $script_handles_with_data = array();
57
+
58
+
59
+	/**
60
+	 * @var DomainInterface
61
+	 */
62
+	protected $domain;
63
+
64
+
65
+
66
+	/**
67
+	 * Holds the manifest data obtained from registered manifest files.
68
+	 * Manifests are maps of asset chunk name to actual built asset file names.
69
+	 * Shape of this array is:
70
+	 *
71
+	 * array(
72
+	 *  'some_namespace_slug' => array(
73
+	 *      'some_chunk_name' => array(
74
+	 *          'js' => 'filename.js'
75
+	 *          'css' => 'filename.js'
76
+	 *      ),
77
+	 *      'url_base' => 'https://baseurl.com/to/assets
78
+	 *  )
79
+	 * )
80
+	 *
81
+	 * @var array
82
+	 */
83
+	private $manifest_data = array();
84
+
85
+
86
+	/**
87
+	 * Registry constructor.
88
+	 * Hooking into WP actions for script registry.
89
+	 *
90
+	 * @param EE_Template_Config $template_config
91
+	 * @param EE_Currency_Config $currency_config
92
+	 * @param DomainInterface    $domain
93
+	 * @throws InvalidArgumentException
94
+	 * @throws InvalidFilePathException
95
+	 */
96
+	public function __construct(
97
+		EE_Template_Config $template_config,
98
+		EE_Currency_Config $currency_config,
99
+		DomainInterface $domain
100
+	) {
101
+		$this->template_config = $template_config;
102
+		$this->currency_config = $currency_config;
103
+		$this->domain = $domain;
104
+		$this->registerManifestFile(
105
+			self::ASSET_NAMESPACE,
106
+			$this->domain->distributionAssetsUrl(),
107
+			$this->domain->distributionAssetsPath() . 'build-manifest.json'
108
+		);
109
+		add_action('wp_enqueue_scripts', array($this, 'scripts'), 1);
110
+		add_action('admin_enqueue_scripts', array($this, 'scripts'), 1);
111
+		add_action('wp_enqueue_scripts', array($this, 'enqueueData'), 2);
112
+		add_action('admin_enqueue_scripts', array($this, 'enqueueData'), 2);
113
+		add_action('wp_print_footer_scripts', array($this, 'enqueueData'), 1);
114
+		add_action('admin_print_footer_scripts', array($this, 'enqueueData'), 1);
115
+	}
116
+
117
+	/**
118
+	 * Callback for the WP script actions.
119
+	 * Used to register globally accessible core scripts.
120
+	 * Also used to add the eejs.data object to the source for any js having eejs-core as a dependency.
121
+	 *
122
+	 */
123
+	public function scripts()
124
+	{
125
+		global $wp_version;
126
+		wp_register_script(
127
+			'ee-manifest',
128
+			$this->getJsUrl(self::ASSET_NAMESPACE, 'manifest'),
129
+			array(),
130
+			null,
131
+			true
132
+		);
133
+		wp_register_script(
134
+			'eejs-core',
135
+			$this->getJsUrl(self::ASSET_NAMESPACE, 'eejs'),
136
+			array('ee-manifest'),
137
+			null,
138
+			true
139
+		);
140
+		wp_register_script(
141
+			'ee-vendor-react',
142
+			$this->getJsUrl(self::ASSET_NAMESPACE, 'reactVendor'),
143
+			array('eejs-core'),
144
+			null,
145
+			true
146
+		);
147
+		//only run this if WordPress 4.4.0 > is in use.
148
+		if (version_compare($wp_version, '4.4.0', '>')) {
149
+			//js.api
150
+			wp_register_script(
151
+				'eejs-api',
152
+				EE_LIBRARIES_URL . 'rest_api/assets/js/eejs-api.min.js',
153
+				array('underscore', 'eejs-core'),
154
+				EVENT_ESPRESSO_VERSION,
155
+				true
156
+			);
157
+			$this->jsdata['eejs_api_nonce'] = wp_create_nonce('wp_rest');
158
+			$this->jsdata['paths'] = array('rest_route' => rest_url('ee/v4.8.36/'));
159
+		}
160
+		if (! is_admin()) {
161
+			$this->loadCoreCss();
162
+		}
163
+		$this->loadCoreJs();
164
+		$this->loadJqueryValidate();
165
+		$this->loadAccountingJs();
166
+		$this->loadQtipJs();
167
+		$this->registerAdminAssets();
168
+	}
169
+
170
+
171
+
172
+	/**
173
+	 * Call back for the script print in frontend and backend.
174
+	 * Used to call wp_localize_scripts so that data can be added throughout the runtime until this later hook point.
175
+	 *
176
+	 * @since 4.9.31.rc.015
177
+	 */
178
+	public function enqueueData()
179
+	{
180
+		$this->removeAlreadyRegisteredDataForScriptHandles();
181
+		wp_localize_script('eejs-core', 'eejsdata', array('data' => $this->jsdata));
182
+		wp_localize_script('espresso_core', 'eei18n', EE_Registry::$i18n_js_strings);
183
+		$this->localizeAccountingJs();
184
+		$this->addRegisteredScriptHandlesWithData('eejs-core');
185
+		$this->addRegisteredScriptHandlesWithData('espresso_core');
186
+	}
187
+
188
+
189
+
190
+	/**
191
+	 * Used to add data to eejs.data object.
192
+	 * Note:  Overriding existing data is not allowed.
193
+	 * Data will be accessible as a javascript object when you list `eejs-core` as a dependency for your javascript.
194
+	 * If the data you add is something like this:
195
+	 *  $this->addData( 'my_plugin_data', array( 'foo' => 'gar' ) );
196
+	 * It will be exposed in the page source as:
197
+	 *  eejs.data.my_plugin_data.foo == gar
198
+	 *
199
+	 * @param string       $key   Key used to access your data
200
+	 * @param string|array $value Value to attach to key
201
+	 * @throws InvalidArgumentException
202
+	 */
203
+	public function addData($key, $value)
204
+	{
205
+		if ($this->verifyDataNotExisting($key)) {
206
+			$this->jsdata[$key] = $value;
207
+		}
208
+	}
209
+
210
+
211
+
212
+	/**
213
+	 * Similar to addData except this allows for users to push values to an existing key where the values on key are
214
+	 * elements in an array.
215
+	 * When you use this method, the value you include will be appended to the end of an array on $key.
216
+	 * So if the $key was 'test' and you added a value of 'my_data' then it would be represented in the javascript
217
+	 * object like this, eejs.data.test = [ my_data,
218
+	 * ]
219
+	 * If there has already been a scalar value attached to the data object given key, then
220
+	 * this will throw an exception.
221
+	 *
222
+	 * @param string       $key   Key to attach data to.
223
+	 * @param string|array $value Value being registered.
224
+	 * @throws InvalidArgumentException
225
+	 */
226
+	public function pushData($key, $value)
227
+	{
228
+		if (isset($this->jsdata[$key])
229
+			&& ! is_array($this->jsdata[$key])
230
+		) {
231
+			throw new invalidArgumentException(
232
+				sprintf(
233
+					__(
234
+						'The value for %1$s is already set and it is not an array. The %2$s method can only be used to
235 235
                          push values to this data element when it is an array.',
236
-                        'event_espresso'
237
-                    ),
238
-                    $key,
239
-                    __METHOD__
240
-                )
241
-            );
242
-        }
243
-        $this->jsdata[$key][] = $value;
244
-    }
245
-
246
-
247
-
248
-    /**
249
-     * Used to set content used by javascript for a template.
250
-     * Note: Overrides of existing registered templates are not allowed.
251
-     *
252
-     * @param string $template_reference
253
-     * @param string $template_content
254
-     * @throws InvalidArgumentException
255
-     */
256
-    public function addTemplate($template_reference, $template_content)
257
-    {
258
-        if (! isset($this->jsdata['templates'])) {
259
-            $this->jsdata['templates'] = array();
260
-        }
261
-        //no overrides allowed.
262
-        if (isset($this->jsdata['templates'][$template_reference])) {
263
-            throw new invalidArgumentException(
264
-                sprintf(
265
-                    __(
266
-                        'The %1$s key already exists for the templates array in the js data array.  No overrides are allowed.',
267
-                        'event_espresso'
268
-                    ),
269
-                    $template_reference
270
-                )
271
-            );
272
-        }
273
-        $this->jsdata['templates'][$template_reference] = $template_content;
274
-    }
275
-
276
-
277
-
278
-    /**
279
-     * Retrieve the template content already registered for the given reference.
280
-     *
281
-     * @param string $template_reference
282
-     * @return string
283
-     */
284
-    public function getTemplate($template_reference)
285
-    {
286
-        return isset($this->jsdata['templates'], $this->jsdata['templates'][$template_reference])
287
-            ? $this->jsdata['templates'][$template_reference]
288
-            : '';
289
-    }
290
-
291
-
292
-
293
-    /**
294
-     * Retrieve registered data.
295
-     *
296
-     * @param string $key Name of key to attach data to.
297
-     * @return mixed                If there is no for the given key, then false is returned.
298
-     */
299
-    public function getData($key)
300
-    {
301
-        return isset($this->jsdata[$key])
302
-            ? $this->jsdata[$key]
303
-            : false;
304
-    }
305
-
306
-
307
-    /**
308
-     * Get the actual asset path for asset manifests.
309
-     * If there is no asset path found for the given $chunk_name, then the $chunk_name is returned.
310
-     * @param string $namespace  The namespace associated with the manifest file hosting the map of chunk_name to actual
311
-     *                           asset file location.
312
-     * @param string $chunk_name
313
-     * @param string $asset_type
314
-     * @return string
315
-     * @since 4.9.59.p
316
-     */
317
-    public function getAssetUrl($namespace, $chunk_name, $asset_type)
318
-    {
319
-        $url = isset(
320
-            $this->manifest_data[$namespace][$chunk_name][$asset_type],
321
-            $this->manifest_data[$namespace]['url_base']
322
-        )
323
-            ? $this->manifest_data[$namespace]['url_base']
324
-              . $this->manifest_data[$namespace][$chunk_name][$asset_type]
325
-            : $chunk_name;
326
-        return apply_filters(
327
-            'FHEE__EventEspresso_core_services_assets_Registry__getAssetUrl',
328
-            $url,
329
-            $namespace,
330
-            $chunk_name,
331
-            $asset_type
332
-        );
333
-    }
334
-
335
-
336
-    /**
337
-     * Return the url to a js file for the given namespace and chunk name.
338
-     *
339
-     * @param string $namespace
340
-     * @param string $chunk_name
341
-     * @return string
342
-     */
343
-    public function getJsUrl($namespace, $chunk_name)
344
-    {
345
-        return $this->getAssetUrl($namespace, $chunk_name, self::ASSET_TYPE_JS);
346
-    }
347
-
348
-
349
-    /**
350
-     * Return the url to a css file for the given namespace and chunk name.
351
-     *
352
-     * @param string $namespace
353
-     * @param string $chunk_name
354
-     * @return string
355
-     */
356
-    public function getCssUrl($namespace, $chunk_name)
357
-    {
358
-        return $this->getAssetUrl($namespace, $chunk_name, self::ASSET_TYPE_CSS);
359
-    }
360
-
361
-
362
-    /**
363
-     * Used to register a js/css manifest file with the registered_manifest_files property.
364
-     *
365
-     * @param string $namespace     Provided to associate the manifest file with a specific namespace.
366
-     * @param string $url_base      The url base for the manifest file location.
367
-     * @param string $manifest_file The absolute path to the manifest file.
368
-     * @throws InvalidArgumentException
369
-     * @throws InvalidFilePathException
370
-     * @since 4.9.59.p
371
-     */
372
-    public function registerManifestFile($namespace, $url_base, $manifest_file)
373
-    {
374
-        if (isset($this->manifest_data[$namespace])) {
375
-            throw new InvalidArgumentException(
376
-                sprintf(
377
-                    esc_html__(
378
-                        'The namespace for this manifest file has already been registered, choose a namespace other than %s',
379
-                        'event_espresso'
380
-                    ),
381
-                    $namespace
382
-                )
383
-            );
384
-        }
385
-        if (filter_var($url_base, FILTER_VALIDATE_URL) === false) {
386
-            if ( WP_DEBUG ) {
387
-                throw new InvalidArgumentException(
388
-                    sprintf(
389
-                        esc_html__(
390
-                            'The provided value for %1$s is not a valid url.  The url provided was: %2$s',
391
-                            'event_espresso'
392
-                        ),
393
-                        '$url_base',
394
-                        $url_base
395
-                    )
396
-                );
397
-            }
398
-            if (is_admin()) {
399
-                EE_Error::add_error(
400
-                    sprintf(
401
-                        esc_html__(
402
-                            'The url given for %1$s assets is invalid.  The url provided was: "%2$s". This usually happens when another plugin or theme on a site is using the "%3$s" filter or has an invalid url set for the "%4$s" constant',
403
-                            'event_espresso'
404
-                        ),
405
-                        'Event Espresso',
406
-                        $url_base,
407
-                        'plugins_url',
408
-                        'WP_PLUGIN_URL'
409
-                    )
410
-                );
411
-            }
412
-            return;
413
-        }
414
-        $this->manifest_data[$namespace] = $this->decodeManifestFile($manifest_file);
415
-        if (! isset($this->manifest_data[$namespace]['url_base'])) {
416
-            $this->manifest_data[$namespace]['url_base'] = trailingslashit($url_base);
417
-        }
418
-    }
419
-
420
-
421
-
422
-    /**
423
-     * Decodes json from the provided manifest file.
424
-     *
425
-     * @since 4.9.59.p
426
-     * @param string $manifest_file Path to manifest file.
427
-     * @return array
428
-     * @throws InvalidFilePathException
429
-     */
430
-    private function decodeManifestFile($manifest_file)
431
-    {
432
-        if (! file_exists($manifest_file)) {
433
-            throw new InvalidFilePathException($manifest_file);
434
-        }
435
-        return json_decode(file_get_contents($manifest_file), true);
436
-    }
437
-
438
-
439
-
440
-    /**
441
-     * Verifies whether the given data exists already on the jsdata array.
442
-     * Overriding data is not allowed.
443
-     *
444
-     * @param string $key Index for data.
445
-     * @return bool        If valid then return true.
446
-     * @throws InvalidArgumentException if data already exists.
447
-     */
448
-    protected function verifyDataNotExisting($key)
449
-    {
450
-        if (isset($this->jsdata[$key])) {
451
-            if (is_array($this->jsdata[$key])) {
452
-                throw new InvalidArgumentException(
453
-                    sprintf(
454
-                        __(
455
-                            'The value for %1$s already exists in the Registry::eejs object.
236
+						'event_espresso'
237
+					),
238
+					$key,
239
+					__METHOD__
240
+				)
241
+			);
242
+		}
243
+		$this->jsdata[$key][] = $value;
244
+	}
245
+
246
+
247
+
248
+	/**
249
+	 * Used to set content used by javascript for a template.
250
+	 * Note: Overrides of existing registered templates are not allowed.
251
+	 *
252
+	 * @param string $template_reference
253
+	 * @param string $template_content
254
+	 * @throws InvalidArgumentException
255
+	 */
256
+	public function addTemplate($template_reference, $template_content)
257
+	{
258
+		if (! isset($this->jsdata['templates'])) {
259
+			$this->jsdata['templates'] = array();
260
+		}
261
+		//no overrides allowed.
262
+		if (isset($this->jsdata['templates'][$template_reference])) {
263
+			throw new invalidArgumentException(
264
+				sprintf(
265
+					__(
266
+						'The %1$s key already exists for the templates array in the js data array.  No overrides are allowed.',
267
+						'event_espresso'
268
+					),
269
+					$template_reference
270
+				)
271
+			);
272
+		}
273
+		$this->jsdata['templates'][$template_reference] = $template_content;
274
+	}
275
+
276
+
277
+
278
+	/**
279
+	 * Retrieve the template content already registered for the given reference.
280
+	 *
281
+	 * @param string $template_reference
282
+	 * @return string
283
+	 */
284
+	public function getTemplate($template_reference)
285
+	{
286
+		return isset($this->jsdata['templates'], $this->jsdata['templates'][$template_reference])
287
+			? $this->jsdata['templates'][$template_reference]
288
+			: '';
289
+	}
290
+
291
+
292
+
293
+	/**
294
+	 * Retrieve registered data.
295
+	 *
296
+	 * @param string $key Name of key to attach data to.
297
+	 * @return mixed                If there is no for the given key, then false is returned.
298
+	 */
299
+	public function getData($key)
300
+	{
301
+		return isset($this->jsdata[$key])
302
+			? $this->jsdata[$key]
303
+			: false;
304
+	}
305
+
306
+
307
+	/**
308
+	 * Get the actual asset path for asset manifests.
309
+	 * If there is no asset path found for the given $chunk_name, then the $chunk_name is returned.
310
+	 * @param string $namespace  The namespace associated with the manifest file hosting the map of chunk_name to actual
311
+	 *                           asset file location.
312
+	 * @param string $chunk_name
313
+	 * @param string $asset_type
314
+	 * @return string
315
+	 * @since 4.9.59.p
316
+	 */
317
+	public function getAssetUrl($namespace, $chunk_name, $asset_type)
318
+	{
319
+		$url = isset(
320
+			$this->manifest_data[$namespace][$chunk_name][$asset_type],
321
+			$this->manifest_data[$namespace]['url_base']
322
+		)
323
+			? $this->manifest_data[$namespace]['url_base']
324
+			  . $this->manifest_data[$namespace][$chunk_name][$asset_type]
325
+			: $chunk_name;
326
+		return apply_filters(
327
+			'FHEE__EventEspresso_core_services_assets_Registry__getAssetUrl',
328
+			$url,
329
+			$namespace,
330
+			$chunk_name,
331
+			$asset_type
332
+		);
333
+	}
334
+
335
+
336
+	/**
337
+	 * Return the url to a js file for the given namespace and chunk name.
338
+	 *
339
+	 * @param string $namespace
340
+	 * @param string $chunk_name
341
+	 * @return string
342
+	 */
343
+	public function getJsUrl($namespace, $chunk_name)
344
+	{
345
+		return $this->getAssetUrl($namespace, $chunk_name, self::ASSET_TYPE_JS);
346
+	}
347
+
348
+
349
+	/**
350
+	 * Return the url to a css file for the given namespace and chunk name.
351
+	 *
352
+	 * @param string $namespace
353
+	 * @param string $chunk_name
354
+	 * @return string
355
+	 */
356
+	public function getCssUrl($namespace, $chunk_name)
357
+	{
358
+		return $this->getAssetUrl($namespace, $chunk_name, self::ASSET_TYPE_CSS);
359
+	}
360
+
361
+
362
+	/**
363
+	 * Used to register a js/css manifest file with the registered_manifest_files property.
364
+	 *
365
+	 * @param string $namespace     Provided to associate the manifest file with a specific namespace.
366
+	 * @param string $url_base      The url base for the manifest file location.
367
+	 * @param string $manifest_file The absolute path to the manifest file.
368
+	 * @throws InvalidArgumentException
369
+	 * @throws InvalidFilePathException
370
+	 * @since 4.9.59.p
371
+	 */
372
+	public function registerManifestFile($namespace, $url_base, $manifest_file)
373
+	{
374
+		if (isset($this->manifest_data[$namespace])) {
375
+			throw new InvalidArgumentException(
376
+				sprintf(
377
+					esc_html__(
378
+						'The namespace for this manifest file has already been registered, choose a namespace other than %s',
379
+						'event_espresso'
380
+					),
381
+					$namespace
382
+				)
383
+			);
384
+		}
385
+		if (filter_var($url_base, FILTER_VALIDATE_URL) === false) {
386
+			if ( WP_DEBUG ) {
387
+				throw new InvalidArgumentException(
388
+					sprintf(
389
+						esc_html__(
390
+							'The provided value for %1$s is not a valid url.  The url provided was: %2$s',
391
+							'event_espresso'
392
+						),
393
+						'$url_base',
394
+						$url_base
395
+					)
396
+				);
397
+			}
398
+			if (is_admin()) {
399
+				EE_Error::add_error(
400
+					sprintf(
401
+						esc_html__(
402
+							'The url given for %1$s assets is invalid.  The url provided was: "%2$s". This usually happens when another plugin or theme on a site is using the "%3$s" filter or has an invalid url set for the "%4$s" constant',
403
+							'event_espresso'
404
+						),
405
+						'Event Espresso',
406
+						$url_base,
407
+						'plugins_url',
408
+						'WP_PLUGIN_URL'
409
+					)
410
+				);
411
+			}
412
+			return;
413
+		}
414
+		$this->manifest_data[$namespace] = $this->decodeManifestFile($manifest_file);
415
+		if (! isset($this->manifest_data[$namespace]['url_base'])) {
416
+			$this->manifest_data[$namespace]['url_base'] = trailingslashit($url_base);
417
+		}
418
+	}
419
+
420
+
421
+
422
+	/**
423
+	 * Decodes json from the provided manifest file.
424
+	 *
425
+	 * @since 4.9.59.p
426
+	 * @param string $manifest_file Path to manifest file.
427
+	 * @return array
428
+	 * @throws InvalidFilePathException
429
+	 */
430
+	private function decodeManifestFile($manifest_file)
431
+	{
432
+		if (! file_exists($manifest_file)) {
433
+			throw new InvalidFilePathException($manifest_file);
434
+		}
435
+		return json_decode(file_get_contents($manifest_file), true);
436
+	}
437
+
438
+
439
+
440
+	/**
441
+	 * Verifies whether the given data exists already on the jsdata array.
442
+	 * Overriding data is not allowed.
443
+	 *
444
+	 * @param string $key Index for data.
445
+	 * @return bool        If valid then return true.
446
+	 * @throws InvalidArgumentException if data already exists.
447
+	 */
448
+	protected function verifyDataNotExisting($key)
449
+	{
450
+		if (isset($this->jsdata[$key])) {
451
+			if (is_array($this->jsdata[$key])) {
452
+				throw new InvalidArgumentException(
453
+					sprintf(
454
+						__(
455
+							'The value for %1$s already exists in the Registry::eejs object.
456 456
                             Overrides are not allowed. Since the value of this data is an array, you may want to use the
457 457
                             %2$s method to push your value to the array.',
458
-                            'event_espresso'
459
-                        ),
460
-                        $key,
461
-                        'pushData()'
462
-                    )
463
-                );
464
-            }
465
-            throw new InvalidArgumentException(
466
-                sprintf(
467
-                    __(
468
-                        'The value for %1$s already exists in the Registry::eejs object. Overrides are not
458
+							'event_espresso'
459
+						),
460
+						$key,
461
+						'pushData()'
462
+					)
463
+				);
464
+			}
465
+			throw new InvalidArgumentException(
466
+				sprintf(
467
+					__(
468
+						'The value for %1$s already exists in the Registry::eejs object. Overrides are not
469 469
                         allowed.  Consider attaching your value to a different key',
470
-                        'event_espresso'
471
-                    ),
472
-                    $key
473
-                )
474
-            );
475
-        }
476
-        return true;
477
-    }
478
-
479
-
480
-
481
-    /**
482
-     * registers core default stylesheets
483
-     */
484
-    private function loadCoreCss()
485
-    {
486
-        if ($this->template_config->enable_default_style) {
487
-            $default_stylesheet_path = is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')
488
-                ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css'
489
-                : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css';
490
-            wp_register_style(
491
-                'espresso_default',
492
-                $default_stylesheet_path,
493
-                array('dashicons'),
494
-                EVENT_ESPRESSO_VERSION
495
-            );
496
-            //Load custom style sheet if available
497
-            if ($this->template_config->custom_style_sheet !== null) {
498
-                wp_register_style(
499
-                    'espresso_custom_css',
500
-                    EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet,
501
-                    array('espresso_default'),
502
-                    EVENT_ESPRESSO_VERSION
503
-                );
504
-            }
505
-        }
506
-    }
507
-
508
-
509
-
510
-    /**
511
-     * registers core default javascript
512
-     */
513
-    private function loadCoreJs()
514
-    {
515
-        // load core js
516
-        wp_register_script(
517
-            'espresso_core',
518
-            EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
519
-            array('jquery'),
520
-            EVENT_ESPRESSO_VERSION,
521
-            true
522
-        );
523
-    }
524
-
525
-
526
-
527
-    /**
528
-     * registers jQuery Validate for form validation
529
-     */
530
-    private function loadJqueryValidate()
531
-    {
532
-        // register jQuery Validate and additional methods
533
-        wp_register_script(
534
-            'jquery-validate',
535
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js',
536
-            array('jquery'),
537
-            '1.15.0',
538
-            true
539
-        );
540
-        wp_register_script(
541
-            'jquery-validate-extra-methods',
542
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js',
543
-            array('jquery', 'jquery-validate'),
544
-            '1.15.0',
545
-            true
546
-        );
547
-    }
548
-
549
-
550
-
551
-    /**
552
-     * registers accounting.js for performing client-side calculations
553
-     */
554
-    private function loadAccountingJs()
555
-    {
556
-        //accounting.js library
557
-        // @link http://josscrowcroft.github.io/accounting.js/
558
-        wp_register_script(
559
-            'ee-accounting-core',
560
-            EE_THIRD_PARTY_URL . 'accounting/accounting.js',
561
-            array('underscore'),
562
-            '0.3.2',
563
-            true
564
-        );
565
-        wp_register_script(
566
-            'ee-accounting',
567
-            EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js',
568
-            array('ee-accounting-core'),
569
-            EVENT_ESPRESSO_VERSION,
570
-            true
571
-        );
572
-    }
573
-
574
-
575
-
576
-    /**
577
-     * registers accounting.js for performing client-side calculations
578
-     */
579
-    private function localizeAccountingJs()
580
-    {
581
-        wp_localize_script(
582
-            'ee-accounting',
583
-            'EE_ACCOUNTING_CFG',
584
-            array(
585
-                'currency' => array(
586
-                    'symbol'    => $this->currency_config->sign,
587
-                    'format'    => array(
588
-                        'pos'  => $this->currency_config->sign_b4 ? '%s%v' : '%v%s',
589
-                        'neg'  => $this->currency_config->sign_b4 ? '- %s%v' : '- %v%s',
590
-                        'zero' => $this->currency_config->sign_b4 ? '%s--' : '--%s',
591
-                    ),
592
-                    'decimal'   => $this->currency_config->dec_mrk,
593
-                    'thousand'  => $this->currency_config->thsnds,
594
-                    'precision' => $this->currency_config->dec_plc,
595
-                ),
596
-                'number'   => array(
597
-                    'precision' => $this->currency_config->dec_plc,
598
-                    'thousand'  => $this->currency_config->thsnds,
599
-                    'decimal'   => $this->currency_config->dec_mrk,
600
-                ),
601
-            )
602
-        );
603
-        $this->addRegisteredScriptHandlesWithData('ee-accounting');
604
-    }
605
-
606
-
607
-
608
-    /**
609
-     * registers assets for cleaning your ears
610
-     */
611
-    private function loadQtipJs()
612
-    {
613
-        // qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook,
614
-        // can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' );
615
-        if (apply_filters('FHEE_load_qtip', false)) {
616
-            EEH_Qtip_Loader::instance()->register_and_enqueue();
617
-        }
618
-    }
619
-
620
-
621
-    /**
622
-     * This is used to set registered script handles that have data.
623
-     * @param string $script_handle
624
-     */
625
-    private function addRegisteredScriptHandlesWithData($script_handle)
626
-    {
627
-        $this->script_handles_with_data[$script_handle] = $script_handle;
628
-    }
629
-
630
-
631
-    /**
632
-     * Checks WP_Scripts for all of each script handle registered internally as having data and unsets from the
633
-     * Dependency stored in WP_Scripts if its set.
634
-     */
635
-    private function removeAlreadyRegisteredDataForScriptHandles()
636
-    {
637
-        if (empty($this->script_handles_with_data)) {
638
-            return;
639
-        }
640
-        foreach ($this->script_handles_with_data as $script_handle) {
641
-            $this->removeAlreadyRegisteredDataForScriptHandle($script_handle);
642
-        }
643
-    }
644
-
645
-
646
-    /**
647
-     * Removes any data dependency registered in WP_Scripts if its set.
648
-     * @param string $script_handle
649
-     */
650
-    private function removeAlreadyRegisteredDataForScriptHandle($script_handle)
651
-    {
652
-        if (isset($this->script_handles_with_data[$script_handle])) {
653
-            global $wp_scripts;
654
-            if ($wp_scripts->get_data($script_handle, 'data')) {
655
-                unset($wp_scripts->registered[$script_handle]->extra['data']);
656
-                unset($this->script_handles_with_data[$script_handle]);
657
-            }
658
-        }
659
-    }
660
-
661
-
662
-    /**
663
-     * Registers assets that are used in the WordPress admin.
664
-     */
665
-    private function registerAdminAssets()
666
-    {
667
-        wp_register_script(
668
-            'ee-wp-plugins-page',
669
-            $this->getJsUrl(self::ASSET_NAMESPACE, 'wp-plugins-page'),
670
-            array(
671
-                'jquery',
672
-                'ee-vendor-react'
673
-            ),
674
-            null,
675
-            true
676
-        );
677
-        wp_register_style(
678
-            'ee-wp-plugins-page',
679
-            $this->getCssUrl(self::ASSET_NAMESPACE, 'wp-plugins-page'),
680
-            array(),
681
-            null
682
-        );
683
-    }
470
+						'event_espresso'
471
+					),
472
+					$key
473
+				)
474
+			);
475
+		}
476
+		return true;
477
+	}
478
+
479
+
480
+
481
+	/**
482
+	 * registers core default stylesheets
483
+	 */
484
+	private function loadCoreCss()
485
+	{
486
+		if ($this->template_config->enable_default_style) {
487
+			$default_stylesheet_path = is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')
488
+				? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css'
489
+				: EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css';
490
+			wp_register_style(
491
+				'espresso_default',
492
+				$default_stylesheet_path,
493
+				array('dashicons'),
494
+				EVENT_ESPRESSO_VERSION
495
+			);
496
+			//Load custom style sheet if available
497
+			if ($this->template_config->custom_style_sheet !== null) {
498
+				wp_register_style(
499
+					'espresso_custom_css',
500
+					EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet,
501
+					array('espresso_default'),
502
+					EVENT_ESPRESSO_VERSION
503
+				);
504
+			}
505
+		}
506
+	}
507
+
508
+
509
+
510
+	/**
511
+	 * registers core default javascript
512
+	 */
513
+	private function loadCoreJs()
514
+	{
515
+		// load core js
516
+		wp_register_script(
517
+			'espresso_core',
518
+			EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
519
+			array('jquery'),
520
+			EVENT_ESPRESSO_VERSION,
521
+			true
522
+		);
523
+	}
524
+
525
+
526
+
527
+	/**
528
+	 * registers jQuery Validate for form validation
529
+	 */
530
+	private function loadJqueryValidate()
531
+	{
532
+		// register jQuery Validate and additional methods
533
+		wp_register_script(
534
+			'jquery-validate',
535
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js',
536
+			array('jquery'),
537
+			'1.15.0',
538
+			true
539
+		);
540
+		wp_register_script(
541
+			'jquery-validate-extra-methods',
542
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js',
543
+			array('jquery', 'jquery-validate'),
544
+			'1.15.0',
545
+			true
546
+		);
547
+	}
548
+
549
+
550
+
551
+	/**
552
+	 * registers accounting.js for performing client-side calculations
553
+	 */
554
+	private function loadAccountingJs()
555
+	{
556
+		//accounting.js library
557
+		// @link http://josscrowcroft.github.io/accounting.js/
558
+		wp_register_script(
559
+			'ee-accounting-core',
560
+			EE_THIRD_PARTY_URL . 'accounting/accounting.js',
561
+			array('underscore'),
562
+			'0.3.2',
563
+			true
564
+		);
565
+		wp_register_script(
566
+			'ee-accounting',
567
+			EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js',
568
+			array('ee-accounting-core'),
569
+			EVENT_ESPRESSO_VERSION,
570
+			true
571
+		);
572
+	}
573
+
574
+
575
+
576
+	/**
577
+	 * registers accounting.js for performing client-side calculations
578
+	 */
579
+	private function localizeAccountingJs()
580
+	{
581
+		wp_localize_script(
582
+			'ee-accounting',
583
+			'EE_ACCOUNTING_CFG',
584
+			array(
585
+				'currency' => array(
586
+					'symbol'    => $this->currency_config->sign,
587
+					'format'    => array(
588
+						'pos'  => $this->currency_config->sign_b4 ? '%s%v' : '%v%s',
589
+						'neg'  => $this->currency_config->sign_b4 ? '- %s%v' : '- %v%s',
590
+						'zero' => $this->currency_config->sign_b4 ? '%s--' : '--%s',
591
+					),
592
+					'decimal'   => $this->currency_config->dec_mrk,
593
+					'thousand'  => $this->currency_config->thsnds,
594
+					'precision' => $this->currency_config->dec_plc,
595
+				),
596
+				'number'   => array(
597
+					'precision' => $this->currency_config->dec_plc,
598
+					'thousand'  => $this->currency_config->thsnds,
599
+					'decimal'   => $this->currency_config->dec_mrk,
600
+				),
601
+			)
602
+		);
603
+		$this->addRegisteredScriptHandlesWithData('ee-accounting');
604
+	}
605
+
606
+
607
+
608
+	/**
609
+	 * registers assets for cleaning your ears
610
+	 */
611
+	private function loadQtipJs()
612
+	{
613
+		// qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook,
614
+		// can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' );
615
+		if (apply_filters('FHEE_load_qtip', false)) {
616
+			EEH_Qtip_Loader::instance()->register_and_enqueue();
617
+		}
618
+	}
619
+
620
+
621
+	/**
622
+	 * This is used to set registered script handles that have data.
623
+	 * @param string $script_handle
624
+	 */
625
+	private function addRegisteredScriptHandlesWithData($script_handle)
626
+	{
627
+		$this->script_handles_with_data[$script_handle] = $script_handle;
628
+	}
629
+
630
+
631
+	/**
632
+	 * Checks WP_Scripts for all of each script handle registered internally as having data and unsets from the
633
+	 * Dependency stored in WP_Scripts if its set.
634
+	 */
635
+	private function removeAlreadyRegisteredDataForScriptHandles()
636
+	{
637
+		if (empty($this->script_handles_with_data)) {
638
+			return;
639
+		}
640
+		foreach ($this->script_handles_with_data as $script_handle) {
641
+			$this->removeAlreadyRegisteredDataForScriptHandle($script_handle);
642
+		}
643
+	}
644
+
645
+
646
+	/**
647
+	 * Removes any data dependency registered in WP_Scripts if its set.
648
+	 * @param string $script_handle
649
+	 */
650
+	private function removeAlreadyRegisteredDataForScriptHandle($script_handle)
651
+	{
652
+		if (isset($this->script_handles_with_data[$script_handle])) {
653
+			global $wp_scripts;
654
+			if ($wp_scripts->get_data($script_handle, 'data')) {
655
+				unset($wp_scripts->registered[$script_handle]->extra['data']);
656
+				unset($this->script_handles_with_data[$script_handle]);
657
+			}
658
+		}
659
+	}
660
+
661
+
662
+	/**
663
+	 * Registers assets that are used in the WordPress admin.
664
+	 */
665
+	private function registerAdminAssets()
666
+	{
667
+		wp_register_script(
668
+			'ee-wp-plugins-page',
669
+			$this->getJsUrl(self::ASSET_NAMESPACE, 'wp-plugins-page'),
670
+			array(
671
+				'jquery',
672
+				'ee-vendor-react'
673
+			),
674
+			null,
675
+			true
676
+		);
677
+		wp_register_style(
678
+			'ee-wp-plugins-page',
679
+			$this->getCssUrl(self::ASSET_NAMESPACE, 'wp-plugins-page'),
680
+			array(),
681
+			null
682
+		);
683
+	}
684 684
 }
Please login to merge, or discard this patch.