Completed
Pull Request — master (#294)
by Darren
15:29
created
espresso.php 1 patch
Indentation   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -38,103 +38,103 @@
 block discarded – undo
38 38
  * @since       4.0
39 39
  */
40 40
 if (function_exists('espresso_version')) {
41
-    if (! function_exists('espresso_duplicate_plugin_error')) {
42
-        /**
43
-         *    espresso_duplicate_plugin_error
44
-         *    displays if more than one version of EE is activated at the same time
45
-         */
46
-        function espresso_duplicate_plugin_error()
47
-        {
48
-            ?>
41
+	if (! function_exists('espresso_duplicate_plugin_error')) {
42
+		/**
43
+		 *    espresso_duplicate_plugin_error
44
+		 *    displays if more than one version of EE is activated at the same time
45
+		 */
46
+		function espresso_duplicate_plugin_error()
47
+		{
48
+			?>
49 49
             <div class="error">
50 50
                 <p>
51 51
                     <?php
52
-                    echo esc_html__(
53
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
-                        'event_espresso'
55
-                    ); ?>
52
+					echo esc_html__(
53
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
+						'event_espresso'
55
+					); ?>
56 56
                 </p>
57 57
             </div>
58 58
             <?php
59
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
60
-        }
61
-    }
62
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
59
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
60
+		}
61
+	}
62
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
63 63
 
64 64
 } else {
65
-    define('EE_MIN_PHP_VER_REQUIRED', '5.4.0');
66
-    if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
67
-        /**
68
-         * espresso_minimum_php_version_error
69
-         * @return void
70
-         */
71
-        function espresso_minimum_php_version_error()
72
-        {
73
-            ?>
65
+	define('EE_MIN_PHP_VER_REQUIRED', '5.4.0');
66
+	if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
67
+		/**
68
+		 * espresso_minimum_php_version_error
69
+		 * @return void
70
+		 */
71
+		function espresso_minimum_php_version_error()
72
+		{
73
+			?>
74 74
             <div class="error">
75 75
                 <p>
76 76
                     <?php
77
-                    printf(
78
-                        esc_html__(
79
-                            'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
-                            'event_espresso'
81
-                        ),
82
-                        EE_MIN_PHP_VER_REQUIRED,
83
-                        PHP_VERSION,
84
-                        '<br/>',
85
-                        '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
-                    );
87
-                    ?>
77
+					printf(
78
+						esc_html__(
79
+							'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
+							'event_espresso'
81
+						),
82
+						EE_MIN_PHP_VER_REQUIRED,
83
+						PHP_VERSION,
84
+						'<br/>',
85
+						'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
+					);
87
+					?>
88 88
                 </p>
89 89
             </div>
90 90
             <?php
91
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
92
-        }
91
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
92
+		}
93 93
 
94
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
-    } else {
96
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
-        /**
98
-         * espresso_version
99
-         * Returns the plugin version
100
-         *
101
-         * @return string
102
-         */
103
-        function espresso_version()
104
-        {
105
-            return apply_filters('FHEE__espresso__espresso_version', '4.9.61.rc.003');
106
-        }
94
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
+	} else {
96
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
+		/**
98
+		 * espresso_version
99
+		 * Returns the plugin version
100
+		 *
101
+		 * @return string
102
+		 */
103
+		function espresso_version()
104
+		{
105
+			return apply_filters('FHEE__espresso__espresso_version', '4.9.61.rc.003');
106
+		}
107 107
 
108
-        /**
109
-         * espresso_plugin_activation
110
-         * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
-         */
112
-        function espresso_plugin_activation()
113
-        {
114
-            update_option('ee_espresso_activation', true);
115
-        }
108
+		/**
109
+		 * espresso_plugin_activation
110
+		 * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
+		 */
112
+		function espresso_plugin_activation()
113
+		{
114
+			update_option('ee_espresso_activation', true);
115
+		}
116 116
 
117
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
117
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
118 118
 
119
-        require_once __DIR__ . '/core/bootstrap_espresso.php';
120
-        bootstrap_espresso();
121
-    }
119
+		require_once __DIR__ . '/core/bootstrap_espresso.php';
120
+		bootstrap_espresso();
121
+	}
122 122
 }
123 123
 if (! function_exists('espresso_deactivate_plugin')) {
124
-    /**
125
-     *    deactivate_plugin
126
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
-     *
128
-     * @access public
129
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
-     * @return    void
131
-     */
132
-    function espresso_deactivate_plugin($plugin_basename = '')
133
-    {
134
-        if (! function_exists('deactivate_plugins')) {
135
-            require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
-        }
137
-        unset($_GET['activate'], $_REQUEST['activate']);
138
-        deactivate_plugins($plugin_basename);
139
-    }
124
+	/**
125
+	 *    deactivate_plugin
126
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
+	 *
128
+	 * @access public
129
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
+	 * @return    void
131
+	 */
132
+	function espresso_deactivate_plugin($plugin_basename = '')
133
+	{
134
+		if (! function_exists('deactivate_plugins')) {
135
+			require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
+		}
137
+		unset($_GET['activate'], $_REQUEST['activate']);
138
+		deactivate_plugins($plugin_basename);
139
+	}
140 140
 }
Please login to merge, or discard this patch.
core/services/assets/Registry.php 2 patches
Indentation   +645 added lines, -645 removed lines patch added patch discarded remove patch
@@ -26,653 +26,653 @@
 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
-            $message = printf(
387
-                esc_html__(
388
-                    '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',
389
-                    'event_espresso'
390
-                ),
391
-                'Event Espresso',
392
-                $url_base,
393
-                'plugins_url',
394
-                'WP_PLUGIN_URL'
395
-            );
396
-            if ( WP_DEBUG ) {
397
-                throw new InvalidArgumentException(
398
-                    $message
399
-                );
400
-            }
401
-            if (is_admin()) {
402
-                EE_Error::add_error(
403
-                    $message
404
-                );
405
-            }
406
-            return;
407
-        }
408
-        $this->manifest_data[$namespace] = $this->decodeManifestFile($manifest_file);
409
-        if (! isset($this->manifest_data[$namespace]['url_base'])) {
410
-            $this->manifest_data[$namespace]['url_base'] = trailingslashit($url_base);
411
-        }
412
-    }
413
-
414
-
415
-
416
-    /**
417
-     * Decodes json from the provided manifest file.
418
-     *
419
-     * @since 4.9.59.p
420
-     * @param string $manifest_file Path to manifest file.
421
-     * @return array
422
-     * @throws InvalidFilePathException
423
-     */
424
-    private function decodeManifestFile($manifest_file)
425
-    {
426
-        if (! file_exists($manifest_file)) {
427
-            throw new InvalidFilePathException($manifest_file);
428
-        }
429
-        return json_decode(file_get_contents($manifest_file), true);
430
-    }
431
-
432
-
433
-
434
-    /**
435
-     * Verifies whether the given data exists already on the jsdata array.
436
-     * Overriding data is not allowed.
437
-     *
438
-     * @param string $key Index for data.
439
-     * @return bool        If valid then return true.
440
-     * @throws InvalidArgumentException if data already exists.
441
-     */
442
-    protected function verifyDataNotExisting($key)
443
-    {
444
-        if (isset($this->jsdata[$key])) {
445
-            if (is_array($this->jsdata[$key])) {
446
-                throw new InvalidArgumentException(
447
-                    sprintf(
448
-                        __(
449
-                            '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
+			$message = printf(
387
+				esc_html__(
388
+					'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',
389
+					'event_espresso'
390
+				),
391
+				'Event Espresso',
392
+				$url_base,
393
+				'plugins_url',
394
+				'WP_PLUGIN_URL'
395
+			);
396
+			if ( WP_DEBUG ) {
397
+				throw new InvalidArgumentException(
398
+					$message
399
+				);
400
+			}
401
+			if (is_admin()) {
402
+				EE_Error::add_error(
403
+					$message
404
+				);
405
+			}
406
+			return;
407
+		}
408
+		$this->manifest_data[$namespace] = $this->decodeManifestFile($manifest_file);
409
+		if (! isset($this->manifest_data[$namespace]['url_base'])) {
410
+			$this->manifest_data[$namespace]['url_base'] = trailingslashit($url_base);
411
+		}
412
+	}
413
+
414
+
415
+
416
+	/**
417
+	 * Decodes json from the provided manifest file.
418
+	 *
419
+	 * @since 4.9.59.p
420
+	 * @param string $manifest_file Path to manifest file.
421
+	 * @return array
422
+	 * @throws InvalidFilePathException
423
+	 */
424
+	private function decodeManifestFile($manifest_file)
425
+	{
426
+		if (! file_exists($manifest_file)) {
427
+			throw new InvalidFilePathException($manifest_file);
428
+		}
429
+		return json_decode(file_get_contents($manifest_file), true);
430
+	}
431
+
432
+
433
+
434
+	/**
435
+	 * Verifies whether the given data exists already on the jsdata array.
436
+	 * Overriding data is not allowed.
437
+	 *
438
+	 * @param string $key Index for data.
439
+	 * @return bool        If valid then return true.
440
+	 * @throws InvalidArgumentException if data already exists.
441
+	 */
442
+	protected function verifyDataNotExisting($key)
443
+	{
444
+		if (isset($this->jsdata[$key])) {
445
+			if (is_array($this->jsdata[$key])) {
446
+				throw new InvalidArgumentException(
447
+					sprintf(
448
+						__(
449
+							'The value for %1$s already exists in the Registry::eejs object.
450 450
                             Overrides are not allowed. Since the value of this data is an array, you may want to use the
451 451
                             %2$s method to push your value to the array.',
452
-                            'event_espresso'
453
-                        ),
454
-                        $key,
455
-                        'pushData()'
456
-                    )
457
-                );
458
-            }
459
-            throw new InvalidArgumentException(
460
-                sprintf(
461
-                    __(
462
-                        'The value for %1$s already exists in the Registry::eejs object. Overrides are not
452
+							'event_espresso'
453
+						),
454
+						$key,
455
+						'pushData()'
456
+					)
457
+				);
458
+			}
459
+			throw new InvalidArgumentException(
460
+				sprintf(
461
+					__(
462
+						'The value for %1$s already exists in the Registry::eejs object. Overrides are not
463 463
                         allowed.  Consider attaching your value to a different key',
464
-                        'event_espresso'
465
-                    ),
466
-                    $key
467
-                )
468
-            );
469
-        }
470
-        return true;
471
-    }
472
-
473
-
474
-
475
-    /**
476
-     * registers core default stylesheets
477
-     */
478
-    private function loadCoreCss()
479
-    {
480
-        if ($this->template_config->enable_default_style) {
481
-            $default_stylesheet_path = is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')
482
-                ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css'
483
-                : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css';
484
-            wp_register_style(
485
-                'espresso_default',
486
-                $default_stylesheet_path,
487
-                array('dashicons'),
488
-                EVENT_ESPRESSO_VERSION
489
-            );
490
-            //Load custom style sheet if available
491
-            if ($this->template_config->custom_style_sheet !== null) {
492
-                wp_register_style(
493
-                    'espresso_custom_css',
494
-                    EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet,
495
-                    array('espresso_default'),
496
-                    EVENT_ESPRESSO_VERSION
497
-                );
498
-            }
499
-        }
500
-    }
501
-
502
-
503
-
504
-    /**
505
-     * registers core default javascript
506
-     */
507
-    private function loadCoreJs()
508
-    {
509
-        // load core js
510
-        wp_register_script(
511
-            'espresso_core',
512
-            EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
513
-            array('jquery'),
514
-            EVENT_ESPRESSO_VERSION,
515
-            true
516
-        );
517
-    }
518
-
519
-
520
-
521
-    /**
522
-     * registers jQuery Validate for form validation
523
-     */
524
-    private function loadJqueryValidate()
525
-    {
526
-        // register jQuery Validate and additional methods
527
-        wp_register_script(
528
-            'jquery-validate',
529
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js',
530
-            array('jquery'),
531
-            '1.15.0',
532
-            true
533
-        );
534
-        wp_register_script(
535
-            'jquery-validate-extra-methods',
536
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js',
537
-            array('jquery', 'jquery-validate'),
538
-            '1.15.0',
539
-            true
540
-        );
541
-    }
542
-
543
-
544
-
545
-    /**
546
-     * registers accounting.js for performing client-side calculations
547
-     */
548
-    private function loadAccountingJs()
549
-    {
550
-        //accounting.js library
551
-        // @link http://josscrowcroft.github.io/accounting.js/
552
-        wp_register_script(
553
-            'ee-accounting-core',
554
-            EE_THIRD_PARTY_URL . 'accounting/accounting.js',
555
-            array('underscore'),
556
-            '0.3.2',
557
-            true
558
-        );
559
-        wp_register_script(
560
-            'ee-accounting',
561
-            EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js',
562
-            array('ee-accounting-core'),
563
-            EVENT_ESPRESSO_VERSION,
564
-            true
565
-        );
566
-    }
567
-
568
-
569
-
570
-    /**
571
-     * registers accounting.js for performing client-side calculations
572
-     */
573
-    private function localizeAccountingJs()
574
-    {
575
-        wp_localize_script(
576
-            'ee-accounting',
577
-            'EE_ACCOUNTING_CFG',
578
-            array(
579
-                'currency' => array(
580
-                    'symbol'    => $this->currency_config->sign,
581
-                    'format'    => array(
582
-                        'pos'  => $this->currency_config->sign_b4 ? '%s%v' : '%v%s',
583
-                        'neg'  => $this->currency_config->sign_b4 ? '- %s%v' : '- %v%s',
584
-                        'zero' => $this->currency_config->sign_b4 ? '%s--' : '--%s',
585
-                    ),
586
-                    'decimal'   => $this->currency_config->dec_mrk,
587
-                    'thousand'  => $this->currency_config->thsnds,
588
-                    'precision' => $this->currency_config->dec_plc,
589
-                ),
590
-                'number'   => array(
591
-                    'precision' => $this->currency_config->dec_plc,
592
-                    'thousand'  => $this->currency_config->thsnds,
593
-                    'decimal'   => $this->currency_config->dec_mrk,
594
-                ),
595
-            )
596
-        );
597
-        $this->addRegisteredScriptHandlesWithData('ee-accounting');
598
-    }
599
-
600
-
601
-
602
-    /**
603
-     * registers assets for cleaning your ears
604
-     */
605
-    private function loadQtipJs()
606
-    {
607
-        // qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook,
608
-        // can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' );
609
-        if (apply_filters('FHEE_load_qtip', false)) {
610
-            EEH_Qtip_Loader::instance()->register_and_enqueue();
611
-        }
612
-    }
613
-
614
-
615
-    /**
616
-     * This is used to set registered script handles that have data.
617
-     * @param string $script_handle
618
-     */
619
-    private function addRegisteredScriptHandlesWithData($script_handle)
620
-    {
621
-        $this->script_handles_with_data[$script_handle] = $script_handle;
622
-    }
623
-
624
-
625
-    /**
626
-     * Checks WP_Scripts for all of each script handle registered internally as having data and unsets from the
627
-     * Dependency stored in WP_Scripts if its set.
628
-     */
629
-    private function removeAlreadyRegisteredDataForScriptHandles()
630
-    {
631
-        if (empty($this->script_handles_with_data)) {
632
-            return;
633
-        }
634
-        foreach ($this->script_handles_with_data as $script_handle) {
635
-            $this->removeAlreadyRegisteredDataForScriptHandle($script_handle);
636
-        }
637
-    }
638
-
639
-
640
-    /**
641
-     * Removes any data dependency registered in WP_Scripts if its set.
642
-     * @param string $script_handle
643
-     */
644
-    private function removeAlreadyRegisteredDataForScriptHandle($script_handle)
645
-    {
646
-        if (isset($this->script_handles_with_data[$script_handle])) {
647
-            global $wp_scripts;
648
-            if ($wp_scripts->get_data($script_handle, 'data')) {
649
-                unset($wp_scripts->registered[$script_handle]->extra['data']);
650
-                unset($this->script_handles_with_data[$script_handle]);
651
-            }
652
-        }
653
-    }
654
-
655
-
656
-    /**
657
-     * Registers assets that are used in the WordPress admin.
658
-     */
659
-    private function registerAdminAssets()
660
-    {
661
-        wp_register_script(
662
-            'ee-wp-plugins-page',
663
-            $this->getJsUrl(self::ASSET_NAMESPACE, 'wp-plugins-page'),
664
-            array(
665
-                'jquery',
666
-                'ee-vendor-react'
667
-            ),
668
-            null,
669
-            true
670
-        );
671
-        wp_register_style(
672
-            'ee-wp-plugins-page',
673
-            $this->getCssUrl(self::ASSET_NAMESPACE, 'wp-plugins-page'),
674
-            array(),
675
-            null
676
-        );
677
-    }
464
+						'event_espresso'
465
+					),
466
+					$key
467
+				)
468
+			);
469
+		}
470
+		return true;
471
+	}
472
+
473
+
474
+
475
+	/**
476
+	 * registers core default stylesheets
477
+	 */
478
+	private function loadCoreCss()
479
+	{
480
+		if ($this->template_config->enable_default_style) {
481
+			$default_stylesheet_path = is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')
482
+				? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css'
483
+				: EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css';
484
+			wp_register_style(
485
+				'espresso_default',
486
+				$default_stylesheet_path,
487
+				array('dashicons'),
488
+				EVENT_ESPRESSO_VERSION
489
+			);
490
+			//Load custom style sheet if available
491
+			if ($this->template_config->custom_style_sheet !== null) {
492
+				wp_register_style(
493
+					'espresso_custom_css',
494
+					EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet,
495
+					array('espresso_default'),
496
+					EVENT_ESPRESSO_VERSION
497
+				);
498
+			}
499
+		}
500
+	}
501
+
502
+
503
+
504
+	/**
505
+	 * registers core default javascript
506
+	 */
507
+	private function loadCoreJs()
508
+	{
509
+		// load core js
510
+		wp_register_script(
511
+			'espresso_core',
512
+			EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
513
+			array('jquery'),
514
+			EVENT_ESPRESSO_VERSION,
515
+			true
516
+		);
517
+	}
518
+
519
+
520
+
521
+	/**
522
+	 * registers jQuery Validate for form validation
523
+	 */
524
+	private function loadJqueryValidate()
525
+	{
526
+		// register jQuery Validate and additional methods
527
+		wp_register_script(
528
+			'jquery-validate',
529
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js',
530
+			array('jquery'),
531
+			'1.15.0',
532
+			true
533
+		);
534
+		wp_register_script(
535
+			'jquery-validate-extra-methods',
536
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js',
537
+			array('jquery', 'jquery-validate'),
538
+			'1.15.0',
539
+			true
540
+		);
541
+	}
542
+
543
+
544
+
545
+	/**
546
+	 * registers accounting.js for performing client-side calculations
547
+	 */
548
+	private function loadAccountingJs()
549
+	{
550
+		//accounting.js library
551
+		// @link http://josscrowcroft.github.io/accounting.js/
552
+		wp_register_script(
553
+			'ee-accounting-core',
554
+			EE_THIRD_PARTY_URL . 'accounting/accounting.js',
555
+			array('underscore'),
556
+			'0.3.2',
557
+			true
558
+		);
559
+		wp_register_script(
560
+			'ee-accounting',
561
+			EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js',
562
+			array('ee-accounting-core'),
563
+			EVENT_ESPRESSO_VERSION,
564
+			true
565
+		);
566
+	}
567
+
568
+
569
+
570
+	/**
571
+	 * registers accounting.js for performing client-side calculations
572
+	 */
573
+	private function localizeAccountingJs()
574
+	{
575
+		wp_localize_script(
576
+			'ee-accounting',
577
+			'EE_ACCOUNTING_CFG',
578
+			array(
579
+				'currency' => array(
580
+					'symbol'    => $this->currency_config->sign,
581
+					'format'    => array(
582
+						'pos'  => $this->currency_config->sign_b4 ? '%s%v' : '%v%s',
583
+						'neg'  => $this->currency_config->sign_b4 ? '- %s%v' : '- %v%s',
584
+						'zero' => $this->currency_config->sign_b4 ? '%s--' : '--%s',
585
+					),
586
+					'decimal'   => $this->currency_config->dec_mrk,
587
+					'thousand'  => $this->currency_config->thsnds,
588
+					'precision' => $this->currency_config->dec_plc,
589
+				),
590
+				'number'   => array(
591
+					'precision' => $this->currency_config->dec_plc,
592
+					'thousand'  => $this->currency_config->thsnds,
593
+					'decimal'   => $this->currency_config->dec_mrk,
594
+				),
595
+			)
596
+		);
597
+		$this->addRegisteredScriptHandlesWithData('ee-accounting');
598
+	}
599
+
600
+
601
+
602
+	/**
603
+	 * registers assets for cleaning your ears
604
+	 */
605
+	private function loadQtipJs()
606
+	{
607
+		// qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook,
608
+		// can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' );
609
+		if (apply_filters('FHEE_load_qtip', false)) {
610
+			EEH_Qtip_Loader::instance()->register_and_enqueue();
611
+		}
612
+	}
613
+
614
+
615
+	/**
616
+	 * This is used to set registered script handles that have data.
617
+	 * @param string $script_handle
618
+	 */
619
+	private function addRegisteredScriptHandlesWithData($script_handle)
620
+	{
621
+		$this->script_handles_with_data[$script_handle] = $script_handle;
622
+	}
623
+
624
+
625
+	/**
626
+	 * Checks WP_Scripts for all of each script handle registered internally as having data and unsets from the
627
+	 * Dependency stored in WP_Scripts if its set.
628
+	 */
629
+	private function removeAlreadyRegisteredDataForScriptHandles()
630
+	{
631
+		if (empty($this->script_handles_with_data)) {
632
+			return;
633
+		}
634
+		foreach ($this->script_handles_with_data as $script_handle) {
635
+			$this->removeAlreadyRegisteredDataForScriptHandle($script_handle);
636
+		}
637
+	}
638
+
639
+
640
+	/**
641
+	 * Removes any data dependency registered in WP_Scripts if its set.
642
+	 * @param string $script_handle
643
+	 */
644
+	private function removeAlreadyRegisteredDataForScriptHandle($script_handle)
645
+	{
646
+		if (isset($this->script_handles_with_data[$script_handle])) {
647
+			global $wp_scripts;
648
+			if ($wp_scripts->get_data($script_handle, 'data')) {
649
+				unset($wp_scripts->registered[$script_handle]->extra['data']);
650
+				unset($this->script_handles_with_data[$script_handle]);
651
+			}
652
+		}
653
+	}
654
+
655
+
656
+	/**
657
+	 * Registers assets that are used in the WordPress admin.
658
+	 */
659
+	private function registerAdminAssets()
660
+	{
661
+		wp_register_script(
662
+			'ee-wp-plugins-page',
663
+			$this->getJsUrl(self::ASSET_NAMESPACE, 'wp-plugins-page'),
664
+			array(
665
+				'jquery',
666
+				'ee-vendor-react'
667
+			),
668
+			null,
669
+			true
670
+		);
671
+		wp_register_style(
672
+			'ee-wp-plugins-page',
673
+			$this->getCssUrl(self::ASSET_NAMESPACE, 'wp-plugins-page'),
674
+			array(),
675
+			null
676
+		);
677
+	}
678 678
 }
Please login to merge, or discard this patch.
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.
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
                 'plugins_url',
394 394
                 'WP_PLUGIN_URL'
395 395
             );
396
-            if ( WP_DEBUG ) {
396
+            if (WP_DEBUG) {
397 397
                 throw new InvalidArgumentException(
398 398
                     $message
399 399
                 );
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
             return;
407 407
         }
408 408
         $this->manifest_data[$namespace] = $this->decodeManifestFile($manifest_file);
409
-        if (! isset($this->manifest_data[$namespace]['url_base'])) {
409
+        if ( ! isset($this->manifest_data[$namespace]['url_base'])) {
410 410
             $this->manifest_data[$namespace]['url_base'] = trailingslashit($url_base);
411 411
         }
412 412
     }
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
      */
424 424
     private function decodeManifestFile($manifest_file)
425 425
     {
426
-        if (! file_exists($manifest_file)) {
426
+        if ( ! file_exists($manifest_file)) {
427 427
             throw new InvalidFilePathException($manifest_file);
428 428
         }
429 429
         return json_decode(file_get_contents($manifest_file), true);
@@ -478,9 +478,9 @@  discard block
 block discarded – undo
478 478
     private function loadCoreCss()
479 479
     {
480 480
         if ($this->template_config->enable_default_style) {
481
-            $default_stylesheet_path = is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')
481
+            $default_stylesheet_path = is_readable(EVENT_ESPRESSO_UPLOAD_DIR.'css/style.css')
482 482
                 ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css'
483
-                : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css';
483
+                : EE_GLOBAL_ASSETS_URL.'css/espresso_default.css';
484 484
             wp_register_style(
485 485
                 'espresso_default',
486 486
                 $default_stylesheet_path,
@@ -491,7 +491,7 @@  discard block
 block discarded – undo
491 491
             if ($this->template_config->custom_style_sheet !== null) {
492 492
                 wp_register_style(
493 493
                     'espresso_custom_css',
494
-                    EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet,
494
+                    EVENT_ESPRESSO_UPLOAD_URL.'css/'.$this->template_config->custom_style_sheet,
495 495
                     array('espresso_default'),
496 496
                     EVENT_ESPRESSO_VERSION
497 497
                 );
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
         // load core js
510 510
         wp_register_script(
511 511
             'espresso_core',
512
-            EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
512
+            EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js',
513 513
             array('jquery'),
514 514
             EVENT_ESPRESSO_VERSION,
515 515
             true
@@ -526,14 +526,14 @@  discard block
 block discarded – undo
526 526
         // register jQuery Validate and additional methods
527 527
         wp_register_script(
528 528
             'jquery-validate',
529
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js',
529
+            EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.min.js',
530 530
             array('jquery'),
531 531
             '1.15.0',
532 532
             true
533 533
         );
534 534
         wp_register_script(
535 535
             'jquery-validate-extra-methods',
536
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js',
536
+            EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.additional-methods.min.js',
537 537
             array('jquery', 'jquery-validate'),
538 538
             '1.15.0',
539 539
             true
@@ -551,14 +551,14 @@  discard block
 block discarded – undo
551 551
         // @link http://josscrowcroft.github.io/accounting.js/
552 552
         wp_register_script(
553 553
             'ee-accounting-core',
554
-            EE_THIRD_PARTY_URL . 'accounting/accounting.js',
554
+            EE_THIRD_PARTY_URL.'accounting/accounting.js',
555 555
             array('underscore'),
556 556
             '0.3.2',
557 557
             true
558 558
         );
559 559
         wp_register_script(
560 560
             'ee-accounting',
561
-            EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js',
561
+            EE_GLOBAL_ASSETS_URL.'scripts/ee-accounting-config.js',
562 562
             array('ee-accounting-core'),
563 563
             EVENT_ESPRESSO_VERSION,
564 564
             true
Please login to merge, or discard this patch.