Completed
Pull Request — master (#1191)
by
unknown
08:45
created
core/services/assets/Registry.php 2 patches
Indentation   +584 added lines, -584 removed lines patch added patch discarded remove patch
@@ -23,595 +23,595 @@
 block discarded – undo
23 23
 class Registry
24 24
 {
25 25
 
26
-    const FILE_NAME_BUILD_MANIFEST = 'build-manifest.json';
27
-
28
-    /**
29
-     * @var AssetCollection $assets
30
-     */
31
-    protected $assets;
32
-
33
-    /**
34
-     * @var I18nRegistry
35
-     */
36
-    private $i18n_registry;
37
-
38
-    /**
39
-     * This holds the jsdata data object that will be exposed on pages that enqueue the `eejs-core` script.
40
-     *
41
-     * @var array
42
-     */
43
-    protected $jsdata = array();
44
-
45
-    /**
46
-     * This keeps track of all scripts with registered data.  It is used to prevent duplicate data objects setup in the
47
-     * page source.
48
-     *
49
-     * @var array
50
-     */
51
-    private $script_handles_with_data = array();
52
-
53
-
54
-    /**
55
-     * Holds the manifest data obtained from registered manifest files.
56
-     * Manifests are maps of asset chunk name to actual built asset file names.
57
-     * Shape of this array is:
58
-     * array(
59
-     *  'some_namespace_slug' => array(
60
-     *      'some_chunk_name' => array(
61
-     *          'js' => 'filename.js'
62
-     *          'css' => 'filename.js'
63
-     *      ),
64
-     *      'url_base' => 'https://baseurl.com/to/assets
65
-     *  )
66
-     * )
67
-     *
68
-     * @var array
69
-     */
70
-    private $manifest_data = array();
71
-
72
-
73
-    /**
74
-     * Registry constructor.
75
-     * Hooking into WP actions for script registry.
76
-     *
77
-     * @param AssetCollection $assets
78
-     * @param I18nRegistry    $i18n_registry
79
-     */
80
-    public function __construct(AssetCollection $assets, I18nRegistry $i18n_registry)
81
-    {
82
-        $this->assets = $assets;
83
-        $this->i18n_registry = $i18n_registry;
84
-        add_action('wp_enqueue_scripts', array($this, 'registerManifestFiles'), 1);
85
-        add_action('admin_enqueue_scripts', array($this, 'registerManifestFiles'), 1);
86
-        add_action('wp_enqueue_scripts', array($this, 'registerScriptsAndStyles'), 3);
87
-        add_action('admin_enqueue_scripts', array($this, 'registerScriptsAndStyles'), 3);
88
-        add_action('wp_enqueue_scripts', array($this, 'enqueueData'), 4);
89
-        add_action('admin_enqueue_scripts', array($this, 'enqueueData'), 4);
90
-        add_action('wp_print_footer_scripts', array($this, 'enqueueData'), 1);
91
-        add_action('admin_print_footer_scripts', array($this, 'enqueueData'), 1);
92
-    }
93
-
94
-
95
-    /**
96
-     * For classes that have Registry as a dependency, this provides a handy way to register script handles for i18n
97
-     * translation handling.
98
-     *
99
-     * @return I18nRegistry
100
-     */
101
-    public function getI18nRegistry()
102
-    {
103
-        return $this->i18n_registry;
104
-    }
105
-
106
-
107
-    /**
108
-     * Callback for the wp_enqueue_scripts actions used to register assets.
109
-     *
110
-     * @since 4.9.62.p
111
-     * @throws Exception
112
-     */
113
-    public function registerScriptsAndStyles()
114
-    {
115
-        try {
116
-            $this->registerScripts($this->assets->getJavascriptAssets());
117
-            $this->registerStyles($this->assets->getStylesheetAssets());
118
-        } catch (Exception $exception) {
119
-            new ExceptionStackTraceDisplay($exception);
120
-        }
121
-    }
122
-
123
-
124
-    /**
125
-     * Registers JS assets with WP core
126
-     *
127
-     * @since 4.9.62.p
128
-     * @param JavascriptAsset[] $scripts
129
-     * @throws AssetRegistrationException
130
-     * @throws InvalidDataTypeException
131
-     */
132
-    public function registerScripts(array $scripts)
133
-    {
134
-        foreach ($scripts as $script) {
135
-            // skip to next script if this has already been done
136
-            if ($script->isRegistered()) {
137
-                continue;
138
-            }
139
-            do_action(
140
-                'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__before_script',
141
-                $script
142
-            );
143
-            $registered = wp_register_script(
144
-                $script->handle(),
145
-                $script->source(),
146
-                $script->dependencies(),
147
-                $script->version(),
148
-                $script->loadInFooter()
149
-            );
150
-            if (! $registered && $this->debug()) {
151
-                throw new AssetRegistrationException($script->handle());
152
-            }
153
-            $script->setRegistered($registered);
154
-            if ($script->requiresTranslation()) {
155
-                $this->registerTranslation($script->handle());
156
-            }
157
-            do_action(
158
-                'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__after_script',
159
-                $script
160
-            );
161
-        }
162
-    }
163
-
164
-
165
-    /**
166
-     * Registers CSS assets with WP core
167
-     *
168
-     * @since 4.9.62.p
169
-     * @param StylesheetAsset[] $styles
170
-     * @throws InvalidDataTypeException
171
-     */
172
-    public function registerStyles(array $styles)
173
-    {
174
-        foreach ($styles as $style) {
175
-            // skip to next style if this has already been done
176
-            if ($style->isRegistered()) {
177
-                continue;
178
-            }
179
-            do_action(
180
-                'AHEE__EventEspresso_core_services_assets_Registry__registerStyles__before_style',
181
-                $style
182
-            );
183
-            wp_register_style(
184
-                $style->handle(),
185
-                $style->source(),
186
-                $style->dependencies(),
187
-                $style->version(),
188
-                $style->media()
189
-            );
190
-            $style->setRegistered();
191
-            do_action(
192
-                'AHEE__EventEspresso_core_services_assets_Registry__registerStyles__after_style',
193
-                $style
194
-            );
195
-        }
196
-    }
197
-
198
-
199
-    /**
200
-     * Call back for the script print in frontend and backend.
201
-     * Used to call wp_localize_scripts so that data can be added throughout the runtime until this later hook point.
202
-     *
203
-     * @since 4.9.31.rc.015
204
-     */
205
-    public function enqueueData()
206
-    {
207
-        $this->removeAlreadyRegisteredDataForScriptHandles();
208
-        wp_add_inline_script(
209
-            'eejs-core',
210
-            'var eejsdata=' . wp_json_encode(array('data' => $this->jsdata)),
211
-            'before'
212
-        );
213
-        $scripts = $this->assets->getJavascriptAssetsWithData();
214
-        foreach ($scripts as $script) {
215
-            $this->addRegisteredScriptHandlesWithData($script->handle());
216
-            if ($script->hasInlineDataCallback()) {
217
-                $localize = $script->inlineDataCallback();
218
-                $localize();
219
-            }
220
-        }
221
-    }
222
-
223
-
224
-    /**
225
-     * Used to add data to eejs.data object.
226
-     * Note:  Overriding existing data is not allowed.
227
-     * Data will be accessible as a javascript object when you list `eejs-core` as a dependency for your javascript.
228
-     * If the data you add is something like this:
229
-     *  $this->addData( 'my_plugin_data', array( 'foo' => 'gar' ) );
230
-     * It will be exposed in the page source as:
231
-     *  eejs.data.my_plugin_data.foo == gar
232
-     *
233
-     * @param string       $key   Key used to access your data
234
-     * @param string|array $value Value to attach to key
235
-     * @throws InvalidArgumentException
236
-     */
237
-    public function addData($key, $value)
238
-    {
239
-        if ($this->verifyDataNotExisting($key)) {
240
-            $this->jsdata[ $key ] = $value;
241
-        }
242
-    }
243
-
244
-
245
-    /**
246
-     * Similar to addData except this allows for users to push values to an existing key where the values on key are
247
-     * elements in an array.
248
-     *
249
-     * When you use this method, the value you include will be merged with the array on $key.
250
-     * So if the $key was 'test' and you added a value of ['my_data'] then it would be represented in the javascript
251
-     * object like this, eejs.data.test = [ my_data,
252
-     * ]
253
-     * If there has already been a scalar value attached to the data object given key (via addData for instance), then
254
-     * this will throw an exception.
255
-     *
256
-     * Caution: Only add data using this method if you are okay with the potential for additional data added on the same
257
-     * key potentially overriding the existing data on merge (specifically with associative arrays).
258
-     *
259
-     * @param string       $key   Key to attach data to.
260
-     * @param string|array $value Value being registered.
261
-     * @throws InvalidArgumentException
262
-     */
263
-    public function pushData($key, $value)
264
-    {
265
-        if (isset($this->jsdata[ $key ])
266
-            && ! is_array($this->jsdata[ $key ])
267
-        ) {
268
-            if (! $this->debug()) {
269
-                return;
270
-            }
271
-            throw new InvalidArgumentException(
272
-                sprintf(
273
-                    __(
274
-                        'The value for %1$s is already set and it is not an array. The %2$s method can only be used to
26
+	const FILE_NAME_BUILD_MANIFEST = 'build-manifest.json';
27
+
28
+	/**
29
+	 * @var AssetCollection $assets
30
+	 */
31
+	protected $assets;
32
+
33
+	/**
34
+	 * @var I18nRegistry
35
+	 */
36
+	private $i18n_registry;
37
+
38
+	/**
39
+	 * This holds the jsdata data object that will be exposed on pages that enqueue the `eejs-core` script.
40
+	 *
41
+	 * @var array
42
+	 */
43
+	protected $jsdata = array();
44
+
45
+	/**
46
+	 * This keeps track of all scripts with registered data.  It is used to prevent duplicate data objects setup in the
47
+	 * page source.
48
+	 *
49
+	 * @var array
50
+	 */
51
+	private $script_handles_with_data = array();
52
+
53
+
54
+	/**
55
+	 * Holds the manifest data obtained from registered manifest files.
56
+	 * Manifests are maps of asset chunk name to actual built asset file names.
57
+	 * Shape of this array is:
58
+	 * array(
59
+	 *  'some_namespace_slug' => array(
60
+	 *      'some_chunk_name' => array(
61
+	 *          'js' => 'filename.js'
62
+	 *          'css' => 'filename.js'
63
+	 *      ),
64
+	 *      'url_base' => 'https://baseurl.com/to/assets
65
+	 *  )
66
+	 * )
67
+	 *
68
+	 * @var array
69
+	 */
70
+	private $manifest_data = array();
71
+
72
+
73
+	/**
74
+	 * Registry constructor.
75
+	 * Hooking into WP actions for script registry.
76
+	 *
77
+	 * @param AssetCollection $assets
78
+	 * @param I18nRegistry    $i18n_registry
79
+	 */
80
+	public function __construct(AssetCollection $assets, I18nRegistry $i18n_registry)
81
+	{
82
+		$this->assets = $assets;
83
+		$this->i18n_registry = $i18n_registry;
84
+		add_action('wp_enqueue_scripts', array($this, 'registerManifestFiles'), 1);
85
+		add_action('admin_enqueue_scripts', array($this, 'registerManifestFiles'), 1);
86
+		add_action('wp_enqueue_scripts', array($this, 'registerScriptsAndStyles'), 3);
87
+		add_action('admin_enqueue_scripts', array($this, 'registerScriptsAndStyles'), 3);
88
+		add_action('wp_enqueue_scripts', array($this, 'enqueueData'), 4);
89
+		add_action('admin_enqueue_scripts', array($this, 'enqueueData'), 4);
90
+		add_action('wp_print_footer_scripts', array($this, 'enqueueData'), 1);
91
+		add_action('admin_print_footer_scripts', array($this, 'enqueueData'), 1);
92
+	}
93
+
94
+
95
+	/**
96
+	 * For classes that have Registry as a dependency, this provides a handy way to register script handles for i18n
97
+	 * translation handling.
98
+	 *
99
+	 * @return I18nRegistry
100
+	 */
101
+	public function getI18nRegistry()
102
+	{
103
+		return $this->i18n_registry;
104
+	}
105
+
106
+
107
+	/**
108
+	 * Callback for the wp_enqueue_scripts actions used to register assets.
109
+	 *
110
+	 * @since 4.9.62.p
111
+	 * @throws Exception
112
+	 */
113
+	public function registerScriptsAndStyles()
114
+	{
115
+		try {
116
+			$this->registerScripts($this->assets->getJavascriptAssets());
117
+			$this->registerStyles($this->assets->getStylesheetAssets());
118
+		} catch (Exception $exception) {
119
+			new ExceptionStackTraceDisplay($exception);
120
+		}
121
+	}
122
+
123
+
124
+	/**
125
+	 * Registers JS assets with WP core
126
+	 *
127
+	 * @since 4.9.62.p
128
+	 * @param JavascriptAsset[] $scripts
129
+	 * @throws AssetRegistrationException
130
+	 * @throws InvalidDataTypeException
131
+	 */
132
+	public function registerScripts(array $scripts)
133
+	{
134
+		foreach ($scripts as $script) {
135
+			// skip to next script if this has already been done
136
+			if ($script->isRegistered()) {
137
+				continue;
138
+			}
139
+			do_action(
140
+				'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__before_script',
141
+				$script
142
+			);
143
+			$registered = wp_register_script(
144
+				$script->handle(),
145
+				$script->source(),
146
+				$script->dependencies(),
147
+				$script->version(),
148
+				$script->loadInFooter()
149
+			);
150
+			if (! $registered && $this->debug()) {
151
+				throw new AssetRegistrationException($script->handle());
152
+			}
153
+			$script->setRegistered($registered);
154
+			if ($script->requiresTranslation()) {
155
+				$this->registerTranslation($script->handle());
156
+			}
157
+			do_action(
158
+				'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__after_script',
159
+				$script
160
+			);
161
+		}
162
+	}
163
+
164
+
165
+	/**
166
+	 * Registers CSS assets with WP core
167
+	 *
168
+	 * @since 4.9.62.p
169
+	 * @param StylesheetAsset[] $styles
170
+	 * @throws InvalidDataTypeException
171
+	 */
172
+	public function registerStyles(array $styles)
173
+	{
174
+		foreach ($styles as $style) {
175
+			// skip to next style if this has already been done
176
+			if ($style->isRegistered()) {
177
+				continue;
178
+			}
179
+			do_action(
180
+				'AHEE__EventEspresso_core_services_assets_Registry__registerStyles__before_style',
181
+				$style
182
+			);
183
+			wp_register_style(
184
+				$style->handle(),
185
+				$style->source(),
186
+				$style->dependencies(),
187
+				$style->version(),
188
+				$style->media()
189
+			);
190
+			$style->setRegistered();
191
+			do_action(
192
+				'AHEE__EventEspresso_core_services_assets_Registry__registerStyles__after_style',
193
+				$style
194
+			);
195
+		}
196
+	}
197
+
198
+
199
+	/**
200
+	 * Call back for the script print in frontend and backend.
201
+	 * Used to call wp_localize_scripts so that data can be added throughout the runtime until this later hook point.
202
+	 *
203
+	 * @since 4.9.31.rc.015
204
+	 */
205
+	public function enqueueData()
206
+	{
207
+		$this->removeAlreadyRegisteredDataForScriptHandles();
208
+		wp_add_inline_script(
209
+			'eejs-core',
210
+			'var eejsdata=' . wp_json_encode(array('data' => $this->jsdata)),
211
+			'before'
212
+		);
213
+		$scripts = $this->assets->getJavascriptAssetsWithData();
214
+		foreach ($scripts as $script) {
215
+			$this->addRegisteredScriptHandlesWithData($script->handle());
216
+			if ($script->hasInlineDataCallback()) {
217
+				$localize = $script->inlineDataCallback();
218
+				$localize();
219
+			}
220
+		}
221
+	}
222
+
223
+
224
+	/**
225
+	 * Used to add data to eejs.data object.
226
+	 * Note:  Overriding existing data is not allowed.
227
+	 * Data will be accessible as a javascript object when you list `eejs-core` as a dependency for your javascript.
228
+	 * If the data you add is something like this:
229
+	 *  $this->addData( 'my_plugin_data', array( 'foo' => 'gar' ) );
230
+	 * It will be exposed in the page source as:
231
+	 *  eejs.data.my_plugin_data.foo == gar
232
+	 *
233
+	 * @param string       $key   Key used to access your data
234
+	 * @param string|array $value Value to attach to key
235
+	 * @throws InvalidArgumentException
236
+	 */
237
+	public function addData($key, $value)
238
+	{
239
+		if ($this->verifyDataNotExisting($key)) {
240
+			$this->jsdata[ $key ] = $value;
241
+		}
242
+	}
243
+
244
+
245
+	/**
246
+	 * Similar to addData except this allows for users to push values to an existing key where the values on key are
247
+	 * elements in an array.
248
+	 *
249
+	 * When you use this method, the value you include will be merged with the array on $key.
250
+	 * So if the $key was 'test' and you added a value of ['my_data'] then it would be represented in the javascript
251
+	 * object like this, eejs.data.test = [ my_data,
252
+	 * ]
253
+	 * If there has already been a scalar value attached to the data object given key (via addData for instance), then
254
+	 * this will throw an exception.
255
+	 *
256
+	 * Caution: Only add data using this method if you are okay with the potential for additional data added on the same
257
+	 * key potentially overriding the existing data on merge (specifically with associative arrays).
258
+	 *
259
+	 * @param string       $key   Key to attach data to.
260
+	 * @param string|array $value Value being registered.
261
+	 * @throws InvalidArgumentException
262
+	 */
263
+	public function pushData($key, $value)
264
+	{
265
+		if (isset($this->jsdata[ $key ])
266
+			&& ! is_array($this->jsdata[ $key ])
267
+		) {
268
+			if (! $this->debug()) {
269
+				return;
270
+			}
271
+			throw new InvalidArgumentException(
272
+				sprintf(
273
+					__(
274
+						'The value for %1$s is already set and it is not an array. The %2$s method can only be used to
275 275
                          push values to this data element when it is an array.',
276
-                        'event_espresso'
277
-                    ),
278
-                    $key,
279
-                    __METHOD__
280
-                )
281
-            );
282
-        }
283
-        if ( ! isset( $this->jsdata[ $key ] ) ) {
284
-            $this->jsdata[ $key ] = is_array($value) ? $value : [$value];
285
-        } else {
286
-            $this->jsdata[ $key ] = array_merge( $this->jsdata[$key], (array) $value);
287
-        }
288
-    }
289
-
290
-
291
-    /**
292
-     * Used to set content used by javascript for a template.
293
-     * Note: Overrides of existing registered templates are not allowed.
294
-     *
295
-     * @param string $template_reference
296
-     * @param string $template_content
297
-     * @throws InvalidArgumentException
298
-     */
299
-    public function addTemplate($template_reference, $template_content)
300
-    {
301
-        if (! isset($this->jsdata['templates'])) {
302
-            $this->jsdata['templates'] = array();
303
-        }
304
-        //no overrides allowed.
305
-        if (isset($this->jsdata['templates'][ $template_reference ])) {
306
-            if (! $this->debug()) {
307
-                return;
308
-            }
309
-            throw new InvalidArgumentException(
310
-                sprintf(
311
-                    __(
312
-                        'The %1$s key already exists for the templates array in the js data array.  No overrides are allowed.',
313
-                        'event_espresso'
314
-                    ),
315
-                    $template_reference
316
-                )
317
-            );
318
-        }
319
-        $this->jsdata['templates'][ $template_reference ] = $template_content;
320
-    }
321
-
322
-
323
-    /**
324
-     * Retrieve the template content already registered for the given reference.
325
-     *
326
-     * @param string $template_reference
327
-     * @return string
328
-     */
329
-    public function getTemplate($template_reference)
330
-    {
331
-        return isset($this->jsdata['templates'][ $template_reference ])
332
-            ? $this->jsdata['templates'][ $template_reference ]
333
-            : '';
334
-    }
335
-
336
-
337
-    /**
338
-     * Retrieve registered data.
339
-     *
340
-     * @param string $key Name of key to attach data to.
341
-     * @return mixed                If there is no for the given key, then false is returned.
342
-     */
343
-    public function getData($key)
344
-    {
345
-        return isset($this->jsdata[ $key ])
346
-            ? $this->jsdata[ $key ]
347
-            : false;
348
-    }
349
-
350
-
351
-    /**
352
-     * Verifies whether the given data exists already on the jsdata array.
353
-     * Overriding data is not allowed.
354
-     *
355
-     * @param string $key Index for data.
356
-     * @return bool        If valid then return true.
357
-     * @throws InvalidArgumentException if data already exists.
358
-     */
359
-    protected function verifyDataNotExisting($key)
360
-    {
361
-        if (isset($this->jsdata[ $key ])) {
362
-            if (! $this->debug()) {
363
-                return false;
364
-            }
365
-            if (is_array($this->jsdata[ $key ])) {
366
-                throw new InvalidArgumentException(
367
-                    sprintf(
368
-                        __(
369
-                            'The value for %1$s already exists in the Registry::eejs object.
276
+						'event_espresso'
277
+					),
278
+					$key,
279
+					__METHOD__
280
+				)
281
+			);
282
+		}
283
+		if ( ! isset( $this->jsdata[ $key ] ) ) {
284
+			$this->jsdata[ $key ] = is_array($value) ? $value : [$value];
285
+		} else {
286
+			$this->jsdata[ $key ] = array_merge( $this->jsdata[$key], (array) $value);
287
+		}
288
+	}
289
+
290
+
291
+	/**
292
+	 * Used to set content used by javascript for a template.
293
+	 * Note: Overrides of existing registered templates are not allowed.
294
+	 *
295
+	 * @param string $template_reference
296
+	 * @param string $template_content
297
+	 * @throws InvalidArgumentException
298
+	 */
299
+	public function addTemplate($template_reference, $template_content)
300
+	{
301
+		if (! isset($this->jsdata['templates'])) {
302
+			$this->jsdata['templates'] = array();
303
+		}
304
+		//no overrides allowed.
305
+		if (isset($this->jsdata['templates'][ $template_reference ])) {
306
+			if (! $this->debug()) {
307
+				return;
308
+			}
309
+			throw new InvalidArgumentException(
310
+				sprintf(
311
+					__(
312
+						'The %1$s key already exists for the templates array in the js data array.  No overrides are allowed.',
313
+						'event_espresso'
314
+					),
315
+					$template_reference
316
+				)
317
+			);
318
+		}
319
+		$this->jsdata['templates'][ $template_reference ] = $template_content;
320
+	}
321
+
322
+
323
+	/**
324
+	 * Retrieve the template content already registered for the given reference.
325
+	 *
326
+	 * @param string $template_reference
327
+	 * @return string
328
+	 */
329
+	public function getTemplate($template_reference)
330
+	{
331
+		return isset($this->jsdata['templates'][ $template_reference ])
332
+			? $this->jsdata['templates'][ $template_reference ]
333
+			: '';
334
+	}
335
+
336
+
337
+	/**
338
+	 * Retrieve registered data.
339
+	 *
340
+	 * @param string $key Name of key to attach data to.
341
+	 * @return mixed                If there is no for the given key, then false is returned.
342
+	 */
343
+	public function getData($key)
344
+	{
345
+		return isset($this->jsdata[ $key ])
346
+			? $this->jsdata[ $key ]
347
+			: false;
348
+	}
349
+
350
+
351
+	/**
352
+	 * Verifies whether the given data exists already on the jsdata array.
353
+	 * Overriding data is not allowed.
354
+	 *
355
+	 * @param string $key Index for data.
356
+	 * @return bool        If valid then return true.
357
+	 * @throws InvalidArgumentException if data already exists.
358
+	 */
359
+	protected function verifyDataNotExisting($key)
360
+	{
361
+		if (isset($this->jsdata[ $key ])) {
362
+			if (! $this->debug()) {
363
+				return false;
364
+			}
365
+			if (is_array($this->jsdata[ $key ])) {
366
+				throw new InvalidArgumentException(
367
+					sprintf(
368
+						__(
369
+							'The value for %1$s already exists in the Registry::eejs object.
370 370
                             Overrides are not allowed. Since the value of this data is an array, you may want to use the
371 371
                             %2$s method to push your value to the array.',
372
-                            'event_espresso'
373
-                        ),
374
-                        $key,
375
-                        'pushData()'
376
-                    )
377
-                );
378
-            }
379
-            throw new InvalidArgumentException(
380
-                sprintf(
381
-                    __(
382
-                        'The value for %1$s already exists in the Registry::eejs object. Overrides are not
372
+							'event_espresso'
373
+						),
374
+						$key,
375
+						'pushData()'
376
+					)
377
+				);
378
+			}
379
+			throw new InvalidArgumentException(
380
+				sprintf(
381
+					__(
382
+						'The value for %1$s already exists in the Registry::eejs object. Overrides are not
383 383
                         allowed.  Consider attaching your value to a different key',
384
-                        'event_espresso'
385
-                    ),
386
-                    $key
387
-                )
388
-            );
389
-        }
390
-        return true;
391
-    }
392
-
393
-
394
-    /**
395
-     * Get the actual asset path for asset manifests.
396
-     * If there is no asset path found for the given $chunk_name, then the $chunk_name is returned.
397
-     *
398
-     * @param string $namespace  The namespace associated with the manifest file hosting the map of chunk_name to actual
399
-     *                           asset file location.
400
-     * @param string $chunk_name
401
-     * @param string $asset_type
402
-     * @return string
403
-     * @since 4.9.59.p
404
-     */
405
-    public function getAssetUrl($namespace, $chunk_name, $asset_type)
406
-    {
407
-        $url = isset(
408
-            $this->manifest_data[ $namespace ][ $chunk_name . '.' . $asset_type ],
409
-            $this->manifest_data[ $namespace ]['url_base']
410
-        )
411
-            ? $this->manifest_data[ $namespace ]['url_base']
412
-              . $this->manifest_data[ $namespace ][ $chunk_name . '.' . $asset_type ]
413
-            : $chunk_name;
414
-
415
-        return apply_filters(
416
-            'FHEE__EventEspresso_core_services_assets_Registry__getAssetUrl',
417
-            $url,
418
-            $namespace,
419
-            $chunk_name,
420
-            $asset_type
421
-        );
422
-    }
423
-
424
-
425
-
426
-    /**
427
-     * Return the url to a js file for the given namespace and chunk name.
428
-     *
429
-     * @param string $namespace
430
-     * @param string $chunk_name
431
-     * @return string
432
-     */
433
-    public function getJsUrl($namespace, $chunk_name)
434
-    {
435
-        return $this->getAssetUrl($namespace, $chunk_name, Asset::TYPE_JS);
436
-    }
437
-
438
-
439
-    /**
440
-     * Return the url to a css file for the given namespace and chunk name.
441
-     *
442
-     * @param string $namespace
443
-     * @param string $chunk_name
444
-     * @return string
445
-     */
446
-    public function getCssUrl($namespace, $chunk_name)
447
-    {
448
-        return $this->getAssetUrl($namespace, $chunk_name, Asset::TYPE_CSS);
449
-    }
450
-
451
-
452
-    /**
453
-     * @since 4.9.62.p
454
-     * @throws InvalidArgumentException
455
-     * @throws InvalidFilePathException
456
-     */
457
-    public function registerManifestFiles()
458
-    {
459
-        $manifest_files = $this->assets->getManifestFiles();
460
-        foreach ($manifest_files as $manifest_file) {
461
-            $this->registerManifestFile(
462
-                $manifest_file->assetNamespace(),
463
-                $manifest_file->urlBase(),
464
-                $manifest_file->filepath() . Registry::FILE_NAME_BUILD_MANIFEST
465
-            );
466
-        }
467
-    }
468
-
469
-
470
-    /**
471
-     * Used to register a js/css manifest file with the registered_manifest_files property.
472
-     *
473
-     * @param string $namespace     Provided to associate the manifest file with a specific namespace.
474
-     * @param string $url_base      The url base for the manifest file location.
475
-     * @param string $manifest_file The absolute path to the manifest file.
476
-     * @throws InvalidArgumentException
477
-     * @throws InvalidFilePathException
478
-     * @since 4.9.59.p
479
-     */
480
-    public function registerManifestFile($namespace, $url_base, $manifest_file)
481
-    {
482
-        if (isset($this->manifest_data[ $namespace ])) {
483
-            if (! $this->debug()) {
484
-                return;
485
-            }
486
-            throw new InvalidArgumentException(
487
-                sprintf(
488
-                    esc_html__(
489
-                        'The namespace for this manifest file has already been registered, choose a namespace other than %s',
490
-                        'event_espresso'
491
-                    ),
492
-                    $namespace
493
-                )
494
-            );
495
-        }
496
-        if (filter_var($url_base, FILTER_VALIDATE_URL) === false) {
497
-            if (is_admin()) {
498
-                EE_Error::add_error(
499
-                    sprintf(
500
-                        esc_html__(
501
-                            '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',
502
-                            'event_espresso'
503
-                        ),
504
-                        'Event Espresso',
505
-                        $url_base,
506
-                        'plugins_url',
507
-                        'WP_PLUGIN_URL'
508
-                    ),
509
-                    __FILE__,
510
-                    __FUNCTION__,
511
-                    __LINE__
512
-                );
513
-            }
514
-            return;
515
-        }
516
-        $this->manifest_data[ $namespace ] = $this->decodeManifestFile($manifest_file);
517
-        if (! isset($this->manifest_data[ $namespace ]['url_base'])) {
518
-            $this->manifest_data[ $namespace ]['url_base'] = trailingslashit($url_base);
519
-        }
520
-    }
521
-
522
-
523
-    /**
524
-     * Decodes json from the provided manifest file.
525
-     *
526
-     * @since 4.9.59.p
527
-     * @param string $manifest_file Path to manifest file.
528
-     * @return array
529
-     * @throws InvalidFilePathException
530
-     */
531
-    private function decodeManifestFile($manifest_file)
532
-    {
533
-        if (! file_exists($manifest_file)) {
534
-            throw new InvalidFilePathException($manifest_file);
535
-        }
536
-        return json_decode(file_get_contents($manifest_file), true);
537
-    }
538
-
539
-
540
-    /**
541
-     * This is used to set registered script handles that have data.
542
-     *
543
-     * @param string $script_handle
544
-     */
545
-    private function addRegisteredScriptHandlesWithData($script_handle)
546
-    {
547
-        $this->script_handles_with_data[ $script_handle ] = $script_handle;
548
-    }
549
-
550
-
551
-    /**i
384
+						'event_espresso'
385
+					),
386
+					$key
387
+				)
388
+			);
389
+		}
390
+		return true;
391
+	}
392
+
393
+
394
+	/**
395
+	 * Get the actual asset path for asset manifests.
396
+	 * If there is no asset path found for the given $chunk_name, then the $chunk_name is returned.
397
+	 *
398
+	 * @param string $namespace  The namespace associated with the manifest file hosting the map of chunk_name to actual
399
+	 *                           asset file location.
400
+	 * @param string $chunk_name
401
+	 * @param string $asset_type
402
+	 * @return string
403
+	 * @since 4.9.59.p
404
+	 */
405
+	public function getAssetUrl($namespace, $chunk_name, $asset_type)
406
+	{
407
+		$url = isset(
408
+			$this->manifest_data[ $namespace ][ $chunk_name . '.' . $asset_type ],
409
+			$this->manifest_data[ $namespace ]['url_base']
410
+		)
411
+			? $this->manifest_data[ $namespace ]['url_base']
412
+			  . $this->manifest_data[ $namespace ][ $chunk_name . '.' . $asset_type ]
413
+			: $chunk_name;
414
+
415
+		return apply_filters(
416
+			'FHEE__EventEspresso_core_services_assets_Registry__getAssetUrl',
417
+			$url,
418
+			$namespace,
419
+			$chunk_name,
420
+			$asset_type
421
+		);
422
+	}
423
+
424
+
425
+
426
+	/**
427
+	 * Return the url to a js file for the given namespace and chunk name.
428
+	 *
429
+	 * @param string $namespace
430
+	 * @param string $chunk_name
431
+	 * @return string
432
+	 */
433
+	public function getJsUrl($namespace, $chunk_name)
434
+	{
435
+		return $this->getAssetUrl($namespace, $chunk_name, Asset::TYPE_JS);
436
+	}
437
+
438
+
439
+	/**
440
+	 * Return the url to a css file for the given namespace and chunk name.
441
+	 *
442
+	 * @param string $namespace
443
+	 * @param string $chunk_name
444
+	 * @return string
445
+	 */
446
+	public function getCssUrl($namespace, $chunk_name)
447
+	{
448
+		return $this->getAssetUrl($namespace, $chunk_name, Asset::TYPE_CSS);
449
+	}
450
+
451
+
452
+	/**
453
+	 * @since 4.9.62.p
454
+	 * @throws InvalidArgumentException
455
+	 * @throws InvalidFilePathException
456
+	 */
457
+	public function registerManifestFiles()
458
+	{
459
+		$manifest_files = $this->assets->getManifestFiles();
460
+		foreach ($manifest_files as $manifest_file) {
461
+			$this->registerManifestFile(
462
+				$manifest_file->assetNamespace(),
463
+				$manifest_file->urlBase(),
464
+				$manifest_file->filepath() . Registry::FILE_NAME_BUILD_MANIFEST
465
+			);
466
+		}
467
+	}
468
+
469
+
470
+	/**
471
+	 * Used to register a js/css manifest file with the registered_manifest_files property.
472
+	 *
473
+	 * @param string $namespace     Provided to associate the manifest file with a specific namespace.
474
+	 * @param string $url_base      The url base for the manifest file location.
475
+	 * @param string $manifest_file The absolute path to the manifest file.
476
+	 * @throws InvalidArgumentException
477
+	 * @throws InvalidFilePathException
478
+	 * @since 4.9.59.p
479
+	 */
480
+	public function registerManifestFile($namespace, $url_base, $manifest_file)
481
+	{
482
+		if (isset($this->manifest_data[ $namespace ])) {
483
+			if (! $this->debug()) {
484
+				return;
485
+			}
486
+			throw new InvalidArgumentException(
487
+				sprintf(
488
+					esc_html__(
489
+						'The namespace for this manifest file has already been registered, choose a namespace other than %s',
490
+						'event_espresso'
491
+					),
492
+					$namespace
493
+				)
494
+			);
495
+		}
496
+		if (filter_var($url_base, FILTER_VALIDATE_URL) === false) {
497
+			if (is_admin()) {
498
+				EE_Error::add_error(
499
+					sprintf(
500
+						esc_html__(
501
+							'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',
502
+							'event_espresso'
503
+						),
504
+						'Event Espresso',
505
+						$url_base,
506
+						'plugins_url',
507
+						'WP_PLUGIN_URL'
508
+					),
509
+					__FILE__,
510
+					__FUNCTION__,
511
+					__LINE__
512
+				);
513
+			}
514
+			return;
515
+		}
516
+		$this->manifest_data[ $namespace ] = $this->decodeManifestFile($manifest_file);
517
+		if (! isset($this->manifest_data[ $namespace ]['url_base'])) {
518
+			$this->manifest_data[ $namespace ]['url_base'] = trailingslashit($url_base);
519
+		}
520
+	}
521
+
522
+
523
+	/**
524
+	 * Decodes json from the provided manifest file.
525
+	 *
526
+	 * @since 4.9.59.p
527
+	 * @param string $manifest_file Path to manifest file.
528
+	 * @return array
529
+	 * @throws InvalidFilePathException
530
+	 */
531
+	private function decodeManifestFile($manifest_file)
532
+	{
533
+		if (! file_exists($manifest_file)) {
534
+			throw new InvalidFilePathException($manifest_file);
535
+		}
536
+		return json_decode(file_get_contents($manifest_file), true);
537
+	}
538
+
539
+
540
+	/**
541
+	 * This is used to set registered script handles that have data.
542
+	 *
543
+	 * @param string $script_handle
544
+	 */
545
+	private function addRegisteredScriptHandlesWithData($script_handle)
546
+	{
547
+		$this->script_handles_with_data[ $script_handle ] = $script_handle;
548
+	}
549
+
550
+
551
+	/**i
552 552
      * Checks WP_Scripts for all of each script handle registered internally as having data and unsets from the
553 553
      * Dependency stored in WP_Scripts if its set.
554 554
      */
555
-    private function removeAlreadyRegisteredDataForScriptHandles()
556
-    {
557
-        if (empty($this->script_handles_with_data)) {
558
-            return;
559
-        }
560
-        foreach ($this->script_handles_with_data as $script_handle) {
561
-            $this->removeAlreadyRegisteredDataForScriptHandle($script_handle);
562
-        }
563
-    }
564
-
565
-
566
-    /**
567
-     * Removes any data dependency registered in WP_Scripts if its set.
568
-     *
569
-     * @param string $script_handle
570
-     */
571
-    private function removeAlreadyRegisteredDataForScriptHandle($script_handle)
572
-    {
573
-        if (isset($this->script_handles_with_data[ $script_handle ])) {
574
-            global $wp_scripts;
575
-            $unset_handle = false;
576
-            if ($wp_scripts->get_data($script_handle, 'data')) {
577
-                unset($wp_scripts->registered[ $script_handle ]->extra['data']);
578
-                $unset_handle = true;
579
-            }
580
-            //deal with inline_scripts
581
-            if ($wp_scripts->get_data($script_handle, 'before')) {
582
-                unset($wp_scripts->registered[ $script_handle ]->extra['before']);
583
-                $unset_handle = true;
584
-            }
585
-            if ($wp_scripts->get_data($script_handle, 'after')) {
586
-                unset($wp_scripts->registered[ $script_handle ]->extra['after']);
587
-            }
588
-            if ($unset_handle) {
589
-                unset($this->script_handles_with_data[ $script_handle ]);
590
-            }
591
-        }
592
-    }
593
-
594
-
595
-    /**
596
-     * register translations for a registered script
597
-     *
598
-     * @param string $handle
599
-     */
600
-    public function registerTranslation($handle)
601
-    {
602
-        $this->i18n_registry->registerScriptI18n($handle);
603
-    }
604
-
605
-
606
-    /**
607
-     * @since 4.9.63.p
608
-     * @return bool
609
-     */
610
-    private function debug()
611
-    {
612
-        return apply_filters(
613
-            'FHEE__EventEspresso_core_services_assets_Registry__debug',
614
-            defined('EE_DEBUG') && EE_DEBUG
615
-        );
616
-    }
555
+	private function removeAlreadyRegisteredDataForScriptHandles()
556
+	{
557
+		if (empty($this->script_handles_with_data)) {
558
+			return;
559
+		}
560
+		foreach ($this->script_handles_with_data as $script_handle) {
561
+			$this->removeAlreadyRegisteredDataForScriptHandle($script_handle);
562
+		}
563
+	}
564
+
565
+
566
+	/**
567
+	 * Removes any data dependency registered in WP_Scripts if its set.
568
+	 *
569
+	 * @param string $script_handle
570
+	 */
571
+	private function removeAlreadyRegisteredDataForScriptHandle($script_handle)
572
+	{
573
+		if (isset($this->script_handles_with_data[ $script_handle ])) {
574
+			global $wp_scripts;
575
+			$unset_handle = false;
576
+			if ($wp_scripts->get_data($script_handle, 'data')) {
577
+				unset($wp_scripts->registered[ $script_handle ]->extra['data']);
578
+				$unset_handle = true;
579
+			}
580
+			//deal with inline_scripts
581
+			if ($wp_scripts->get_data($script_handle, 'before')) {
582
+				unset($wp_scripts->registered[ $script_handle ]->extra['before']);
583
+				$unset_handle = true;
584
+			}
585
+			if ($wp_scripts->get_data($script_handle, 'after')) {
586
+				unset($wp_scripts->registered[ $script_handle ]->extra['after']);
587
+			}
588
+			if ($unset_handle) {
589
+				unset($this->script_handles_with_data[ $script_handle ]);
590
+			}
591
+		}
592
+	}
593
+
594
+
595
+	/**
596
+	 * register translations for a registered script
597
+	 *
598
+	 * @param string $handle
599
+	 */
600
+	public function registerTranslation($handle)
601
+	{
602
+		$this->i18n_registry->registerScriptI18n($handle);
603
+	}
604
+
605
+
606
+	/**
607
+	 * @since 4.9.63.p
608
+	 * @return bool
609
+	 */
610
+	private function debug()
611
+	{
612
+		return apply_filters(
613
+			'FHEE__EventEspresso_core_services_assets_Registry__debug',
614
+			defined('EE_DEBUG') && EE_DEBUG
615
+		);
616
+	}
617 617
 }
Please login to merge, or discard this patch.
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
                 $script->version(),
148 148
                 $script->loadInFooter()
149 149
             );
150
-            if (! $registered && $this->debug()) {
150
+            if ( ! $registered && $this->debug()) {
151 151
                 throw new AssetRegistrationException($script->handle());
152 152
             }
153 153
             $script->setRegistered($registered);
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
         $this->removeAlreadyRegisteredDataForScriptHandles();
208 208
         wp_add_inline_script(
209 209
             'eejs-core',
210
-            'var eejsdata=' . wp_json_encode(array('data' => $this->jsdata)),
210
+            'var eejsdata='.wp_json_encode(array('data' => $this->jsdata)),
211 211
             'before'
212 212
         );
213 213
         $scripts = $this->assets->getJavascriptAssetsWithData();
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
     public function addData($key, $value)
238 238
     {
239 239
         if ($this->verifyDataNotExisting($key)) {
240
-            $this->jsdata[ $key ] = $value;
240
+            $this->jsdata[$key] = $value;
241 241
         }
242 242
     }
243 243
 
@@ -262,10 +262,10 @@  discard block
 block discarded – undo
262 262
      */
263 263
     public function pushData($key, $value)
264 264
     {
265
-        if (isset($this->jsdata[ $key ])
266
-            && ! is_array($this->jsdata[ $key ])
265
+        if (isset($this->jsdata[$key])
266
+            && ! is_array($this->jsdata[$key])
267 267
         ) {
268
-            if (! $this->debug()) {
268
+            if ( ! $this->debug()) {
269 269
                 return;
270 270
             }
271 271
             throw new InvalidArgumentException(
@@ -280,10 +280,10 @@  discard block
 block discarded – undo
280 280
                 )
281 281
             );
282 282
         }
283
-        if ( ! isset( $this->jsdata[ $key ] ) ) {
284
-            $this->jsdata[ $key ] = is_array($value) ? $value : [$value];
283
+        if ( ! isset($this->jsdata[$key])) {
284
+            $this->jsdata[$key] = is_array($value) ? $value : [$value];
285 285
         } else {
286
-            $this->jsdata[ $key ] = array_merge( $this->jsdata[$key], (array) $value);
286
+            $this->jsdata[$key] = array_merge($this->jsdata[$key], (array) $value);
287 287
         }
288 288
     }
289 289
 
@@ -298,12 +298,12 @@  discard block
 block discarded – undo
298 298
      */
299 299
     public function addTemplate($template_reference, $template_content)
300 300
     {
301
-        if (! isset($this->jsdata['templates'])) {
301
+        if ( ! isset($this->jsdata['templates'])) {
302 302
             $this->jsdata['templates'] = array();
303 303
         }
304 304
         //no overrides allowed.
305
-        if (isset($this->jsdata['templates'][ $template_reference ])) {
306
-            if (! $this->debug()) {
305
+        if (isset($this->jsdata['templates'][$template_reference])) {
306
+            if ( ! $this->debug()) {
307 307
                 return;
308 308
             }
309 309
             throw new InvalidArgumentException(
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
                 )
317 317
             );
318 318
         }
319
-        $this->jsdata['templates'][ $template_reference ] = $template_content;
319
+        $this->jsdata['templates'][$template_reference] = $template_content;
320 320
     }
321 321
 
322 322
 
@@ -328,8 +328,8 @@  discard block
 block discarded – undo
328 328
      */
329 329
     public function getTemplate($template_reference)
330 330
     {
331
-        return isset($this->jsdata['templates'][ $template_reference ])
332
-            ? $this->jsdata['templates'][ $template_reference ]
331
+        return isset($this->jsdata['templates'][$template_reference])
332
+            ? $this->jsdata['templates'][$template_reference]
333 333
             : '';
334 334
     }
335 335
 
@@ -342,8 +342,8 @@  discard block
 block discarded – undo
342 342
      */
343 343
     public function getData($key)
344 344
     {
345
-        return isset($this->jsdata[ $key ])
346
-            ? $this->jsdata[ $key ]
345
+        return isset($this->jsdata[$key])
346
+            ? $this->jsdata[$key]
347 347
             : false;
348 348
     }
349 349
 
@@ -358,11 +358,11 @@  discard block
 block discarded – undo
358 358
      */
359 359
     protected function verifyDataNotExisting($key)
360 360
     {
361
-        if (isset($this->jsdata[ $key ])) {
362
-            if (! $this->debug()) {
361
+        if (isset($this->jsdata[$key])) {
362
+            if ( ! $this->debug()) {
363 363
                 return false;
364 364
             }
365
-            if (is_array($this->jsdata[ $key ])) {
365
+            if (is_array($this->jsdata[$key])) {
366 366
                 throw new InvalidArgumentException(
367 367
                     sprintf(
368 368
                         __(
@@ -405,11 +405,11 @@  discard block
 block discarded – undo
405 405
     public function getAssetUrl($namespace, $chunk_name, $asset_type)
406 406
     {
407 407
         $url = isset(
408
-            $this->manifest_data[ $namespace ][ $chunk_name . '.' . $asset_type ],
409
-            $this->manifest_data[ $namespace ]['url_base']
408
+            $this->manifest_data[$namespace][$chunk_name.'.'.$asset_type],
409
+            $this->manifest_data[$namespace]['url_base']
410 410
         )
411
-            ? $this->manifest_data[ $namespace ]['url_base']
412
-              . $this->manifest_data[ $namespace ][ $chunk_name . '.' . $asset_type ]
411
+            ? $this->manifest_data[$namespace]['url_base']
412
+              . $this->manifest_data[$namespace][$chunk_name.'.'.$asset_type]
413 413
             : $chunk_name;
414 414
 
415 415
         return apply_filters(
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
             $this->registerManifestFile(
462 462
                 $manifest_file->assetNamespace(),
463 463
                 $manifest_file->urlBase(),
464
-                $manifest_file->filepath() . Registry::FILE_NAME_BUILD_MANIFEST
464
+                $manifest_file->filepath().Registry::FILE_NAME_BUILD_MANIFEST
465 465
             );
466 466
         }
467 467
     }
@@ -479,8 +479,8 @@  discard block
 block discarded – undo
479 479
      */
480 480
     public function registerManifestFile($namespace, $url_base, $manifest_file)
481 481
     {
482
-        if (isset($this->manifest_data[ $namespace ])) {
483
-            if (! $this->debug()) {
482
+        if (isset($this->manifest_data[$namespace])) {
483
+            if ( ! $this->debug()) {
484 484
                 return;
485 485
             }
486 486
             throw new InvalidArgumentException(
@@ -513,9 +513,9 @@  discard block
 block discarded – undo
513 513
             }
514 514
             return;
515 515
         }
516
-        $this->manifest_data[ $namespace ] = $this->decodeManifestFile($manifest_file);
517
-        if (! isset($this->manifest_data[ $namespace ]['url_base'])) {
518
-            $this->manifest_data[ $namespace ]['url_base'] = trailingslashit($url_base);
516
+        $this->manifest_data[$namespace] = $this->decodeManifestFile($manifest_file);
517
+        if ( ! isset($this->manifest_data[$namespace]['url_base'])) {
518
+            $this->manifest_data[$namespace]['url_base'] = trailingslashit($url_base);
519 519
         }
520 520
     }
521 521
 
@@ -530,7 +530,7 @@  discard block
 block discarded – undo
530 530
      */
531 531
     private function decodeManifestFile($manifest_file)
532 532
     {
533
-        if (! file_exists($manifest_file)) {
533
+        if ( ! file_exists($manifest_file)) {
534 534
             throw new InvalidFilePathException($manifest_file);
535 535
         }
536 536
         return json_decode(file_get_contents($manifest_file), true);
@@ -544,7 +544,7 @@  discard block
 block discarded – undo
544 544
      */
545 545
     private function addRegisteredScriptHandlesWithData($script_handle)
546 546
     {
547
-        $this->script_handles_with_data[ $script_handle ] = $script_handle;
547
+        $this->script_handles_with_data[$script_handle] = $script_handle;
548 548
     }
549 549
 
550 550
 
@@ -570,23 +570,23 @@  discard block
 block discarded – undo
570 570
      */
571 571
     private function removeAlreadyRegisteredDataForScriptHandle($script_handle)
572 572
     {
573
-        if (isset($this->script_handles_with_data[ $script_handle ])) {
573
+        if (isset($this->script_handles_with_data[$script_handle])) {
574 574
             global $wp_scripts;
575 575
             $unset_handle = false;
576 576
             if ($wp_scripts->get_data($script_handle, 'data')) {
577
-                unset($wp_scripts->registered[ $script_handle ]->extra['data']);
577
+                unset($wp_scripts->registered[$script_handle]->extra['data']);
578 578
                 $unset_handle = true;
579 579
             }
580 580
             //deal with inline_scripts
581 581
             if ($wp_scripts->get_data($script_handle, 'before')) {
582
-                unset($wp_scripts->registered[ $script_handle ]->extra['before']);
582
+                unset($wp_scripts->registered[$script_handle]->extra['before']);
583 583
                 $unset_handle = true;
584 584
             }
585 585
             if ($wp_scripts->get_data($script_handle, 'after')) {
586
-                unset($wp_scripts->registered[ $script_handle ]->extra['after']);
586
+                unset($wp_scripts->registered[$script_handle]->extra['after']);
587 587
             }
588 588
             if ($unset_handle) {
589
-                unset($this->script_handles_with_data[ $script_handle ]);
589
+                unset($this->script_handles_with_data[$script_handle]);
590 590
             }
591 591
         }
592 592
     }
Please login to merge, or discard this patch.
core/admin/EE_Admin_Hooks.core.php 2 patches
Indentation   +718 added lines, -718 removed lines patch added patch discarded remove patch
@@ -13,722 +13,722 @@
 block discarded – undo
13 13
 {
14 14
 
15 15
 
16
-    /**
17
-     * we're just going to use this to hold the name of the caller class (child class name)
18
-     *
19
-     * @var string
20
-     */
21
-    public $caller;
22
-
23
-
24
-    /**
25
-     * this is just a flag set automatically to indicate whether we've got an extended hook class running (i.e.
26
-     * espresso_events_Registration_Form_Hooks_Extend extends espresso_events_Registration_Form_Hooks).  This flag is
27
-     * used later to make sure we require the needed files.
28
-     *
29
-     * @var bool
30
-     */
31
-    protected $_extend;
32
-
33
-
34
-    /**
35
-     * child classes MUST set this property so that the page object can be loaded correctly
36
-     *
37
-     * @var string
38
-     */
39
-    protected $_name;
40
-
41
-
42
-    /**
43
-     * This is set by child classes and is an associative array of ajax hooks in the format:
44
-     * array(
45
-     *    'ajax_action_ref' => 'executing_method'; //must be public
46
-     * )
47
-     *
48
-     * @var array
49
-     */
50
-    protected $_ajax_func;
51
-
52
-
53
-    /**
54
-     * This is an array of methods that get executed on a page routes admin_init hook. Use the following format:
55
-     * array(
56
-     *    'page_route' => 'executing_method' //must be public
57
-     * )
58
-     *
59
-     * @var array
60
-     */
61
-    protected $_init_func;
62
-
63
-
64
-    /**
65
-     * This is an array of methods that output metabox content for the given page route.  Use the following format:
66
-     * array(
67
-     *    0 => array(
68
-     *        'page_route' => 'string_for_page_route', //must correspond to a page route in the class being connected
69
-     *        with (i.e. "edit_event") If this is in an array then the same params below will be used but the metabox
70
-     *        will be added to each route.
71
-     *        'func' =>  'executing_method',  //must be public (i.e. public function executing_method($post,
72
-     *        $callback_args){} ).  Note if you include callback args in the array then you need to declare them in the
73
-     *        method arguments.
74
-     *        'id' => 'identifier_for_metabox', //so it can be removed by addons (optional, class will set it
75
-     *        automatically)
76
-     *        'priority' => 'default', //default 'default' (optional)
77
-     *        'label' => __('Localized Title', 'event_espresso'),
78
-     *        'context' => 'advanced' //advanced is default (optional),
79
-     *    'callback_args' => array() //any callback args to include (optional)
80
-     * )
81
-     * Why are we indexing numerically?  Because it's possible there may be more than one metabox per page_route.
82
-     *
83
-     * @var array
84
-     */
85
-    protected $_metaboxes;
86
-
87
-
88
-    /**
89
-     * This is an array of values that indicate any metaboxes we want removed from a given page route.  Usually this is
90
-     * used when caffeinated functionality is replacing decaffeinated functionality.  Use the following format for the
91
-     * array: array(
92
-     *    0 => array(
93
-     *        'page_route' => 'string_for_page_route' //can be string or array of strings that match a page_route(s)
94
-     *        that are in the class being connected with (i.e. 'edit', or 'create_new').
95
-     *        'id' => 'identifier_for_metabox', //what the id is of the metabox being removed
96
-     *        'context' => 'normal', //the context for the metabox being removed (has to match)
97
-     *        'screen' => 'screen_id', //(optional), if not included then this class will attempt to remove the metabox
98
-     *        using the currently loaded screen object->id  however, there may be cases where you have to specify the
99
-     *        id for the screen the metabox is on.
100
-     *    )
101
-     * )
102
-     *
103
-     * @var array
104
-     */
105
-    protected $_remove_metaboxes;
106
-
107
-
108
-    /**
109
-     * This parent class takes care of loading the scripts and styles if the child class has set the properties for
110
-     * them in the following format.  Note, the first array index ('register') is for defining all the registers.  The
111
-     * second array index is for indicating what routes each script/style loads on. array(
112
-     * 'registers' => array(
113
-     *        'script_ref' => array( // if more than one script is to be loaded its best to use the 'dependency'
114
-     *        argument to link scripts together.
115
-     *            'type' => 'js' // 'js' or 'css' (defaults to js).  This tells us what type of wp_function to use
116
-     *            'url' => 'http://urltoscript.css.js',
117
-     *            'depends' => array('jquery'), //an array of dependencies for the scripts. REMEMBER, if a script has
118
-     *            already been registered elsewhere in the system.  You can just use the depends array to make sure it
119
-     *            gets loaded before the one you are setting here.
120
-     *            'footer' => TRUE //defaults to true (styles don't use this parameter)
121
-     *        ),
122
-     *    'enqueues' => array( //this time each key corresponds to the script ref followed by an array of page routes
123
-     *    the script gets enqueued on.
124
-     *        'script_ref' => array('route_one', 'route_two')
125
-     *    ),
126
-     *    'localize' => array( //this allows you to set a localize object.  Indicate which script the object is being
127
-     *    attached to and then include an array indexed by the name of the object and the array of key/value pairs for
128
-     *    the object.
129
-     *        'scrip_ref' => array(
130
-     *            'NAME_OF_JS_OBJECT' => array(
131
-     *                'translate_ref' => __('localized_string', 'event_espresso'),
132
-     *                'some_data' => 5
133
-     *            )
134
-     *        )
135
-     *    )
136
-     * )
137
-     *
138
-     * @var array
139
-     */
140
-    protected $_scripts_styles;
141
-
142
-
143
-    /**
144
-     * This is a property that will contain the current route.
145
-     *
146
-     * @var string;
147
-     */
148
-    protected $_current_route;
149
-
150
-
151
-    /**
152
-     * this optional property can be set by child classes to override the priority for the automatic action/filter hook
153
-     * loading in the `_load_routed_hooks()` method.  Please follow this format: array(
154
-     *    'wp_hook_reference' => 1
155
-     *    )
156
-     * )
157
-     *
158
-     * @var array
159
-     */
160
-    protected $_wp_action_filters_priority;
161
-
162
-
163
-    /**
164
-     * This just holds a merged array of the $_POST and $_GET vars in favor of $_POST
165
-     *
166
-     * @var array
167
-     */
168
-    protected $_req_data;
169
-
170
-
171
-    /**
172
-     * This just holds an instance of the page object for this hook
173
-     *
174
-     * @var EE_Admin_Page
175
-     */
176
-    protected $_page_object;
177
-
178
-
179
-    /**
180
-     * This holds the EE_Admin_Page object from the calling admin page that this object hooks into.
181
-     *
182
-     * @var EE_Admin_Page|EE_Admin_Page_CPT
183
-     */
184
-    protected $_adminpage_obj;
185
-
186
-
187
-    /**
188
-     * Holds EE_Registry object
189
-     *
190
-     * @var EE_Registry
191
-     */
192
-    protected $EE = null;
193
-
194
-
195
-    /**
196
-     * constructor
197
-     *
198
-     * @param EE_Admin_Page $admin_page the calling admin_page_object
199
-     */
200
-    public function __construct(EE_Admin_Page $adminpage)
201
-    {
202
-
203
-        $this->_adminpage_obj = $adminpage;
204
-        $this->_req_data = array_merge($_GET, $_POST);
205
-        $this->_set_defaults();
206
-        $this->_set_hooks_properties();
207
-        // first let's verify we're on the right page
208
-        if (! isset($this->_req_data['page'])
209
-            || (isset($this->_req_data['page'])
210
-                && $this->_adminpage_obj->page_slug
211
-                   != $this->_req_data['page'])) {
212
-            return;
213
-        } //get out nothing more to be done here.
214
-        // allow for extends to modify properties
215
-        if (method_exists($this, '_extend_properties')) {
216
-            $this->_extend_properties();
217
-        }
218
-        $this->_set_page_object();
219
-        $this->_init_hooks();
220
-        $this->_load_custom_methods();
221
-        $this->_load_routed_hooks();
222
-        add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts_styles'));
223
-        add_action('admin_enqueue_scripts', array($this, 'add_metaboxes'), 20);
224
-        add_action('admin_enqueue_scripts', array($this, 'remove_metaboxes'), 15);
225
-        $this->_ajax_hooks();
226
-    }
227
-
228
-
229
-    /**
230
-     * used by child classes to set the following properties:
231
-     * $_ajax_func (optional)
232
-     * $_init_func (optional)
233
-     * $_metaboxes (optional)
234
-     * $_scripts (optional)
235
-     * $_styles (optional)
236
-     * $_name (required)
237
-     * Also in this method will be registered any scripts or styles loaded on the targeted page (as indicated in the
238
-     * _scripts/_styles properties) Also children should place in this method any filters/actions that have to happen
239
-     * really early on page load (just after admin_init) if they want to have them registered for handling early.
240
-     *
241
-     * @access protected
242
-     * @abstract
243
-     * @return void
244
-     */
245
-    abstract protected function _set_hooks_properties();
246
-
247
-
248
-    /**
249
-     * The hooks for enqueue_scripts and enqueue_styles will be run in here.  Child classes need to define their
250
-     * scripts and styles in the relevant $_scripts and $_styles properties.  Child classes must have also already
251
-     * registered the scripts and styles using wp_register_script and wp_register_style functions.
252
-     *
253
-     * @access public
254
-     * @return void
255
-     */
256
-    public function enqueue_scripts_styles()
257
-    {
258
-
259
-        if (! empty($this->_scripts_styles)) {
260
-            // first let's do all the registrations
261
-            if (! isset($this->_scripts_styles['registers'])) {
262
-                $msg[] = __(
263
-                    'There is no "registers" index in the <code>$this->_scripts_styles</code> property.',
264
-                    'event_espresso'
265
-                );
266
-                $msg[] = sprintf(
267
-                    __(
268
-                        'Make sure you read the phpdoc comments above the definition of the $_scripts_styles property in the <code>EE_Admin_Hooks</code> class and modify according in the %s child',
269
-                        'event_espresso'
270
-                    ),
271
-                    '<strong>' . $this->caller . '</strong>'
272
-                );
273
-                throw new EE_Error(implode('||', $msg));
274
-            }
275
-            foreach ($this->_scripts_styles['registers'] as $ref => $details) {
276
-                $defaults = array(
277
-                    'type'    => 'js',
278
-                    'url'     => '',
279
-                    'depends' => array(),
280
-                    'version' => EVENT_ESPRESSO_VERSION,
281
-                    'footer'  => true,
282
-                );
283
-                $details = wp_parse_args($details, $defaults);
284
-                extract($details);
285
-                // let's make sure that we set the 'registers' type if it's not set! We need it later to determine whhich enqueu we do
286
-                $this->_scripts_styles['registers'][ $ref ]['type'] = $type;
287
-                // let's make sure we're not missing any REQUIRED parameters
288
-                if (empty($url)) {
289
-                    $msg[] = sprintf(
290
-                        __('Missing the url for the requested %s', 'event_espresso'),
291
-                        $type == 'js' ? 'script' : 'stylesheet'
292
-                    );
293
-                    $msg[] = sprintf(
294
-                        __(
295
-                            'Doublecheck your <code>$this->_scripts_styles</code> array in %s and make sure that there is a "url" set for the %s ref',
296
-                            'event_espresso'
297
-                        ),
298
-                        '<strong>' . $this->caller . '</strong>',
299
-                        $ref
300
-                    );
301
-                    throw new EE_Error(implode('||', $msg));
302
-                }
303
-                // made it here so let's do the appropriate registration
304
-                $type == 'js'
305
-                    ? wp_register_script($ref, $url, $depends, $version, $footer)
306
-                    : wp_register_style(
307
-                        $ref,
308
-                        $url,
309
-                        $depends,
310
-                        $version
311
-                    );
312
-            }
313
-            // k now lets do the enqueues
314
-            if (! isset($this->_scripts_styles['enqueues'])) {
315
-                return;
316
-            }  //not sure if we should throw an error here or not.
317
-
318
-            foreach ($this->_scripts_styles['enqueues'] as $ref => $routes) {
319
-                // make sure $routes is an array
320
-                $routes = (array) $routes;
321
-                if (in_array($this->_current_route, $routes)) {
322
-                    $this->_scripts_styles['registers'][ $ref ]['type'] == 'js' ? wp_enqueue_script($ref)
323
-                        : wp_enqueue_style($ref);
324
-                    // if we have a localization for the script let's do that too.
325
-                    if (isset($this->_scripts_styles['localize'][ $ref ])) {
326
-                        foreach ($this->_scripts_styles['localize'][ $ref ] as $object_name => $indexes) {
327
-                            wp_localize_script(
328
-                                $ref,
329
-                                $object_name,
330
-                                $this->_scripts_styles['localize'][ $ref ][ $object_name ]
331
-                            );
332
-                        }
333
-                    }
334
-                }
335
-            }
336
-            // let's do the deregisters
337
-            if (! isset($this->_scripts_styles['deregisters'])) {
338
-                return;
339
-            }
340
-            foreach ($this->_scripts_styles['deregisters'] as $ref => $details) {
341
-                $defaults = array(
342
-                    'type' => 'js',
343
-                );
344
-                $details = wp_parse_args($details, $defaults);
345
-                extract($details);
346
-                $type == 'js' ? wp_deregister_script($ref) : wp_deregister_style($ref);
347
-            }
348
-        }
349
-    }
350
-
351
-
352
-    /**
353
-     * just set the defaults for the hooks properties.
354
-     *
355
-     * @access private
356
-     * @return void
357
-     */
358
-    private function _set_defaults()
359
-    {
360
-        $this->_ajax_func = $this->_init_func = $this->_metaboxes = $this->_scripts = $this->_styles = $this->_wp_action_filters_priority = array();
361
-        $this->_current_route = $this->getCurrentRoute();
362
-        $this->caller = get_class($this);
363
-        $this->_extend = stripos($this->caller, 'Extend') ? true : false;
364
-    }
365
-
366
-
367
-    /**
368
-     * A helper for determining the current route.
369
-     * @return string
370
-     */
371
-    private function getCurrentRoute()
372
-    {
373
-        // list tables do something else with 'action' for bulk actions.
374
-        $action = ! empty($_REQUEST['action']) && $_REQUEST['action'] !== '-1' ? $_REQUEST['action'] : 'default';
375
-        // we set a 'route' variable in some cases where action is being used by something else.
376
-        $action = $action === 'default' && isset($_REQUEST['route']) ? $_REQUEST['route'] : $action;
377
-        return sanitize_key($action);
378
-    }
379
-
380
-
381
-    /**
382
-     * this sets the _page_object property
383
-     *
384
-     * @access protected
385
-     * @return void
386
-     */
387
-    protected function _set_page_object()
388
-    {
389
-        // first make sure $this->_name is set
390
-        if (empty($this->_name)) {
391
-            $msg[] = __('We can\'t load the page object', 'event_espresso');
392
-            $msg[] = sprintf(
393
-                __("This is because the %s child class has not set the '_name' property", 'event_espresso'),
394
-                $this->caller
395
-            );
396
-            throw new EE_Error(implode('||', $msg));
397
-        }
398
-        $ref = str_replace('_', ' ', $this->_name); // take the_message -> the message
399
-        $ref = str_replace(' ', '_', ucwords($ref)) . '_Admin_Page'; // take the message -> The_Message
400
-        // first default file (if exists)
401
-        $decaf_file = EE_ADMIN_PAGES . $this->_name . DS . $ref . '.core.php';
402
-        if (is_readable($decaf_file)) {
403
-            require_once($decaf_file);
404
-        }
405
-        // now we have to do require for extended file (if needed)
406
-        if ($this->_extend) {
407
-            require_once(EE_CORE_CAF_ADMIN_EXTEND . $this->_name . DS . 'Extend_' . $ref . '.core.php');
408
-        }
409
-        // if we've got an extended class we use that!
410
-        $ref = $this->_extend ? 'Extend_' . $ref : $ref;
411
-        // let's make sure the class exists
412
-        if (! class_exists($ref)) {
413
-            $msg[] = __('We can\'t load the page object', 'event_espresso');
414
-            $msg[] = sprintf(
415
-                __(
416
-                    'The class name that was given is %s. Check the spelling and make sure its correct, also there needs to be an autoloader setup for the class',
417
-                    'event_espresso'
418
-                ),
419
-                $ref
420
-            );
421
-            throw new EE_Error(implode('||', $msg));
422
-        }
423
-        $a = new ReflectionClass($ref);
424
-        $this->_page_object = $a->newInstance(false);
425
-    }
426
-
427
-
428
-    /**
429
-     * Child "hook" classes can declare any methods that they want executed when a specific page route is loaded.  The
430
-     * advantage of this is when doing things like running our own db interactions on saves etc.  Remember that
431
-     * $this->_req_data (all the _POST and _GET data) is available to your methods.
432
-     *
433
-     * @access private
434
-     * @return void
435
-     */
436
-    private function _load_custom_methods()
437
-    {
438
-        /**
439
-         * method cannot be named 'default' (@see http://us3.php
440
-         * .net/manual/en/reserved.keywords.php) so need to
441
-         * handle routes that are "default"
442
-         *
443
-         * @since 4.3.0
444
-         */
445
-        $method_callback = $this->_current_route == 'default' ? 'default_callback' : $this->_current_route;
446
-        // these run before the Admin_Page route executes.
447
-        if (method_exists($this, $method_callback)) {
448
-            call_user_func(array($this, $method_callback));
449
-        }
450
-        // these run via the _redirect_after_action method in EE_Admin_Page which usually happens after non_UI methods in EE_Admin_Page classes.  There are two redirect actions, the first fires before $query_args might be manipulated by "save and close" actions and the seond fires right before the actual redirect happens.
451
-        // first the actions
452
-        // note that these action hooks will have the $query_args value available.
453
-        $admin_class_name = get_class($this->_adminpage_obj);
454
-        if (method_exists($this, '_redirect_action_early_' . $this->_current_route)) {
455
-            add_action(
456
-                'AHEE__'
457
-                . $admin_class_name
458
-                . '___redirect_after_action__before_redirect_modification_'
459
-                . $this->_current_route,
460
-                array($this, '_redirect_action_early_' . $this->_current_route),
461
-                10
462
-            );
463
-        }
464
-        if (method_exists($this, '_redirect_action_' . $this->_current_route)) {
465
-            add_action(
466
-                'AHEE_redirect_' . $admin_class_name . $this->_current_route,
467
-                array($this, '_redirect_action_' . $this->_current_route),
468
-                10
469
-            );
470
-        }
471
-        // let's hook into the _redirect itself and allow for changing where the user goes after redirect.  This will have $query_args and $redirect_url available.
472
-        if (method_exists($this, '_redirect_filter_' . $this->_current_route)) {
473
-            add_filter(
474
-                'FHEE_redirect_' . $admin_class_name . $this->_current_route,
475
-                array($this, '_redirect_filter_' . $this->_current_route),
476
-                10,
477
-                2
478
-            );
479
-        }
480
-    }
481
-
482
-
483
-    /**
484
-     * This method will search for a corresponding method with a name matching the route and the wp_hook to run.  This
485
-     * allows child hook classes to target hooking into a specific wp action or filter hook ONLY on a certain route.
486
-     * just remember, methods MUST be public Future hooks should be added in here to be access by child classes.
487
-     *
488
-     * @return void
489
-     */
490
-    private function _load_routed_hooks()
491
-    {
492
-
493
-        // this array provides the hook action names that will be referenced.  Key is the action. Value is an array with the type (action or filter) and the number of parameters for the hook.  We'll default all priorities for automatic hooks to 10.
494
-        $hook_filter_array = array(
495
-            'admin_footer'                                                                            => array(
496
-                'type'     => 'action',
497
-                'argnum'   => 1,
498
-                'priority' => 10,
499
-            ),
500
-            'FHEE_list_table_views_' . $this->_adminpage_obj->page_slug . '_' . $this->_current_route => array(
501
-                'type'     => 'filter',
502
-                'argnum'   => 1,
503
-                'priority' => 10,
504
-            ),
505
-            'FHEE_list_table_views_' . $this->_adminpage_obj->page_slug                               => array(
506
-                'type'     => 'filter',
507
-                'argnum'   => 1,
508
-                'priority' => 10,
509
-            ),
510
-            'FHEE_list_table_views'                                                                   => array(
511
-                'type'     => 'filter',
512
-                'argnum'   => 1,
513
-                'priority' => 10,
514
-            ),
515
-            'AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes'                              => array(
516
-                'type'     => 'action',
517
-                'argnum'   => 1,
518
-                'priority' => 10,
519
-            ),
520
-        );
521
-        foreach ($hook_filter_array as $hook => $args) {
522
-            if (method_exists($this, $this->_current_route . '_' . $hook)) {
523
-                if (isset($this->_wp_action_filters_priority[ $hook ])) {
524
-                    $args['priority'] = $this->_wp_action_filters_priority[ $hook ];
525
-                }
526
-                if ($args['type'] == 'action') {
527
-                    add_action(
528
-                        $hook,
529
-                        array($this, $this->_current_route . '_' . $hook),
530
-                        $args['priority'],
531
-                        $args['argnum']
532
-                    );
533
-                } else {
534
-                    add_filter(
535
-                        $hook,
536
-                        array($this, $this->_current_route . '_' . $hook),
537
-                        $args['priority'],
538
-                        $args['argnum']
539
-                    );
540
-                }
541
-            }
542
-        }
543
-    }
544
-
545
-
546
-    /**
547
-     * Loop throught the $_ajax_func array and add_actions for the array.
548
-     *
549
-     * @return void
550
-     */
551
-    private function _ajax_hooks()
552
-    {
553
-
554
-        if (empty($this->_ajax_func)) {
555
-            return;
556
-        } //get out there's nothing to take care of.
557
-        foreach ($this->_ajax_func as $action => $method) {
558
-            // make sure method exists
559
-            if (! method_exists($this, $method)) {
560
-                $msg[] = __(
561
-                    'There is no corresponding method for the hook labeled in the _ajax_func array',
562
-                    'event_espresso'
563
-                ) . '<br />';
564
-                $msg[] = sprintf(
565
-                    __(
566
-                        'The method name given in the array is %s, check the spelling and make sure it exists in the %s class',
567
-                        'event_espresso'
568
-                    ),
569
-                    $method,
570
-                    $this->caller
571
-                );
572
-                throw new EE_Error(implode('||', $msg));
573
-            }
574
-            add_action('wp_ajax_' . $action, array($this, $method));
575
-        }
576
-    }
577
-
578
-
579
-    /**
580
-     * Loop throught the $_init_func array and add_actions for the array.
581
-     *
582
-     * @return void
583
-     */
584
-    protected function _init_hooks()
585
-    {
586
-        if (empty($this->_init_func)) {
587
-            return;
588
-        } //get out there's nothing to take care of.
589
-        // We need to determine what page_route we are on!
590
-        $current_route = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'default';
591
-        foreach ($this->_init_func as $route => $method) {
592
-            // make sure method exists
593
-            if (! method_exists($this, $method)) {
594
-                $msg[] = __(
595
-                    'There is no corresponding method for the hook labeled in the _init_func array',
596
-                    'event_espresso'
597
-                ) . '<br />';
598
-                $msg[] = sprintf(
599
-                    __(
600
-                        'The method name given in the array is %s, check the spelling and make sure it exists in the %s class',
601
-                        'event_espresso'
602
-                    ),
603
-                    $method,
604
-                    $this->caller
605
-                );
606
-                throw new EE_Error(implode('||', $msg));
607
-            }
608
-            if ($route == $this->_current_route) {
609
-                add_action('admin_init', array($this, $method));
610
-            }
611
-        }
612
-    }
613
-
614
-
615
-    /**
616
-     * Loop through the _metaboxes property and add_metaboxes accordingly
617
-     * //todo we could eventually make this a config component class (i.e. new EE_Metabox);
618
-     *
619
-     * @access public
620
-     * @return void
621
-     */
622
-    public function add_metaboxes()
623
-    {
624
-        if (empty($this->_metaboxes)) {
625
-            return;
626
-        } //get out we don't have any metaboxes to set for this connection
627
-        $this->_handle_metabox_array($this->_metaboxes);
628
-    }
629
-
630
-
631
-    private function _handle_metabox_array($boxes, $add = true)
632
-    {
633
-
634
-        foreach ($boxes as $box) {
635
-            if (! isset($box['page_route'])) {
636
-                continue;
637
-            } //we dont' have a valid array
638
-            // let's make sure $box['page_route'] is an array so the "foreach" will work.
639
-            $box['page_route'] = (array) $box['page_route'];
640
-            foreach ($box['page_route'] as $route) {
641
-                if ($route != $this->_current_route) {
642
-                    continue;
643
-                } //get out we only add metaboxes for set route.
644
-                if ($add) {
645
-                    $this->_add_metabox($box);
646
-                } else {
647
-                    $this->_remove_metabox($box);
648
-                }
649
-            }
650
-        }
651
-    }
652
-
653
-
654
-    /**
655
-     * Loop through the _remove_metaboxes property and remove metaboxes accordingly.
656
-     *
657
-     * @access public
658
-     * @return void
659
-     */
660
-    public function remove_metaboxes()
661
-    {
662
-
663
-        if (empty($this->_remove_metaboxes)) {
664
-            return;
665
-        } //get out there are no metaboxes to remove
666
-        $this->_handle_metabox_array($this->_remove_metaboxes, false);
667
-    }
668
-
669
-
670
-    /**
671
-     * This just handles adding a metabox
672
-     *
673
-     * @access private
674
-     * @param array $args an array of args that have been set for this metabox by the child class
675
-     */
676
-    private function _add_metabox($args)
677
-    {
678
-        $current_screen = get_current_screen();
679
-        $screen_id = is_object($current_screen) ? $current_screen->id : null;
680
-        $func = isset($args['func']) ? $args['func'] : 'some_invalid_callback';
681
-        // set defaults
682
-        $defaults = array(
683
-            'func'          => $func,
684
-            'id'            => $this->caller . '_' . $func . '_metabox',
685
-            'priority'      => 'default',
686
-            'label'         => $this->caller,
687
-            'context'       => 'advanced',
688
-            'callback_args' => array(),
689
-            'page'          => isset($args['page']) ? $args['page'] : $screen_id,
690
-        );
691
-        $args = wp_parse_args($args, $defaults);
692
-        extract($args);
693
-        // make sure method exists
694
-        if (! method_exists($this, $func)) {
695
-            $msg[] = __('There is no corresponding method to display the metabox content', 'event_espresso') . '<br />';
696
-            $msg[] = sprintf(
697
-                __(
698
-                    'The method name given in the array is %s, check the spelling and make sure it exists in the %s class',
699
-                    'event_espresso'
700
-                ),
701
-                $func,
702
-                $this->caller
703
-            );
704
-            throw new EE_Error(implode('||', $msg));
705
-        }
706
-        // everything checks out so lets add the metabox
707
-        add_meta_box($id, $label, array($this, $func), $page, $context, $priority, $callback_args);
708
-    }
709
-
710
-
711
-    private function _remove_metabox($args)
712
-    {
713
-        $current_screen = get_current_screen();
714
-        $screen_id = is_object($current_screen) ? $current_screen->id : null;
715
-        $func = isset($args['func']) ? $args['func'] : 'some_invalid_callback';
716
-        // set defaults
717
-        $defaults = array(
718
-            'id'      => isset($args['id'])
719
-                ? $args['id']
720
-                : $this->_current_route
721
-                  . '_'
722
-                  . $this->caller
723
-                  . '_'
724
-                  . $func
725
-                  . '_metabox',
726
-            'context' => 'default',
727
-            'screen'  => isset($args['screen']) ? $args['screen'] : $screen_id,
728
-        );
729
-        $args = wp_parse_args($args, $defaults);
730
-        extract($args);
731
-        // everything checks out so lets remove the box!
732
-        remove_meta_box($id, $screen, $context);
733
-    }
16
+	/**
17
+	 * we're just going to use this to hold the name of the caller class (child class name)
18
+	 *
19
+	 * @var string
20
+	 */
21
+	public $caller;
22
+
23
+
24
+	/**
25
+	 * this is just a flag set automatically to indicate whether we've got an extended hook class running (i.e.
26
+	 * espresso_events_Registration_Form_Hooks_Extend extends espresso_events_Registration_Form_Hooks).  This flag is
27
+	 * used later to make sure we require the needed files.
28
+	 *
29
+	 * @var bool
30
+	 */
31
+	protected $_extend;
32
+
33
+
34
+	/**
35
+	 * child classes MUST set this property so that the page object can be loaded correctly
36
+	 *
37
+	 * @var string
38
+	 */
39
+	protected $_name;
40
+
41
+
42
+	/**
43
+	 * This is set by child classes and is an associative array of ajax hooks in the format:
44
+	 * array(
45
+	 *    'ajax_action_ref' => 'executing_method'; //must be public
46
+	 * )
47
+	 *
48
+	 * @var array
49
+	 */
50
+	protected $_ajax_func;
51
+
52
+
53
+	/**
54
+	 * This is an array of methods that get executed on a page routes admin_init hook. Use the following format:
55
+	 * array(
56
+	 *    'page_route' => 'executing_method' //must be public
57
+	 * )
58
+	 *
59
+	 * @var array
60
+	 */
61
+	protected $_init_func;
62
+
63
+
64
+	/**
65
+	 * This is an array of methods that output metabox content for the given page route.  Use the following format:
66
+	 * array(
67
+	 *    0 => array(
68
+	 *        'page_route' => 'string_for_page_route', //must correspond to a page route in the class being connected
69
+	 *        with (i.e. "edit_event") If this is in an array then the same params below will be used but the metabox
70
+	 *        will be added to each route.
71
+	 *        'func' =>  'executing_method',  //must be public (i.e. public function executing_method($post,
72
+	 *        $callback_args){} ).  Note if you include callback args in the array then you need to declare them in the
73
+	 *        method arguments.
74
+	 *        'id' => 'identifier_for_metabox', //so it can be removed by addons (optional, class will set it
75
+	 *        automatically)
76
+	 *        'priority' => 'default', //default 'default' (optional)
77
+	 *        'label' => __('Localized Title', 'event_espresso'),
78
+	 *        'context' => 'advanced' //advanced is default (optional),
79
+	 *    'callback_args' => array() //any callback args to include (optional)
80
+	 * )
81
+	 * Why are we indexing numerically?  Because it's possible there may be more than one metabox per page_route.
82
+	 *
83
+	 * @var array
84
+	 */
85
+	protected $_metaboxes;
86
+
87
+
88
+	/**
89
+	 * This is an array of values that indicate any metaboxes we want removed from a given page route.  Usually this is
90
+	 * used when caffeinated functionality is replacing decaffeinated functionality.  Use the following format for the
91
+	 * array: array(
92
+	 *    0 => array(
93
+	 *        'page_route' => 'string_for_page_route' //can be string or array of strings that match a page_route(s)
94
+	 *        that are in the class being connected with (i.e. 'edit', or 'create_new').
95
+	 *        'id' => 'identifier_for_metabox', //what the id is of the metabox being removed
96
+	 *        'context' => 'normal', //the context for the metabox being removed (has to match)
97
+	 *        'screen' => 'screen_id', //(optional), if not included then this class will attempt to remove the metabox
98
+	 *        using the currently loaded screen object->id  however, there may be cases where you have to specify the
99
+	 *        id for the screen the metabox is on.
100
+	 *    )
101
+	 * )
102
+	 *
103
+	 * @var array
104
+	 */
105
+	protected $_remove_metaboxes;
106
+
107
+
108
+	/**
109
+	 * This parent class takes care of loading the scripts and styles if the child class has set the properties for
110
+	 * them in the following format.  Note, the first array index ('register') is for defining all the registers.  The
111
+	 * second array index is for indicating what routes each script/style loads on. array(
112
+	 * 'registers' => array(
113
+	 *        'script_ref' => array( // if more than one script is to be loaded its best to use the 'dependency'
114
+	 *        argument to link scripts together.
115
+	 *            'type' => 'js' // 'js' or 'css' (defaults to js).  This tells us what type of wp_function to use
116
+	 *            'url' => 'http://urltoscript.css.js',
117
+	 *            'depends' => array('jquery'), //an array of dependencies for the scripts. REMEMBER, if a script has
118
+	 *            already been registered elsewhere in the system.  You can just use the depends array to make sure it
119
+	 *            gets loaded before the one you are setting here.
120
+	 *            'footer' => TRUE //defaults to true (styles don't use this parameter)
121
+	 *        ),
122
+	 *    'enqueues' => array( //this time each key corresponds to the script ref followed by an array of page routes
123
+	 *    the script gets enqueued on.
124
+	 *        'script_ref' => array('route_one', 'route_two')
125
+	 *    ),
126
+	 *    'localize' => array( //this allows you to set a localize object.  Indicate which script the object is being
127
+	 *    attached to and then include an array indexed by the name of the object and the array of key/value pairs for
128
+	 *    the object.
129
+	 *        'scrip_ref' => array(
130
+	 *            'NAME_OF_JS_OBJECT' => array(
131
+	 *                'translate_ref' => __('localized_string', 'event_espresso'),
132
+	 *                'some_data' => 5
133
+	 *            )
134
+	 *        )
135
+	 *    )
136
+	 * )
137
+	 *
138
+	 * @var array
139
+	 */
140
+	protected $_scripts_styles;
141
+
142
+
143
+	/**
144
+	 * This is a property that will contain the current route.
145
+	 *
146
+	 * @var string;
147
+	 */
148
+	protected $_current_route;
149
+
150
+
151
+	/**
152
+	 * this optional property can be set by child classes to override the priority for the automatic action/filter hook
153
+	 * loading in the `_load_routed_hooks()` method.  Please follow this format: array(
154
+	 *    'wp_hook_reference' => 1
155
+	 *    )
156
+	 * )
157
+	 *
158
+	 * @var array
159
+	 */
160
+	protected $_wp_action_filters_priority;
161
+
162
+
163
+	/**
164
+	 * This just holds a merged array of the $_POST and $_GET vars in favor of $_POST
165
+	 *
166
+	 * @var array
167
+	 */
168
+	protected $_req_data;
169
+
170
+
171
+	/**
172
+	 * This just holds an instance of the page object for this hook
173
+	 *
174
+	 * @var EE_Admin_Page
175
+	 */
176
+	protected $_page_object;
177
+
178
+
179
+	/**
180
+	 * This holds the EE_Admin_Page object from the calling admin page that this object hooks into.
181
+	 *
182
+	 * @var EE_Admin_Page|EE_Admin_Page_CPT
183
+	 */
184
+	protected $_adminpage_obj;
185
+
186
+
187
+	/**
188
+	 * Holds EE_Registry object
189
+	 *
190
+	 * @var EE_Registry
191
+	 */
192
+	protected $EE = null;
193
+
194
+
195
+	/**
196
+	 * constructor
197
+	 *
198
+	 * @param EE_Admin_Page $admin_page the calling admin_page_object
199
+	 */
200
+	public function __construct(EE_Admin_Page $adminpage)
201
+	{
202
+
203
+		$this->_adminpage_obj = $adminpage;
204
+		$this->_req_data = array_merge($_GET, $_POST);
205
+		$this->_set_defaults();
206
+		$this->_set_hooks_properties();
207
+		// first let's verify we're on the right page
208
+		if (! isset($this->_req_data['page'])
209
+			|| (isset($this->_req_data['page'])
210
+				&& $this->_adminpage_obj->page_slug
211
+				   != $this->_req_data['page'])) {
212
+			return;
213
+		} //get out nothing more to be done here.
214
+		// allow for extends to modify properties
215
+		if (method_exists($this, '_extend_properties')) {
216
+			$this->_extend_properties();
217
+		}
218
+		$this->_set_page_object();
219
+		$this->_init_hooks();
220
+		$this->_load_custom_methods();
221
+		$this->_load_routed_hooks();
222
+		add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts_styles'));
223
+		add_action('admin_enqueue_scripts', array($this, 'add_metaboxes'), 20);
224
+		add_action('admin_enqueue_scripts', array($this, 'remove_metaboxes'), 15);
225
+		$this->_ajax_hooks();
226
+	}
227
+
228
+
229
+	/**
230
+	 * used by child classes to set the following properties:
231
+	 * $_ajax_func (optional)
232
+	 * $_init_func (optional)
233
+	 * $_metaboxes (optional)
234
+	 * $_scripts (optional)
235
+	 * $_styles (optional)
236
+	 * $_name (required)
237
+	 * Also in this method will be registered any scripts or styles loaded on the targeted page (as indicated in the
238
+	 * _scripts/_styles properties) Also children should place in this method any filters/actions that have to happen
239
+	 * really early on page load (just after admin_init) if they want to have them registered for handling early.
240
+	 *
241
+	 * @access protected
242
+	 * @abstract
243
+	 * @return void
244
+	 */
245
+	abstract protected function _set_hooks_properties();
246
+
247
+
248
+	/**
249
+	 * The hooks for enqueue_scripts and enqueue_styles will be run in here.  Child classes need to define their
250
+	 * scripts and styles in the relevant $_scripts and $_styles properties.  Child classes must have also already
251
+	 * registered the scripts and styles using wp_register_script and wp_register_style functions.
252
+	 *
253
+	 * @access public
254
+	 * @return void
255
+	 */
256
+	public function enqueue_scripts_styles()
257
+	{
258
+
259
+		if (! empty($this->_scripts_styles)) {
260
+			// first let's do all the registrations
261
+			if (! isset($this->_scripts_styles['registers'])) {
262
+				$msg[] = __(
263
+					'There is no "registers" index in the <code>$this->_scripts_styles</code> property.',
264
+					'event_espresso'
265
+				);
266
+				$msg[] = sprintf(
267
+					__(
268
+						'Make sure you read the phpdoc comments above the definition of the $_scripts_styles property in the <code>EE_Admin_Hooks</code> class and modify according in the %s child',
269
+						'event_espresso'
270
+					),
271
+					'<strong>' . $this->caller . '</strong>'
272
+				);
273
+				throw new EE_Error(implode('||', $msg));
274
+			}
275
+			foreach ($this->_scripts_styles['registers'] as $ref => $details) {
276
+				$defaults = array(
277
+					'type'    => 'js',
278
+					'url'     => '',
279
+					'depends' => array(),
280
+					'version' => EVENT_ESPRESSO_VERSION,
281
+					'footer'  => true,
282
+				);
283
+				$details = wp_parse_args($details, $defaults);
284
+				extract($details);
285
+				// let's make sure that we set the 'registers' type if it's not set! We need it later to determine whhich enqueu we do
286
+				$this->_scripts_styles['registers'][ $ref ]['type'] = $type;
287
+				// let's make sure we're not missing any REQUIRED parameters
288
+				if (empty($url)) {
289
+					$msg[] = sprintf(
290
+						__('Missing the url for the requested %s', 'event_espresso'),
291
+						$type == 'js' ? 'script' : 'stylesheet'
292
+					);
293
+					$msg[] = sprintf(
294
+						__(
295
+							'Doublecheck your <code>$this->_scripts_styles</code> array in %s and make sure that there is a "url" set for the %s ref',
296
+							'event_espresso'
297
+						),
298
+						'<strong>' . $this->caller . '</strong>',
299
+						$ref
300
+					);
301
+					throw new EE_Error(implode('||', $msg));
302
+				}
303
+				// made it here so let's do the appropriate registration
304
+				$type == 'js'
305
+					? wp_register_script($ref, $url, $depends, $version, $footer)
306
+					: wp_register_style(
307
+						$ref,
308
+						$url,
309
+						$depends,
310
+						$version
311
+					);
312
+			}
313
+			// k now lets do the enqueues
314
+			if (! isset($this->_scripts_styles['enqueues'])) {
315
+				return;
316
+			}  //not sure if we should throw an error here or not.
317
+
318
+			foreach ($this->_scripts_styles['enqueues'] as $ref => $routes) {
319
+				// make sure $routes is an array
320
+				$routes = (array) $routes;
321
+				if (in_array($this->_current_route, $routes)) {
322
+					$this->_scripts_styles['registers'][ $ref ]['type'] == 'js' ? wp_enqueue_script($ref)
323
+						: wp_enqueue_style($ref);
324
+					// if we have a localization for the script let's do that too.
325
+					if (isset($this->_scripts_styles['localize'][ $ref ])) {
326
+						foreach ($this->_scripts_styles['localize'][ $ref ] as $object_name => $indexes) {
327
+							wp_localize_script(
328
+								$ref,
329
+								$object_name,
330
+								$this->_scripts_styles['localize'][ $ref ][ $object_name ]
331
+							);
332
+						}
333
+					}
334
+				}
335
+			}
336
+			// let's do the deregisters
337
+			if (! isset($this->_scripts_styles['deregisters'])) {
338
+				return;
339
+			}
340
+			foreach ($this->_scripts_styles['deregisters'] as $ref => $details) {
341
+				$defaults = array(
342
+					'type' => 'js',
343
+				);
344
+				$details = wp_parse_args($details, $defaults);
345
+				extract($details);
346
+				$type == 'js' ? wp_deregister_script($ref) : wp_deregister_style($ref);
347
+			}
348
+		}
349
+	}
350
+
351
+
352
+	/**
353
+	 * just set the defaults for the hooks properties.
354
+	 *
355
+	 * @access private
356
+	 * @return void
357
+	 */
358
+	private function _set_defaults()
359
+	{
360
+		$this->_ajax_func = $this->_init_func = $this->_metaboxes = $this->_scripts = $this->_styles = $this->_wp_action_filters_priority = array();
361
+		$this->_current_route = $this->getCurrentRoute();
362
+		$this->caller = get_class($this);
363
+		$this->_extend = stripos($this->caller, 'Extend') ? true : false;
364
+	}
365
+
366
+
367
+	/**
368
+	 * A helper for determining the current route.
369
+	 * @return string
370
+	 */
371
+	private function getCurrentRoute()
372
+	{
373
+		// list tables do something else with 'action' for bulk actions.
374
+		$action = ! empty($_REQUEST['action']) && $_REQUEST['action'] !== '-1' ? $_REQUEST['action'] : 'default';
375
+		// we set a 'route' variable in some cases where action is being used by something else.
376
+		$action = $action === 'default' && isset($_REQUEST['route']) ? $_REQUEST['route'] : $action;
377
+		return sanitize_key($action);
378
+	}
379
+
380
+
381
+	/**
382
+	 * this sets the _page_object property
383
+	 *
384
+	 * @access protected
385
+	 * @return void
386
+	 */
387
+	protected function _set_page_object()
388
+	{
389
+		// first make sure $this->_name is set
390
+		if (empty($this->_name)) {
391
+			$msg[] = __('We can\'t load the page object', 'event_espresso');
392
+			$msg[] = sprintf(
393
+				__("This is because the %s child class has not set the '_name' property", 'event_espresso'),
394
+				$this->caller
395
+			);
396
+			throw new EE_Error(implode('||', $msg));
397
+		}
398
+		$ref = str_replace('_', ' ', $this->_name); // take the_message -> the message
399
+		$ref = str_replace(' ', '_', ucwords($ref)) . '_Admin_Page'; // take the message -> The_Message
400
+		// first default file (if exists)
401
+		$decaf_file = EE_ADMIN_PAGES . $this->_name . DS . $ref . '.core.php';
402
+		if (is_readable($decaf_file)) {
403
+			require_once($decaf_file);
404
+		}
405
+		// now we have to do require for extended file (if needed)
406
+		if ($this->_extend) {
407
+			require_once(EE_CORE_CAF_ADMIN_EXTEND . $this->_name . DS . 'Extend_' . $ref . '.core.php');
408
+		}
409
+		// if we've got an extended class we use that!
410
+		$ref = $this->_extend ? 'Extend_' . $ref : $ref;
411
+		// let's make sure the class exists
412
+		if (! class_exists($ref)) {
413
+			$msg[] = __('We can\'t load the page object', 'event_espresso');
414
+			$msg[] = sprintf(
415
+				__(
416
+					'The class name that was given is %s. Check the spelling and make sure its correct, also there needs to be an autoloader setup for the class',
417
+					'event_espresso'
418
+				),
419
+				$ref
420
+			);
421
+			throw new EE_Error(implode('||', $msg));
422
+		}
423
+		$a = new ReflectionClass($ref);
424
+		$this->_page_object = $a->newInstance(false);
425
+	}
426
+
427
+
428
+	/**
429
+	 * Child "hook" classes can declare any methods that they want executed when a specific page route is loaded.  The
430
+	 * advantage of this is when doing things like running our own db interactions on saves etc.  Remember that
431
+	 * $this->_req_data (all the _POST and _GET data) is available to your methods.
432
+	 *
433
+	 * @access private
434
+	 * @return void
435
+	 */
436
+	private function _load_custom_methods()
437
+	{
438
+		/**
439
+		 * method cannot be named 'default' (@see http://us3.php
440
+		 * .net/manual/en/reserved.keywords.php) so need to
441
+		 * handle routes that are "default"
442
+		 *
443
+		 * @since 4.3.0
444
+		 */
445
+		$method_callback = $this->_current_route == 'default' ? 'default_callback' : $this->_current_route;
446
+		// these run before the Admin_Page route executes.
447
+		if (method_exists($this, $method_callback)) {
448
+			call_user_func(array($this, $method_callback));
449
+		}
450
+		// these run via the _redirect_after_action method in EE_Admin_Page which usually happens after non_UI methods in EE_Admin_Page classes.  There are two redirect actions, the first fires before $query_args might be manipulated by "save and close" actions and the seond fires right before the actual redirect happens.
451
+		// first the actions
452
+		// note that these action hooks will have the $query_args value available.
453
+		$admin_class_name = get_class($this->_adminpage_obj);
454
+		if (method_exists($this, '_redirect_action_early_' . $this->_current_route)) {
455
+			add_action(
456
+				'AHEE__'
457
+				. $admin_class_name
458
+				. '___redirect_after_action__before_redirect_modification_'
459
+				. $this->_current_route,
460
+				array($this, '_redirect_action_early_' . $this->_current_route),
461
+				10
462
+			);
463
+		}
464
+		if (method_exists($this, '_redirect_action_' . $this->_current_route)) {
465
+			add_action(
466
+				'AHEE_redirect_' . $admin_class_name . $this->_current_route,
467
+				array($this, '_redirect_action_' . $this->_current_route),
468
+				10
469
+			);
470
+		}
471
+		// let's hook into the _redirect itself and allow for changing where the user goes after redirect.  This will have $query_args and $redirect_url available.
472
+		if (method_exists($this, '_redirect_filter_' . $this->_current_route)) {
473
+			add_filter(
474
+				'FHEE_redirect_' . $admin_class_name . $this->_current_route,
475
+				array($this, '_redirect_filter_' . $this->_current_route),
476
+				10,
477
+				2
478
+			);
479
+		}
480
+	}
481
+
482
+
483
+	/**
484
+	 * This method will search for a corresponding method with a name matching the route and the wp_hook to run.  This
485
+	 * allows child hook classes to target hooking into a specific wp action or filter hook ONLY on a certain route.
486
+	 * just remember, methods MUST be public Future hooks should be added in here to be access by child classes.
487
+	 *
488
+	 * @return void
489
+	 */
490
+	private function _load_routed_hooks()
491
+	{
492
+
493
+		// this array provides the hook action names that will be referenced.  Key is the action. Value is an array with the type (action or filter) and the number of parameters for the hook.  We'll default all priorities for automatic hooks to 10.
494
+		$hook_filter_array = array(
495
+			'admin_footer'                                                                            => array(
496
+				'type'     => 'action',
497
+				'argnum'   => 1,
498
+				'priority' => 10,
499
+			),
500
+			'FHEE_list_table_views_' . $this->_adminpage_obj->page_slug . '_' . $this->_current_route => array(
501
+				'type'     => 'filter',
502
+				'argnum'   => 1,
503
+				'priority' => 10,
504
+			),
505
+			'FHEE_list_table_views_' . $this->_adminpage_obj->page_slug                               => array(
506
+				'type'     => 'filter',
507
+				'argnum'   => 1,
508
+				'priority' => 10,
509
+			),
510
+			'FHEE_list_table_views'                                                                   => array(
511
+				'type'     => 'filter',
512
+				'argnum'   => 1,
513
+				'priority' => 10,
514
+			),
515
+			'AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes'                              => array(
516
+				'type'     => 'action',
517
+				'argnum'   => 1,
518
+				'priority' => 10,
519
+			),
520
+		);
521
+		foreach ($hook_filter_array as $hook => $args) {
522
+			if (method_exists($this, $this->_current_route . '_' . $hook)) {
523
+				if (isset($this->_wp_action_filters_priority[ $hook ])) {
524
+					$args['priority'] = $this->_wp_action_filters_priority[ $hook ];
525
+				}
526
+				if ($args['type'] == 'action') {
527
+					add_action(
528
+						$hook,
529
+						array($this, $this->_current_route . '_' . $hook),
530
+						$args['priority'],
531
+						$args['argnum']
532
+					);
533
+				} else {
534
+					add_filter(
535
+						$hook,
536
+						array($this, $this->_current_route . '_' . $hook),
537
+						$args['priority'],
538
+						$args['argnum']
539
+					);
540
+				}
541
+			}
542
+		}
543
+	}
544
+
545
+
546
+	/**
547
+	 * Loop throught the $_ajax_func array and add_actions for the array.
548
+	 *
549
+	 * @return void
550
+	 */
551
+	private function _ajax_hooks()
552
+	{
553
+
554
+		if (empty($this->_ajax_func)) {
555
+			return;
556
+		} //get out there's nothing to take care of.
557
+		foreach ($this->_ajax_func as $action => $method) {
558
+			// make sure method exists
559
+			if (! method_exists($this, $method)) {
560
+				$msg[] = __(
561
+					'There is no corresponding method for the hook labeled in the _ajax_func array',
562
+					'event_espresso'
563
+				) . '<br />';
564
+				$msg[] = sprintf(
565
+					__(
566
+						'The method name given in the array is %s, check the spelling and make sure it exists in the %s class',
567
+						'event_espresso'
568
+					),
569
+					$method,
570
+					$this->caller
571
+				);
572
+				throw new EE_Error(implode('||', $msg));
573
+			}
574
+			add_action('wp_ajax_' . $action, array($this, $method));
575
+		}
576
+	}
577
+
578
+
579
+	/**
580
+	 * Loop throught the $_init_func array and add_actions for the array.
581
+	 *
582
+	 * @return void
583
+	 */
584
+	protected function _init_hooks()
585
+	{
586
+		if (empty($this->_init_func)) {
587
+			return;
588
+		} //get out there's nothing to take care of.
589
+		// We need to determine what page_route we are on!
590
+		$current_route = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'default';
591
+		foreach ($this->_init_func as $route => $method) {
592
+			// make sure method exists
593
+			if (! method_exists($this, $method)) {
594
+				$msg[] = __(
595
+					'There is no corresponding method for the hook labeled in the _init_func array',
596
+					'event_espresso'
597
+				) . '<br />';
598
+				$msg[] = sprintf(
599
+					__(
600
+						'The method name given in the array is %s, check the spelling and make sure it exists in the %s class',
601
+						'event_espresso'
602
+					),
603
+					$method,
604
+					$this->caller
605
+				);
606
+				throw new EE_Error(implode('||', $msg));
607
+			}
608
+			if ($route == $this->_current_route) {
609
+				add_action('admin_init', array($this, $method));
610
+			}
611
+		}
612
+	}
613
+
614
+
615
+	/**
616
+	 * Loop through the _metaboxes property and add_metaboxes accordingly
617
+	 * //todo we could eventually make this a config component class (i.e. new EE_Metabox);
618
+	 *
619
+	 * @access public
620
+	 * @return void
621
+	 */
622
+	public function add_metaboxes()
623
+	{
624
+		if (empty($this->_metaboxes)) {
625
+			return;
626
+		} //get out we don't have any metaboxes to set for this connection
627
+		$this->_handle_metabox_array($this->_metaboxes);
628
+	}
629
+
630
+
631
+	private function _handle_metabox_array($boxes, $add = true)
632
+	{
633
+
634
+		foreach ($boxes as $box) {
635
+			if (! isset($box['page_route'])) {
636
+				continue;
637
+			} //we dont' have a valid array
638
+			// let's make sure $box['page_route'] is an array so the "foreach" will work.
639
+			$box['page_route'] = (array) $box['page_route'];
640
+			foreach ($box['page_route'] as $route) {
641
+				if ($route != $this->_current_route) {
642
+					continue;
643
+				} //get out we only add metaboxes for set route.
644
+				if ($add) {
645
+					$this->_add_metabox($box);
646
+				} else {
647
+					$this->_remove_metabox($box);
648
+				}
649
+			}
650
+		}
651
+	}
652
+
653
+
654
+	/**
655
+	 * Loop through the _remove_metaboxes property and remove metaboxes accordingly.
656
+	 *
657
+	 * @access public
658
+	 * @return void
659
+	 */
660
+	public function remove_metaboxes()
661
+	{
662
+
663
+		if (empty($this->_remove_metaboxes)) {
664
+			return;
665
+		} //get out there are no metaboxes to remove
666
+		$this->_handle_metabox_array($this->_remove_metaboxes, false);
667
+	}
668
+
669
+
670
+	/**
671
+	 * This just handles adding a metabox
672
+	 *
673
+	 * @access private
674
+	 * @param array $args an array of args that have been set for this metabox by the child class
675
+	 */
676
+	private function _add_metabox($args)
677
+	{
678
+		$current_screen = get_current_screen();
679
+		$screen_id = is_object($current_screen) ? $current_screen->id : null;
680
+		$func = isset($args['func']) ? $args['func'] : 'some_invalid_callback';
681
+		// set defaults
682
+		$defaults = array(
683
+			'func'          => $func,
684
+			'id'            => $this->caller . '_' . $func . '_metabox',
685
+			'priority'      => 'default',
686
+			'label'         => $this->caller,
687
+			'context'       => 'advanced',
688
+			'callback_args' => array(),
689
+			'page'          => isset($args['page']) ? $args['page'] : $screen_id,
690
+		);
691
+		$args = wp_parse_args($args, $defaults);
692
+		extract($args);
693
+		// make sure method exists
694
+		if (! method_exists($this, $func)) {
695
+			$msg[] = __('There is no corresponding method to display the metabox content', 'event_espresso') . '<br />';
696
+			$msg[] = sprintf(
697
+				__(
698
+					'The method name given in the array is %s, check the spelling and make sure it exists in the %s class',
699
+					'event_espresso'
700
+				),
701
+				$func,
702
+				$this->caller
703
+			);
704
+			throw new EE_Error(implode('||', $msg));
705
+		}
706
+		// everything checks out so lets add the metabox
707
+		add_meta_box($id, $label, array($this, $func), $page, $context, $priority, $callback_args);
708
+	}
709
+
710
+
711
+	private function _remove_metabox($args)
712
+	{
713
+		$current_screen = get_current_screen();
714
+		$screen_id = is_object($current_screen) ? $current_screen->id : null;
715
+		$func = isset($args['func']) ? $args['func'] : 'some_invalid_callback';
716
+		// set defaults
717
+		$defaults = array(
718
+			'id'      => isset($args['id'])
719
+				? $args['id']
720
+				: $this->_current_route
721
+				  . '_'
722
+				  . $this->caller
723
+				  . '_'
724
+				  . $func
725
+				  . '_metabox',
726
+			'context' => 'default',
727
+			'screen'  => isset($args['screen']) ? $args['screen'] : $screen_id,
728
+		);
729
+		$args = wp_parse_args($args, $defaults);
730
+		extract($args);
731
+		// everything checks out so lets remove the box!
732
+		remove_meta_box($id, $screen, $context);
733
+	}
734 734
 }
Please login to merge, or discard this patch.
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
         $this->_set_defaults();
206 206
         $this->_set_hooks_properties();
207 207
         // first let's verify we're on the right page
208
-        if (! isset($this->_req_data['page'])
208
+        if ( ! isset($this->_req_data['page'])
209 209
             || (isset($this->_req_data['page'])
210 210
                 && $this->_adminpage_obj->page_slug
211 211
                    != $this->_req_data['page'])) {
@@ -256,9 +256,9 @@  discard block
 block discarded – undo
256 256
     public function enqueue_scripts_styles()
257 257
     {
258 258
 
259
-        if (! empty($this->_scripts_styles)) {
259
+        if ( ! empty($this->_scripts_styles)) {
260 260
             // first let's do all the registrations
261
-            if (! isset($this->_scripts_styles['registers'])) {
261
+            if ( ! isset($this->_scripts_styles['registers'])) {
262 262
                 $msg[] = __(
263 263
                     'There is no "registers" index in the <code>$this->_scripts_styles</code> property.',
264 264
                     'event_espresso'
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
                         'Make sure you read the phpdoc comments above the definition of the $_scripts_styles property in the <code>EE_Admin_Hooks</code> class and modify according in the %s child',
269 269
                         'event_espresso'
270 270
                     ),
271
-                    '<strong>' . $this->caller . '</strong>'
271
+                    '<strong>'.$this->caller.'</strong>'
272 272
                 );
273 273
                 throw new EE_Error(implode('||', $msg));
274 274
             }
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
                 $details = wp_parse_args($details, $defaults);
284 284
                 extract($details);
285 285
                 // let's make sure that we set the 'registers' type if it's not set! We need it later to determine whhich enqueu we do
286
-                $this->_scripts_styles['registers'][ $ref ]['type'] = $type;
286
+                $this->_scripts_styles['registers'][$ref]['type'] = $type;
287 287
                 // let's make sure we're not missing any REQUIRED parameters
288 288
                 if (empty($url)) {
289 289
                     $msg[] = sprintf(
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
                             'Doublecheck your <code>$this->_scripts_styles</code> array in %s and make sure that there is a "url" set for the %s ref',
296 296
                             'event_espresso'
297 297
                         ),
298
-                        '<strong>' . $this->caller . '</strong>',
298
+                        '<strong>'.$this->caller.'</strong>',
299 299
                         $ref
300 300
                     );
301 301
                     throw new EE_Error(implode('||', $msg));
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
                     );
312 312
             }
313 313
             // k now lets do the enqueues
314
-            if (! isset($this->_scripts_styles['enqueues'])) {
314
+            if ( ! isset($this->_scripts_styles['enqueues'])) {
315 315
                 return;
316 316
             }  //not sure if we should throw an error here or not.
317 317
 
@@ -319,22 +319,22 @@  discard block
 block discarded – undo
319 319
                 // make sure $routes is an array
320 320
                 $routes = (array) $routes;
321 321
                 if (in_array($this->_current_route, $routes)) {
322
-                    $this->_scripts_styles['registers'][ $ref ]['type'] == 'js' ? wp_enqueue_script($ref)
322
+                    $this->_scripts_styles['registers'][$ref]['type'] == 'js' ? wp_enqueue_script($ref)
323 323
                         : wp_enqueue_style($ref);
324 324
                     // if we have a localization for the script let's do that too.
325
-                    if (isset($this->_scripts_styles['localize'][ $ref ])) {
326
-                        foreach ($this->_scripts_styles['localize'][ $ref ] as $object_name => $indexes) {
325
+                    if (isset($this->_scripts_styles['localize'][$ref])) {
326
+                        foreach ($this->_scripts_styles['localize'][$ref] as $object_name => $indexes) {
327 327
                             wp_localize_script(
328 328
                                 $ref,
329 329
                                 $object_name,
330
-                                $this->_scripts_styles['localize'][ $ref ][ $object_name ]
330
+                                $this->_scripts_styles['localize'][$ref][$object_name]
331 331
                             );
332 332
                         }
333 333
                     }
334 334
                 }
335 335
             }
336 336
             // let's do the deregisters
337
-            if (! isset($this->_scripts_styles['deregisters'])) {
337
+            if ( ! isset($this->_scripts_styles['deregisters'])) {
338 338
                 return;
339 339
             }
340 340
             foreach ($this->_scripts_styles['deregisters'] as $ref => $details) {
@@ -396,20 +396,20 @@  discard block
 block discarded – undo
396 396
             throw new EE_Error(implode('||', $msg));
397 397
         }
398 398
         $ref = str_replace('_', ' ', $this->_name); // take the_message -> the message
399
-        $ref = str_replace(' ', '_', ucwords($ref)) . '_Admin_Page'; // take the message -> The_Message
399
+        $ref = str_replace(' ', '_', ucwords($ref)).'_Admin_Page'; // take the message -> The_Message
400 400
         // first default file (if exists)
401
-        $decaf_file = EE_ADMIN_PAGES . $this->_name . DS . $ref . '.core.php';
401
+        $decaf_file = EE_ADMIN_PAGES.$this->_name.DS.$ref.'.core.php';
402 402
         if (is_readable($decaf_file)) {
403 403
             require_once($decaf_file);
404 404
         }
405 405
         // now we have to do require for extended file (if needed)
406 406
         if ($this->_extend) {
407
-            require_once(EE_CORE_CAF_ADMIN_EXTEND . $this->_name . DS . 'Extend_' . $ref . '.core.php');
407
+            require_once(EE_CORE_CAF_ADMIN_EXTEND.$this->_name.DS.'Extend_'.$ref.'.core.php');
408 408
         }
409 409
         // if we've got an extended class we use that!
410
-        $ref = $this->_extend ? 'Extend_' . $ref : $ref;
410
+        $ref = $this->_extend ? 'Extend_'.$ref : $ref;
411 411
         // let's make sure the class exists
412
-        if (! class_exists($ref)) {
412
+        if ( ! class_exists($ref)) {
413 413
             $msg[] = __('We can\'t load the page object', 'event_espresso');
414 414
             $msg[] = sprintf(
415 415
                 __(
@@ -451,28 +451,28 @@  discard block
 block discarded – undo
451 451
         // first the actions
452 452
         // note that these action hooks will have the $query_args value available.
453 453
         $admin_class_name = get_class($this->_adminpage_obj);
454
-        if (method_exists($this, '_redirect_action_early_' . $this->_current_route)) {
454
+        if (method_exists($this, '_redirect_action_early_'.$this->_current_route)) {
455 455
             add_action(
456 456
                 'AHEE__'
457 457
                 . $admin_class_name
458 458
                 . '___redirect_after_action__before_redirect_modification_'
459 459
                 . $this->_current_route,
460
-                array($this, '_redirect_action_early_' . $this->_current_route),
460
+                array($this, '_redirect_action_early_'.$this->_current_route),
461 461
                 10
462 462
             );
463 463
         }
464
-        if (method_exists($this, '_redirect_action_' . $this->_current_route)) {
464
+        if (method_exists($this, '_redirect_action_'.$this->_current_route)) {
465 465
             add_action(
466
-                'AHEE_redirect_' . $admin_class_name . $this->_current_route,
467
-                array($this, '_redirect_action_' . $this->_current_route),
466
+                'AHEE_redirect_'.$admin_class_name.$this->_current_route,
467
+                array($this, '_redirect_action_'.$this->_current_route),
468 468
                 10
469 469
             );
470 470
         }
471 471
         // let's hook into the _redirect itself and allow for changing where the user goes after redirect.  This will have $query_args and $redirect_url available.
472
-        if (method_exists($this, '_redirect_filter_' . $this->_current_route)) {
472
+        if (method_exists($this, '_redirect_filter_'.$this->_current_route)) {
473 473
             add_filter(
474
-                'FHEE_redirect_' . $admin_class_name . $this->_current_route,
475
-                array($this, '_redirect_filter_' . $this->_current_route),
474
+                'FHEE_redirect_'.$admin_class_name.$this->_current_route,
475
+                array($this, '_redirect_filter_'.$this->_current_route),
476 476
                 10,
477 477
                 2
478 478
             );
@@ -497,12 +497,12 @@  discard block
 block discarded – undo
497 497
                 'argnum'   => 1,
498 498
                 'priority' => 10,
499 499
             ),
500
-            'FHEE_list_table_views_' . $this->_adminpage_obj->page_slug . '_' . $this->_current_route => array(
500
+            'FHEE_list_table_views_'.$this->_adminpage_obj->page_slug.'_'.$this->_current_route => array(
501 501
                 'type'     => 'filter',
502 502
                 'argnum'   => 1,
503 503
                 'priority' => 10,
504 504
             ),
505
-            'FHEE_list_table_views_' . $this->_adminpage_obj->page_slug                               => array(
505
+            'FHEE_list_table_views_'.$this->_adminpage_obj->page_slug                               => array(
506 506
                 'type'     => 'filter',
507 507
                 'argnum'   => 1,
508 508
                 'priority' => 10,
@@ -519,21 +519,21 @@  discard block
 block discarded – undo
519 519
             ),
520 520
         );
521 521
         foreach ($hook_filter_array as $hook => $args) {
522
-            if (method_exists($this, $this->_current_route . '_' . $hook)) {
523
-                if (isset($this->_wp_action_filters_priority[ $hook ])) {
524
-                    $args['priority'] = $this->_wp_action_filters_priority[ $hook ];
522
+            if (method_exists($this, $this->_current_route.'_'.$hook)) {
523
+                if (isset($this->_wp_action_filters_priority[$hook])) {
524
+                    $args['priority'] = $this->_wp_action_filters_priority[$hook];
525 525
                 }
526 526
                 if ($args['type'] == 'action') {
527 527
                     add_action(
528 528
                         $hook,
529
-                        array($this, $this->_current_route . '_' . $hook),
529
+                        array($this, $this->_current_route.'_'.$hook),
530 530
                         $args['priority'],
531 531
                         $args['argnum']
532 532
                     );
533 533
                 } else {
534 534
                     add_filter(
535 535
                         $hook,
536
-                        array($this, $this->_current_route . '_' . $hook),
536
+                        array($this, $this->_current_route.'_'.$hook),
537 537
                         $args['priority'],
538 538
                         $args['argnum']
539 539
                     );
@@ -556,11 +556,11 @@  discard block
 block discarded – undo
556 556
         } //get out there's nothing to take care of.
557 557
         foreach ($this->_ajax_func as $action => $method) {
558 558
             // make sure method exists
559
-            if (! method_exists($this, $method)) {
559
+            if ( ! method_exists($this, $method)) {
560 560
                 $msg[] = __(
561 561
                     'There is no corresponding method for the hook labeled in the _ajax_func array',
562 562
                     'event_espresso'
563
-                ) . '<br />';
563
+                ).'<br />';
564 564
                 $msg[] = sprintf(
565 565
                     __(
566 566
                         'The method name given in the array is %s, check the spelling and make sure it exists in the %s class',
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
                 );
572 572
                 throw new EE_Error(implode('||', $msg));
573 573
             }
574
-            add_action('wp_ajax_' . $action, array($this, $method));
574
+            add_action('wp_ajax_'.$action, array($this, $method));
575 575
         }
576 576
     }
577 577
 
@@ -590,11 +590,11 @@  discard block
 block discarded – undo
590 590
         $current_route = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'default';
591 591
         foreach ($this->_init_func as $route => $method) {
592 592
             // make sure method exists
593
-            if (! method_exists($this, $method)) {
593
+            if ( ! method_exists($this, $method)) {
594 594
                 $msg[] = __(
595 595
                     'There is no corresponding method for the hook labeled in the _init_func array',
596 596
                     'event_espresso'
597
-                ) . '<br />';
597
+                ).'<br />';
598 598
                 $msg[] = sprintf(
599 599
                     __(
600 600
                         'The method name given in the array is %s, check the spelling and make sure it exists in the %s class',
@@ -632,7 +632,7 @@  discard block
 block discarded – undo
632 632
     {
633 633
 
634 634
         foreach ($boxes as $box) {
635
-            if (! isset($box['page_route'])) {
635
+            if ( ! isset($box['page_route'])) {
636 636
                 continue;
637 637
             } //we dont' have a valid array
638 638
             // let's make sure $box['page_route'] is an array so the "foreach" will work.
@@ -681,7 +681,7 @@  discard block
 block discarded – undo
681 681
         // set defaults
682 682
         $defaults = array(
683 683
             'func'          => $func,
684
-            'id'            => $this->caller . '_' . $func . '_metabox',
684
+            'id'            => $this->caller.'_'.$func.'_metabox',
685 685
             'priority'      => 'default',
686 686
             'label'         => $this->caller,
687 687
             'context'       => 'advanced',
@@ -691,8 +691,8 @@  discard block
 block discarded – undo
691 691
         $args = wp_parse_args($args, $defaults);
692 692
         extract($args);
693 693
         // make sure method exists
694
-        if (! method_exists($this, $func)) {
695
-            $msg[] = __('There is no corresponding method to display the metabox content', 'event_espresso') . '<br />';
694
+        if ( ! method_exists($this, $func)) {
695
+            $msg[] = __('There is no corresponding method to display the metabox content', 'event_espresso').'<br />';
696 696
             $msg[] = sprintf(
697 697
                 __(
698 698
                     'The method name given in the array is %s, check the spelling and make sure it exists in the %s class',
Please login to merge, or discard this patch.
data_migration_scripts/4_1_0_stages/EE_DMS_4_1_0_org_options.dmsstage.php 2 patches
Indentation   +273 added lines, -273 removed lines patch added patch discarded remove patch
@@ -103,289 +103,289 @@
 block discarded – undo
103 103
 class EE_DMS_4_1_0_org_options extends EE_Data_Migration_Script_Stage
104 104
 {
105 105
 
106
-    public function _migration_step($num_items = 50)
107
-    {
106
+	public function _migration_step($num_items = 50)
107
+	{
108 108
 
109
-        $items_actually_migrated = 0;
110
-        $old_org_options = get_option('events_organization_settings');
111
-        foreach ($this->_org_options_we_know_how_to_migrate as $option_name) {
112
-            // only bother migrating if there's a setting to migrate. Otherwise we'll just use the default
113
-            if (isset($old_org_options[ $option_name ])) {
114
-                $this->_handle_org_option($option_name, $old_org_options[ $option_name ]);
115
-            }
116
-            if ($option_name=='surcharge') {
117
-                $this->_insert_new_global_surcharge_price($old_org_options);
118
-            }
119
-            $items_actually_migrated++;
120
-        }
109
+		$items_actually_migrated = 0;
110
+		$old_org_options = get_option('events_organization_settings');
111
+		foreach ($this->_org_options_we_know_how_to_migrate as $option_name) {
112
+			// only bother migrating if there's a setting to migrate. Otherwise we'll just use the default
113
+			if (isset($old_org_options[ $option_name ])) {
114
+				$this->_handle_org_option($option_name, $old_org_options[ $option_name ]);
115
+			}
116
+			if ($option_name=='surcharge') {
117
+				$this->_insert_new_global_surcharge_price($old_org_options);
118
+			}
119
+			$items_actually_migrated++;
120
+		}
121 121
 
122
-        $success = EE_Config::instance()->update_espresso_config(false, true);
123
-        if (! $success) {
124
-            $this->add_error(sprintf(__('Could not save EE Config during org options stage. Reason: %s', 'event_espresso'), EE_Error::get_notices(false)));
125
-            EE_Error::overwrite_errors();
126
-        }
127
-        EE_Network_Config::instance()->update_config(false, false);
128
-        if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) {
129
-            // we may have added new pages and this might be necessary
130
-            flush_rewrite_rules();
131
-            $this->set_completed();
132
-        }
133
-        return $items_actually_migrated;
134
-    }
135
-    public function _count_records_to_migrate()
136
-    {
137
-        $count_of_options_to_migrate = count($this->_org_options_we_know_how_to_migrate);
138
-        return $count_of_options_to_migrate;
139
-    }
140
-    public function __construct()
141
-    {
142
-        $this->_pretty_name = __("Organization Options/Config", "event_espresso");
143
-        $this->_org_options_we_know_how_to_migrate = apply_filters('FHEE__EE_DMS_4_1_0_org_options__org_options_we_know_how_to_migrate', $this->_org_options_we_know_how_to_migrate);
144
-        parent::__construct();
145
-    }
122
+		$success = EE_Config::instance()->update_espresso_config(false, true);
123
+		if (! $success) {
124
+			$this->add_error(sprintf(__('Could not save EE Config during org options stage. Reason: %s', 'event_espresso'), EE_Error::get_notices(false)));
125
+			EE_Error::overwrite_errors();
126
+		}
127
+		EE_Network_Config::instance()->update_config(false, false);
128
+		if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) {
129
+			// we may have added new pages and this might be necessary
130
+			flush_rewrite_rules();
131
+			$this->set_completed();
132
+		}
133
+		return $items_actually_migrated;
134
+	}
135
+	public function _count_records_to_migrate()
136
+	{
137
+		$count_of_options_to_migrate = count($this->_org_options_we_know_how_to_migrate);
138
+		return $count_of_options_to_migrate;
139
+	}
140
+	public function __construct()
141
+	{
142
+		$this->_pretty_name = __("Organization Options/Config", "event_espresso");
143
+		$this->_org_options_we_know_how_to_migrate = apply_filters('FHEE__EE_DMS_4_1_0_org_options__org_options_we_know_how_to_migrate', $this->_org_options_we_know_how_to_migrate);
144
+		parent::__construct();
145
+	}
146 146
 
147
-    private function _handle_org_option($option_name, $value)
148
-    {
149
-        $c = EE_Config::instance();
150
-        $cn = EE_Network_Config::instance();
151
-        switch ($option_name) {
152
-            case 'organization':
153
-                $c->organization->name = $value;
154
-                break;
155
-            case 'organization_street1':
156
-                $c->organization->address_1 = $value;
157
-                break;
158
-            case 'organization_street2':
159
-                $c->organization->address_2 = $value;
160
-                break;
161
-            case 'organization_city':
162
-                $c->organization->city = $value;
163
-                break;
164
-            case 'organization_state':
165
-                try {
166
-                    $state = $this->get_migration_script()->get_or_create_state($value);
167
-                    $state_id = $state['STA_ID'];
168
-                    $c->organization->STA_ID = $state_id;
169
-                } catch (EE_Error $e) {
170
-                }
171
-                break;
172
-            case 'organization_zip':
173
-                $c->organization->zip = $value;
174
-                break;
175
-            case 'contact_email':
176
-                $c->organization->email = $value;
177
-                break;
178
-            case 'default_payment_status':
179
-                $c->registration->default_STS_ID =  $this->get_migration_script()->convert_3_1_payment_status_to_4_1_STS_ID($value);
180
-                break;
181
-            case 'organization_country':
182
-                $iso =$this->get_migration_script()->get_iso_from_3_1_country_id($value);
183
-                $c->organization->CNT_ISO = $iso;
184
-                $country_row = $this->get_migration_script()->get_or_create_country($iso);
185
-                if (! $country_row) {
186
-                    $this->add_error(sprintf(__("Could not set country's currency config because no country exists for ISO %s", "event_espresso"), $iso));
187
-                }
188
-                // can't use EE_Currency_Config's handy constructor because the models are off-limits right now (and it uses them)
189
-                $c->currency->code = $country_row['CNT_cur_code'];          // currency code: USD, CAD, EUR
190
-                $c->currency->name = $country_row['CNT_cur_single'];    // Dollar
191
-                $c->currency->plural = $country_row['CNT_cur_plural'];  // Dollars
192
-                $c->currency->sign =  $country_row['CNT_cur_sign'];             // currency sign: $
193
-                $c->currency->sign_b4 = filter_var($country_row['CNT_cur_sign_b4'], FILTER_VALIDATE_BOOLEAN);        // currency sign before or after: $TRUE  or  FALSE$
194
-                $c->currency->dec_plc = (int) $country_row['CNT_cur_dec_plc'];    // decimal places: 2 = 0.00  3 = 0.000
195
-                $c->currency->dec_mrk = $country_row['CNT_cur_dec_mrk'];    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
196
-                $c->currency->thsnds = $country_row['CNT_cur_thsnds'];  // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
147
+	private function _handle_org_option($option_name, $value)
148
+	{
149
+		$c = EE_Config::instance();
150
+		$cn = EE_Network_Config::instance();
151
+		switch ($option_name) {
152
+			case 'organization':
153
+				$c->organization->name = $value;
154
+				break;
155
+			case 'organization_street1':
156
+				$c->organization->address_1 = $value;
157
+				break;
158
+			case 'organization_street2':
159
+				$c->organization->address_2 = $value;
160
+				break;
161
+			case 'organization_city':
162
+				$c->organization->city = $value;
163
+				break;
164
+			case 'organization_state':
165
+				try {
166
+					$state = $this->get_migration_script()->get_or_create_state($value);
167
+					$state_id = $state['STA_ID'];
168
+					$c->organization->STA_ID = $state_id;
169
+				} catch (EE_Error $e) {
170
+				}
171
+				break;
172
+			case 'organization_zip':
173
+				$c->organization->zip = $value;
174
+				break;
175
+			case 'contact_email':
176
+				$c->organization->email = $value;
177
+				break;
178
+			case 'default_payment_status':
179
+				$c->registration->default_STS_ID =  $this->get_migration_script()->convert_3_1_payment_status_to_4_1_STS_ID($value);
180
+				break;
181
+			case 'organization_country':
182
+				$iso =$this->get_migration_script()->get_iso_from_3_1_country_id($value);
183
+				$c->organization->CNT_ISO = $iso;
184
+				$country_row = $this->get_migration_script()->get_or_create_country($iso);
185
+				if (! $country_row) {
186
+					$this->add_error(sprintf(__("Could not set country's currency config because no country exists for ISO %s", "event_espresso"), $iso));
187
+				}
188
+				// can't use EE_Currency_Config's handy constructor because the models are off-limits right now (and it uses them)
189
+				$c->currency->code = $country_row['CNT_cur_code'];          // currency code: USD, CAD, EUR
190
+				$c->currency->name = $country_row['CNT_cur_single'];    // Dollar
191
+				$c->currency->plural = $country_row['CNT_cur_plural'];  // Dollars
192
+				$c->currency->sign =  $country_row['CNT_cur_sign'];             // currency sign: $
193
+				$c->currency->sign_b4 = filter_var($country_row['CNT_cur_sign_b4'], FILTER_VALIDATE_BOOLEAN);        // currency sign before or after: $TRUE  or  FALSE$
194
+				$c->currency->dec_plc = (int) $country_row['CNT_cur_dec_plc'];    // decimal places: 2 = 0.00  3 = 0.000
195
+				$c->currency->dec_mrk = $country_row['CNT_cur_dec_mrk'];    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
196
+				$c->currency->thsnds = $country_row['CNT_cur_thsnds'];  // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
197 197
   //            $c->currency = new EE_Currency_Config($c->organization->CNT_ISO);break;
198 198
   //        case 'currency_symbol': ignore the currency symbol. we'll just go by their country.
199 199
   //            $c->currency->sign = $value;break;
200
-            case 'show_pending_payment_options':
201
-                $c->registration->show_pending_payment_options = ($value == 'Y');
202
-                break;
203
-            case 'display_address_in_regform':
204
-                $c->template_settings->display_address_in_regform = ($value == 'Y');
205
-                break;
206
-            case 'default_logo_url':
207
-                $c->organization->logo_url = $value;
208
-                break;
209
-            case 'event_page_id':
210
-                // also, find that post, and changes the shortcode in it from ESPRESSO_PAYMENTS
211
-                // to ESPRESSO_THANK_YOU
212
-                $reg_page_post = get_post($value);
213
-                $reg_page_post->post_content = str_replace("[ESPRESSO_EVENTS]", "[ESPRESSO_CHECKOUT]", $reg_page_post->post_content);
214
-                wp_update_post($reg_page_post);
215
-                $c->core->reg_page_id = $value;
216
-                break;
217
-            case 'return_url':
218
-                // also, find that post, and changes the shortcode in it from ESPRESSO_PAYMENTS
219
-                // to ESPRESSO_THANK_YOU
220
-                $thank_you_page_post = get_post($value);
221
-                $thank_you_page_post->post_content = str_replace("[ESPRESSO_PAYMENTS]", "[ESPRESSO_THANK_YOU]", $thank_you_page_post->post_content);
222
-                wp_update_post($thank_you_page_post);
223
-                $c->core->thank_you_page_id = $value;
224
-                break;
225
-            case 'cancel_return':
226
-                $c->core->cancel_page_id = $value;
200
+			case 'show_pending_payment_options':
201
+				$c->registration->show_pending_payment_options = ($value == 'Y');
202
+				break;
203
+			case 'display_address_in_regform':
204
+				$c->template_settings->display_address_in_regform = ($value == 'Y');
205
+				break;
206
+			case 'default_logo_url':
207
+				$c->organization->logo_url = $value;
208
+				break;
209
+			case 'event_page_id':
210
+				// also, find that post, and changes the shortcode in it from ESPRESSO_PAYMENTS
211
+				// to ESPRESSO_THANK_YOU
212
+				$reg_page_post = get_post($value);
213
+				$reg_page_post->post_content = str_replace("[ESPRESSO_EVENTS]", "[ESPRESSO_CHECKOUT]", $reg_page_post->post_content);
214
+				wp_update_post($reg_page_post);
215
+				$c->core->reg_page_id = $value;
216
+				break;
217
+			case 'return_url':
218
+				// also, find that post, and changes the shortcode in it from ESPRESSO_PAYMENTS
219
+				// to ESPRESSO_THANK_YOU
220
+				$thank_you_page_post = get_post($value);
221
+				$thank_you_page_post->post_content = str_replace("[ESPRESSO_PAYMENTS]", "[ESPRESSO_THANK_YOU]", $thank_you_page_post->post_content);
222
+				wp_update_post($thank_you_page_post);
223
+				$c->core->thank_you_page_id = $value;
224
+				break;
225
+			case 'cancel_return':
226
+				$c->core->cancel_page_id = $value;
227 227
 
228
-                break;
229
-            case 'notify_url':
230
-                $c->core->txn_page_id = $value;
231
-                break;
232
-            case 'use_captcha':
233
-                $c->registration->use_captcha = ($value == 'Y');
234
-                break;
235
-            case 'recaptcha_publickey':
236
-                $c->registration->recaptcha_publickey = $value;
237
-                break;
238
-            case 'recaptcha_privatekey':
239
-                $c->registration->recaptcha_privatekey = $value;
240
-                break;
241
-            case 'recaptcha_theme':
242
-                $c->registration->recaptcha_theme = $value;
243
-                break;
244
-            case 'recaptcha_width':
245
-                $c->registration->recaptcha_width = $value;
246
-                break;
247
-            case 'recaptcha_language':
248
-                $c->registration->recaptcha_language = $value;
249
-                break;
250
-            case 'espresso_dashboard_widget':
251
-                $c->admin->use_dashboard_widget = ($value == 'Y');
252
-                break;
253
-            case 'use_personnel_manager':
254
-                $c->admin->use_personnel_manager = ($value == 'Y');
255
-                break;
256
-            case 'use_event_timezones':
257
-                $c->admin->use_event_timezones = ($value == 'Y');
258
-                break;
259
-            case 'full_logging':
260
-                $c->admin->use_full_logging = ($value == 'Y');
261
-                break;
262
-            case 'affiliate_id':
263
-                $c->admin->affiliate_id = $value;
264
-                break;
265
-            case 'site_license_key':
266
-                $cn->core->site_license_key = $value;
267
-                break;
268
-            default:
269
-                do_action('AHEE__EE_DMS_4_1_0__handle_org_option', $option_name, $value);
270
-        }
271
-    }
228
+				break;
229
+			case 'notify_url':
230
+				$c->core->txn_page_id = $value;
231
+				break;
232
+			case 'use_captcha':
233
+				$c->registration->use_captcha = ($value == 'Y');
234
+				break;
235
+			case 'recaptcha_publickey':
236
+				$c->registration->recaptcha_publickey = $value;
237
+				break;
238
+			case 'recaptcha_privatekey':
239
+				$c->registration->recaptcha_privatekey = $value;
240
+				break;
241
+			case 'recaptcha_theme':
242
+				$c->registration->recaptcha_theme = $value;
243
+				break;
244
+			case 'recaptcha_width':
245
+				$c->registration->recaptcha_width = $value;
246
+				break;
247
+			case 'recaptcha_language':
248
+				$c->registration->recaptcha_language = $value;
249
+				break;
250
+			case 'espresso_dashboard_widget':
251
+				$c->admin->use_dashboard_widget = ($value == 'Y');
252
+				break;
253
+			case 'use_personnel_manager':
254
+				$c->admin->use_personnel_manager = ($value == 'Y');
255
+				break;
256
+			case 'use_event_timezones':
257
+				$c->admin->use_event_timezones = ($value == 'Y');
258
+				break;
259
+			case 'full_logging':
260
+				$c->admin->use_full_logging = ($value == 'Y');
261
+				break;
262
+			case 'affiliate_id':
263
+				$c->admin->affiliate_id = $value;
264
+				break;
265
+			case 'site_license_key':
266
+				$cn->core->site_license_key = $value;
267
+				break;
268
+			default:
269
+				do_action('AHEE__EE_DMS_4_1_0__handle_org_option', $option_name, $value);
270
+		}
271
+	}
272 272
 
273
-    /**
274
-     * Creates a 4.1 member price discount
275
-     * @global type $wpdb
276
-     * @param type $old_price
277
-     * @return int
278
-     */
279
-    private function _insert_new_global_surcharge_price($org_options)
280
-    {
281
-        $amount = floatval($org_options['surcharge']);
282
-        // dont createa a price if the surcharge is 0
283
-        if ($amount <=.01) {
284
-            return 0;
285
-        }
286
-        if ($org_options['surcharge_type'] == 'flat_rate') {
287
-            $price_type = EE_DMS_4_1_0_prices::price_type_flat_surcharge;
288
-        } else {
289
-            $price_type = EE_DMS_4_1_0_prices::price_type_percent_surcharge;
290
-        }
291
-        global $wpdb;
292
-        $cols_n_values = array(
293
-            'PRT_ID'=>$price_type,
294
-            'PRC_amount'=>$amount,
295
-            'PRC_name'=>  $org_options['surcharge_text'],
296
-            'PRC_is_default'=>true,
297
-            'PRC_overrides'=>false,
298
-            'PRC_order'=>100,
299
-            'PRC_deleted'=>false,
300
-            'PRC_parent'=>null
273
+	/**
274
+	 * Creates a 4.1 member price discount
275
+	 * @global type $wpdb
276
+	 * @param type $old_price
277
+	 * @return int
278
+	 */
279
+	private function _insert_new_global_surcharge_price($org_options)
280
+	{
281
+		$amount = floatval($org_options['surcharge']);
282
+		// dont createa a price if the surcharge is 0
283
+		if ($amount <=.01) {
284
+			return 0;
285
+		}
286
+		if ($org_options['surcharge_type'] == 'flat_rate') {
287
+			$price_type = EE_DMS_4_1_0_prices::price_type_flat_surcharge;
288
+		} else {
289
+			$price_type = EE_DMS_4_1_0_prices::price_type_percent_surcharge;
290
+		}
291
+		global $wpdb;
292
+		$cols_n_values = array(
293
+			'PRT_ID'=>$price_type,
294
+			'PRC_amount'=>$amount,
295
+			'PRC_name'=>  $org_options['surcharge_text'],
296
+			'PRC_is_default'=>true,
297
+			'PRC_overrides'=>false,
298
+			'PRC_order'=>100,
299
+			'PRC_deleted'=>false,
300
+			'PRC_parent'=>null
301 301
 
302
-        );
303
-        $datatypes = array(
304
-            '%d',// PRT_ID
305
-            '%f',// PRT_amount
306
-            '%s',// PRC_name
307
-            '%d',// PRC_is_default
308
-            '%d',// PRC_overrides
309
-            '%d',// PRC_order
310
-            '%d',// PRC_deleted
311
-            '%d',// PRC_parent
312
-        );
313
-        $price_table = $wpdb->prefix."esp_price";
314
-        $success = $wpdb->insert($price_table, $cols_n_values, $datatypes);
315
-        if (! $success) {
316
-            $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion(
317
-                'org_options',
318
-                array(
319
-                        'surcharge'=>$org_options['surcharge'],
320
-                        'surcharge_type'=>$org_options['surcharge_type'],
321
-                        'surcharge_text'=>$org_options['surcharge_text']),
322
-                $price_table,
323
-                $cols_n_values,
324
-                $datatypes
325
-            ));
326
-            return 0;
327
-        }
328
-        $new_id = $wpdb->insert_id;
329
-        return $new_id;
330
-    }
302
+		);
303
+		$datatypes = array(
304
+			'%d',// PRT_ID
305
+			'%f',// PRT_amount
306
+			'%s',// PRC_name
307
+			'%d',// PRC_is_default
308
+			'%d',// PRC_overrides
309
+			'%d',// PRC_order
310
+			'%d',// PRC_deleted
311
+			'%d',// PRC_parent
312
+		);
313
+		$price_table = $wpdb->prefix."esp_price";
314
+		$success = $wpdb->insert($price_table, $cols_n_values, $datatypes);
315
+		if (! $success) {
316
+			$this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion(
317
+				'org_options',
318
+				array(
319
+						'surcharge'=>$org_options['surcharge'],
320
+						'surcharge_type'=>$org_options['surcharge_type'],
321
+						'surcharge_text'=>$org_options['surcharge_text']),
322
+				$price_table,
323
+				$cols_n_values,
324
+				$datatypes
325
+			));
326
+			return 0;
327
+		}
328
+		$new_id = $wpdb->insert_id;
329
+		return $new_id;
330
+	}
331 331
 
332
-    protected $_org_options_we_know_how_to_migrate = array(
333
-      'organization',
334
-      'organization_street1',
335
-      'organization_street2',
336
-      'organization_city',
337
-      'organization_state',
338
-      'organization_zip',
339
-      'contact_email',
340
-      'default_mail',
341
-      'payment_subject',
342
-      'payment_message',
343
-      'message',
344
-      'default_payment_status',
345
-      'surcharge',// unused?
346
-      'country_id',// unused?
347
-      'organization_country',
332
+	protected $_org_options_we_know_how_to_migrate = array(
333
+	  'organization',
334
+	  'organization_street1',
335
+	  'organization_street2',
336
+	  'organization_city',
337
+	  'organization_state',
338
+	  'organization_zip',
339
+	  'contact_email',
340
+	  'default_mail',
341
+	  'payment_subject',
342
+	  'payment_message',
343
+	  'message',
344
+	  'default_payment_status',
345
+	  'surcharge',// unused?
346
+	  'country_id',// unused?
347
+	  'organization_country',
348 348
 //    'currency_symbol',
349
-      'expire_on_registration_end',
350
-      'email_before_payment',
351
-      'email_fancy_headers',
352
-      'enable_default_style',
353
-      'event_ssl_active',
354
-      'selected_style',
355
-      'show_pending_payment_options',
356
-      'show_reg_footer',
357
-      'skip_confirmation_page',
358
-      'allow_mer_discounts',// no equiv
359
-      'allow_mer_vouchers',// no equiv
360
-      'display_short_description_in_event_list',
361
-      'display_description_on_multi_reg_page',
362
-      'display_address_in_event_list',
363
-      'display_address_in_regform',
364
-      'use_custom_post_types',// no equiv
365
-      'display_ical_download',
366
-      'display_featured_image',
367
-      'themeroller',
368
-      'default_logo_url',
369
-      'event_page_id',
370
-      'return_url',
371
-      'cancel_return',
372
-      'notify_url',
373
-      'events_in_dashboard',
374
-      'use_captcha',
375
-      'recaptcha_publickey',
376
-      'recaptcha_privatekey',
377
-      'recaptcha_theme',
378
-      'recaptcha_width',
379
-      'recaptcha_language',
380
-      'espresso_dashboard_widget',
381
-      'time_reg_limit',
349
+	  'expire_on_registration_end',
350
+	  'email_before_payment',
351
+	  'email_fancy_headers',
352
+	  'enable_default_style',
353
+	  'event_ssl_active',
354
+	  'selected_style',
355
+	  'show_pending_payment_options',
356
+	  'show_reg_footer',
357
+	  'skip_confirmation_page',
358
+	  'allow_mer_discounts',// no equiv
359
+	  'allow_mer_vouchers',// no equiv
360
+	  'display_short_description_in_event_list',
361
+	  'display_description_on_multi_reg_page',
362
+	  'display_address_in_event_list',
363
+	  'display_address_in_regform',
364
+	  'use_custom_post_types',// no equiv
365
+	  'display_ical_download',
366
+	  'display_featured_image',
367
+	  'themeroller',
368
+	  'default_logo_url',
369
+	  'event_page_id',
370
+	  'return_url',
371
+	  'cancel_return',
372
+	  'notify_url',
373
+	  'events_in_dashboard',
374
+	  'use_captcha',
375
+	  'recaptcha_publickey',
376
+	  'recaptcha_privatekey',
377
+	  'recaptcha_theme',
378
+	  'recaptcha_width',
379
+	  'recaptcha_language',
380
+	  'espresso_dashboard_widget',
381
+	  'time_reg_limit',
382 382
 //    'use_attendee_pre_approval', removed in 4.1- instead this is factored into the default reg status
383
-      'use_personnel_manager',// no equiv
384
-      'use_event_timezones',
385
-      'full_logging',
386
-      'surcharge_type',// unused
387
-      'surcharge_text',// unused
388
-      'affiliate_id',
389
-      'site_license_key',
390
-    );
383
+	  'use_personnel_manager',// no equiv
384
+	  'use_event_timezones',
385
+	  'full_logging',
386
+	  'surcharge_type',// unused
387
+	  'surcharge_text',// unused
388
+	  'affiliate_id',
389
+	  'site_license_key',
390
+	);
391 391
 }
Please login to merge, or discard this patch.
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -110,17 +110,17 @@  discard block
 block discarded – undo
110 110
         $old_org_options = get_option('events_organization_settings');
111 111
         foreach ($this->_org_options_we_know_how_to_migrate as $option_name) {
112 112
             // only bother migrating if there's a setting to migrate. Otherwise we'll just use the default
113
-            if (isset($old_org_options[ $option_name ])) {
114
-                $this->_handle_org_option($option_name, $old_org_options[ $option_name ]);
113
+            if (isset($old_org_options[$option_name])) {
114
+                $this->_handle_org_option($option_name, $old_org_options[$option_name]);
115 115
             }
116
-            if ($option_name=='surcharge') {
116
+            if ($option_name == 'surcharge') {
117 117
                 $this->_insert_new_global_surcharge_price($old_org_options);
118 118
             }
119 119
             $items_actually_migrated++;
120 120
         }
121 121
 
122 122
         $success = EE_Config::instance()->update_espresso_config(false, true);
123
-        if (! $success) {
123
+        if ( ! $success) {
124 124
             $this->add_error(sprintf(__('Could not save EE Config during org options stage. Reason: %s', 'event_espresso'), EE_Error::get_notices(false)));
125 125
             EE_Error::overwrite_errors();
126 126
         }
@@ -176,24 +176,24 @@  discard block
 block discarded – undo
176 176
                 $c->organization->email = $value;
177 177
                 break;
178 178
             case 'default_payment_status':
179
-                $c->registration->default_STS_ID =  $this->get_migration_script()->convert_3_1_payment_status_to_4_1_STS_ID($value);
179
+                $c->registration->default_STS_ID = $this->get_migration_script()->convert_3_1_payment_status_to_4_1_STS_ID($value);
180 180
                 break;
181 181
             case 'organization_country':
182
-                $iso =$this->get_migration_script()->get_iso_from_3_1_country_id($value);
182
+                $iso = $this->get_migration_script()->get_iso_from_3_1_country_id($value);
183 183
                 $c->organization->CNT_ISO = $iso;
184 184
                 $country_row = $this->get_migration_script()->get_or_create_country($iso);
185
-                if (! $country_row) {
185
+                if ( ! $country_row) {
186 186
                     $this->add_error(sprintf(__("Could not set country's currency config because no country exists for ISO %s", "event_espresso"), $iso));
187 187
                 }
188 188
                 // can't use EE_Currency_Config's handy constructor because the models are off-limits right now (and it uses them)
189
-                $c->currency->code = $country_row['CNT_cur_code'];          // currency code: USD, CAD, EUR
190
-                $c->currency->name = $country_row['CNT_cur_single'];    // Dollar
191
-                $c->currency->plural = $country_row['CNT_cur_plural'];  // Dollars
192
-                $c->currency->sign =  $country_row['CNT_cur_sign'];             // currency sign: $
193
-                $c->currency->sign_b4 = filter_var($country_row['CNT_cur_sign_b4'], FILTER_VALIDATE_BOOLEAN);        // currency sign before or after: $TRUE  or  FALSE$
194
-                $c->currency->dec_plc = (int) $country_row['CNT_cur_dec_plc'];    // decimal places: 2 = 0.00  3 = 0.000
195
-                $c->currency->dec_mrk = $country_row['CNT_cur_dec_mrk'];    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
196
-                $c->currency->thsnds = $country_row['CNT_cur_thsnds'];  // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
189
+                $c->currency->code = $country_row['CNT_cur_code']; // currency code: USD, CAD, EUR
190
+                $c->currency->name = $country_row['CNT_cur_single']; // Dollar
191
+                $c->currency->plural = $country_row['CNT_cur_plural']; // Dollars
192
+                $c->currency->sign = $country_row['CNT_cur_sign']; // currency sign: $
193
+                $c->currency->sign_b4 = filter_var($country_row['CNT_cur_sign_b4'], FILTER_VALIDATE_BOOLEAN); // currency sign before or after: $TRUE  or  FALSE$
194
+                $c->currency->dec_plc = (int) $country_row['CNT_cur_dec_plc']; // decimal places: 2 = 0.00  3 = 0.000
195
+                $c->currency->dec_mrk = $country_row['CNT_cur_dec_mrk']; // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
196
+                $c->currency->thsnds = $country_row['CNT_cur_thsnds']; // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
197 197
   //            $c->currency = new EE_Currency_Config($c->organization->CNT_ISO);break;
198 198
   //        case 'currency_symbol': ignore the currency symbol. we'll just go by their country.
199 199
   //            $c->currency->sign = $value;break;
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
     {
281 281
         $amount = floatval($org_options['surcharge']);
282 282
         // dont createa a price if the surcharge is 0
283
-        if ($amount <=.01) {
283
+        if ($amount <= .01) {
284 284
             return 0;
285 285
         }
286 286
         if ($org_options['surcharge_type'] == 'flat_rate') {
@@ -301,18 +301,18 @@  discard block
 block discarded – undo
301 301
 
302 302
         );
303 303
         $datatypes = array(
304
-            '%d',// PRT_ID
305
-            '%f',// PRT_amount
306
-            '%s',// PRC_name
307
-            '%d',// PRC_is_default
308
-            '%d',// PRC_overrides
309
-            '%d',// PRC_order
310
-            '%d',// PRC_deleted
311
-            '%d',// PRC_parent
304
+            '%d', // PRT_ID
305
+            '%f', // PRT_amount
306
+            '%s', // PRC_name
307
+            '%d', // PRC_is_default
308
+            '%d', // PRC_overrides
309
+            '%d', // PRC_order
310
+            '%d', // PRC_deleted
311
+            '%d', // PRC_parent
312 312
         );
313 313
         $price_table = $wpdb->prefix."esp_price";
314 314
         $success = $wpdb->insert($price_table, $cols_n_values, $datatypes);
315
-        if (! $success) {
315
+        if ( ! $success) {
316 316
             $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion(
317 317
                 'org_options',
318 318
                 array(
@@ -342,8 +342,8 @@  discard block
 block discarded – undo
342 342
       'payment_message',
343 343
       'message',
344 344
       'default_payment_status',
345
-      'surcharge',// unused?
346
-      'country_id',// unused?
345
+      'surcharge', // unused?
346
+      'country_id', // unused?
347 347
       'organization_country',
348 348
 //    'currency_symbol',
349 349
       'expire_on_registration_end',
@@ -355,13 +355,13 @@  discard block
 block discarded – undo
355 355
       'show_pending_payment_options',
356 356
       'show_reg_footer',
357 357
       'skip_confirmation_page',
358
-      'allow_mer_discounts',// no equiv
359
-      'allow_mer_vouchers',// no equiv
358
+      'allow_mer_discounts', // no equiv
359
+      'allow_mer_vouchers', // no equiv
360 360
       'display_short_description_in_event_list',
361 361
       'display_description_on_multi_reg_page',
362 362
       'display_address_in_event_list',
363 363
       'display_address_in_regform',
364
-      'use_custom_post_types',// no equiv
364
+      'use_custom_post_types', // no equiv
365 365
       'display_ical_download',
366 366
       'display_featured_image',
367 367
       'themeroller',
@@ -380,11 +380,11 @@  discard block
 block discarded – undo
380 380
       'espresso_dashboard_widget',
381 381
       'time_reg_limit',
382 382
 //    'use_attendee_pre_approval', removed in 4.1- instead this is factored into the default reg status
383
-      'use_personnel_manager',// no equiv
383
+      'use_personnel_manager', // no equiv
384 384
       'use_event_timezones',
385 385
       'full_logging',
386
-      'surcharge_type',// unused
387
-      'surcharge_text',// unused
386
+      'surcharge_type', // unused
387
+      'surcharge_text', // unused
388 388
       'affiliate_id',
389 389
       'site_license_key',
390 390
     );
Please login to merge, or discard this patch.
core/domain/services/assets/CoreAssetManager.php 1 patch
Indentation   +544 added lines, -544 removed lines patch added patch discarded remove patch
@@ -32,570 +32,570 @@
 block discarded – undo
32 32
 class CoreAssetManager extends AssetManager
33 33
 {
34 34
 
35
-    // WordPress core / Third party JS asset handles
36
-    const JS_HANDLE_JQUERY = 'jquery';
35
+	// WordPress core / Third party JS asset handles
36
+	const JS_HANDLE_JQUERY = 'jquery';
37 37
 
38
-    const JS_HANDLE_JQUERY_VALIDATE = 'jquery-validate';
38
+	const JS_HANDLE_JQUERY_VALIDATE = 'jquery-validate';
39 39
 
40
-    const JS_HANDLE_JQUERY_VALIDATE_EXTRA = 'jquery-validate-extra-methods';
40
+	const JS_HANDLE_JQUERY_VALIDATE_EXTRA = 'jquery-validate-extra-methods';
41 41
 
42
-    const JS_HANDLE_UNDERSCORE = 'underscore';
42
+	const JS_HANDLE_UNDERSCORE = 'underscore';
43 43
 
44
-    const JS_HANDLE_ACCOUNTING_CORE = 'ee-accounting-core';
44
+	const JS_HANDLE_ACCOUNTING_CORE = 'ee-accounting-core';
45 45
 
46
-    /**
47
-     * @since 4.9.71.p
48
-     */
49
-    const JS_HANDLE_REACT = 'react';
46
+	/**
47
+	 * @since 4.9.71.p
48
+	 */
49
+	const JS_HANDLE_REACT = 'react';
50 50
 
51
-    /**
52
-     * @since 4.9.71.p
53
-     */
54
-    const JS_HANDLE_REACT_DOM = 'react-dom';
51
+	/**
52
+	 * @since 4.9.71.p
53
+	 */
54
+	const JS_HANDLE_REACT_DOM = 'react-dom';
55 55
 
56
-    /**
57
-     * @since 4.9.71.p
58
-     */
59
-    const JS_HANDLE_LODASH = 'lodash';
56
+	/**
57
+	 * @since 4.9.71.p
58
+	 */
59
+	const JS_HANDLE_LODASH = 'lodash';
60 60
 
61
-    // EE JS assets handles
62
-    const JS_HANDLE_MANIFEST = 'ee-manifest';
61
+	// EE JS assets handles
62
+	const JS_HANDLE_MANIFEST = 'ee-manifest';
63 63
 
64
-    const JS_HANDLE_JS_CORE = 'eejs-core';
64
+	const JS_HANDLE_JS_CORE = 'eejs-core';
65 65
 
66
-    const JS_HANDLE_VENDOR = 'eventespresso-vendor';
66
+	const JS_HANDLE_VENDOR = 'eventespresso-vendor';
67 67
 
68
-    const JS_HANDLE_DATA_STORES = 'eventespresso-data-stores';
68
+	const JS_HANDLE_DATA_STORES = 'eventespresso-data-stores';
69 69
 
70
-    const JS_HANDLE_HELPERS = 'eventespresso-helpers';
70
+	const JS_HANDLE_HELPERS = 'eventespresso-helpers';
71 71
 
72
-    const JS_HANDLE_MODEL = 'eventespresso-model';
72
+	const JS_HANDLE_MODEL = 'eventespresso-model';
73 73
 
74
-    const JS_HANDLE_VALUE_OBJECTS = 'eventespresso-value-objects';
74
+	const JS_HANDLE_VALUE_OBJECTS = 'eventespresso-value-objects';
75 75
 
76
-    const JS_HANDLE_HOCS = 'eventespresso-hocs';
76
+	const JS_HANDLE_HOCS = 'eventespresso-hocs';
77 77
 
78
-    const JS_HANDLE_COMPONENTS = 'eventespresso-components';
78
+	const JS_HANDLE_COMPONENTS = 'eventespresso-components';
79 79
 
80
-    const JS_HANDLE_EDITOR_HOCS = 'eventespresso-editor-hocs';
80
+	const JS_HANDLE_EDITOR_HOCS = 'eventespresso-editor-hocs';
81 81
 
82
-    const JS_HANDLE_VALIDATORS = 'eventespresso-validators';
82
+	const JS_HANDLE_VALIDATORS = 'eventespresso-validators';
83 83
 
84
-    const JS_HANDLE_CORE = 'espresso_core';
84
+	const JS_HANDLE_CORE = 'espresso_core';
85 85
 
86
-    const JS_HANDLE_I18N = 'eei18n';
86
+	const JS_HANDLE_I18N = 'eei18n';
87 87
 
88
-    const JS_HANDLE_ACCOUNTING = 'ee-accounting';
88
+	const JS_HANDLE_ACCOUNTING = 'ee-accounting';
89 89
 
90
-    const JS_HANDLE_WP_PLUGINS_PAGE = 'ee-wp-plugins-page';
91
-
92
-    // EE CSS assets handles
93
-    const CSS_HANDLE_DEFAULT = 'espresso_default';
94
-
95
-    const CSS_HANDLE_CUSTOM = 'espresso_custom_css';
96
-
97
-    const CSS_HANDLE_COMPONENTS = 'eventespresso-components';
98
-
99
-    const CSS_HANDLE_CORE_CSS_DEFAULT = 'eventespresso-core-css-default';
100
-
101
-    /**
102
-     * @var EE_Currency_Config $currency_config
103
-     */
104
-    protected $currency_config;
105
-
106
-    /**
107
-     * @var EE_Template_Config $template_config
108
-     */
109
-    protected $template_config;
110
-
111
-
112
-    /**
113
-     * CoreAssetRegister constructor.
114
-     *
115
-     * @param AssetCollection    $assets
116
-     * @param EE_Currency_Config $currency_config
117
-     * @param EE_Template_Config $template_config
118
-     * @param DomainInterface    $domain
119
-     * @param Registry           $registry
120
-     */
121
-    public function __construct(
122
-        AssetCollection $assets,
123
-        EE_Currency_Config $currency_config,
124
-        EE_Template_Config $template_config,
125
-        DomainInterface $domain,
126
-        Registry $registry
127
-    ) {
128
-        $this->currency_config = $currency_config;
129
-        $this->template_config = $template_config;
130
-        parent::__construct($domain, $assets, $registry);
131
-    }
132
-
133
-
134
-    /**
135
-     * @since 4.9.62.p
136
-     * @throws DomainException
137
-     * @throws DuplicateCollectionIdentifierException
138
-     * @throws InvalidArgumentException
139
-     * @throws InvalidDataTypeException
140
-     * @throws InvalidEntityException
141
-     * @throws InvalidInterfaceException
142
-     */
143
-    public function addAssets()
144
-    {
145
-        $this->addJavascriptFiles();
146
-        $this->addStylesheetFiles();
147
-    }
148
-
149
-
150
-    /**
151
-     * @since 4.9.62.p
152
-     * @throws DomainException
153
-     * @throws DuplicateCollectionIdentifierException
154
-     * @throws InvalidArgumentException
155
-     * @throws InvalidDataTypeException
156
-     * @throws InvalidEntityException
157
-     * @throws InvalidInterfaceException
158
-     */
159
-    public function addJavascriptFiles()
160
-    {
161
-        $this->loadCoreJs();
162
-        $this->loadJqueryValidate();
163
-        $this->loadAccountingJs();
164
-        add_action(
165
-            'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__before_script',
166
-            array($this, 'loadQtipJs')
167
-        );
168
-        $this->registerAdminAssets();
169
-    }
170
-
171
-
172
-    /**
173
-     * @since 4.9.62.p
174
-     * @throws DuplicateCollectionIdentifierException
175
-     * @throws InvalidDataTypeException
176
-     * @throws InvalidEntityException
177
-     */
178
-    public function addStylesheetFiles()
179
-    {
180
-        $this->loadCoreCss();
181
-    }
182
-
183
-
184
-    /**
185
-     * core default javascript
186
-     *
187
-     * @since 4.9.62.p
188
-     * @throws DomainException
189
-     * @throws DuplicateCollectionIdentifierException
190
-     * @throws InvalidArgumentException
191
-     * @throws InvalidDataTypeException
192
-     * @throws InvalidEntityException
193
-     * @throws InvalidInterfaceException
194
-     */
195
-    private function loadCoreJs()
196
-    {
197
-        // conditionally load third-party libraries that WP core MIGHT have.
198
-        $this->registerWpAssets();
199
-
200
-        $this->addJavascript(
201
-            CoreAssetManager::JS_HANDLE_MANIFEST,
202
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'manifest')
203
-        );
204
-
205
-        $this->addJavascript(
206
-            CoreAssetManager::JS_HANDLE_JS_CORE,
207
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'eejs'),
208
-            array(CoreAssetManager::JS_HANDLE_MANIFEST)
209
-        )
210
-        ->setHasInlineData();
211
-
212
-        $this->addJavascript(
213
-            CoreAssetManager::JS_HANDLE_VENDOR,
214
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'vendor'),
215
-            array(
216
-                CoreAssetManager::JS_HANDLE_JS_CORE,
217
-                CoreAssetManager::JS_HANDLE_REACT,
218
-                CoreAssetManager::JS_HANDLE_REACT_DOM,
219
-                CoreAssetManager::JS_HANDLE_LODASH,
220
-            )
221
-        );
222
-
223
-        $this->addJavascript(
224
-            CoreAssetManager::JS_HANDLE_VALIDATORS,
225
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'validators')
226
-        )->setRequiresTranslation();
227
-
228
-        $this->addJavascript(
229
-            CoreAssetManager::JS_HANDLE_HELPERS,
230
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'helpers'),
231
-            array(
232
-                CoreAssetManager::JS_HANDLE_VALIDATORS
233
-            )
234
-        )->setRequiresTranslation();
235
-
236
-        $this->addJavascript(
237
-            CoreAssetManager::JS_HANDLE_MODEL,
238
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'model'),
239
-            array(
240
-                CoreAssetManager::JS_HANDLE_HELPERS,
241
-                CoreAssetManager::JS_HANDLE_VALUE_OBJECTS,
242
-            )
243
-        )->setRequiresTranslation();
244
-
245
-        $this->addJavascript(
246
-            CoreAssetManager::JS_HANDLE_VALUE_OBJECTS,
247
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'valueObjects'),
248
-            array(
249
-                CoreAssetManager::JS_HANDLE_VALIDATORS,
250
-                CoreAssetManager::JS_HANDLE_HELPERS,
251
-            )
252
-        )->setRequiresTranslation();
253
-
254
-        $this->addJavascript(
255
-            CoreAssetManager::JS_HANDLE_DATA_STORES,
256
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'data-stores'),
257
-            array(
258
-                CoreAssetManager::JS_HANDLE_VENDOR,
259
-                'wp-data',
260
-                'wp-api-fetch',
261
-                CoreAssetManager::JS_HANDLE_VALUE_OBJECTS,
262
-                CoreAssetManager::JS_HANDLE_MODEL,
263
-            )
264
-        )
265
-             ->setRequiresTranslation()
266
-             ->setInlineDataCallback(
267
-                 function() {
268
-                     wp_add_inline_script(
269
-                         CoreAssetManager::JS_HANDLE_DATA_STORES,
270
-                         is_admin()
271
-                             ? 'wp.apiFetch.use( eejs.middleWares.apiFetch.capsMiddleware( eejs.middleWares.apiFetch.CONTEXT_CAPS_EDIT ) )'
272
-                             : 'wp.apiFetch.use( eejs.middleWares.apiFetch.capsMiddleware )'
273
-                     );
274
-                 }
275
-             );
276
-
277
-        $this->addJavascript(
278
-            CoreAssetManager::JS_HANDLE_HOCS,
279
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'hocs'),
280
-            array(
281
-                CoreAssetManager::JS_HANDLE_DATA_STORES,
282
-                CoreAssetManager::JS_HANDLE_VALUE_OBJECTS,
283
-                'wp-components',
284
-            )
285
-        )->setRequiresTranslation();
286
-
287
-        $this->addJavascript(
288
-            CoreAssetManager::JS_HANDLE_COMPONENTS,
289
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'components'),
290
-            array(
291
-                CoreAssetManager::JS_HANDLE_DATA_STORES,
292
-                CoreAssetManager::JS_HANDLE_VALUE_OBJECTS,
293
-                'wp-components',
294
-            )
295
-        )
296
-        ->setRequiresTranslation();
297
-
298
-        $this->addJavascript(
299
-            CoreAssetManager::JS_HANDLE_EDITOR_HOCS,
300
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'editor-hocs'),
301
-            array(
302
-                CoreAssetManager::JS_HANDLE_COMPONENTS
303
-            )
304
-        )->setRequiresTranslation();
305
-
306
-        $this->registry->addData('eejs_api_nonce', wp_create_nonce('wp_rest'));
307
-        $this->registry->addData(
308
-            'paths',
309
-            array(
310
-                'base_rest_route' => rest_url(),
311
-                'rest_route' => rest_url('ee/v4.8.36/'),
312
-                'collection_endpoints' => EED_Core_Rest_Api::getCollectionRoutesIndexedByModelName(),
313
-                'primary_keys' => EED_Core_Rest_Api::getPrimaryKeyNamesIndexedByModelName(),
314
-                'site_url' => site_url('/'),
315
-                'admin_url' => admin_url('/'),
316
-            )
317
-        );
318
-        // Event Espresso brand name
319
-        $this->registry->addData('brandName', Domain::brandName());
320
-        /** site formatting values **/
321
-        $this->registry->addData(
322
-            'site_formats',
323
-            array(
324
-                'date_formats' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats()
325
-            )
326
-        );
327
-        /** currency data **/
328
-        $this->registry->addData(
329
-            'currency_config',
330
-            $this->getCurrencySettings()
331
-        );
332
-        /** site timezone */
333
-        $this->registry->addData(
334
-            'default_timezone',
335
-            array(
336
-                'pretty' => EEH_DTT_Helper::get_timezone_string_for_display(),
337
-                'string' => get_option('timezone_string'),
338
-                'offset' => EEH_DTT_Helper::get_site_timezone_gmt_offset(),
339
-            )
340
-        );
341
-        /** site locale (user locale if user logged in) */
342
-        $this->registry->addData(
343
-            'locale',
344
-            array(
345
-                'user' => get_user_locale(),
346
-                'site' => get_locale()
347
-            )
348
-        );
349
-
350
-        $this->addJavascript(
351
-            CoreAssetManager::JS_HANDLE_CORE,
352
-            EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
353
-            array(CoreAssetManager::JS_HANDLE_JQUERY)
354
-        )
355
-        ->setInlineDataCallback(
356
-            function () {
357
-                wp_localize_script(
358
-                    CoreAssetManager::JS_HANDLE_CORE,
359
-                    CoreAssetManager::JS_HANDLE_I18N,
360
-                    EE_Registry::$i18n_js_strings
361
-                );
362
-            }
363
-        );
364
-    }
365
-
366
-
367
-    /**
368
-     * Registers vendor files that are bundled with a later version WP but might not be for the current version of
369
-     * WordPress in the running environment.
370
-     *
371
-     * @throws DuplicateCollectionIdentifierException
372
-     * @throws InvalidDataTypeException
373
-     * @throws InvalidEntityException
374
-     * @throws DomainException
375
-     * @since 4.9.71.p
376
-     */
377
-    private function registerWpAssets()
378
-    {
379
-        global $wp_version;
380
-        if (version_compare($wp_version, '5.0.beta', '>=')) {
381
-            return;
382
-        }
383
-        $this->addVendorJavascript(CoreAssetManager::JS_HANDLE_REACT)
384
-            ->setVersion('16.6.0');
385
-        $this->addVendorJavascript(
386
-            CoreAssetManager::JS_HANDLE_REACT_DOM,
387
-            array(CoreAssetManager::JS_HANDLE_REACT)
388
-        )->setVersion('16.6.0');
389
-        $this->addVendorJavascript(CoreAssetManager::JS_HANDLE_LODASH)
390
-            ->setInlineDataCallback(
391
-                function() {
392
-                    wp_add_inline_script(
393
-                        CoreAssetManager::JS_HANDLE_LODASH,
394
-                        'window.lodash = _.noConflict();'
395
-                    );
396
-                }
397
-            )
398
-            ->setVersion('4.17.11');
399
-    }
400
-
401
-
402
-    /**
403
-     * Returns configuration data for the accounting-js library.
404
-     * @since 4.9.71.p
405
-     * @return array
406
-     */
407
-    private function getAccountingSettings() {
408
-        return array(
409
-            'currency' => array(
410
-                'symbol'    => $this->currency_config->sign,
411
-                'format'    => array(
412
-                    'pos'  => $this->currency_config->sign_b4 ? '%s%v' : '%v%s',
413
-                    'neg'  => $this->currency_config->sign_b4 ? '- %s%v' : '- %v%s',
414
-                    'zero' => $this->currency_config->sign_b4 ? '%s--' : '--%s',
415
-                ),
416
-                'decimal'   => $this->currency_config->dec_mrk,
417
-                'thousand'  => $this->currency_config->thsnds,
418
-                'precision' => $this->currency_config->dec_plc,
419
-            ),
420
-            'number'   => array(
421
-                'precision' => $this->currency_config->dec_plc,
422
-                'thousand'  => $this->currency_config->thsnds,
423
-                'decimal'   => $this->currency_config->dec_mrk,
424
-            ),
425
-        );
426
-    }
427
-
428
-
429
-    /**
430
-     * Returns configuration data for the js Currency VO.
431
-     * @since 4.9.71.p
432
-     * @return array
433
-     */
434
-    private function getCurrencySettings()
435
-    {
436
-        return array(
437
-            'code' => $this->currency_config->code,
438
-            'singularLabel' => $this->currency_config->name,
439
-            'pluralLabel' => $this->currency_config->plural,
440
-            'sign' => $this->currency_config->sign,
441
-            'signB4' => $this->currency_config->sign_b4,
442
-            'decimalPlaces' => $this->currency_config->dec_plc,
443
-            'decimalMark' => $this->currency_config->dec_mrk,
444
-            'thousandsSeparator' => $this->currency_config->thsnds,
445
-        );
446
-    }
447
-
448
-
449
-    /**
450
-     * @since 4.9.62.p
451
-     * @throws DuplicateCollectionIdentifierException
452
-     * @throws InvalidDataTypeException
453
-     * @throws InvalidEntityException
454
-     */
455
-    private function loadCoreCss()
456
-    {
457
-        if ($this->template_config->enable_default_style && ! is_admin()) {
458
-            $this->addStylesheet(
459
-                CoreAssetManager::CSS_HANDLE_DEFAULT,
460
-                is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')
461
-                    ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css'
462
-                    : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css',
463
-                array('dashicons')
464
-            );
465
-            //Load custom style sheet if available
466
-            if ($this->template_config->custom_style_sheet !== null) {
467
-                $this->addStylesheet(
468
-                    CoreAssetManager::CSS_HANDLE_CUSTOM,
469
-                    EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet,
470
-                    array(CoreAssetManager::CSS_HANDLE_DEFAULT)
471
-                );
472
-            }
473
-        }
474
-        $this->addStylesheet(
475
-            CoreAssetManager::CSS_HANDLE_CORE_CSS_DEFAULT,
476
-            $this->registry->getCssUrl(
477
-                $this->domain->assetNamespace(),
478
-                'core-default-theme'
479
-            ),
480
-            ['dashicons']
481
-        );
482
-        $this->addStylesheet(
483
-            CoreAssetManager::CSS_HANDLE_COMPONENTS,
484
-            $this->registry->getCssUrl(
485
-                $this->domain->assetNamespace(),
486
-                'components'
487
-            ),
488
-            [CoreAssetManager::CSS_HANDLE_CORE_CSS_DEFAULT]
489
-        );
490
-    }
491
-
492
-
493
-    /**
494
-     * jQuery Validate for form validation
495
-     *
496
-     * @since 4.9.62.p
497
-     * @throws DomainException
498
-     * @throws DuplicateCollectionIdentifierException
499
-     * @throws InvalidDataTypeException
500
-     * @throws InvalidEntityException
501
-     */
502
-    private function loadJqueryValidate()
503
-    {
504
-        $this->addJavascript(
505
-            CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE,
506
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js',
507
-            array(CoreAssetManager::JS_HANDLE_JQUERY)
508
-        )
509
-        ->setVersion('1.15.0');
510
-
511
-        $this->addJavascript(
512
-            CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE_EXTRA,
513
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js',
514
-            array(CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE)
515
-        )
516
-        ->setVersion('1.15.0');
517
-    }
518
-
519
-
520
-    /**
521
-     * accounting.js for performing client-side calculations
522
-     *
523
-     * @since 4.9.62.p
524
-     * @throws DomainException
525
-     * @throws DuplicateCollectionIdentifierException
526
-     * @throws InvalidDataTypeException
527
-     * @throws InvalidEntityException
528
-     */
529
-    private function loadAccountingJs()
530
-    {
531
-        //accounting.js library
532
-        // @link http://josscrowcroft.github.io/accounting.js/
533
-        $this->addJavascript(
534
-            CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE,
535
-            EE_THIRD_PARTY_URL . 'accounting/accounting.js',
536
-            array(CoreAssetManager::JS_HANDLE_UNDERSCORE)
537
-        )
538
-        ->setVersion('0.3.2');
539
-
540
-        $this->addJavascript(
541
-            CoreAssetManager::JS_HANDLE_ACCOUNTING,
542
-            EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js',
543
-            array(CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE)
544
-        )
545
-        ->setInlineDataCallback(
546
-            function () {
547
-                 wp_localize_script(
548
-                     CoreAssetManager::JS_HANDLE_ACCOUNTING,
549
-                     'EE_ACCOUNTING_CFG',
550
-                     $this->getAccountingSettings()
551
-                 );
552
-            }
553
-        )
554
-        ->setVersion();
555
-    }
556
-
557
-
558
-    /**
559
-     * registers assets for cleaning your ears
560
-     *
561
-     * @param JavascriptAsset $script
562
-     */
563
-    public function loadQtipJs(JavascriptAsset $script)
564
-    {
565
-        // qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook,
566
-        // can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' );
567
-        if (
568
-            $script->handle() === CoreAssetManager::JS_HANDLE_WP_PLUGINS_PAGE
569
-            && apply_filters('FHEE_load_qtip', false)
570
-        ) {
571
-            EEH_Qtip_Loader::instance()->register_and_enqueue();
572
-        }
573
-    }
574
-
575
-
576
-    /**
577
-     * assets that are used in the WordPress admin
578
-     *
579
-     * @since 4.9.62.p
580
-     * @throws DuplicateCollectionIdentifierException
581
-     * @throws InvalidDataTypeException
582
-     * @throws InvalidEntityException
583
-     */
584
-    private function registerAdminAssets()
585
-    {
586
-        $this->addJavascript(
587
-            CoreAssetManager::JS_HANDLE_WP_PLUGINS_PAGE,
588
-            $this->registry->getJsUrl($this->domain->assetNamespace(), 'wp-plugins-page'),
589
-            array(
590
-                CoreAssetManager::JS_HANDLE_JQUERY,
591
-                CoreAssetManager::JS_HANDLE_VENDOR,
592
-            )
593
-        )
594
-        ->setRequiresTranslation();
595
-
596
-        $this->addStylesheet(
597
-            CoreAssetManager::JS_HANDLE_WP_PLUGINS_PAGE,
598
-            $this->registry->getCssUrl($this->domain->assetNamespace(), 'wp-plugins-page')
599
-        );
600
-    }
90
+	const JS_HANDLE_WP_PLUGINS_PAGE = 'ee-wp-plugins-page';
91
+
92
+	// EE CSS assets handles
93
+	const CSS_HANDLE_DEFAULT = 'espresso_default';
94
+
95
+	const CSS_HANDLE_CUSTOM = 'espresso_custom_css';
96
+
97
+	const CSS_HANDLE_COMPONENTS = 'eventespresso-components';
98
+
99
+	const CSS_HANDLE_CORE_CSS_DEFAULT = 'eventespresso-core-css-default';
100
+
101
+	/**
102
+	 * @var EE_Currency_Config $currency_config
103
+	 */
104
+	protected $currency_config;
105
+
106
+	/**
107
+	 * @var EE_Template_Config $template_config
108
+	 */
109
+	protected $template_config;
110
+
111
+
112
+	/**
113
+	 * CoreAssetRegister constructor.
114
+	 *
115
+	 * @param AssetCollection    $assets
116
+	 * @param EE_Currency_Config $currency_config
117
+	 * @param EE_Template_Config $template_config
118
+	 * @param DomainInterface    $domain
119
+	 * @param Registry           $registry
120
+	 */
121
+	public function __construct(
122
+		AssetCollection $assets,
123
+		EE_Currency_Config $currency_config,
124
+		EE_Template_Config $template_config,
125
+		DomainInterface $domain,
126
+		Registry $registry
127
+	) {
128
+		$this->currency_config = $currency_config;
129
+		$this->template_config = $template_config;
130
+		parent::__construct($domain, $assets, $registry);
131
+	}
132
+
133
+
134
+	/**
135
+	 * @since 4.9.62.p
136
+	 * @throws DomainException
137
+	 * @throws DuplicateCollectionIdentifierException
138
+	 * @throws InvalidArgumentException
139
+	 * @throws InvalidDataTypeException
140
+	 * @throws InvalidEntityException
141
+	 * @throws InvalidInterfaceException
142
+	 */
143
+	public function addAssets()
144
+	{
145
+		$this->addJavascriptFiles();
146
+		$this->addStylesheetFiles();
147
+	}
148
+
149
+
150
+	/**
151
+	 * @since 4.9.62.p
152
+	 * @throws DomainException
153
+	 * @throws DuplicateCollectionIdentifierException
154
+	 * @throws InvalidArgumentException
155
+	 * @throws InvalidDataTypeException
156
+	 * @throws InvalidEntityException
157
+	 * @throws InvalidInterfaceException
158
+	 */
159
+	public function addJavascriptFiles()
160
+	{
161
+		$this->loadCoreJs();
162
+		$this->loadJqueryValidate();
163
+		$this->loadAccountingJs();
164
+		add_action(
165
+			'AHEE__EventEspresso_core_services_assets_Registry__registerScripts__before_script',
166
+			array($this, 'loadQtipJs')
167
+		);
168
+		$this->registerAdminAssets();
169
+	}
170
+
171
+
172
+	/**
173
+	 * @since 4.9.62.p
174
+	 * @throws DuplicateCollectionIdentifierException
175
+	 * @throws InvalidDataTypeException
176
+	 * @throws InvalidEntityException
177
+	 */
178
+	public function addStylesheetFiles()
179
+	{
180
+		$this->loadCoreCss();
181
+	}
182
+
183
+
184
+	/**
185
+	 * core default javascript
186
+	 *
187
+	 * @since 4.9.62.p
188
+	 * @throws DomainException
189
+	 * @throws DuplicateCollectionIdentifierException
190
+	 * @throws InvalidArgumentException
191
+	 * @throws InvalidDataTypeException
192
+	 * @throws InvalidEntityException
193
+	 * @throws InvalidInterfaceException
194
+	 */
195
+	private function loadCoreJs()
196
+	{
197
+		// conditionally load third-party libraries that WP core MIGHT have.
198
+		$this->registerWpAssets();
199
+
200
+		$this->addJavascript(
201
+			CoreAssetManager::JS_HANDLE_MANIFEST,
202
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'manifest')
203
+		);
204
+
205
+		$this->addJavascript(
206
+			CoreAssetManager::JS_HANDLE_JS_CORE,
207
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'eejs'),
208
+			array(CoreAssetManager::JS_HANDLE_MANIFEST)
209
+		)
210
+		->setHasInlineData();
211
+
212
+		$this->addJavascript(
213
+			CoreAssetManager::JS_HANDLE_VENDOR,
214
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'vendor'),
215
+			array(
216
+				CoreAssetManager::JS_HANDLE_JS_CORE,
217
+				CoreAssetManager::JS_HANDLE_REACT,
218
+				CoreAssetManager::JS_HANDLE_REACT_DOM,
219
+				CoreAssetManager::JS_HANDLE_LODASH,
220
+			)
221
+		);
222
+
223
+		$this->addJavascript(
224
+			CoreAssetManager::JS_HANDLE_VALIDATORS,
225
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'validators')
226
+		)->setRequiresTranslation();
227
+
228
+		$this->addJavascript(
229
+			CoreAssetManager::JS_HANDLE_HELPERS,
230
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'helpers'),
231
+			array(
232
+				CoreAssetManager::JS_HANDLE_VALIDATORS
233
+			)
234
+		)->setRequiresTranslation();
235
+
236
+		$this->addJavascript(
237
+			CoreAssetManager::JS_HANDLE_MODEL,
238
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'model'),
239
+			array(
240
+				CoreAssetManager::JS_HANDLE_HELPERS,
241
+				CoreAssetManager::JS_HANDLE_VALUE_OBJECTS,
242
+			)
243
+		)->setRequiresTranslation();
244
+
245
+		$this->addJavascript(
246
+			CoreAssetManager::JS_HANDLE_VALUE_OBJECTS,
247
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'valueObjects'),
248
+			array(
249
+				CoreAssetManager::JS_HANDLE_VALIDATORS,
250
+				CoreAssetManager::JS_HANDLE_HELPERS,
251
+			)
252
+		)->setRequiresTranslation();
253
+
254
+		$this->addJavascript(
255
+			CoreAssetManager::JS_HANDLE_DATA_STORES,
256
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'data-stores'),
257
+			array(
258
+				CoreAssetManager::JS_HANDLE_VENDOR,
259
+				'wp-data',
260
+				'wp-api-fetch',
261
+				CoreAssetManager::JS_HANDLE_VALUE_OBJECTS,
262
+				CoreAssetManager::JS_HANDLE_MODEL,
263
+			)
264
+		)
265
+			 ->setRequiresTranslation()
266
+			 ->setInlineDataCallback(
267
+				 function() {
268
+					 wp_add_inline_script(
269
+						 CoreAssetManager::JS_HANDLE_DATA_STORES,
270
+						 is_admin()
271
+							 ? 'wp.apiFetch.use( eejs.middleWares.apiFetch.capsMiddleware( eejs.middleWares.apiFetch.CONTEXT_CAPS_EDIT ) )'
272
+							 : 'wp.apiFetch.use( eejs.middleWares.apiFetch.capsMiddleware )'
273
+					 );
274
+				 }
275
+			 );
276
+
277
+		$this->addJavascript(
278
+			CoreAssetManager::JS_HANDLE_HOCS,
279
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'hocs'),
280
+			array(
281
+				CoreAssetManager::JS_HANDLE_DATA_STORES,
282
+				CoreAssetManager::JS_HANDLE_VALUE_OBJECTS,
283
+				'wp-components',
284
+			)
285
+		)->setRequiresTranslation();
286
+
287
+		$this->addJavascript(
288
+			CoreAssetManager::JS_HANDLE_COMPONENTS,
289
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'components'),
290
+			array(
291
+				CoreAssetManager::JS_HANDLE_DATA_STORES,
292
+				CoreAssetManager::JS_HANDLE_VALUE_OBJECTS,
293
+				'wp-components',
294
+			)
295
+		)
296
+		->setRequiresTranslation();
297
+
298
+		$this->addJavascript(
299
+			CoreAssetManager::JS_HANDLE_EDITOR_HOCS,
300
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'editor-hocs'),
301
+			array(
302
+				CoreAssetManager::JS_HANDLE_COMPONENTS
303
+			)
304
+		)->setRequiresTranslation();
305
+
306
+		$this->registry->addData('eejs_api_nonce', wp_create_nonce('wp_rest'));
307
+		$this->registry->addData(
308
+			'paths',
309
+			array(
310
+				'base_rest_route' => rest_url(),
311
+				'rest_route' => rest_url('ee/v4.8.36/'),
312
+				'collection_endpoints' => EED_Core_Rest_Api::getCollectionRoutesIndexedByModelName(),
313
+				'primary_keys' => EED_Core_Rest_Api::getPrimaryKeyNamesIndexedByModelName(),
314
+				'site_url' => site_url('/'),
315
+				'admin_url' => admin_url('/'),
316
+			)
317
+		);
318
+		// Event Espresso brand name
319
+		$this->registry->addData('brandName', Domain::brandName());
320
+		/** site formatting values **/
321
+		$this->registry->addData(
322
+			'site_formats',
323
+			array(
324
+				'date_formats' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats()
325
+			)
326
+		);
327
+		/** currency data **/
328
+		$this->registry->addData(
329
+			'currency_config',
330
+			$this->getCurrencySettings()
331
+		);
332
+		/** site timezone */
333
+		$this->registry->addData(
334
+			'default_timezone',
335
+			array(
336
+				'pretty' => EEH_DTT_Helper::get_timezone_string_for_display(),
337
+				'string' => get_option('timezone_string'),
338
+				'offset' => EEH_DTT_Helper::get_site_timezone_gmt_offset(),
339
+			)
340
+		);
341
+		/** site locale (user locale if user logged in) */
342
+		$this->registry->addData(
343
+			'locale',
344
+			array(
345
+				'user' => get_user_locale(),
346
+				'site' => get_locale()
347
+			)
348
+		);
349
+
350
+		$this->addJavascript(
351
+			CoreAssetManager::JS_HANDLE_CORE,
352
+			EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
353
+			array(CoreAssetManager::JS_HANDLE_JQUERY)
354
+		)
355
+		->setInlineDataCallback(
356
+			function () {
357
+				wp_localize_script(
358
+					CoreAssetManager::JS_HANDLE_CORE,
359
+					CoreAssetManager::JS_HANDLE_I18N,
360
+					EE_Registry::$i18n_js_strings
361
+				);
362
+			}
363
+		);
364
+	}
365
+
366
+
367
+	/**
368
+	 * Registers vendor files that are bundled with a later version WP but might not be for the current version of
369
+	 * WordPress in the running environment.
370
+	 *
371
+	 * @throws DuplicateCollectionIdentifierException
372
+	 * @throws InvalidDataTypeException
373
+	 * @throws InvalidEntityException
374
+	 * @throws DomainException
375
+	 * @since 4.9.71.p
376
+	 */
377
+	private function registerWpAssets()
378
+	{
379
+		global $wp_version;
380
+		if (version_compare($wp_version, '5.0.beta', '>=')) {
381
+			return;
382
+		}
383
+		$this->addVendorJavascript(CoreAssetManager::JS_HANDLE_REACT)
384
+			->setVersion('16.6.0');
385
+		$this->addVendorJavascript(
386
+			CoreAssetManager::JS_HANDLE_REACT_DOM,
387
+			array(CoreAssetManager::JS_HANDLE_REACT)
388
+		)->setVersion('16.6.0');
389
+		$this->addVendorJavascript(CoreAssetManager::JS_HANDLE_LODASH)
390
+			->setInlineDataCallback(
391
+				function() {
392
+					wp_add_inline_script(
393
+						CoreAssetManager::JS_HANDLE_LODASH,
394
+						'window.lodash = _.noConflict();'
395
+					);
396
+				}
397
+			)
398
+			->setVersion('4.17.11');
399
+	}
400
+
401
+
402
+	/**
403
+	 * Returns configuration data for the accounting-js library.
404
+	 * @since 4.9.71.p
405
+	 * @return array
406
+	 */
407
+	private function getAccountingSettings() {
408
+		return array(
409
+			'currency' => array(
410
+				'symbol'    => $this->currency_config->sign,
411
+				'format'    => array(
412
+					'pos'  => $this->currency_config->sign_b4 ? '%s%v' : '%v%s',
413
+					'neg'  => $this->currency_config->sign_b4 ? '- %s%v' : '- %v%s',
414
+					'zero' => $this->currency_config->sign_b4 ? '%s--' : '--%s',
415
+				),
416
+				'decimal'   => $this->currency_config->dec_mrk,
417
+				'thousand'  => $this->currency_config->thsnds,
418
+				'precision' => $this->currency_config->dec_plc,
419
+			),
420
+			'number'   => array(
421
+				'precision' => $this->currency_config->dec_plc,
422
+				'thousand'  => $this->currency_config->thsnds,
423
+				'decimal'   => $this->currency_config->dec_mrk,
424
+			),
425
+		);
426
+	}
427
+
428
+
429
+	/**
430
+	 * Returns configuration data for the js Currency VO.
431
+	 * @since 4.9.71.p
432
+	 * @return array
433
+	 */
434
+	private function getCurrencySettings()
435
+	{
436
+		return array(
437
+			'code' => $this->currency_config->code,
438
+			'singularLabel' => $this->currency_config->name,
439
+			'pluralLabel' => $this->currency_config->plural,
440
+			'sign' => $this->currency_config->sign,
441
+			'signB4' => $this->currency_config->sign_b4,
442
+			'decimalPlaces' => $this->currency_config->dec_plc,
443
+			'decimalMark' => $this->currency_config->dec_mrk,
444
+			'thousandsSeparator' => $this->currency_config->thsnds,
445
+		);
446
+	}
447
+
448
+
449
+	/**
450
+	 * @since 4.9.62.p
451
+	 * @throws DuplicateCollectionIdentifierException
452
+	 * @throws InvalidDataTypeException
453
+	 * @throws InvalidEntityException
454
+	 */
455
+	private function loadCoreCss()
456
+	{
457
+		if ($this->template_config->enable_default_style && ! is_admin()) {
458
+			$this->addStylesheet(
459
+				CoreAssetManager::CSS_HANDLE_DEFAULT,
460
+				is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')
461
+					? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css'
462
+					: EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css',
463
+				array('dashicons')
464
+			);
465
+			//Load custom style sheet if available
466
+			if ($this->template_config->custom_style_sheet !== null) {
467
+				$this->addStylesheet(
468
+					CoreAssetManager::CSS_HANDLE_CUSTOM,
469
+					EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet,
470
+					array(CoreAssetManager::CSS_HANDLE_DEFAULT)
471
+				);
472
+			}
473
+		}
474
+		$this->addStylesheet(
475
+			CoreAssetManager::CSS_HANDLE_CORE_CSS_DEFAULT,
476
+			$this->registry->getCssUrl(
477
+				$this->domain->assetNamespace(),
478
+				'core-default-theme'
479
+			),
480
+			['dashicons']
481
+		);
482
+		$this->addStylesheet(
483
+			CoreAssetManager::CSS_HANDLE_COMPONENTS,
484
+			$this->registry->getCssUrl(
485
+				$this->domain->assetNamespace(),
486
+				'components'
487
+			),
488
+			[CoreAssetManager::CSS_HANDLE_CORE_CSS_DEFAULT]
489
+		);
490
+	}
491
+
492
+
493
+	/**
494
+	 * jQuery Validate for form validation
495
+	 *
496
+	 * @since 4.9.62.p
497
+	 * @throws DomainException
498
+	 * @throws DuplicateCollectionIdentifierException
499
+	 * @throws InvalidDataTypeException
500
+	 * @throws InvalidEntityException
501
+	 */
502
+	private function loadJqueryValidate()
503
+	{
504
+		$this->addJavascript(
505
+			CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE,
506
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js',
507
+			array(CoreAssetManager::JS_HANDLE_JQUERY)
508
+		)
509
+		->setVersion('1.15.0');
510
+
511
+		$this->addJavascript(
512
+			CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE_EXTRA,
513
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js',
514
+			array(CoreAssetManager::JS_HANDLE_JQUERY_VALIDATE)
515
+		)
516
+		->setVersion('1.15.0');
517
+	}
518
+
519
+
520
+	/**
521
+	 * accounting.js for performing client-side calculations
522
+	 *
523
+	 * @since 4.9.62.p
524
+	 * @throws DomainException
525
+	 * @throws DuplicateCollectionIdentifierException
526
+	 * @throws InvalidDataTypeException
527
+	 * @throws InvalidEntityException
528
+	 */
529
+	private function loadAccountingJs()
530
+	{
531
+		//accounting.js library
532
+		// @link http://josscrowcroft.github.io/accounting.js/
533
+		$this->addJavascript(
534
+			CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE,
535
+			EE_THIRD_PARTY_URL . 'accounting/accounting.js',
536
+			array(CoreAssetManager::JS_HANDLE_UNDERSCORE)
537
+		)
538
+		->setVersion('0.3.2');
539
+
540
+		$this->addJavascript(
541
+			CoreAssetManager::JS_HANDLE_ACCOUNTING,
542
+			EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js',
543
+			array(CoreAssetManager::JS_HANDLE_ACCOUNTING_CORE)
544
+		)
545
+		->setInlineDataCallback(
546
+			function () {
547
+				 wp_localize_script(
548
+					 CoreAssetManager::JS_HANDLE_ACCOUNTING,
549
+					 'EE_ACCOUNTING_CFG',
550
+					 $this->getAccountingSettings()
551
+				 );
552
+			}
553
+		)
554
+		->setVersion();
555
+	}
556
+
557
+
558
+	/**
559
+	 * registers assets for cleaning your ears
560
+	 *
561
+	 * @param JavascriptAsset $script
562
+	 */
563
+	public function loadQtipJs(JavascriptAsset $script)
564
+	{
565
+		// qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook,
566
+		// can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' );
567
+		if (
568
+			$script->handle() === CoreAssetManager::JS_HANDLE_WP_PLUGINS_PAGE
569
+			&& apply_filters('FHEE_load_qtip', false)
570
+		) {
571
+			EEH_Qtip_Loader::instance()->register_and_enqueue();
572
+		}
573
+	}
574
+
575
+
576
+	/**
577
+	 * assets that are used in the WordPress admin
578
+	 *
579
+	 * @since 4.9.62.p
580
+	 * @throws DuplicateCollectionIdentifierException
581
+	 * @throws InvalidDataTypeException
582
+	 * @throws InvalidEntityException
583
+	 */
584
+	private function registerAdminAssets()
585
+	{
586
+		$this->addJavascript(
587
+			CoreAssetManager::JS_HANDLE_WP_PLUGINS_PAGE,
588
+			$this->registry->getJsUrl($this->domain->assetNamespace(), 'wp-plugins-page'),
589
+			array(
590
+				CoreAssetManager::JS_HANDLE_JQUERY,
591
+				CoreAssetManager::JS_HANDLE_VENDOR,
592
+			)
593
+		)
594
+		->setRequiresTranslation();
595
+
596
+		$this->addStylesheet(
597
+			CoreAssetManager::JS_HANDLE_WP_PLUGINS_PAGE,
598
+			$this->registry->getCssUrl($this->domain->assetNamespace(), 'wp-plugins-page')
599
+		);
600
+	}
601 601
 }
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.81.rc.020');
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.81.rc.020');
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.
registrations/form_sections/EE_Registration_Custom_Questions_Form.form.php 2 patches
Indentation   +155 added lines, -155 removed lines patch added patch discarded remove patch
@@ -15,173 +15,173 @@
 block discarded – undo
15 15
  */
16 16
 class EE_Registration_Custom_Questions_Form extends EE_Form_Section_Proper
17 17
 {
18
-    /**
19
-     *
20
-     * @var EE_Registration
21
-     */
22
-    protected $_registration = null;
18
+	/**
19
+	 *
20
+	 * @var EE_Registration
21
+	 */
22
+	protected $_registration = null;
23 23
 
24
-    /**
25
-     *
26
-     * @param EE_Registration $reg
27
-     * @param array $options
28
-     */
29
-    public function __construct(EE_Registration $reg, $options = array())
30
-    {
31
-        $this->_registration = $reg;
32
-        if (! isset($options['layout_strategy'])) {
33
-            $options['layout_strategy'] = new EE_Admin_Two_Column_Layout();
34
-        }
35
-        if (! isset($options['html_id'])) {
36
-            $options['html_id'] = 'reg-admin-attendee-questions-frm';
37
-        }
38
-        $this->build_form_from_registration();
39
-        parent::__construct($options);
40
-    }
24
+	/**
25
+	 *
26
+	 * @param EE_Registration $reg
27
+	 * @param array $options
28
+	 */
29
+	public function __construct(EE_Registration $reg, $options = array())
30
+	{
31
+		$this->_registration = $reg;
32
+		if (! isset($options['layout_strategy'])) {
33
+			$options['layout_strategy'] = new EE_Admin_Two_Column_Layout();
34
+		}
35
+		if (! isset($options['html_id'])) {
36
+			$options['html_id'] = 'reg-admin-attendee-questions-frm';
37
+		}
38
+		$this->build_form_from_registration();
39
+		parent::__construct($options);
40
+	}
41 41
 
42 42
 
43
-    /**
44
-     * Gets the registration object this form is about
45
-     * @return EE_Registration
46
-     */
47
-    public function get_registration()
48
-    {
49
-        return $this->_registration;
50
-    }
43
+	/**
44
+	 * Gets the registration object this form is about
45
+	 * @return EE_Registration
46
+	 */
47
+	public function get_registration()
48
+	{
49
+		return $this->_registration;
50
+	}
51 51
 
52
-    public function build_form_from_registration()
53
-    {
54
-        $reg = $this->get_registration();
55
-        if (! $reg instanceof EE_Registration) {
56
-            throw new EE_Error(__('We cannot build the registration custom questions form because there is no registration set on it yet', 'event_espresso'));
57
-        }
58
-        // we want to get all their question groups
59
-        $question_groups = EEM_Question_Group::instance()->get_all(
60
-            array(
61
-                array(
62
-                    'Event_Question_Group.EVT_ID' => $reg->event_ID(),
63
-                    'Event_Question_Group.EQG_primary' => $reg->count() == 1 ? true : false,
64
-                    'OR' => array(
65
-                        'Question.QST_system*blank' =>  '',
66
-                        'Question.QST_system*null' => array( 'IS_NULL' )
67
-                    )
68
-                ),
69
-                'order_by' => array( 'QSG_order' => 'ASC' )
70
-            )
71
-        );
72
-        // get each question groups questions
73
-        foreach ($question_groups as $question_group) {
74
-            if ($question_group instanceof EE_Question_Group) {
75
-                $this->_subsections[ $question_group->ID() ] = $this->build_subform_from_question_group(
76
-                    $question_group,
77
-                    $reg
78
-                );
79
-            }
80
-        }
81
-    }
52
+	public function build_form_from_registration()
53
+	{
54
+		$reg = $this->get_registration();
55
+		if (! $reg instanceof EE_Registration) {
56
+			throw new EE_Error(__('We cannot build the registration custom questions form because there is no registration set on it yet', 'event_espresso'));
57
+		}
58
+		// we want to get all their question groups
59
+		$question_groups = EEM_Question_Group::instance()->get_all(
60
+			array(
61
+				array(
62
+					'Event_Question_Group.EVT_ID' => $reg->event_ID(),
63
+					'Event_Question_Group.EQG_primary' => $reg->count() == 1 ? true : false,
64
+					'OR' => array(
65
+						'Question.QST_system*blank' =>  '',
66
+						'Question.QST_system*null' => array( 'IS_NULL' )
67
+					)
68
+				),
69
+				'order_by' => array( 'QSG_order' => 'ASC' )
70
+			)
71
+		);
72
+		// get each question groups questions
73
+		foreach ($question_groups as $question_group) {
74
+			if ($question_group instanceof EE_Question_Group) {
75
+				$this->_subsections[ $question_group->ID() ] = $this->build_subform_from_question_group(
76
+					$question_group,
77
+					$reg
78
+				);
79
+			}
80
+		}
81
+	}
82 82
 
83 83
 
84 84
 
85
-    /**
86
-     *
87
-     * @param EE_Question_Group $question_group
88
-     * @param EE_Registration   $registration
89
-     * @return \EE_Form_Section_Proper
90
-     * @throws \EE_Error
91
-     */
92
-    public function build_subform_from_question_group($question_group, $registration)
93
-    {
94
-        if (! $question_group instanceof EE_Question_Group ||
95
-            ! $registration instanceof EE_Registration) {
96
-            throw new EE_Error(__('A valid question group and registration must be passed to EE_Registration_Custom_Question_Form', 'event_espresso'));
97
-        }
98
-        $parts_of_subsection = array(
99
-            'title' => new EE_Form_Section_HTML(
100
-                EEH_HTML::h5(
101
-                    $question_group->name(),
102
-                    $question_group->identifier(),
103
-                    'espresso-question-group-title-h5 section-title'
104
-                )
105
-            )
106
-        );
107
-        $questions = $question_group->questions(
108
-            array(
109
-                array(
110
-                    'OR' => array(
111
-                        'QST_system*blank' => '',
112
-                        'QST_system*null' => array( 'IS_NULL' )
113
-                    )
114
-                )
115
-            )
116
-        );
117
-        foreach ($questions as $question) {
118
-            $parts_of_subsection[ $question->ID() ] = $question->generate_form_input($registration);
119
-        }
120
-        if (EE_Registry::instance()->CAP->current_user_can(
121
-            'ee_edit_registration',
122
-            'edit-reg-questions-mbox',
123
-            $this->_registration->ID()
124
-        )) {
125
-            $parts_of_subsection['edit_link'] = new EE_Form_Section_HTML(
126
-                EEH_HTML::table(
127
-                    EEH_HTML::tr(
128
-                        '<th/><td class="reg-admin-edit-attendee-question-td"><a class="reg-admin-edit-attendee-question-lnk" href="#" aria-label="' . esc_attr__('click to edit question', 'event_espresso') . '">
85
+	/**
86
+	 *
87
+	 * @param EE_Question_Group $question_group
88
+	 * @param EE_Registration   $registration
89
+	 * @return \EE_Form_Section_Proper
90
+	 * @throws \EE_Error
91
+	 */
92
+	public function build_subform_from_question_group($question_group, $registration)
93
+	{
94
+		if (! $question_group instanceof EE_Question_Group ||
95
+			! $registration instanceof EE_Registration) {
96
+			throw new EE_Error(__('A valid question group and registration must be passed to EE_Registration_Custom_Question_Form', 'event_espresso'));
97
+		}
98
+		$parts_of_subsection = array(
99
+			'title' => new EE_Form_Section_HTML(
100
+				EEH_HTML::h5(
101
+					$question_group->name(),
102
+					$question_group->identifier(),
103
+					'espresso-question-group-title-h5 section-title'
104
+				)
105
+			)
106
+		);
107
+		$questions = $question_group->questions(
108
+			array(
109
+				array(
110
+					'OR' => array(
111
+						'QST_system*blank' => '',
112
+						'QST_system*null' => array( 'IS_NULL' )
113
+					)
114
+				)
115
+			)
116
+		);
117
+		foreach ($questions as $question) {
118
+			$parts_of_subsection[ $question->ID() ] = $question->generate_form_input($registration);
119
+		}
120
+		if (EE_Registry::instance()->CAP->current_user_can(
121
+			'ee_edit_registration',
122
+			'edit-reg-questions-mbox',
123
+			$this->_registration->ID()
124
+		)) {
125
+			$parts_of_subsection['edit_link'] = new EE_Form_Section_HTML(
126
+				EEH_HTML::table(
127
+					EEH_HTML::tr(
128
+						'<th/><td class="reg-admin-edit-attendee-question-td"><a class="reg-admin-edit-attendee-question-lnk" href="#" aria-label="' . esc_attr__('click to edit question', 'event_espresso') . '">
129 129
 		  			<span class="reg-admin-edit-question-group-spn">' . __('edit the above question group', 'event_espresso') . '</span>
130 130
 		  			<div class="dashicons dashicons-edit"></div>
131 131
 		  		</a></td>'
132
-                    ) .
133
-                    EEH_HTML::no_row('', 2)
134
-                )
135
-            );
136
-        }
137
-        return new EE_Form_Section_Proper(
138
-            array(
139
-                'subsections' => $parts_of_subsection,
140
-                'html_class' => 'question-group-questions',
141
-            )
142
-        );
143
-    }
132
+					) .
133
+					EEH_HTML::no_row('', 2)
134
+				)
135
+			);
136
+		}
137
+		return new EE_Form_Section_Proper(
138
+			array(
139
+				'subsections' => $parts_of_subsection,
140
+				'html_class' => 'question-group-questions',
141
+			)
142
+		);
143
+	}
144 144
 
145
-    /**
146
-     * Overrides parent so if inputs were disabled, we leave those with their defaults
147
-     * from the answers in the DB
148
-     * @param array $req_data like $_POST
149
-     * @return void
150
-     */
151
-    protected function _normalize($req_data)
152
-    {
153
-        $this->_received_submission = true;
154
-        $this->_validation_errors = array();
155
-        foreach ($this->get_validatable_subsections() as $subsection) {
156
-            if ($subsection->form_data_present_in($req_data)) {
157
-                try {
158
-                    $subsection->_normalize($req_data);
159
-                } catch (EE_Validation_Error $e) {
160
-                    $subsection->add_validation_error($e);
161
-                }
162
-            }
163
-        }
164
-    }
145
+	/**
146
+	 * Overrides parent so if inputs were disabled, we leave those with their defaults
147
+	 * from the answers in the DB
148
+	 * @param array $req_data like $_POST
149
+	 * @return void
150
+	 */
151
+	protected function _normalize($req_data)
152
+	{
153
+		$this->_received_submission = true;
154
+		$this->_validation_errors = array();
155
+		foreach ($this->get_validatable_subsections() as $subsection) {
156
+			if ($subsection->form_data_present_in($req_data)) {
157
+				try {
158
+					$subsection->_normalize($req_data);
159
+				} catch (EE_Validation_Error $e) {
160
+					$subsection->add_validation_error($e);
161
+				}
162
+			}
163
+		}
164
+	}
165 165
 
166 166
 
167 167
 
168
-    /**
169
-     * Performs validation on this form section and its subsections. For each subsection,
170
-     * calls _validate_{subsection_name} on THIS form (if the function exists) and passes it the subsection, then calls _validate on that subsection.
171
-     * If you need to perform validation on the form as a whole (considering multiple) you would be best to override this _validate method,
172
-     * calling parent::_validate() first.
173
-     */
174
-    protected function _validate()
175
-    {
176
-        foreach ($this->get_validatable_subsections() as $subsection_name => $subsection) {
177
-            if ($subsection->form_data_present_in(array_merge($_GET, $_POST))) {
178
-                if (method_exists($this, '_validate_'.$subsection_name)) {
179
-                    call_user_func_array(array($this,'_validate_'.$subsection_name), array($subsection));
180
-                }
181
-                $subsection->_validate();
182
-            } elseif ($subsection instanceof EE_Form_Section_Proper) {
183
-                $subsection->_received_submission = true;
184
-            }
185
-        }
186
-    }
168
+	/**
169
+	 * Performs validation on this form section and its subsections. For each subsection,
170
+	 * calls _validate_{subsection_name} on THIS form (if the function exists) and passes it the subsection, then calls _validate on that subsection.
171
+	 * If you need to perform validation on the form as a whole (considering multiple) you would be best to override this _validate method,
172
+	 * calling parent::_validate() first.
173
+	 */
174
+	protected function _validate()
175
+	{
176
+		foreach ($this->get_validatable_subsections() as $subsection_name => $subsection) {
177
+			if ($subsection->form_data_present_in(array_merge($_GET, $_POST))) {
178
+				if (method_exists($this, '_validate_'.$subsection_name)) {
179
+					call_user_func_array(array($this,'_validate_'.$subsection_name), array($subsection));
180
+				}
181
+				$subsection->_validate();
182
+			} elseif ($subsection instanceof EE_Form_Section_Proper) {
183
+				$subsection->_received_submission = true;
184
+			}
185
+		}
186
+	}
187 187
 }
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -29,10 +29,10 @@  discard block
 block discarded – undo
29 29
     public function __construct(EE_Registration $reg, $options = array())
30 30
     {
31 31
         $this->_registration = $reg;
32
-        if (! isset($options['layout_strategy'])) {
32
+        if ( ! isset($options['layout_strategy'])) {
33 33
             $options['layout_strategy'] = new EE_Admin_Two_Column_Layout();
34 34
         }
35
-        if (! isset($options['html_id'])) {
35
+        if ( ! isset($options['html_id'])) {
36 36
             $options['html_id'] = 'reg-admin-attendee-questions-frm';
37 37
         }
38 38
         $this->build_form_from_registration();
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
     public function build_form_from_registration()
53 53
     {
54 54
         $reg = $this->get_registration();
55
-        if (! $reg instanceof EE_Registration) {
55
+        if ( ! $reg instanceof EE_Registration) {
56 56
             throw new EE_Error(__('We cannot build the registration custom questions form because there is no registration set on it yet', 'event_espresso'));
57 57
         }
58 58
         // we want to get all their question groups
@@ -63,16 +63,16 @@  discard block
 block discarded – undo
63 63
                     'Event_Question_Group.EQG_primary' => $reg->count() == 1 ? true : false,
64 64
                     'OR' => array(
65 65
                         'Question.QST_system*blank' =>  '',
66
-                        'Question.QST_system*null' => array( 'IS_NULL' )
66
+                        'Question.QST_system*null' => array('IS_NULL')
67 67
                     )
68 68
                 ),
69
-                'order_by' => array( 'QSG_order' => 'ASC' )
69
+                'order_by' => array('QSG_order' => 'ASC')
70 70
             )
71 71
         );
72 72
         // get each question groups questions
73 73
         foreach ($question_groups as $question_group) {
74 74
             if ($question_group instanceof EE_Question_Group) {
75
-                $this->_subsections[ $question_group->ID() ] = $this->build_subform_from_question_group(
75
+                $this->_subsections[$question_group->ID()] = $this->build_subform_from_question_group(
76 76
                     $question_group,
77 77
                     $reg
78 78
                 );
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
      */
92 92
     public function build_subform_from_question_group($question_group, $registration)
93 93
     {
94
-        if (! $question_group instanceof EE_Question_Group ||
94
+        if ( ! $question_group instanceof EE_Question_Group ||
95 95
             ! $registration instanceof EE_Registration) {
96 96
             throw new EE_Error(__('A valid question group and registration must be passed to EE_Registration_Custom_Question_Form', 'event_espresso'));
97 97
         }
@@ -109,13 +109,13 @@  discard block
 block discarded – undo
109 109
                 array(
110 110
                     'OR' => array(
111 111
                         'QST_system*blank' => '',
112
-                        'QST_system*null' => array( 'IS_NULL' )
112
+                        'QST_system*null' => array('IS_NULL')
113 113
                     )
114 114
                 )
115 115
             )
116 116
         );
117 117
         foreach ($questions as $question) {
118
-            $parts_of_subsection[ $question->ID() ] = $question->generate_form_input($registration);
118
+            $parts_of_subsection[$question->ID()] = $question->generate_form_input($registration);
119 119
         }
120 120
         if (EE_Registry::instance()->CAP->current_user_can(
121 121
             'ee_edit_registration',
@@ -125,11 +125,11 @@  discard block
 block discarded – undo
125 125
             $parts_of_subsection['edit_link'] = new EE_Form_Section_HTML(
126 126
                 EEH_HTML::table(
127 127
                     EEH_HTML::tr(
128
-                        '<th/><td class="reg-admin-edit-attendee-question-td"><a class="reg-admin-edit-attendee-question-lnk" href="#" aria-label="' . esc_attr__('click to edit question', 'event_espresso') . '">
129
-		  			<span class="reg-admin-edit-question-group-spn">' . __('edit the above question group', 'event_espresso') . '</span>
128
+                        '<th/><td class="reg-admin-edit-attendee-question-td"><a class="reg-admin-edit-attendee-question-lnk" href="#" aria-label="'.esc_attr__('click to edit question', 'event_espresso').'">
129
+		  			<span class="reg-admin-edit-question-group-spn">' . __('edit the above question group', 'event_espresso').'</span>
130 130
 		  			<div class="dashicons dashicons-edit"></div>
131 131
 		  		</a></td>'
132
-                    ) .
132
+                    ).
133 133
                     EEH_HTML::no_row('', 2)
134 134
                 )
135 135
             );
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
         foreach ($this->get_validatable_subsections() as $subsection_name => $subsection) {
177 177
             if ($subsection->form_data_present_in(array_merge($_GET, $_POST))) {
178 178
                 if (method_exists($this, '_validate_'.$subsection_name)) {
179
-                    call_user_func_array(array($this,'_validate_'.$subsection_name), array($subsection));
179
+                    call_user_func_array(array($this, '_validate_'.$subsection_name), array($subsection));
180 180
                 }
181 181
                 $subsection->_validate();
182 182
             } elseif ($subsection instanceof EE_Form_Section_Proper) {
Please login to merge, or discard this patch.