Completed
Branch master (20d56d)
by
unknown
49:08 queued 40:01
created
core/services/assets/Registry.php 2 patches
Indentation   +731 added lines, -731 removed lines patch added patch discarded remove patch
@@ -27,742 +27,742 @@
 block discarded – undo
27 27
 class Registry
28 28
 {
29 29
 
30
-    const FILE_NAME_BUILD_MANIFEST = 'build-manifest.json';
31
-
32
-    /**
33
-     * @var AssetCollection $assets
34
-     */
35
-    protected $assets;
36
-
37
-    /**
38
-     * @var I18nRegistry
39
-     */
40
-    private $i18n_registry;
41
-
42
-    /**
43
-     * This holds the jsdata data object that will be exposed on pages that enqueue the `eejs-core` script.
44
-     *
45
-     * @var array
46
-     */
47
-    protected $jsdata = array();
48
-
49
-    /**
50
-     * This keeps track of all scripts with registered data.  It is used to prevent duplicate data objects setup in the
51
-     * page source.
52
-     *
53
-     * @var array
54
-     */
55
-    private $script_handles_with_data = array();
56
-
57
-
58
-    /**
59
-     * Holds the manifest data obtained from registered manifest files.
60
-     * Manifests are maps of asset chunk name to actual built asset file names.
61
-     * Shape of this array is:
62
-     * array(
63
-     *  'some_namespace_slug' => array(
64
-     *      'some_chunk_name' => array(
65
-     *          'js' => 'filename.js'
66
-     *          'css' => 'filename.js'
67
-     *      ),
68
-     *      'url_base' => 'https://baseurl.com/to/assets
69
-     *  )
70
-     * )
71
-     *
72
-     * @var array
73
-     */
74
-    private $manifest_data = array();
75
-
76
-
77
-    /**
78
-     * Holds any dependency data obtained from registered dependency map json.
79
-     * Dependency map json is generated via the @wordpress/dependency-extraction-webpack-plugin via the webpack config.
80
-     * @see https://github.com/WordPress/gutenberg/tree/master/packages/dependency-extraction-webpack-plugin
81
-     *
82
-     * @var array
83
-     */
84
-    private $dependencies_data = [];
85
-
86
-
87
-    /**
88
-     * This is a known array of possible wp css handles that correspond to what may be exposed as dependencies in our
89
-     * build process.  Currently the dependency export process in webpack does not consider css imports, so we derive
90
-     * them via the js dependencies (WP uses the same handle for both js and css). This is a list of known handles that
91
-     * are used for both js and css.
92
-     * @var array
93
-     */
94
-    private $wp_css_handle_dependencies = [
95
-        'wp-components',
96
-        'wp-block-editor',
97
-        'wp-block-library',
98
-        'wp-edit-post',
99
-        'wp-edit-widgets',
100
-        'wp-editor',
101
-        'wp-format-library',
102
-        'wp-list-reusable-blocks',
103
-        'wp-nux',
104
-    ];
105
-
106
-
107
-    /**
108
-     * Registry constructor.
109
-     * Hooking into WP actions for script registry.
110
-     *
111
-     * @param AssetCollection      $assets
112
-     * @param I18nRegistry         $i18n_registry
113
-     * @throws InvalidArgumentException
114
-     * @throws InvalidDataTypeException
115
-     * @throws InvalidInterfaceException
116
-     */
117
-    public function __construct(AssetCollection $assets, I18nRegistry $i18n_registry)
118
-    {
119
-        $this->assets = $assets;
120
-        $this->i18n_registry = $i18n_registry;
121
-        add_action('wp_enqueue_scripts', array($this, 'registerManifestFiles'), 1);
122
-        add_action('admin_enqueue_scripts', array($this, 'registerManifestFiles'), 1);
123
-        add_action('wp_enqueue_scripts', array($this, 'registerScriptsAndStyles'), 3);
124
-        add_action('admin_enqueue_scripts', array($this, 'registerScriptsAndStyles'), 3);
125
-        add_action('wp_enqueue_scripts', array($this, 'enqueueData'), 4);
126
-        add_action('admin_enqueue_scripts', array($this, 'enqueueData'), 4);
127
-        add_action('wp_print_footer_scripts', array($this, 'enqueueData'), 1);
128
-        add_action('admin_print_footer_scripts', array($this, 'enqueueData'), 1);
129
-    }
130
-
131
-
132
-    /**
133
-     * For classes that have Registry as a dependency, this provides a handy way to register script handles for i18n
134
-     * translation handling.
135
-     *
136
-     * @return I18nRegistry
137
-     */
138
-    public function getI18nRegistry()
139
-    {
140
-        return $this->i18n_registry;
141
-    }
142
-
143
-
144
-    /**
145
-     * Callback for the wp_enqueue_scripts actions used to register assets.
146
-     *
147
-     * @since 4.9.62.p
148
-     * @throws Exception
149
-     */
150
-    public function registerScriptsAndStyles()
151
-    {
152
-        try {
153
-            $this->registerScripts($this->assets->getJavascriptAssets());
154
-            $this->registerStyles($this->assets->getStylesheetAssets());
155
-        } catch (Exception $exception) {
156
-            new ExceptionStackTraceDisplay($exception);
157
-        }
158
-    }
159
-
160
-
161
-    /**
162
-     * Registers JS assets with WP core
163
-     *
164
-     * @since 4.9.62.p
165
-     * @param JavascriptAsset[] $scripts
166
-     * @throws AssetRegistrationException
167
-     * @throws InvalidDataTypeException
168
-     */
169
-    public function registerScripts(array $scripts)
170
-    {
171
-        foreach ($scripts as $script) {
172
-            // skip to next script if this has already been done
173
-            if ($script->isRegistered()) {
174
-                continue;
175
-            }
176
-            do_action(
177
-                'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__before_script',
178
-                $script
179
-            );
180
-            $registered = wp_register_script(
181
-                $script->handle(),
182
-                $script->source(),
183
-                $script->dependencies(),
184
-                $script->version(),
185
-                $script->loadInFooter()
186
-            );
187
-            if (! $registered && $this->debug()) {
188
-                throw new AssetRegistrationException($script->handle());
189
-            }
190
-            $script->setRegistered($registered);
191
-            if ($script->requiresTranslation()) {
192
-                $this->registerTranslation($script->handle());
193
-            }
194
-            do_action(
195
-                'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__after_script',
196
-                $script
197
-            );
198
-        }
199
-    }
200
-
201
-
202
-    /**
203
-     * Registers CSS assets with WP core
204
-     *
205
-     * @since 4.9.62.p
206
-     * @param StylesheetAsset[] $styles
207
-     * @throws InvalidDataTypeException
208
-     */
209
-    public function registerStyles(array $styles)
210
-    {
211
-        foreach ($styles as $style) {
212
-            // skip to next style if this has already been done
213
-            if ($style->isRegistered()) {
214
-                continue;
215
-            }
216
-            do_action(
217
-                'AHEE__EventEspresso_core_services_assets_Registry__registerStyles__before_style',
218
-                $style
219
-            );
220
-            wp_register_style(
221
-                $style->handle(),
222
-                $style->source(),
223
-                $style->dependencies(),
224
-                $style->version(),
225
-                $style->media()
226
-            );
227
-            $style->setRegistered();
228
-            do_action(
229
-                'AHEE__EventEspresso_core_services_assets_Registry__registerStyles__after_style',
230
-                $style
231
-            );
232
-        }
233
-    }
234
-
235
-
236
-    /**
237
-     * Call back for the script print in frontend and backend.
238
-     * Used to call wp_localize_scripts so that data can be added throughout the runtime until this later hook point.
239
-     *
240
-     * @since 4.9.31.rc.015
241
-     */
242
-    public function enqueueData()
243
-    {
244
-        $this->removeAlreadyRegisteredDataForScriptHandles();
245
-        wp_add_inline_script(
246
-            'eejs-core',
247
-            'var eejsdata=' . wp_json_encode(array('data' => $this->jsdata)),
248
-            'before'
249
-        );
250
-        $scripts = $this->assets->getJavascriptAssetsWithData();
251
-        foreach ($scripts as $script) {
252
-            $this->addRegisteredScriptHandlesWithData($script->handle());
253
-            if ($script->hasInlineDataCallback()) {
254
-                $localize = $script->inlineDataCallback();
255
-                $localize();
256
-            }
257
-        }
258
-    }
259
-
260
-
261
-    /**
262
-     * Used to add data to eejs.data object.
263
-     * Note:  Overriding existing data is not allowed.
264
-     * Data will be accessible as a javascript object when you list `eejs-core` as a dependency for your javascript.
265
-     * If the data you add is something like this:
266
-     *  $this->addData( 'my_plugin_data', array( 'foo' => 'gar' ) );
267
-     * It will be exposed in the page source as:
268
-     *  eejs.data.my_plugin_data.foo == gar
269
-     *
270
-     * @param string       $key   Key used to access your data
271
-     * @param string|array $value Value to attach to key
272
-     * @throws InvalidArgumentException
273
-     */
274
-    public function addData($key, $value)
275
-    {
276
-        if ($this->verifyDataNotExisting($key)) {
277
-            $this->jsdata[ $key ] = $value;
278
-        }
279
-    }
280
-
281
-
282
-    /**
283
-     * Similar to addData except this allows for users to push values to an existing key where the values on key are
284
-     * elements in an array.
285
-     *
286
-     * When you use this method, the value you include will be merged with the array on $key.
287
-     * So if the $key was 'test' and you added a value of ['my_data'] then it would be represented in the javascript
288
-     * object like this, eejs.data.test = [ my_data,
289
-     * ]
290
-     * If there has already been a scalar value attached to the data object given key (via addData for instance), then
291
-     * this will throw an exception.
292
-     *
293
-     * Caution: Only add data using this method if you are okay with the potential for additional data added on the same
294
-     * key potentially overriding the existing data on merge (specifically with associative arrays).
295
-     *
296
-     * @param string       $key   Key to attach data to.
297
-     * @param string|array $value Value being registered.
298
-     * @throws InvalidArgumentException
299
-     */
300
-    public function pushData($key, $value)
301
-    {
302
-        if (isset($this->jsdata[ $key ])
303
-            && ! is_array($this->jsdata[ $key ])
304
-        ) {
305
-            if (! $this->debug()) {
306
-                return;
307
-            }
308
-            throw new InvalidArgumentException(
309
-                sprintf(
310
-                    __(
311
-                        'The value for %1$s is already set and it is not an array. The %2$s method can only be used to
30
+	const FILE_NAME_BUILD_MANIFEST = 'build-manifest.json';
31
+
32
+	/**
33
+	 * @var AssetCollection $assets
34
+	 */
35
+	protected $assets;
36
+
37
+	/**
38
+	 * @var I18nRegistry
39
+	 */
40
+	private $i18n_registry;
41
+
42
+	/**
43
+	 * This holds the jsdata data object that will be exposed on pages that enqueue the `eejs-core` script.
44
+	 *
45
+	 * @var array
46
+	 */
47
+	protected $jsdata = array();
48
+
49
+	/**
50
+	 * This keeps track of all scripts with registered data.  It is used to prevent duplicate data objects setup in the
51
+	 * page source.
52
+	 *
53
+	 * @var array
54
+	 */
55
+	private $script_handles_with_data = array();
56
+
57
+
58
+	/**
59
+	 * Holds the manifest data obtained from registered manifest files.
60
+	 * Manifests are maps of asset chunk name to actual built asset file names.
61
+	 * Shape of this array is:
62
+	 * array(
63
+	 *  'some_namespace_slug' => array(
64
+	 *      'some_chunk_name' => array(
65
+	 *          'js' => 'filename.js'
66
+	 *          'css' => 'filename.js'
67
+	 *      ),
68
+	 *      'url_base' => 'https://baseurl.com/to/assets
69
+	 *  )
70
+	 * )
71
+	 *
72
+	 * @var array
73
+	 */
74
+	private $manifest_data = array();
75
+
76
+
77
+	/**
78
+	 * Holds any dependency data obtained from registered dependency map json.
79
+	 * Dependency map json is generated via the @wordpress/dependency-extraction-webpack-plugin via the webpack config.
80
+	 * @see https://github.com/WordPress/gutenberg/tree/master/packages/dependency-extraction-webpack-plugin
81
+	 *
82
+	 * @var array
83
+	 */
84
+	private $dependencies_data = [];
85
+
86
+
87
+	/**
88
+	 * This is a known array of possible wp css handles that correspond to what may be exposed as dependencies in our
89
+	 * build process.  Currently the dependency export process in webpack does not consider css imports, so we derive
90
+	 * them via the js dependencies (WP uses the same handle for both js and css). This is a list of known handles that
91
+	 * are used for both js and css.
92
+	 * @var array
93
+	 */
94
+	private $wp_css_handle_dependencies = [
95
+		'wp-components',
96
+		'wp-block-editor',
97
+		'wp-block-library',
98
+		'wp-edit-post',
99
+		'wp-edit-widgets',
100
+		'wp-editor',
101
+		'wp-format-library',
102
+		'wp-list-reusable-blocks',
103
+		'wp-nux',
104
+	];
105
+
106
+
107
+	/**
108
+	 * Registry constructor.
109
+	 * Hooking into WP actions for script registry.
110
+	 *
111
+	 * @param AssetCollection      $assets
112
+	 * @param I18nRegistry         $i18n_registry
113
+	 * @throws InvalidArgumentException
114
+	 * @throws InvalidDataTypeException
115
+	 * @throws InvalidInterfaceException
116
+	 */
117
+	public function __construct(AssetCollection $assets, I18nRegistry $i18n_registry)
118
+	{
119
+		$this->assets = $assets;
120
+		$this->i18n_registry = $i18n_registry;
121
+		add_action('wp_enqueue_scripts', array($this, 'registerManifestFiles'), 1);
122
+		add_action('admin_enqueue_scripts', array($this, 'registerManifestFiles'), 1);
123
+		add_action('wp_enqueue_scripts', array($this, 'registerScriptsAndStyles'), 3);
124
+		add_action('admin_enqueue_scripts', array($this, 'registerScriptsAndStyles'), 3);
125
+		add_action('wp_enqueue_scripts', array($this, 'enqueueData'), 4);
126
+		add_action('admin_enqueue_scripts', array($this, 'enqueueData'), 4);
127
+		add_action('wp_print_footer_scripts', array($this, 'enqueueData'), 1);
128
+		add_action('admin_print_footer_scripts', array($this, 'enqueueData'), 1);
129
+	}
130
+
131
+
132
+	/**
133
+	 * For classes that have Registry as a dependency, this provides a handy way to register script handles for i18n
134
+	 * translation handling.
135
+	 *
136
+	 * @return I18nRegistry
137
+	 */
138
+	public function getI18nRegistry()
139
+	{
140
+		return $this->i18n_registry;
141
+	}
142
+
143
+
144
+	/**
145
+	 * Callback for the wp_enqueue_scripts actions used to register assets.
146
+	 *
147
+	 * @since 4.9.62.p
148
+	 * @throws Exception
149
+	 */
150
+	public function registerScriptsAndStyles()
151
+	{
152
+		try {
153
+			$this->registerScripts($this->assets->getJavascriptAssets());
154
+			$this->registerStyles($this->assets->getStylesheetAssets());
155
+		} catch (Exception $exception) {
156
+			new ExceptionStackTraceDisplay($exception);
157
+		}
158
+	}
159
+
160
+
161
+	/**
162
+	 * Registers JS assets with WP core
163
+	 *
164
+	 * @since 4.9.62.p
165
+	 * @param JavascriptAsset[] $scripts
166
+	 * @throws AssetRegistrationException
167
+	 * @throws InvalidDataTypeException
168
+	 */
169
+	public function registerScripts(array $scripts)
170
+	{
171
+		foreach ($scripts as $script) {
172
+			// skip to next script if this has already been done
173
+			if ($script->isRegistered()) {
174
+				continue;
175
+			}
176
+			do_action(
177
+				'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__before_script',
178
+				$script
179
+			);
180
+			$registered = wp_register_script(
181
+				$script->handle(),
182
+				$script->source(),
183
+				$script->dependencies(),
184
+				$script->version(),
185
+				$script->loadInFooter()
186
+			);
187
+			if (! $registered && $this->debug()) {
188
+				throw new AssetRegistrationException($script->handle());
189
+			}
190
+			$script->setRegistered($registered);
191
+			if ($script->requiresTranslation()) {
192
+				$this->registerTranslation($script->handle());
193
+			}
194
+			do_action(
195
+				'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__after_script',
196
+				$script
197
+			);
198
+		}
199
+	}
200
+
201
+
202
+	/**
203
+	 * Registers CSS assets with WP core
204
+	 *
205
+	 * @since 4.9.62.p
206
+	 * @param StylesheetAsset[] $styles
207
+	 * @throws InvalidDataTypeException
208
+	 */
209
+	public function registerStyles(array $styles)
210
+	{
211
+		foreach ($styles as $style) {
212
+			// skip to next style if this has already been done
213
+			if ($style->isRegistered()) {
214
+				continue;
215
+			}
216
+			do_action(
217
+				'AHEE__EventEspresso_core_services_assets_Registry__registerStyles__before_style',
218
+				$style
219
+			);
220
+			wp_register_style(
221
+				$style->handle(),
222
+				$style->source(),
223
+				$style->dependencies(),
224
+				$style->version(),
225
+				$style->media()
226
+			);
227
+			$style->setRegistered();
228
+			do_action(
229
+				'AHEE__EventEspresso_core_services_assets_Registry__registerStyles__after_style',
230
+				$style
231
+			);
232
+		}
233
+	}
234
+
235
+
236
+	/**
237
+	 * Call back for the script print in frontend and backend.
238
+	 * Used to call wp_localize_scripts so that data can be added throughout the runtime until this later hook point.
239
+	 *
240
+	 * @since 4.9.31.rc.015
241
+	 */
242
+	public function enqueueData()
243
+	{
244
+		$this->removeAlreadyRegisteredDataForScriptHandles();
245
+		wp_add_inline_script(
246
+			'eejs-core',
247
+			'var eejsdata=' . wp_json_encode(array('data' => $this->jsdata)),
248
+			'before'
249
+		);
250
+		$scripts = $this->assets->getJavascriptAssetsWithData();
251
+		foreach ($scripts as $script) {
252
+			$this->addRegisteredScriptHandlesWithData($script->handle());
253
+			if ($script->hasInlineDataCallback()) {
254
+				$localize = $script->inlineDataCallback();
255
+				$localize();
256
+			}
257
+		}
258
+	}
259
+
260
+
261
+	/**
262
+	 * Used to add data to eejs.data object.
263
+	 * Note:  Overriding existing data is not allowed.
264
+	 * Data will be accessible as a javascript object when you list `eejs-core` as a dependency for your javascript.
265
+	 * If the data you add is something like this:
266
+	 *  $this->addData( 'my_plugin_data', array( 'foo' => 'gar' ) );
267
+	 * It will be exposed in the page source as:
268
+	 *  eejs.data.my_plugin_data.foo == gar
269
+	 *
270
+	 * @param string       $key   Key used to access your data
271
+	 * @param string|array $value Value to attach to key
272
+	 * @throws InvalidArgumentException
273
+	 */
274
+	public function addData($key, $value)
275
+	{
276
+		if ($this->verifyDataNotExisting($key)) {
277
+			$this->jsdata[ $key ] = $value;
278
+		}
279
+	}
280
+
281
+
282
+	/**
283
+	 * Similar to addData except this allows for users to push values to an existing key where the values on key are
284
+	 * elements in an array.
285
+	 *
286
+	 * When you use this method, the value you include will be merged with the array on $key.
287
+	 * So if the $key was 'test' and you added a value of ['my_data'] then it would be represented in the javascript
288
+	 * object like this, eejs.data.test = [ my_data,
289
+	 * ]
290
+	 * If there has already been a scalar value attached to the data object given key (via addData for instance), then
291
+	 * this will throw an exception.
292
+	 *
293
+	 * Caution: Only add data using this method if you are okay with the potential for additional data added on the same
294
+	 * key potentially overriding the existing data on merge (specifically with associative arrays).
295
+	 *
296
+	 * @param string       $key   Key to attach data to.
297
+	 * @param string|array $value Value being registered.
298
+	 * @throws InvalidArgumentException
299
+	 */
300
+	public function pushData($key, $value)
301
+	{
302
+		if (isset($this->jsdata[ $key ])
303
+			&& ! is_array($this->jsdata[ $key ])
304
+		) {
305
+			if (! $this->debug()) {
306
+				return;
307
+			}
308
+			throw new InvalidArgumentException(
309
+				sprintf(
310
+					__(
311
+						'The value for %1$s is already set and it is not an array. The %2$s method can only be used to
312 312
                          push values to this data element when it is an array.',
313
-                        'event_espresso'
314
-                    ),
315
-                    $key,
316
-                    __METHOD__
317
-                )
318
-            );
319
-        }
320
-        if ( ! isset( $this->jsdata[ $key ] ) ) {
321
-            $this->jsdata[ $key ] = is_array($value) ? $value : [$value];
322
-        } else {
323
-            $this->jsdata[ $key ] = array_merge( $this->jsdata[$key], (array) $value);
324
-        }
325
-    }
326
-
327
-
328
-    /**
329
-     * Used to set content used by javascript for a template.
330
-     * Note: Overrides of existing registered templates are not allowed.
331
-     *
332
-     * @param string $template_reference
333
-     * @param string $template_content
334
-     * @throws InvalidArgumentException
335
-     */
336
-    public function addTemplate($template_reference, $template_content)
337
-    {
338
-        if (! isset($this->jsdata['templates'])) {
339
-            $this->jsdata['templates'] = array();
340
-        }
341
-        //no overrides allowed.
342
-        if (isset($this->jsdata['templates'][ $template_reference ])) {
343
-            if (! $this->debug()) {
344
-                return;
345
-            }
346
-            throw new InvalidArgumentException(
347
-                sprintf(
348
-                    __(
349
-                        'The %1$s key already exists for the templates array in the js data array.  No overrides are allowed.',
350
-                        'event_espresso'
351
-                    ),
352
-                    $template_reference
353
-                )
354
-            );
355
-        }
356
-        $this->jsdata['templates'][ $template_reference ] = $template_content;
357
-    }
358
-
359
-
360
-    /**
361
-     * Retrieve the template content already registered for the given reference.
362
-     *
363
-     * @param string $template_reference
364
-     * @return string
365
-     */
366
-    public function getTemplate($template_reference)
367
-    {
368
-        return isset($this->jsdata['templates'][ $template_reference ])
369
-            ? $this->jsdata['templates'][ $template_reference ]
370
-            : '';
371
-    }
372
-
373
-
374
-    /**
375
-     * Retrieve registered data.
376
-     *
377
-     * @param string $key Name of key to attach data to.
378
-     * @return mixed                If there is no for the given key, then false is returned.
379
-     */
380
-    public function getData($key)
381
-    {
382
-        return isset($this->jsdata[ $key ])
383
-            ? $this->jsdata[ $key ]
384
-            : false;
385
-    }
386
-
387
-
388
-    /**
389
-     * Verifies whether the given data exists already on the jsdata array.
390
-     * Overriding data is not allowed.
391
-     *
392
-     * @param string $key Index for data.
393
-     * @return bool        If valid then return true.
394
-     * @throws InvalidArgumentException if data already exists.
395
-     */
396
-    protected function verifyDataNotExisting($key)
397
-    {
398
-        if (isset($this->jsdata[ $key ])) {
399
-            if (! $this->debug()) {
400
-                return false;
401
-            }
402
-            if (is_array($this->jsdata[ $key ])) {
403
-                throw new InvalidArgumentException(
404
-                    sprintf(
405
-                        __(
406
-                            'The value for %1$s already exists in the Registry::eejs object.
313
+						'event_espresso'
314
+					),
315
+					$key,
316
+					__METHOD__
317
+				)
318
+			);
319
+		}
320
+		if ( ! isset( $this->jsdata[ $key ] ) ) {
321
+			$this->jsdata[ $key ] = is_array($value) ? $value : [$value];
322
+		} else {
323
+			$this->jsdata[ $key ] = array_merge( $this->jsdata[$key], (array) $value);
324
+		}
325
+	}
326
+
327
+
328
+	/**
329
+	 * Used to set content used by javascript for a template.
330
+	 * Note: Overrides of existing registered templates are not allowed.
331
+	 *
332
+	 * @param string $template_reference
333
+	 * @param string $template_content
334
+	 * @throws InvalidArgumentException
335
+	 */
336
+	public function addTemplate($template_reference, $template_content)
337
+	{
338
+		if (! isset($this->jsdata['templates'])) {
339
+			$this->jsdata['templates'] = array();
340
+		}
341
+		//no overrides allowed.
342
+		if (isset($this->jsdata['templates'][ $template_reference ])) {
343
+			if (! $this->debug()) {
344
+				return;
345
+			}
346
+			throw new InvalidArgumentException(
347
+				sprintf(
348
+					__(
349
+						'The %1$s key already exists for the templates array in the js data array.  No overrides are allowed.',
350
+						'event_espresso'
351
+					),
352
+					$template_reference
353
+				)
354
+			);
355
+		}
356
+		$this->jsdata['templates'][ $template_reference ] = $template_content;
357
+	}
358
+
359
+
360
+	/**
361
+	 * Retrieve the template content already registered for the given reference.
362
+	 *
363
+	 * @param string $template_reference
364
+	 * @return string
365
+	 */
366
+	public function getTemplate($template_reference)
367
+	{
368
+		return isset($this->jsdata['templates'][ $template_reference ])
369
+			? $this->jsdata['templates'][ $template_reference ]
370
+			: '';
371
+	}
372
+
373
+
374
+	/**
375
+	 * Retrieve registered data.
376
+	 *
377
+	 * @param string $key Name of key to attach data to.
378
+	 * @return mixed                If there is no for the given key, then false is returned.
379
+	 */
380
+	public function getData($key)
381
+	{
382
+		return isset($this->jsdata[ $key ])
383
+			? $this->jsdata[ $key ]
384
+			: false;
385
+	}
386
+
387
+
388
+	/**
389
+	 * Verifies whether the given data exists already on the jsdata array.
390
+	 * Overriding data is not allowed.
391
+	 *
392
+	 * @param string $key Index for data.
393
+	 * @return bool        If valid then return true.
394
+	 * @throws InvalidArgumentException if data already exists.
395
+	 */
396
+	protected function verifyDataNotExisting($key)
397
+	{
398
+		if (isset($this->jsdata[ $key ])) {
399
+			if (! $this->debug()) {
400
+				return false;
401
+			}
402
+			if (is_array($this->jsdata[ $key ])) {
403
+				throw new InvalidArgumentException(
404
+					sprintf(
405
+						__(
406
+							'The value for %1$s already exists in the Registry::eejs object.
407 407
                             Overrides are not allowed. Since the value of this data is an array, you may want to use the
408 408
                             %2$s method to push your value to the array.',
409
-                            'event_espresso'
410
-                        ),
411
-                        $key,
412
-                        'pushData()'
413
-                    )
414
-                );
415
-            }
416
-            throw new InvalidArgumentException(
417
-                sprintf(
418
-                    __(
419
-                        'The value for %1$s already exists in the Registry::eejs object. Overrides are not
409
+							'event_espresso'
410
+						),
411
+						$key,
412
+						'pushData()'
413
+					)
414
+				);
415
+			}
416
+			throw new InvalidArgumentException(
417
+				sprintf(
418
+					__(
419
+						'The value for %1$s already exists in the Registry::eejs object. Overrides are not
420 420
                         allowed.  Consider attaching your value to a different key',
421
-                        'event_espresso'
422
-                    ),
423
-                    $key
424
-                )
425
-            );
426
-        }
427
-        return true;
428
-    }
429
-
430
-
431
-    /**
432
-     * Get the actual asset path for asset manifests.
433
-     * If there is no asset path found for the given $chunk_name, then the $chunk_name is returned.
434
-     *
435
-     * @param string $namespace  The namespace associated with the manifest file hosting the map of chunk_name to actual
436
-     *                           asset file location.
437
-     * @param string $chunk_name
438
-     * @param string $asset_type
439
-     * @return string
440
-     * @since 4.9.59.p
441
-     */
442
-    public function getAssetUrl($namespace, $chunk_name, $asset_type)
443
-    {
444
-        $url = isset(
445
-            $this->manifest_data[ $namespace ][ $chunk_name . '.' . $asset_type ],
446
-            $this->manifest_data[ $namespace ]['url_base']
447
-        )
448
-            ? $this->manifest_data[ $namespace ]['url_base']
449
-              . $this->manifest_data[ $namespace ][ $chunk_name . '.' . $asset_type ]
450
-            : $chunk_name;
451
-
452
-        return apply_filters(
453
-            'FHEE__EventEspresso_core_services_assets_Registry__getAssetUrl',
454
-            $url,
455
-            $namespace,
456
-            $chunk_name,
457
-            $asset_type
458
-        );
459
-    }
460
-
461
-
462
-
463
-    /**
464
-     * Return the url to a js file for the given namespace and chunk name.
465
-     *
466
-     * @param string $namespace
467
-     * @param string $chunk_name
468
-     * @return string
469
-     */
470
-    public function getJsUrl($namespace, $chunk_name)
471
-    {
472
-        return $this->getAssetUrl($namespace, $chunk_name, Asset::TYPE_JS);
473
-    }
474
-
475
-
476
-    /**
477
-     * Return the url to a css file for the given namespace and chunk name.
478
-     *
479
-     * @param string $namespace
480
-     * @param string $chunk_name
481
-     * @return string
482
-     */
483
-    public function getCssUrl($namespace, $chunk_name)
484
-    {
485
-        return $this->getAssetUrl($namespace, $chunk_name, Asset::TYPE_CSS);
486
-    }
487
-
488
-
489
-    /**
490
-     * Return the dependencies for a given asset $chunk_name
491
-     *
492
-     * @param string $namespace
493
-     * @param string $chunk_name
494
-     * @param string $asset_type
495
-     * @return array
496
-     * @since $VID:$
497
-     */
498
-    private function getDependenciesForAsset($namespace, $chunk_name, $asset_type)
499
-    {
500
-        $asset_index = $chunk_name . '.' . $asset_type;
501
-        if (! isset( $this->dependencies_data[ $namespace ][ $asset_index ])) {
502
-            $path = isset($this->manifest_data[ $namespace ]['path'])
503
-                ? $this->manifest_data[ $namespace ]['path']
504
-                : '';
505
-            $dependencies_index = $chunk_name . '.' . Asset::TYPE_JSON;
506
-            $file_path = isset($this->manifest_data[ $namespace ][ $dependencies_index ])
507
-                ? $path . $this->manifest_data[ $namespace ][ $dependencies_index ]
508
-                :
509
-                '';
510
-            $this->dependencies_data[ $namespace ][ $asset_index ] = $file_path !== '' && file_exists($file_path)
511
-                ? $this->getDependenciesForAssetType($namespace, $asset_type, $file_path, $chunk_name)
512
-                : [];
513
-        }
514
-        return $this->dependencies_data[ $namespace ][ $asset_index ];
515
-    }
516
-
517
-
518
-    /**
519
-     * Return dependencies according to asset type.
520
-     *
521
-     * For css assets, this filters the auto generated dependencies by css type.
522
-     *
523
-     * @param string $namespace
524
-     * @param string $asset_type
525
-     * @param string $file_path
526
-     * @param string $chunk_name
527
-     * @return array
528
-     * @since $VID:$
529
-     */
530
-    private function getDependenciesForAssetType($namespace, $asset_type, $file_path, $chunk_name)
531
-    {
532
-        $asset_dependencies = json_decode(file_get_contents($file_path), true);
533
-        if ($asset_type === Asset::TYPE_JS) {
534
-            return $chunk_name === 'eejs-core' ? $asset_dependencies : array_merge(
535
-                $asset_dependencies,
536
-                [ CoreAssetManager::JS_HANDLE_JS_CORE ]
537
-            );
538
-        }
539
-        // for css we need to make sure there is actually a css file related to this chunk.
540
-        if (isset($this->manifest_data[ $namespace ])) {
541
-            // array of css chunk files for ee.
542
-            $css_chunks = array_map(
543
-                function ($value) {
544
-                    return str_replace('.css', '', $value);
545
-                },
546
-                array_filter(
547
-                    array_keys($this->manifest_data[ $namespace ]),
548
-                    function ($value) {
549
-                        return strpos($value, '.css') !== false;
550
-                    }
551
-                )
552
-            );
553
-            // add known wp chunks with css
554
-            $css_chunks = array_merge( $css_chunks, $this->wp_css_handle_dependencies);
555
-            // flip for easier search
556
-            $css_chunks = array_flip($css_chunks);
557
-            // now let's filter the dependencies for the incoming chunk to actual chunks that have styles
558
-            return array_filter(
559
-                $asset_dependencies,
560
-                function ($chunk_name) use ($css_chunks) {
561
-                    return isset($css_chunks[ $chunk_name ]);
562
-                }
563
-            );
564
-        }
565
-        return [];
566
-    }
567
-
568
-
569
-    /**
570
-     * Get the dependencies array for the given js asset chunk name
571
-     *
572
-     * @param string $namespace
573
-     * @param string $chunk_name
574
-     * @return array
575
-     * @since $VID:$
576
-     */
577
-    public function getJsDependencies($namespace, $chunk_name)
578
-    {
579
-        return $this->getDependenciesForAsset($namespace, $chunk_name, Asset::TYPE_JS);
580
-    }
581
-
582
-
583
-    /**
584
-     * Get the dependencies array for the given css asset chunk name
585
-     *
586
-     * @param string $namespace
587
-     * @param string $chunk_name
588
-     * @return array
589
-     * @since $VID:$
590
-     */
591
-    public function getCssDependencies($namespace, $chunk_name)
592
-    {
593
-        return $this->getDependenciesForAsset($namespace, $chunk_name, Asset::TYPE_CSS);
594
-    }
595
-
596
-
597
-    /**
598
-     * @since 4.9.62.p
599
-     * @throws InvalidArgumentException
600
-     * @throws InvalidFilePathException
601
-     */
602
-    public function registerManifestFiles()
603
-    {
604
-        $manifest_files = $this->assets->getManifestFiles();
605
-        foreach ($manifest_files as $manifest_file) {
606
-            $this->registerManifestFile(
607
-                $manifest_file->assetNamespace(),
608
-                $manifest_file->urlBase(),
609
-                $manifest_file->filepath() . Registry::FILE_NAME_BUILD_MANIFEST,
610
-                $manifest_file->filepath()
611
-            );
612
-        }
613
-    }
614
-
615
-
616
-    /**
617
-     * Used to register a js/css manifest file with the registered_manifest_files property.
618
-     *
619
-     * @param string $namespace     Provided to associate the manifest file with a specific namespace.
620
-     * @param string $url_base      The url base for the manifest file location.
621
-     * @param string $manifest_file The absolute path to the manifest file.
622
-     * @param string $manifest_file_path  The path to the folder containing the manifest file. If not provided will be
623
-     *                                    default to `plugin_root/assets/dist`.
624
-     * @throws InvalidArgumentException
625
-     * @throws InvalidFilePathException
626
-     * @since 4.9.59.p
627
-     */
628
-    public function registerManifestFile($namespace, $url_base, $manifest_file, $manifest_file_path = '')
629
-    {
630
-        if (isset($this->manifest_data[ $namespace ])) {
631
-            if (! $this->debug()) {
632
-                return;
633
-            }
634
-            throw new InvalidArgumentException(
635
-                sprintf(
636
-                    esc_html__(
637
-                        'The namespace for this manifest file has already been registered, choose a namespace other than %s',
638
-                        'event_espresso'
639
-                    ),
640
-                    $namespace
641
-                )
642
-            );
643
-        }
644
-        if (filter_var($url_base, FILTER_VALIDATE_URL) === false) {
645
-            if (is_admin()) {
646
-                EE_Error::add_error(
647
-                    sprintf(
648
-                        esc_html__(
649
-                            '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',
650
-                            'event_espresso'
651
-                        ),
652
-                        'Event Espresso',
653
-                        $url_base,
654
-                        'plugins_url',
655
-                        'WP_PLUGIN_URL'
656
-                    ),
657
-                    __FILE__,
658
-                    __FUNCTION__,
659
-                    __LINE__
660
-                );
661
-            }
662
-            return;
663
-        }
664
-        $this->manifest_data[ $namespace ] = $this->decodeManifestFile($manifest_file);
665
-        if (! isset($this->manifest_data[ $namespace ]['url_base'])) {
666
-            $this->manifest_data[ $namespace ]['url_base'] = trailingslashit($url_base);
667
-        }
668
-        if (! isset($this->manifest_data[ $namespace ]['path'])) {
669
-            $this->manifest_data[ $namespace ]['path'] = $manifest_file_path;
670
-        }
671
-    }
672
-
673
-
674
-    /**
675
-     * Decodes json from the provided manifest file.
676
-     *
677
-     * @since 4.9.59.p
678
-     * @param string $manifest_file Path to manifest file.
679
-     * @return array
680
-     * @throws InvalidFilePathException
681
-     */
682
-    private function decodeManifestFile($manifest_file)
683
-    {
684
-        if (! file_exists($manifest_file)) {
685
-            throw new InvalidFilePathException($manifest_file);
686
-        }
687
-        return json_decode(file_get_contents($manifest_file), true);
688
-    }
689
-
690
-
691
-    /**
692
-     * This is used to set registered script handles that have data.
693
-     *
694
-     * @param string $script_handle
695
-     */
696
-    private function addRegisteredScriptHandlesWithData($script_handle)
697
-    {
698
-        $this->script_handles_with_data[ $script_handle ] = $script_handle;
699
-    }
700
-
701
-
702
-    /**i
421
+						'event_espresso'
422
+					),
423
+					$key
424
+				)
425
+			);
426
+		}
427
+		return true;
428
+	}
429
+
430
+
431
+	/**
432
+	 * Get the actual asset path for asset manifests.
433
+	 * If there is no asset path found for the given $chunk_name, then the $chunk_name is returned.
434
+	 *
435
+	 * @param string $namespace  The namespace associated with the manifest file hosting the map of chunk_name to actual
436
+	 *                           asset file location.
437
+	 * @param string $chunk_name
438
+	 * @param string $asset_type
439
+	 * @return string
440
+	 * @since 4.9.59.p
441
+	 */
442
+	public function getAssetUrl($namespace, $chunk_name, $asset_type)
443
+	{
444
+		$url = isset(
445
+			$this->manifest_data[ $namespace ][ $chunk_name . '.' . $asset_type ],
446
+			$this->manifest_data[ $namespace ]['url_base']
447
+		)
448
+			? $this->manifest_data[ $namespace ]['url_base']
449
+			  . $this->manifest_data[ $namespace ][ $chunk_name . '.' . $asset_type ]
450
+			: $chunk_name;
451
+
452
+		return apply_filters(
453
+			'FHEE__EventEspresso_core_services_assets_Registry__getAssetUrl',
454
+			$url,
455
+			$namespace,
456
+			$chunk_name,
457
+			$asset_type
458
+		);
459
+	}
460
+
461
+
462
+
463
+	/**
464
+	 * Return the url to a js file for the given namespace and chunk name.
465
+	 *
466
+	 * @param string $namespace
467
+	 * @param string $chunk_name
468
+	 * @return string
469
+	 */
470
+	public function getJsUrl($namespace, $chunk_name)
471
+	{
472
+		return $this->getAssetUrl($namespace, $chunk_name, Asset::TYPE_JS);
473
+	}
474
+
475
+
476
+	/**
477
+	 * Return the url to a css file for the given namespace and chunk name.
478
+	 *
479
+	 * @param string $namespace
480
+	 * @param string $chunk_name
481
+	 * @return string
482
+	 */
483
+	public function getCssUrl($namespace, $chunk_name)
484
+	{
485
+		return $this->getAssetUrl($namespace, $chunk_name, Asset::TYPE_CSS);
486
+	}
487
+
488
+
489
+	/**
490
+	 * Return the dependencies for a given asset $chunk_name
491
+	 *
492
+	 * @param string $namespace
493
+	 * @param string $chunk_name
494
+	 * @param string $asset_type
495
+	 * @return array
496
+	 * @since $VID:$
497
+	 */
498
+	private function getDependenciesForAsset($namespace, $chunk_name, $asset_type)
499
+	{
500
+		$asset_index = $chunk_name . '.' . $asset_type;
501
+		if (! isset( $this->dependencies_data[ $namespace ][ $asset_index ])) {
502
+			$path = isset($this->manifest_data[ $namespace ]['path'])
503
+				? $this->manifest_data[ $namespace ]['path']
504
+				: '';
505
+			$dependencies_index = $chunk_name . '.' . Asset::TYPE_JSON;
506
+			$file_path = isset($this->manifest_data[ $namespace ][ $dependencies_index ])
507
+				? $path . $this->manifest_data[ $namespace ][ $dependencies_index ]
508
+				:
509
+				'';
510
+			$this->dependencies_data[ $namespace ][ $asset_index ] = $file_path !== '' && file_exists($file_path)
511
+				? $this->getDependenciesForAssetType($namespace, $asset_type, $file_path, $chunk_name)
512
+				: [];
513
+		}
514
+		return $this->dependencies_data[ $namespace ][ $asset_index ];
515
+	}
516
+
517
+
518
+	/**
519
+	 * Return dependencies according to asset type.
520
+	 *
521
+	 * For css assets, this filters the auto generated dependencies by css type.
522
+	 *
523
+	 * @param string $namespace
524
+	 * @param string $asset_type
525
+	 * @param string $file_path
526
+	 * @param string $chunk_name
527
+	 * @return array
528
+	 * @since $VID:$
529
+	 */
530
+	private function getDependenciesForAssetType($namespace, $asset_type, $file_path, $chunk_name)
531
+	{
532
+		$asset_dependencies = json_decode(file_get_contents($file_path), true);
533
+		if ($asset_type === Asset::TYPE_JS) {
534
+			return $chunk_name === 'eejs-core' ? $asset_dependencies : array_merge(
535
+				$asset_dependencies,
536
+				[ CoreAssetManager::JS_HANDLE_JS_CORE ]
537
+			);
538
+		}
539
+		// for css we need to make sure there is actually a css file related to this chunk.
540
+		if (isset($this->manifest_data[ $namespace ])) {
541
+			// array of css chunk files for ee.
542
+			$css_chunks = array_map(
543
+				function ($value) {
544
+					return str_replace('.css', '', $value);
545
+				},
546
+				array_filter(
547
+					array_keys($this->manifest_data[ $namespace ]),
548
+					function ($value) {
549
+						return strpos($value, '.css') !== false;
550
+					}
551
+				)
552
+			);
553
+			// add known wp chunks with css
554
+			$css_chunks = array_merge( $css_chunks, $this->wp_css_handle_dependencies);
555
+			// flip for easier search
556
+			$css_chunks = array_flip($css_chunks);
557
+			// now let's filter the dependencies for the incoming chunk to actual chunks that have styles
558
+			return array_filter(
559
+				$asset_dependencies,
560
+				function ($chunk_name) use ($css_chunks) {
561
+					return isset($css_chunks[ $chunk_name ]);
562
+				}
563
+			);
564
+		}
565
+		return [];
566
+	}
567
+
568
+
569
+	/**
570
+	 * Get the dependencies array for the given js asset chunk name
571
+	 *
572
+	 * @param string $namespace
573
+	 * @param string $chunk_name
574
+	 * @return array
575
+	 * @since $VID:$
576
+	 */
577
+	public function getJsDependencies($namespace, $chunk_name)
578
+	{
579
+		return $this->getDependenciesForAsset($namespace, $chunk_name, Asset::TYPE_JS);
580
+	}
581
+
582
+
583
+	/**
584
+	 * Get the dependencies array for the given css asset chunk name
585
+	 *
586
+	 * @param string $namespace
587
+	 * @param string $chunk_name
588
+	 * @return array
589
+	 * @since $VID:$
590
+	 */
591
+	public function getCssDependencies($namespace, $chunk_name)
592
+	{
593
+		return $this->getDependenciesForAsset($namespace, $chunk_name, Asset::TYPE_CSS);
594
+	}
595
+
596
+
597
+	/**
598
+	 * @since 4.9.62.p
599
+	 * @throws InvalidArgumentException
600
+	 * @throws InvalidFilePathException
601
+	 */
602
+	public function registerManifestFiles()
603
+	{
604
+		$manifest_files = $this->assets->getManifestFiles();
605
+		foreach ($manifest_files as $manifest_file) {
606
+			$this->registerManifestFile(
607
+				$manifest_file->assetNamespace(),
608
+				$manifest_file->urlBase(),
609
+				$manifest_file->filepath() . Registry::FILE_NAME_BUILD_MANIFEST,
610
+				$manifest_file->filepath()
611
+			);
612
+		}
613
+	}
614
+
615
+
616
+	/**
617
+	 * Used to register a js/css manifest file with the registered_manifest_files property.
618
+	 *
619
+	 * @param string $namespace     Provided to associate the manifest file with a specific namespace.
620
+	 * @param string $url_base      The url base for the manifest file location.
621
+	 * @param string $manifest_file The absolute path to the manifest file.
622
+	 * @param string $manifest_file_path  The path to the folder containing the manifest file. If not provided will be
623
+	 *                                    default to `plugin_root/assets/dist`.
624
+	 * @throws InvalidArgumentException
625
+	 * @throws InvalidFilePathException
626
+	 * @since 4.9.59.p
627
+	 */
628
+	public function registerManifestFile($namespace, $url_base, $manifest_file, $manifest_file_path = '')
629
+	{
630
+		if (isset($this->manifest_data[ $namespace ])) {
631
+			if (! $this->debug()) {
632
+				return;
633
+			}
634
+			throw new InvalidArgumentException(
635
+				sprintf(
636
+					esc_html__(
637
+						'The namespace for this manifest file has already been registered, choose a namespace other than %s',
638
+						'event_espresso'
639
+					),
640
+					$namespace
641
+				)
642
+			);
643
+		}
644
+		if (filter_var($url_base, FILTER_VALIDATE_URL) === false) {
645
+			if (is_admin()) {
646
+				EE_Error::add_error(
647
+					sprintf(
648
+						esc_html__(
649
+							'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',
650
+							'event_espresso'
651
+						),
652
+						'Event Espresso',
653
+						$url_base,
654
+						'plugins_url',
655
+						'WP_PLUGIN_URL'
656
+					),
657
+					__FILE__,
658
+					__FUNCTION__,
659
+					__LINE__
660
+				);
661
+			}
662
+			return;
663
+		}
664
+		$this->manifest_data[ $namespace ] = $this->decodeManifestFile($manifest_file);
665
+		if (! isset($this->manifest_data[ $namespace ]['url_base'])) {
666
+			$this->manifest_data[ $namespace ]['url_base'] = trailingslashit($url_base);
667
+		}
668
+		if (! isset($this->manifest_data[ $namespace ]['path'])) {
669
+			$this->manifest_data[ $namespace ]['path'] = $manifest_file_path;
670
+		}
671
+	}
672
+
673
+
674
+	/**
675
+	 * Decodes json from the provided manifest file.
676
+	 *
677
+	 * @since 4.9.59.p
678
+	 * @param string $manifest_file Path to manifest file.
679
+	 * @return array
680
+	 * @throws InvalidFilePathException
681
+	 */
682
+	private function decodeManifestFile($manifest_file)
683
+	{
684
+		if (! file_exists($manifest_file)) {
685
+			throw new InvalidFilePathException($manifest_file);
686
+		}
687
+		return json_decode(file_get_contents($manifest_file), true);
688
+	}
689
+
690
+
691
+	/**
692
+	 * This is used to set registered script handles that have data.
693
+	 *
694
+	 * @param string $script_handle
695
+	 */
696
+	private function addRegisteredScriptHandlesWithData($script_handle)
697
+	{
698
+		$this->script_handles_with_data[ $script_handle ] = $script_handle;
699
+	}
700
+
701
+
702
+	/**i
703 703
      * Checks WP_Scripts for all of each script handle registered internally as having data and unsets from the
704 704
      * Dependency stored in WP_Scripts if its set.
705 705
      */
706
-    private function removeAlreadyRegisteredDataForScriptHandles()
707
-    {
708
-        if (empty($this->script_handles_with_data)) {
709
-            return;
710
-        }
711
-        foreach ($this->script_handles_with_data as $script_handle) {
712
-            $this->removeAlreadyRegisteredDataForScriptHandle($script_handle);
713
-        }
714
-    }
715
-
716
-
717
-    /**
718
-     * Removes any data dependency registered in WP_Scripts if its set.
719
-     *
720
-     * @param string $script_handle
721
-     */
722
-    private function removeAlreadyRegisteredDataForScriptHandle($script_handle)
723
-    {
724
-        if (isset($this->script_handles_with_data[ $script_handle ])) {
725
-            global $wp_scripts;
726
-            $unset_handle = false;
727
-            if ($wp_scripts->get_data($script_handle, 'data')) {
728
-                unset($wp_scripts->registered[ $script_handle ]->extra['data']);
729
-                $unset_handle = true;
730
-            }
731
-            //deal with inline_scripts
732
-            if ($wp_scripts->get_data($script_handle, 'before')) {
733
-                unset($wp_scripts->registered[ $script_handle ]->extra['before']);
734
-                $unset_handle = true;
735
-            }
736
-            if ($wp_scripts->get_data($script_handle, 'after')) {
737
-                unset($wp_scripts->registered[ $script_handle ]->extra['after']);
738
-            }
739
-            if ($unset_handle) {
740
-                unset($this->script_handles_with_data[ $script_handle ]);
741
-            }
742
-        }
743
-    }
744
-
745
-
746
-    /**
747
-     * register translations for a registered script
748
-     *
749
-     * @param string $handle
750
-     */
751
-    public function registerTranslation($handle)
752
-    {
753
-        $this->i18n_registry->registerScriptI18n($handle);
754
-    }
755
-
756
-
757
-    /**
758
-     * @since 4.9.63.p
759
-     * @return bool
760
-     */
761
-    private function debug()
762
-    {
763
-        return apply_filters(
764
-            'FHEE__EventEspresso_core_services_assets_Registry__debug',
765
-            defined('EE_DEBUG') && EE_DEBUG
766
-        );
767
-    }
706
+	private function removeAlreadyRegisteredDataForScriptHandles()
707
+	{
708
+		if (empty($this->script_handles_with_data)) {
709
+			return;
710
+		}
711
+		foreach ($this->script_handles_with_data as $script_handle) {
712
+			$this->removeAlreadyRegisteredDataForScriptHandle($script_handle);
713
+		}
714
+	}
715
+
716
+
717
+	/**
718
+	 * Removes any data dependency registered in WP_Scripts if its set.
719
+	 *
720
+	 * @param string $script_handle
721
+	 */
722
+	private function removeAlreadyRegisteredDataForScriptHandle($script_handle)
723
+	{
724
+		if (isset($this->script_handles_with_data[ $script_handle ])) {
725
+			global $wp_scripts;
726
+			$unset_handle = false;
727
+			if ($wp_scripts->get_data($script_handle, 'data')) {
728
+				unset($wp_scripts->registered[ $script_handle ]->extra['data']);
729
+				$unset_handle = true;
730
+			}
731
+			//deal with inline_scripts
732
+			if ($wp_scripts->get_data($script_handle, 'before')) {
733
+				unset($wp_scripts->registered[ $script_handle ]->extra['before']);
734
+				$unset_handle = true;
735
+			}
736
+			if ($wp_scripts->get_data($script_handle, 'after')) {
737
+				unset($wp_scripts->registered[ $script_handle ]->extra['after']);
738
+			}
739
+			if ($unset_handle) {
740
+				unset($this->script_handles_with_data[ $script_handle ]);
741
+			}
742
+		}
743
+	}
744
+
745
+
746
+	/**
747
+	 * register translations for a registered script
748
+	 *
749
+	 * @param string $handle
750
+	 */
751
+	public function registerTranslation($handle)
752
+	{
753
+		$this->i18n_registry->registerScriptI18n($handle);
754
+	}
755
+
756
+
757
+	/**
758
+	 * @since 4.9.63.p
759
+	 * @return bool
760
+	 */
761
+	private function debug()
762
+	{
763
+		return apply_filters(
764
+			'FHEE__EventEspresso_core_services_assets_Registry__debug',
765
+			defined('EE_DEBUG') && EE_DEBUG
766
+		);
767
+	}
768 768
 }
Please login to merge, or discard this patch.
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
                 $script->version(),
185 185
                 $script->loadInFooter()
186 186
             );
187
-            if (! $registered && $this->debug()) {
187
+            if ( ! $registered && $this->debug()) {
188 188
                 throw new AssetRegistrationException($script->handle());
189 189
             }
190 190
             $script->setRegistered($registered);
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
         $this->removeAlreadyRegisteredDataForScriptHandles();
245 245
         wp_add_inline_script(
246 246
             'eejs-core',
247
-            'var eejsdata=' . wp_json_encode(array('data' => $this->jsdata)),
247
+            'var eejsdata='.wp_json_encode(array('data' => $this->jsdata)),
248 248
             'before'
249 249
         );
250 250
         $scripts = $this->assets->getJavascriptAssetsWithData();
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
     public function addData($key, $value)
275 275
     {
276 276
         if ($this->verifyDataNotExisting($key)) {
277
-            $this->jsdata[ $key ] = $value;
277
+            $this->jsdata[$key] = $value;
278 278
         }
279 279
     }
280 280
 
@@ -299,10 +299,10 @@  discard block
 block discarded – undo
299 299
      */
300 300
     public function pushData($key, $value)
301 301
     {
302
-        if (isset($this->jsdata[ $key ])
303
-            && ! is_array($this->jsdata[ $key ])
302
+        if (isset($this->jsdata[$key])
303
+            && ! is_array($this->jsdata[$key])
304 304
         ) {
305
-            if (! $this->debug()) {
305
+            if ( ! $this->debug()) {
306 306
                 return;
307 307
             }
308 308
             throw new InvalidArgumentException(
@@ -317,10 +317,10 @@  discard block
 block discarded – undo
317 317
                 )
318 318
             );
319 319
         }
320
-        if ( ! isset( $this->jsdata[ $key ] ) ) {
321
-            $this->jsdata[ $key ] = is_array($value) ? $value : [$value];
320
+        if ( ! isset($this->jsdata[$key])) {
321
+            $this->jsdata[$key] = is_array($value) ? $value : [$value];
322 322
         } else {
323
-            $this->jsdata[ $key ] = array_merge( $this->jsdata[$key], (array) $value);
323
+            $this->jsdata[$key] = array_merge($this->jsdata[$key], (array) $value);
324 324
         }
325 325
     }
326 326
 
@@ -335,12 +335,12 @@  discard block
 block discarded – undo
335 335
      */
336 336
     public function addTemplate($template_reference, $template_content)
337 337
     {
338
-        if (! isset($this->jsdata['templates'])) {
338
+        if ( ! isset($this->jsdata['templates'])) {
339 339
             $this->jsdata['templates'] = array();
340 340
         }
341 341
         //no overrides allowed.
342
-        if (isset($this->jsdata['templates'][ $template_reference ])) {
343
-            if (! $this->debug()) {
342
+        if (isset($this->jsdata['templates'][$template_reference])) {
343
+            if ( ! $this->debug()) {
344 344
                 return;
345 345
             }
346 346
             throw new InvalidArgumentException(
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
                 )
354 354
             );
355 355
         }
356
-        $this->jsdata['templates'][ $template_reference ] = $template_content;
356
+        $this->jsdata['templates'][$template_reference] = $template_content;
357 357
     }
358 358
 
359 359
 
@@ -365,8 +365,8 @@  discard block
 block discarded – undo
365 365
      */
366 366
     public function getTemplate($template_reference)
367 367
     {
368
-        return isset($this->jsdata['templates'][ $template_reference ])
369
-            ? $this->jsdata['templates'][ $template_reference ]
368
+        return isset($this->jsdata['templates'][$template_reference])
369
+            ? $this->jsdata['templates'][$template_reference]
370 370
             : '';
371 371
     }
372 372
 
@@ -379,8 +379,8 @@  discard block
 block discarded – undo
379 379
      */
380 380
     public function getData($key)
381 381
     {
382
-        return isset($this->jsdata[ $key ])
383
-            ? $this->jsdata[ $key ]
382
+        return isset($this->jsdata[$key])
383
+            ? $this->jsdata[$key]
384 384
             : false;
385 385
     }
386 386
 
@@ -395,11 +395,11 @@  discard block
 block discarded – undo
395 395
      */
396 396
     protected function verifyDataNotExisting($key)
397 397
     {
398
-        if (isset($this->jsdata[ $key ])) {
399
-            if (! $this->debug()) {
398
+        if (isset($this->jsdata[$key])) {
399
+            if ( ! $this->debug()) {
400 400
                 return false;
401 401
             }
402
-            if (is_array($this->jsdata[ $key ])) {
402
+            if (is_array($this->jsdata[$key])) {
403 403
                 throw new InvalidArgumentException(
404 404
                     sprintf(
405 405
                         __(
@@ -442,11 +442,11 @@  discard block
 block discarded – undo
442 442
     public function getAssetUrl($namespace, $chunk_name, $asset_type)
443 443
     {
444 444
         $url = isset(
445
-            $this->manifest_data[ $namespace ][ $chunk_name . '.' . $asset_type ],
446
-            $this->manifest_data[ $namespace ]['url_base']
445
+            $this->manifest_data[$namespace][$chunk_name.'.'.$asset_type],
446
+            $this->manifest_data[$namespace]['url_base']
447 447
         )
448
-            ? $this->manifest_data[ $namespace ]['url_base']
449
-              . $this->manifest_data[ $namespace ][ $chunk_name . '.' . $asset_type ]
448
+            ? $this->manifest_data[$namespace]['url_base']
449
+              . $this->manifest_data[$namespace][$chunk_name.'.'.$asset_type]
450 450
             : $chunk_name;
451 451
 
452 452
         return apply_filters(
@@ -497,21 +497,21 @@  discard block
 block discarded – undo
497 497
      */
498 498
     private function getDependenciesForAsset($namespace, $chunk_name, $asset_type)
499 499
     {
500
-        $asset_index = $chunk_name . '.' . $asset_type;
501
-        if (! isset( $this->dependencies_data[ $namespace ][ $asset_index ])) {
502
-            $path = isset($this->manifest_data[ $namespace ]['path'])
503
-                ? $this->manifest_data[ $namespace ]['path']
500
+        $asset_index = $chunk_name.'.'.$asset_type;
501
+        if ( ! isset($this->dependencies_data[$namespace][$asset_index])) {
502
+            $path = isset($this->manifest_data[$namespace]['path'])
503
+                ? $this->manifest_data[$namespace]['path']
504 504
                 : '';
505
-            $dependencies_index = $chunk_name . '.' . Asset::TYPE_JSON;
506
-            $file_path = isset($this->manifest_data[ $namespace ][ $dependencies_index ])
507
-                ? $path . $this->manifest_data[ $namespace ][ $dependencies_index ]
505
+            $dependencies_index = $chunk_name.'.'.Asset::TYPE_JSON;
506
+            $file_path = isset($this->manifest_data[$namespace][$dependencies_index])
507
+                ? $path.$this->manifest_data[$namespace][$dependencies_index]
508 508
                 :
509 509
                 '';
510
-            $this->dependencies_data[ $namespace ][ $asset_index ] = $file_path !== '' && file_exists($file_path)
510
+            $this->dependencies_data[$namespace][$asset_index] = $file_path !== '' && file_exists($file_path)
511 511
                 ? $this->getDependenciesForAssetType($namespace, $asset_type, $file_path, $chunk_name)
512 512
                 : [];
513 513
         }
514
-        return $this->dependencies_data[ $namespace ][ $asset_index ];
514
+        return $this->dependencies_data[$namespace][$asset_index];
515 515
     }
516 516
 
517 517
 
@@ -533,32 +533,32 @@  discard block
 block discarded – undo
533 533
         if ($asset_type === Asset::TYPE_JS) {
534 534
             return $chunk_name === 'eejs-core' ? $asset_dependencies : array_merge(
535 535
                 $asset_dependencies,
536
-                [ CoreAssetManager::JS_HANDLE_JS_CORE ]
536
+                [CoreAssetManager::JS_HANDLE_JS_CORE]
537 537
             );
538 538
         }
539 539
         // for css we need to make sure there is actually a css file related to this chunk.
540
-        if (isset($this->manifest_data[ $namespace ])) {
540
+        if (isset($this->manifest_data[$namespace])) {
541 541
             // array of css chunk files for ee.
542 542
             $css_chunks = array_map(
543
-                function ($value) {
543
+                function($value) {
544 544
                     return str_replace('.css', '', $value);
545 545
                 },
546 546
                 array_filter(
547
-                    array_keys($this->manifest_data[ $namespace ]),
548
-                    function ($value) {
547
+                    array_keys($this->manifest_data[$namespace]),
548
+                    function($value) {
549 549
                         return strpos($value, '.css') !== false;
550 550
                     }
551 551
                 )
552 552
             );
553 553
             // add known wp chunks with css
554
-            $css_chunks = array_merge( $css_chunks, $this->wp_css_handle_dependencies);
554
+            $css_chunks = array_merge($css_chunks, $this->wp_css_handle_dependencies);
555 555
             // flip for easier search
556 556
             $css_chunks = array_flip($css_chunks);
557 557
             // now let's filter the dependencies for the incoming chunk to actual chunks that have styles
558 558
             return array_filter(
559 559
                 $asset_dependencies,
560
-                function ($chunk_name) use ($css_chunks) {
561
-                    return isset($css_chunks[ $chunk_name ]);
560
+                function($chunk_name) use ($css_chunks) {
561
+                    return isset($css_chunks[$chunk_name]);
562 562
                 }
563 563
             );
564 564
         }
@@ -606,7 +606,7 @@  discard block
 block discarded – undo
606 606
             $this->registerManifestFile(
607 607
                 $manifest_file->assetNamespace(),
608 608
                 $manifest_file->urlBase(),
609
-                $manifest_file->filepath() . Registry::FILE_NAME_BUILD_MANIFEST,
609
+                $manifest_file->filepath().Registry::FILE_NAME_BUILD_MANIFEST,
610 610
                 $manifest_file->filepath()
611 611
             );
612 612
         }
@@ -627,8 +627,8 @@  discard block
 block discarded – undo
627 627
      */
628 628
     public function registerManifestFile($namespace, $url_base, $manifest_file, $manifest_file_path = '')
629 629
     {
630
-        if (isset($this->manifest_data[ $namespace ])) {
631
-            if (! $this->debug()) {
630
+        if (isset($this->manifest_data[$namespace])) {
631
+            if ( ! $this->debug()) {
632 632
                 return;
633 633
             }
634 634
             throw new InvalidArgumentException(
@@ -661,12 +661,12 @@  discard block
 block discarded – undo
661 661
             }
662 662
             return;
663 663
         }
664
-        $this->manifest_data[ $namespace ] = $this->decodeManifestFile($manifest_file);
665
-        if (! isset($this->manifest_data[ $namespace ]['url_base'])) {
666
-            $this->manifest_data[ $namespace ]['url_base'] = trailingslashit($url_base);
664
+        $this->manifest_data[$namespace] = $this->decodeManifestFile($manifest_file);
665
+        if ( ! isset($this->manifest_data[$namespace]['url_base'])) {
666
+            $this->manifest_data[$namespace]['url_base'] = trailingslashit($url_base);
667 667
         }
668
-        if (! isset($this->manifest_data[ $namespace ]['path'])) {
669
-            $this->manifest_data[ $namespace ]['path'] = $manifest_file_path;
668
+        if ( ! isset($this->manifest_data[$namespace]['path'])) {
669
+            $this->manifest_data[$namespace]['path'] = $manifest_file_path;
670 670
         }
671 671
     }
672 672
 
@@ -681,7 +681,7 @@  discard block
 block discarded – undo
681 681
      */
682 682
     private function decodeManifestFile($manifest_file)
683 683
     {
684
-        if (! file_exists($manifest_file)) {
684
+        if ( ! file_exists($manifest_file)) {
685 685
             throw new InvalidFilePathException($manifest_file);
686 686
         }
687 687
         return json_decode(file_get_contents($manifest_file), true);
@@ -695,7 +695,7 @@  discard block
 block discarded – undo
695 695
      */
696 696
     private function addRegisteredScriptHandlesWithData($script_handle)
697 697
     {
698
-        $this->script_handles_with_data[ $script_handle ] = $script_handle;
698
+        $this->script_handles_with_data[$script_handle] = $script_handle;
699 699
     }
700 700
 
701 701
 
@@ -721,23 +721,23 @@  discard block
 block discarded – undo
721 721
      */
722 722
     private function removeAlreadyRegisteredDataForScriptHandle($script_handle)
723 723
     {
724
-        if (isset($this->script_handles_with_data[ $script_handle ])) {
724
+        if (isset($this->script_handles_with_data[$script_handle])) {
725 725
             global $wp_scripts;
726 726
             $unset_handle = false;
727 727
             if ($wp_scripts->get_data($script_handle, 'data')) {
728
-                unset($wp_scripts->registered[ $script_handle ]->extra['data']);
728
+                unset($wp_scripts->registered[$script_handle]->extra['data']);
729 729
                 $unset_handle = true;
730 730
             }
731 731
             //deal with inline_scripts
732 732
             if ($wp_scripts->get_data($script_handle, 'before')) {
733
-                unset($wp_scripts->registered[ $script_handle ]->extra['before']);
733
+                unset($wp_scripts->registered[$script_handle]->extra['before']);
734 734
                 $unset_handle = true;
735 735
             }
736 736
             if ($wp_scripts->get_data($script_handle, 'after')) {
737
-                unset($wp_scripts->registered[ $script_handle ]->extra['after']);
737
+                unset($wp_scripts->registered[$script_handle]->extra['after']);
738 738
             }
739 739
             if ($unset_handle) {
740
-                unset($this->script_handles_with_data[ $script_handle ]);
740
+                unset($this->script_handles_with_data[$script_handle]);
741 741
             }
742 742
         }
743 743
     }
Please login to merge, or discard this patch.
espresso.php 1 patch
Indentation   +80 added lines, -80 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
 } else {
64
-    define('EE_MIN_PHP_VER_REQUIRED', '5.4.0');
65
-    if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
-        /**
67
-         * espresso_minimum_php_version_error
68
-         *
69
-         * @return void
70
-         */
71
-        function espresso_minimum_php_version_error()
72
-        {
73
-            ?>
64
+	define('EE_MIN_PHP_VER_REQUIRED', '5.4.0');
65
+	if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
+		/**
67
+		 * espresso_minimum_php_version_error
68
+		 *
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.82.rc.034');
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.82.rc.034');
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.