Completed
Branch BUG/309/remove-reg-step (a65c05)
by
unknown
14:24 queued 30s
created
core/services/assets/Registry.php 2 patches
Indentation   +691 added lines, -691 removed lines patch added patch discarded remove patch
@@ -26,702 +26,702 @@
 block discarded – undo
26 26
 class Registry
27 27
 {
28 28
 
29
-    const ASSET_TYPE_CSS = 'css';
30
-    const ASSET_TYPE_JS = 'js';
31
-    const ASSET_NAMESPACE = 'core';
32
-
33
-    /**
34
-     * @var EE_Template_Config $template_config
35
-     */
36
-    protected $template_config;
37
-
38
-    /**
39
-     * @var EE_Currency_Config $currency_config
40
-     */
41
-    protected $currency_config;
42
-
43
-    /**
44
-     * This holds the jsdata data object that will be exposed on pages that enqueue the `eejs-core` script.
45
-     *
46
-     * @var array
47
-     */
48
-    protected $jsdata = array();
49
-
50
-
51
-    /**
52
-     * This keeps track of all scripts with registered data.  It is used to prevent duplicate data objects setup in the
53
-     * page source.
54
-     * @var array
55
-     */
56
-    protected $script_handles_with_data = array();
57
-
58
-
59
-    /**
60
-     * @var DomainInterface
61
-     */
62
-    protected $domain;
63
-
64
-
65
-    /**
66
-     * @var I18nRegistry
67
-     */
68
-    private $i18n_registry;
69
-
70
-
71
-
72
-    /**
73
-     * Holds the manifest data obtained from registered manifest files.
74
-     * Manifests are maps of asset chunk name to actual built asset file names.
75
-     * Shape of this array is:
76
-     *
77
-     * array(
78
-     *  'some_namespace_slug' => array(
79
-     *      'some_chunk_name' => array(
80
-     *          'js' => 'filename.js'
81
-     *          'css' => 'filename.js'
82
-     *      ),
83
-     *      'url_base' => 'https://baseurl.com/to/assets
84
-     *  )
85
-     * )
86
-     *
87
-     * @var array
88
-     */
89
-    private $manifest_data = array();
90
-
91
-
92
-    /**
93
-     * Registry constructor.
94
-     * Hooking into WP actions for script registry.
95
-     *
96
-     * @param EE_Template_Config $template_config
97
-     * @param EE_Currency_Config $currency_config
98
-     * @param I18nRegistry       $i18n_registry
99
-     * @param DomainInterface    $domain
100
-     * @throws InvalidArgumentException
101
-     * @throws InvalidFilePathException
102
-     */
103
-    public function __construct(
104
-        EE_Template_Config $template_config,
105
-        EE_Currency_Config $currency_config,
106
-        I18nRegistry $i18n_registry,
107
-        DomainInterface $domain
108
-    ) {
109
-        $this->template_config = $template_config;
110
-        $this->currency_config = $currency_config;
111
-        $this->domain = $domain;
112
-        $this->i18n_registry = $i18n_registry;
113
-        $this->registerManifestFile(
114
-            self::ASSET_NAMESPACE,
115
-            $this->domain->distributionAssetsUrl(),
116
-            $this->domain->distributionAssetsPath() . 'build-manifest.json'
117
-        );
118
-        add_action('wp_enqueue_scripts', array($this, 'scripts'), 1);
119
-        add_action('admin_enqueue_scripts', array($this, 'scripts'), 1);
120
-        add_action('wp_enqueue_scripts', array($this, 'enqueueData'), 2);
121
-        add_action('admin_enqueue_scripts', array($this, 'enqueueData'), 2);
122
-        add_action('wp_print_footer_scripts', array($this, 'enqueueData'), 1);
123
-        add_action('admin_print_footer_scripts', array($this, 'enqueueData'), 1);
124
-    }
125
-
126
-
127
-    /**
128
-     * For classes that have Registry as a dependency, this provides a handy way to register script handles for i18n
129
-     * translation handling.
130
-     *
131
-     * @return I18nRegistry
132
-     */
133
-    public function getI18nRegistry()
134
-    {
135
-        return $this->i18n_registry;
136
-    }
137
-
138
-    /**
139
-     * Callback for the WP script actions.
140
-     * Used to register globally accessible core scripts.
141
-     * Also used to add the eejs.data object to the source for any js having eejs-core as a dependency.
142
-     *
143
-     */
144
-    public function scripts()
145
-    {
146
-        global $wp_version;
147
-        wp_register_script(
148
-            'ee-manifest',
149
-            $this->getJsUrl(self::ASSET_NAMESPACE, 'manifest'),
150
-            array(),
151
-            null,
152
-            true
153
-        );
154
-        wp_register_script(
155
-            'eejs-core',
156
-            $this->getJsUrl(self::ASSET_NAMESPACE, 'eejs'),
157
-            array('ee-manifest'),
158
-            null,
159
-            true
160
-        );
161
-        wp_register_script(
162
-            'ee-vendor-react',
163
-            $this->getJsUrl(self::ASSET_NAMESPACE, 'reactVendor'),
164
-            array('eejs-core'),
165
-            null,
166
-            true
167
-        );
168
-        //only run this if WordPress 4.4.0 > is in use.
169
-        if (version_compare($wp_version, '4.4.0', '>')) {
170
-            //js.api
171
-            wp_register_script(
172
-                'eejs-api',
173
-                EE_LIBRARIES_URL . 'rest_api/assets/js/eejs-api.min.js',
174
-                array('underscore', 'eejs-core'),
175
-                EVENT_ESPRESSO_VERSION,
176
-                true
177
-            );
178
-            $this->jsdata['eejs_api_nonce'] = wp_create_nonce('wp_rest');
179
-            $this->jsdata['paths'] = array('rest_route' => rest_url('ee/v4.8.36/'));
180
-        }
181
-        if (! is_admin()) {
182
-            $this->loadCoreCss();
183
-        }
184
-        $this->registerTranslationsForHandles(array('eejs-core'));
185
-        $this->loadCoreJs();
186
-        $this->loadJqueryValidate();
187
-        $this->loadAccountingJs();
188
-        $this->loadQtipJs();
189
-        $this->registerAdminAssets();
190
-    }
191
-
192
-
193
-
194
-    /**
195
-     * Call back for the script print in frontend and backend.
196
-     * Used to call wp_localize_scripts so that data can be added throughout the runtime until this later hook point.
197
-     *
198
-     * @since 4.9.31.rc.015
199
-     */
200
-    public function enqueueData()
201
-    {
202
-        $this->removeAlreadyRegisteredDataForScriptHandles();
203
-        wp_add_inline_script(
204
-            'eejs-core',
205
-            'var eejsdata=' . wp_json_encode(array('data' => $this->jsdata)),
206
-            'before'
207
-        );
208
-        wp_localize_script('espresso_core', 'eei18n', EE_Registry::$i18n_js_strings);
209
-        $this->localizeAccountingJs();
210
-        $this->addRegisteredScriptHandlesWithData('eejs-core');
211
-        $this->addRegisteredScriptHandlesWithData('espresso_core');
212
-    }
213
-
214
-
215
-
216
-    /**
217
-     * Used to add data to eejs.data object.
218
-     * Note:  Overriding existing data is not allowed.
219
-     * Data will be accessible as a javascript object when you list `eejs-core` as a dependency for your javascript.
220
-     * If the data you add is something like this:
221
-     *  $this->addData( 'my_plugin_data', array( 'foo' => 'gar' ) );
222
-     * It will be exposed in the page source as:
223
-     *  eejs.data.my_plugin_data.foo == gar
224
-     *
225
-     * @param string       $key   Key used to access your data
226
-     * @param string|array $value Value to attach to key
227
-     * @throws InvalidArgumentException
228
-     */
229
-    public function addData($key, $value)
230
-    {
231
-        if ($this->verifyDataNotExisting($key)) {
232
-            $this->jsdata[$key] = $value;
233
-        }
234
-    }
235
-
236
-
237
-
238
-    /**
239
-     * Similar to addData except this allows for users to push values to an existing key where the values on key are
240
-     * elements in an array.
241
-     * When you use this method, the value you include will be appended to the end of an array on $key.
242
-     * So if the $key was 'test' and you added a value of 'my_data' then it would be represented in the javascript
243
-     * object like this, eejs.data.test = [ my_data,
244
-     * ]
245
-     * If there has already been a scalar value attached to the data object given key, then
246
-     * this will throw an exception.
247
-     *
248
-     * @param string       $key   Key to attach data to.
249
-     * @param string|array $value Value being registered.
250
-     * @throws InvalidArgumentException
251
-     */
252
-    public function pushData($key, $value)
253
-    {
254
-        if (isset($this->jsdata[$key])
255
-            && ! is_array($this->jsdata[$key])
256
-        ) {
257
-            throw new invalidArgumentException(
258
-                sprintf(
259
-                    __(
260
-                        'The value for %1$s is already set and it is not an array. The %2$s method can only be used to
29
+	const ASSET_TYPE_CSS = 'css';
30
+	const ASSET_TYPE_JS = 'js';
31
+	const ASSET_NAMESPACE = 'core';
32
+
33
+	/**
34
+	 * @var EE_Template_Config $template_config
35
+	 */
36
+	protected $template_config;
37
+
38
+	/**
39
+	 * @var EE_Currency_Config $currency_config
40
+	 */
41
+	protected $currency_config;
42
+
43
+	/**
44
+	 * This holds the jsdata data object that will be exposed on pages that enqueue the `eejs-core` script.
45
+	 *
46
+	 * @var array
47
+	 */
48
+	protected $jsdata = array();
49
+
50
+
51
+	/**
52
+	 * This keeps track of all scripts with registered data.  It is used to prevent duplicate data objects setup in the
53
+	 * page source.
54
+	 * @var array
55
+	 */
56
+	protected $script_handles_with_data = array();
57
+
58
+
59
+	/**
60
+	 * @var DomainInterface
61
+	 */
62
+	protected $domain;
63
+
64
+
65
+	/**
66
+	 * @var I18nRegistry
67
+	 */
68
+	private $i18n_registry;
69
+
70
+
71
+
72
+	/**
73
+	 * Holds the manifest data obtained from registered manifest files.
74
+	 * Manifests are maps of asset chunk name to actual built asset file names.
75
+	 * Shape of this array is:
76
+	 *
77
+	 * array(
78
+	 *  'some_namespace_slug' => array(
79
+	 *      'some_chunk_name' => array(
80
+	 *          'js' => 'filename.js'
81
+	 *          'css' => 'filename.js'
82
+	 *      ),
83
+	 *      'url_base' => 'https://baseurl.com/to/assets
84
+	 *  )
85
+	 * )
86
+	 *
87
+	 * @var array
88
+	 */
89
+	private $manifest_data = array();
90
+
91
+
92
+	/**
93
+	 * Registry constructor.
94
+	 * Hooking into WP actions for script registry.
95
+	 *
96
+	 * @param EE_Template_Config $template_config
97
+	 * @param EE_Currency_Config $currency_config
98
+	 * @param I18nRegistry       $i18n_registry
99
+	 * @param DomainInterface    $domain
100
+	 * @throws InvalidArgumentException
101
+	 * @throws InvalidFilePathException
102
+	 */
103
+	public function __construct(
104
+		EE_Template_Config $template_config,
105
+		EE_Currency_Config $currency_config,
106
+		I18nRegistry $i18n_registry,
107
+		DomainInterface $domain
108
+	) {
109
+		$this->template_config = $template_config;
110
+		$this->currency_config = $currency_config;
111
+		$this->domain = $domain;
112
+		$this->i18n_registry = $i18n_registry;
113
+		$this->registerManifestFile(
114
+			self::ASSET_NAMESPACE,
115
+			$this->domain->distributionAssetsUrl(),
116
+			$this->domain->distributionAssetsPath() . 'build-manifest.json'
117
+		);
118
+		add_action('wp_enqueue_scripts', array($this, 'scripts'), 1);
119
+		add_action('admin_enqueue_scripts', array($this, 'scripts'), 1);
120
+		add_action('wp_enqueue_scripts', array($this, 'enqueueData'), 2);
121
+		add_action('admin_enqueue_scripts', array($this, 'enqueueData'), 2);
122
+		add_action('wp_print_footer_scripts', array($this, 'enqueueData'), 1);
123
+		add_action('admin_print_footer_scripts', array($this, 'enqueueData'), 1);
124
+	}
125
+
126
+
127
+	/**
128
+	 * For classes that have Registry as a dependency, this provides a handy way to register script handles for i18n
129
+	 * translation handling.
130
+	 *
131
+	 * @return I18nRegistry
132
+	 */
133
+	public function getI18nRegistry()
134
+	{
135
+		return $this->i18n_registry;
136
+	}
137
+
138
+	/**
139
+	 * Callback for the WP script actions.
140
+	 * Used to register globally accessible core scripts.
141
+	 * Also used to add the eejs.data object to the source for any js having eejs-core as a dependency.
142
+	 *
143
+	 */
144
+	public function scripts()
145
+	{
146
+		global $wp_version;
147
+		wp_register_script(
148
+			'ee-manifest',
149
+			$this->getJsUrl(self::ASSET_NAMESPACE, 'manifest'),
150
+			array(),
151
+			null,
152
+			true
153
+		);
154
+		wp_register_script(
155
+			'eejs-core',
156
+			$this->getJsUrl(self::ASSET_NAMESPACE, 'eejs'),
157
+			array('ee-manifest'),
158
+			null,
159
+			true
160
+		);
161
+		wp_register_script(
162
+			'ee-vendor-react',
163
+			$this->getJsUrl(self::ASSET_NAMESPACE, 'reactVendor'),
164
+			array('eejs-core'),
165
+			null,
166
+			true
167
+		);
168
+		//only run this if WordPress 4.4.0 > is in use.
169
+		if (version_compare($wp_version, '4.4.0', '>')) {
170
+			//js.api
171
+			wp_register_script(
172
+				'eejs-api',
173
+				EE_LIBRARIES_URL . 'rest_api/assets/js/eejs-api.min.js',
174
+				array('underscore', 'eejs-core'),
175
+				EVENT_ESPRESSO_VERSION,
176
+				true
177
+			);
178
+			$this->jsdata['eejs_api_nonce'] = wp_create_nonce('wp_rest');
179
+			$this->jsdata['paths'] = array('rest_route' => rest_url('ee/v4.8.36/'));
180
+		}
181
+		if (! is_admin()) {
182
+			$this->loadCoreCss();
183
+		}
184
+		$this->registerTranslationsForHandles(array('eejs-core'));
185
+		$this->loadCoreJs();
186
+		$this->loadJqueryValidate();
187
+		$this->loadAccountingJs();
188
+		$this->loadQtipJs();
189
+		$this->registerAdminAssets();
190
+	}
191
+
192
+
193
+
194
+	/**
195
+	 * Call back for the script print in frontend and backend.
196
+	 * Used to call wp_localize_scripts so that data can be added throughout the runtime until this later hook point.
197
+	 *
198
+	 * @since 4.9.31.rc.015
199
+	 */
200
+	public function enqueueData()
201
+	{
202
+		$this->removeAlreadyRegisteredDataForScriptHandles();
203
+		wp_add_inline_script(
204
+			'eejs-core',
205
+			'var eejsdata=' . wp_json_encode(array('data' => $this->jsdata)),
206
+			'before'
207
+		);
208
+		wp_localize_script('espresso_core', 'eei18n', EE_Registry::$i18n_js_strings);
209
+		$this->localizeAccountingJs();
210
+		$this->addRegisteredScriptHandlesWithData('eejs-core');
211
+		$this->addRegisteredScriptHandlesWithData('espresso_core');
212
+	}
213
+
214
+
215
+
216
+	/**
217
+	 * Used to add data to eejs.data object.
218
+	 * Note:  Overriding existing data is not allowed.
219
+	 * Data will be accessible as a javascript object when you list `eejs-core` as a dependency for your javascript.
220
+	 * If the data you add is something like this:
221
+	 *  $this->addData( 'my_plugin_data', array( 'foo' => 'gar' ) );
222
+	 * It will be exposed in the page source as:
223
+	 *  eejs.data.my_plugin_data.foo == gar
224
+	 *
225
+	 * @param string       $key   Key used to access your data
226
+	 * @param string|array $value Value to attach to key
227
+	 * @throws InvalidArgumentException
228
+	 */
229
+	public function addData($key, $value)
230
+	{
231
+		if ($this->verifyDataNotExisting($key)) {
232
+			$this->jsdata[$key] = $value;
233
+		}
234
+	}
235
+
236
+
237
+
238
+	/**
239
+	 * Similar to addData except this allows for users to push values to an existing key where the values on key are
240
+	 * elements in an array.
241
+	 * When you use this method, the value you include will be appended to the end of an array on $key.
242
+	 * So if the $key was 'test' and you added a value of 'my_data' then it would be represented in the javascript
243
+	 * object like this, eejs.data.test = [ my_data,
244
+	 * ]
245
+	 * If there has already been a scalar value attached to the data object given key, then
246
+	 * this will throw an exception.
247
+	 *
248
+	 * @param string       $key   Key to attach data to.
249
+	 * @param string|array $value Value being registered.
250
+	 * @throws InvalidArgumentException
251
+	 */
252
+	public function pushData($key, $value)
253
+	{
254
+		if (isset($this->jsdata[$key])
255
+			&& ! is_array($this->jsdata[$key])
256
+		) {
257
+			throw new invalidArgumentException(
258
+				sprintf(
259
+					__(
260
+						'The value for %1$s is already set and it is not an array. The %2$s method can only be used to
261 261
                          push values to this data element when it is an array.',
262
-                        'event_espresso'
263
-                    ),
264
-                    $key,
265
-                    __METHOD__
266
-                )
267
-            );
268
-        }
269
-        $this->jsdata[$key][] = $value;
270
-    }
271
-
272
-
273
-
274
-    /**
275
-     * Used to set content used by javascript for a template.
276
-     * Note: Overrides of existing registered templates are not allowed.
277
-     *
278
-     * @param string $template_reference
279
-     * @param string $template_content
280
-     * @throws InvalidArgumentException
281
-     */
282
-    public function addTemplate($template_reference, $template_content)
283
-    {
284
-        if (! isset($this->jsdata['templates'])) {
285
-            $this->jsdata['templates'] = array();
286
-        }
287
-        //no overrides allowed.
288
-        if (isset($this->jsdata['templates'][$template_reference])) {
289
-            throw new invalidArgumentException(
290
-                sprintf(
291
-                    __(
292
-                        'The %1$s key already exists for the templates array in the js data array.  No overrides are allowed.',
293
-                        'event_espresso'
294
-                    ),
295
-                    $template_reference
296
-                )
297
-            );
298
-        }
299
-        $this->jsdata['templates'][$template_reference] = $template_content;
300
-    }
301
-
302
-
303
-
304
-    /**
305
-     * Retrieve the template content already registered for the given reference.
306
-     *
307
-     * @param string $template_reference
308
-     * @return string
309
-     */
310
-    public function getTemplate($template_reference)
311
-    {
312
-        return isset($this->jsdata['templates'], $this->jsdata['templates'][$template_reference])
313
-            ? $this->jsdata['templates'][$template_reference]
314
-            : '';
315
-    }
316
-
317
-
318
-
319
-    /**
320
-     * Retrieve registered data.
321
-     *
322
-     * @param string $key Name of key to attach data to.
323
-     * @return mixed                If there is no for the given key, then false is returned.
324
-     */
325
-    public function getData($key)
326
-    {
327
-        return isset($this->jsdata[$key])
328
-            ? $this->jsdata[$key]
329
-            : false;
330
-    }
331
-
332
-
333
-    /**
334
-     * Get the actual asset path for asset manifests.
335
-     * If there is no asset path found for the given $chunk_name, then the $chunk_name is returned.
336
-     * @param string $namespace  The namespace associated with the manifest file hosting the map of chunk_name to actual
337
-     *                           asset file location.
338
-     * @param string $chunk_name
339
-     * @param string $asset_type
340
-     * @return string
341
-     * @since 4.9.59.p
342
-     */
343
-    public function getAssetUrl($namespace, $chunk_name, $asset_type)
344
-    {
345
-        $url = isset(
346
-            $this->manifest_data[$namespace][$chunk_name][$asset_type],
347
-            $this->manifest_data[$namespace]['url_base']
348
-        )
349
-            ? $this->manifest_data[$namespace]['url_base']
350
-              . $this->manifest_data[$namespace][$chunk_name][$asset_type]
351
-            : $chunk_name;
352
-        return apply_filters(
353
-            'FHEE__EventEspresso_core_services_assets_Registry__getAssetUrl',
354
-            $url,
355
-            $namespace,
356
-            $chunk_name,
357
-            $asset_type
358
-        );
359
-    }
360
-
361
-
362
-    /**
363
-     * Return the url to a js file for the given namespace and chunk name.
364
-     *
365
-     * @param string $namespace
366
-     * @param string $chunk_name
367
-     * @return string
368
-     */
369
-    public function getJsUrl($namespace, $chunk_name)
370
-    {
371
-        return $this->getAssetUrl($namespace, $chunk_name, self::ASSET_TYPE_JS);
372
-    }
373
-
374
-
375
-    /**
376
-     * Return the url to a css file for the given namespace and chunk name.
377
-     *
378
-     * @param string $namespace
379
-     * @param string $chunk_name
380
-     * @return string
381
-     */
382
-    public function getCssUrl($namespace, $chunk_name)
383
-    {
384
-        return $this->getAssetUrl($namespace, $chunk_name, self::ASSET_TYPE_CSS);
385
-    }
386
-
387
-
388
-    /**
389
-     * Used to register a js/css manifest file with the registered_manifest_files property.
390
-     *
391
-     * @param string $namespace     Provided to associate the manifest file with a specific namespace.
392
-     * @param string $url_base      The url base for the manifest file location.
393
-     * @param string $manifest_file The absolute path to the manifest file.
394
-     * @throws InvalidArgumentException
395
-     * @throws InvalidFilePathException
396
-     * @since 4.9.59.p
397
-     */
398
-    public function registerManifestFile($namespace, $url_base, $manifest_file)
399
-    {
400
-        if (isset($this->manifest_data[$namespace])) {
401
-            throw new InvalidArgumentException(
402
-                sprintf(
403
-                    esc_html__(
404
-                        'The namespace for this manifest file has already been registered, choose a namespace other than %s',
405
-                        'event_espresso'
406
-                    ),
407
-                    $namespace
408
-                )
409
-            );
410
-        }
411
-        if (filter_var($url_base, FILTER_VALIDATE_URL) === false) {
412
-            if (is_admin()) {
413
-                EE_Error::add_error(
414
-                    sprintf(
415
-                        esc_html__(
416
-                            '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',
417
-                            'event_espresso'
418
-                        ),
419
-                        'Event Espresso',
420
-                        $url_base,
421
-                        'plugins_url',
422
-                        'WP_PLUGIN_URL'
423
-                    ),
424
-                    __FILE__,
425
-                    __FUNCTION__,
426
-                    __LINE__
427
-                );
428
-            }
429
-            return;
430
-        }
431
-        $this->manifest_data[$namespace] = $this->decodeManifestFile($manifest_file);
432
-        if (! isset($this->manifest_data[$namespace]['url_base'])) {
433
-            $this->manifest_data[$namespace]['url_base'] = trailingslashit($url_base);
434
-        }
435
-    }
436
-
437
-
438
-
439
-    /**
440
-     * Decodes json from the provided manifest file.
441
-     *
442
-     * @since 4.9.59.p
443
-     * @param string $manifest_file Path to manifest file.
444
-     * @return array
445
-     * @throws InvalidFilePathException
446
-     */
447
-    private function decodeManifestFile($manifest_file)
448
-    {
449
-        if (! file_exists($manifest_file)) {
450
-            throw new InvalidFilePathException($manifest_file);
451
-        }
452
-        return json_decode(file_get_contents($manifest_file), true);
453
-    }
454
-
455
-
456
-
457
-    /**
458
-     * Verifies whether the given data exists already on the jsdata array.
459
-     * Overriding data is not allowed.
460
-     *
461
-     * @param string $key Index for data.
462
-     * @return bool        If valid then return true.
463
-     * @throws InvalidArgumentException if data already exists.
464
-     */
465
-    protected function verifyDataNotExisting($key)
466
-    {
467
-        if (isset($this->jsdata[$key])) {
468
-            if (is_array($this->jsdata[$key])) {
469
-                throw new InvalidArgumentException(
470
-                    sprintf(
471
-                        __(
472
-                            'The value for %1$s already exists in the Registry::eejs object.
262
+						'event_espresso'
263
+					),
264
+					$key,
265
+					__METHOD__
266
+				)
267
+			);
268
+		}
269
+		$this->jsdata[$key][] = $value;
270
+	}
271
+
272
+
273
+
274
+	/**
275
+	 * Used to set content used by javascript for a template.
276
+	 * Note: Overrides of existing registered templates are not allowed.
277
+	 *
278
+	 * @param string $template_reference
279
+	 * @param string $template_content
280
+	 * @throws InvalidArgumentException
281
+	 */
282
+	public function addTemplate($template_reference, $template_content)
283
+	{
284
+		if (! isset($this->jsdata['templates'])) {
285
+			$this->jsdata['templates'] = array();
286
+		}
287
+		//no overrides allowed.
288
+		if (isset($this->jsdata['templates'][$template_reference])) {
289
+			throw new invalidArgumentException(
290
+				sprintf(
291
+					__(
292
+						'The %1$s key already exists for the templates array in the js data array.  No overrides are allowed.',
293
+						'event_espresso'
294
+					),
295
+					$template_reference
296
+				)
297
+			);
298
+		}
299
+		$this->jsdata['templates'][$template_reference] = $template_content;
300
+	}
301
+
302
+
303
+
304
+	/**
305
+	 * Retrieve the template content already registered for the given reference.
306
+	 *
307
+	 * @param string $template_reference
308
+	 * @return string
309
+	 */
310
+	public function getTemplate($template_reference)
311
+	{
312
+		return isset($this->jsdata['templates'], $this->jsdata['templates'][$template_reference])
313
+			? $this->jsdata['templates'][$template_reference]
314
+			: '';
315
+	}
316
+
317
+
318
+
319
+	/**
320
+	 * Retrieve registered data.
321
+	 *
322
+	 * @param string $key Name of key to attach data to.
323
+	 * @return mixed                If there is no for the given key, then false is returned.
324
+	 */
325
+	public function getData($key)
326
+	{
327
+		return isset($this->jsdata[$key])
328
+			? $this->jsdata[$key]
329
+			: false;
330
+	}
331
+
332
+
333
+	/**
334
+	 * Get the actual asset path for asset manifests.
335
+	 * If there is no asset path found for the given $chunk_name, then the $chunk_name is returned.
336
+	 * @param string $namespace  The namespace associated with the manifest file hosting the map of chunk_name to actual
337
+	 *                           asset file location.
338
+	 * @param string $chunk_name
339
+	 * @param string $asset_type
340
+	 * @return string
341
+	 * @since 4.9.59.p
342
+	 */
343
+	public function getAssetUrl($namespace, $chunk_name, $asset_type)
344
+	{
345
+		$url = isset(
346
+			$this->manifest_data[$namespace][$chunk_name][$asset_type],
347
+			$this->manifest_data[$namespace]['url_base']
348
+		)
349
+			? $this->manifest_data[$namespace]['url_base']
350
+			  . $this->manifest_data[$namespace][$chunk_name][$asset_type]
351
+			: $chunk_name;
352
+		return apply_filters(
353
+			'FHEE__EventEspresso_core_services_assets_Registry__getAssetUrl',
354
+			$url,
355
+			$namespace,
356
+			$chunk_name,
357
+			$asset_type
358
+		);
359
+	}
360
+
361
+
362
+	/**
363
+	 * Return the url to a js file for the given namespace and chunk name.
364
+	 *
365
+	 * @param string $namespace
366
+	 * @param string $chunk_name
367
+	 * @return string
368
+	 */
369
+	public function getJsUrl($namespace, $chunk_name)
370
+	{
371
+		return $this->getAssetUrl($namespace, $chunk_name, self::ASSET_TYPE_JS);
372
+	}
373
+
374
+
375
+	/**
376
+	 * Return the url to a css file for the given namespace and chunk name.
377
+	 *
378
+	 * @param string $namespace
379
+	 * @param string $chunk_name
380
+	 * @return string
381
+	 */
382
+	public function getCssUrl($namespace, $chunk_name)
383
+	{
384
+		return $this->getAssetUrl($namespace, $chunk_name, self::ASSET_TYPE_CSS);
385
+	}
386
+
387
+
388
+	/**
389
+	 * Used to register a js/css manifest file with the registered_manifest_files property.
390
+	 *
391
+	 * @param string $namespace     Provided to associate the manifest file with a specific namespace.
392
+	 * @param string $url_base      The url base for the manifest file location.
393
+	 * @param string $manifest_file The absolute path to the manifest file.
394
+	 * @throws InvalidArgumentException
395
+	 * @throws InvalidFilePathException
396
+	 * @since 4.9.59.p
397
+	 */
398
+	public function registerManifestFile($namespace, $url_base, $manifest_file)
399
+	{
400
+		if (isset($this->manifest_data[$namespace])) {
401
+			throw new InvalidArgumentException(
402
+				sprintf(
403
+					esc_html__(
404
+						'The namespace for this manifest file has already been registered, choose a namespace other than %s',
405
+						'event_espresso'
406
+					),
407
+					$namespace
408
+				)
409
+			);
410
+		}
411
+		if (filter_var($url_base, FILTER_VALIDATE_URL) === false) {
412
+			if (is_admin()) {
413
+				EE_Error::add_error(
414
+					sprintf(
415
+						esc_html__(
416
+							'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',
417
+							'event_espresso'
418
+						),
419
+						'Event Espresso',
420
+						$url_base,
421
+						'plugins_url',
422
+						'WP_PLUGIN_URL'
423
+					),
424
+					__FILE__,
425
+					__FUNCTION__,
426
+					__LINE__
427
+				);
428
+			}
429
+			return;
430
+		}
431
+		$this->manifest_data[$namespace] = $this->decodeManifestFile($manifest_file);
432
+		if (! isset($this->manifest_data[$namespace]['url_base'])) {
433
+			$this->manifest_data[$namespace]['url_base'] = trailingslashit($url_base);
434
+		}
435
+	}
436
+
437
+
438
+
439
+	/**
440
+	 * Decodes json from the provided manifest file.
441
+	 *
442
+	 * @since 4.9.59.p
443
+	 * @param string $manifest_file Path to manifest file.
444
+	 * @return array
445
+	 * @throws InvalidFilePathException
446
+	 */
447
+	private function decodeManifestFile($manifest_file)
448
+	{
449
+		if (! file_exists($manifest_file)) {
450
+			throw new InvalidFilePathException($manifest_file);
451
+		}
452
+		return json_decode(file_get_contents($manifest_file), true);
453
+	}
454
+
455
+
456
+
457
+	/**
458
+	 * Verifies whether the given data exists already on the jsdata array.
459
+	 * Overriding data is not allowed.
460
+	 *
461
+	 * @param string $key Index for data.
462
+	 * @return bool        If valid then return true.
463
+	 * @throws InvalidArgumentException if data already exists.
464
+	 */
465
+	protected function verifyDataNotExisting($key)
466
+	{
467
+		if (isset($this->jsdata[$key])) {
468
+			if (is_array($this->jsdata[$key])) {
469
+				throw new InvalidArgumentException(
470
+					sprintf(
471
+						__(
472
+							'The value for %1$s already exists in the Registry::eejs object.
473 473
                             Overrides are not allowed. Since the value of this data is an array, you may want to use the
474 474
                             %2$s method to push your value to the array.',
475
-                            'event_espresso'
476
-                        ),
477
-                        $key,
478
-                        'pushData()'
479
-                    )
480
-                );
481
-            }
482
-            throw new InvalidArgumentException(
483
-                sprintf(
484
-                    __(
485
-                        'The value for %1$s already exists in the Registry::eejs object. Overrides are not
475
+							'event_espresso'
476
+						),
477
+						$key,
478
+						'pushData()'
479
+					)
480
+				);
481
+			}
482
+			throw new InvalidArgumentException(
483
+				sprintf(
484
+					__(
485
+						'The value for %1$s already exists in the Registry::eejs object. Overrides are not
486 486
                         allowed.  Consider attaching your value to a different key',
487
-                        'event_espresso'
488
-                    ),
489
-                    $key
490
-                )
491
-            );
492
-        }
493
-        return true;
494
-    }
495
-
496
-
497
-
498
-    /**
499
-     * registers core default stylesheets
500
-     */
501
-    private function loadCoreCss()
502
-    {
503
-        if ($this->template_config->enable_default_style) {
504
-            $default_stylesheet_path = is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')
505
-                ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css'
506
-                : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css';
507
-            wp_register_style(
508
-                'espresso_default',
509
-                $default_stylesheet_path,
510
-                array('dashicons'),
511
-                EVENT_ESPRESSO_VERSION
512
-            );
513
-            //Load custom style sheet if available
514
-            if ($this->template_config->custom_style_sheet !== null) {
515
-                wp_register_style(
516
-                    'espresso_custom_css',
517
-                    EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet,
518
-                    array('espresso_default'),
519
-                    EVENT_ESPRESSO_VERSION
520
-                );
521
-            }
522
-        }
523
-    }
524
-
525
-
526
-
527
-    /**
528
-     * registers core default javascript
529
-     */
530
-    private function loadCoreJs()
531
-    {
532
-        // load core js
533
-        wp_register_script(
534
-            'espresso_core',
535
-            EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
536
-            array('jquery'),
537
-            EVENT_ESPRESSO_VERSION,
538
-            true
539
-        );
540
-    }
541
-
542
-
543
-
544
-    /**
545
-     * registers jQuery Validate for form validation
546
-     */
547
-    private function loadJqueryValidate()
548
-    {
549
-        // register jQuery Validate and additional methods
550
-        wp_register_script(
551
-            'jquery-validate',
552
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js',
553
-            array('jquery'),
554
-            '1.15.0',
555
-            true
556
-        );
557
-        wp_register_script(
558
-            'jquery-validate-extra-methods',
559
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js',
560
-            array('jquery', 'jquery-validate'),
561
-            '1.15.0',
562
-            true
563
-        );
564
-    }
565
-
566
-
567
-
568
-    /**
569
-     * registers accounting.js for performing client-side calculations
570
-     */
571
-    private function loadAccountingJs()
572
-    {
573
-        //accounting.js library
574
-        // @link http://josscrowcroft.github.io/accounting.js/
575
-        wp_register_script(
576
-            'ee-accounting-core',
577
-            EE_THIRD_PARTY_URL . 'accounting/accounting.js',
578
-            array('underscore'),
579
-            '0.3.2',
580
-            true
581
-        );
582
-        wp_register_script(
583
-            'ee-accounting',
584
-            EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js',
585
-            array('ee-accounting-core'),
586
-            EVENT_ESPRESSO_VERSION,
587
-            true
588
-        );
589
-    }
590
-
591
-
592
-
593
-    /**
594
-     * registers accounting.js for performing client-side calculations
595
-     */
596
-    private function localizeAccountingJs()
597
-    {
598
-        wp_localize_script(
599
-            'ee-accounting',
600
-            'EE_ACCOUNTING_CFG',
601
-            array(
602
-                'currency' => array(
603
-                    'symbol'    => $this->currency_config->sign,
604
-                    'format'    => array(
605
-                        'pos'  => $this->currency_config->sign_b4 ? '%s%v' : '%v%s',
606
-                        'neg'  => $this->currency_config->sign_b4 ? '- %s%v' : '- %v%s',
607
-                        'zero' => $this->currency_config->sign_b4 ? '%s--' : '--%s',
608
-                    ),
609
-                    'decimal'   => $this->currency_config->dec_mrk,
610
-                    'thousand'  => $this->currency_config->thsnds,
611
-                    'precision' => $this->currency_config->dec_plc,
612
-                ),
613
-                'number'   => array(
614
-                    'precision' => $this->currency_config->dec_plc,
615
-                    'thousand'  => $this->currency_config->thsnds,
616
-                    'decimal'   => $this->currency_config->dec_mrk,
617
-                ),
618
-            )
619
-        );
620
-        $this->addRegisteredScriptHandlesWithData('ee-accounting');
621
-    }
622
-
623
-
624
-
625
-    /**
626
-     * registers assets for cleaning your ears
627
-     */
628
-    private function loadQtipJs()
629
-    {
630
-        // qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook,
631
-        // can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' );
632
-        if (apply_filters('FHEE_load_qtip', false)) {
633
-            EEH_Qtip_Loader::instance()->register_and_enqueue();
634
-        }
635
-    }
636
-
637
-
638
-    /**
639
-     * This is used to set registered script handles that have data.
640
-     * @param string $script_handle
641
-     */
642
-    private function addRegisteredScriptHandlesWithData($script_handle)
643
-    {
644
-        $this->script_handles_with_data[$script_handle] = $script_handle;
645
-    }
646
-
647
-
648
-    /**i
487
+						'event_espresso'
488
+					),
489
+					$key
490
+				)
491
+			);
492
+		}
493
+		return true;
494
+	}
495
+
496
+
497
+
498
+	/**
499
+	 * registers core default stylesheets
500
+	 */
501
+	private function loadCoreCss()
502
+	{
503
+		if ($this->template_config->enable_default_style) {
504
+			$default_stylesheet_path = is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')
505
+				? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css'
506
+				: EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css';
507
+			wp_register_style(
508
+				'espresso_default',
509
+				$default_stylesheet_path,
510
+				array('dashicons'),
511
+				EVENT_ESPRESSO_VERSION
512
+			);
513
+			//Load custom style sheet if available
514
+			if ($this->template_config->custom_style_sheet !== null) {
515
+				wp_register_style(
516
+					'espresso_custom_css',
517
+					EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet,
518
+					array('espresso_default'),
519
+					EVENT_ESPRESSO_VERSION
520
+				);
521
+			}
522
+		}
523
+	}
524
+
525
+
526
+
527
+	/**
528
+	 * registers core default javascript
529
+	 */
530
+	private function loadCoreJs()
531
+	{
532
+		// load core js
533
+		wp_register_script(
534
+			'espresso_core',
535
+			EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
536
+			array('jquery'),
537
+			EVENT_ESPRESSO_VERSION,
538
+			true
539
+		);
540
+	}
541
+
542
+
543
+
544
+	/**
545
+	 * registers jQuery Validate for form validation
546
+	 */
547
+	private function loadJqueryValidate()
548
+	{
549
+		// register jQuery Validate and additional methods
550
+		wp_register_script(
551
+			'jquery-validate',
552
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js',
553
+			array('jquery'),
554
+			'1.15.0',
555
+			true
556
+		);
557
+		wp_register_script(
558
+			'jquery-validate-extra-methods',
559
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js',
560
+			array('jquery', 'jquery-validate'),
561
+			'1.15.0',
562
+			true
563
+		);
564
+	}
565
+
566
+
567
+
568
+	/**
569
+	 * registers accounting.js for performing client-side calculations
570
+	 */
571
+	private function loadAccountingJs()
572
+	{
573
+		//accounting.js library
574
+		// @link http://josscrowcroft.github.io/accounting.js/
575
+		wp_register_script(
576
+			'ee-accounting-core',
577
+			EE_THIRD_PARTY_URL . 'accounting/accounting.js',
578
+			array('underscore'),
579
+			'0.3.2',
580
+			true
581
+		);
582
+		wp_register_script(
583
+			'ee-accounting',
584
+			EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js',
585
+			array('ee-accounting-core'),
586
+			EVENT_ESPRESSO_VERSION,
587
+			true
588
+		);
589
+	}
590
+
591
+
592
+
593
+	/**
594
+	 * registers accounting.js for performing client-side calculations
595
+	 */
596
+	private function localizeAccountingJs()
597
+	{
598
+		wp_localize_script(
599
+			'ee-accounting',
600
+			'EE_ACCOUNTING_CFG',
601
+			array(
602
+				'currency' => array(
603
+					'symbol'    => $this->currency_config->sign,
604
+					'format'    => array(
605
+						'pos'  => $this->currency_config->sign_b4 ? '%s%v' : '%v%s',
606
+						'neg'  => $this->currency_config->sign_b4 ? '- %s%v' : '- %v%s',
607
+						'zero' => $this->currency_config->sign_b4 ? '%s--' : '--%s',
608
+					),
609
+					'decimal'   => $this->currency_config->dec_mrk,
610
+					'thousand'  => $this->currency_config->thsnds,
611
+					'precision' => $this->currency_config->dec_plc,
612
+				),
613
+				'number'   => array(
614
+					'precision' => $this->currency_config->dec_plc,
615
+					'thousand'  => $this->currency_config->thsnds,
616
+					'decimal'   => $this->currency_config->dec_mrk,
617
+				),
618
+			)
619
+		);
620
+		$this->addRegisteredScriptHandlesWithData('ee-accounting');
621
+	}
622
+
623
+
624
+
625
+	/**
626
+	 * registers assets for cleaning your ears
627
+	 */
628
+	private function loadQtipJs()
629
+	{
630
+		// qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook,
631
+		// can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' );
632
+		if (apply_filters('FHEE_load_qtip', false)) {
633
+			EEH_Qtip_Loader::instance()->register_and_enqueue();
634
+		}
635
+	}
636
+
637
+
638
+	/**
639
+	 * This is used to set registered script handles that have data.
640
+	 * @param string $script_handle
641
+	 */
642
+	private function addRegisteredScriptHandlesWithData($script_handle)
643
+	{
644
+		$this->script_handles_with_data[$script_handle] = $script_handle;
645
+	}
646
+
647
+
648
+	/**i
649 649
      * Checks WP_Scripts for all of each script handle registered internally as having data and unsets from the
650 650
      * Dependency stored in WP_Scripts if its set.
651 651
      */
652
-    private function removeAlreadyRegisteredDataForScriptHandles()
653
-    {
654
-        if (empty($this->script_handles_with_data)) {
655
-            return;
656
-        }
657
-        foreach ($this->script_handles_with_data as $script_handle) {
658
-            $this->removeAlreadyRegisteredDataForScriptHandle($script_handle);
659
-        }
660
-    }
661
-
662
-
663
-    /**
664
-     * Removes any data dependency registered in WP_Scripts if its set.
665
-     * @param string $script_handle
666
-     */
667
-    private function removeAlreadyRegisteredDataForScriptHandle($script_handle)
668
-    {
669
-        if (isset($this->script_handles_with_data[$script_handle])) {
670
-            global $wp_scripts;
671
-            $unset_handle = false;
672
-            if ($wp_scripts->get_data($script_handle, 'data')) {
673
-                unset($wp_scripts->registered[$script_handle]->extra['data']);
674
-                $unset_handle = true;
675
-            }
676
-            //deal with inline_scripts
677
-            if ($wp_scripts->get_data($script_handle, 'before')) {
678
-                unset($wp_scripts->registered[$script_handle]->extra['before']);
679
-                $unset_handle = true;
680
-            }
681
-            if ($wp_scripts->get_data($script_handle, 'after')) {
682
-                unset($wp_scripts->registered[$script_handle]->extra['after']);
683
-            }
684
-            if ($unset_handle) {
685
-                unset($this->script_handles_with_data[$script_handle]);
686
-            }
687
-        }
688
-    }
689
-
690
-
691
-    /**
692
-     * Registers assets that are used in the WordPress admin.
693
-     */
694
-    private function registerAdminAssets()
695
-    {
696
-        wp_register_script(
697
-            'ee-wp-plugins-page',
698
-            $this->getJsUrl(self::ASSET_NAMESPACE, 'wp-plugins-page'),
699
-            array(
700
-                'jquery',
701
-                'ee-vendor-react'
702
-            ),
703
-            null,
704
-            true
705
-        );
706
-        wp_register_style(
707
-            'ee-wp-plugins-page',
708
-            $this->getCssUrl(self::ASSET_NAMESPACE, 'wp-plugins-page'),
709
-            array(),
710
-            null
711
-        );
712
-        $this->registerTranslationsForHandles(array('ee-wp-plugins-page'));
713
-    }
714
-
715
-
716
-    /**
717
-     * All handles that are registered via the registry that might have translations have their translations registered
718
-     *
719
-     * @param array $handles_to_register
720
-     */
721
-    private function registerTranslationsForHandles(array $handles_to_register)
722
-    {
723
-        foreach($handles_to_register as $handle) {
724
-            $this->i18n_registry->registerScriptI18n($handle);
725
-        }
726
-    }
652
+	private function removeAlreadyRegisteredDataForScriptHandles()
653
+	{
654
+		if (empty($this->script_handles_with_data)) {
655
+			return;
656
+		}
657
+		foreach ($this->script_handles_with_data as $script_handle) {
658
+			$this->removeAlreadyRegisteredDataForScriptHandle($script_handle);
659
+		}
660
+	}
661
+
662
+
663
+	/**
664
+	 * Removes any data dependency registered in WP_Scripts if its set.
665
+	 * @param string $script_handle
666
+	 */
667
+	private function removeAlreadyRegisteredDataForScriptHandle($script_handle)
668
+	{
669
+		if (isset($this->script_handles_with_data[$script_handle])) {
670
+			global $wp_scripts;
671
+			$unset_handle = false;
672
+			if ($wp_scripts->get_data($script_handle, 'data')) {
673
+				unset($wp_scripts->registered[$script_handle]->extra['data']);
674
+				$unset_handle = true;
675
+			}
676
+			//deal with inline_scripts
677
+			if ($wp_scripts->get_data($script_handle, 'before')) {
678
+				unset($wp_scripts->registered[$script_handle]->extra['before']);
679
+				$unset_handle = true;
680
+			}
681
+			if ($wp_scripts->get_data($script_handle, 'after')) {
682
+				unset($wp_scripts->registered[$script_handle]->extra['after']);
683
+			}
684
+			if ($unset_handle) {
685
+				unset($this->script_handles_with_data[$script_handle]);
686
+			}
687
+		}
688
+	}
689
+
690
+
691
+	/**
692
+	 * Registers assets that are used in the WordPress admin.
693
+	 */
694
+	private function registerAdminAssets()
695
+	{
696
+		wp_register_script(
697
+			'ee-wp-plugins-page',
698
+			$this->getJsUrl(self::ASSET_NAMESPACE, 'wp-plugins-page'),
699
+			array(
700
+				'jquery',
701
+				'ee-vendor-react'
702
+			),
703
+			null,
704
+			true
705
+		);
706
+		wp_register_style(
707
+			'ee-wp-plugins-page',
708
+			$this->getCssUrl(self::ASSET_NAMESPACE, 'wp-plugins-page'),
709
+			array(),
710
+			null
711
+		);
712
+		$this->registerTranslationsForHandles(array('ee-wp-plugins-page'));
713
+	}
714
+
715
+
716
+	/**
717
+	 * All handles that are registered via the registry that might have translations have their translations registered
718
+	 *
719
+	 * @param array $handles_to_register
720
+	 */
721
+	private function registerTranslationsForHandles(array $handles_to_register)
722
+	{
723
+		foreach($handles_to_register as $handle) {
724
+			$this->i18n_registry->registerScriptI18n($handle);
725
+		}
726
+	}
727 727
 }
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
         $this->registerManifestFile(
114 114
             self::ASSET_NAMESPACE,
115 115
             $this->domain->distributionAssetsUrl(),
116
-            $this->domain->distributionAssetsPath() . 'build-manifest.json'
116
+            $this->domain->distributionAssetsPath().'build-manifest.json'
117 117
         );
118 118
         add_action('wp_enqueue_scripts', array($this, 'scripts'), 1);
119 119
         add_action('admin_enqueue_scripts', array($this, 'scripts'), 1);
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
             //js.api
171 171
             wp_register_script(
172 172
                 'eejs-api',
173
-                EE_LIBRARIES_URL . 'rest_api/assets/js/eejs-api.min.js',
173
+                EE_LIBRARIES_URL.'rest_api/assets/js/eejs-api.min.js',
174 174
                 array('underscore', 'eejs-core'),
175 175
                 EVENT_ESPRESSO_VERSION,
176 176
                 true
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
             $this->jsdata['eejs_api_nonce'] = wp_create_nonce('wp_rest');
179 179
             $this->jsdata['paths'] = array('rest_route' => rest_url('ee/v4.8.36/'));
180 180
         }
181
-        if (! is_admin()) {
181
+        if ( ! is_admin()) {
182 182
             $this->loadCoreCss();
183 183
         }
184 184
         $this->registerTranslationsForHandles(array('eejs-core'));
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
         $this->removeAlreadyRegisteredDataForScriptHandles();
203 203
         wp_add_inline_script(
204 204
             'eejs-core',
205
-            'var eejsdata=' . wp_json_encode(array('data' => $this->jsdata)),
205
+            'var eejsdata='.wp_json_encode(array('data' => $this->jsdata)),
206 206
             'before'
207 207
         );
208 208
         wp_localize_script('espresso_core', 'eei18n', EE_Registry::$i18n_js_strings);
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
      */
282 282
     public function addTemplate($template_reference, $template_content)
283 283
     {
284
-        if (! isset($this->jsdata['templates'])) {
284
+        if ( ! isset($this->jsdata['templates'])) {
285 285
             $this->jsdata['templates'] = array();
286 286
         }
287 287
         //no overrides allowed.
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
             return;
430 430
         }
431 431
         $this->manifest_data[$namespace] = $this->decodeManifestFile($manifest_file);
432
-        if (! isset($this->manifest_data[$namespace]['url_base'])) {
432
+        if ( ! isset($this->manifest_data[$namespace]['url_base'])) {
433 433
             $this->manifest_data[$namespace]['url_base'] = trailingslashit($url_base);
434 434
         }
435 435
     }
@@ -446,7 +446,7 @@  discard block
 block discarded – undo
446 446
      */
447 447
     private function decodeManifestFile($manifest_file)
448 448
     {
449
-        if (! file_exists($manifest_file)) {
449
+        if ( ! file_exists($manifest_file)) {
450 450
             throw new InvalidFilePathException($manifest_file);
451 451
         }
452 452
         return json_decode(file_get_contents($manifest_file), true);
@@ -501,9 +501,9 @@  discard block
 block discarded – undo
501 501
     private function loadCoreCss()
502 502
     {
503 503
         if ($this->template_config->enable_default_style) {
504
-            $default_stylesheet_path = is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')
504
+            $default_stylesheet_path = is_readable(EVENT_ESPRESSO_UPLOAD_DIR.'css/style.css')
505 505
                 ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css'
506
-                : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css';
506
+                : EE_GLOBAL_ASSETS_URL.'css/espresso_default.css';
507 507
             wp_register_style(
508 508
                 'espresso_default',
509 509
                 $default_stylesheet_path,
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
             if ($this->template_config->custom_style_sheet !== null) {
515 515
                 wp_register_style(
516 516
                     'espresso_custom_css',
517
-                    EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet,
517
+                    EVENT_ESPRESSO_UPLOAD_URL.'css/'.$this->template_config->custom_style_sheet,
518 518
                     array('espresso_default'),
519 519
                     EVENT_ESPRESSO_VERSION
520 520
                 );
@@ -532,7 +532,7 @@  discard block
 block discarded – undo
532 532
         // load core js
533 533
         wp_register_script(
534 534
             'espresso_core',
535
-            EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
535
+            EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js',
536 536
             array('jquery'),
537 537
             EVENT_ESPRESSO_VERSION,
538 538
             true
@@ -549,14 +549,14 @@  discard block
 block discarded – undo
549 549
         // register jQuery Validate and additional methods
550 550
         wp_register_script(
551 551
             'jquery-validate',
552
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js',
552
+            EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.min.js',
553 553
             array('jquery'),
554 554
             '1.15.0',
555 555
             true
556 556
         );
557 557
         wp_register_script(
558 558
             'jquery-validate-extra-methods',
559
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js',
559
+            EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.additional-methods.min.js',
560 560
             array('jquery', 'jquery-validate'),
561 561
             '1.15.0',
562 562
             true
@@ -574,14 +574,14 @@  discard block
 block discarded – undo
574 574
         // @link http://josscrowcroft.github.io/accounting.js/
575 575
         wp_register_script(
576 576
             'ee-accounting-core',
577
-            EE_THIRD_PARTY_URL . 'accounting/accounting.js',
577
+            EE_THIRD_PARTY_URL.'accounting/accounting.js',
578 578
             array('underscore'),
579 579
             '0.3.2',
580 580
             true
581 581
         );
582 582
         wp_register_script(
583 583
             'ee-accounting',
584
-            EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js',
584
+            EE_GLOBAL_ASSETS_URL.'scripts/ee-accounting-config.js',
585 585
             array('ee-accounting-core'),
586 586
             EVENT_ESPRESSO_VERSION,
587 587
             true
@@ -720,7 +720,7 @@  discard block
 block discarded – undo
720 720
      */
721 721
     private function registerTranslationsForHandles(array $handles_to_register)
722 722
     {
723
-        foreach($handles_to_register as $handle) {
723
+        foreach ($handles_to_register as $handle) {
724 724
             $this->i18n_registry->registerScriptI18n($handle);
725 725
         }
726 726
     }
Please login to merge, or discard this patch.
espresso.php 1 patch
Indentation   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -38,103 +38,103 @@
 block discarded – undo
38 38
  * @since       4.0
39 39
  */
40 40
 if (function_exists('espresso_version')) {
41
-    if (! function_exists('espresso_duplicate_plugin_error')) {
42
-        /**
43
-         *    espresso_duplicate_plugin_error
44
-         *    displays if more than one version of EE is activated at the same time
45
-         */
46
-        function espresso_duplicate_plugin_error()
47
-        {
48
-            ?>
41
+	if (! function_exists('espresso_duplicate_plugin_error')) {
42
+		/**
43
+		 *    espresso_duplicate_plugin_error
44
+		 *    displays if more than one version of EE is activated at the same time
45
+		 */
46
+		function espresso_duplicate_plugin_error()
47
+		{
48
+			?>
49 49
             <div class="error">
50 50
                 <p>
51 51
                     <?php
52
-                    echo esc_html__(
53
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
-                        'event_espresso'
55
-                    ); ?>
52
+					echo esc_html__(
53
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
+						'event_espresso'
55
+					); ?>
56 56
                 </p>
57 57
             </div>
58 58
             <?php
59
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
60
-        }
61
-    }
62
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
59
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
60
+		}
61
+	}
62
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
63 63
 
64 64
 } else {
65
-    define('EE_MIN_PHP_VER_REQUIRED', '5.4.0');
66
-    if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
67
-        /**
68
-         * espresso_minimum_php_version_error
69
-         * @return void
70
-         */
71
-        function espresso_minimum_php_version_error()
72
-        {
73
-            ?>
65
+	define('EE_MIN_PHP_VER_REQUIRED', '5.4.0');
66
+	if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
67
+		/**
68
+		 * espresso_minimum_php_version_error
69
+		 * @return void
70
+		 */
71
+		function espresso_minimum_php_version_error()
72
+		{
73
+			?>
74 74
             <div class="error">
75 75
                 <p>
76 76
                     <?php
77
-                    printf(
78
-                        esc_html__(
79
-                            'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
-                            'event_espresso'
81
-                        ),
82
-                        EE_MIN_PHP_VER_REQUIRED,
83
-                        PHP_VERSION,
84
-                        '<br/>',
85
-                        '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
-                    );
87
-                    ?>
77
+					printf(
78
+						esc_html__(
79
+							'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
+							'event_espresso'
81
+						),
82
+						EE_MIN_PHP_VER_REQUIRED,
83
+						PHP_VERSION,
84
+						'<br/>',
85
+						'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
+					);
87
+					?>
88 88
                 </p>
89 89
             </div>
90 90
             <?php
91
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
92
-        }
91
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
92
+		}
93 93
 
94
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
-    } else {
96
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
-        /**
98
-         * espresso_version
99
-         * Returns the plugin version
100
-         *
101
-         * @return string
102
-         */
103
-        function espresso_version()
104
-        {
105
-            return apply_filters('FHEE__espresso__espresso_version', '4.9.62.rc.010');
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.62.rc.010');
106
+		}
107 107
 
108
-        /**
109
-         * espresso_plugin_activation
110
-         * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
-         */
112
-        function espresso_plugin_activation()
113
-        {
114
-            update_option('ee_espresso_activation', true);
115
-        }
108
+		/**
109
+		 * espresso_plugin_activation
110
+		 * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
+		 */
112
+		function espresso_plugin_activation()
113
+		{
114
+			update_option('ee_espresso_activation', true);
115
+		}
116 116
 
117
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
117
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
118 118
 
119
-        require_once __DIR__ . '/core/bootstrap_espresso.php';
120
-        bootstrap_espresso();
121
-    }
119
+		require_once __DIR__ . '/core/bootstrap_espresso.php';
120
+		bootstrap_espresso();
121
+	}
122 122
 }
123 123
 if (! function_exists('espresso_deactivate_plugin')) {
124
-    /**
125
-     *    deactivate_plugin
126
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
-     *
128
-     * @access public
129
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
-     * @return    void
131
-     */
132
-    function espresso_deactivate_plugin($plugin_basename = '')
133
-    {
134
-        if (! function_exists('deactivate_plugins')) {
135
-            require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
-        }
137
-        unset($_GET['activate'], $_REQUEST['activate']);
138
-        deactivate_plugins($plugin_basename);
139
-    }
124
+	/**
125
+	 *    deactivate_plugin
126
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
+	 *
128
+	 * @access public
129
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
+	 * @return    void
131
+	 */
132
+	function espresso_deactivate_plugin($plugin_basename = '')
133
+	{
134
+		if (! function_exists('deactivate_plugins')) {
135
+			require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
+		}
137
+		unset($_GET['activate'], $_REQUEST['activate']);
138
+		deactivate_plugins($plugin_basename);
139
+	}
140 140
 }
Please login to merge, or discard this patch.
core/EE_Config.core.php 1 patch
Indentation   +3092 added lines, -3092 removed lines patch added patch discarded remove patch
@@ -17,2474 +17,2474 @@  discard block
 block discarded – undo
17 17
 final class EE_Config implements ResettableInterface
18 18
 {
19 19
 
20
-    const OPTION_NAME        = 'ee_config';
20
+	const OPTION_NAME        = 'ee_config';
21
+
22
+	const LOG_NAME           = 'ee_config_log';
23
+
24
+	const LOG_LENGTH         = 100;
25
+
26
+	const ADDON_OPTION_NAMES = 'ee_config_option_names';
27
+
28
+
29
+	/**
30
+	 *    instance of the EE_Config object
31
+	 *
32
+	 * @var    EE_Config $_instance
33
+	 * @access    private
34
+	 */
35
+	private static $_instance;
36
+
37
+	/**
38
+	 * @var boolean $_logging_enabled
39
+	 */
40
+	private static $_logging_enabled = false;
41
+
42
+	/**
43
+	 * @var LegacyShortcodesManager $legacy_shortcodes_manager
44
+	 */
45
+	private $legacy_shortcodes_manager;
46
+
47
+	/**
48
+	 * An StdClass whose property names are addon slugs,
49
+	 * and values are their config classes
50
+	 *
51
+	 * @var StdClass
52
+	 */
53
+	public $addons;
54
+
55
+	/**
56
+	 * @var EE_Admin_Config
57
+	 */
58
+	public $admin;
59
+
60
+	/**
61
+	 * @var EE_Core_Config
62
+	 */
63
+	public $core;
64
+
65
+	/**
66
+	 * @var EE_Currency_Config
67
+	 */
68
+	public $currency;
69
+
70
+	/**
71
+	 * @var EE_Organization_Config
72
+	 */
73
+	public $organization;
74
+
75
+	/**
76
+	 * @var EE_Registration_Config
77
+	 */
78
+	public $registration;
79
+
80
+	/**
81
+	 * @var EE_Template_Config
82
+	 */
83
+	public $template_settings;
84
+
85
+	/**
86
+	 * Holds EE environment values.
87
+	 *
88
+	 * @var EE_Environment_Config
89
+	 */
90
+	public $environment;
91
+
92
+	/**
93
+	 * settings pertaining to Google maps
94
+	 *
95
+	 * @var EE_Map_Config
96
+	 */
97
+	public $map_settings;
98
+
99
+	/**
100
+	 * settings pertaining to Taxes
101
+	 *
102
+	 * @var EE_Tax_Config
103
+	 */
104
+	public $tax_settings;
105
+
106
+
107
+	/**
108
+	 * Settings pertaining to global messages settings.
109
+	 *
110
+	 * @var EE_Messages_Config
111
+	 */
112
+	public $messages;
113
+
114
+	/**
115
+	 * @deprecated
116
+	 * @var EE_Gateway_Config
117
+	 */
118
+	public $gateway;
119
+
120
+	/**
121
+	 * @var    array $_addon_option_names
122
+	 * @access    private
123
+	 */
124
+	private $_addon_option_names = array();
125
+
126
+	/**
127
+	 * @var    array $_module_route_map
128
+	 * @access    private
129
+	 */
130
+	private static $_module_route_map = array();
131
+
132
+	/**
133
+	 * @var    array $_module_forward_map
134
+	 * @access    private
135
+	 */
136
+	private static $_module_forward_map = array();
137
+
138
+	/**
139
+	 * @var    array $_module_view_map
140
+	 * @access    private
141
+	 */
142
+	private static $_module_view_map = array();
143
+
144
+
145
+
146
+	/**
147
+	 * @singleton method used to instantiate class object
148
+	 * @access    public
149
+	 * @return EE_Config instance
150
+	 */
151
+	public static function instance()
152
+	{
153
+		// check if class object is instantiated, and instantiated properly
154
+		if (! self::$_instance instanceof EE_Config) {
155
+			self::$_instance = new self();
156
+		}
157
+		return self::$_instance;
158
+	}
159
+
160
+
161
+
162
+	/**
163
+	 * Resets the config
164
+	 *
165
+	 * @param bool    $hard_reset    if TRUE, sets EE_CONFig back to its original settings in the database. If FALSE
166
+	 *                               (default) leaves the database alone, and merely resets the EE_Config object to
167
+	 *                               reflect its state in the database
168
+	 * @param boolean $reinstantiate if TRUE (default) call instance() and return it. Otherwise, just leave
169
+	 *                               $_instance as NULL. Useful in case you want to forget about the old instance on
170
+	 *                               EE_Config, but might not be ready to instantiate EE_Config currently (eg if the
171
+	 *                               site was put into maintenance mode)
172
+	 * @return EE_Config
173
+	 */
174
+	public static function reset($hard_reset = false, $reinstantiate = true)
175
+	{
176
+		if (self::$_instance instanceof EE_Config) {
177
+			if ($hard_reset) {
178
+				self::$_instance->legacy_shortcodes_manager = null;
179
+				self::$_instance->_addon_option_names = array();
180
+				self::$_instance->_initialize_config();
181
+				self::$_instance->update_espresso_config();
182
+			}
183
+			self::$_instance->update_addon_option_names();
184
+		}
185
+		self::$_instance = null;
186
+		//we don't need to reset the static properties imo because those should
187
+		//only change when a module is added or removed. Currently we don't
188
+		//support removing a module during a request when it previously existed
189
+		if ($reinstantiate) {
190
+			return self::instance();
191
+		} else {
192
+			return null;
193
+		}
194
+	}
195
+
196
+
197
+
198
+	/**
199
+	 *    class constructor
200
+	 *
201
+	 * @access    private
202
+	 */
203
+	private function __construct()
204
+	{
205
+		do_action('AHEE__EE_Config__construct__begin', $this);
206
+		EE_Config::$_logging_enabled = apply_filters('FHEE__EE_Config___construct__logging_enabled', false);
207
+		// setup empty config classes
208
+		$this->_initialize_config();
209
+		// load existing EE site settings
210
+		$this->_load_core_config();
211
+		// confirm everything loaded correctly and set filtered defaults if not
212
+		$this->_verify_config();
213
+		//  register shortcodes and modules
214
+		add_action(
215
+			'AHEE__EE_System__register_shortcodes_modules_and_widgets',
216
+			array($this, 'register_shortcodes_and_modules'),
217
+			999
218
+		);
219
+		//  initialize shortcodes and modules
220
+		add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'initialize_shortcodes_and_modules'));
221
+		// register widgets
222
+		add_action('widgets_init', array($this, 'widgets_init'), 10);
223
+		// shutdown
224
+		add_action('shutdown', array($this, 'shutdown'), 10);
225
+		// construct__end hook
226
+		do_action('AHEE__EE_Config__construct__end', $this);
227
+		// hardcoded hack
228
+		$this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014';
229
+	}
230
+
231
+
232
+
233
+	/**
234
+	 * @return boolean
235
+	 */
236
+	public static function logging_enabled()
237
+	{
238
+		return self::$_logging_enabled;
239
+	}
240
+
241
+
242
+
243
+	/**
244
+	 * use to get the current theme if needed from static context
245
+	 *
246
+	 * @return string current theme set.
247
+	 */
248
+	public static function get_current_theme()
249
+	{
250
+		return isset(self::$_instance->template_settings->current_espresso_theme)
251
+			? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014';
252
+	}
253
+
254
+
255
+
256
+	/**
257
+	 *        _initialize_config
258
+	 *
259
+	 * @access private
260
+	 * @return void
261
+	 */
262
+	private function _initialize_config()
263
+	{
264
+		EE_Config::trim_log();
265
+		//set defaults
266
+		$this->_addon_option_names = get_option(EE_Config::ADDON_OPTION_NAMES, array());
267
+		$this->addons = new stdClass();
268
+		// set _module_route_map
269
+		EE_Config::$_module_route_map = array();
270
+		// set _module_forward_map
271
+		EE_Config::$_module_forward_map = array();
272
+		// set _module_view_map
273
+		EE_Config::$_module_view_map = array();
274
+	}
275
+
276
+
277
+
278
+	/**
279
+	 *        load core plugin configuration
280
+	 *
281
+	 * @access private
282
+	 * @return void
283
+	 */
284
+	private function _load_core_config()
285
+	{
286
+		// load_core_config__start hook
287
+		do_action('AHEE__EE_Config___load_core_config__start', $this);
288
+		$espresso_config = $this->get_espresso_config();
289
+		foreach ($espresso_config as $config => $settings) {
290
+			// load_core_config__start hook
291
+			$settings = apply_filters(
292
+				'FHEE__EE_Config___load_core_config__config_settings',
293
+				$settings,
294
+				$config,
295
+				$this
296
+			);
297
+			if (is_object($settings) && property_exists($this, $config)) {
298
+				$this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings);
299
+				//call configs populate method to ensure any defaults are set for empty values.
300
+				if (method_exists($settings, 'populate')) {
301
+					$this->{$config}->populate();
302
+				}
303
+				if (method_exists($settings, 'do_hooks')) {
304
+					$this->{$config}->do_hooks();
305
+				}
306
+			}
307
+		}
308
+		if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', false)) {
309
+			$this->update_espresso_config();
310
+		}
311
+		// load_core_config__end hook
312
+		do_action('AHEE__EE_Config___load_core_config__end', $this);
313
+	}
314
+
315
+
316
+
317
+	/**
318
+	 *    _verify_config
319
+	 *
320
+	 * @access    protected
321
+	 * @return    void
322
+	 */
323
+	protected function _verify_config()
324
+	{
325
+		$this->core = $this->core instanceof EE_Core_Config
326
+			? $this->core
327
+			: new EE_Core_Config();
328
+		$this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core);
329
+		$this->organization = $this->organization instanceof EE_Organization_Config
330
+			? $this->organization
331
+			: new EE_Organization_Config();
332
+		$this->organization = apply_filters(
333
+			'FHEE__EE_Config___initialize_config__organization',
334
+			$this->organization
335
+		);
336
+		$this->currency = $this->currency instanceof EE_Currency_Config
337
+			? $this->currency
338
+			: new EE_Currency_Config();
339
+		$this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency);
340
+		$this->registration = $this->registration instanceof EE_Registration_Config
341
+			? $this->registration
342
+			: new EE_Registration_Config();
343
+		$this->registration = apply_filters(
344
+			'FHEE__EE_Config___initialize_config__registration',
345
+			$this->registration
346
+		);
347
+		$this->admin = $this->admin instanceof EE_Admin_Config
348
+			? $this->admin
349
+			: new EE_Admin_Config();
350
+		$this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin);
351
+		$this->template_settings = $this->template_settings instanceof EE_Template_Config
352
+			? $this->template_settings
353
+			: new EE_Template_Config();
354
+		$this->template_settings = apply_filters(
355
+			'FHEE__EE_Config___initialize_config__template_settings',
356
+			$this->template_settings
357
+		);
358
+		$this->map_settings = $this->map_settings instanceof EE_Map_Config
359
+			? $this->map_settings
360
+			: new EE_Map_Config();
361
+		$this->map_settings = apply_filters('FHEE__EE_Config___initialize_config__map_settings',
362
+			$this->map_settings);
363
+		$this->environment = $this->environment instanceof EE_Environment_Config
364
+			? $this->environment
365
+			: new EE_Environment_Config();
366
+		$this->environment = apply_filters('FHEE__EE_Config___initialize_config__environment',
367
+			$this->environment);
368
+		$this->tax_settings = $this->tax_settings instanceof EE_Tax_Config
369
+			? $this->tax_settings
370
+			: new EE_Tax_Config();
371
+		$this->tax_settings = apply_filters('FHEE__EE_Config___initialize_config__tax_settings',
372
+			$this->tax_settings);
373
+		$this->messages = apply_filters('FHEE__EE_Config__initialize_config__messages', $this->messages);
374
+		$this->messages = $this->messages instanceof EE_Messages_Config
375
+			? $this->messages
376
+			: new EE_Messages_Config();
377
+		$this->gateway = $this->gateway instanceof EE_Gateway_Config
378
+			? $this->gateway
379
+			: new EE_Gateway_Config();
380
+		$this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway);
381
+		$this->legacy_shortcodes_manager = null;
382
+	}
383
+
384
+
385
+	/**
386
+	 *    get_espresso_config
387
+	 *
388
+	 * @access    public
389
+	 * @return    array of espresso config stuff
390
+	 */
391
+	public function get_espresso_config()
392
+	{
393
+		// grab espresso configuration
394
+		return apply_filters(
395
+			'FHEE__EE_Config__get_espresso_config__CFG',
396
+			get_option(EE_Config::OPTION_NAME, array())
397
+		);
398
+	}
399
+
400
+
401
+
402
+	/**
403
+	 *    double_check_config_comparison
404
+	 *
405
+	 * @access    public
406
+	 * @param string $option
407
+	 * @param        $old_value
408
+	 * @param        $value
409
+	 */
410
+	public function double_check_config_comparison($option = '', $old_value, $value)
411
+	{
412
+		// make sure we're checking the ee config
413
+		if ($option === EE_Config::OPTION_NAME) {
414
+			// run a loose comparison of the old value against the new value for type and properties,
415
+			// but NOT exact instance like WP update_option does (ie: NOT type safe comparison)
416
+			if ($value != $old_value) {
417
+				// if they are NOT the same, then remove the hook,
418
+				// which means the subsequent update results will be based solely on the update query results
419
+				// the reason we do this is because, as stated above,
420
+				// WP update_option performs an exact instance comparison (===) on any update values passed to it
421
+				// this happens PRIOR to serialization and any subsequent update.
422
+				// If values are found to match their previous old value,
423
+				// then WP bails before performing any update.
424
+				// Since we are passing the EE_Config object, it is comparing the EXACT instance of the saved version
425
+				// it just pulled from the db, with the one being passed to it (which will not match).
426
+				// HOWEVER, once the object is serialized and passed off to MySQL to update,
427
+				// MySQL MAY ALSO NOT perform the update because
428
+				// the string it sees in the db looks the same as the new one it has been passed!!!
429
+				// This results in the query returning an "affected rows" value of ZERO,
430
+				// which gets returned immediately by WP update_option and looks like an error.
431
+				remove_action('update_option', array($this, 'check_config_updated'));
432
+			}
433
+		}
434
+	}
435
+
436
+
437
+
438
+	/**
439
+	 *    update_espresso_config
440
+	 *
441
+	 * @access   public
442
+	 */
443
+	protected function _reset_espresso_addon_config()
444
+	{
445
+		$this->_addon_option_names = array();
446
+		foreach ($this->addons as $addon_name => $addon_config_obj) {
447
+			$addon_config_obj = maybe_unserialize($addon_config_obj);
448
+			if ($addon_config_obj instanceof EE_Config_Base) {
449
+				$this->update_config('addons', $addon_name, $addon_config_obj, false);
450
+			}
451
+			$this->addons->{$addon_name} = null;
452
+		}
453
+	}
454
+
455
+
456
+
457
+	/**
458
+	 *    update_espresso_config
459
+	 *
460
+	 * @access   public
461
+	 * @param   bool $add_success
462
+	 * @param   bool $add_error
463
+	 * @return   bool
464
+	 */
465
+	public function update_espresso_config($add_success = false, $add_error = true)
466
+	{
467
+		// don't allow config updates during WP heartbeats
468
+		if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
469
+			return false;
470
+		}
471
+		// commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197
472
+		//$clone = clone( self::$_instance );
473
+		//self::$_instance = NULL;
474
+		do_action('AHEE__EE_Config__update_espresso_config__begin', $this);
475
+		$this->_reset_espresso_addon_config();
476
+		// hook into update_option because that happens AFTER the ( $value === $old_value ) conditional
477
+		// but BEFORE the actual update occurs
478
+		add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3);
479
+		// don't want to persist legacy_shortcodes_manager, but don't want to lose it either
480
+		$legacy_shortcodes_manager = $this->legacy_shortcodes_manager;
481
+		$this->legacy_shortcodes_manager = null;
482
+		// now update "ee_config"
483
+		$saved = update_option(EE_Config::OPTION_NAME, $this);
484
+		$this->legacy_shortcodes_manager = $legacy_shortcodes_manager;
485
+		EE_Config::log(EE_Config::OPTION_NAME);
486
+		// if not saved... check if the hook we just added still exists;
487
+		// if it does, it means one of two things:
488
+		// 		that update_option bailed at the ( $value === $old_value ) conditional,
489
+		//		 or...
490
+		// 		the db update query returned 0 rows affected
491
+		// 		(probably because the data  value was the same from it's perspective)
492
+		// so the existence of the hook means that a negative result from update_option is NOT an error,
493
+		// but just means no update occurred, so don't display an error to the user.
494
+		// BUT... if update_option returns FALSE, AND the hook is missing,
495
+		// then it means that something truly went wrong
496
+		$saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved;
497
+		// remove our action since we don't want it in the system anymore
498
+		remove_action('update_option', array($this, 'double_check_config_comparison'), 1);
499
+		do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved);
500
+		//self::$_instance = $clone;
501
+		//unset( $clone );
502
+		// if config remains the same or was updated successfully
503
+		if ($saved) {
504
+			if ($add_success) {
505
+				EE_Error::add_success(
506
+					__('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'),
507
+					__FILE__,
508
+					__FUNCTION__,
509
+					__LINE__
510
+				);
511
+			}
512
+			return true;
513
+		} else {
514
+			if ($add_error) {
515
+				EE_Error::add_error(
516
+					__('The Event Espresso Configuration Settings were not updated.', 'event_espresso'),
517
+					__FILE__,
518
+					__FUNCTION__,
519
+					__LINE__
520
+				);
521
+			}
522
+			return false;
523
+		}
524
+	}
525
+
526
+
527
+
528
+	/**
529
+	 *    _verify_config_params
530
+	 *
531
+	 * @access    private
532
+	 * @param    string         $section
533
+	 * @param    string         $name
534
+	 * @param    string         $config_class
535
+	 * @param    EE_Config_Base $config_obj
536
+	 * @param    array          $tests_to_run
537
+	 * @param    bool           $display_errors
538
+	 * @return    bool    TRUE on success, FALSE on fail
539
+	 */
540
+	private function _verify_config_params(
541
+		$section = '',
542
+		$name = '',
543
+		$config_class = '',
544
+		$config_obj = null,
545
+		$tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8),
546
+		$display_errors = true
547
+	) {
548
+		try {
549
+			foreach ($tests_to_run as $test) {
550
+				switch ($test) {
551
+					// TEST #1 : check that section was set
552
+					case 1 :
553
+						if (empty($section)) {
554
+							if ($display_errors) {
555
+								throw new EE_Error(
556
+									sprintf(
557
+										__(
558
+											'No configuration section has been provided while attempting to save "%s".',
559
+											'event_espresso'
560
+										),
561
+										$config_class
562
+									)
563
+								);
564
+							}
565
+							return false;
566
+						}
567
+						break;
568
+					// TEST #2 : check that settings section exists
569
+					case 2 :
570
+						if (! isset($this->{$section})) {
571
+							if ($display_errors) {
572
+								throw new EE_Error(
573
+									sprintf(
574
+										__('The "%s" configuration section does not exist.', 'event_espresso'),
575
+										$section
576
+									)
577
+								);
578
+							}
579
+							return false;
580
+						}
581
+						break;
582
+					// TEST #3 : check that section is the proper format
583
+					case 3 :
584
+						if (
585
+						! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass)
586
+						) {
587
+							if ($display_errors) {
588
+								throw new EE_Error(
589
+									sprintf(
590
+										__(
591
+											'The "%s" configuration settings have not been formatted correctly.',
592
+											'event_espresso'
593
+										),
594
+										$section
595
+									)
596
+								);
597
+							}
598
+							return false;
599
+						}
600
+						break;
601
+					// TEST #4 : check that config section name has been set
602
+					case 4 :
603
+						if (empty($name)) {
604
+							if ($display_errors) {
605
+								throw new EE_Error(
606
+									__(
607
+										'No name has been provided for the specific configuration section.',
608
+										'event_espresso'
609
+									)
610
+								);
611
+							}
612
+							return false;
613
+						}
614
+						break;
615
+					// TEST #5 : check that a config class name has been set
616
+					case 5 :
617
+						if (empty($config_class)) {
618
+							if ($display_errors) {
619
+								throw new EE_Error(
620
+									__(
621
+										'No class name has been provided for the specific configuration section.',
622
+										'event_espresso'
623
+									)
624
+								);
625
+							}
626
+							return false;
627
+						}
628
+						break;
629
+					// TEST #6 : verify config class is accessible
630
+					case 6 :
631
+						if (! class_exists($config_class)) {
632
+							if ($display_errors) {
633
+								throw new EE_Error(
634
+									sprintf(
635
+										__(
636
+											'The "%s" class does not exist. Please ensure that an autoloader has been set for it.',
637
+											'event_espresso'
638
+										),
639
+										$config_class
640
+									)
641
+								);
642
+							}
643
+							return false;
644
+						}
645
+						break;
646
+					// TEST #7 : check that config has even been set
647
+					case 7 :
648
+						if (! isset($this->{$section}->{$name})) {
649
+							if ($display_errors) {
650
+								throw new EE_Error(
651
+									sprintf(
652
+										__('No configuration has been set for "%1$s->%2$s".', 'event_espresso'),
653
+										$section,
654
+										$name
655
+									)
656
+								);
657
+							}
658
+							return false;
659
+						} else {
660
+							// and make sure it's not serialized
661
+							$this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name});
662
+						}
663
+						break;
664
+					// TEST #8 : check that config is the requested type
665
+					case 8 :
666
+						if (! $this->{$section}->{$name} instanceof $config_class) {
667
+							if ($display_errors) {
668
+								throw new EE_Error(
669
+									sprintf(
670
+										__(
671
+											'The configuration for "%1$s->%2$s" is not of the "%3$s" class.',
672
+											'event_espresso'
673
+										),
674
+										$section,
675
+										$name,
676
+										$config_class
677
+									)
678
+								);
679
+							}
680
+							return false;
681
+						}
682
+						break;
683
+					// TEST #9 : verify config object
684
+					case 9 :
685
+						if (! $config_obj instanceof EE_Config_Base) {
686
+							if ($display_errors) {
687
+								throw new EE_Error(
688
+									sprintf(
689
+										__('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'),
690
+										print_r($config_obj, true)
691
+									)
692
+								);
693
+							}
694
+							return false;
695
+						}
696
+						break;
697
+				}
698
+			}
699
+		} catch (EE_Error $e) {
700
+			$e->get_error();
701
+		}
702
+		// you have successfully run the gauntlet
703
+		return true;
704
+	}
705
+
706
+
707
+
708
+	/**
709
+	 *    _generate_config_option_name
710
+	 *
711
+	 * @access        protected
712
+	 * @param        string $section
713
+	 * @param        string $name
714
+	 * @return        string
715
+	 */
716
+	private function _generate_config_option_name($section = '', $name = '')
717
+	{
718
+		return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name));
719
+	}
720
+
721
+
722
+
723
+	/**
724
+	 *    _set_config_class
725
+	 * ensures that a config class is set, either from a passed config class or one generated from the config name
726
+	 *
727
+	 * @access    private
728
+	 * @param    string $config_class
729
+	 * @param    string $name
730
+	 * @return    string
731
+	 */
732
+	private function _set_config_class($config_class = '', $name = '')
733
+	{
734
+		return ! empty($config_class)
735
+			? $config_class
736
+			: str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config';
737
+	}
738
+
739
+
740
+
741
+	/**
742
+	 *    set_config
743
+	 *
744
+	 * @access    protected
745
+	 * @param    string         $section
746
+	 * @param    string         $name
747
+	 * @param    string         $config_class
748
+	 * @param    EE_Config_Base $config_obj
749
+	 * @return    EE_Config_Base
750
+	 */
751
+	public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null)
752
+	{
753
+		// ensure config class is set to something
754
+		$config_class = $this->_set_config_class($config_class, $name);
755
+		// run tests 1-4, 6, and 7 to verify all config params are set and valid
756
+		if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
757
+			return null;
758
+		}
759
+		$config_option_name = $this->_generate_config_option_name($section, $name);
760
+		// if the config option name hasn't been added yet to the list of option names we're tracking, then do so now
761
+		if (! isset($this->_addon_option_names[$config_option_name])) {
762
+			$this->_addon_option_names[$config_option_name] = $config_class;
763
+			$this->update_addon_option_names();
764
+		}
765
+		// verify the incoming config object but suppress errors
766
+		if (! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
767
+			$config_obj = new $config_class();
768
+		}
769
+		if (get_option($config_option_name)) {
770
+			EE_Config::log($config_option_name);
771
+			update_option($config_option_name, $config_obj);
772
+			$this->{$section}->{$name} = $config_obj;
773
+			return $this->{$section}->{$name};
774
+		} else {
775
+			// create a wp-option for this config
776
+			if (add_option($config_option_name, $config_obj, '', 'no')) {
777
+				$this->{$section}->{$name} = maybe_unserialize($config_obj);
778
+				return $this->{$section}->{$name};
779
+			} else {
780
+				EE_Error::add_error(
781
+					sprintf(__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class),
782
+					__FILE__,
783
+					__FUNCTION__,
784
+					__LINE__
785
+				);
786
+				return null;
787
+			}
788
+		}
789
+	}
790
+
791
+
792
+
793
+	/**
794
+	 *    update_config
795
+	 * Important: the config object must ALREADY be set, otherwise this will produce an error.
796
+	 *
797
+	 * @access    public
798
+	 * @param    string                $section
799
+	 * @param    string                $name
800
+	 * @param    EE_Config_Base|string $config_obj
801
+	 * @param    bool                  $throw_errors
802
+	 * @return    bool
803
+	 */
804
+	public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true)
805
+	{
806
+		// don't allow config updates during WP heartbeats
807
+		if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
808
+			return false;
809
+		}
810
+		$config_obj = maybe_unserialize($config_obj);
811
+		// get class name of the incoming object
812
+		$config_class = get_class($config_obj);
813
+		// run tests 1-5 and 9 to verify config
814
+		if (! $this->_verify_config_params(
815
+			$section,
816
+			$name,
817
+			$config_class,
818
+			$config_obj,
819
+			array(1, 2, 3, 4, 7, 9)
820
+		)
821
+		) {
822
+			return false;
823
+		}
824
+		$config_option_name = $this->_generate_config_option_name($section, $name);
825
+		// check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array
826
+		if (! isset($this->_addon_option_names[$config_option_name])) {
827
+			// save new config to db
828
+			if ($this->set_config($section, $name, $config_class, $config_obj)) {
829
+				return true;
830
+			}
831
+		} else {
832
+			// first check if the record already exists
833
+			$existing_config = get_option($config_option_name);
834
+			$config_obj = serialize($config_obj);
835
+			// just return if db record is already up to date (NOT type safe comparison)
836
+			if ($existing_config == $config_obj) {
837
+				$this->{$section}->{$name} = $config_obj;
838
+				return true;
839
+			} else if (update_option($config_option_name, $config_obj)) {
840
+				EE_Config::log($config_option_name);
841
+				// update wp-option for this config class
842
+				$this->{$section}->{$name} = $config_obj;
843
+				return true;
844
+			} elseif ($throw_errors) {
845
+				EE_Error::add_error(
846
+					sprintf(
847
+						__(
848
+							'The "%1$s" object stored at"%2$s" was not successfully updated in the database.',
849
+							'event_espresso'
850
+						),
851
+						$config_class,
852
+						'EE_Config->' . $section . '->' . $name
853
+					),
854
+					__FILE__,
855
+					__FUNCTION__,
856
+					__LINE__
857
+				);
858
+			}
859
+		}
860
+		return false;
861
+	}
862
+
863
+
864
+
865
+	/**
866
+	 *    get_config
867
+	 *
868
+	 * @access    public
869
+	 * @param    string $section
870
+	 * @param    string $name
871
+	 * @param    string $config_class
872
+	 * @return    mixed EE_Config_Base | NULL
873
+	 */
874
+	public function get_config($section = '', $name = '', $config_class = '')
875
+	{
876
+		// ensure config class is set to something
877
+		$config_class = $this->_set_config_class($config_class, $name);
878
+		// run tests 1-4, 6 and 7 to verify that all params have been set
879
+		if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
880
+			return null;
881
+		}
882
+		// now test if the requested config object exists, but suppress errors
883
+		if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) {
884
+			// config already exists, so pass it back
885
+			return $this->{$section}->{$name};
886
+		}
887
+		// load config option from db if it exists
888
+		$config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name));
889
+		// verify the newly retrieved config object, but suppress errors
890
+		if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
891
+			// config is good, so set it and pass it back
892
+			$this->{$section}->{$name} = $config_obj;
893
+			return $this->{$section}->{$name};
894
+		}
895
+		// oops! $config_obj is not already set and does not exist in the db, so create a new one
896
+		$config_obj = $this->set_config($section, $name, $config_class);
897
+		// verify the newly created config object
898
+		if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) {
899
+			return $this->{$section}->{$name};
900
+		} else {
901
+			EE_Error::add_error(
902
+				sprintf(__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class),
903
+				__FILE__,
904
+				__FUNCTION__,
905
+				__LINE__
906
+			);
907
+		}
908
+		return null;
909
+	}
910
+
911
+
912
+
913
+	/**
914
+	 *    get_config_option
915
+	 *
916
+	 * @access    public
917
+	 * @param    string $config_option_name
918
+	 * @return    mixed EE_Config_Base | FALSE
919
+	 */
920
+	public function get_config_option($config_option_name = '')
921
+	{
922
+		// retrieve the wp-option for this config class.
923
+		$config_option = maybe_unserialize(get_option($config_option_name, array()));
924
+		if (empty($config_option)) {
925
+			EE_Config::log($config_option_name . '-NOT-FOUND');
926
+		}
927
+		return $config_option;
928
+	}
929
+
930
+
931
+
932
+	/**
933
+	 * log
934
+	 *
935
+	 * @param string $config_option_name
936
+	 */
937
+	public static function log($config_option_name = '')
938
+	{
939
+		if (EE_Config::logging_enabled() && ! empty($config_option_name)) {
940
+			$config_log = get_option(EE_Config::LOG_NAME, array());
941
+			//copy incoming $_REQUEST and sanitize it so we can save it
942
+			$_request = $_REQUEST;
943
+			array_walk_recursive($_request, 'sanitize_text_field');
944
+			$config_log[(string)microtime(true)] = array(
945
+				'config_name' => $config_option_name,
946
+				'request'     => $_request,
947
+			);
948
+			update_option(EE_Config::LOG_NAME, $config_log);
949
+		}
950
+	}
951
+
952
+
953
+
954
+	/**
955
+	 * trim_log
956
+	 * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH
957
+	 */
958
+	public static function trim_log()
959
+	{
960
+		if (! EE_Config::logging_enabled()) {
961
+			return;
962
+		}
963
+		$config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array()));
964
+		$log_length = count($config_log);
965
+		if ($log_length > EE_Config::LOG_LENGTH) {
966
+			ksort($config_log);
967
+			$config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true);
968
+			update_option(EE_Config::LOG_NAME, $config_log);
969
+		}
970
+	}
971
+
972
+
973
+
974
+	/**
975
+	 *    get_page_for_posts
976
+	 *    if the wp-option "show_on_front" is set to "page", then this is the post_name for the post set in the
977
+	 *    wp-option "page_for_posts", or "posts" if no page is selected
978
+	 *
979
+	 * @access    public
980
+	 * @return    string
981
+	 */
982
+	public static function get_page_for_posts()
983
+	{
984
+		$page_for_posts = get_option('page_for_posts');
985
+		if (! $page_for_posts) {
986
+			return 'posts';
987
+		}
988
+		/** @type WPDB $wpdb */
989
+		global $wpdb;
990
+		$SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d";
991
+		return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts));
992
+	}
993
+
994
+
995
+
996
+	/**
997
+	 *    register_shortcodes_and_modules.
998
+	 *    At this point, it's too early to tell if we're maintenance mode or not.
999
+	 *    In fact, this is where we give modules a chance to let core know they exist
1000
+	 *    so they can help trigger maintenance mode if it's needed
1001
+	 *
1002
+	 * @access    public
1003
+	 * @return    void
1004
+	 */
1005
+	public function register_shortcodes_and_modules()
1006
+	{
1007
+		// allow modules to set hooks for the rest of the system
1008
+		EE_Registry::instance()->modules = $this->_register_modules();
1009
+	}
1010
+
1011
+
1012
+
1013
+	/**
1014
+	 *    initialize_shortcodes_and_modules
1015
+	 *    meaning they can start adding their hooks to get stuff done
1016
+	 *
1017
+	 * @access    public
1018
+	 * @return    void
1019
+	 */
1020
+	public function initialize_shortcodes_and_modules()
1021
+	{
1022
+		// allow modules to set hooks for the rest of the system
1023
+		$this->_initialize_modules();
1024
+	}
1025
+
1026
+
1027
+
1028
+	/**
1029
+	 *    widgets_init
1030
+	 *
1031
+	 * @access private
1032
+	 * @return void
1033
+	 */
1034
+	public function widgets_init()
1035
+	{
1036
+		//only init widgets on admin pages when not in complete maintenance, and
1037
+		//on frontend when not in any maintenance mode
1038
+		if (
1039
+			! EE_Maintenance_Mode::instance()->level()
1040
+			|| (
1041
+				is_admin()
1042
+				&& EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance
1043
+			)
1044
+		) {
1045
+			// grab list of installed widgets
1046
+			$widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR);
1047
+			// filter list of modules to register
1048
+			$widgets_to_register = apply_filters(
1049
+				'FHEE__EE_Config__register_widgets__widgets_to_register',
1050
+				$widgets_to_register
1051
+			);
1052
+			if (! empty($widgets_to_register)) {
1053
+				// cycle thru widget folders
1054
+				foreach ($widgets_to_register as $widget_path) {
1055
+					// add to list of installed widget modules
1056
+					EE_Config::register_ee_widget($widget_path);
1057
+				}
1058
+			}
1059
+			// filter list of installed modules
1060
+			EE_Registry::instance()->widgets = apply_filters(
1061
+				'FHEE__EE_Config__register_widgets__installed_widgets',
1062
+				EE_Registry::instance()->widgets
1063
+			);
1064
+		}
1065
+	}
1066
+
1067
+
1068
+
1069
+	/**
1070
+	 *    register_ee_widget - makes core aware of this widget
1071
+	 *
1072
+	 * @access    public
1073
+	 * @param    string $widget_path - full path up to and including widget folder
1074
+	 * @return    void
1075
+	 */
1076
+	public static function register_ee_widget($widget_path = null)
1077
+	{
1078
+		do_action('AHEE__EE_Config__register_widget__begin', $widget_path);
1079
+		$widget_ext = '.widget.php';
1080
+		// make all separators match
1081
+		$widget_path = rtrim(str_replace('/\\', DS, $widget_path), DS);
1082
+		// does the file path INCLUDE the actual file name as part of the path ?
1083
+		if (strpos($widget_path, $widget_ext) !== false) {
1084
+			// grab and shortcode file name from directory name and break apart at dots
1085
+			$file_name = explode('.', basename($widget_path));
1086
+			// take first segment from file name pieces and remove class prefix if it exists
1087
+			$widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0];
1088
+			// sanitize shortcode directory name
1089
+			$widget = sanitize_key($widget);
1090
+			// now we need to rebuild the shortcode path
1091
+			$widget_path = explode(DS, $widget_path);
1092
+			// remove last segment
1093
+			array_pop($widget_path);
1094
+			// glue it back together
1095
+			$widget_path = implode(DS, $widget_path);
1096
+		} else {
1097
+			// grab and sanitize widget directory name
1098
+			$widget = sanitize_key(basename($widget_path));
1099
+		}
1100
+		// create classname from widget directory name
1101
+		$widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget)));
1102
+		// add class prefix
1103
+		$widget_class = 'EEW_' . $widget;
1104
+		// does the widget exist ?
1105
+		if (! is_readable($widget_path . DS . $widget_class . $widget_ext)) {
1106
+			$msg = sprintf(
1107
+				__(
1108
+					'The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s',
1109
+					'event_espresso'
1110
+				),
1111
+				$widget_class,
1112
+				$widget_path . DS . $widget_class . $widget_ext
1113
+			);
1114
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1115
+			return;
1116
+		}
1117
+		// load the widget class file
1118
+		require_once($widget_path . DS . $widget_class . $widget_ext);
1119
+		// verify that class exists
1120
+		if (! class_exists($widget_class)) {
1121
+			$msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class);
1122
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1123
+			return;
1124
+		}
1125
+		register_widget($widget_class);
1126
+		// add to array of registered widgets
1127
+		EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext;
1128
+	}
1129
+
1130
+
1131
+
1132
+	/**
1133
+	 *        _register_modules
1134
+	 *
1135
+	 * @access private
1136
+	 * @return array
1137
+	 */
1138
+	private function _register_modules()
1139
+	{
1140
+		// grab list of installed modules
1141
+		$modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR);
1142
+		// filter list of modules to register
1143
+		$modules_to_register = apply_filters(
1144
+			'FHEE__EE_Config__register_modules__modules_to_register',
1145
+			$modules_to_register
1146
+		);
1147
+		if (! empty($modules_to_register)) {
1148
+			// loop through folders
1149
+			foreach ($modules_to_register as $module_path) {
1150
+				/**TEMPORARILY EXCLUDE gateways from modules for time being**/
1151
+				if (
1152
+					$module_path !== EE_MODULES . 'zzz-copy-this-module-template'
1153
+					&& $module_path !== EE_MODULES . 'gateways'
1154
+				) {
1155
+					// add to list of installed modules
1156
+					EE_Config::register_module($module_path);
1157
+				}
1158
+			}
1159
+		}
1160
+		// filter list of installed modules
1161
+		return apply_filters(
1162
+			'FHEE__EE_Config___register_modules__installed_modules',
1163
+			EE_Registry::instance()->modules
1164
+		);
1165
+	}
1166
+
1167
+
1168
+
1169
+	/**
1170
+	 *    register_module - makes core aware of this module
1171
+	 *
1172
+	 * @access    public
1173
+	 * @param    string $module_path - full path up to and including module folder
1174
+	 * @return    bool
1175
+	 */
1176
+	public static function register_module($module_path = null)
1177
+	{
1178
+		do_action('AHEE__EE_Config__register_module__begin', $module_path);
1179
+		$module_ext = '.module.php';
1180
+		// make all separators match
1181
+		$module_path = str_replace(array('\\', '/'), DS, $module_path);
1182
+		// does the file path INCLUDE the actual file name as part of the path ?
1183
+		if (strpos($module_path, $module_ext) !== false) {
1184
+			// grab and shortcode file name from directory name and break apart at dots
1185
+			$module_file = explode('.', basename($module_path));
1186
+			// now we need to rebuild the shortcode path
1187
+			$module_path = explode(DS, $module_path);
1188
+			// remove last segment
1189
+			array_pop($module_path);
1190
+			// glue it back together
1191
+			$module_path = implode(DS, $module_path) . DS;
1192
+			// take first segment from file name pieces and sanitize it
1193
+			$module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]);
1194
+			// ensure class prefix is added
1195
+			$module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module;
1196
+		} else {
1197
+			// we need to generate the filename based off of the folder name
1198
+			// grab and sanitize module name
1199
+			$module = strtolower(basename($module_path));
1200
+			$module = preg_replace('/[^a-z0-9_\-]/', '', $module);
1201
+			// like trailingslashit()
1202
+			$module_path = rtrim($module_path, DS) . DS;
1203
+			// create classname from module directory name
1204
+			$module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module)));
1205
+			// add class prefix
1206
+			$module_class = 'EED_' . $module;
1207
+		}
1208
+		// does the module exist ?
1209
+		if (! is_readable($module_path . DS . $module_class . $module_ext)) {
1210
+			$msg = sprintf(
1211
+				__(
1212
+					'The requested %s module file could not be found or is not readable due to file permissions.',
1213
+					'event_espresso'
1214
+				),
1215
+				$module
1216
+			);
1217
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1218
+			return false;
1219
+		}
1220
+		// load the module class file
1221
+		require_once($module_path . $module_class . $module_ext);
1222
+		// verify that class exists
1223
+		if (! class_exists($module_class)) {
1224
+			$msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
1225
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1226
+			return false;
1227
+		}
1228
+		// add to array of registered modules
1229
+		EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext;
1230
+		do_action(
1231
+			'AHEE__EE_Config__register_module__complete',
1232
+			$module_class,
1233
+			EE_Registry::instance()->modules->{$module_class}
1234
+		);
1235
+		return true;
1236
+	}
1237
+
1238
+
1239
+
1240
+	/**
1241
+	 *    _initialize_modules
1242
+	 *    allow modules to set hooks for the rest of the system
1243
+	 *
1244
+	 * @access private
1245
+	 * @return void
1246
+	 */
1247
+	private function _initialize_modules()
1248
+	{
1249
+		// cycle thru shortcode folders
1250
+		foreach (EE_Registry::instance()->modules as $module_class => $module_path) {
1251
+			// fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
1252
+			// which set hooks ?
1253
+			if (is_admin()) {
1254
+				// fire immediately
1255
+				call_user_func(array($module_class, 'set_hooks_admin'));
1256
+			} else {
1257
+				// delay until other systems are online
1258
+				add_action(
1259
+					'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons',
1260
+					array($module_class, 'set_hooks')
1261
+				);
1262
+			}
1263
+		}
1264
+	}
1265
+
1266
+
1267
+
1268
+	/**
1269
+	 *    register_route - adds module method routes to route_map
1270
+	 *
1271
+	 * @access    public
1272
+	 * @param    string $route       - "pretty" public alias for module method
1273
+	 * @param    string $module      - module name (classname without EED_ prefix)
1274
+	 * @param    string $method_name - the actual module method to be routed to
1275
+	 * @param    string $key         - url param key indicating a route is being called
1276
+	 * @return    bool
1277
+	 */
1278
+	public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee')
1279
+	{
1280
+		do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name);
1281
+		$module = str_replace('EED_', '', $module);
1282
+		$module_class = 'EED_' . $module;
1283
+		if (! isset(EE_Registry::instance()->modules->{$module_class})) {
1284
+			$msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module);
1285
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1286
+			return false;
1287
+		}
1288
+		if (empty($route)) {
1289
+			$msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route);
1290
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1291
+			return false;
1292
+		}
1293
+		if (! method_exists('EED_' . $module, $method_name)) {
1294
+			$msg = sprintf(
1295
+				__('A valid class method for the %s route has not been supplied.', 'event_espresso'),
1296
+				$route
1297
+			);
1298
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1299
+			return false;
1300
+		}
1301
+		EE_Config::$_module_route_map[$key][$route] = array('EED_' . $module, $method_name);
1302
+		return true;
1303
+	}
1304
+
1305
+
1306
+
1307
+	/**
1308
+	 *    get_route - get module method route
1309
+	 *
1310
+	 * @access    public
1311
+	 * @param    string $route - "pretty" public alias for module method
1312
+	 * @param    string $key   - url param key indicating a route is being called
1313
+	 * @return    string
1314
+	 */
1315
+	public static function get_route($route = null, $key = 'ee')
1316
+	{
1317
+		do_action('AHEE__EE_Config__get_route__begin', $route);
1318
+		$route = (string)apply_filters('FHEE__EE_Config__get_route', $route);
1319
+		if (isset(EE_Config::$_module_route_map[$key][$route])) {
1320
+			return EE_Config::$_module_route_map[$key][$route];
1321
+		}
1322
+		return null;
1323
+	}
1324
+
1325
+
1326
+
1327
+	/**
1328
+	 *    get_routes - get ALL module method routes
1329
+	 *
1330
+	 * @access    public
1331
+	 * @return    array
1332
+	 */
1333
+	public static function get_routes()
1334
+	{
1335
+		return EE_Config::$_module_route_map;
1336
+	}
1337
+
1338
+
1339
+
1340
+	/**
1341
+	 *    register_forward - allows modules to forward request to another module for further processing
1342
+	 *
1343
+	 * @access    public
1344
+	 * @param    string       $route   - "pretty" public alias for module method
1345
+	 * @param    integer      $status  - integer value corresponding  to status constant strings set in module parent
1346
+	 *                                 class, allows different forwards to be served based on status
1347
+	 * @param    array|string $forward - function name or array( class, method )
1348
+	 * @param    string       $key     - url param key indicating a route is being called
1349
+	 * @return    bool
1350
+	 */
1351
+	public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee')
1352
+	{
1353
+		do_action('AHEE__EE_Config__register_forward', $route, $status, $forward);
1354
+		if (! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1355
+			$msg = sprintf(
1356
+				__('The module route %s for this forward has not been registered.', 'event_espresso'),
1357
+				$route
1358
+			);
1359
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1360
+			return false;
1361
+		}
1362
+		if (empty($forward)) {
1363
+			$msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route);
1364
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1365
+			return false;
1366
+		}
1367
+		if (is_array($forward)) {
1368
+			if (! isset($forward[1])) {
1369
+				$msg = sprintf(
1370
+					__('A class method for the %s forwarding route has not been supplied.', 'event_espresso'),
1371
+					$route
1372
+				);
1373
+				EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1374
+				return false;
1375
+			}
1376
+			if (! method_exists($forward[0], $forward[1])) {
1377
+				$msg = sprintf(
1378
+					__('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'),
1379
+					$forward[1],
1380
+					$route
1381
+				);
1382
+				EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1383
+				return false;
1384
+			}
1385
+		} else if (! function_exists($forward)) {
1386
+			$msg = sprintf(
1387
+				__('The function %s for the %s forwarding route is in invalid.', 'event_espresso'),
1388
+				$forward,
1389
+				$route
1390
+			);
1391
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1392
+			return false;
1393
+		}
1394
+		EE_Config::$_module_forward_map[$key][$route][absint($status)] = $forward;
1395
+		return true;
1396
+	}
1397
+
1398
+
1399
+
1400
+	/**
1401
+	 *    get_forward - get forwarding route
1402
+	 *
1403
+	 * @access    public
1404
+	 * @param    string  $route  - "pretty" public alias for module method
1405
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1406
+	 *                           allows different forwards to be served based on status
1407
+	 * @param    string  $key    - url param key indicating a route is being called
1408
+	 * @return    string
1409
+	 */
1410
+	public static function get_forward($route = null, $status = 0, $key = 'ee')
1411
+	{
1412
+		do_action('AHEE__EE_Config__get_forward__begin', $route, $status);
1413
+		if (isset(EE_Config::$_module_forward_map[$key][$route][$status])) {
1414
+			return apply_filters(
1415
+				'FHEE__EE_Config__get_forward',
1416
+				EE_Config::$_module_forward_map[$key][$route][$status],
1417
+				$route,
1418
+				$status
1419
+			);
1420
+		}
1421
+		return null;
1422
+	}
1423
+
1424
+
1425
+
1426
+	/**
1427
+	 *    register_forward - allows modules to specify different view templates for different method routes and status
1428
+	 *    results
1429
+	 *
1430
+	 * @access    public
1431
+	 * @param    string  $route  - "pretty" public alias for module method
1432
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1433
+	 *                           allows different views to be served based on status
1434
+	 * @param    string  $view
1435
+	 * @param    string  $key    - url param key indicating a route is being called
1436
+	 * @return    bool
1437
+	 */
1438
+	public static function register_view($route = null, $status = 0, $view = null, $key = 'ee')
1439
+	{
1440
+		do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view);
1441
+		if (! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1442
+			$msg = sprintf(
1443
+				__('The module route %s for this view has not been registered.', 'event_espresso'),
1444
+				$route
1445
+			);
1446
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1447
+			return false;
1448
+		}
1449
+		if (! is_readable($view)) {
1450
+			$msg = sprintf(
1451
+				__(
1452
+					'The %s view file could not be found or is not readable due to file permissions.',
1453
+					'event_espresso'
1454
+				),
1455
+				$view
1456
+			);
1457
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1458
+			return false;
1459
+		}
1460
+		EE_Config::$_module_view_map[$key][$route][absint($status)] = $view;
1461
+		return true;
1462
+	}
1463
+
1464
+
1465
+
1466
+	/**
1467
+	 *    get_view - get view for route and status
1468
+	 *
1469
+	 * @access    public
1470
+	 * @param    string  $route  - "pretty" public alias for module method
1471
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1472
+	 *                           allows different views to be served based on status
1473
+	 * @param    string  $key    - url param key indicating a route is being called
1474
+	 * @return    string
1475
+	 */
1476
+	public static function get_view($route = null, $status = 0, $key = 'ee')
1477
+	{
1478
+		do_action('AHEE__EE_Config__get_view__begin', $route, $status);
1479
+		if (isset(EE_Config::$_module_view_map[$key][$route][$status])) {
1480
+			return apply_filters(
1481
+				'FHEE__EE_Config__get_view',
1482
+				EE_Config::$_module_view_map[$key][$route][$status],
1483
+				$route,
1484
+				$status
1485
+			);
1486
+		}
1487
+		return null;
1488
+	}
1489
+
1490
+
1491
+
1492
+	public function update_addon_option_names()
1493
+	{
1494
+		update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names);
1495
+	}
1496
+
1497
+
1498
+
1499
+	public function shutdown()
1500
+	{
1501
+		$this->update_addon_option_names();
1502
+	}
1503
+
1504
+
1505
+
1506
+	/**
1507
+	 * @return LegacyShortcodesManager
1508
+	 */
1509
+	public static function getLegacyShortcodesManager()
1510
+	{
1511
+
1512
+		if ( ! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) {
1513
+			EE_Config::instance()->legacy_shortcodes_manager = new LegacyShortcodesManager(
1514
+				EE_Registry::instance()
1515
+			);
1516
+		}
1517
+		return EE_Config::instance()->legacy_shortcodes_manager;
1518
+	}
1519
+
1520
+
1521
+
1522
+	/**
1523
+	 * register_shortcode - makes core aware of this shortcode
1524
+	 *
1525
+	 * @deprecated 4.9.26
1526
+	 * @param    string $shortcode_path - full path up to and including shortcode folder
1527
+	 * @return    bool
1528
+	 */
1529
+	public static function register_shortcode($shortcode_path = null)
1530
+	{
1531
+		EE_Error::doing_it_wrong(
1532
+			__METHOD__,
1533
+			__(
1534
+				'Usage is deprecated. Use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::registerShortcode() as direct replacement, or better yet, please see the new \EventEspresso\core\services\shortcodes\ShortcodesManager class.',
1535
+				'event_espresso'
1536
+			),
1537
+			'4.9.26'
1538
+		);
1539
+		return EE_Config::instance()->getLegacyShortcodesManager()->registerShortcode($shortcode_path);
1540
+	}
21 1541
 
22
-    const LOG_NAME           = 'ee_config_log';
23 1542
 
24
-    const LOG_LENGTH         = 100;
25 1543
 
26
-    const ADDON_OPTION_NAMES = 'ee_config_option_names';
27
-
28
-
29
-    /**
30
-     *    instance of the EE_Config object
31
-     *
32
-     * @var    EE_Config $_instance
33
-     * @access    private
34
-     */
35
-    private static $_instance;
36
-
37
-    /**
38
-     * @var boolean $_logging_enabled
39
-     */
40
-    private static $_logging_enabled = false;
41
-
42
-    /**
43
-     * @var LegacyShortcodesManager $legacy_shortcodes_manager
44
-     */
45
-    private $legacy_shortcodes_manager;
46
-
47
-    /**
48
-     * An StdClass whose property names are addon slugs,
49
-     * and values are their config classes
50
-     *
51
-     * @var StdClass
52
-     */
53
-    public $addons;
54
-
55
-    /**
56
-     * @var EE_Admin_Config
57
-     */
58
-    public $admin;
59
-
60
-    /**
61
-     * @var EE_Core_Config
62
-     */
63
-    public $core;
64
-
65
-    /**
66
-     * @var EE_Currency_Config
67
-     */
68
-    public $currency;
69
-
70
-    /**
71
-     * @var EE_Organization_Config
72
-     */
73
-    public $organization;
74
-
75
-    /**
76
-     * @var EE_Registration_Config
77
-     */
78
-    public $registration;
79
-
80
-    /**
81
-     * @var EE_Template_Config
82
-     */
83
-    public $template_settings;
84
-
85
-    /**
86
-     * Holds EE environment values.
87
-     *
88
-     * @var EE_Environment_Config
89
-     */
90
-    public $environment;
91
-
92
-    /**
93
-     * settings pertaining to Google maps
94
-     *
95
-     * @var EE_Map_Config
96
-     */
97
-    public $map_settings;
98
-
99
-    /**
100
-     * settings pertaining to Taxes
101
-     *
102
-     * @var EE_Tax_Config
103
-     */
104
-    public $tax_settings;
105
-
106
-
107
-    /**
108
-     * Settings pertaining to global messages settings.
109
-     *
110
-     * @var EE_Messages_Config
111
-     */
112
-    public $messages;
113
-
114
-    /**
115
-     * @deprecated
116
-     * @var EE_Gateway_Config
117
-     */
118
-    public $gateway;
119
-
120
-    /**
121
-     * @var    array $_addon_option_names
122
-     * @access    private
123
-     */
124
-    private $_addon_option_names = array();
125
-
126
-    /**
127
-     * @var    array $_module_route_map
128
-     * @access    private
129
-     */
130
-    private static $_module_route_map = array();
131
-
132
-    /**
133
-     * @var    array $_module_forward_map
134
-     * @access    private
135
-     */
136
-    private static $_module_forward_map = array();
137
-
138
-    /**
139
-     * @var    array $_module_view_map
140
-     * @access    private
141
-     */
142
-    private static $_module_view_map = array();
143
-
144
-
145
-
146
-    /**
147
-     * @singleton method used to instantiate class object
148
-     * @access    public
149
-     * @return EE_Config instance
150
-     */
151
-    public static function instance()
152
-    {
153
-        // check if class object is instantiated, and instantiated properly
154
-        if (! self::$_instance instanceof EE_Config) {
155
-            self::$_instance = new self();
156
-        }
157
-        return self::$_instance;
158
-    }
159
-
160
-
161
-
162
-    /**
163
-     * Resets the config
164
-     *
165
-     * @param bool    $hard_reset    if TRUE, sets EE_CONFig back to its original settings in the database. If FALSE
166
-     *                               (default) leaves the database alone, and merely resets the EE_Config object to
167
-     *                               reflect its state in the database
168
-     * @param boolean $reinstantiate if TRUE (default) call instance() and return it. Otherwise, just leave
169
-     *                               $_instance as NULL. Useful in case you want to forget about the old instance on
170
-     *                               EE_Config, but might not be ready to instantiate EE_Config currently (eg if the
171
-     *                               site was put into maintenance mode)
172
-     * @return EE_Config
173
-     */
174
-    public static function reset($hard_reset = false, $reinstantiate = true)
175
-    {
176
-        if (self::$_instance instanceof EE_Config) {
177
-            if ($hard_reset) {
178
-                self::$_instance->legacy_shortcodes_manager = null;
179
-                self::$_instance->_addon_option_names = array();
180
-                self::$_instance->_initialize_config();
181
-                self::$_instance->update_espresso_config();
182
-            }
183
-            self::$_instance->update_addon_option_names();
184
-        }
185
-        self::$_instance = null;
186
-        //we don't need to reset the static properties imo because those should
187
-        //only change when a module is added or removed. Currently we don't
188
-        //support removing a module during a request when it previously existed
189
-        if ($reinstantiate) {
190
-            return self::instance();
191
-        } else {
192
-            return null;
193
-        }
194
-    }
195
-
196
-
197
-
198
-    /**
199
-     *    class constructor
200
-     *
201
-     * @access    private
202
-     */
203
-    private function __construct()
204
-    {
205
-        do_action('AHEE__EE_Config__construct__begin', $this);
206
-        EE_Config::$_logging_enabled = apply_filters('FHEE__EE_Config___construct__logging_enabled', false);
207
-        // setup empty config classes
208
-        $this->_initialize_config();
209
-        // load existing EE site settings
210
-        $this->_load_core_config();
211
-        // confirm everything loaded correctly and set filtered defaults if not
212
-        $this->_verify_config();
213
-        //  register shortcodes and modules
214
-        add_action(
215
-            'AHEE__EE_System__register_shortcodes_modules_and_widgets',
216
-            array($this, 'register_shortcodes_and_modules'),
217
-            999
218
-        );
219
-        //  initialize shortcodes and modules
220
-        add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'initialize_shortcodes_and_modules'));
221
-        // register widgets
222
-        add_action('widgets_init', array($this, 'widgets_init'), 10);
223
-        // shutdown
224
-        add_action('shutdown', array($this, 'shutdown'), 10);
225
-        // construct__end hook
226
-        do_action('AHEE__EE_Config__construct__end', $this);
227
-        // hardcoded hack
228
-        $this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014';
229
-    }
230
-
231
-
232
-
233
-    /**
234
-     * @return boolean
235
-     */
236
-    public static function logging_enabled()
237
-    {
238
-        return self::$_logging_enabled;
239
-    }
240
-
241
-
242
-
243
-    /**
244
-     * use to get the current theme if needed from static context
245
-     *
246
-     * @return string current theme set.
247
-     */
248
-    public static function get_current_theme()
249
-    {
250
-        return isset(self::$_instance->template_settings->current_espresso_theme)
251
-            ? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014';
252
-    }
253
-
254
-
255
-
256
-    /**
257
-     *        _initialize_config
258
-     *
259
-     * @access private
260
-     * @return void
261
-     */
262
-    private function _initialize_config()
263
-    {
264
-        EE_Config::trim_log();
265
-        //set defaults
266
-        $this->_addon_option_names = get_option(EE_Config::ADDON_OPTION_NAMES, array());
267
-        $this->addons = new stdClass();
268
-        // set _module_route_map
269
-        EE_Config::$_module_route_map = array();
270
-        // set _module_forward_map
271
-        EE_Config::$_module_forward_map = array();
272
-        // set _module_view_map
273
-        EE_Config::$_module_view_map = array();
274
-    }
275
-
276
-
277
-
278
-    /**
279
-     *        load core plugin configuration
280
-     *
281
-     * @access private
282
-     * @return void
283
-     */
284
-    private function _load_core_config()
285
-    {
286
-        // load_core_config__start hook
287
-        do_action('AHEE__EE_Config___load_core_config__start', $this);
288
-        $espresso_config = $this->get_espresso_config();
289
-        foreach ($espresso_config as $config => $settings) {
290
-            // load_core_config__start hook
291
-            $settings = apply_filters(
292
-                'FHEE__EE_Config___load_core_config__config_settings',
293
-                $settings,
294
-                $config,
295
-                $this
296
-            );
297
-            if (is_object($settings) && property_exists($this, $config)) {
298
-                $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings);
299
-                //call configs populate method to ensure any defaults are set for empty values.
300
-                if (method_exists($settings, 'populate')) {
301
-                    $this->{$config}->populate();
302
-                }
303
-                if (method_exists($settings, 'do_hooks')) {
304
-                    $this->{$config}->do_hooks();
305
-                }
306
-            }
307
-        }
308
-        if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', false)) {
309
-            $this->update_espresso_config();
310
-        }
311
-        // load_core_config__end hook
312
-        do_action('AHEE__EE_Config___load_core_config__end', $this);
313
-    }
314
-
315
-
316
-
317
-    /**
318
-     *    _verify_config
319
-     *
320
-     * @access    protected
321
-     * @return    void
322
-     */
323
-    protected function _verify_config()
324
-    {
325
-        $this->core = $this->core instanceof EE_Core_Config
326
-            ? $this->core
327
-            : new EE_Core_Config();
328
-        $this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core);
329
-        $this->organization = $this->organization instanceof EE_Organization_Config
330
-            ? $this->organization
331
-            : new EE_Organization_Config();
332
-        $this->organization = apply_filters(
333
-            'FHEE__EE_Config___initialize_config__organization',
334
-            $this->organization
335
-        );
336
-        $this->currency = $this->currency instanceof EE_Currency_Config
337
-            ? $this->currency
338
-            : new EE_Currency_Config();
339
-        $this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency);
340
-        $this->registration = $this->registration instanceof EE_Registration_Config
341
-            ? $this->registration
342
-            : new EE_Registration_Config();
343
-        $this->registration = apply_filters(
344
-            'FHEE__EE_Config___initialize_config__registration',
345
-            $this->registration
346
-        );
347
-        $this->admin = $this->admin instanceof EE_Admin_Config
348
-            ? $this->admin
349
-            : new EE_Admin_Config();
350
-        $this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin);
351
-        $this->template_settings = $this->template_settings instanceof EE_Template_Config
352
-            ? $this->template_settings
353
-            : new EE_Template_Config();
354
-        $this->template_settings = apply_filters(
355
-            'FHEE__EE_Config___initialize_config__template_settings',
356
-            $this->template_settings
357
-        );
358
-        $this->map_settings = $this->map_settings instanceof EE_Map_Config
359
-            ? $this->map_settings
360
-            : new EE_Map_Config();
361
-        $this->map_settings = apply_filters('FHEE__EE_Config___initialize_config__map_settings',
362
-            $this->map_settings);
363
-        $this->environment = $this->environment instanceof EE_Environment_Config
364
-            ? $this->environment
365
-            : new EE_Environment_Config();
366
-        $this->environment = apply_filters('FHEE__EE_Config___initialize_config__environment',
367
-            $this->environment);
368
-        $this->tax_settings = $this->tax_settings instanceof EE_Tax_Config
369
-            ? $this->tax_settings
370
-            : new EE_Tax_Config();
371
-        $this->tax_settings = apply_filters('FHEE__EE_Config___initialize_config__tax_settings',
372
-            $this->tax_settings);
373
-        $this->messages = apply_filters('FHEE__EE_Config__initialize_config__messages', $this->messages);
374
-        $this->messages = $this->messages instanceof EE_Messages_Config
375
-            ? $this->messages
376
-            : new EE_Messages_Config();
377
-        $this->gateway = $this->gateway instanceof EE_Gateway_Config
378
-            ? $this->gateway
379
-            : new EE_Gateway_Config();
380
-        $this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway);
381
-        $this->legacy_shortcodes_manager = null;
382
-    }
383
-
384
-
385
-    /**
386
-     *    get_espresso_config
387
-     *
388
-     * @access    public
389
-     * @return    array of espresso config stuff
390
-     */
391
-    public function get_espresso_config()
392
-    {
393
-        // grab espresso configuration
394
-        return apply_filters(
395
-            'FHEE__EE_Config__get_espresso_config__CFG',
396
-            get_option(EE_Config::OPTION_NAME, array())
397
-        );
398
-    }
399
-
400
-
401
-
402
-    /**
403
-     *    double_check_config_comparison
404
-     *
405
-     * @access    public
406
-     * @param string $option
407
-     * @param        $old_value
408
-     * @param        $value
409
-     */
410
-    public function double_check_config_comparison($option = '', $old_value, $value)
411
-    {
412
-        // make sure we're checking the ee config
413
-        if ($option === EE_Config::OPTION_NAME) {
414
-            // run a loose comparison of the old value against the new value for type and properties,
415
-            // but NOT exact instance like WP update_option does (ie: NOT type safe comparison)
416
-            if ($value != $old_value) {
417
-                // if they are NOT the same, then remove the hook,
418
-                // which means the subsequent update results will be based solely on the update query results
419
-                // the reason we do this is because, as stated above,
420
-                // WP update_option performs an exact instance comparison (===) on any update values passed to it
421
-                // this happens PRIOR to serialization and any subsequent update.
422
-                // If values are found to match their previous old value,
423
-                // then WP bails before performing any update.
424
-                // Since we are passing the EE_Config object, it is comparing the EXACT instance of the saved version
425
-                // it just pulled from the db, with the one being passed to it (which will not match).
426
-                // HOWEVER, once the object is serialized and passed off to MySQL to update,
427
-                // MySQL MAY ALSO NOT perform the update because
428
-                // the string it sees in the db looks the same as the new one it has been passed!!!
429
-                // This results in the query returning an "affected rows" value of ZERO,
430
-                // which gets returned immediately by WP update_option and looks like an error.
431
-                remove_action('update_option', array($this, 'check_config_updated'));
432
-            }
433
-        }
434
-    }
435
-
436
-
437
-
438
-    /**
439
-     *    update_espresso_config
440
-     *
441
-     * @access   public
442
-     */
443
-    protected function _reset_espresso_addon_config()
444
-    {
445
-        $this->_addon_option_names = array();
446
-        foreach ($this->addons as $addon_name => $addon_config_obj) {
447
-            $addon_config_obj = maybe_unserialize($addon_config_obj);
448
-            if ($addon_config_obj instanceof EE_Config_Base) {
449
-                $this->update_config('addons', $addon_name, $addon_config_obj, false);
450
-            }
451
-            $this->addons->{$addon_name} = null;
452
-        }
453
-    }
454
-
455
-
456
-
457
-    /**
458
-     *    update_espresso_config
459
-     *
460
-     * @access   public
461
-     * @param   bool $add_success
462
-     * @param   bool $add_error
463
-     * @return   bool
464
-     */
465
-    public function update_espresso_config($add_success = false, $add_error = true)
466
-    {
467
-        // don't allow config updates during WP heartbeats
468
-        if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
469
-            return false;
470
-        }
471
-        // commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197
472
-        //$clone = clone( self::$_instance );
473
-        //self::$_instance = NULL;
474
-        do_action('AHEE__EE_Config__update_espresso_config__begin', $this);
475
-        $this->_reset_espresso_addon_config();
476
-        // hook into update_option because that happens AFTER the ( $value === $old_value ) conditional
477
-        // but BEFORE the actual update occurs
478
-        add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3);
479
-        // don't want to persist legacy_shortcodes_manager, but don't want to lose it either
480
-        $legacy_shortcodes_manager = $this->legacy_shortcodes_manager;
481
-        $this->legacy_shortcodes_manager = null;
482
-        // now update "ee_config"
483
-        $saved = update_option(EE_Config::OPTION_NAME, $this);
484
-        $this->legacy_shortcodes_manager = $legacy_shortcodes_manager;
485
-        EE_Config::log(EE_Config::OPTION_NAME);
486
-        // if not saved... check if the hook we just added still exists;
487
-        // if it does, it means one of two things:
488
-        // 		that update_option bailed at the ( $value === $old_value ) conditional,
489
-        //		 or...
490
-        // 		the db update query returned 0 rows affected
491
-        // 		(probably because the data  value was the same from it's perspective)
492
-        // so the existence of the hook means that a negative result from update_option is NOT an error,
493
-        // but just means no update occurred, so don't display an error to the user.
494
-        // BUT... if update_option returns FALSE, AND the hook is missing,
495
-        // then it means that something truly went wrong
496
-        $saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved;
497
-        // remove our action since we don't want it in the system anymore
498
-        remove_action('update_option', array($this, 'double_check_config_comparison'), 1);
499
-        do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved);
500
-        //self::$_instance = $clone;
501
-        //unset( $clone );
502
-        // if config remains the same or was updated successfully
503
-        if ($saved) {
504
-            if ($add_success) {
505
-                EE_Error::add_success(
506
-                    __('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'),
507
-                    __FILE__,
508
-                    __FUNCTION__,
509
-                    __LINE__
510
-                );
511
-            }
512
-            return true;
513
-        } else {
514
-            if ($add_error) {
515
-                EE_Error::add_error(
516
-                    __('The Event Espresso Configuration Settings were not updated.', 'event_espresso'),
517
-                    __FILE__,
518
-                    __FUNCTION__,
519
-                    __LINE__
520
-                );
521
-            }
522
-            return false;
523
-        }
524
-    }
525
-
526
-
527
-
528
-    /**
529
-     *    _verify_config_params
530
-     *
531
-     * @access    private
532
-     * @param    string         $section
533
-     * @param    string         $name
534
-     * @param    string         $config_class
535
-     * @param    EE_Config_Base $config_obj
536
-     * @param    array          $tests_to_run
537
-     * @param    bool           $display_errors
538
-     * @return    bool    TRUE on success, FALSE on fail
539
-     */
540
-    private function _verify_config_params(
541
-        $section = '',
542
-        $name = '',
543
-        $config_class = '',
544
-        $config_obj = null,
545
-        $tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8),
546
-        $display_errors = true
547
-    ) {
548
-        try {
549
-            foreach ($tests_to_run as $test) {
550
-                switch ($test) {
551
-                    // TEST #1 : check that section was set
552
-                    case 1 :
553
-                        if (empty($section)) {
554
-                            if ($display_errors) {
555
-                                throw new EE_Error(
556
-                                    sprintf(
557
-                                        __(
558
-                                            'No configuration section has been provided while attempting to save "%s".',
559
-                                            'event_espresso'
560
-                                        ),
561
-                                        $config_class
562
-                                    )
563
-                                );
564
-                            }
565
-                            return false;
566
-                        }
567
-                        break;
568
-                    // TEST #2 : check that settings section exists
569
-                    case 2 :
570
-                        if (! isset($this->{$section})) {
571
-                            if ($display_errors) {
572
-                                throw new EE_Error(
573
-                                    sprintf(
574
-                                        __('The "%s" configuration section does not exist.', 'event_espresso'),
575
-                                        $section
576
-                                    )
577
-                                );
578
-                            }
579
-                            return false;
580
-                        }
581
-                        break;
582
-                    // TEST #3 : check that section is the proper format
583
-                    case 3 :
584
-                        if (
585
-                        ! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass)
586
-                        ) {
587
-                            if ($display_errors) {
588
-                                throw new EE_Error(
589
-                                    sprintf(
590
-                                        __(
591
-                                            'The "%s" configuration settings have not been formatted correctly.',
592
-                                            'event_espresso'
593
-                                        ),
594
-                                        $section
595
-                                    )
596
-                                );
597
-                            }
598
-                            return false;
599
-                        }
600
-                        break;
601
-                    // TEST #4 : check that config section name has been set
602
-                    case 4 :
603
-                        if (empty($name)) {
604
-                            if ($display_errors) {
605
-                                throw new EE_Error(
606
-                                    __(
607
-                                        'No name has been provided for the specific configuration section.',
608
-                                        'event_espresso'
609
-                                    )
610
-                                );
611
-                            }
612
-                            return false;
613
-                        }
614
-                        break;
615
-                    // TEST #5 : check that a config class name has been set
616
-                    case 5 :
617
-                        if (empty($config_class)) {
618
-                            if ($display_errors) {
619
-                                throw new EE_Error(
620
-                                    __(
621
-                                        'No class name has been provided for the specific configuration section.',
622
-                                        'event_espresso'
623
-                                    )
624
-                                );
625
-                            }
626
-                            return false;
627
-                        }
628
-                        break;
629
-                    // TEST #6 : verify config class is accessible
630
-                    case 6 :
631
-                        if (! class_exists($config_class)) {
632
-                            if ($display_errors) {
633
-                                throw new EE_Error(
634
-                                    sprintf(
635
-                                        __(
636
-                                            'The "%s" class does not exist. Please ensure that an autoloader has been set for it.',
637
-                                            'event_espresso'
638
-                                        ),
639
-                                        $config_class
640
-                                    )
641
-                                );
642
-                            }
643
-                            return false;
644
-                        }
645
-                        break;
646
-                    // TEST #7 : check that config has even been set
647
-                    case 7 :
648
-                        if (! isset($this->{$section}->{$name})) {
649
-                            if ($display_errors) {
650
-                                throw new EE_Error(
651
-                                    sprintf(
652
-                                        __('No configuration has been set for "%1$s->%2$s".', 'event_espresso'),
653
-                                        $section,
654
-                                        $name
655
-                                    )
656
-                                );
657
-                            }
658
-                            return false;
659
-                        } else {
660
-                            // and make sure it's not serialized
661
-                            $this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name});
662
-                        }
663
-                        break;
664
-                    // TEST #8 : check that config is the requested type
665
-                    case 8 :
666
-                        if (! $this->{$section}->{$name} instanceof $config_class) {
667
-                            if ($display_errors) {
668
-                                throw new EE_Error(
669
-                                    sprintf(
670
-                                        __(
671
-                                            'The configuration for "%1$s->%2$s" is not of the "%3$s" class.',
672
-                                            'event_espresso'
673
-                                        ),
674
-                                        $section,
675
-                                        $name,
676
-                                        $config_class
677
-                                    )
678
-                                );
679
-                            }
680
-                            return false;
681
-                        }
682
-                        break;
683
-                    // TEST #9 : verify config object
684
-                    case 9 :
685
-                        if (! $config_obj instanceof EE_Config_Base) {
686
-                            if ($display_errors) {
687
-                                throw new EE_Error(
688
-                                    sprintf(
689
-                                        __('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'),
690
-                                        print_r($config_obj, true)
691
-                                    )
692
-                                );
693
-                            }
694
-                            return false;
695
-                        }
696
-                        break;
697
-                }
698
-            }
699
-        } catch (EE_Error $e) {
700
-            $e->get_error();
701
-        }
702
-        // you have successfully run the gauntlet
703
-        return true;
704
-    }
705
-
706
-
707
-
708
-    /**
709
-     *    _generate_config_option_name
710
-     *
711
-     * @access        protected
712
-     * @param        string $section
713
-     * @param        string $name
714
-     * @return        string
715
-     */
716
-    private function _generate_config_option_name($section = '', $name = '')
717
-    {
718
-        return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name));
719
-    }
720
-
721
-
722
-
723
-    /**
724
-     *    _set_config_class
725
-     * ensures that a config class is set, either from a passed config class or one generated from the config name
726
-     *
727
-     * @access    private
728
-     * @param    string $config_class
729
-     * @param    string $name
730
-     * @return    string
731
-     */
732
-    private function _set_config_class($config_class = '', $name = '')
733
-    {
734
-        return ! empty($config_class)
735
-            ? $config_class
736
-            : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config';
737
-    }
738
-
739
-
740
-
741
-    /**
742
-     *    set_config
743
-     *
744
-     * @access    protected
745
-     * @param    string         $section
746
-     * @param    string         $name
747
-     * @param    string         $config_class
748
-     * @param    EE_Config_Base $config_obj
749
-     * @return    EE_Config_Base
750
-     */
751
-    public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null)
752
-    {
753
-        // ensure config class is set to something
754
-        $config_class = $this->_set_config_class($config_class, $name);
755
-        // run tests 1-4, 6, and 7 to verify all config params are set and valid
756
-        if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
757
-            return null;
758
-        }
759
-        $config_option_name = $this->_generate_config_option_name($section, $name);
760
-        // if the config option name hasn't been added yet to the list of option names we're tracking, then do so now
761
-        if (! isset($this->_addon_option_names[$config_option_name])) {
762
-            $this->_addon_option_names[$config_option_name] = $config_class;
763
-            $this->update_addon_option_names();
764
-        }
765
-        // verify the incoming config object but suppress errors
766
-        if (! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
767
-            $config_obj = new $config_class();
768
-        }
769
-        if (get_option($config_option_name)) {
770
-            EE_Config::log($config_option_name);
771
-            update_option($config_option_name, $config_obj);
772
-            $this->{$section}->{$name} = $config_obj;
773
-            return $this->{$section}->{$name};
774
-        } else {
775
-            // create a wp-option for this config
776
-            if (add_option($config_option_name, $config_obj, '', 'no')) {
777
-                $this->{$section}->{$name} = maybe_unserialize($config_obj);
778
-                return $this->{$section}->{$name};
779
-            } else {
780
-                EE_Error::add_error(
781
-                    sprintf(__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class),
782
-                    __FILE__,
783
-                    __FUNCTION__,
784
-                    __LINE__
785
-                );
786
-                return null;
787
-            }
788
-        }
789
-    }
790
-
791
-
792
-
793
-    /**
794
-     *    update_config
795
-     * Important: the config object must ALREADY be set, otherwise this will produce an error.
796
-     *
797
-     * @access    public
798
-     * @param    string                $section
799
-     * @param    string                $name
800
-     * @param    EE_Config_Base|string $config_obj
801
-     * @param    bool                  $throw_errors
802
-     * @return    bool
803
-     */
804
-    public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true)
805
-    {
806
-        // don't allow config updates during WP heartbeats
807
-        if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
808
-            return false;
809
-        }
810
-        $config_obj = maybe_unserialize($config_obj);
811
-        // get class name of the incoming object
812
-        $config_class = get_class($config_obj);
813
-        // run tests 1-5 and 9 to verify config
814
-        if (! $this->_verify_config_params(
815
-            $section,
816
-            $name,
817
-            $config_class,
818
-            $config_obj,
819
-            array(1, 2, 3, 4, 7, 9)
820
-        )
821
-        ) {
822
-            return false;
823
-        }
824
-        $config_option_name = $this->_generate_config_option_name($section, $name);
825
-        // check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array
826
-        if (! isset($this->_addon_option_names[$config_option_name])) {
827
-            // save new config to db
828
-            if ($this->set_config($section, $name, $config_class, $config_obj)) {
829
-                return true;
830
-            }
831
-        } else {
832
-            // first check if the record already exists
833
-            $existing_config = get_option($config_option_name);
834
-            $config_obj = serialize($config_obj);
835
-            // just return if db record is already up to date (NOT type safe comparison)
836
-            if ($existing_config == $config_obj) {
837
-                $this->{$section}->{$name} = $config_obj;
838
-                return true;
839
-            } else if (update_option($config_option_name, $config_obj)) {
840
-                EE_Config::log($config_option_name);
841
-                // update wp-option for this config class
842
-                $this->{$section}->{$name} = $config_obj;
843
-                return true;
844
-            } elseif ($throw_errors) {
845
-                EE_Error::add_error(
846
-                    sprintf(
847
-                        __(
848
-                            'The "%1$s" object stored at"%2$s" was not successfully updated in the database.',
849
-                            'event_espresso'
850
-                        ),
851
-                        $config_class,
852
-                        'EE_Config->' . $section . '->' . $name
853
-                    ),
854
-                    __FILE__,
855
-                    __FUNCTION__,
856
-                    __LINE__
857
-                );
858
-            }
859
-        }
860
-        return false;
861
-    }
862
-
863
-
864
-
865
-    /**
866
-     *    get_config
867
-     *
868
-     * @access    public
869
-     * @param    string $section
870
-     * @param    string $name
871
-     * @param    string $config_class
872
-     * @return    mixed EE_Config_Base | NULL
873
-     */
874
-    public function get_config($section = '', $name = '', $config_class = '')
875
-    {
876
-        // ensure config class is set to something
877
-        $config_class = $this->_set_config_class($config_class, $name);
878
-        // run tests 1-4, 6 and 7 to verify that all params have been set
879
-        if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
880
-            return null;
881
-        }
882
-        // now test if the requested config object exists, but suppress errors
883
-        if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) {
884
-            // config already exists, so pass it back
885
-            return $this->{$section}->{$name};
886
-        }
887
-        // load config option from db if it exists
888
-        $config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name));
889
-        // verify the newly retrieved config object, but suppress errors
890
-        if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
891
-            // config is good, so set it and pass it back
892
-            $this->{$section}->{$name} = $config_obj;
893
-            return $this->{$section}->{$name};
894
-        }
895
-        // oops! $config_obj is not already set and does not exist in the db, so create a new one
896
-        $config_obj = $this->set_config($section, $name, $config_class);
897
-        // verify the newly created config object
898
-        if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) {
899
-            return $this->{$section}->{$name};
900
-        } else {
901
-            EE_Error::add_error(
902
-                sprintf(__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class),
903
-                __FILE__,
904
-                __FUNCTION__,
905
-                __LINE__
906
-            );
907
-        }
908
-        return null;
909
-    }
910
-
911
-
912
-
913
-    /**
914
-     *    get_config_option
915
-     *
916
-     * @access    public
917
-     * @param    string $config_option_name
918
-     * @return    mixed EE_Config_Base | FALSE
919
-     */
920
-    public function get_config_option($config_option_name = '')
921
-    {
922
-        // retrieve the wp-option for this config class.
923
-        $config_option = maybe_unserialize(get_option($config_option_name, array()));
924
-        if (empty($config_option)) {
925
-            EE_Config::log($config_option_name . '-NOT-FOUND');
926
-        }
927
-        return $config_option;
928
-    }
929
-
930
-
931
-
932
-    /**
933
-     * log
934
-     *
935
-     * @param string $config_option_name
936
-     */
937
-    public static function log($config_option_name = '')
938
-    {
939
-        if (EE_Config::logging_enabled() && ! empty($config_option_name)) {
940
-            $config_log = get_option(EE_Config::LOG_NAME, array());
941
-            //copy incoming $_REQUEST and sanitize it so we can save it
942
-            $_request = $_REQUEST;
943
-            array_walk_recursive($_request, 'sanitize_text_field');
944
-            $config_log[(string)microtime(true)] = array(
945
-                'config_name' => $config_option_name,
946
-                'request'     => $_request,
947
-            );
948
-            update_option(EE_Config::LOG_NAME, $config_log);
949
-        }
950
-    }
951
-
952
-
953
-
954
-    /**
955
-     * trim_log
956
-     * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH
957
-     */
958
-    public static function trim_log()
959
-    {
960
-        if (! EE_Config::logging_enabled()) {
961
-            return;
962
-        }
963
-        $config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array()));
964
-        $log_length = count($config_log);
965
-        if ($log_length > EE_Config::LOG_LENGTH) {
966
-            ksort($config_log);
967
-            $config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true);
968
-            update_option(EE_Config::LOG_NAME, $config_log);
969
-        }
970
-    }
971
-
972
-
973
-
974
-    /**
975
-     *    get_page_for_posts
976
-     *    if the wp-option "show_on_front" is set to "page", then this is the post_name for the post set in the
977
-     *    wp-option "page_for_posts", or "posts" if no page is selected
978
-     *
979
-     * @access    public
980
-     * @return    string
981
-     */
982
-    public static function get_page_for_posts()
983
-    {
984
-        $page_for_posts = get_option('page_for_posts');
985
-        if (! $page_for_posts) {
986
-            return 'posts';
987
-        }
988
-        /** @type WPDB $wpdb */
989
-        global $wpdb;
990
-        $SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d";
991
-        return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts));
992
-    }
993
-
994
-
995
-
996
-    /**
997
-     *    register_shortcodes_and_modules.
998
-     *    At this point, it's too early to tell if we're maintenance mode or not.
999
-     *    In fact, this is where we give modules a chance to let core know they exist
1000
-     *    so they can help trigger maintenance mode if it's needed
1001
-     *
1002
-     * @access    public
1003
-     * @return    void
1004
-     */
1005
-    public function register_shortcodes_and_modules()
1006
-    {
1007
-        // allow modules to set hooks for the rest of the system
1008
-        EE_Registry::instance()->modules = $this->_register_modules();
1009
-    }
1010
-
1011
-
1012
-
1013
-    /**
1014
-     *    initialize_shortcodes_and_modules
1015
-     *    meaning they can start adding their hooks to get stuff done
1016
-     *
1017
-     * @access    public
1018
-     * @return    void
1019
-     */
1020
-    public function initialize_shortcodes_and_modules()
1021
-    {
1022
-        // allow modules to set hooks for the rest of the system
1023
-        $this->_initialize_modules();
1024
-    }
1025
-
1026
-
1027
-
1028
-    /**
1029
-     *    widgets_init
1030
-     *
1031
-     * @access private
1032
-     * @return void
1033
-     */
1034
-    public function widgets_init()
1035
-    {
1036
-        //only init widgets on admin pages when not in complete maintenance, and
1037
-        //on frontend when not in any maintenance mode
1038
-        if (
1039
-            ! EE_Maintenance_Mode::instance()->level()
1040
-            || (
1041
-                is_admin()
1042
-                && EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance
1043
-            )
1044
-        ) {
1045
-            // grab list of installed widgets
1046
-            $widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR);
1047
-            // filter list of modules to register
1048
-            $widgets_to_register = apply_filters(
1049
-                'FHEE__EE_Config__register_widgets__widgets_to_register',
1050
-                $widgets_to_register
1051
-            );
1052
-            if (! empty($widgets_to_register)) {
1053
-                // cycle thru widget folders
1054
-                foreach ($widgets_to_register as $widget_path) {
1055
-                    // add to list of installed widget modules
1056
-                    EE_Config::register_ee_widget($widget_path);
1057
-                }
1058
-            }
1059
-            // filter list of installed modules
1060
-            EE_Registry::instance()->widgets = apply_filters(
1061
-                'FHEE__EE_Config__register_widgets__installed_widgets',
1062
-                EE_Registry::instance()->widgets
1063
-            );
1064
-        }
1065
-    }
1066
-
1067
-
1068
-
1069
-    /**
1070
-     *    register_ee_widget - makes core aware of this widget
1071
-     *
1072
-     * @access    public
1073
-     * @param    string $widget_path - full path up to and including widget folder
1074
-     * @return    void
1075
-     */
1076
-    public static function register_ee_widget($widget_path = null)
1077
-    {
1078
-        do_action('AHEE__EE_Config__register_widget__begin', $widget_path);
1079
-        $widget_ext = '.widget.php';
1080
-        // make all separators match
1081
-        $widget_path = rtrim(str_replace('/\\', DS, $widget_path), DS);
1082
-        // does the file path INCLUDE the actual file name as part of the path ?
1083
-        if (strpos($widget_path, $widget_ext) !== false) {
1084
-            // grab and shortcode file name from directory name and break apart at dots
1085
-            $file_name = explode('.', basename($widget_path));
1086
-            // take first segment from file name pieces and remove class prefix if it exists
1087
-            $widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0];
1088
-            // sanitize shortcode directory name
1089
-            $widget = sanitize_key($widget);
1090
-            // now we need to rebuild the shortcode path
1091
-            $widget_path = explode(DS, $widget_path);
1092
-            // remove last segment
1093
-            array_pop($widget_path);
1094
-            // glue it back together
1095
-            $widget_path = implode(DS, $widget_path);
1096
-        } else {
1097
-            // grab and sanitize widget directory name
1098
-            $widget = sanitize_key(basename($widget_path));
1099
-        }
1100
-        // create classname from widget directory name
1101
-        $widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget)));
1102
-        // add class prefix
1103
-        $widget_class = 'EEW_' . $widget;
1104
-        // does the widget exist ?
1105
-        if (! is_readable($widget_path . DS . $widget_class . $widget_ext)) {
1106
-            $msg = sprintf(
1107
-                __(
1108
-                    'The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s',
1109
-                    'event_espresso'
1110
-                ),
1111
-                $widget_class,
1112
-                $widget_path . DS . $widget_class . $widget_ext
1113
-            );
1114
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1115
-            return;
1116
-        }
1117
-        // load the widget class file
1118
-        require_once($widget_path . DS . $widget_class . $widget_ext);
1119
-        // verify that class exists
1120
-        if (! class_exists($widget_class)) {
1121
-            $msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class);
1122
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1123
-            return;
1124
-        }
1125
-        register_widget($widget_class);
1126
-        // add to array of registered widgets
1127
-        EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext;
1128
-    }
1129
-
1130
-
1131
-
1132
-    /**
1133
-     *        _register_modules
1134
-     *
1135
-     * @access private
1136
-     * @return array
1137
-     */
1138
-    private function _register_modules()
1139
-    {
1140
-        // grab list of installed modules
1141
-        $modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR);
1142
-        // filter list of modules to register
1143
-        $modules_to_register = apply_filters(
1144
-            'FHEE__EE_Config__register_modules__modules_to_register',
1145
-            $modules_to_register
1146
-        );
1147
-        if (! empty($modules_to_register)) {
1148
-            // loop through folders
1149
-            foreach ($modules_to_register as $module_path) {
1150
-                /**TEMPORARILY EXCLUDE gateways from modules for time being**/
1151
-                if (
1152
-                    $module_path !== EE_MODULES . 'zzz-copy-this-module-template'
1153
-                    && $module_path !== EE_MODULES . 'gateways'
1154
-                ) {
1155
-                    // add to list of installed modules
1156
-                    EE_Config::register_module($module_path);
1157
-                }
1158
-            }
1159
-        }
1160
-        // filter list of installed modules
1161
-        return apply_filters(
1162
-            'FHEE__EE_Config___register_modules__installed_modules',
1163
-            EE_Registry::instance()->modules
1164
-        );
1165
-    }
1166
-
1167
-
1168
-
1169
-    /**
1170
-     *    register_module - makes core aware of this module
1171
-     *
1172
-     * @access    public
1173
-     * @param    string $module_path - full path up to and including module folder
1174
-     * @return    bool
1175
-     */
1176
-    public static function register_module($module_path = null)
1177
-    {
1178
-        do_action('AHEE__EE_Config__register_module__begin', $module_path);
1179
-        $module_ext = '.module.php';
1180
-        // make all separators match
1181
-        $module_path = str_replace(array('\\', '/'), DS, $module_path);
1182
-        // does the file path INCLUDE the actual file name as part of the path ?
1183
-        if (strpos($module_path, $module_ext) !== false) {
1184
-            // grab and shortcode file name from directory name and break apart at dots
1185
-            $module_file = explode('.', basename($module_path));
1186
-            // now we need to rebuild the shortcode path
1187
-            $module_path = explode(DS, $module_path);
1188
-            // remove last segment
1189
-            array_pop($module_path);
1190
-            // glue it back together
1191
-            $module_path = implode(DS, $module_path) . DS;
1192
-            // take first segment from file name pieces and sanitize it
1193
-            $module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]);
1194
-            // ensure class prefix is added
1195
-            $module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module;
1196
-        } else {
1197
-            // we need to generate the filename based off of the folder name
1198
-            // grab and sanitize module name
1199
-            $module = strtolower(basename($module_path));
1200
-            $module = preg_replace('/[^a-z0-9_\-]/', '', $module);
1201
-            // like trailingslashit()
1202
-            $module_path = rtrim($module_path, DS) . DS;
1203
-            // create classname from module directory name
1204
-            $module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module)));
1205
-            // add class prefix
1206
-            $module_class = 'EED_' . $module;
1207
-        }
1208
-        // does the module exist ?
1209
-        if (! is_readable($module_path . DS . $module_class . $module_ext)) {
1210
-            $msg = sprintf(
1211
-                __(
1212
-                    'The requested %s module file could not be found or is not readable due to file permissions.',
1213
-                    'event_espresso'
1214
-                ),
1215
-                $module
1216
-            );
1217
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1218
-            return false;
1219
-        }
1220
-        // load the module class file
1221
-        require_once($module_path . $module_class . $module_ext);
1222
-        // verify that class exists
1223
-        if (! class_exists($module_class)) {
1224
-            $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
1225
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1226
-            return false;
1227
-        }
1228
-        // add to array of registered modules
1229
-        EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext;
1230
-        do_action(
1231
-            'AHEE__EE_Config__register_module__complete',
1232
-            $module_class,
1233
-            EE_Registry::instance()->modules->{$module_class}
1234
-        );
1235
-        return true;
1236
-    }
1237
-
1238
-
1239
-
1240
-    /**
1241
-     *    _initialize_modules
1242
-     *    allow modules to set hooks for the rest of the system
1243
-     *
1244
-     * @access private
1245
-     * @return void
1246
-     */
1247
-    private function _initialize_modules()
1248
-    {
1249
-        // cycle thru shortcode folders
1250
-        foreach (EE_Registry::instance()->modules as $module_class => $module_path) {
1251
-            // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
1252
-            // which set hooks ?
1253
-            if (is_admin()) {
1254
-                // fire immediately
1255
-                call_user_func(array($module_class, 'set_hooks_admin'));
1256
-            } else {
1257
-                // delay until other systems are online
1258
-                add_action(
1259
-                    'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons',
1260
-                    array($module_class, 'set_hooks')
1261
-                );
1262
-            }
1263
-        }
1264
-    }
1265
-
1266
-
1267
-
1268
-    /**
1269
-     *    register_route - adds module method routes to route_map
1270
-     *
1271
-     * @access    public
1272
-     * @param    string $route       - "pretty" public alias for module method
1273
-     * @param    string $module      - module name (classname without EED_ prefix)
1274
-     * @param    string $method_name - the actual module method to be routed to
1275
-     * @param    string $key         - url param key indicating a route is being called
1276
-     * @return    bool
1277
-     */
1278
-    public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee')
1279
-    {
1280
-        do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name);
1281
-        $module = str_replace('EED_', '', $module);
1282
-        $module_class = 'EED_' . $module;
1283
-        if (! isset(EE_Registry::instance()->modules->{$module_class})) {
1284
-            $msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module);
1285
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1286
-            return false;
1287
-        }
1288
-        if (empty($route)) {
1289
-            $msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route);
1290
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1291
-            return false;
1292
-        }
1293
-        if (! method_exists('EED_' . $module, $method_name)) {
1294
-            $msg = sprintf(
1295
-                __('A valid class method for the %s route has not been supplied.', 'event_espresso'),
1296
-                $route
1297
-            );
1298
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1299
-            return false;
1300
-        }
1301
-        EE_Config::$_module_route_map[$key][$route] = array('EED_' . $module, $method_name);
1302
-        return true;
1303
-    }
1304
-
1305
-
1306
-
1307
-    /**
1308
-     *    get_route - get module method route
1309
-     *
1310
-     * @access    public
1311
-     * @param    string $route - "pretty" public alias for module method
1312
-     * @param    string $key   - url param key indicating a route is being called
1313
-     * @return    string
1314
-     */
1315
-    public static function get_route($route = null, $key = 'ee')
1316
-    {
1317
-        do_action('AHEE__EE_Config__get_route__begin', $route);
1318
-        $route = (string)apply_filters('FHEE__EE_Config__get_route', $route);
1319
-        if (isset(EE_Config::$_module_route_map[$key][$route])) {
1320
-            return EE_Config::$_module_route_map[$key][$route];
1321
-        }
1322
-        return null;
1323
-    }
1324
-
1325
-
1326
-
1327
-    /**
1328
-     *    get_routes - get ALL module method routes
1329
-     *
1330
-     * @access    public
1331
-     * @return    array
1332
-     */
1333
-    public static function get_routes()
1334
-    {
1335
-        return EE_Config::$_module_route_map;
1336
-    }
1337
-
1338
-
1339
-
1340
-    /**
1341
-     *    register_forward - allows modules to forward request to another module for further processing
1342
-     *
1343
-     * @access    public
1344
-     * @param    string       $route   - "pretty" public alias for module method
1345
-     * @param    integer      $status  - integer value corresponding  to status constant strings set in module parent
1346
-     *                                 class, allows different forwards to be served based on status
1347
-     * @param    array|string $forward - function name or array( class, method )
1348
-     * @param    string       $key     - url param key indicating a route is being called
1349
-     * @return    bool
1350
-     */
1351
-    public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee')
1352
-    {
1353
-        do_action('AHEE__EE_Config__register_forward', $route, $status, $forward);
1354
-        if (! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1355
-            $msg = sprintf(
1356
-                __('The module route %s for this forward has not been registered.', 'event_espresso'),
1357
-                $route
1358
-            );
1359
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1360
-            return false;
1361
-        }
1362
-        if (empty($forward)) {
1363
-            $msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route);
1364
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1365
-            return false;
1366
-        }
1367
-        if (is_array($forward)) {
1368
-            if (! isset($forward[1])) {
1369
-                $msg = sprintf(
1370
-                    __('A class method for the %s forwarding route has not been supplied.', 'event_espresso'),
1371
-                    $route
1372
-                );
1373
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1374
-                return false;
1375
-            }
1376
-            if (! method_exists($forward[0], $forward[1])) {
1377
-                $msg = sprintf(
1378
-                    __('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'),
1379
-                    $forward[1],
1380
-                    $route
1381
-                );
1382
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1383
-                return false;
1384
-            }
1385
-        } else if (! function_exists($forward)) {
1386
-            $msg = sprintf(
1387
-                __('The function %s for the %s forwarding route is in invalid.', 'event_espresso'),
1388
-                $forward,
1389
-                $route
1390
-            );
1391
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1392
-            return false;
1393
-        }
1394
-        EE_Config::$_module_forward_map[$key][$route][absint($status)] = $forward;
1395
-        return true;
1396
-    }
1397
-
1398
-
1399
-
1400
-    /**
1401
-     *    get_forward - get forwarding route
1402
-     *
1403
-     * @access    public
1404
-     * @param    string  $route  - "pretty" public alias for module method
1405
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1406
-     *                           allows different forwards to be served based on status
1407
-     * @param    string  $key    - url param key indicating a route is being called
1408
-     * @return    string
1409
-     */
1410
-    public static function get_forward($route = null, $status = 0, $key = 'ee')
1411
-    {
1412
-        do_action('AHEE__EE_Config__get_forward__begin', $route, $status);
1413
-        if (isset(EE_Config::$_module_forward_map[$key][$route][$status])) {
1414
-            return apply_filters(
1415
-                'FHEE__EE_Config__get_forward',
1416
-                EE_Config::$_module_forward_map[$key][$route][$status],
1417
-                $route,
1418
-                $status
1419
-            );
1420
-        }
1421
-        return null;
1422
-    }
1423
-
1424
-
1425
-
1426
-    /**
1427
-     *    register_forward - allows modules to specify different view templates for different method routes and status
1428
-     *    results
1429
-     *
1430
-     * @access    public
1431
-     * @param    string  $route  - "pretty" public alias for module method
1432
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1433
-     *                           allows different views to be served based on status
1434
-     * @param    string  $view
1435
-     * @param    string  $key    - url param key indicating a route is being called
1436
-     * @return    bool
1437
-     */
1438
-    public static function register_view($route = null, $status = 0, $view = null, $key = 'ee')
1439
-    {
1440
-        do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view);
1441
-        if (! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1442
-            $msg = sprintf(
1443
-                __('The module route %s for this view has not been registered.', 'event_espresso'),
1444
-                $route
1445
-            );
1446
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1447
-            return false;
1448
-        }
1449
-        if (! is_readable($view)) {
1450
-            $msg = sprintf(
1451
-                __(
1452
-                    'The %s view file could not be found or is not readable due to file permissions.',
1453
-                    'event_espresso'
1454
-                ),
1455
-                $view
1456
-            );
1457
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1458
-            return false;
1459
-        }
1460
-        EE_Config::$_module_view_map[$key][$route][absint($status)] = $view;
1461
-        return true;
1462
-    }
1463
-
1464
-
1465
-
1466
-    /**
1467
-     *    get_view - get view for route and status
1468
-     *
1469
-     * @access    public
1470
-     * @param    string  $route  - "pretty" public alias for module method
1471
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1472
-     *                           allows different views to be served based on status
1473
-     * @param    string  $key    - url param key indicating a route is being called
1474
-     * @return    string
1475
-     */
1476
-    public static function get_view($route = null, $status = 0, $key = 'ee')
1477
-    {
1478
-        do_action('AHEE__EE_Config__get_view__begin', $route, $status);
1479
-        if (isset(EE_Config::$_module_view_map[$key][$route][$status])) {
1480
-            return apply_filters(
1481
-                'FHEE__EE_Config__get_view',
1482
-                EE_Config::$_module_view_map[$key][$route][$status],
1483
-                $route,
1484
-                $status
1485
-            );
1486
-        }
1487
-        return null;
1488
-    }
1489
-
1490
-
1491
-
1492
-    public function update_addon_option_names()
1493
-    {
1494
-        update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names);
1495
-    }
1496
-
1497
-
1498
-
1499
-    public function shutdown()
1500
-    {
1501
-        $this->update_addon_option_names();
1502
-    }
1503
-
1504
-
1505
-
1506
-    /**
1507
-     * @return LegacyShortcodesManager
1508
-     */
1509
-    public static function getLegacyShortcodesManager()
1510
-    {
1511
-
1512
-        if ( ! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) {
1513
-            EE_Config::instance()->legacy_shortcodes_manager = new LegacyShortcodesManager(
1514
-                EE_Registry::instance()
1515
-            );
1516
-        }
1517
-        return EE_Config::instance()->legacy_shortcodes_manager;
1518
-    }
1519
-
1520
-
1521
-
1522
-    /**
1523
-     * register_shortcode - makes core aware of this shortcode
1524
-     *
1525
-     * @deprecated 4.9.26
1526
-     * @param    string $shortcode_path - full path up to and including shortcode folder
1527
-     * @return    bool
1528
-     */
1529
-    public static function register_shortcode($shortcode_path = null)
1530
-    {
1531
-        EE_Error::doing_it_wrong(
1532
-            __METHOD__,
1533
-            __(
1534
-                'Usage is deprecated. Use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::registerShortcode() as direct replacement, or better yet, please see the new \EventEspresso\core\services\shortcodes\ShortcodesManager class.',
1535
-                'event_espresso'
1536
-            ),
1537
-            '4.9.26'
1538
-        );
1539
-        return EE_Config::instance()->getLegacyShortcodesManager()->registerShortcode($shortcode_path);
1540
-    }
1541
-
1542
-
1543
-
1544
-}
1545
-
1546
-
1547
-
1548
-/**
1549
- * Base class used for config classes. These classes should generally not have
1550
- * magic functions in use, except we'll allow them to magically set and get stuff...
1551
- * basically, they should just be well-defined stdClasses
1552
- */
1553
-class EE_Config_Base
1554
-{
1555
-
1556
-    /**
1557
-     * Utility function for escaping the value of a property and returning.
1558
-     *
1559
-     * @param string $property property name (checks to see if exists).
1560
-     * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1561
-     * @throws \EE_Error
1562
-     */
1563
-    public function get_pretty($property)
1564
-    {
1565
-        if (! property_exists($this, $property)) {
1566
-            throw new EE_Error(
1567
-                sprintf(
1568
-                    __(
1569
-                        '%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.',
1570
-                        'event_espresso'
1571
-                    ),
1572
-                    get_class($this),
1573
-                    $property
1574
-                )
1575
-            );
1576
-        }
1577
-        //just handling escaping of strings for now.
1578
-        if (is_string($this->{$property})) {
1579
-            return stripslashes($this->{$property});
1580
-        }
1581
-        return $this->{$property};
1582
-    }
1583
-
1584
-
1585
-
1586
-    public function populate()
1587
-    {
1588
-        //grab defaults via a new instance of this class.
1589
-        $class_name = get_class($this);
1590
-        $defaults = new $class_name;
1591
-        //loop through the properties for this class and see if they are set.  If they are NOT, then grab the
1592
-        //default from our $defaults object.
1593
-        foreach (get_object_vars($defaults) as $property => $value) {
1594
-            if ($this->{$property} === null) {
1595
-                $this->{$property} = $value;
1596
-            }
1597
-        }
1598
-        //cleanup
1599
-        unset($defaults);
1600
-    }
1601
-
1602
-
1603
-
1604
-    /**
1605
-     *        __isset
1606
-     *
1607
-     * @param $a
1608
-     * @return bool
1609
-     */
1610
-    public function __isset($a)
1611
-    {
1612
-        return false;
1613
-    }
1614
-
1615
-
1616
-
1617
-    /**
1618
-     *        __unset
1619
-     *
1620
-     * @param $a
1621
-     * @return bool
1622
-     */
1623
-    public function __unset($a)
1624
-    {
1625
-        return false;
1626
-    }
1627
-
1628
-
1629
-
1630
-    /**
1631
-     *        __clone
1632
-     */
1633
-    public function __clone()
1634
-    {
1635
-    }
1636
-
1637
-
1638
-
1639
-    /**
1640
-     *        __wakeup
1641
-     */
1642
-    public function __wakeup()
1643
-    {
1644
-    }
1645
-
1646
-
1647
-
1648
-    /**
1649
-     *        __destruct
1650
-     */
1651
-    public function __destruct()
1652
-    {
1653
-    }
1654
-}
1655
-
1656
-
1657
-
1658
-/**
1659
- * Class for defining what's in the EE_Config relating to registration settings
1660
- */
1661
-class EE_Core_Config extends EE_Config_Base
1662
-{
1663
-
1664
-    public $current_blog_id;
1665
-
1666
-    public $ee_ueip_optin;
1667
-
1668
-    public $ee_ueip_has_notified;
1669
-
1670
-    /**
1671
-     * Not to be confused with the 4 critical page variables (See
1672
-     * get_critical_pages_array()), this is just an array of wp posts that have EE
1673
-     * shortcodes in them. Keys are slugs, values are arrays with only 1 element: where the key is the shortcode
1674
-     * in the page, and the value is the page's ID. The key 'posts' is basically a duplicate of this same array.
1675
-     *
1676
-     * @var array
1677
-     */
1678
-    public $post_shortcodes;
1679
-
1680
-    public $module_route_map;
1681
-
1682
-    public $module_forward_map;
1683
-
1684
-    public $module_view_map;
1685
-
1686
-    /**
1687
-     * The next 4 vars are the IDs of critical EE pages.
1688
-     *
1689
-     * @var int
1690
-     */
1691
-    public $reg_page_id;
1692
-
1693
-    public $txn_page_id;
1694
-
1695
-    public $thank_you_page_id;
1696
-
1697
-    public $cancel_page_id;
1698
-
1699
-    /**
1700
-     * The next 4 vars are the URLs of critical EE pages.
1701
-     *
1702
-     * @var int
1703
-     */
1704
-    public $reg_page_url;
1705
-
1706
-    public $txn_page_url;
1707
-
1708
-    public $thank_you_page_url;
1709
-
1710
-    public $cancel_page_url;
1711
-
1712
-    /**
1713
-     * The next vars relate to the custom slugs for EE CPT routes
1714
-     */
1715
-    public $event_cpt_slug;
1716
-
1717
-
1718
-    /**
1719
-     * This caches the _ee_ueip_option in case this config is reset in the same
1720
-     * request across blog switches in a multisite context.
1721
-     * Avoids extra queries to the db for this option.
1722
-     *
1723
-     * @var bool
1724
-     */
1725
-    public static $ee_ueip_option;
1726
-
1727
-
1728
-
1729
-    /**
1730
-     *    class constructor
1731
-     *
1732
-     * @access    public
1733
-     */
1734
-    public function __construct()
1735
-    {
1736
-        // set default organization settings
1737
-        $this->current_blog_id = get_current_blog_id();
1738
-        $this->current_blog_id = $this->current_blog_id === null ? 1 : $this->current_blog_id;
1739
-        $this->ee_ueip_optin = $this->_get_main_ee_ueip_optin();
1740
-        $this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true;
1741
-        $this->post_shortcodes = array();
1742
-        $this->module_route_map = array();
1743
-        $this->module_forward_map = array();
1744
-        $this->module_view_map = array();
1745
-        // critical EE page IDs
1746
-        $this->reg_page_id = 0;
1747
-        $this->txn_page_id = 0;
1748
-        $this->thank_you_page_id = 0;
1749
-        $this->cancel_page_id = 0;
1750
-        // critical EE page URLs
1751
-        $this->reg_page_url = '';
1752
-        $this->txn_page_url = '';
1753
-        $this->thank_you_page_url = '';
1754
-        $this->cancel_page_url = '';
1755
-        //cpt slugs
1756
-        $this->event_cpt_slug = __('events', 'event_espresso');
1757
-        //ueip constant check
1758
-        if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) {
1759
-            $this->ee_ueip_optin = false;
1760
-            $this->ee_ueip_has_notified = true;
1761
-        }
1762
-    }
1763
-
1764
-
1765
-
1766
-    /**
1767
-     * @return array
1768
-     */
1769
-    public function get_critical_pages_array()
1770
-    {
1771
-        return array(
1772
-            $this->reg_page_id,
1773
-            $this->txn_page_id,
1774
-            $this->thank_you_page_id,
1775
-            $this->cancel_page_id,
1776
-        );
1777
-    }
1778
-
1779
-
1780
-
1781
-    /**
1782
-     * @return array
1783
-     */
1784
-    public function get_critical_pages_shortcodes_array()
1785
-    {
1786
-        return array(
1787
-            $this->reg_page_id       => 'ESPRESSO_CHECKOUT',
1788
-            $this->txn_page_id       => 'ESPRESSO_TXN_PAGE',
1789
-            $this->thank_you_page_id => 'ESPRESSO_THANK_YOU',
1790
-            $this->cancel_page_id    => 'ESPRESSO_CANCELLED',
1791
-        );
1792
-    }
1793
-
1794
-
1795
-
1796
-    /**
1797
-     *  gets/returns URL for EE reg_page
1798
-     *
1799
-     * @access    public
1800
-     * @return    string
1801
-     */
1802
-    public function reg_page_url()
1803
-    {
1804
-        if (! $this->reg_page_url) {
1805
-            $this->reg_page_url = add_query_arg(
1806
-                                      array('uts' => time()),
1807
-                                      get_permalink($this->reg_page_id)
1808
-                                  ) . '#checkout';
1809
-        }
1810
-        return $this->reg_page_url;
1811
-    }
1812
-
1813
-
1814
-
1815
-    /**
1816
-     *  gets/returns URL for EE txn_page
1817
-     *
1818
-     * @param array $query_args like what gets passed to
1819
-     *                          add_query_arg() as the first argument
1820
-     * @access    public
1821
-     * @return    string
1822
-     */
1823
-    public function txn_page_url($query_args = array())
1824
-    {
1825
-        if (! $this->txn_page_url) {
1826
-            $this->txn_page_url = get_permalink($this->txn_page_id);
1827
-        }
1828
-        if ($query_args) {
1829
-            return add_query_arg($query_args, $this->txn_page_url);
1830
-        } else {
1831
-            return $this->txn_page_url;
1832
-        }
1833
-    }
1834
-
1835
-
1836
-
1837
-    /**
1838
-     *  gets/returns URL for EE thank_you_page
1839
-     *
1840
-     * @param array $query_args like what gets passed to
1841
-     *                          add_query_arg() as the first argument
1842
-     * @access    public
1843
-     * @return    string
1844
-     */
1845
-    public function thank_you_page_url($query_args = array())
1846
-    {
1847
-        if (! $this->thank_you_page_url) {
1848
-            $this->thank_you_page_url = get_permalink($this->thank_you_page_id);
1849
-        }
1850
-        if ($query_args) {
1851
-            return add_query_arg($query_args, $this->thank_you_page_url);
1852
-        } else {
1853
-            return $this->thank_you_page_url;
1854
-        }
1855
-    }
1856
-
1857
-
1858
-
1859
-    /**
1860
-     *  gets/returns URL for EE cancel_page
1861
-     *
1862
-     * @access    public
1863
-     * @return    string
1864
-     */
1865
-    public function cancel_page_url()
1866
-    {
1867
-        if (! $this->cancel_page_url) {
1868
-            $this->cancel_page_url = get_permalink($this->cancel_page_id);
1869
-        }
1870
-        return $this->cancel_page_url;
1871
-    }
1872
-
1873
-
1874
-
1875
-    /**
1876
-     * Resets all critical page urls to their original state.  Used primarily by the __sleep() magic method currently.
1877
-     *
1878
-     * @since 4.7.5
1879
-     */
1880
-    protected function _reset_urls()
1881
-    {
1882
-        $this->reg_page_url = '';
1883
-        $this->txn_page_url = '';
1884
-        $this->cancel_page_url = '';
1885
-        $this->thank_you_page_url = '';
1886
-    }
1887
-
1888
-
1889
-
1890
-    /**
1891
-     * Used to return what the optin value is set for the EE User Experience Program.
1892
-     * This accounts for multisite and this value being requested for a subsite.  In multisite, the value is set
1893
-     * on the main site only.
1894
-     *
1895
-     * @return mixed|void
1896
-     */
1897
-    protected function _get_main_ee_ueip_optin()
1898
-    {
1899
-        //if this is the main site then we can just bypass our direct query.
1900
-        if (is_main_site()) {
1901
-            return get_option('ee_ueip_optin', false);
1902
-        }
1903
-        //is this already cached for this request?  If so use it.
1904
-        if ( ! empty(EE_Core_Config::$ee_ueip_option)) {
1905
-            return EE_Core_Config::$ee_ueip_option;
1906
-        }
1907
-        global $wpdb;
1908
-        $current_network_main_site = is_multisite() ? get_current_site() : null;
1909
-        $current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1;
1910
-        $option = 'ee_ueip_optin';
1911
-        //set correct table for query
1912
-        $table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options';
1913
-        //rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because
1914
-        //get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be
1915
-        //re-constructed on the blog switch.  Note, we are still executing any core wp filters on this option retrieval.
1916
-        //this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog
1917
-        //for the purpose of caching.
1918
-        $pre = apply_filters('pre_option_' . $option, false, $option);
1919
-        if (false !== $pre) {
1920
-            EE_Core_Config::$ee_ueip_option = $pre;
1921
-            return EE_Core_Config::$ee_ueip_option;
1922
-        }
1923
-        $row = $wpdb->get_row($wpdb->prepare("SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1",
1924
-            $option));
1925
-        if (is_object($row)) {
1926
-            $value = $row->option_value;
1927
-        } else { //option does not exist so use default.
1928
-            return apply_filters('default_option_' . $option, false, $option);
1929
-        }
1930
-        EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option);
1931
-        return EE_Core_Config::$ee_ueip_option;
1932
-    }
1933
-
1934
-    /**
1935
-     * Utility function for escaping the value of a property and returning.
1936
-     *
1937
-     * @param string $property property name (checks to see if exists).
1938
-     * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1939
-     * @throws \EE_Error
1940
-     */
1941
-    public function get_pretty($property)
1942
-    {
1943
-        if ($property === 'ee_ueip_optin') {
1944
-            return $this->ee_ueip_optin ? 'yes' : 'no';
1945
-        }
1946
-        return parent::get_pretty($property);
1947
-    }
1948
-
1949
-
1950
-    /**
1951
-     * Currently used to ensure critical page urls have initial values saved to the db instead of any current set values
1952
-     * on the object.
1953
-     *
1954
-     * @return array
1955
-     */
1956
-    public function __sleep()
1957
-    {
1958
-        //reset all url properties
1959
-        $this->_reset_urls();
1960
-        //return what to save to db
1961
-        return array_keys(get_object_vars($this));
1962
-    }
1963
-
1964
-}
1965
-
1966
-
1967
-
1968
-/**
1969
- * Config class for storing info on the Organization
1970
- */
1971
-class EE_Organization_Config extends EE_Config_Base
1972
-{
1973
-
1974
-    /**
1975
-     * @var string $name
1976
-     * eg EE4.1
1977
-     */
1978
-    public $name;
1979
-
1980
-    /**
1981
-     * @var string $address_1
1982
-     * eg 123 Onna Road
1983
-     */
1984
-    public $address_1;
1985
-
1986
-    /**
1987
-     * @var string $address_2
1988
-     * eg PO Box 123
1989
-     */
1990
-    public $address_2;
1991
-
1992
-    /**
1993
-     * @var string $city
1994
-     * eg Inna City
1995
-     */
1996
-    public $city;
1997
-
1998
-    /**
1999
-     * @var int $STA_ID
2000
-     * eg 4
2001
-     */
2002
-    public $STA_ID;
2003
-
2004
-    /**
2005
-     * @var string $CNT_ISO
2006
-     * eg US
2007
-     */
2008
-    public $CNT_ISO;
2009
-
2010
-    /**
2011
-     * @var string $zip
2012
-     * eg 12345  or V1A 2B3
2013
-     */
2014
-    public $zip;
2015
-
2016
-    /**
2017
-     * @var string $email
2018
-     * eg [email protected]
2019
-     */
2020
-    public $email;
2021
-
2022
-
2023
-    /**
2024
-     * @var string $phone
2025
-     * eg. 111-111-1111
2026
-     */
2027
-    public $phone;
2028
-
2029
-
2030
-    /**
2031
-     * @var string $vat
2032
-     * VAT/Tax Number
2033
-     */
2034
-    public $vat;
2035
-
2036
-    /**
2037
-     * @var string $logo_url
2038
-     * eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg
2039
-     */
2040
-    public $logo_url;
2041
-
2042
-
2043
-    /**
2044
-     * The below are all various properties for holding links to organization social network profiles
2045
-     *
2046
-     * @var string
2047
-     */
2048
-    /**
2049
-     * facebook (facebook.com/profile.name)
2050
-     *
2051
-     * @var string
2052
-     */
2053
-    public $facebook;
2054
-
2055
-
2056
-    /**
2057
-     * twitter (twitter.com/twitter_handle)
2058
-     *
2059
-     * @var string
2060
-     */
2061
-    public $twitter;
2062
-
2063
-
2064
-    /**
2065
-     * linkedin (linkedin.com/in/profile_name)
2066
-     *
2067
-     * @var string
2068
-     */
2069
-    public $linkedin;
2070
-
2071
-
2072
-    /**
2073
-     * pinterest (www.pinterest.com/profile_name)
2074
-     *
2075
-     * @var string
2076
-     */
2077
-    public $pinterest;
2078
-
2079
-
2080
-    /**
2081
-     * google+ (google.com/+profileName)
2082
-     *
2083
-     * @var string
2084
-     */
2085
-    public $google;
2086
-
2087
-
2088
-    /**
2089
-     * instagram (instagram.com/handle)
2090
-     *
2091
-     * @var string
2092
-     */
2093
-    public $instagram;
2094
-
2095
-
2096
-
2097
-    /**
2098
-     *    class constructor
2099
-     *
2100
-     * @access    public
2101
-     */
2102
-    public function __construct()
2103
-    {
2104
-        // set default organization settings
2105
-        //decode HTML entities from the WP blogname, because it's stored in the DB with HTML entities encoded
2106
-        $this->name = wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES);
2107
-        $this->address_1 = '123 Onna Road';
2108
-        $this->address_2 = 'PO Box 123';
2109
-        $this->city = 'Inna City';
2110
-        $this->STA_ID = 4;
2111
-        $this->CNT_ISO = 'US';
2112
-        $this->zip = '12345';
2113
-        $this->email = get_bloginfo('admin_email');
2114
-        $this->phone = '';
2115
-        $this->vat = '123456789';
2116
-        $this->logo_url = '';
2117
-        $this->facebook = '';
2118
-        $this->twitter = '';
2119
-        $this->linkedin = '';
2120
-        $this->pinterest = '';
2121
-        $this->google = '';
2122
-        $this->instagram = '';
2123
-    }
2124
-
2125
-}
2126
-
2127
-
2128
-
2129
-/**
2130
- * Class for defining what's in the EE_Config relating to currency
2131
- */
2132
-class EE_Currency_Config extends EE_Config_Base
2133
-{
2134
-
2135
-    /**
2136
-     * @var string $code
2137
-     * eg 'US'
2138
-     */
2139
-    public $code;
2140
-
2141
-    /**
2142
-     * @var string $name
2143
-     * eg 'Dollar'
2144
-     */
2145
-    public $name;
2146
-
2147
-    /**
2148
-     * plural name
2149
-     *
2150
-     * @var string $plural
2151
-     * eg 'Dollars'
2152
-     */
2153
-    public $plural;
2154
-
2155
-    /**
2156
-     * currency sign
2157
-     *
2158
-     * @var string $sign
2159
-     * eg '$'
2160
-     */
2161
-    public $sign;
2162
-
2163
-    /**
2164
-     * Whether the currency sign should come before the number or not
2165
-     *
2166
-     * @var boolean $sign_b4
2167
-     */
2168
-    public $sign_b4;
2169
-
2170
-    /**
2171
-     * How many digits should come after the decimal place
2172
-     *
2173
-     * @var int $dec_plc
2174
-     */
2175
-    public $dec_plc;
2176
-
2177
-    /**
2178
-     * Symbol to use for decimal mark
2179
-     *
2180
-     * @var string $dec_mrk
2181
-     * eg '.'
2182
-     */
2183
-    public $dec_mrk;
2184
-
2185
-    /**
2186
-     * Symbol to use for thousands
2187
-     *
2188
-     * @var string $thsnds
2189
-     * eg ','
2190
-     */
2191
-    public $thsnds;
2192
-
2193
-
2194
-
2195
-    /**
2196
-     *    class constructor
2197
-     *
2198
-     * @access    public
2199
-     * @param string $CNT_ISO
2200
-     * @throws \EE_Error
2201
-     */
2202
-    public function __construct($CNT_ISO = '')
2203
-    {
2204
-        /** @var \EventEspresso\core\services\database\TableAnalysis $table_analysis */
2205
-        $table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
2206
-        // get country code from organization settings or use default
2207
-        $ORG_CNT = isset(EE_Registry::instance()->CFG->organization)
2208
-                   && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config
2209
-            ? EE_Registry::instance()->CFG->organization->CNT_ISO
2210
-            : '';
2211
-        // but override if requested
2212
-        $CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT;
2213
-        // so if that all went well, and we are not in M-Mode (cuz you can't query the db in M-Mode) and double-check the countries table exists
2214
-        if (
2215
-            ! empty($CNT_ISO)
2216
-            && EE_Maintenance_Mode::instance()->models_can_query()
2217
-            && $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table())
2218
-        ) {
2219
-            // retrieve the country settings from the db, just in case they have been customized
2220
-            $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO);
2221
-            if ($country instanceof EE_Country) {
2222
-                $this->code = $country->currency_code();    // currency code: USD, CAD, EUR
2223
-                $this->name = $country->currency_name_single();    // Dollar
2224
-                $this->plural = $country->currency_name_plural();    // Dollars
2225
-                $this->sign = $country->currency_sign();            // currency sign: $
2226
-                $this->sign_b4 = $country->currency_sign_before();        // currency sign before or after: $TRUE  or  FALSE$
2227
-                $this->dec_plc = $country->currency_decimal_places();    // decimal places: 2 = 0.00  3 = 0.000
2228
-                $this->dec_mrk = $country->currency_decimal_mark();    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2229
-                $this->thsnds = $country->currency_thousands_separator();    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2230
-            }
2231
-        }
2232
-        // fallback to hardcoded defaults, in case the above failed
2233
-        if (empty($this->code)) {
2234
-            // set default currency settings
2235
-            $this->code = 'USD';    // currency code: USD, CAD, EUR
2236
-            $this->name = __('Dollar', 'event_espresso');    // Dollar
2237
-            $this->plural = __('Dollars', 'event_espresso');    // Dollars
2238
-            $this->sign = '$';    // currency sign: $
2239
-            $this->sign_b4 = true;    // currency sign before or after: $TRUE  or  FALSE$
2240
-            $this->dec_plc = 2;    // decimal places: 2 = 0.00  3 = 0.000
2241
-            $this->dec_mrk = '.';    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2242
-            $this->thsnds = ',';    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2243
-        }
2244
-    }
2245
-}
2246
-
2247
-
2248
-
2249
-/**
2250
- * Class for defining what's in the EE_Config relating to registration settings
2251
- */
2252
-class EE_Registration_Config extends EE_Config_Base
2253
-{
2254
-
2255
-    /**
2256
-     * Default registration status
2257
-     *
2258
-     * @var string $default_STS_ID
2259
-     * eg 'RPP'
2260
-     */
2261
-    public $default_STS_ID;
2262
-
2263
-
2264
-    /**
2265
-     * For new events, this will be the default value for the maximum number of tickets (equivalent to maximum number of
2266
-     * registrations)
2267
-     * @var int
2268
-     */
2269
-    public $default_maximum_number_of_tickets;
2270
-
2271
-
2272
-    /**
2273
-     * level of validation to apply to email addresses
2274
-     *
2275
-     * @var string $email_validation_level
2276
-     * options: 'basic', 'wp_default', 'i18n', 'i18n_dns'
2277
-     */
2278
-    public $email_validation_level;
2279
-
2280
-    /**
2281
-     *    whether or not to show alternate payment options during the reg process if payment status is pending
2282
-     *
2283
-     * @var boolean $show_pending_payment_options
2284
-     */
2285
-    public $show_pending_payment_options;
2286
-
2287
-    /**
2288
-     * Whether to skip the registration confirmation page
2289
-     *
2290
-     * @var boolean $skip_reg_confirmation
2291
-     */
2292
-    public $skip_reg_confirmation;
2293
-
2294
-    /**
2295
-     * an array of SPCO reg steps where:
2296
-     *        the keys denotes the reg step order
2297
-     *        each element consists of an array with the following elements:
2298
-     *            "file_path" => the file path to the EE_SPCO_Reg_Step class
2299
-     *            "class_name" => the specific EE_SPCO_Reg_Step child class name
2300
-     *            "slug" => the URL param used to trigger the reg step
2301
-     *
2302
-     * @var array $reg_steps
2303
-     */
2304
-    public $reg_steps;
2305
-
2306
-    /**
2307
-     * Whether registration confirmation should be the last page of SPCO
2308
-     *
2309
-     * @var boolean $reg_confirmation_last
2310
-     */
2311
-    public $reg_confirmation_last;
2312
-
2313
-    /**
2314
-     * Whether or not to enable the EE Bot Trap
2315
-     *
2316
-     * @var boolean $use_bot_trap
2317
-     */
2318
-    public $use_bot_trap;
2319
-
2320
-    /**
2321
-     * Whether or not to encrypt some data sent by the EE Bot Trap
2322
-     *
2323
-     * @var boolean $use_encryption
2324
-     */
2325
-    public $use_encryption;
2326
-
2327
-    /**
2328
-     * Whether or not to use ReCaptcha
2329
-     *
2330
-     * @var boolean $use_captcha
2331
-     */
2332
-    public $use_captcha;
2333
-
2334
-    /**
2335
-     * ReCaptcha Theme
2336
-     *
2337
-     * @var string $recaptcha_theme
2338
-     *    options: 'dark', 'light', 'invisible'
2339
-     */
2340
-    public $recaptcha_theme;
1544
+}
2341 1545
 
2342
-    /**
2343
-     * ReCaptcha Badge - determines the position of the reCAPTCHA badge if using Invisible ReCaptcha.
2344
-     *
2345
-     * @var string $recaptcha_badge
2346
-     *    options: 'bottomright', 'bottomleft', 'inline'
2347
-     */
2348
-    public $recaptcha_badge;
2349 1546
 
2350
-    /**
2351
-     * ReCaptcha Type
2352
-     *
2353
-     * @var string $recaptcha_type
2354
-     *    options: 'audio', 'image'
2355
-     */
2356
-    public $recaptcha_type;
2357 1547
 
2358
-    /**
2359
-     * ReCaptcha language
2360
-     *
2361
-     * @var string $recaptcha_language
2362
-     * eg 'en'
2363
-     */
2364
-    public $recaptcha_language;
1548
+/**
1549
+ * Base class used for config classes. These classes should generally not have
1550
+ * magic functions in use, except we'll allow them to magically set and get stuff...
1551
+ * basically, they should just be well-defined stdClasses
1552
+ */
1553
+class EE_Config_Base
1554
+{
2365 1555
 
2366
-    /**
2367
-     * ReCaptcha public key
2368
-     *
2369
-     * @var string $recaptcha_publickey
2370
-     */
2371
-    public $recaptcha_publickey;
1556
+	/**
1557
+	 * Utility function for escaping the value of a property and returning.
1558
+	 *
1559
+	 * @param string $property property name (checks to see if exists).
1560
+	 * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1561
+	 * @throws \EE_Error
1562
+	 */
1563
+	public function get_pretty($property)
1564
+	{
1565
+		if (! property_exists($this, $property)) {
1566
+			throw new EE_Error(
1567
+				sprintf(
1568
+					__(
1569
+						'%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.',
1570
+						'event_espresso'
1571
+					),
1572
+					get_class($this),
1573
+					$property
1574
+				)
1575
+			);
1576
+		}
1577
+		//just handling escaping of strings for now.
1578
+		if (is_string($this->{$property})) {
1579
+			return stripslashes($this->{$property});
1580
+		}
1581
+		return $this->{$property};
1582
+	}
1583
+
1584
+
1585
+
1586
+	public function populate()
1587
+	{
1588
+		//grab defaults via a new instance of this class.
1589
+		$class_name = get_class($this);
1590
+		$defaults = new $class_name;
1591
+		//loop through the properties for this class and see if they are set.  If they are NOT, then grab the
1592
+		//default from our $defaults object.
1593
+		foreach (get_object_vars($defaults) as $property => $value) {
1594
+			if ($this->{$property} === null) {
1595
+				$this->{$property} = $value;
1596
+			}
1597
+		}
1598
+		//cleanup
1599
+		unset($defaults);
1600
+	}
1601
+
1602
+
1603
+
1604
+	/**
1605
+	 *        __isset
1606
+	 *
1607
+	 * @param $a
1608
+	 * @return bool
1609
+	 */
1610
+	public function __isset($a)
1611
+	{
1612
+		return false;
1613
+	}
1614
+
1615
+
1616
+
1617
+	/**
1618
+	 *        __unset
1619
+	 *
1620
+	 * @param $a
1621
+	 * @return bool
1622
+	 */
1623
+	public function __unset($a)
1624
+	{
1625
+		return false;
1626
+	}
1627
+
1628
+
1629
+
1630
+	/**
1631
+	 *        __clone
1632
+	 */
1633
+	public function __clone()
1634
+	{
1635
+	}
1636
+
1637
+
1638
+
1639
+	/**
1640
+	 *        __wakeup
1641
+	 */
1642
+	public function __wakeup()
1643
+	{
1644
+	}
1645
+
1646
+
1647
+
1648
+	/**
1649
+	 *        __destruct
1650
+	 */
1651
+	public function __destruct()
1652
+	{
1653
+	}
1654
+}
2372 1655
 
2373
-    /**
2374
-     * ReCaptcha private key
2375
-     *
2376
-     * @var string $recaptcha_privatekey
2377
-     */
2378
-    public $recaptcha_privatekey;
2379 1656
 
2380
-    /**
2381
-     * array of form names protected by ReCaptcha
2382
-     *
2383
-     * @var array $recaptcha_protected_forms
2384
-     */
2385
-    public $recaptcha_protected_forms;
2386 1657
 
2387
-    /**
2388
-     * ReCaptcha width
2389
-     *
2390
-     * @var int $recaptcha_width
2391
-     * @deprecated
2392
-     */
2393
-    public $recaptcha_width;
1658
+/**
1659
+ * Class for defining what's in the EE_Config relating to registration settings
1660
+ */
1661
+class EE_Core_Config extends EE_Config_Base
1662
+{
2394 1663
 
2395
-    /**
2396
-     * Whether or not invalid attempts to directly access the registration checkout page should be tracked.
2397
-     *
2398
-     * @var boolean $track_invalid_checkout_access
2399
-     */
2400
-    protected $track_invalid_checkout_access = true;
1664
+	public $current_blog_id;
1665
+
1666
+	public $ee_ueip_optin;
1667
+
1668
+	public $ee_ueip_has_notified;
1669
+
1670
+	/**
1671
+	 * Not to be confused with the 4 critical page variables (See
1672
+	 * get_critical_pages_array()), this is just an array of wp posts that have EE
1673
+	 * shortcodes in them. Keys are slugs, values are arrays with only 1 element: where the key is the shortcode
1674
+	 * in the page, and the value is the page's ID. The key 'posts' is basically a duplicate of this same array.
1675
+	 *
1676
+	 * @var array
1677
+	 */
1678
+	public $post_shortcodes;
1679
+
1680
+	public $module_route_map;
1681
+
1682
+	public $module_forward_map;
1683
+
1684
+	public $module_view_map;
1685
+
1686
+	/**
1687
+	 * The next 4 vars are the IDs of critical EE pages.
1688
+	 *
1689
+	 * @var int
1690
+	 */
1691
+	public $reg_page_id;
1692
+
1693
+	public $txn_page_id;
1694
+
1695
+	public $thank_you_page_id;
1696
+
1697
+	public $cancel_page_id;
1698
+
1699
+	/**
1700
+	 * The next 4 vars are the URLs of critical EE pages.
1701
+	 *
1702
+	 * @var int
1703
+	 */
1704
+	public $reg_page_url;
1705
+
1706
+	public $txn_page_url;
1707
+
1708
+	public $thank_you_page_url;
1709
+
1710
+	public $cancel_page_url;
1711
+
1712
+	/**
1713
+	 * The next vars relate to the custom slugs for EE CPT routes
1714
+	 */
1715
+	public $event_cpt_slug;
1716
+
1717
+
1718
+	/**
1719
+	 * This caches the _ee_ueip_option in case this config is reset in the same
1720
+	 * request across blog switches in a multisite context.
1721
+	 * Avoids extra queries to the db for this option.
1722
+	 *
1723
+	 * @var bool
1724
+	 */
1725
+	public static $ee_ueip_option;
1726
+
1727
+
1728
+
1729
+	/**
1730
+	 *    class constructor
1731
+	 *
1732
+	 * @access    public
1733
+	 */
1734
+	public function __construct()
1735
+	{
1736
+		// set default organization settings
1737
+		$this->current_blog_id = get_current_blog_id();
1738
+		$this->current_blog_id = $this->current_blog_id === null ? 1 : $this->current_blog_id;
1739
+		$this->ee_ueip_optin = $this->_get_main_ee_ueip_optin();
1740
+		$this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true;
1741
+		$this->post_shortcodes = array();
1742
+		$this->module_route_map = array();
1743
+		$this->module_forward_map = array();
1744
+		$this->module_view_map = array();
1745
+		// critical EE page IDs
1746
+		$this->reg_page_id = 0;
1747
+		$this->txn_page_id = 0;
1748
+		$this->thank_you_page_id = 0;
1749
+		$this->cancel_page_id = 0;
1750
+		// critical EE page URLs
1751
+		$this->reg_page_url = '';
1752
+		$this->txn_page_url = '';
1753
+		$this->thank_you_page_url = '';
1754
+		$this->cancel_page_url = '';
1755
+		//cpt slugs
1756
+		$this->event_cpt_slug = __('events', 'event_espresso');
1757
+		//ueip constant check
1758
+		if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) {
1759
+			$this->ee_ueip_optin = false;
1760
+			$this->ee_ueip_has_notified = true;
1761
+		}
1762
+	}
1763
+
1764
+
1765
+
1766
+	/**
1767
+	 * @return array
1768
+	 */
1769
+	public function get_critical_pages_array()
1770
+	{
1771
+		return array(
1772
+			$this->reg_page_id,
1773
+			$this->txn_page_id,
1774
+			$this->thank_you_page_id,
1775
+			$this->cancel_page_id,
1776
+		);
1777
+	}
1778
+
1779
+
1780
+
1781
+	/**
1782
+	 * @return array
1783
+	 */
1784
+	public function get_critical_pages_shortcodes_array()
1785
+	{
1786
+		return array(
1787
+			$this->reg_page_id       => 'ESPRESSO_CHECKOUT',
1788
+			$this->txn_page_id       => 'ESPRESSO_TXN_PAGE',
1789
+			$this->thank_you_page_id => 'ESPRESSO_THANK_YOU',
1790
+			$this->cancel_page_id    => 'ESPRESSO_CANCELLED',
1791
+		);
1792
+	}
1793
+
1794
+
1795
+
1796
+	/**
1797
+	 *  gets/returns URL for EE reg_page
1798
+	 *
1799
+	 * @access    public
1800
+	 * @return    string
1801
+	 */
1802
+	public function reg_page_url()
1803
+	{
1804
+		if (! $this->reg_page_url) {
1805
+			$this->reg_page_url = add_query_arg(
1806
+									  array('uts' => time()),
1807
+									  get_permalink($this->reg_page_id)
1808
+								  ) . '#checkout';
1809
+		}
1810
+		return $this->reg_page_url;
1811
+	}
1812
+
1813
+
1814
+
1815
+	/**
1816
+	 *  gets/returns URL for EE txn_page
1817
+	 *
1818
+	 * @param array $query_args like what gets passed to
1819
+	 *                          add_query_arg() as the first argument
1820
+	 * @access    public
1821
+	 * @return    string
1822
+	 */
1823
+	public function txn_page_url($query_args = array())
1824
+	{
1825
+		if (! $this->txn_page_url) {
1826
+			$this->txn_page_url = get_permalink($this->txn_page_id);
1827
+		}
1828
+		if ($query_args) {
1829
+			return add_query_arg($query_args, $this->txn_page_url);
1830
+		} else {
1831
+			return $this->txn_page_url;
1832
+		}
1833
+	}
1834
+
1835
+
1836
+
1837
+	/**
1838
+	 *  gets/returns URL for EE thank_you_page
1839
+	 *
1840
+	 * @param array $query_args like what gets passed to
1841
+	 *                          add_query_arg() as the first argument
1842
+	 * @access    public
1843
+	 * @return    string
1844
+	 */
1845
+	public function thank_you_page_url($query_args = array())
1846
+	{
1847
+		if (! $this->thank_you_page_url) {
1848
+			$this->thank_you_page_url = get_permalink($this->thank_you_page_id);
1849
+		}
1850
+		if ($query_args) {
1851
+			return add_query_arg($query_args, $this->thank_you_page_url);
1852
+		} else {
1853
+			return $this->thank_you_page_url;
1854
+		}
1855
+	}
1856
+
1857
+
1858
+
1859
+	/**
1860
+	 *  gets/returns URL for EE cancel_page
1861
+	 *
1862
+	 * @access    public
1863
+	 * @return    string
1864
+	 */
1865
+	public function cancel_page_url()
1866
+	{
1867
+		if (! $this->cancel_page_url) {
1868
+			$this->cancel_page_url = get_permalink($this->cancel_page_id);
1869
+		}
1870
+		return $this->cancel_page_url;
1871
+	}
1872
+
1873
+
1874
+
1875
+	/**
1876
+	 * Resets all critical page urls to their original state.  Used primarily by the __sleep() magic method currently.
1877
+	 *
1878
+	 * @since 4.7.5
1879
+	 */
1880
+	protected function _reset_urls()
1881
+	{
1882
+		$this->reg_page_url = '';
1883
+		$this->txn_page_url = '';
1884
+		$this->cancel_page_url = '';
1885
+		$this->thank_you_page_url = '';
1886
+	}
1887
+
1888
+
1889
+
1890
+	/**
1891
+	 * Used to return what the optin value is set for the EE User Experience Program.
1892
+	 * This accounts for multisite and this value being requested for a subsite.  In multisite, the value is set
1893
+	 * on the main site only.
1894
+	 *
1895
+	 * @return mixed|void
1896
+	 */
1897
+	protected function _get_main_ee_ueip_optin()
1898
+	{
1899
+		//if this is the main site then we can just bypass our direct query.
1900
+		if (is_main_site()) {
1901
+			return get_option('ee_ueip_optin', false);
1902
+		}
1903
+		//is this already cached for this request?  If so use it.
1904
+		if ( ! empty(EE_Core_Config::$ee_ueip_option)) {
1905
+			return EE_Core_Config::$ee_ueip_option;
1906
+		}
1907
+		global $wpdb;
1908
+		$current_network_main_site = is_multisite() ? get_current_site() : null;
1909
+		$current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1;
1910
+		$option = 'ee_ueip_optin';
1911
+		//set correct table for query
1912
+		$table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options';
1913
+		//rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because
1914
+		//get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be
1915
+		//re-constructed on the blog switch.  Note, we are still executing any core wp filters on this option retrieval.
1916
+		//this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog
1917
+		//for the purpose of caching.
1918
+		$pre = apply_filters('pre_option_' . $option, false, $option);
1919
+		if (false !== $pre) {
1920
+			EE_Core_Config::$ee_ueip_option = $pre;
1921
+			return EE_Core_Config::$ee_ueip_option;
1922
+		}
1923
+		$row = $wpdb->get_row($wpdb->prepare("SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1",
1924
+			$option));
1925
+		if (is_object($row)) {
1926
+			$value = $row->option_value;
1927
+		} else { //option does not exist so use default.
1928
+			return apply_filters('default_option_' . $option, false, $option);
1929
+		}
1930
+		EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option);
1931
+		return EE_Core_Config::$ee_ueip_option;
1932
+	}
1933
+
1934
+	/**
1935
+	 * Utility function for escaping the value of a property and returning.
1936
+	 *
1937
+	 * @param string $property property name (checks to see if exists).
1938
+	 * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1939
+	 * @throws \EE_Error
1940
+	 */
1941
+	public function get_pretty($property)
1942
+	{
1943
+		if ($property === 'ee_ueip_optin') {
1944
+			return $this->ee_ueip_optin ? 'yes' : 'no';
1945
+		}
1946
+		return parent::get_pretty($property);
1947
+	}
1948
+
1949
+
1950
+	/**
1951
+	 * Currently used to ensure critical page urls have initial values saved to the db instead of any current set values
1952
+	 * on the object.
1953
+	 *
1954
+	 * @return array
1955
+	 */
1956
+	public function __sleep()
1957
+	{
1958
+		//reset all url properties
1959
+		$this->_reset_urls();
1960
+		//return what to save to db
1961
+		return array_keys(get_object_vars($this));
1962
+	}
2401 1963
 
1964
+}
2402 1965
 
2403 1966
 
2404
-    /**
2405
-     *    class constructor
2406
-     *
2407
-     * @access    public
2408
-     */
2409
-    public function __construct()
2410
-    {
2411
-        // set default registration settings
2412
-        $this->default_STS_ID = EEM_Registration::status_id_pending_payment;
2413
-        $this->email_validation_level = 'wp_default';
2414
-        $this->show_pending_payment_options = true;
2415
-        $this->skip_reg_confirmation = true;
2416
-        $this->reg_steps = array();
2417
-        $this->reg_confirmation_last = false;
2418
-        $this->use_bot_trap = true;
2419
-        $this->use_encryption = true;
2420
-        $this->use_captcha = false;
2421
-        $this->recaptcha_theme = 'light';
2422
-        $this->recaptcha_badge = 'bottomleft';
2423
-        $this->recaptcha_type = 'image';
2424
-        $this->recaptcha_language = 'en';
2425
-        $this->recaptcha_publickey = null;
2426
-        $this->recaptcha_privatekey = null;
2427
-        $this->recaptcha_protected_forms = array();
2428
-        $this->recaptcha_width = 500;
2429
-        $this->default_maximum_number_of_tickets = 10;
2430
-    }
2431
-
2432
-
2433
-
2434
-    /**
2435
-     * This is called by the config loader and hooks are initialized AFTER the config has been populated.
2436
-     *
2437
-     * @since 4.8.8.rc.019
2438
-     */
2439
-    public function do_hooks()
2440
-    {
2441
-        add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event'));
2442
-        add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_max_ticket_on_EEM_Event'));
2443
-    }
2444 1967
 
1968
+/**
1969
+ * Config class for storing info on the Organization
1970
+ */
1971
+class EE_Organization_Config extends EE_Config_Base
1972
+{
2445 1973
 
1974
+	/**
1975
+	 * @var string $name
1976
+	 * eg EE4.1
1977
+	 */
1978
+	public $name;
1979
+
1980
+	/**
1981
+	 * @var string $address_1
1982
+	 * eg 123 Onna Road
1983
+	 */
1984
+	public $address_1;
1985
+
1986
+	/**
1987
+	 * @var string $address_2
1988
+	 * eg PO Box 123
1989
+	 */
1990
+	public $address_2;
1991
+
1992
+	/**
1993
+	 * @var string $city
1994
+	 * eg Inna City
1995
+	 */
1996
+	public $city;
1997
+
1998
+	/**
1999
+	 * @var int $STA_ID
2000
+	 * eg 4
2001
+	 */
2002
+	public $STA_ID;
2003
+
2004
+	/**
2005
+	 * @var string $CNT_ISO
2006
+	 * eg US
2007
+	 */
2008
+	public $CNT_ISO;
2009
+
2010
+	/**
2011
+	 * @var string $zip
2012
+	 * eg 12345  or V1A 2B3
2013
+	 */
2014
+	public $zip;
2015
+
2016
+	/**
2017
+	 * @var string $email
2018
+	 * eg [email protected]
2019
+	 */
2020
+	public $email;
2021
+
2022
+
2023
+	/**
2024
+	 * @var string $phone
2025
+	 * eg. 111-111-1111
2026
+	 */
2027
+	public $phone;
2028
+
2029
+
2030
+	/**
2031
+	 * @var string $vat
2032
+	 * VAT/Tax Number
2033
+	 */
2034
+	public $vat;
2035
+
2036
+	/**
2037
+	 * @var string $logo_url
2038
+	 * eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg
2039
+	 */
2040
+	public $logo_url;
2041
+
2042
+
2043
+	/**
2044
+	 * The below are all various properties for holding links to organization social network profiles
2045
+	 *
2046
+	 * @var string
2047
+	 */
2048
+	/**
2049
+	 * facebook (facebook.com/profile.name)
2050
+	 *
2051
+	 * @var string
2052
+	 */
2053
+	public $facebook;
2054
+
2055
+
2056
+	/**
2057
+	 * twitter (twitter.com/twitter_handle)
2058
+	 *
2059
+	 * @var string
2060
+	 */
2061
+	public $twitter;
2062
+
2063
+
2064
+	/**
2065
+	 * linkedin (linkedin.com/in/profile_name)
2066
+	 *
2067
+	 * @var string
2068
+	 */
2069
+	public $linkedin;
2070
+
2071
+
2072
+	/**
2073
+	 * pinterest (www.pinterest.com/profile_name)
2074
+	 *
2075
+	 * @var string
2076
+	 */
2077
+	public $pinterest;
2078
+
2079
+
2080
+	/**
2081
+	 * google+ (google.com/+profileName)
2082
+	 *
2083
+	 * @var string
2084
+	 */
2085
+	public $google;
2086
+
2087
+
2088
+	/**
2089
+	 * instagram (instagram.com/handle)
2090
+	 *
2091
+	 * @var string
2092
+	 */
2093
+	public $instagram;
2094
+
2095
+
2096
+
2097
+	/**
2098
+	 *    class constructor
2099
+	 *
2100
+	 * @access    public
2101
+	 */
2102
+	public function __construct()
2103
+	{
2104
+		// set default organization settings
2105
+		//decode HTML entities from the WP blogname, because it's stored in the DB with HTML entities encoded
2106
+		$this->name = wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES);
2107
+		$this->address_1 = '123 Onna Road';
2108
+		$this->address_2 = 'PO Box 123';
2109
+		$this->city = 'Inna City';
2110
+		$this->STA_ID = 4;
2111
+		$this->CNT_ISO = 'US';
2112
+		$this->zip = '12345';
2113
+		$this->email = get_bloginfo('admin_email');
2114
+		$this->phone = '';
2115
+		$this->vat = '123456789';
2116
+		$this->logo_url = '';
2117
+		$this->facebook = '';
2118
+		$this->twitter = '';
2119
+		$this->linkedin = '';
2120
+		$this->pinterest = '';
2121
+		$this->google = '';
2122
+		$this->instagram = '';
2123
+	}
2446 2124
 
2447
-    /**
2448
-     * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_default_registration_status
2449
-     * field matches the config setting for default_STS_ID.
2450
-     */
2451
-    public function set_default_reg_status_on_EEM_Event()
2452
-    {
2453
-        EEM_Event::set_default_reg_status($this->default_STS_ID);
2454
-    }
2125
+}
2455 2126
 
2456 2127
 
2457
-    /**
2458
-     * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_additional_limit field
2459
-     * for Events matches the config setting for default_maximum_number_of_tickets
2460
-     */
2461
-    public function set_default_max_ticket_on_EEM_Event()
2462
-    {
2463
-        EEM_Event::set_default_additional_limit($this->default_maximum_number_of_tickets);
2464
-    }
2465 2128
 
2129
+/**
2130
+ * Class for defining what's in the EE_Config relating to currency
2131
+ */
2132
+class EE_Currency_Config extends EE_Config_Base
2133
+{
2466 2134
 
2135
+	/**
2136
+	 * @var string $code
2137
+	 * eg 'US'
2138
+	 */
2139
+	public $code;
2140
+
2141
+	/**
2142
+	 * @var string $name
2143
+	 * eg 'Dollar'
2144
+	 */
2145
+	public $name;
2146
+
2147
+	/**
2148
+	 * plural name
2149
+	 *
2150
+	 * @var string $plural
2151
+	 * eg 'Dollars'
2152
+	 */
2153
+	public $plural;
2154
+
2155
+	/**
2156
+	 * currency sign
2157
+	 *
2158
+	 * @var string $sign
2159
+	 * eg '$'
2160
+	 */
2161
+	public $sign;
2162
+
2163
+	/**
2164
+	 * Whether the currency sign should come before the number or not
2165
+	 *
2166
+	 * @var boolean $sign_b4
2167
+	 */
2168
+	public $sign_b4;
2169
+
2170
+	/**
2171
+	 * How many digits should come after the decimal place
2172
+	 *
2173
+	 * @var int $dec_plc
2174
+	 */
2175
+	public $dec_plc;
2176
+
2177
+	/**
2178
+	 * Symbol to use for decimal mark
2179
+	 *
2180
+	 * @var string $dec_mrk
2181
+	 * eg '.'
2182
+	 */
2183
+	public $dec_mrk;
2184
+
2185
+	/**
2186
+	 * Symbol to use for thousands
2187
+	 *
2188
+	 * @var string $thsnds
2189
+	 * eg ','
2190
+	 */
2191
+	public $thsnds;
2192
+
2193
+
2194
+
2195
+	/**
2196
+	 *    class constructor
2197
+	 *
2198
+	 * @access    public
2199
+	 * @param string $CNT_ISO
2200
+	 * @throws \EE_Error
2201
+	 */
2202
+	public function __construct($CNT_ISO = '')
2203
+	{
2204
+		/** @var \EventEspresso\core\services\database\TableAnalysis $table_analysis */
2205
+		$table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
2206
+		// get country code from organization settings or use default
2207
+		$ORG_CNT = isset(EE_Registry::instance()->CFG->organization)
2208
+				   && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config
2209
+			? EE_Registry::instance()->CFG->organization->CNT_ISO
2210
+			: '';
2211
+		// but override if requested
2212
+		$CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT;
2213
+		// so if that all went well, and we are not in M-Mode (cuz you can't query the db in M-Mode) and double-check the countries table exists
2214
+		if (
2215
+			! empty($CNT_ISO)
2216
+			&& EE_Maintenance_Mode::instance()->models_can_query()
2217
+			&& $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table())
2218
+		) {
2219
+			// retrieve the country settings from the db, just in case they have been customized
2220
+			$country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO);
2221
+			if ($country instanceof EE_Country) {
2222
+				$this->code = $country->currency_code();    // currency code: USD, CAD, EUR
2223
+				$this->name = $country->currency_name_single();    // Dollar
2224
+				$this->plural = $country->currency_name_plural();    // Dollars
2225
+				$this->sign = $country->currency_sign();            // currency sign: $
2226
+				$this->sign_b4 = $country->currency_sign_before();        // currency sign before or after: $TRUE  or  FALSE$
2227
+				$this->dec_plc = $country->currency_decimal_places();    // decimal places: 2 = 0.00  3 = 0.000
2228
+				$this->dec_mrk = $country->currency_decimal_mark();    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2229
+				$this->thsnds = $country->currency_thousands_separator();    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2230
+			}
2231
+		}
2232
+		// fallback to hardcoded defaults, in case the above failed
2233
+		if (empty($this->code)) {
2234
+			// set default currency settings
2235
+			$this->code = 'USD';    // currency code: USD, CAD, EUR
2236
+			$this->name = __('Dollar', 'event_espresso');    // Dollar
2237
+			$this->plural = __('Dollars', 'event_espresso');    // Dollars
2238
+			$this->sign = '$';    // currency sign: $
2239
+			$this->sign_b4 = true;    // currency sign before or after: $TRUE  or  FALSE$
2240
+			$this->dec_plc = 2;    // decimal places: 2 = 0.00  3 = 0.000
2241
+			$this->dec_mrk = '.';    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2242
+			$this->thsnds = ',';    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2243
+		}
2244
+	}
2245
+}
2467 2246
 
2468
-    /**
2469
-     * @return boolean
2470
-     */
2471
-    public function track_invalid_checkout_access()
2472
-    {
2473
-        return $this->track_invalid_checkout_access;
2474
-    }
2475 2247
 
2476 2248
 
2249
+/**
2250
+ * Class for defining what's in the EE_Config relating to registration settings
2251
+ */
2252
+class EE_Registration_Config extends EE_Config_Base
2253
+{
2477 2254
 
2478
-    /**
2479
-     * @param boolean $track_invalid_checkout_access
2480
-     */
2481
-    public function set_track_invalid_checkout_access($track_invalid_checkout_access)
2482
-    {
2483
-        $this->track_invalid_checkout_access = filter_var(
2484
-            $track_invalid_checkout_access,
2485
-            FILTER_VALIDATE_BOOLEAN
2486
-        );
2487
-    }
2255
+	/**
2256
+	 * Default registration status
2257
+	 *
2258
+	 * @var string $default_STS_ID
2259
+	 * eg 'RPP'
2260
+	 */
2261
+	public $default_STS_ID;
2262
+
2263
+
2264
+	/**
2265
+	 * For new events, this will be the default value for the maximum number of tickets (equivalent to maximum number of
2266
+	 * registrations)
2267
+	 * @var int
2268
+	 */
2269
+	public $default_maximum_number_of_tickets;
2270
+
2271
+
2272
+	/**
2273
+	 * level of validation to apply to email addresses
2274
+	 *
2275
+	 * @var string $email_validation_level
2276
+	 * options: 'basic', 'wp_default', 'i18n', 'i18n_dns'
2277
+	 */
2278
+	public $email_validation_level;
2279
+
2280
+	/**
2281
+	 *    whether or not to show alternate payment options during the reg process if payment status is pending
2282
+	 *
2283
+	 * @var boolean $show_pending_payment_options
2284
+	 */
2285
+	public $show_pending_payment_options;
2286
+
2287
+	/**
2288
+	 * Whether to skip the registration confirmation page
2289
+	 *
2290
+	 * @var boolean $skip_reg_confirmation
2291
+	 */
2292
+	public $skip_reg_confirmation;
2293
+
2294
+	/**
2295
+	 * an array of SPCO reg steps where:
2296
+	 *        the keys denotes the reg step order
2297
+	 *        each element consists of an array with the following elements:
2298
+	 *            "file_path" => the file path to the EE_SPCO_Reg_Step class
2299
+	 *            "class_name" => the specific EE_SPCO_Reg_Step child class name
2300
+	 *            "slug" => the URL param used to trigger the reg step
2301
+	 *
2302
+	 * @var array $reg_steps
2303
+	 */
2304
+	public $reg_steps;
2305
+
2306
+	/**
2307
+	 * Whether registration confirmation should be the last page of SPCO
2308
+	 *
2309
+	 * @var boolean $reg_confirmation_last
2310
+	 */
2311
+	public $reg_confirmation_last;
2312
+
2313
+	/**
2314
+	 * Whether or not to enable the EE Bot Trap
2315
+	 *
2316
+	 * @var boolean $use_bot_trap
2317
+	 */
2318
+	public $use_bot_trap;
2319
+
2320
+	/**
2321
+	 * Whether or not to encrypt some data sent by the EE Bot Trap
2322
+	 *
2323
+	 * @var boolean $use_encryption
2324
+	 */
2325
+	public $use_encryption;
2326
+
2327
+	/**
2328
+	 * Whether or not to use ReCaptcha
2329
+	 *
2330
+	 * @var boolean $use_captcha
2331
+	 */
2332
+	public $use_captcha;
2333
+
2334
+	/**
2335
+	 * ReCaptcha Theme
2336
+	 *
2337
+	 * @var string $recaptcha_theme
2338
+	 *    options: 'dark', 'light', 'invisible'
2339
+	 */
2340
+	public $recaptcha_theme;
2341
+
2342
+	/**
2343
+	 * ReCaptcha Badge - determines the position of the reCAPTCHA badge if using Invisible ReCaptcha.
2344
+	 *
2345
+	 * @var string $recaptcha_badge
2346
+	 *    options: 'bottomright', 'bottomleft', 'inline'
2347
+	 */
2348
+	public $recaptcha_badge;
2349
+
2350
+	/**
2351
+	 * ReCaptcha Type
2352
+	 *
2353
+	 * @var string $recaptcha_type
2354
+	 *    options: 'audio', 'image'
2355
+	 */
2356
+	public $recaptcha_type;
2357
+
2358
+	/**
2359
+	 * ReCaptcha language
2360
+	 *
2361
+	 * @var string $recaptcha_language
2362
+	 * eg 'en'
2363
+	 */
2364
+	public $recaptcha_language;
2365
+
2366
+	/**
2367
+	 * ReCaptcha public key
2368
+	 *
2369
+	 * @var string $recaptcha_publickey
2370
+	 */
2371
+	public $recaptcha_publickey;
2372
+
2373
+	/**
2374
+	 * ReCaptcha private key
2375
+	 *
2376
+	 * @var string $recaptcha_privatekey
2377
+	 */
2378
+	public $recaptcha_privatekey;
2379
+
2380
+	/**
2381
+	 * array of form names protected by ReCaptcha
2382
+	 *
2383
+	 * @var array $recaptcha_protected_forms
2384
+	 */
2385
+	public $recaptcha_protected_forms;
2386
+
2387
+	/**
2388
+	 * ReCaptcha width
2389
+	 *
2390
+	 * @var int $recaptcha_width
2391
+	 * @deprecated
2392
+	 */
2393
+	public $recaptcha_width;
2394
+
2395
+	/**
2396
+	 * Whether or not invalid attempts to directly access the registration checkout page should be tracked.
2397
+	 *
2398
+	 * @var boolean $track_invalid_checkout_access
2399
+	 */
2400
+	protected $track_invalid_checkout_access = true;
2401
+
2402
+
2403
+
2404
+	/**
2405
+	 *    class constructor
2406
+	 *
2407
+	 * @access    public
2408
+	 */
2409
+	public function __construct()
2410
+	{
2411
+		// set default registration settings
2412
+		$this->default_STS_ID = EEM_Registration::status_id_pending_payment;
2413
+		$this->email_validation_level = 'wp_default';
2414
+		$this->show_pending_payment_options = true;
2415
+		$this->skip_reg_confirmation = true;
2416
+		$this->reg_steps = array();
2417
+		$this->reg_confirmation_last = false;
2418
+		$this->use_bot_trap = true;
2419
+		$this->use_encryption = true;
2420
+		$this->use_captcha = false;
2421
+		$this->recaptcha_theme = 'light';
2422
+		$this->recaptcha_badge = 'bottomleft';
2423
+		$this->recaptcha_type = 'image';
2424
+		$this->recaptcha_language = 'en';
2425
+		$this->recaptcha_publickey = null;
2426
+		$this->recaptcha_privatekey = null;
2427
+		$this->recaptcha_protected_forms = array();
2428
+		$this->recaptcha_width = 500;
2429
+		$this->default_maximum_number_of_tickets = 10;
2430
+	}
2431
+
2432
+
2433
+
2434
+	/**
2435
+	 * This is called by the config loader and hooks are initialized AFTER the config has been populated.
2436
+	 *
2437
+	 * @since 4.8.8.rc.019
2438
+	 */
2439
+	public function do_hooks()
2440
+	{
2441
+		add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event'));
2442
+		add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_max_ticket_on_EEM_Event'));
2443
+	}
2444
+
2445
+
2446
+
2447
+	/**
2448
+	 * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_default_registration_status
2449
+	 * field matches the config setting for default_STS_ID.
2450
+	 */
2451
+	public function set_default_reg_status_on_EEM_Event()
2452
+	{
2453
+		EEM_Event::set_default_reg_status($this->default_STS_ID);
2454
+	}
2455
+
2456
+
2457
+	/**
2458
+	 * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_additional_limit field
2459
+	 * for Events matches the config setting for default_maximum_number_of_tickets
2460
+	 */
2461
+	public function set_default_max_ticket_on_EEM_Event()
2462
+	{
2463
+		EEM_Event::set_default_additional_limit($this->default_maximum_number_of_tickets);
2464
+	}
2465
+
2466
+
2467
+
2468
+	/**
2469
+	 * @return boolean
2470
+	 */
2471
+	public function track_invalid_checkout_access()
2472
+	{
2473
+		return $this->track_invalid_checkout_access;
2474
+	}
2475
+
2476
+
2477
+
2478
+	/**
2479
+	 * @param boolean $track_invalid_checkout_access
2480
+	 */
2481
+	public function set_track_invalid_checkout_access($track_invalid_checkout_access)
2482
+	{
2483
+		$this->track_invalid_checkout_access = filter_var(
2484
+			$track_invalid_checkout_access,
2485
+			FILTER_VALIDATE_BOOLEAN
2486
+		);
2487
+	}
2488 2488
 
2489 2489
 
2490 2490
 
@@ -2498,160 +2498,160 @@  discard block
 block discarded – undo
2498 2498
 class EE_Admin_Config extends EE_Config_Base
2499 2499
 {
2500 2500
 
2501
-    /**
2502
-     * @var boolean $use_personnel_manager
2503
-     */
2504
-    public $use_personnel_manager;
2505
-
2506
-    /**
2507
-     * @var boolean $use_dashboard_widget
2508
-     */
2509
-    public $use_dashboard_widget;
2510
-
2511
-    /**
2512
-     * @var int $events_in_dashboard
2513
-     */
2514
-    public $events_in_dashboard;
2515
-
2516
-    /**
2517
-     * @var boolean $use_event_timezones
2518
-     */
2519
-    public $use_event_timezones;
2520
-
2521
-    /**
2522
-     * @var boolean $use_full_logging
2523
-     */
2524
-    public $use_full_logging;
2525
-
2526
-    /**
2527
-     * @var string $log_file_name
2528
-     */
2529
-    public $log_file_name;
2530
-
2531
-    /**
2532
-     * @var string $debug_file_name
2533
-     */
2534
-    public $debug_file_name;
2535
-
2536
-    /**
2537
-     * @var boolean $use_remote_logging
2538
-     */
2539
-    public $use_remote_logging;
2540
-
2541
-    /**
2542
-     * @var string $remote_logging_url
2543
-     */
2544
-    public $remote_logging_url;
2545
-
2546
-    /**
2547
-     * @var boolean $show_reg_footer
2548
-     */
2549
-    public $show_reg_footer;
2550
-
2551
-    /**
2552
-     * @var string $affiliate_id
2553
-     */
2554
-    public $affiliate_id;
2555
-
2556
-    /**
2557
-     * help tours on or off (global setting)
2558
-     *
2559
-     * @var boolean
2560
-     */
2561
-    public $help_tour_activation;
2562
-
2563
-    /**
2564
-     * adds extra layer of encoding to session data to prevent serialization errors
2565
-     * but is incompatible with some server configuration errors
2566
-     * if you get "500 internal server errors" during registration, try turning this on
2567
-     * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off
2568
-     *
2569
-     * @var boolean $encode_session_data
2570
-     */
2571
-    private $encode_session_data = false;
2572
-
2573
-
2574
-
2575
-    /**
2576
-     *    class constructor
2577
-     *
2578
-     * @access    public
2579
-     */
2580
-    public function __construct()
2581
-    {
2582
-        // set default general admin settings
2583
-        $this->use_personnel_manager = true;
2584
-        $this->use_dashboard_widget = true;
2585
-        $this->events_in_dashboard = 30;
2586
-        $this->use_event_timezones = false;
2587
-        $this->use_full_logging = false;
2588
-        $this->use_remote_logging = false;
2589
-        $this->remote_logging_url = null;
2590
-        $this->show_reg_footer = true;
2591
-        $this->affiliate_id = 'default';
2592
-        $this->help_tour_activation = true;
2593
-        $this->encode_session_data = false;
2594
-    }
2595
-
2596
-
2597
-
2598
-    /**
2599
-     * @param bool $reset
2600
-     * @return string
2601
-     */
2602
-    public function log_file_name($reset = false)
2603
-    {
2604
-        if (empty($this->log_file_name) || $reset) {
2605
-            $this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt';
2606
-            EE_Config::instance()->update_espresso_config(false, false);
2607
-        }
2608
-        return $this->log_file_name;
2609
-    }
2610
-
2611
-
2612
-
2613
-    /**
2614
-     * @param bool $reset
2615
-     * @return string
2616
-     */
2617
-    public function debug_file_name($reset = false)
2618
-    {
2619
-        if (empty($this->debug_file_name) || $reset) {
2620
-            $this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt';
2621
-            EE_Config::instance()->update_espresso_config(false, false);
2622
-        }
2623
-        return $this->debug_file_name;
2624
-    }
2625
-
2626
-
2627
-
2628
-    /**
2629
-     * @return string
2630
-     */
2631
-    public function affiliate_id()
2632
-    {
2633
-        return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default';
2634
-    }
2635
-
2636
-
2637
-
2638
-    /**
2639
-     * @return boolean
2640
-     */
2641
-    public function encode_session_data()
2642
-    {
2643
-        return filter_var($this->encode_session_data, FILTER_VALIDATE_BOOLEAN);
2644
-    }
2645
-
2646
-
2647
-
2648
-    /**
2649
-     * @param boolean $encode_session_data
2650
-     */
2651
-    public function set_encode_session_data($encode_session_data)
2652
-    {
2653
-        $this->encode_session_data = filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN);
2654
-    }
2501
+	/**
2502
+	 * @var boolean $use_personnel_manager
2503
+	 */
2504
+	public $use_personnel_manager;
2505
+
2506
+	/**
2507
+	 * @var boolean $use_dashboard_widget
2508
+	 */
2509
+	public $use_dashboard_widget;
2510
+
2511
+	/**
2512
+	 * @var int $events_in_dashboard
2513
+	 */
2514
+	public $events_in_dashboard;
2515
+
2516
+	/**
2517
+	 * @var boolean $use_event_timezones
2518
+	 */
2519
+	public $use_event_timezones;
2520
+
2521
+	/**
2522
+	 * @var boolean $use_full_logging
2523
+	 */
2524
+	public $use_full_logging;
2525
+
2526
+	/**
2527
+	 * @var string $log_file_name
2528
+	 */
2529
+	public $log_file_name;
2530
+
2531
+	/**
2532
+	 * @var string $debug_file_name
2533
+	 */
2534
+	public $debug_file_name;
2535
+
2536
+	/**
2537
+	 * @var boolean $use_remote_logging
2538
+	 */
2539
+	public $use_remote_logging;
2540
+
2541
+	/**
2542
+	 * @var string $remote_logging_url
2543
+	 */
2544
+	public $remote_logging_url;
2545
+
2546
+	/**
2547
+	 * @var boolean $show_reg_footer
2548
+	 */
2549
+	public $show_reg_footer;
2550
+
2551
+	/**
2552
+	 * @var string $affiliate_id
2553
+	 */
2554
+	public $affiliate_id;
2555
+
2556
+	/**
2557
+	 * help tours on or off (global setting)
2558
+	 *
2559
+	 * @var boolean
2560
+	 */
2561
+	public $help_tour_activation;
2562
+
2563
+	/**
2564
+	 * adds extra layer of encoding to session data to prevent serialization errors
2565
+	 * but is incompatible with some server configuration errors
2566
+	 * if you get "500 internal server errors" during registration, try turning this on
2567
+	 * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off
2568
+	 *
2569
+	 * @var boolean $encode_session_data
2570
+	 */
2571
+	private $encode_session_data = false;
2572
+
2573
+
2574
+
2575
+	/**
2576
+	 *    class constructor
2577
+	 *
2578
+	 * @access    public
2579
+	 */
2580
+	public function __construct()
2581
+	{
2582
+		// set default general admin settings
2583
+		$this->use_personnel_manager = true;
2584
+		$this->use_dashboard_widget = true;
2585
+		$this->events_in_dashboard = 30;
2586
+		$this->use_event_timezones = false;
2587
+		$this->use_full_logging = false;
2588
+		$this->use_remote_logging = false;
2589
+		$this->remote_logging_url = null;
2590
+		$this->show_reg_footer = true;
2591
+		$this->affiliate_id = 'default';
2592
+		$this->help_tour_activation = true;
2593
+		$this->encode_session_data = false;
2594
+	}
2595
+
2596
+
2597
+
2598
+	/**
2599
+	 * @param bool $reset
2600
+	 * @return string
2601
+	 */
2602
+	public function log_file_name($reset = false)
2603
+	{
2604
+		if (empty($this->log_file_name) || $reset) {
2605
+			$this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt';
2606
+			EE_Config::instance()->update_espresso_config(false, false);
2607
+		}
2608
+		return $this->log_file_name;
2609
+	}
2610
+
2611
+
2612
+
2613
+	/**
2614
+	 * @param bool $reset
2615
+	 * @return string
2616
+	 */
2617
+	public function debug_file_name($reset = false)
2618
+	{
2619
+		if (empty($this->debug_file_name) || $reset) {
2620
+			$this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt';
2621
+			EE_Config::instance()->update_espresso_config(false, false);
2622
+		}
2623
+		return $this->debug_file_name;
2624
+	}
2625
+
2626
+
2627
+
2628
+	/**
2629
+	 * @return string
2630
+	 */
2631
+	public function affiliate_id()
2632
+	{
2633
+		return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default';
2634
+	}
2635
+
2636
+
2637
+
2638
+	/**
2639
+	 * @return boolean
2640
+	 */
2641
+	public function encode_session_data()
2642
+	{
2643
+		return filter_var($this->encode_session_data, FILTER_VALIDATE_BOOLEAN);
2644
+	}
2645
+
2646
+
2647
+
2648
+	/**
2649
+	 * @param boolean $encode_session_data
2650
+	 */
2651
+	public function set_encode_session_data($encode_session_data)
2652
+	{
2653
+		$this->encode_session_data = filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN);
2654
+	}
2655 2655
 
2656 2656
 
2657 2657
 
@@ -2665,71 +2665,71 @@  discard block
 block discarded – undo
2665 2665
 class EE_Template_Config extends EE_Config_Base
2666 2666
 {
2667 2667
 
2668
-    /**
2669
-     * @var boolean $enable_default_style
2670
-     */
2671
-    public $enable_default_style;
2672
-
2673
-    /**
2674
-     * @var string $custom_style_sheet
2675
-     */
2676
-    public $custom_style_sheet;
2677
-
2678
-    /**
2679
-     * @var boolean $display_address_in_regform
2680
-     */
2681
-    public $display_address_in_regform;
2682
-
2683
-    /**
2684
-     * @var int $display_description_on_multi_reg_page
2685
-     */
2686
-    public $display_description_on_multi_reg_page;
2687
-
2688
-    /**
2689
-     * @var boolean $use_custom_templates
2690
-     */
2691
-    public $use_custom_templates;
2692
-
2693
-    /**
2694
-     * @var string $current_espresso_theme
2695
-     */
2696
-    public $current_espresso_theme;
2697
-
2698
-    /**
2699
-     * @var EE_Ticket_Selector_Config $EED_Ticket_Selector
2700
-     */
2701
-    public $EED_Ticket_Selector;
2702
-
2703
-    /**
2704
-     * @var EE_Event_Single_Config $EED_Event_Single
2705
-     */
2706
-    public $EED_Event_Single;
2707
-
2708
-    /**
2709
-     * @var EE_Events_Archive_Config $EED_Events_Archive
2710
-     */
2711
-    public $EED_Events_Archive;
2712
-
2713
-
2714
-
2715
-    /**
2716
-     *    class constructor
2717
-     *
2718
-     * @access    public
2719
-     */
2720
-    public function __construct()
2721
-    {
2722
-        // set default template settings
2723
-        $this->enable_default_style = true;
2724
-        $this->custom_style_sheet = null;
2725
-        $this->display_address_in_regform = true;
2726
-        $this->display_description_on_multi_reg_page = false;
2727
-        $this->use_custom_templates = false;
2728
-        $this->current_espresso_theme = 'Espresso_Arabica_2014';
2729
-        $this->EED_Event_Single = null;
2730
-        $this->EED_Events_Archive = null;
2731
-        $this->EED_Ticket_Selector = null;
2732
-    }
2668
+	/**
2669
+	 * @var boolean $enable_default_style
2670
+	 */
2671
+	public $enable_default_style;
2672
+
2673
+	/**
2674
+	 * @var string $custom_style_sheet
2675
+	 */
2676
+	public $custom_style_sheet;
2677
+
2678
+	/**
2679
+	 * @var boolean $display_address_in_regform
2680
+	 */
2681
+	public $display_address_in_regform;
2682
+
2683
+	/**
2684
+	 * @var int $display_description_on_multi_reg_page
2685
+	 */
2686
+	public $display_description_on_multi_reg_page;
2687
+
2688
+	/**
2689
+	 * @var boolean $use_custom_templates
2690
+	 */
2691
+	public $use_custom_templates;
2692
+
2693
+	/**
2694
+	 * @var string $current_espresso_theme
2695
+	 */
2696
+	public $current_espresso_theme;
2697
+
2698
+	/**
2699
+	 * @var EE_Ticket_Selector_Config $EED_Ticket_Selector
2700
+	 */
2701
+	public $EED_Ticket_Selector;
2702
+
2703
+	/**
2704
+	 * @var EE_Event_Single_Config $EED_Event_Single
2705
+	 */
2706
+	public $EED_Event_Single;
2707
+
2708
+	/**
2709
+	 * @var EE_Events_Archive_Config $EED_Events_Archive
2710
+	 */
2711
+	public $EED_Events_Archive;
2712
+
2713
+
2714
+
2715
+	/**
2716
+	 *    class constructor
2717
+	 *
2718
+	 * @access    public
2719
+	 */
2720
+	public function __construct()
2721
+	{
2722
+		// set default template settings
2723
+		$this->enable_default_style = true;
2724
+		$this->custom_style_sheet = null;
2725
+		$this->display_address_in_regform = true;
2726
+		$this->display_description_on_multi_reg_page = false;
2727
+		$this->use_custom_templates = false;
2728
+		$this->current_espresso_theme = 'Espresso_Arabica_2014';
2729
+		$this->EED_Event_Single = null;
2730
+		$this->EED_Events_Archive = null;
2731
+		$this->EED_Ticket_Selector = null;
2732
+	}
2733 2733
 
2734 2734
 }
2735 2735
 
@@ -2741,115 +2741,115 @@  discard block
 block discarded – undo
2741 2741
 class EE_Map_Config extends EE_Config_Base
2742 2742
 {
2743 2743
 
2744
-    /**
2745
-     * @var boolean $use_google_maps
2746
-     */
2747
-    public $use_google_maps;
2748
-
2749
-    /**
2750
-     * @var string $api_key
2751
-     */
2752
-    public $google_map_api_key;
2753
-
2754
-    /**
2755
-     * @var int $event_details_map_width
2756
-     */
2757
-    public $event_details_map_width;
2758
-
2759
-    /**
2760
-     * @var int $event_details_map_height
2761
-     */
2762
-    public $event_details_map_height;
2763
-
2764
-    /**
2765
-     * @var int $event_details_map_zoom
2766
-     */
2767
-    public $event_details_map_zoom;
2768
-
2769
-    /**
2770
-     * @var boolean $event_details_display_nav
2771
-     */
2772
-    public $event_details_display_nav;
2773
-
2774
-    /**
2775
-     * @var boolean $event_details_nav_size
2776
-     */
2777
-    public $event_details_nav_size;
2778
-
2779
-    /**
2780
-     * @var string $event_details_control_type
2781
-     */
2782
-    public $event_details_control_type;
2783
-
2784
-    /**
2785
-     * @var string $event_details_map_align
2786
-     */
2787
-    public $event_details_map_align;
2788
-
2789
-    /**
2790
-     * @var int $event_list_map_width
2791
-     */
2792
-    public $event_list_map_width;
2793
-
2794
-    /**
2795
-     * @var int $event_list_map_height
2796
-     */
2797
-    public $event_list_map_height;
2798
-
2799
-    /**
2800
-     * @var int $event_list_map_zoom
2801
-     */
2802
-    public $event_list_map_zoom;
2803
-
2804
-    /**
2805
-     * @var boolean $event_list_display_nav
2806
-     */
2807
-    public $event_list_display_nav;
2808
-
2809
-    /**
2810
-     * @var boolean $event_list_nav_size
2811
-     */
2812
-    public $event_list_nav_size;
2813
-
2814
-    /**
2815
-     * @var string $event_list_control_type
2816
-     */
2817
-    public $event_list_control_type;
2818
-
2819
-    /**
2820
-     * @var string $event_list_map_align
2821
-     */
2822
-    public $event_list_map_align;
2823
-
2824
-
2825
-
2826
-    /**
2827
-     *    class constructor
2828
-     *
2829
-     * @access    public
2830
-     */
2831
-    public function __construct()
2832
-    {
2833
-        // set default map settings
2834
-        $this->use_google_maps = true;
2835
-        $this->google_map_api_key = '';
2836
-        // for event details pages (reg page)
2837
-        $this->event_details_map_width = 585;            // ee_map_width_single
2838
-        $this->event_details_map_height = 362;            // ee_map_height_single
2839
-        $this->event_details_map_zoom = 14;            // ee_map_zoom_single
2840
-        $this->event_details_display_nav = true;            // ee_map_nav_display_single
2841
-        $this->event_details_nav_size = false;            // ee_map_nav_size_single
2842
-        $this->event_details_control_type = 'default';        // ee_map_type_control_single
2843
-        $this->event_details_map_align = 'center';            // ee_map_align_single
2844
-        // for event list pages
2845
-        $this->event_list_map_width = 300;            // ee_map_width
2846
-        $this->event_list_map_height = 185;        // ee_map_height
2847
-        $this->event_list_map_zoom = 12;            // ee_map_zoom
2848
-        $this->event_list_display_nav = false;        // ee_map_nav_display
2849
-        $this->event_list_nav_size = true;            // ee_map_nav_size
2850
-        $this->event_list_control_type = 'dropdown';        // ee_map_type_control
2851
-        $this->event_list_map_align = 'center';            // ee_map_align
2852
-    }
2744
+	/**
2745
+	 * @var boolean $use_google_maps
2746
+	 */
2747
+	public $use_google_maps;
2748
+
2749
+	/**
2750
+	 * @var string $api_key
2751
+	 */
2752
+	public $google_map_api_key;
2753
+
2754
+	/**
2755
+	 * @var int $event_details_map_width
2756
+	 */
2757
+	public $event_details_map_width;
2758
+
2759
+	/**
2760
+	 * @var int $event_details_map_height
2761
+	 */
2762
+	public $event_details_map_height;
2763
+
2764
+	/**
2765
+	 * @var int $event_details_map_zoom
2766
+	 */
2767
+	public $event_details_map_zoom;
2768
+
2769
+	/**
2770
+	 * @var boolean $event_details_display_nav
2771
+	 */
2772
+	public $event_details_display_nav;
2773
+
2774
+	/**
2775
+	 * @var boolean $event_details_nav_size
2776
+	 */
2777
+	public $event_details_nav_size;
2778
+
2779
+	/**
2780
+	 * @var string $event_details_control_type
2781
+	 */
2782
+	public $event_details_control_type;
2783
+
2784
+	/**
2785
+	 * @var string $event_details_map_align
2786
+	 */
2787
+	public $event_details_map_align;
2788
+
2789
+	/**
2790
+	 * @var int $event_list_map_width
2791
+	 */
2792
+	public $event_list_map_width;
2793
+
2794
+	/**
2795
+	 * @var int $event_list_map_height
2796
+	 */
2797
+	public $event_list_map_height;
2798
+
2799
+	/**
2800
+	 * @var int $event_list_map_zoom
2801
+	 */
2802
+	public $event_list_map_zoom;
2803
+
2804
+	/**
2805
+	 * @var boolean $event_list_display_nav
2806
+	 */
2807
+	public $event_list_display_nav;
2808
+
2809
+	/**
2810
+	 * @var boolean $event_list_nav_size
2811
+	 */
2812
+	public $event_list_nav_size;
2813
+
2814
+	/**
2815
+	 * @var string $event_list_control_type
2816
+	 */
2817
+	public $event_list_control_type;
2818
+
2819
+	/**
2820
+	 * @var string $event_list_map_align
2821
+	 */
2822
+	public $event_list_map_align;
2823
+
2824
+
2825
+
2826
+	/**
2827
+	 *    class constructor
2828
+	 *
2829
+	 * @access    public
2830
+	 */
2831
+	public function __construct()
2832
+	{
2833
+		// set default map settings
2834
+		$this->use_google_maps = true;
2835
+		$this->google_map_api_key = '';
2836
+		// for event details pages (reg page)
2837
+		$this->event_details_map_width = 585;            // ee_map_width_single
2838
+		$this->event_details_map_height = 362;            // ee_map_height_single
2839
+		$this->event_details_map_zoom = 14;            // ee_map_zoom_single
2840
+		$this->event_details_display_nav = true;            // ee_map_nav_display_single
2841
+		$this->event_details_nav_size = false;            // ee_map_nav_size_single
2842
+		$this->event_details_control_type = 'default';        // ee_map_type_control_single
2843
+		$this->event_details_map_align = 'center';            // ee_map_align_single
2844
+		// for event list pages
2845
+		$this->event_list_map_width = 300;            // ee_map_width
2846
+		$this->event_list_map_height = 185;        // ee_map_height
2847
+		$this->event_list_map_zoom = 12;            // ee_map_zoom
2848
+		$this->event_list_display_nav = false;        // ee_map_nav_display
2849
+		$this->event_list_nav_size = true;            // ee_map_nav_size
2850
+		$this->event_list_control_type = 'dropdown';        // ee_map_type_control
2851
+		$this->event_list_map_align = 'center';            // ee_map_align
2852
+	}
2853 2853
 
2854 2854
 }
2855 2855
 
@@ -2861,47 +2861,47 @@  discard block
 block discarded – undo
2861 2861
 class EE_Events_Archive_Config extends EE_Config_Base
2862 2862
 {
2863 2863
 
2864
-    public $display_status_banner;
2864
+	public $display_status_banner;
2865 2865
 
2866
-    public $display_description;
2866
+	public $display_description;
2867 2867
 
2868
-    public $display_ticket_selector;
2868
+	public $display_ticket_selector;
2869 2869
 
2870
-    public $display_datetimes;
2870
+	public $display_datetimes;
2871 2871
 
2872
-    public $display_venue;
2872
+	public $display_venue;
2873 2873
 
2874
-    public $display_expired_events;
2874
+	public $display_expired_events;
2875 2875
 
2876
-    public $use_sortable_display_order;
2876
+	public $use_sortable_display_order;
2877 2877
 
2878
-    public $display_order_tickets;
2878
+	public $display_order_tickets;
2879 2879
 
2880
-    public $display_order_datetimes;
2880
+	public $display_order_datetimes;
2881 2881
 
2882
-    public $display_order_event;
2882
+	public $display_order_event;
2883 2883
 
2884
-    public $display_order_venue;
2884
+	public $display_order_venue;
2885 2885
 
2886 2886
 
2887 2887
 
2888
-    /**
2889
-     *    class constructor
2890
-     */
2891
-    public function __construct()
2892
-    {
2893
-        $this->display_status_banner = 0;
2894
-        $this->display_description = 1;
2895
-        $this->display_ticket_selector = 0;
2896
-        $this->display_datetimes = 1;
2897
-        $this->display_venue = 0;
2898
-        $this->display_expired_events = 0;
2899
-        $this->use_sortable_display_order = false;
2900
-        $this->display_order_tickets = 100;
2901
-        $this->display_order_datetimes = 110;
2902
-        $this->display_order_event = 120;
2903
-        $this->display_order_venue = 130;
2904
-    }
2888
+	/**
2889
+	 *    class constructor
2890
+	 */
2891
+	public function __construct()
2892
+	{
2893
+		$this->display_status_banner = 0;
2894
+		$this->display_description = 1;
2895
+		$this->display_ticket_selector = 0;
2896
+		$this->display_datetimes = 1;
2897
+		$this->display_venue = 0;
2898
+		$this->display_expired_events = 0;
2899
+		$this->use_sortable_display_order = false;
2900
+		$this->display_order_tickets = 100;
2901
+		$this->display_order_datetimes = 110;
2902
+		$this->display_order_event = 120;
2903
+		$this->display_order_venue = 130;
2904
+	}
2905 2905
 }
2906 2906
 
2907 2907
 
@@ -2912,35 +2912,35 @@  discard block
 block discarded – undo
2912 2912
 class EE_Event_Single_Config extends EE_Config_Base
2913 2913
 {
2914 2914
 
2915
-    public $display_status_banner_single;
2915
+	public $display_status_banner_single;
2916 2916
 
2917
-    public $display_venue;
2917
+	public $display_venue;
2918 2918
 
2919
-    public $use_sortable_display_order;
2919
+	public $use_sortable_display_order;
2920 2920
 
2921
-    public $display_order_tickets;
2921
+	public $display_order_tickets;
2922 2922
 
2923
-    public $display_order_datetimes;
2923
+	public $display_order_datetimes;
2924 2924
 
2925
-    public $display_order_event;
2925
+	public $display_order_event;
2926 2926
 
2927
-    public $display_order_venue;
2927
+	public $display_order_venue;
2928 2928
 
2929 2929
 
2930 2930
 
2931
-    /**
2932
-     *    class constructor
2933
-     */
2934
-    public function __construct()
2935
-    {
2936
-        $this->display_status_banner_single = 0;
2937
-        $this->display_venue = 1;
2938
-        $this->use_sortable_display_order = false;
2939
-        $this->display_order_tickets = 100;
2940
-        $this->display_order_datetimes = 110;
2941
-        $this->display_order_event = 120;
2942
-        $this->display_order_venue = 130;
2943
-    }
2931
+	/**
2932
+	 *    class constructor
2933
+	 */
2934
+	public function __construct()
2935
+	{
2936
+		$this->display_status_banner_single = 0;
2937
+		$this->display_venue = 1;
2938
+		$this->use_sortable_display_order = false;
2939
+		$this->display_order_tickets = 100;
2940
+		$this->display_order_datetimes = 110;
2941
+		$this->display_order_event = 120;
2942
+		$this->display_order_venue = 130;
2943
+	}
2944 2944
 }
2945 2945
 
2946 2946
 
@@ -2951,152 +2951,152 @@  discard block
 block discarded – undo
2951 2951
 class EE_Ticket_Selector_Config extends EE_Config_Base
2952 2952
 {
2953 2953
 
2954
-    /**
2955
-     * constant to indicate that a datetime selector should NEVER be shown for ticket selectors
2956
-     */
2957
-    const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector';
2958
-
2959
-    /**
2960
-     * constant to indicate that a datetime selector should only be shown for ticket selectors
2961
-     * when the number of datetimes for the event matches the value set for $datetime_selector_threshold
2962
-     */
2963
-    const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector';
2964
-
2965
-    /**
2966
-     * @var boolean $show_ticket_sale_columns
2967
-     */
2968
-    public $show_ticket_sale_columns;
2969
-
2970
-    /**
2971
-     * @var boolean $show_ticket_details
2972
-     */
2973
-    public $show_ticket_details;
2974
-
2975
-    /**
2976
-     * @var boolean $show_expired_tickets
2977
-     */
2978
-    public $show_expired_tickets;
2979
-
2980
-    /**
2981
-     * whether or not to display a dropdown box populated with event datetimes
2982
-     * that toggles which tickets are displayed for a ticket selector.
2983
-     * uses one of the *_DATETIME_SELECTOR constants defined above
2984
-     *
2985
-     * @var string $show_datetime_selector
2986
-     */
2987
-    private $show_datetime_selector = 'no_datetime_selector';
2988
-
2989
-    /**
2990
-     * the number of datetimes an event has to have before conditionally displaying a datetime selector
2991
-     *
2992
-     * @var int $datetime_selector_threshold
2993
-     */
2994
-    private $datetime_selector_threshold = 3;
2995
-
2996
-
2997
-
2998
-    /**
2999
-     *    class constructor
3000
-     */
3001
-    public function __construct()
3002
-    {
3003
-        $this->show_ticket_sale_columns = true;
3004
-        $this->show_ticket_details = true;
3005
-        $this->show_expired_tickets = true;
3006
-        $this->show_datetime_selector = \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3007
-        $this->datetime_selector_threshold = 3;
3008
-    }
3009
-
3010
-
3011
-
3012
-    /**
3013
-     * returns true if a datetime selector should be displayed
3014
-     *
3015
-     * @param array $datetimes
3016
-     * @return bool
3017
-     */
3018
-    public function showDatetimeSelector(array $datetimes)
3019
-    {
3020
-        // if the settings are NOT: don't show OR below threshold, THEN active = true
3021
-        return ! (
3022
-            $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR
3023
-            || (
3024
-                $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR
3025
-                && count($datetimes) < $this->getDatetimeSelectorThreshold()
3026
-            )
3027
-        );
3028
-    }
3029
-
3030
-
3031
-
3032
-    /**
3033
-     * @return string
3034
-     */
3035
-    public function getShowDatetimeSelector()
3036
-    {
3037
-        return $this->show_datetime_selector;
3038
-    }
3039
-
3040
-
3041
-
3042
-    /**
3043
-     * @param bool $keys_only
3044
-     * @return array
3045
-     */
3046
-    public function getShowDatetimeSelectorOptions($keys_only = true)
3047
-    {
3048
-        return $keys_only
3049
-            ? array(
3050
-                \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR,
3051
-                \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR,
3052
-            )
3053
-            : array(
3054
-                \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__(
3055
-                    'Do not show date & time filter', 'event_espresso'
3056
-                ),
3057
-                \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR  => esc_html__(
3058
-                    'Maybe show date & time filter', 'event_espresso'
3059
-                ),
3060
-            );
3061
-    }
3062
-
3063
-
3064
-
3065
-    /**
3066
-     * @param string $show_datetime_selector
3067
-     */
3068
-    public function setShowDatetimeSelector($show_datetime_selector)
3069
-    {
3070
-        $this->show_datetime_selector = in_array(
3071
-            $show_datetime_selector,
3072
-            $this->getShowDatetimeSelectorOptions(),
3073
-            true
3074
-        )
3075
-            ? $show_datetime_selector
3076
-            : \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3077
-    }
3078
-
3079
-
3080
-
3081
-    /**
3082
-     * @return int
3083
-     */
3084
-    public function getDatetimeSelectorThreshold()
3085
-    {
3086
-        return $this->datetime_selector_threshold;
3087
-    }
3088
-
3089
-
3090
-
3091
-
3092
-    /**
3093
-     * @param int $datetime_selector_threshold
3094
-     */
3095
-    public function setDatetimeSelectorThreshold($datetime_selector_threshold)
3096
-    {
3097
-        $datetime_selector_threshold = absint($datetime_selector_threshold);
3098
-        $this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3;
3099
-    }
2954
+	/**
2955
+	 * constant to indicate that a datetime selector should NEVER be shown for ticket selectors
2956
+	 */
2957
+	const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector';
2958
+
2959
+	/**
2960
+	 * constant to indicate that a datetime selector should only be shown for ticket selectors
2961
+	 * when the number of datetimes for the event matches the value set for $datetime_selector_threshold
2962
+	 */
2963
+	const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector';
2964
+
2965
+	/**
2966
+	 * @var boolean $show_ticket_sale_columns
2967
+	 */
2968
+	public $show_ticket_sale_columns;
2969
+
2970
+	/**
2971
+	 * @var boolean $show_ticket_details
2972
+	 */
2973
+	public $show_ticket_details;
2974
+
2975
+	/**
2976
+	 * @var boolean $show_expired_tickets
2977
+	 */
2978
+	public $show_expired_tickets;
2979
+
2980
+	/**
2981
+	 * whether or not to display a dropdown box populated with event datetimes
2982
+	 * that toggles which tickets are displayed for a ticket selector.
2983
+	 * uses one of the *_DATETIME_SELECTOR constants defined above
2984
+	 *
2985
+	 * @var string $show_datetime_selector
2986
+	 */
2987
+	private $show_datetime_selector = 'no_datetime_selector';
2988
+
2989
+	/**
2990
+	 * the number of datetimes an event has to have before conditionally displaying a datetime selector
2991
+	 *
2992
+	 * @var int $datetime_selector_threshold
2993
+	 */
2994
+	private $datetime_selector_threshold = 3;
2995
+
2996
+
2997
+
2998
+	/**
2999
+	 *    class constructor
3000
+	 */
3001
+	public function __construct()
3002
+	{
3003
+		$this->show_ticket_sale_columns = true;
3004
+		$this->show_ticket_details = true;
3005
+		$this->show_expired_tickets = true;
3006
+		$this->show_datetime_selector = \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3007
+		$this->datetime_selector_threshold = 3;
3008
+	}
3009
+
3010
+
3011
+
3012
+	/**
3013
+	 * returns true if a datetime selector should be displayed
3014
+	 *
3015
+	 * @param array $datetimes
3016
+	 * @return bool
3017
+	 */
3018
+	public function showDatetimeSelector(array $datetimes)
3019
+	{
3020
+		// if the settings are NOT: don't show OR below threshold, THEN active = true
3021
+		return ! (
3022
+			$this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR
3023
+			|| (
3024
+				$this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR
3025
+				&& count($datetimes) < $this->getDatetimeSelectorThreshold()
3026
+			)
3027
+		);
3028
+	}
3029
+
3030
+
3031
+
3032
+	/**
3033
+	 * @return string
3034
+	 */
3035
+	public function getShowDatetimeSelector()
3036
+	{
3037
+		return $this->show_datetime_selector;
3038
+	}
3039
+
3040
+
3041
+
3042
+	/**
3043
+	 * @param bool $keys_only
3044
+	 * @return array
3045
+	 */
3046
+	public function getShowDatetimeSelectorOptions($keys_only = true)
3047
+	{
3048
+		return $keys_only
3049
+			? array(
3050
+				\EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR,
3051
+				\EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR,
3052
+			)
3053
+			: array(
3054
+				\EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__(
3055
+					'Do not show date & time filter', 'event_espresso'
3056
+				),
3057
+				\EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR  => esc_html__(
3058
+					'Maybe show date & time filter', 'event_espresso'
3059
+				),
3060
+			);
3061
+	}
3062
+
3063
+
3064
+
3065
+	/**
3066
+	 * @param string $show_datetime_selector
3067
+	 */
3068
+	public function setShowDatetimeSelector($show_datetime_selector)
3069
+	{
3070
+		$this->show_datetime_selector = in_array(
3071
+			$show_datetime_selector,
3072
+			$this->getShowDatetimeSelectorOptions(),
3073
+			true
3074
+		)
3075
+			? $show_datetime_selector
3076
+			: \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3077
+	}
3078
+
3079
+
3080
+
3081
+	/**
3082
+	 * @return int
3083
+	 */
3084
+	public function getDatetimeSelectorThreshold()
3085
+	{
3086
+		return $this->datetime_selector_threshold;
3087
+	}
3088
+
3089
+
3090
+
3091
+
3092
+	/**
3093
+	 * @param int $datetime_selector_threshold
3094
+	 */
3095
+	public function setDatetimeSelectorThreshold($datetime_selector_threshold)
3096
+	{
3097
+		$datetime_selector_threshold = absint($datetime_selector_threshold);
3098
+		$this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3;
3099
+	}
3100 3100
 
3101 3101
 
3102 3102
 
@@ -3114,85 +3114,85 @@  discard block
 block discarded – undo
3114 3114
 class EE_Environment_Config extends EE_Config_Base
3115 3115
 {
3116 3116
 
3117
-    /**
3118
-     * Hold any php environment variables that we want to track.
3119
-     *
3120
-     * @var stdClass;
3121
-     */
3122
-    public $php;
3123
-
3124
-
3125
-
3126
-    /**
3127
-     *    constructor
3128
-     */
3129
-    public function __construct()
3130
-    {
3131
-        $this->php = new stdClass();
3132
-        $this->_set_php_values();
3133
-    }
3134
-
3135
-
3136
-
3137
-    /**
3138
-     * This sets the php environment variables.
3139
-     *
3140
-     * @since 4.4.0
3141
-     * @return void
3142
-     */
3143
-    protected function _set_php_values()
3144
-    {
3145
-        $this->php->max_input_vars = ini_get('max_input_vars');
3146
-        $this->php->version = phpversion();
3147
-    }
3148
-
3149
-
3150
-
3151
-    /**
3152
-     * helper method for determining whether input_count is
3153
-     * reaching the potential maximum the server can handle
3154
-     * according to max_input_vars
3155
-     *
3156
-     * @param int   $input_count the count of input vars.
3157
-     * @return array {
3158
-     *                           An array that represents whether available space and if no available space the error
3159
-     *                           message.
3160
-     * @type bool   $has_space   whether more inputs can be added.
3161
-     * @type string $msg         Any message to be displayed.
3162
-     *                           }
3163
-     */
3164
-    public function max_input_vars_limit_check($input_count = 0)
3165
-    {
3166
-        if (! empty($this->php->max_input_vars)
3167
-            && ($input_count >= $this->php->max_input_vars)
3168
-            && (PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9)
3169
-        ) {
3170
-            return sprintf(
3171
-                __(
3172
-                    'The maximum number of inputs on this page has been exceeded.  You cannot add anymore items (i.e. tickets, datetimes, custom fields) on this page because of your servers PHP "max_input_vars" setting.%1$sThere are %2$d inputs and the maximum amount currently allowed by your server is %3$d.',
3173
-                    'event_espresso'
3174
-                ),
3175
-                '<br>',
3176
-                $input_count,
3177
-                $this->php->max_input_vars
3178
-            );
3179
-        } else {
3180
-            return '';
3181
-        }
3182
-    }
3183
-
3184
-
3185
-
3186
-    /**
3187
-     * The purpose of this method is just to force rechecking php values so if they've changed, they get updated.
3188
-     *
3189
-     * @since 4.4.1
3190
-     * @return void
3191
-     */
3192
-    public function recheck_values()
3193
-    {
3194
-        $this->_set_php_values();
3195
-    }
3117
+	/**
3118
+	 * Hold any php environment variables that we want to track.
3119
+	 *
3120
+	 * @var stdClass;
3121
+	 */
3122
+	public $php;
3123
+
3124
+
3125
+
3126
+	/**
3127
+	 *    constructor
3128
+	 */
3129
+	public function __construct()
3130
+	{
3131
+		$this->php = new stdClass();
3132
+		$this->_set_php_values();
3133
+	}
3134
+
3135
+
3136
+
3137
+	/**
3138
+	 * This sets the php environment variables.
3139
+	 *
3140
+	 * @since 4.4.0
3141
+	 * @return void
3142
+	 */
3143
+	protected function _set_php_values()
3144
+	{
3145
+		$this->php->max_input_vars = ini_get('max_input_vars');
3146
+		$this->php->version = phpversion();
3147
+	}
3148
+
3149
+
3150
+
3151
+	/**
3152
+	 * helper method for determining whether input_count is
3153
+	 * reaching the potential maximum the server can handle
3154
+	 * according to max_input_vars
3155
+	 *
3156
+	 * @param int   $input_count the count of input vars.
3157
+	 * @return array {
3158
+	 *                           An array that represents whether available space and if no available space the error
3159
+	 *                           message.
3160
+	 * @type bool   $has_space   whether more inputs can be added.
3161
+	 * @type string $msg         Any message to be displayed.
3162
+	 *                           }
3163
+	 */
3164
+	public function max_input_vars_limit_check($input_count = 0)
3165
+	{
3166
+		if (! empty($this->php->max_input_vars)
3167
+			&& ($input_count >= $this->php->max_input_vars)
3168
+			&& (PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9)
3169
+		) {
3170
+			return sprintf(
3171
+				__(
3172
+					'The maximum number of inputs on this page has been exceeded.  You cannot add anymore items (i.e. tickets, datetimes, custom fields) on this page because of your servers PHP "max_input_vars" setting.%1$sThere are %2$d inputs and the maximum amount currently allowed by your server is %3$d.',
3173
+					'event_espresso'
3174
+				),
3175
+				'<br>',
3176
+				$input_count,
3177
+				$this->php->max_input_vars
3178
+			);
3179
+		} else {
3180
+			return '';
3181
+		}
3182
+	}
3183
+
3184
+
3185
+
3186
+	/**
3187
+	 * The purpose of this method is just to force rechecking php values so if they've changed, they get updated.
3188
+	 *
3189
+	 * @since 4.4.1
3190
+	 * @return void
3191
+	 */
3192
+	public function recheck_values()
3193
+	{
3194
+		$this->_set_php_values();
3195
+	}
3196 3196
 
3197 3197
 
3198 3198
 
@@ -3210,22 +3210,22 @@  discard block
 block discarded – undo
3210 3210
 class EE_Tax_Config extends EE_Config_Base
3211 3211
 {
3212 3212
 
3213
-    /*
3213
+	/*
3214 3214
      * flag to indicate whether or not to display ticket prices with the taxes included
3215 3215
      *
3216 3216
      * @var boolean $prices_displayed_including_taxes
3217 3217
      */
3218
-    public $prices_displayed_including_taxes;
3218
+	public $prices_displayed_including_taxes;
3219 3219
 
3220 3220
 
3221 3221
 
3222
-    /**
3223
-     *    class constructor
3224
-     */
3225
-    public function __construct()
3226
-    {
3227
-        $this->prices_displayed_including_taxes = true;
3228
-    }
3222
+	/**
3223
+	 *    class constructor
3224
+	 */
3225
+	public function __construct()
3226
+	{
3227
+		$this->prices_displayed_including_taxes = true;
3228
+	}
3229 3229
 }
3230 3230
 
3231 3231
 
@@ -3240,17 +3240,17 @@  discard block
 block discarded – undo
3240 3240
 class EE_Messages_Config extends EE_Config_Base
3241 3241
 {
3242 3242
 
3243
-    /**
3244
-     * This is an integer representing the deletion threshold in months for when old messages will get deleted.
3245
-     * A value of 0 represents never deleting.  Default is 0.
3246
-     *
3247
-     * @var integer
3248
-     */
3249
-    public $delete_threshold;
3250
-
3251
-    public function __construct() {
3252
-        $this->delete_threshold = 0;
3253
-    }
3243
+	/**
3244
+	 * This is an integer representing the deletion threshold in months for when old messages will get deleted.
3245
+	 * A value of 0 represents never deleting.  Default is 0.
3246
+	 *
3247
+	 * @var integer
3248
+	 */
3249
+	public $delete_threshold;
3250
+
3251
+	public function __construct() {
3252
+		$this->delete_threshold = 0;
3253
+	}
3254 3254
 }
3255 3255
 
3256 3256
 
@@ -3262,34 +3262,34 @@  discard block
 block discarded – undo
3262 3262
 class EE_Gateway_Config extends EE_Config_Base
3263 3263
 {
3264 3264
 
3265
-    /**
3266
-     * Array with keys that are payment gateways slugs, and values are arrays
3267
-     * with any config info the gateway wants to store
3268
-     *
3269
-     * @var array
3270
-     */
3271
-    public $payment_settings;
3272
-
3273
-    /**
3274
-     * Where keys are gateway slugs, and values are booleans indicating whether or not
3275
-     * the gateway is stored in the uploads directory
3276
-     *
3277
-     * @var array
3278
-     */
3279
-    public $active_gateways;
3280
-
3281
-
3282
-
3283
-    /**
3284
-     *    class constructor
3285
-     *
3286
-     * @deprecated
3287
-     */
3288
-    public function __construct()
3289
-    {
3290
-        $this->payment_settings = array();
3291
-        $this->active_gateways = array('Invoice' => false);
3292
-    }
3265
+	/**
3266
+	 * Array with keys that are payment gateways slugs, and values are arrays
3267
+	 * with any config info the gateway wants to store
3268
+	 *
3269
+	 * @var array
3270
+	 */
3271
+	public $payment_settings;
3272
+
3273
+	/**
3274
+	 * Where keys are gateway slugs, and values are booleans indicating whether or not
3275
+	 * the gateway is stored in the uploads directory
3276
+	 *
3277
+	 * @var array
3278
+	 */
3279
+	public $active_gateways;
3280
+
3281
+
3282
+
3283
+	/**
3284
+	 *    class constructor
3285
+	 *
3286
+	 * @deprecated
3287
+	 */
3288
+	public function __construct()
3289
+	{
3290
+		$this->payment_settings = array();
3291
+		$this->active_gateways = array('Invoice' => false);
3292
+	}
3293 3293
 }
3294 3294
 
3295 3295
 // End of file EE_Config.core.php
Please login to merge, or discard this patch.
modules/single_page_checkout/EED_Single_Page_Checkout.module.php 2 patches
Indentation   +1836 added lines, -1836 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
 use EventEspresso\core\exceptions\InvalidInterfaceException;
7 7
 
8 8
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
9
-    exit('No direct script access allowed');
9
+	exit('No direct script access allowed');
10 10
 }
11 11
 
12 12
 
@@ -21,1841 +21,1841 @@  discard block
 block discarded – undo
21 21
 class EED_Single_Page_Checkout extends EED_Module
22 22
 {
23 23
 
24
-    /**
25
-     * $_initialized - has the SPCO controller already been initialized ?
26
-     *
27
-     * @access private
28
-     * @var bool $_initialized
29
-     */
30
-    private static $_initialized = false;
31
-
32
-
33
-    /**
34
-     * $_checkout_verified - is the EE_Checkout verified as correct for this request ?
35
-     *
36
-     * @access private
37
-     * @var bool $_valid_checkout
38
-     */
39
-    private static $_checkout_verified = true;
40
-
41
-    /**
42
-     *    $_reg_steps_array - holds initial array of reg steps
43
-     *
44
-     * @access private
45
-     * @var array $_reg_steps_array
46
-     */
47
-    private static $_reg_steps_array = array();
48
-
49
-    /**
50
-     *    $checkout - EE_Checkout object for handling the properties of the current checkout process
51
-     *
52
-     * @access public
53
-     * @var EE_Checkout $checkout
54
-     */
55
-    public $checkout;
56
-
57
-
58
-
59
-    /**
60
-     * @return EED_Module|EED_Single_Page_Checkout
61
-     */
62
-    public static function instance()
63
-    {
64
-        add_filter('EED_Single_Page_Checkout__SPCO_active', '__return_true');
65
-        return parent::get_instance(__CLASS__);
66
-    }
67
-
68
-
69
-
70
-    /**
71
-     * @return EE_CART
72
-     */
73
-    public function cart()
74
-    {
75
-        return $this->checkout->cart;
76
-    }
77
-
78
-
79
-
80
-    /**
81
-     * @return EE_Transaction
82
-     */
83
-    public function transaction()
84
-    {
85
-        return $this->checkout->transaction;
86
-    }
87
-
88
-
89
-
90
-    /**
91
-     *    set_hooks - for hooking into EE Core, other modules, etc
92
-     *
93
-     * @access    public
94
-     * @return    void
95
-     * @throws EE_Error
96
-     */
97
-    public static function set_hooks()
98
-    {
99
-        EED_Single_Page_Checkout::set_definitions();
100
-    }
101
-
102
-
103
-
104
-    /**
105
-     *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
106
-     *
107
-     * @access    public
108
-     * @return    void
109
-     * @throws EE_Error
110
-     */
111
-    public static function set_hooks_admin()
112
-    {
113
-        EED_Single_Page_Checkout::set_definitions();
114
-        if ( ! (defined('DOING_AJAX') && DOING_AJAX)) {
115
-            return;
116
-        }
117
-        // going to start an output buffer in case anything gets accidentally output
118
-        // that might disrupt our JSON response
119
-        ob_start();
120
-        EED_Single_Page_Checkout::load_request_handler();
121
-        EED_Single_Page_Checkout::load_reg_steps();
122
-        // set ajax hooks
123
-        add_action('wp_ajax_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step'));
124
-        add_action('wp_ajax_nopriv_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step'));
125
-        add_action('wp_ajax_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step'));
126
-        add_action('wp_ajax_nopriv_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step'));
127
-        add_action('wp_ajax_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step'));
128
-        add_action('wp_ajax_nopriv_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step'));
129
-    }
130
-
131
-
132
-
133
-    /**
134
-     *    process ajax request
135
-     *
136
-     * @param string $ajax_action
137
-     * @throws EE_Error
138
-     */
139
-    public static function process_ajax_request($ajax_action)
140
-    {
141
-        EE_Registry::instance()->REQ->set('action', $ajax_action);
142
-        EED_Single_Page_Checkout::instance()->_initialize();
143
-    }
144
-
145
-
146
-
147
-    /**
148
-     *    ajax display registration step
149
-     *
150
-     * @throws EE_Error
151
-     */
152
-    public static function display_reg_step()
153
-    {
154
-        EED_Single_Page_Checkout::process_ajax_request('display_spco_reg_step');
155
-    }
156
-
157
-
158
-
159
-    /**
160
-     *    ajax process registration step
161
-     *
162
-     * @throws EE_Error
163
-     */
164
-    public static function process_reg_step()
165
-    {
166
-        EED_Single_Page_Checkout::process_ajax_request('process_reg_step');
167
-    }
168
-
169
-
170
-
171
-    /**
172
-     *    ajax process registration step
173
-     *
174
-     * @throws EE_Error
175
-     */
176
-    public static function update_reg_step()
177
-    {
178
-        EED_Single_Page_Checkout::process_ajax_request('update_reg_step');
179
-    }
180
-
181
-
182
-
183
-    /**
184
-     *   update_checkout
185
-     *
186
-     * @access public
187
-     * @return void
188
-     * @throws EE_Error
189
-     */
190
-    public static function update_checkout()
191
-    {
192
-        EED_Single_Page_Checkout::process_ajax_request('update_checkout');
193
-    }
194
-
195
-
196
-
197
-    /**
198
-     *    load_request_handler
199
-     *
200
-     * @access    public
201
-     * @return    void
202
-     */
203
-    public static function load_request_handler()
204
-    {
205
-        // load core Request_Handler class
206
-        if (EE_Registry::instance()->REQ !== null) {
207
-            EE_Registry::instance()->load_core('Request_Handler');
208
-        }
209
-    }
210
-
211
-
212
-
213
-    /**
214
-     *    set_definitions
215
-     *
216
-     * @access    public
217
-     * @return    void
218
-     * @throws EE_Error
219
-     */
220
-    public static function set_definitions()
221
-    {
222
-        if(defined('SPCO_BASE_PATH')) {
223
-            return;
224
-        }
225
-        define(
226
-            'SPCO_BASE_PATH',
227
-            rtrim(str_replace(array('\\', '/'), DS, plugin_dir_path(__FILE__)), DS) . DS
228
-        );
229
-        define('SPCO_CSS_URL', plugin_dir_url(__FILE__) . 'css' . DS);
230
-        define('SPCO_IMG_URL', plugin_dir_url(__FILE__) . 'img' . DS);
231
-        define('SPCO_JS_URL', plugin_dir_url(__FILE__) . 'js' . DS);
232
-        define('SPCO_INC_PATH', SPCO_BASE_PATH . 'inc' . DS);
233
-        define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH . 'reg_steps' . DS);
234
-        define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH . 'templates' . DS);
235
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(SPCO_BASE_PATH, true);
236
-        EE_Registry::$i18n_js_strings['registration_expiration_notice'] = EED_Single_Page_Checkout::getRegistrationExpirationNotice();
237
-    }
238
-
239
-
240
-
241
-    /**
242
-     * load_reg_steps
243
-     * loads and instantiates each reg step based on the EE_Registry::instance()->CFG->registration->reg_steps array
244
-     *
245
-     * @access    private
246
-     * @throws EE_Error
247
-     */
248
-    public static function load_reg_steps()
249
-    {
250
-        static $reg_steps_loaded = false;
251
-        if ($reg_steps_loaded) {
252
-            return;
253
-        }
254
-        // filter list of reg_steps
255
-        $reg_steps_to_load = (array)apply_filters(
256
-            'AHEE__SPCO__load_reg_steps__reg_steps_to_load',
257
-            EED_Single_Page_Checkout::get_reg_steps()
258
-        );
259
-        // sort by key (order)
260
-        ksort($reg_steps_to_load);
261
-        // loop through folders
262
-        foreach ($reg_steps_to_load as $order => $reg_step) {
263
-            // we need a
264
-            if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) {
265
-                // copy over to the reg_steps_array
266
-                EED_Single_Page_Checkout::$_reg_steps_array[$order] = $reg_step;
267
-                // register custom key route for each reg step
268
-                // ie: step=>"slug" - this is the entire reason we load the reg steps array now
269
-                EE_Config::register_route(
270
-                    $reg_step['slug'],
271
-                    'EED_Single_Page_Checkout',
272
-                    'run',
273
-                    'step'
274
-                );
275
-                // add AJAX or other hooks
276
-                if (isset($reg_step['has_hooks']) && $reg_step['has_hooks']) {
277
-                    // setup autoloaders if necessary
278
-                    if ( ! class_exists($reg_step['class_name'])) {
279
-                        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(
280
-                            $reg_step['file_path'],
281
-                            true
282
-                        );
283
-                    }
284
-                    if (is_callable($reg_step['class_name'], 'set_hooks')) {
285
-                        call_user_func(array($reg_step['class_name'], 'set_hooks'));
286
-                    }
287
-                }
288
-            }
289
-        }
290
-        $reg_steps_loaded = true;
291
-    }
292
-
293
-
294
-
295
-    /**
296
-     *    get_reg_steps
297
-     *
298
-     * @access    public
299
-     * @return    array
300
-     */
301
-    public static function get_reg_steps()
302
-    {
303
-        $reg_steps = EE_Registry::instance()->CFG->registration->reg_steps;
304
-        if (empty($reg_steps)) {
305
-            $reg_steps = array(
306
-                10  => array(
307
-                    'file_path'  => SPCO_REG_STEPS_PATH . 'attendee_information',
308
-                    'class_name' => 'EE_SPCO_Reg_Step_Attendee_Information',
309
-                    'slug'       => 'attendee_information',
310
-                    'has_hooks'  => false,
311
-                ),
312
-                30  => array(
313
-                    'file_path'  => SPCO_REG_STEPS_PATH . 'payment_options',
314
-                    'class_name' => 'EE_SPCO_Reg_Step_Payment_Options',
315
-                    'slug'       => 'payment_options',
316
-                    'has_hooks'  => true,
317
-                ),
318
-                999 => array(
319
-                    'file_path'  => SPCO_REG_STEPS_PATH . 'finalize_registration',
320
-                    'class_name' => 'EE_SPCO_Reg_Step_Finalize_Registration',
321
-                    'slug'       => 'finalize_registration',
322
-                    'has_hooks'  => false,
323
-                ),
324
-            );
325
-        }
326
-        return $reg_steps;
327
-    }
328
-
329
-
330
-
331
-    /**
332
-     *    registration_checkout_for_admin
333
-     *
334
-     * @access    public
335
-     * @return    string
336
-     * @throws EE_Error
337
-     */
338
-    public static function registration_checkout_for_admin()
339
-    {
340
-        EED_Single_Page_Checkout::load_request_handler();
341
-        EE_Registry::instance()->REQ->set('step', 'attendee_information');
342
-        EE_Registry::instance()->REQ->set('action', 'display_spco_reg_step');
343
-        EE_Registry::instance()->REQ->set('process_form_submission', false);
344
-        EED_Single_Page_Checkout::instance()->_initialize();
345
-        EED_Single_Page_Checkout::instance()->_display_spco_reg_form();
346
-        return EE_Registry::instance()->REQ->get_output();
347
-    }
348
-
349
-
350
-
351
-    /**
352
-     * process_registration_from_admin
353
-     *
354
-     * @access public
355
-     * @return \EE_Transaction
356
-     * @throws EE_Error
357
-     */
358
-    public static function process_registration_from_admin()
359
-    {
360
-        EED_Single_Page_Checkout::load_request_handler();
361
-        EE_Registry::instance()->REQ->set('step', 'attendee_information');
362
-        EE_Registry::instance()->REQ->set('action', 'process_reg_step');
363
-        EE_Registry::instance()->REQ->set('process_form_submission', true);
364
-        EED_Single_Page_Checkout::instance()->_initialize();
365
-        if (EED_Single_Page_Checkout::instance()->checkout->current_step->completed()) {
366
-            $final_reg_step = end(EED_Single_Page_Checkout::instance()->checkout->reg_steps);
367
-            if ($final_reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration) {
368
-                EED_Single_Page_Checkout::instance()->checkout->set_reg_step_initiated($final_reg_step);
369
-                if ($final_reg_step->process_reg_step()) {
370
-                    $final_reg_step->set_completed();
371
-                    EED_Single_Page_Checkout::instance()->checkout->update_txn_reg_steps_array();
372
-                    return EED_Single_Page_Checkout::instance()->checkout->transaction;
373
-                }
374
-            }
375
-        }
376
-        return null;
377
-    }
378
-
379
-
380
-
381
-    /**
382
-     *    run
383
-     *
384
-     * @access    public
385
-     * @param WP_Query $WP_Query
386
-     * @return    void
387
-     * @throws EE_Error
388
-     */
389
-    public function run($WP_Query)
390
-    {
391
-        if (
392
-            $WP_Query instanceof WP_Query
393
-            && $WP_Query->is_main_query()
394
-            && apply_filters('FHEE__EED_Single_Page_Checkout__run', true)
395
-            && $this->_is_reg_checkout()
396
-        ) {
397
-            $this->_initialize();
398
-        }
399
-    }
400
-
401
-
402
-
403
-    /**
404
-     * determines whether current url matches reg page url
405
-     *
406
-     * @return bool
407
-     */
408
-    protected function _is_reg_checkout()
409
-    {
410
-        // get current permalink for reg page without any extra query args
411
-        $reg_page_url = \get_permalink(EE_Config::instance()->core->reg_page_id);
412
-        // get request URI for current request, but without the scheme or host
413
-        $current_request_uri = \EEH_URL::filter_input_server_url('REQUEST_URI');
414
-        $current_request_uri = html_entity_decode($current_request_uri);
415
-        // get array of query args from the current request URI
416
-        $query_args = \EEH_URL::get_query_string($current_request_uri);
417
-        // grab page id if it is set
418
-        $page_id = isset($query_args['page_id']) ? absint($query_args['page_id']) : 0;
419
-        // and remove the page id from the query args (we will re-add it later)
420
-        unset($query_args['page_id']);
421
-        // now strip all query args from current request URI
422
-        $current_request_uri = remove_query_arg(array_keys($query_args), $current_request_uri);
423
-        // and re-add the page id if it was set
424
-        if ($page_id) {
425
-            $current_request_uri = add_query_arg('page_id', $page_id, $current_request_uri);
426
-        }
427
-        // remove slashes and ?
428
-        $current_request_uri = trim($current_request_uri, '?/');
429
-        // is current request URI part of the known full reg page URL ?
430
-        return ! empty($current_request_uri) && strpos($reg_page_url, $current_request_uri) !== false;
431
-    }
432
-
433
-
434
-
435
-    /**
436
-     * @param WP_Query $wp_query
437
-     * @return    void
438
-     * @throws EE_Error
439
-     */
440
-    public static function init($wp_query)
441
-    {
442
-        EED_Single_Page_Checkout::instance()->run($wp_query);
443
-    }
444
-
445
-
446
-
447
-    /**
448
-     *    _initialize - initial module setup
449
-     *
450
-     * @access    private
451
-     * @throws EE_Error
452
-     * @return    void
453
-     */
454
-    private function _initialize()
455
-    {
456
-        // ensure SPCO doesn't run twice
457
-        if (EED_Single_Page_Checkout::$_initialized) {
458
-            return;
459
-        }
460
-        try {
461
-            EED_Single_Page_Checkout::load_reg_steps();
462
-            $this->_verify_session();
463
-            // setup the EE_Checkout object
464
-            $this->checkout = $this->_initialize_checkout();
465
-            // filter checkout
466
-            $this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout);
467
-            // get the $_GET
468
-            $this->_get_request_vars();
469
-            if ($this->_block_bots()) {
470
-                return;
471
-            }
472
-            // filter continue_reg
473
-            $this->checkout->continue_reg = apply_filters(
474
-                'FHEE__EED_Single_Page_Checkout__init___continue_reg',
475
-                true,
476
-                $this->checkout
477
-            );
478
-            // load the reg steps array
479
-            if ( ! $this->_load_and_instantiate_reg_steps()) {
480
-                EED_Single_Page_Checkout::$_initialized = true;
481
-                return;
482
-            }
483
-            // set the current step
484
-            $this->checkout->set_current_step($this->checkout->step);
485
-            // and the next step
486
-            $this->checkout->set_next_step();
487
-            // verify that everything has been setup correctly
488
-            if ( ! ($this->_verify_transaction_and_get_registrations() && $this->_final_verifications())) {
489
-                EED_Single_Page_Checkout::$_initialized = true;
490
-                return;
491
-            }
492
-            // lock the transaction
493
-            $this->checkout->transaction->lock();
494
-            // make sure all of our cached objects are added to their respective model entity mappers
495
-            $this->checkout->refresh_all_entities();
496
-            // set amount owing
497
-            $this->checkout->amount_owing = $this->checkout->transaction->remaining();
498
-            // initialize each reg step, which gives them the chance to potentially alter the process
499
-            $this->_initialize_reg_steps();
500
-            // DEBUG LOG
501
-            //$this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ );
502
-            // get reg form
503
-            if( ! $this->_check_form_submission()) {
504
-                EED_Single_Page_Checkout::$_initialized = true;
505
-                return;
506
-            }
507
-            // checkout the action!!!
508
-            $this->_process_form_action();
509
-            // add some style and make it dance
510
-            $this->add_styles_and_scripts();
511
-            // kk... SPCO has successfully run
512
-            EED_Single_Page_Checkout::$_initialized = true;
513
-            // set no cache headers and constants
514
-            EE_System::do_not_cache();
515
-            // add anchor
516
-            add_action('loop_start', array($this, 'set_checkout_anchor'), 1);
517
-            // remove transaction lock
518
-            add_action('shutdown', array($this, 'unlock_transaction'), 1);
519
-        } catch (Exception $e) {
520
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
521
-        }
522
-    }
523
-
524
-
525
-
526
-    /**
527
-     *    _verify_session
528
-     * checks that the session is valid and not expired
529
-     *
530
-     * @access    private
531
-     * @throws EE_Error
532
-     */
533
-    private function _verify_session()
534
-    {
535
-        if ( ! EE_Registry::instance()->SSN instanceof EE_Session) {
536
-            throw new EE_Error(__('The EE_Session class could not be loaded.', 'event_espresso'));
537
-        }
538
-        $clear_session_requested = filter_var(
539
-            EE_Registry::instance()->REQ->get('clear_session', false),
540
-            FILTER_VALIDATE_BOOLEAN
541
-        );
542
-        // is session still valid ?
543
-        if ($clear_session_requested
544
-            || ( EE_Registry::instance()->SSN->expired()
545
-              && EE_Registry::instance()->REQ->get('e_reg_url_link', '') === ''
546
-            )
547
-        ) {
548
-            $this->checkout = new EE_Checkout();
549
-            EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
550
-            // EE_Registry::instance()->SSN->reset_cart();
551
-            // EE_Registry::instance()->SSN->reset_checkout();
552
-            // EE_Registry::instance()->SSN->reset_transaction();
553
-            if (! $clear_session_requested) {
554
-                EE_Error::add_attention(
555
-                    EE_Registry::$i18n_js_strings['registration_expiration_notice'],
556
-                    __FILE__, __FUNCTION__, __LINE__
557
-                );
558
-            }
559
-            // EE_Registry::instance()->SSN->reset_expired();
560
-        }
561
-    }
562
-
563
-
564
-
565
-    /**
566
-     *    _initialize_checkout
567
-     * loads and instantiates EE_Checkout
568
-     *
569
-     * @access    private
570
-     * @throws EE_Error
571
-     * @return EE_Checkout
572
-     */
573
-    private function _initialize_checkout()
574
-    {
575
-        // look in session for existing checkout
576
-        /** @type EE_Checkout $checkout */
577
-        $checkout = EE_Registry::instance()->SSN->checkout();
578
-        // verify
579
-        if ( ! $checkout instanceof EE_Checkout) {
580
-            // instantiate EE_Checkout object for handling the properties of the current checkout process
581
-            $checkout = EE_Registry::instance()->load_file(
582
-                SPCO_INC_PATH,
583
-                'EE_Checkout',
584
-                'class', array(),
585
-                false
586
-            );
587
-        } else {
588
-            if ($checkout->current_step->is_final_step() && $checkout->exit_spco() === true) {
589
-                $this->unlock_transaction();
590
-                wp_safe_redirect($checkout->redirect_url);
591
-                exit();
592
-            }
593
-        }
594
-        $checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout);
595
-        // verify again
596
-        if ( ! $checkout instanceof EE_Checkout) {
597
-            throw new EE_Error(__('The EE_Checkout class could not be loaded.', 'event_espresso'));
598
-        }
599
-        // reset anything that needs a clean slate for each request
600
-        $checkout->reset_for_current_request();
601
-        return $checkout;
602
-    }
603
-
604
-
605
-
606
-    /**
607
-     *    _get_request_vars
608
-     *
609
-     * @access    private
610
-     * @return    void
611
-     * @throws EE_Error
612
-     */
613
-    private function _get_request_vars()
614
-    {
615
-        // load classes
616
-        EED_Single_Page_Checkout::load_request_handler();
617
-        //make sure this request is marked as belonging to EE
618
-        EE_Registry::instance()->REQ->set_espresso_page(true);
619
-        // which step is being requested ?
620
-        $this->checkout->step = EE_Registry::instance()->REQ->get('step', $this->_get_first_step());
621
-        // which step is being edited ?
622
-        $this->checkout->edit_step = EE_Registry::instance()->REQ->get('edit_step', '');
623
-        // and what we're doing on the current step
624
-        $this->checkout->action = EE_Registry::instance()->REQ->get('action', 'display_spco_reg_step');
625
-        // timestamp
626
-        $this->checkout->uts = EE_Registry::instance()->REQ->get('uts', 0);
627
-        // returning to edit ?
628
-        $this->checkout->reg_url_link = EE_Registry::instance()->REQ->get('e_reg_url_link', '');
629
-        // add reg url link to registration query params
630
-        if ($this->checkout->reg_url_link && strpos($this->checkout->reg_url_link, '1-') !== 0) {
631
-            $this->checkout->reg_cache_where_params[0]['REG_url_link'] = $this->checkout->reg_url_link;
632
-        }
633
-        // or some other kind of revisit ?
634
-        $this->checkout->revisit = filter_var(
635
-            EE_Registry::instance()->REQ->get('revisit', false),
636
-            FILTER_VALIDATE_BOOLEAN
637
-        );
638
-        // and whether or not to generate a reg form for this request
639
-        $this->checkout->generate_reg_form = filter_var(
640
-            EE_Registry::instance()->REQ->get('generate_reg_form', true),
641
-            FILTER_VALIDATE_BOOLEAN
642
-        );
643
-        // and whether or not to process a reg form submission for this request
644
-        $this->checkout->process_form_submission = filter_var(
645
-            EE_Registry::instance()->REQ->get(
646
-                'process_form_submission',
647
-                $this->checkout->action === 'process_reg_step'
648
-            ),
649
-            FILTER_VALIDATE_BOOLEAN
650
-        );
651
-        $this->checkout->process_form_submission = filter_var(
652
-            $this->checkout->action !== 'display_spco_reg_step'
653
-                ? $this->checkout->process_form_submission
654
-                : false,
655
-            FILTER_VALIDATE_BOOLEAN
656
-        );
657
-        // $this->_display_request_vars();
658
-    }
659
-
660
-
661
-
662
-    /**
663
-     *  _display_request_vars
664
-     *
665
-     * @access    protected
666
-     * @return    void
667
-     */
668
-    protected function _display_request_vars()
669
-    {
670
-        if ( ! WP_DEBUG) {
671
-            return;
672
-        }
673
-        EEH_Debug_Tools::printr($_REQUEST, '$_REQUEST', __FILE__, __LINE__);
674
-        EEH_Debug_Tools::printr($this->checkout->step, '$this->checkout->step', __FILE__, __LINE__);
675
-        EEH_Debug_Tools::printr($this->checkout->edit_step, '$this->checkout->edit_step', __FILE__, __LINE__);
676
-        EEH_Debug_Tools::printr($this->checkout->action, '$this->checkout->action', __FILE__, __LINE__);
677
-        EEH_Debug_Tools::printr($this->checkout->reg_url_link, '$this->checkout->reg_url_link', __FILE__, __LINE__);
678
-        EEH_Debug_Tools::printr($this->checkout->revisit, '$this->checkout->revisit', __FILE__, __LINE__);
679
-        EEH_Debug_Tools::printr($this->checkout->generate_reg_form, '$this->checkout->generate_reg_form', __FILE__, __LINE__);
680
-        EEH_Debug_Tools::printr($this->checkout->process_form_submission, '$this->checkout->process_form_submission', __FILE__, __LINE__);
681
-    }
682
-
683
-
684
-
685
-    /**
686
-     * _block_bots
687
-     * checks that the incoming request has either of the following set:
688
-     *  a uts (unix timestamp) which indicates that the request was redirected from the Ticket Selector
689
-     *  a REG URL Link, which indicates that the request is a return visit to SPCO for a valid TXN
690
-     * so if you're not coming from the Ticket Selector nor returning for a valid IP...
691
-     * then where you coming from man?
692
-     *
693
-     * @return boolean
694
-     */
695
-    private function _block_bots()
696
-    {
697
-        $invalid_checkout_access = EED_Invalid_Checkout_Access::getInvalidCheckoutAccess();
698
-        if ($invalid_checkout_access->checkoutAccessIsInvalid($this->checkout)) {
699
-            return true;
700
-        }
701
-        return false;
702
-    }
703
-
704
-
705
-
706
-    /**
707
-     *    _get_first_step
708
-     *  gets slug for first step in $_reg_steps_array
709
-     *
710
-     * @access    private
711
-     * @throws EE_Error
712
-     * @return    string
713
-     */
714
-    private function _get_first_step()
715
-    {
716
-        $first_step = reset(EED_Single_Page_Checkout::$_reg_steps_array);
717
-        return isset($first_step['slug']) ? $first_step['slug'] : 'attendee_information';
718
-    }
719
-
720
-
721
-    /**
722
-     * instantiates each reg step based on the loaded reg_steps array
723
-     *
724
-     * @return    bool
725
-     * @throws EE_Error
726
-     * @throws InvalidArgumentException
727
-     * @throws InvalidDataTypeException
728
-     * @throws InvalidInterfaceException
729
-     */
730
-    private function _load_and_instantiate_reg_steps()
731
-    {
732
-        do_action('AHEE__Single_Page_Checkout___load_and_instantiate_reg_steps__start', $this->checkout);
733
-        // have reg_steps already been instantiated ?
734
-        if (
735
-            empty($this->checkout->reg_steps)
736
-            || apply_filters('FHEE__Single_Page_Checkout__load_reg_steps__reload_reg_steps', false, $this->checkout)
737
-        ) {
738
-            // if not, then loop through raw reg steps array
739
-            foreach (EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step) {
740
-                if ( ! $this->_load_and_instantiate_reg_step($reg_step, $order)) {
741
-                    return false;
742
-                }
743
-            }
744
-            if(isset($this->checkout->reg_steps['registration_confirmation'])){
745
-                // skip the registration_confirmation page ?
746
-                if (EE_Registry::instance()->CFG->registration->skip_reg_confirmation) {
747
-                    // just remove it from the reg steps array
748
-                    $this->checkout->remove_reg_step('registration_confirmation', false);
749
-                } elseif (EE_Registry::instance()->CFG->registration->reg_confirmation_last
750
-                ) {
751
-                    // set the order to something big like 100
752
-                    $this->checkout->set_reg_step_order('registration_confirmation', 100);
753
-                }
754
-            }
755
-            // filter the array for good luck
756
-            $this->checkout->reg_steps = apply_filters(
757
-                'FHEE__Single_Page_Checkout__load_reg_steps__reg_steps',
758
-                $this->checkout->reg_steps
759
-            );
760
-            // finally re-sort based on the reg step class order properties
761
-            $this->checkout->sort_reg_steps();
762
-        } else {
763
-            foreach ($this->checkout->reg_steps as $reg_step) {
764
-                // set all current step stati to FALSE
765
-                $reg_step->set_is_current_step(false);
766
-            }
767
-        }
768
-        if (empty($this->checkout->reg_steps)) {
769
-            EE_Error::add_error(
770
-                __('No Reg Steps were loaded..', 'event_espresso'),
771
-                __FILE__, __FUNCTION__, __LINE__
772
-            );
773
-            return false;
774
-        }
775
-        // make reg step details available to JS
776
-        $this->checkout->set_reg_step_JSON_info();
777
-        return true;
778
-    }
779
-
780
-
781
-
782
-    /**
783
-     *     _load_and_instantiate_reg_step
784
-     *
785
-     * @access    private
786
-     * @param array $reg_step
787
-     * @param int   $order
788
-     * @return bool
789
-     */
790
-    private function _load_and_instantiate_reg_step($reg_step = array(), $order = 0)
791
-    {
792
-        // we need a file_path, class_name, and slug to add a reg step
793
-        if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) {
794
-            // if editing a specific step, but this is NOT that step... (and it's not the 'finalize_registration' step)
795
-            if (
796
-                $this->checkout->reg_url_link
797
-                && $this->checkout->step !== $reg_step['slug']
798
-                && $reg_step['slug'] !== 'finalize_registration'
799
-                // normally at this point we would NOT load the reg step, but this filter can change that
800
-                && apply_filters(
801
-                    'FHEE__Single_Page_Checkout___load_and_instantiate_reg_step__bypass_reg_step',
802
-                    true,
803
-                    $reg_step,
804
-                    $this->checkout
805
-                )
806
-            ) {
807
-                return true;
808
-            }
809
-            // instantiate step class using file path and class name
810
-            $reg_step_obj = EE_Registry::instance()->load_file(
811
-                $reg_step['file_path'],
812
-                $reg_step['class_name'],
813
-                'class',
814
-                $this->checkout,
815
-                false
816
-            );
817
-            // did we gets the goods ?
818
-            if ($reg_step_obj instanceof EE_SPCO_Reg_Step) {
819
-                // set reg step order based on config
820
-                $reg_step_obj->set_order($order);
821
-                // add instantiated reg step object to the master reg steps array
822
-                $this->checkout->add_reg_step($reg_step_obj);
823
-            } else {
824
-                EE_Error::add_error(
825
-                    __('The current step could not be set.', 'event_espresso'),
826
-                    __FILE__, __FUNCTION__, __LINE__
827
-                );
828
-                return false;
829
-            }
830
-        } else {
831
-            if (WP_DEBUG) {
832
-                EE_Error::add_error(
833
-                    sprintf(
834
-                        __(
835
-                            'A registration step could not be loaded. One or more of the following data points is invalid:%4$s%5$sFile Path: %1$s%6$s%5$sClass Name: %2$s%6$s%5$sSlug: %3$s%6$s%7$s',
836
-                            'event_espresso'
837
-                        ),
838
-                        isset($reg_step['file_path']) ? $reg_step['file_path'] : '',
839
-                        isset($reg_step['class_name']) ? $reg_step['class_name'] : '',
840
-                        isset($reg_step['slug']) ? $reg_step['slug'] : '',
841
-                        '<ul>',
842
-                        '<li>',
843
-                        '</li>',
844
-                        '</ul>'
845
-                    ),
846
-                    __FILE__, __FUNCTION__, __LINE__
847
-                );
848
-            }
849
-            return false;
850
-        }
851
-        return true;
852
-    }
853
-
854
-
855
-    /**
856
-     * _verify_transaction_and_get_registrations
857
-     *
858
-     * @access private
859
-     * @return bool
860
-     * @throws InvalidDataTypeException
861
-     * @throws InvalidEntityException
862
-     * @throws EE_Error
863
-     */
864
-    private function _verify_transaction_and_get_registrations()
865
-    {
866
-        // was there already a valid transaction in the checkout from the session ?
867
-        if ( ! $this->checkout->transaction instanceof EE_Transaction) {
868
-            // get transaction from db or session
869
-            $this->checkout->transaction = $this->checkout->reg_url_link && ! is_admin()
870
-                ? $this->_get_transaction_and_cart_for_previous_visit()
871
-                : $this->_get_cart_for_current_session_and_setup_new_transaction();
872
-            if ( ! $this->checkout->transaction instanceof EE_Transaction) {
873
-                EE_Error::add_error(
874
-                    __('Your Registration and Transaction information could not be retrieved from the db.',
875
-                        'event_espresso'),
876
-                    __FILE__, __FUNCTION__, __LINE__
877
-                );
878
-                $this->checkout->transaction = EE_Transaction::new_instance();
879
-                // add some style and make it dance
880
-                $this->add_styles_and_scripts();
881
-                EED_Single_Page_Checkout::$_initialized = true;
882
-                return false;
883
-            }
884
-            // and the registrations for the transaction
885
-            $this->_get_registrations($this->checkout->transaction);
886
-        }
887
-        return true;
888
-    }
889
-
890
-
891
-
892
-    /**
893
-     * _get_transaction_and_cart_for_previous_visit
894
-     *
895
-     * @access private
896
-     * @return mixed EE_Transaction|NULL
897
-     */
898
-    private function _get_transaction_and_cart_for_previous_visit()
899
-    {
900
-        /** @var $TXN_model EEM_Transaction */
901
-        $TXN_model = EE_Registry::instance()->load_model('Transaction');
902
-        // because the reg_url_link is present in the request,
903
-        // this is a return visit to SPCO, so we'll get the transaction data from the db
904
-        $transaction = $TXN_model->get_transaction_from_reg_url_link($this->checkout->reg_url_link);
905
-        // verify transaction
906
-        if ($transaction instanceof EE_Transaction) {
907
-            // and get the cart that was used for that transaction
908
-            $this->checkout->cart = $this->_get_cart_for_transaction($transaction);
909
-            return $transaction;
910
-        }
911
-        EE_Error::add_error(
912
-            __('Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso'),
913
-            __FILE__, __FUNCTION__, __LINE__
914
-        );
915
-        return null;
916
-
917
-    }
918
-
919
-
920
-
921
-    /**
922
-     * _get_cart_for_transaction
923
-     *
924
-     * @access private
925
-     * @param EE_Transaction $transaction
926
-     * @return EE_Cart
927
-     */
928
-    private function _get_cart_for_transaction($transaction)
929
-    {
930
-        return $this->checkout->get_cart_for_transaction($transaction);
931
-    }
932
-
933
-
934
-
935
-    /**
936
-     * get_cart_for_transaction
937
-     *
938
-     * @access public
939
-     * @param EE_Transaction $transaction
940
-     * @return EE_Cart
941
-     */
942
-    public function get_cart_for_transaction(EE_Transaction $transaction)
943
-    {
944
-        return $this->checkout->get_cart_for_transaction($transaction);
945
-    }
946
-
947
-
948
-
949
-    /**
950
-     * _get_transaction_and_cart_for_current_session
951
-     *    generates a new EE_Transaction object and adds it to the $_transaction property.
952
-     *
953
-     * @access private
954
-     * @return EE_Transaction
955
-     * @throws EE_Error
956
-     */
957
-    private function _get_cart_for_current_session_and_setup_new_transaction()
958
-    {
959
-        //  if there's no transaction, then this is the FIRST visit to SPCO
960
-        // so load up the cart ( passing nothing for the TXN because it doesn't exist yet )
961
-        $this->checkout->cart = $this->_get_cart_for_transaction(null);
962
-        // and then create a new transaction
963
-        $transaction = $this->_initialize_transaction();
964
-        // verify transaction
965
-        if ($transaction instanceof EE_Transaction) {
966
-            // save it so that we have an ID for other objects to use
967
-            $transaction->save();
968
-            // and save TXN data to the cart
969
-            $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn($transaction->ID());
970
-        } else {
971
-            EE_Error::add_error(
972
-                __('A Valid Transaction could not be initialized.', 'event_espresso'),
973
-                __FILE__, __FUNCTION__, __LINE__
974
-            );
975
-        }
976
-        return $transaction;
977
-    }
978
-
979
-
980
-
981
-    /**
982
-     *    generates a new EE_Transaction object and adds it to the $_transaction property.
983
-     *
984
-     * @access private
985
-     * @return mixed EE_Transaction|NULL
986
-     */
987
-    private function _initialize_transaction()
988
-    {
989
-        try {
990
-            // ensure cart totals have been calculated
991
-            $this->checkout->cart->get_grand_total()->recalculate_total_including_taxes();
992
-            // grab the cart grand total
993
-            $cart_total = $this->checkout->cart->get_cart_grand_total();
994
-            // create new TXN
995
-            $transaction = EE_Transaction::new_instance(
996
-                array(
997
-                    'TXN_reg_steps' => $this->checkout->initialize_txn_reg_steps_array(),
998
-                    'TXN_total'     => $cart_total > 0 ? $cart_total : 0,
999
-                    'TXN_paid'      => 0,
1000
-                    'STS_ID'        => EEM_Transaction::failed_status_code,
1001
-                )
1002
-            );
1003
-            // save it so that we have an ID for other objects to use
1004
-            $transaction->save();
1005
-            // set cron job for following up on TXNs after their session has expired
1006
-            EE_Cron_Tasks::schedule_expired_transaction_check(
1007
-                EE_Registry::instance()->SSN->expiration() + 1,
1008
-                $transaction->ID()
1009
-            );
1010
-            return $transaction;
1011
-        } catch (Exception $e) {
1012
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
1013
-        }
1014
-        return null;
1015
-    }
1016
-
1017
-
1018
-    /**
1019
-     * _get_registrations
1020
-     *
1021
-     * @access private
1022
-     * @param EE_Transaction $transaction
1023
-     * @return void
1024
-     * @throws InvalidDataTypeException
1025
-     * @throws InvalidEntityException
1026
-     * @throws EE_Error
1027
-     */
1028
-    private function _get_registrations(EE_Transaction $transaction)
1029
-    {
1030
-        // first step: grab the registrants  { : o
1031
-        $registrations = $transaction->registrations($this->checkout->reg_cache_where_params, false);
1032
-        $this->checkout->total_ticket_count = count($registrations);
1033
-        // verify registrations have been set
1034
-        if (empty($registrations)) {
1035
-            // if no cached registrations, then check the db
1036
-            $registrations = $transaction->registrations($this->checkout->reg_cache_where_params, false);
1037
-            // still nothing ? well as long as this isn't a revisit
1038
-            if (empty($registrations) && ! $this->checkout->revisit) {
1039
-                // generate new registrations from scratch
1040
-                $registrations = $this->_initialize_registrations($transaction);
1041
-            }
1042
-        }
1043
-        // sort by their original registration order
1044
-        usort($registrations, array('EED_Single_Page_Checkout', 'sort_registrations_by_REG_count'));
1045
-        // then loop thru the array
1046
-        foreach ($registrations as $registration) {
1047
-            // verify each registration
1048
-            if ($registration instanceof EE_Registration) {
1049
-                // we display all attendee info for the primary registrant
1050
-                if ($this->checkout->reg_url_link === $registration->reg_url_link()
1051
-                    && $registration->is_primary_registrant()
1052
-                ) {
1053
-                    $this->checkout->primary_revisit = true;
1054
-                    break;
1055
-                }
1056
-                if ($this->checkout->revisit && $this->checkout->reg_url_link !== $registration->reg_url_link()) {
1057
-                    // but hide info if it doesn't belong to you
1058
-                    $transaction->clear_cache('Registration', $registration->ID());
1059
-                    $this->checkout->total_ticket_count--;
1060
-                }
1061
-                $this->checkout->set_reg_status_updated($registration->ID(), false);
1062
-            }
1063
-        }
1064
-    }
1065
-
1066
-
1067
-    /**
1068
-     *    adds related EE_Registration objects for each ticket in the cart to the current EE_Transaction object
1069
-     *
1070
-     * @access private
1071
-     * @param EE_Transaction $transaction
1072
-     * @return    array
1073
-     * @throws InvalidDataTypeException
1074
-     * @throws InvalidEntityException
1075
-     * @throws EE_Error
1076
-     */
1077
-    private function _initialize_registrations(EE_Transaction $transaction)
1078
-    {
1079
-        $att_nmbr = 0;
1080
-        $registrations = array();
1081
-        if ($transaction instanceof EE_Transaction) {
1082
-            /** @type EE_Registration_Processor $registration_processor */
1083
-            $registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
1084
-            $this->checkout->total_ticket_count = $this->checkout->cart->all_ticket_quantity_count();
1085
-            // now let's add the cart items to the $transaction
1086
-            foreach ($this->checkout->cart->get_tickets() as $line_item) {
1087
-                //do the following for each ticket of this type they selected
1088
-                for ($x = 1; $x <= $line_item->quantity(); $x++) {
1089
-                    $att_nmbr++;
1090
-                    /** @var EventEspresso\core\services\commands\registration\CreateRegistrationCommand $CreateRegistrationCommand */
1091
-                    $CreateRegistrationCommand = EE_Registry::instance()->create(
1092
-                        'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
1093
-                        array(
1094
-                            $transaction,
1095
-                            $line_item,
1096
-                            $att_nmbr,
1097
-                            $this->checkout->total_ticket_count,
1098
-                        )
1099
-                    );
1100
-                    // override capabilities for frontend registrations
1101
-                    if ( ! is_admin()) {
1102
-                        $CreateRegistrationCommand->setCapCheck(
1103
-                            new PublicCapabilities('', 'create_new_registration')
1104
-                        );
1105
-                    }
1106
-                    $registration = EE_Registry::instance()->BUS->execute($CreateRegistrationCommand);
1107
-                    if ( ! $registration instanceof EE_Registration) {
1108
-                        throw new InvalidEntityException($registration, 'EE_Registration');
1109
-                    }
1110
-                    $registrations[ $registration->ID() ] = $registration;
1111
-                }
1112
-            }
1113
-            $registration_processor->fix_reg_final_price_rounding_issue($transaction);
1114
-        }
1115
-        return $registrations;
1116
-    }
1117
-
1118
-
1119
-
1120
-    /**
1121
-     * sorts registrations by REG_count
1122
-     *
1123
-     * @access public
1124
-     * @param EE_Registration $reg_A
1125
-     * @param EE_Registration $reg_B
1126
-     * @return int
1127
-     */
1128
-    public static function sort_registrations_by_REG_count(EE_Registration $reg_A, EE_Registration $reg_B)
1129
-    {
1130
-        // this shouldn't ever happen within the same TXN, but oh well
1131
-        if ($reg_A->count() === $reg_B->count()) {
1132
-            return 0;
1133
-        }
1134
-        return ($reg_A->count() > $reg_B->count()) ? 1 : -1;
1135
-    }
1136
-
1137
-
1138
-
1139
-    /**
1140
-     *    _final_verifications
1141
-     * just makes sure that everything is set up correctly before proceeding
1142
-     *
1143
-     * @access    private
1144
-     * @return    bool
1145
-     * @throws EE_Error
1146
-     */
1147
-    private function _final_verifications()
1148
-    {
1149
-        // filter checkout
1150
-        $this->checkout = apply_filters(
1151
-            'FHEE__EED_Single_Page_Checkout___final_verifications__checkout',
1152
-            $this->checkout
1153
-        );
1154
-        //verify that current step is still set correctly
1155
-        if ( ! $this->checkout->current_step instanceof EE_SPCO_Reg_Step) {
1156
-            EE_Error::add_error(
1157
-                __('We\'re sorry but the registration process can not proceed because one or more registration steps were not setup correctly. Please refresh the page and try again or contact support.', 'event_espresso'),
1158
-                __FILE__,
1159
-                __FUNCTION__,
1160
-                __LINE__
1161
-            );
1162
-            return false;
1163
-        }
1164
-        // if returning to SPCO, then verify that primary registrant is set
1165
-        if ( ! empty($this->checkout->reg_url_link)) {
1166
-            $valid_registrant = $this->checkout->transaction->primary_registration();
1167
-            if ( ! $valid_registrant instanceof EE_Registration) {
1168
-                EE_Error::add_error(
1169
-                    __('We\'re sorry but there appears to be an error with the "reg_url_link" or the primary registrant for this transaction. Please refresh the page and try again or contact support.', 'event_espresso'),
1170
-                    __FILE__,
1171
-                    __FUNCTION__,
1172
-                    __LINE__
1173
-                );
1174
-                return false;
1175
-            }
1176
-            $valid_registrant = null;
1177
-            foreach (
1178
-                $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params) as $registration
1179
-            ) {
1180
-                if (
1181
-                    $registration instanceof EE_Registration
1182
-                    && $registration->reg_url_link() === $this->checkout->reg_url_link
1183
-                ) {
1184
-                    $valid_registrant = $registration;
1185
-                }
1186
-            }
1187
-            if ( ! $valid_registrant instanceof EE_Registration) {
1188
-                // hmmm... maybe we have the wrong session because the user is opening multiple tabs ?
1189
-                if (EED_Single_Page_Checkout::$_checkout_verified) {
1190
-                    // clear the session, mark the checkout as unverified, and try again
1191
-                    EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
1192
-                    EED_Single_Page_Checkout::$_initialized = false;
1193
-                    EED_Single_Page_Checkout::$_checkout_verified = false;
1194
-                    $this->_initialize();
1195
-                    EE_Error::reset_notices();
1196
-                    return false;
1197
-                }
1198
-                EE_Error::add_error(
1199
-                    __(
1200
-                        'We\'re sorry but there appears to be an error with the "reg_url_link" or the transaction itself. Please refresh the page and try again or contact support.',
1201
-                        'event_espresso'
1202
-                    ),
1203
-                    __FILE__,
1204
-                    __FUNCTION__,
1205
-                    __LINE__
1206
-                );
1207
-                return false;
1208
-            }
1209
-        }
1210
-        // now that things have been kinda sufficiently verified,
1211
-        // let's add the checkout to the session so that it's available to other systems
1212
-        EE_Registry::instance()->SSN->set_checkout($this->checkout);
1213
-        return true;
1214
-    }
1215
-
1216
-
1217
-
1218
-    /**
1219
-     *    _initialize_reg_steps
1220
-     * first makes sure that EE_Transaction_Processor::set_reg_step_initiated() is called as required
1221
-     * then loops thru all of the active reg steps and calls the initialize_reg_step() method
1222
-     *
1223
-     * @access    private
1224
-     * @param bool $reinitializing
1225
-     * @throws EE_Error
1226
-     */
1227
-    private function _initialize_reg_steps($reinitializing = false)
1228
-    {
1229
-        $this->checkout->set_reg_step_initiated($this->checkout->current_step);
1230
-        // loop thru all steps to call their individual "initialize" methods and set i18n strings for JS
1231
-        foreach ($this->checkout->reg_steps as $reg_step) {
1232
-            if ( ! $reg_step->initialize_reg_step()) {
1233
-                // if not initialized then maybe this step is being removed...
1234
-                if ( ! $reinitializing && $reg_step->is_current_step()) {
1235
-                    // if it was the current step, then we need to start over here
1236
-                    $this->_initialize_reg_steps(true);
1237
-                    return;
1238
-                }
1239
-                continue;
1240
-            }
1241
-            // add css and JS for current step
1242
-            $reg_step->enqueue_styles_and_scripts();
1243
-            // i18n
1244
-            $reg_step->translate_js_strings();
1245
-            if ($reg_step->is_current_step()) {
1246
-                // the text that appears on the reg step form submit button
1247
-                $reg_step->set_submit_button_text();
1248
-            }
1249
-        }
1250
-        // dynamically creates hook point like: AHEE__Single_Page_Checkout___initialize_reg_step__attendee_information
1251
-        do_action(
1252
-            "AHEE__Single_Page_Checkout___initialize_reg_step__{$this->checkout->current_step->slug()}",
1253
-            $this->checkout->current_step
1254
-        );
1255
-    }
1256
-
1257
-
1258
-
1259
-    /**
1260
-     * _check_form_submission
1261
-     *
1262
-     * @access private
1263
-     * @return boolean
1264
-     */
1265
-    private function _check_form_submission()
1266
-    {
1267
-        //does this request require the reg form to be generated ?
1268
-        if ($this->checkout->generate_reg_form) {
1269
-            // ever heard that song by Blue Rodeo ?
1270
-            try {
1271
-                $this->checkout->current_step->reg_form = $this->checkout->current_step->generate_reg_form();
1272
-                // if not displaying a form, then check for form submission
1273
-                if (
1274
-                    $this->checkout->process_form_submission
1275
-                    && $this->checkout->current_step->reg_form->was_submitted()
1276
-                ) {
1277
-                    // clear out any old data in case this step is being run again
1278
-                    $this->checkout->current_step->set_valid_data(array());
1279
-                    // capture submitted form data
1280
-                    $this->checkout->current_step->reg_form->receive_form_submission(
1281
-                        apply_filters(
1282
-                            'FHEE__Single_Page_Checkout___check_form_submission__request_params',
1283
-                            EE_Registry::instance()->REQ->params(),
1284
-                            $this->checkout
1285
-                        )
1286
-                    );
1287
-                    // validate submitted form data
1288
-                    if ( ! $this->checkout->continue_reg || ! $this->checkout->current_step->reg_form->is_valid()) {
1289
-                        // thou shall not pass !!!
1290
-                        $this->checkout->continue_reg = false;
1291
-                        // any form validation errors?
1292
-                        if ($this->checkout->current_step->reg_form->submission_error_message() !== '') {
1293
-                            EE_Error::add_error(
1294
-                                $this->checkout->current_step->reg_form->submission_error_message(),
1295
-                                __FILE__, __FUNCTION__, __LINE__
1296
-                            );
1297
-                        }
1298
-                        // well not really... what will happen is
1299
-                        // we'll just get redirected back to redo the current step
1300
-                        $this->go_to_next_step();
1301
-                        return false;
1302
-                    }
1303
-                }
1304
-            } catch (EE_Error $e) {
1305
-                $e->get_error();
1306
-            }
1307
-        }
1308
-        return true;
1309
-    }
1310
-
1311
-
1312
-
1313
-    /**
1314
-     * _process_action
1315
-     *
1316
-     * @access private
1317
-     * @return void
1318
-     * @throws EE_Error
1319
-     */
1320
-    private function _process_form_action()
1321
-    {
1322
-        // what cha wanna do?
1323
-        switch ($this->checkout->action) {
1324
-            // AJAX next step reg form
1325
-            case 'display_spco_reg_step' :
1326
-                $this->checkout->redirect = false;
1327
-                if (EE_Registry::instance()->REQ->ajax) {
1328
-                    $this->checkout->json_response->set_reg_step_html(
1329
-                        $this->checkout->current_step->display_reg_form()
1330
-                    );
1331
-                }
1332
-                break;
1333
-            default :
1334
-                // meh... do one of those other steps first
1335
-                if (
1336
-                    ! empty($this->checkout->action)
1337
-                    && is_callable(array($this->checkout->current_step, $this->checkout->action))
1338
-                ) {
1339
-                    // dynamically creates hook point like:
1340
-                    //   AHEE__Single_Page_Checkout__before_attendee_information__process_reg_step
1341
-                    do_action(
1342
-                        "AHEE__Single_Page_Checkout__before_{$this->checkout->current_step->slug()}__{$this->checkout->action}",
1343
-                        $this->checkout->current_step
1344
-                    );
1345
-                    // call action on current step
1346
-                    if (call_user_func(array($this->checkout->current_step, $this->checkout->action))) {
1347
-                        // good registrant, you get to proceed
1348
-                        if (
1349
-                            $this->checkout->current_step->success_message() !== ''
1350
-                            && apply_filters(
1351
-                                'FHEE__Single_Page_Checkout___process_form_action__display_success',
1352
-                                false
1353
-                            )
1354
-                        ) {
1355
-                            EE_Error::add_success(
1356
-                                $this->checkout->current_step->success_message()
1357
-                                . '<br />' . $this->checkout->next_step->_instructions()
1358
-                            );
1359
-                        }
1360
-                        // pack it up, pack it in...
1361
-                        $this->_setup_redirect();
1362
-                    }
1363
-                    // dynamically creates hook point like:
1364
-                    //  AHEE__Single_Page_Checkout__after_payment_options__process_reg_step
1365
-                    do_action(
1366
-                        "AHEE__Single_Page_Checkout__after_{$this->checkout->current_step->slug()}__{$this->checkout->action}",
1367
-                        $this->checkout->current_step
1368
-                    );
1369
-                } else {
1370
-                    EE_Error::add_error(
1371
-                        sprintf(
1372
-                            __(
1373
-                                'The requested form action "%s" does not exist for the current "%s" registration step.',
1374
-                                'event_espresso'
1375
-                            ),
1376
-                            $this->checkout->action,
1377
-                            $this->checkout->current_step->name()
1378
-                        ),
1379
-                        __FILE__,
1380
-                        __FUNCTION__,
1381
-                        __LINE__
1382
-                    );
1383
-                }
1384
-            // end default
1385
-        }
1386
-        // store our progress so far
1387
-        $this->checkout->stash_transaction_and_checkout();
1388
-        // advance to the next step! If you pass GO, collect $200
1389
-        $this->go_to_next_step();
1390
-    }
1391
-
1392
-
1393
-
1394
-    /**
1395
-     *        add_styles_and_scripts
1396
-     *
1397
-     * @access        public
1398
-     * @return        void
1399
-     */
1400
-    public function add_styles_and_scripts()
1401
-    {
1402
-        // i18n
1403
-        $this->translate_js_strings();
1404
-        if ($this->checkout->admin_request) {
1405
-            add_action('admin_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10);
1406
-        } else {
1407
-            add_action('wp_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10);
1408
-        }
1409
-    }
1410
-
1411
-
1412
-
1413
-    /**
1414
-     *        translate_js_strings
1415
-     *
1416
-     * @access        public
1417
-     * @return        void
1418
-     */
1419
-    public function translate_js_strings()
1420
-    {
1421
-        EE_Registry::$i18n_js_strings['revisit'] = $this->checkout->revisit;
1422
-        EE_Registry::$i18n_js_strings['e_reg_url_link'] = $this->checkout->reg_url_link;
1423
-        EE_Registry::$i18n_js_strings['server_error'] = __(
1424
-            'An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again or contact support.',
1425
-            'event_espresso'
1426
-        );
1427
-        EE_Registry::$i18n_js_strings['invalid_json_response'] = __(
1428
-            'An invalid response was returned from the server while attempting to process your request. Please refresh the page and try again or contact support.',
1429
-            'event_espresso'
1430
-        );
1431
-        EE_Registry::$i18n_js_strings['validation_error'] = __(
1432
-            'There appears to be a problem with the form validation configuration! Please check the admin settings or contact support.',
1433
-            'event_espresso'
1434
-        );
1435
-        EE_Registry::$i18n_js_strings['invalid_payment_method'] = __(
1436
-            'There appears to be a problem with the payment method configuration! Please refresh the page and try again or contact support.',
1437
-            'event_espresso'
1438
-        );
1439
-        EE_Registry::$i18n_js_strings['reg_step_error'] = __(
1440
-            'This registration step could not be completed. Please refresh the page and try again.',
1441
-            'event_espresso'
1442
-        );
1443
-        EE_Registry::$i18n_js_strings['invalid_coupon'] = __(
1444
-            'We\'re sorry but that coupon code does not appear to be valid. If this is incorrect, please contact the site administrator.',
1445
-            'event_espresso'
1446
-        );
1447
-        EE_Registry::$i18n_js_strings['process_registration'] = sprintf(
1448
-            __(
1449
-                'Please wait while we process your registration.%sDo not refresh the page or navigate away while this is happening.%sThank you for your patience.',
1450
-                'event_espresso'
1451
-            ),
1452
-            '<br/>',
1453
-            '<br/>'
1454
-        );
1455
-        EE_Registry::$i18n_js_strings['language'] = get_bloginfo('language');
1456
-        EE_Registry::$i18n_js_strings['EESID'] = EE_Registry::instance()->SSN->id();
1457
-        EE_Registry::$i18n_js_strings['currency'] = EE_Registry::instance()->CFG->currency;
1458
-        EE_Registry::$i18n_js_strings['datepicker_yearRange'] = '-150:+20';
1459
-        EE_Registry::$i18n_js_strings['timer_years'] = __('years', 'event_espresso');
1460
-        EE_Registry::$i18n_js_strings['timer_months'] = __('months', 'event_espresso');
1461
-        EE_Registry::$i18n_js_strings['timer_weeks'] = __('weeks', 'event_espresso');
1462
-        EE_Registry::$i18n_js_strings['timer_days'] = __('days', 'event_espresso');
1463
-        EE_Registry::$i18n_js_strings['timer_hours'] = __('hours', 'event_espresso');
1464
-        EE_Registry::$i18n_js_strings['timer_minutes'] = __('minutes', 'event_espresso');
1465
-        EE_Registry::$i18n_js_strings['timer_seconds'] = __('seconds', 'event_espresso');
1466
-        EE_Registry::$i18n_js_strings['timer_year'] = __('year', 'event_espresso');
1467
-        EE_Registry::$i18n_js_strings['timer_month'] = __('month', 'event_espresso');
1468
-        EE_Registry::$i18n_js_strings['timer_week'] = __('week', 'event_espresso');
1469
-        EE_Registry::$i18n_js_strings['timer_day'] = __('day', 'event_espresso');
1470
-        EE_Registry::$i18n_js_strings['timer_hour'] = __('hour', 'event_espresso');
1471
-        EE_Registry::$i18n_js_strings['timer_minute'] = __('minute', 'event_espresso');
1472
-        EE_Registry::$i18n_js_strings['timer_second'] = __('second', 'event_espresso');
1473
-        EE_Registry::$i18n_js_strings['registration_expiration_notice'] = EED_Single_Page_Checkout::getRegistrationExpirationNotice();
1474
-        EE_Registry::$i18n_js_strings['ajax_submit'] = apply_filters(
1475
-            'FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit',
1476
-            true
1477
-        );
1478
-        EE_Registry::$i18n_js_strings['session_extension'] = absint(
1479
-            apply_filters('FHEE__EE_Session__extend_expiration__seconds_added', 10 * MINUTE_IN_SECONDS)
1480
-        );
1481
-        EE_Registry::$i18n_js_strings['session_expiration'] = gmdate(
1482
-            'M d, Y H:i:s',
1483
-            EE_Registry::instance()->SSN->expiration() + (get_option('gmt_offset') * HOUR_IN_SECONDS)
1484
-        );
1485
-    }
1486
-
1487
-
1488
-
1489
-    /**
1490
-     *    enqueue_styles_and_scripts
1491
-     *
1492
-     * @access        public
1493
-     * @return        void
1494
-     * @throws EE_Error
1495
-     */
1496
-    public function enqueue_styles_and_scripts()
1497
-    {
1498
-        // load css
1499
-        wp_register_style(
1500
-            'single_page_checkout',
1501
-            SPCO_CSS_URL . 'single_page_checkout.css',
1502
-            array('espresso_default'),
1503
-            EVENT_ESPRESSO_VERSION
1504
-        );
1505
-        wp_enqueue_style('single_page_checkout');
1506
-        // load JS
1507
-        wp_register_script(
1508
-            'jquery_plugin',
1509
-            EE_THIRD_PARTY_URL . 'jquery	.plugin.min.js',
1510
-            array('jquery'),
1511
-            '1.0.1',
1512
-            true
1513
-        );
1514
-        wp_register_script(
1515
-            'jquery_countdown',
1516
-            EE_THIRD_PARTY_URL . 'jquery	.countdown.min.js',
1517
-            array('jquery_plugin'),
1518
-            '2.0.2',
1519
-            true
1520
-        );
1521
-        wp_register_script(
1522
-            'single_page_checkout',
1523
-            SPCO_JS_URL . 'single_page_checkout.js',
1524
-            array('espresso_core', 'underscore', 'ee_form_section_validation', 'jquery_countdown'),
1525
-            EVENT_ESPRESSO_VERSION,
1526
-            true
1527
-        );
1528
-        if ($this->checkout->registration_form instanceof EE_Form_Section_Proper) {
1529
-            $this->checkout->registration_form->enqueue_js();
1530
-        }
1531
-        if ($this->checkout->current_step->reg_form instanceof EE_Form_Section_Proper) {
1532
-            $this->checkout->current_step->reg_form->enqueue_js();
1533
-        }
1534
-        wp_enqueue_script('single_page_checkout');
1535
-        /**
1536
-         * global action hook for enqueueing styles and scripts with
1537
-         * spco calls.
1538
-         */
1539
-        do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts', $this);
1540
-        /**
1541
-         * dynamic action hook for enqueueing styles and scripts with spco calls.
1542
-         * The hook will end up being something like:
1543
-         *      AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__attendee_information
1544
-         */
1545
-        do_action(
1546
-            'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__' . $this->checkout->current_step->slug(),
1547
-            $this
1548
-        );
1549
-    }
1550
-
1551
-
1552
-
1553
-    /**
1554
-     *    display the Registration Single Page Checkout Form
1555
-     *
1556
-     * @access    private
1557
-     * @return    void
1558
-     * @throws EE_Error
1559
-     */
1560
-    private function _display_spco_reg_form()
1561
-    {
1562
-        // if registering via the admin, just display the reg form for the current step
1563
-        if ($this->checkout->admin_request) {
1564
-            EE_Registry::instance()->REQ->add_output($this->checkout->current_step->display_reg_form());
1565
-        } else {
1566
-            // add powered by EE msg
1567
-            add_action('AHEE__SPCO__reg_form_footer', array('EED_Single_Page_Checkout', 'display_registration_footer'));
1568
-            $empty_cart = count(
1569
-                $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params)
1570
-            ) < 1;
1571
-            EE_Registry::$i18n_js_strings['empty_cart'] = $empty_cart;
1572
-            $cookies_not_set_msg = '';
1573
-            if ($empty_cart) {
1574
-                $cookies_not_set_msg = apply_filters(
1575
-                    'FHEE__Single_Page_Checkout__display_spco_reg_form__cookies_not_set_msg',
1576
-                    sprintf(
1577
-                        __(
1578
-                            '%1$s%3$sIt appears your browser is not currently set to accept Cookies%4$s%5$sIn order to register for events, you need to enable cookies.%7$sIf you require assistance, then click the following link to learn how to %8$senable cookies%9$s%6$s%2$s',
1579
-                            'event_espresso'
1580
-                        ),
1581
-                        '<div class="ee-attention hidden" id="ee-cookies-not-set-msg">',
1582
-                        '</div>',
1583
-                        '<h6 class="important-notice">',
1584
-                        '</h6>',
1585
-                        '<p>',
1586
-                        '</p>',
1587
-                        '<br />',
1588
-                        '<a href="http://www.whatarecookies.com/enable.asp" target="_blank">',
1589
-                        '</a>'
1590
-                    )
1591
-                );
1592
-            }
1593
-            $this->checkout->registration_form = new EE_Form_Section_Proper(
1594
-                array(
1595
-                    'name'            => 'single-page-checkout',
1596
-                    'html_id'         => 'ee-single-page-checkout-dv',
1597
-                    'layout_strategy' =>
1598
-                        new EE_Template_Layout(
1599
-                            array(
1600
-                                'layout_template_file' => SPCO_TEMPLATES_PATH . 'registration_page_wrapper.template.php',
1601
-                                'template_args'        => array(
1602
-                                    'empty_cart'              => $empty_cart,
1603
-                                    'revisit'                 => $this->checkout->revisit,
1604
-                                    'reg_steps'               => $this->checkout->reg_steps,
1605
-                                    'next_step'               => $this->checkout->next_step instanceof EE_SPCO_Reg_Step
1606
-                                        ? $this->checkout->next_step->slug()
1607
-                                        : '',
1608
-                                    'empty_msg'               => apply_filters(
1609
-                                        'FHEE__Single_Page_Checkout__display_spco_reg_form__empty_msg',
1610
-                                        sprintf(
1611
-                                            __(
1612
-                                                'You need to %1$sReturn to Events list%2$sselect at least one event%3$s before you can proceed with the registration process.',
1613
-                                                'event_espresso'
1614
-                                            ),
1615
-                                            '<a href="'
1616
-                                            . get_post_type_archive_link('espresso_events')
1617
-                                            . '" title="',
1618
-                                            '">',
1619
-                                            '</a>'
1620
-                                        )
1621
-                                    ),
1622
-                                    'cookies_not_set_msg'     => $cookies_not_set_msg,
1623
-                                    'registration_time_limit' => $this->checkout->get_registration_time_limit(),
1624
-                                    'session_expiration'      => gmdate(
1625
-                                        'M d, Y H:i:s',
1626
-                                        EE_Registry::instance()->SSN->expiration()
1627
-                                        + (get_option('gmt_offset') * HOUR_IN_SECONDS)
1628
-                                    ),
1629
-                                ),
1630
-                            )
1631
-                        ),
1632
-                )
1633
-            );
1634
-            // load template and add to output sent that gets filtered into the_content()
1635
-            EE_Registry::instance()->REQ->add_output($this->checkout->registration_form->get_html());
1636
-        }
1637
-    }
1638
-
1639
-
1640
-
1641
-    /**
1642
-     *    add_extra_finalize_registration_inputs
1643
-     *
1644
-     * @access    public
1645
-     * @param $next_step
1646
-     * @internal  param string $label
1647
-     * @return void
1648
-     */
1649
-    public function add_extra_finalize_registration_inputs($next_step)
1650
-    {
1651
-        if ($next_step === 'finalize_registration') {
1652
-            echo '<div id="spco-extra-finalize_registration-inputs-dv"></div>';
1653
-        }
1654
-    }
1655
-
1656
-
1657
-
1658
-    /**
1659
-     *    display_registration_footer
1660
-     *
1661
-     * @access    public
1662
-     * @return    string
1663
-     */
1664
-    public static function display_registration_footer()
1665
-    {
1666
-        if (
1667
-        apply_filters(
1668
-            'FHEE__EE_Front__Controller__show_reg_footer',
1669
-            EE_Registry::instance()->CFG->admin->show_reg_footer
1670
-        )
1671
-        ) {
1672
-            add_filter(
1673
-                'FHEE__EEH_Template__powered_by_event_espresso__url',
1674
-                function ($url) {
1675
-                    return apply_filters('FHEE__EE_Front_Controller__registration_footer__url', $url);
1676
-                }
1677
-            );
1678
-            echo apply_filters(
1679
-                'FHEE__EE_Front_Controller__display_registration_footer',
1680
-                \EEH_Template::powered_by_event_espresso(
1681
-                    '',
1682
-                    'espresso-registration-footer-dv',
1683
-                    array('utm_content' => 'registration_checkout')
1684
-                )
1685
-            );
1686
-        }
1687
-        return '';
1688
-    }
1689
-
1690
-
1691
-
1692
-    /**
1693
-     *    unlock_transaction
1694
-     *
1695
-     * @access    public
1696
-     * @return    void
1697
-     * @throws EE_Error
1698
-     */
1699
-    public function unlock_transaction()
1700
-    {
1701
-        if ($this->checkout->transaction instanceof EE_Transaction) {
1702
-            $this->checkout->transaction->unlock();
1703
-        }
1704
-    }
1705
-
1706
-
1707
-
1708
-    /**
1709
-     *        _setup_redirect
1710
-     *
1711
-     * @access    private
1712
-     * @return void
1713
-     */
1714
-    private function _setup_redirect()
1715
-    {
1716
-        if ($this->checkout->continue_reg && $this->checkout->next_step instanceof EE_SPCO_Reg_Step) {
1717
-            $this->checkout->redirect = true;
1718
-            if (empty($this->checkout->redirect_url)) {
1719
-                $this->checkout->redirect_url = $this->checkout->next_step->reg_step_url();
1720
-            }
1721
-            $this->checkout->redirect_url = apply_filters(
1722
-                'FHEE__EED_Single_Page_Checkout___setup_redirect__checkout_redirect_url',
1723
-                $this->checkout->redirect_url,
1724
-                $this->checkout
1725
-            );
1726
-        }
1727
-    }
1728
-
1729
-
1730
-
1731
-    /**
1732
-     *   handle ajax message responses and redirects
1733
-     *
1734
-     * @access public
1735
-     * @return void
1736
-     * @throws EE_Error
1737
-     */
1738
-    public function go_to_next_step()
1739
-    {
1740
-        if (EE_Registry::instance()->REQ->ajax) {
1741
-            // capture contents of output buffer we started earlier in the request, and insert into JSON response
1742
-            $this->checkout->json_response->set_unexpected_errors(ob_get_clean());
1743
-        }
1744
-        $this->unlock_transaction();
1745
-        // just return for these conditions
1746
-        if (
1747
-            $this->checkout->admin_request
1748
-            || $this->checkout->action === 'redirect_form'
1749
-            || $this->checkout->action === 'update_checkout'
1750
-        ) {
1751
-            return;
1752
-        }
1753
-        // AJAX response
1754
-        $this->_handle_json_response();
1755
-        // redirect to next step or the Thank You page
1756
-        $this->_handle_html_redirects();
1757
-        // hmmm... must be something wrong, so let's just display the form again !
1758
-        $this->_display_spco_reg_form();
1759
-    }
1760
-
1761
-
1762
-
1763
-    /**
1764
-     *   _handle_json_response
1765
-     *
1766
-     * @access protected
1767
-     * @return void
1768
-     */
1769
-    protected function _handle_json_response()
1770
-    {
1771
-        // if this is an ajax request
1772
-        if (EE_Registry::instance()->REQ->ajax) {
1773
-            // DEBUG LOG
1774
-            //$this->checkout->log(
1775
-            //	__CLASS__, __FUNCTION__, __LINE__,
1776
-            //	array(
1777
-            //		'json_response_redirect_url' => $this->checkout->json_response->redirect_url(),
1778
-            //		'redirect'                   => $this->checkout->redirect,
1779
-            //		'continue_reg'               => $this->checkout->continue_reg,
1780
-            //	)
1781
-            //);
1782
-            $this->checkout->json_response->set_registration_time_limit(
1783
-                $this->checkout->get_registration_time_limit()
1784
-            );
1785
-            $this->checkout->json_response->set_payment_amount($this->checkout->amount_owing);
1786
-            // just send the ajax (
1787
-            $json_response = apply_filters(
1788
-                'FHEE__EE_Single_Page_Checkout__JSON_response',
1789
-                $this->checkout->json_response
1790
-            );
1791
-            echo $json_response;
1792
-            exit();
1793
-        }
1794
-    }
1795
-
1796
-
1797
-
1798
-    /**
1799
-     *   _handle_redirects
1800
-     *
1801
-     * @access protected
1802
-     * @return void
1803
-     */
1804
-    protected function _handle_html_redirects()
1805
-    {
1806
-        // going somewhere ?
1807
-        if ($this->checkout->redirect && ! empty($this->checkout->redirect_url)) {
1808
-            // store notices in a transient
1809
-            EE_Error::get_notices(false, true, true);
1810
-            // DEBUG LOG
1811
-            //$this->checkout->log(
1812
-            //	__CLASS__, __FUNCTION__, __LINE__,
1813
-            //	array(
1814
-            //		'headers_sent' => headers_sent(),
1815
-            //		'redirect_url'     => $this->checkout->redirect_url,
1816
-            //		'headers_list'    => headers_list(),
1817
-            //	)
1818
-            //);
1819
-            wp_safe_redirect($this->checkout->redirect_url);
1820
-            exit();
1821
-        }
1822
-    }
1823
-
1824
-
1825
-
1826
-    /**
1827
-     *   set_checkout_anchor
1828
-     *
1829
-     * @access public
1830
-     * @return void
1831
-     */
1832
-    public function set_checkout_anchor()
1833
-    {
1834
-        echo '<a id="checkout" style="float: left; margin-left: -999em;"></a>';
1835
-    }
1836
-
1837
-    /**
1838
-     *    getRegistrationExpirationNotice
1839
-     *
1840
-     * @since 4.9.59.p
1841
-     * @access    public
1842
-     * @return    string
1843
-     */
1844
-    public static function getRegistrationExpirationNotice()
1845
-    {
1846
-        return sprintf(
1847
-            __('%1$sWe\'re sorry, but your registration time has expired.%2$s%3$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please accept our apologies for any inconvenience this may have caused.%8$s',
1848
-                'event_espresso'),
1849
-            '<h4 class="important-notice">',
1850
-            '</h4>',
1851
-            '<br />',
1852
-            '<p>',
1853
-            '<a href="' . get_post_type_archive_link('espresso_events') . '" title="',
1854
-            '">',
1855
-            '</a>',
1856
-            '</p>'
1857
-        );
1858
-    }
24
+	/**
25
+	 * $_initialized - has the SPCO controller already been initialized ?
26
+	 *
27
+	 * @access private
28
+	 * @var bool $_initialized
29
+	 */
30
+	private static $_initialized = false;
31
+
32
+
33
+	/**
34
+	 * $_checkout_verified - is the EE_Checkout verified as correct for this request ?
35
+	 *
36
+	 * @access private
37
+	 * @var bool $_valid_checkout
38
+	 */
39
+	private static $_checkout_verified = true;
40
+
41
+	/**
42
+	 *    $_reg_steps_array - holds initial array of reg steps
43
+	 *
44
+	 * @access private
45
+	 * @var array $_reg_steps_array
46
+	 */
47
+	private static $_reg_steps_array = array();
48
+
49
+	/**
50
+	 *    $checkout - EE_Checkout object for handling the properties of the current checkout process
51
+	 *
52
+	 * @access public
53
+	 * @var EE_Checkout $checkout
54
+	 */
55
+	public $checkout;
56
+
57
+
58
+
59
+	/**
60
+	 * @return EED_Module|EED_Single_Page_Checkout
61
+	 */
62
+	public static function instance()
63
+	{
64
+		add_filter('EED_Single_Page_Checkout__SPCO_active', '__return_true');
65
+		return parent::get_instance(__CLASS__);
66
+	}
67
+
68
+
69
+
70
+	/**
71
+	 * @return EE_CART
72
+	 */
73
+	public function cart()
74
+	{
75
+		return $this->checkout->cart;
76
+	}
77
+
78
+
79
+
80
+	/**
81
+	 * @return EE_Transaction
82
+	 */
83
+	public function transaction()
84
+	{
85
+		return $this->checkout->transaction;
86
+	}
87
+
88
+
89
+
90
+	/**
91
+	 *    set_hooks - for hooking into EE Core, other modules, etc
92
+	 *
93
+	 * @access    public
94
+	 * @return    void
95
+	 * @throws EE_Error
96
+	 */
97
+	public static function set_hooks()
98
+	{
99
+		EED_Single_Page_Checkout::set_definitions();
100
+	}
101
+
102
+
103
+
104
+	/**
105
+	 *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
106
+	 *
107
+	 * @access    public
108
+	 * @return    void
109
+	 * @throws EE_Error
110
+	 */
111
+	public static function set_hooks_admin()
112
+	{
113
+		EED_Single_Page_Checkout::set_definitions();
114
+		if ( ! (defined('DOING_AJAX') && DOING_AJAX)) {
115
+			return;
116
+		}
117
+		// going to start an output buffer in case anything gets accidentally output
118
+		// that might disrupt our JSON response
119
+		ob_start();
120
+		EED_Single_Page_Checkout::load_request_handler();
121
+		EED_Single_Page_Checkout::load_reg_steps();
122
+		// set ajax hooks
123
+		add_action('wp_ajax_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step'));
124
+		add_action('wp_ajax_nopriv_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step'));
125
+		add_action('wp_ajax_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step'));
126
+		add_action('wp_ajax_nopriv_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step'));
127
+		add_action('wp_ajax_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step'));
128
+		add_action('wp_ajax_nopriv_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step'));
129
+	}
130
+
131
+
132
+
133
+	/**
134
+	 *    process ajax request
135
+	 *
136
+	 * @param string $ajax_action
137
+	 * @throws EE_Error
138
+	 */
139
+	public static function process_ajax_request($ajax_action)
140
+	{
141
+		EE_Registry::instance()->REQ->set('action', $ajax_action);
142
+		EED_Single_Page_Checkout::instance()->_initialize();
143
+	}
144
+
145
+
146
+
147
+	/**
148
+	 *    ajax display registration step
149
+	 *
150
+	 * @throws EE_Error
151
+	 */
152
+	public static function display_reg_step()
153
+	{
154
+		EED_Single_Page_Checkout::process_ajax_request('display_spco_reg_step');
155
+	}
156
+
157
+
158
+
159
+	/**
160
+	 *    ajax process registration step
161
+	 *
162
+	 * @throws EE_Error
163
+	 */
164
+	public static function process_reg_step()
165
+	{
166
+		EED_Single_Page_Checkout::process_ajax_request('process_reg_step');
167
+	}
168
+
169
+
170
+
171
+	/**
172
+	 *    ajax process registration step
173
+	 *
174
+	 * @throws EE_Error
175
+	 */
176
+	public static function update_reg_step()
177
+	{
178
+		EED_Single_Page_Checkout::process_ajax_request('update_reg_step');
179
+	}
180
+
181
+
182
+
183
+	/**
184
+	 *   update_checkout
185
+	 *
186
+	 * @access public
187
+	 * @return void
188
+	 * @throws EE_Error
189
+	 */
190
+	public static function update_checkout()
191
+	{
192
+		EED_Single_Page_Checkout::process_ajax_request('update_checkout');
193
+	}
194
+
195
+
196
+
197
+	/**
198
+	 *    load_request_handler
199
+	 *
200
+	 * @access    public
201
+	 * @return    void
202
+	 */
203
+	public static function load_request_handler()
204
+	{
205
+		// load core Request_Handler class
206
+		if (EE_Registry::instance()->REQ !== null) {
207
+			EE_Registry::instance()->load_core('Request_Handler');
208
+		}
209
+	}
210
+
211
+
212
+
213
+	/**
214
+	 *    set_definitions
215
+	 *
216
+	 * @access    public
217
+	 * @return    void
218
+	 * @throws EE_Error
219
+	 */
220
+	public static function set_definitions()
221
+	{
222
+		if(defined('SPCO_BASE_PATH')) {
223
+			return;
224
+		}
225
+		define(
226
+			'SPCO_BASE_PATH',
227
+			rtrim(str_replace(array('\\', '/'), DS, plugin_dir_path(__FILE__)), DS) . DS
228
+		);
229
+		define('SPCO_CSS_URL', plugin_dir_url(__FILE__) . 'css' . DS);
230
+		define('SPCO_IMG_URL', plugin_dir_url(__FILE__) . 'img' . DS);
231
+		define('SPCO_JS_URL', plugin_dir_url(__FILE__) . 'js' . DS);
232
+		define('SPCO_INC_PATH', SPCO_BASE_PATH . 'inc' . DS);
233
+		define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH . 'reg_steps' . DS);
234
+		define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH . 'templates' . DS);
235
+		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(SPCO_BASE_PATH, true);
236
+		EE_Registry::$i18n_js_strings['registration_expiration_notice'] = EED_Single_Page_Checkout::getRegistrationExpirationNotice();
237
+	}
238
+
239
+
240
+
241
+	/**
242
+	 * load_reg_steps
243
+	 * loads and instantiates each reg step based on the EE_Registry::instance()->CFG->registration->reg_steps array
244
+	 *
245
+	 * @access    private
246
+	 * @throws EE_Error
247
+	 */
248
+	public static function load_reg_steps()
249
+	{
250
+		static $reg_steps_loaded = false;
251
+		if ($reg_steps_loaded) {
252
+			return;
253
+		}
254
+		// filter list of reg_steps
255
+		$reg_steps_to_load = (array)apply_filters(
256
+			'AHEE__SPCO__load_reg_steps__reg_steps_to_load',
257
+			EED_Single_Page_Checkout::get_reg_steps()
258
+		);
259
+		// sort by key (order)
260
+		ksort($reg_steps_to_load);
261
+		// loop through folders
262
+		foreach ($reg_steps_to_load as $order => $reg_step) {
263
+			// we need a
264
+			if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) {
265
+				// copy over to the reg_steps_array
266
+				EED_Single_Page_Checkout::$_reg_steps_array[$order] = $reg_step;
267
+				// register custom key route for each reg step
268
+				// ie: step=>"slug" - this is the entire reason we load the reg steps array now
269
+				EE_Config::register_route(
270
+					$reg_step['slug'],
271
+					'EED_Single_Page_Checkout',
272
+					'run',
273
+					'step'
274
+				);
275
+				// add AJAX or other hooks
276
+				if (isset($reg_step['has_hooks']) && $reg_step['has_hooks']) {
277
+					// setup autoloaders if necessary
278
+					if ( ! class_exists($reg_step['class_name'])) {
279
+						EEH_Autoloader::register_autoloaders_for_each_file_in_folder(
280
+							$reg_step['file_path'],
281
+							true
282
+						);
283
+					}
284
+					if (is_callable($reg_step['class_name'], 'set_hooks')) {
285
+						call_user_func(array($reg_step['class_name'], 'set_hooks'));
286
+					}
287
+				}
288
+			}
289
+		}
290
+		$reg_steps_loaded = true;
291
+	}
292
+
293
+
294
+
295
+	/**
296
+	 *    get_reg_steps
297
+	 *
298
+	 * @access    public
299
+	 * @return    array
300
+	 */
301
+	public static function get_reg_steps()
302
+	{
303
+		$reg_steps = EE_Registry::instance()->CFG->registration->reg_steps;
304
+		if (empty($reg_steps)) {
305
+			$reg_steps = array(
306
+				10  => array(
307
+					'file_path'  => SPCO_REG_STEPS_PATH . 'attendee_information',
308
+					'class_name' => 'EE_SPCO_Reg_Step_Attendee_Information',
309
+					'slug'       => 'attendee_information',
310
+					'has_hooks'  => false,
311
+				),
312
+				30  => array(
313
+					'file_path'  => SPCO_REG_STEPS_PATH . 'payment_options',
314
+					'class_name' => 'EE_SPCO_Reg_Step_Payment_Options',
315
+					'slug'       => 'payment_options',
316
+					'has_hooks'  => true,
317
+				),
318
+				999 => array(
319
+					'file_path'  => SPCO_REG_STEPS_PATH . 'finalize_registration',
320
+					'class_name' => 'EE_SPCO_Reg_Step_Finalize_Registration',
321
+					'slug'       => 'finalize_registration',
322
+					'has_hooks'  => false,
323
+				),
324
+			);
325
+		}
326
+		return $reg_steps;
327
+	}
328
+
329
+
330
+
331
+	/**
332
+	 *    registration_checkout_for_admin
333
+	 *
334
+	 * @access    public
335
+	 * @return    string
336
+	 * @throws EE_Error
337
+	 */
338
+	public static function registration_checkout_for_admin()
339
+	{
340
+		EED_Single_Page_Checkout::load_request_handler();
341
+		EE_Registry::instance()->REQ->set('step', 'attendee_information');
342
+		EE_Registry::instance()->REQ->set('action', 'display_spco_reg_step');
343
+		EE_Registry::instance()->REQ->set('process_form_submission', false);
344
+		EED_Single_Page_Checkout::instance()->_initialize();
345
+		EED_Single_Page_Checkout::instance()->_display_spco_reg_form();
346
+		return EE_Registry::instance()->REQ->get_output();
347
+	}
348
+
349
+
350
+
351
+	/**
352
+	 * process_registration_from_admin
353
+	 *
354
+	 * @access public
355
+	 * @return \EE_Transaction
356
+	 * @throws EE_Error
357
+	 */
358
+	public static function process_registration_from_admin()
359
+	{
360
+		EED_Single_Page_Checkout::load_request_handler();
361
+		EE_Registry::instance()->REQ->set('step', 'attendee_information');
362
+		EE_Registry::instance()->REQ->set('action', 'process_reg_step');
363
+		EE_Registry::instance()->REQ->set('process_form_submission', true);
364
+		EED_Single_Page_Checkout::instance()->_initialize();
365
+		if (EED_Single_Page_Checkout::instance()->checkout->current_step->completed()) {
366
+			$final_reg_step = end(EED_Single_Page_Checkout::instance()->checkout->reg_steps);
367
+			if ($final_reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration) {
368
+				EED_Single_Page_Checkout::instance()->checkout->set_reg_step_initiated($final_reg_step);
369
+				if ($final_reg_step->process_reg_step()) {
370
+					$final_reg_step->set_completed();
371
+					EED_Single_Page_Checkout::instance()->checkout->update_txn_reg_steps_array();
372
+					return EED_Single_Page_Checkout::instance()->checkout->transaction;
373
+				}
374
+			}
375
+		}
376
+		return null;
377
+	}
378
+
379
+
380
+
381
+	/**
382
+	 *    run
383
+	 *
384
+	 * @access    public
385
+	 * @param WP_Query $WP_Query
386
+	 * @return    void
387
+	 * @throws EE_Error
388
+	 */
389
+	public function run($WP_Query)
390
+	{
391
+		if (
392
+			$WP_Query instanceof WP_Query
393
+			&& $WP_Query->is_main_query()
394
+			&& apply_filters('FHEE__EED_Single_Page_Checkout__run', true)
395
+			&& $this->_is_reg_checkout()
396
+		) {
397
+			$this->_initialize();
398
+		}
399
+	}
400
+
401
+
402
+
403
+	/**
404
+	 * determines whether current url matches reg page url
405
+	 *
406
+	 * @return bool
407
+	 */
408
+	protected function _is_reg_checkout()
409
+	{
410
+		// get current permalink for reg page without any extra query args
411
+		$reg_page_url = \get_permalink(EE_Config::instance()->core->reg_page_id);
412
+		// get request URI for current request, but without the scheme or host
413
+		$current_request_uri = \EEH_URL::filter_input_server_url('REQUEST_URI');
414
+		$current_request_uri = html_entity_decode($current_request_uri);
415
+		// get array of query args from the current request URI
416
+		$query_args = \EEH_URL::get_query_string($current_request_uri);
417
+		// grab page id if it is set
418
+		$page_id = isset($query_args['page_id']) ? absint($query_args['page_id']) : 0;
419
+		// and remove the page id from the query args (we will re-add it later)
420
+		unset($query_args['page_id']);
421
+		// now strip all query args from current request URI
422
+		$current_request_uri = remove_query_arg(array_keys($query_args), $current_request_uri);
423
+		// and re-add the page id if it was set
424
+		if ($page_id) {
425
+			$current_request_uri = add_query_arg('page_id', $page_id, $current_request_uri);
426
+		}
427
+		// remove slashes and ?
428
+		$current_request_uri = trim($current_request_uri, '?/');
429
+		// is current request URI part of the known full reg page URL ?
430
+		return ! empty($current_request_uri) && strpos($reg_page_url, $current_request_uri) !== false;
431
+	}
432
+
433
+
434
+
435
+	/**
436
+	 * @param WP_Query $wp_query
437
+	 * @return    void
438
+	 * @throws EE_Error
439
+	 */
440
+	public static function init($wp_query)
441
+	{
442
+		EED_Single_Page_Checkout::instance()->run($wp_query);
443
+	}
444
+
445
+
446
+
447
+	/**
448
+	 *    _initialize - initial module setup
449
+	 *
450
+	 * @access    private
451
+	 * @throws EE_Error
452
+	 * @return    void
453
+	 */
454
+	private function _initialize()
455
+	{
456
+		// ensure SPCO doesn't run twice
457
+		if (EED_Single_Page_Checkout::$_initialized) {
458
+			return;
459
+		}
460
+		try {
461
+			EED_Single_Page_Checkout::load_reg_steps();
462
+			$this->_verify_session();
463
+			// setup the EE_Checkout object
464
+			$this->checkout = $this->_initialize_checkout();
465
+			// filter checkout
466
+			$this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout);
467
+			// get the $_GET
468
+			$this->_get_request_vars();
469
+			if ($this->_block_bots()) {
470
+				return;
471
+			}
472
+			// filter continue_reg
473
+			$this->checkout->continue_reg = apply_filters(
474
+				'FHEE__EED_Single_Page_Checkout__init___continue_reg',
475
+				true,
476
+				$this->checkout
477
+			);
478
+			// load the reg steps array
479
+			if ( ! $this->_load_and_instantiate_reg_steps()) {
480
+				EED_Single_Page_Checkout::$_initialized = true;
481
+				return;
482
+			}
483
+			// set the current step
484
+			$this->checkout->set_current_step($this->checkout->step);
485
+			// and the next step
486
+			$this->checkout->set_next_step();
487
+			// verify that everything has been setup correctly
488
+			if ( ! ($this->_verify_transaction_and_get_registrations() && $this->_final_verifications())) {
489
+				EED_Single_Page_Checkout::$_initialized = true;
490
+				return;
491
+			}
492
+			// lock the transaction
493
+			$this->checkout->transaction->lock();
494
+			// make sure all of our cached objects are added to their respective model entity mappers
495
+			$this->checkout->refresh_all_entities();
496
+			// set amount owing
497
+			$this->checkout->amount_owing = $this->checkout->transaction->remaining();
498
+			// initialize each reg step, which gives them the chance to potentially alter the process
499
+			$this->_initialize_reg_steps();
500
+			// DEBUG LOG
501
+			//$this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ );
502
+			// get reg form
503
+			if( ! $this->_check_form_submission()) {
504
+				EED_Single_Page_Checkout::$_initialized = true;
505
+				return;
506
+			}
507
+			// checkout the action!!!
508
+			$this->_process_form_action();
509
+			// add some style and make it dance
510
+			$this->add_styles_and_scripts();
511
+			// kk... SPCO has successfully run
512
+			EED_Single_Page_Checkout::$_initialized = true;
513
+			// set no cache headers and constants
514
+			EE_System::do_not_cache();
515
+			// add anchor
516
+			add_action('loop_start', array($this, 'set_checkout_anchor'), 1);
517
+			// remove transaction lock
518
+			add_action('shutdown', array($this, 'unlock_transaction'), 1);
519
+		} catch (Exception $e) {
520
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
521
+		}
522
+	}
523
+
524
+
525
+
526
+	/**
527
+	 *    _verify_session
528
+	 * checks that the session is valid and not expired
529
+	 *
530
+	 * @access    private
531
+	 * @throws EE_Error
532
+	 */
533
+	private function _verify_session()
534
+	{
535
+		if ( ! EE_Registry::instance()->SSN instanceof EE_Session) {
536
+			throw new EE_Error(__('The EE_Session class could not be loaded.', 'event_espresso'));
537
+		}
538
+		$clear_session_requested = filter_var(
539
+			EE_Registry::instance()->REQ->get('clear_session', false),
540
+			FILTER_VALIDATE_BOOLEAN
541
+		);
542
+		// is session still valid ?
543
+		if ($clear_session_requested
544
+			|| ( EE_Registry::instance()->SSN->expired()
545
+			  && EE_Registry::instance()->REQ->get('e_reg_url_link', '') === ''
546
+			)
547
+		) {
548
+			$this->checkout = new EE_Checkout();
549
+			EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
550
+			// EE_Registry::instance()->SSN->reset_cart();
551
+			// EE_Registry::instance()->SSN->reset_checkout();
552
+			// EE_Registry::instance()->SSN->reset_transaction();
553
+			if (! $clear_session_requested) {
554
+				EE_Error::add_attention(
555
+					EE_Registry::$i18n_js_strings['registration_expiration_notice'],
556
+					__FILE__, __FUNCTION__, __LINE__
557
+				);
558
+			}
559
+			// EE_Registry::instance()->SSN->reset_expired();
560
+		}
561
+	}
562
+
563
+
564
+
565
+	/**
566
+	 *    _initialize_checkout
567
+	 * loads and instantiates EE_Checkout
568
+	 *
569
+	 * @access    private
570
+	 * @throws EE_Error
571
+	 * @return EE_Checkout
572
+	 */
573
+	private function _initialize_checkout()
574
+	{
575
+		// look in session for existing checkout
576
+		/** @type EE_Checkout $checkout */
577
+		$checkout = EE_Registry::instance()->SSN->checkout();
578
+		// verify
579
+		if ( ! $checkout instanceof EE_Checkout) {
580
+			// instantiate EE_Checkout object for handling the properties of the current checkout process
581
+			$checkout = EE_Registry::instance()->load_file(
582
+				SPCO_INC_PATH,
583
+				'EE_Checkout',
584
+				'class', array(),
585
+				false
586
+			);
587
+		} else {
588
+			if ($checkout->current_step->is_final_step() && $checkout->exit_spco() === true) {
589
+				$this->unlock_transaction();
590
+				wp_safe_redirect($checkout->redirect_url);
591
+				exit();
592
+			}
593
+		}
594
+		$checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout);
595
+		// verify again
596
+		if ( ! $checkout instanceof EE_Checkout) {
597
+			throw new EE_Error(__('The EE_Checkout class could not be loaded.', 'event_espresso'));
598
+		}
599
+		// reset anything that needs a clean slate for each request
600
+		$checkout->reset_for_current_request();
601
+		return $checkout;
602
+	}
603
+
604
+
605
+
606
+	/**
607
+	 *    _get_request_vars
608
+	 *
609
+	 * @access    private
610
+	 * @return    void
611
+	 * @throws EE_Error
612
+	 */
613
+	private function _get_request_vars()
614
+	{
615
+		// load classes
616
+		EED_Single_Page_Checkout::load_request_handler();
617
+		//make sure this request is marked as belonging to EE
618
+		EE_Registry::instance()->REQ->set_espresso_page(true);
619
+		// which step is being requested ?
620
+		$this->checkout->step = EE_Registry::instance()->REQ->get('step', $this->_get_first_step());
621
+		// which step is being edited ?
622
+		$this->checkout->edit_step = EE_Registry::instance()->REQ->get('edit_step', '');
623
+		// and what we're doing on the current step
624
+		$this->checkout->action = EE_Registry::instance()->REQ->get('action', 'display_spco_reg_step');
625
+		// timestamp
626
+		$this->checkout->uts = EE_Registry::instance()->REQ->get('uts', 0);
627
+		// returning to edit ?
628
+		$this->checkout->reg_url_link = EE_Registry::instance()->REQ->get('e_reg_url_link', '');
629
+		// add reg url link to registration query params
630
+		if ($this->checkout->reg_url_link && strpos($this->checkout->reg_url_link, '1-') !== 0) {
631
+			$this->checkout->reg_cache_where_params[0]['REG_url_link'] = $this->checkout->reg_url_link;
632
+		}
633
+		// or some other kind of revisit ?
634
+		$this->checkout->revisit = filter_var(
635
+			EE_Registry::instance()->REQ->get('revisit', false),
636
+			FILTER_VALIDATE_BOOLEAN
637
+		);
638
+		// and whether or not to generate a reg form for this request
639
+		$this->checkout->generate_reg_form = filter_var(
640
+			EE_Registry::instance()->REQ->get('generate_reg_form', true),
641
+			FILTER_VALIDATE_BOOLEAN
642
+		);
643
+		// and whether or not to process a reg form submission for this request
644
+		$this->checkout->process_form_submission = filter_var(
645
+			EE_Registry::instance()->REQ->get(
646
+				'process_form_submission',
647
+				$this->checkout->action === 'process_reg_step'
648
+			),
649
+			FILTER_VALIDATE_BOOLEAN
650
+		);
651
+		$this->checkout->process_form_submission = filter_var(
652
+			$this->checkout->action !== 'display_spco_reg_step'
653
+				? $this->checkout->process_form_submission
654
+				: false,
655
+			FILTER_VALIDATE_BOOLEAN
656
+		);
657
+		// $this->_display_request_vars();
658
+	}
659
+
660
+
661
+
662
+	/**
663
+	 *  _display_request_vars
664
+	 *
665
+	 * @access    protected
666
+	 * @return    void
667
+	 */
668
+	protected function _display_request_vars()
669
+	{
670
+		if ( ! WP_DEBUG) {
671
+			return;
672
+		}
673
+		EEH_Debug_Tools::printr($_REQUEST, '$_REQUEST', __FILE__, __LINE__);
674
+		EEH_Debug_Tools::printr($this->checkout->step, '$this->checkout->step', __FILE__, __LINE__);
675
+		EEH_Debug_Tools::printr($this->checkout->edit_step, '$this->checkout->edit_step', __FILE__, __LINE__);
676
+		EEH_Debug_Tools::printr($this->checkout->action, '$this->checkout->action', __FILE__, __LINE__);
677
+		EEH_Debug_Tools::printr($this->checkout->reg_url_link, '$this->checkout->reg_url_link', __FILE__, __LINE__);
678
+		EEH_Debug_Tools::printr($this->checkout->revisit, '$this->checkout->revisit', __FILE__, __LINE__);
679
+		EEH_Debug_Tools::printr($this->checkout->generate_reg_form, '$this->checkout->generate_reg_form', __FILE__, __LINE__);
680
+		EEH_Debug_Tools::printr($this->checkout->process_form_submission, '$this->checkout->process_form_submission', __FILE__, __LINE__);
681
+	}
682
+
683
+
684
+
685
+	/**
686
+	 * _block_bots
687
+	 * checks that the incoming request has either of the following set:
688
+	 *  a uts (unix timestamp) which indicates that the request was redirected from the Ticket Selector
689
+	 *  a REG URL Link, which indicates that the request is a return visit to SPCO for a valid TXN
690
+	 * so if you're not coming from the Ticket Selector nor returning for a valid IP...
691
+	 * then where you coming from man?
692
+	 *
693
+	 * @return boolean
694
+	 */
695
+	private function _block_bots()
696
+	{
697
+		$invalid_checkout_access = EED_Invalid_Checkout_Access::getInvalidCheckoutAccess();
698
+		if ($invalid_checkout_access->checkoutAccessIsInvalid($this->checkout)) {
699
+			return true;
700
+		}
701
+		return false;
702
+	}
703
+
704
+
705
+
706
+	/**
707
+	 *    _get_first_step
708
+	 *  gets slug for first step in $_reg_steps_array
709
+	 *
710
+	 * @access    private
711
+	 * @throws EE_Error
712
+	 * @return    string
713
+	 */
714
+	private function _get_first_step()
715
+	{
716
+		$first_step = reset(EED_Single_Page_Checkout::$_reg_steps_array);
717
+		return isset($first_step['slug']) ? $first_step['slug'] : 'attendee_information';
718
+	}
719
+
720
+
721
+	/**
722
+	 * instantiates each reg step based on the loaded reg_steps array
723
+	 *
724
+	 * @return    bool
725
+	 * @throws EE_Error
726
+	 * @throws InvalidArgumentException
727
+	 * @throws InvalidDataTypeException
728
+	 * @throws InvalidInterfaceException
729
+	 */
730
+	private function _load_and_instantiate_reg_steps()
731
+	{
732
+		do_action('AHEE__Single_Page_Checkout___load_and_instantiate_reg_steps__start', $this->checkout);
733
+		// have reg_steps already been instantiated ?
734
+		if (
735
+			empty($this->checkout->reg_steps)
736
+			|| apply_filters('FHEE__Single_Page_Checkout__load_reg_steps__reload_reg_steps', false, $this->checkout)
737
+		) {
738
+			// if not, then loop through raw reg steps array
739
+			foreach (EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step) {
740
+				if ( ! $this->_load_and_instantiate_reg_step($reg_step, $order)) {
741
+					return false;
742
+				}
743
+			}
744
+			if(isset($this->checkout->reg_steps['registration_confirmation'])){
745
+				// skip the registration_confirmation page ?
746
+				if (EE_Registry::instance()->CFG->registration->skip_reg_confirmation) {
747
+					// just remove it from the reg steps array
748
+					$this->checkout->remove_reg_step('registration_confirmation', false);
749
+				} elseif (EE_Registry::instance()->CFG->registration->reg_confirmation_last
750
+				) {
751
+					// set the order to something big like 100
752
+					$this->checkout->set_reg_step_order('registration_confirmation', 100);
753
+				}
754
+			}
755
+			// filter the array for good luck
756
+			$this->checkout->reg_steps = apply_filters(
757
+				'FHEE__Single_Page_Checkout__load_reg_steps__reg_steps',
758
+				$this->checkout->reg_steps
759
+			);
760
+			// finally re-sort based on the reg step class order properties
761
+			$this->checkout->sort_reg_steps();
762
+		} else {
763
+			foreach ($this->checkout->reg_steps as $reg_step) {
764
+				// set all current step stati to FALSE
765
+				$reg_step->set_is_current_step(false);
766
+			}
767
+		}
768
+		if (empty($this->checkout->reg_steps)) {
769
+			EE_Error::add_error(
770
+				__('No Reg Steps were loaded..', 'event_espresso'),
771
+				__FILE__, __FUNCTION__, __LINE__
772
+			);
773
+			return false;
774
+		}
775
+		// make reg step details available to JS
776
+		$this->checkout->set_reg_step_JSON_info();
777
+		return true;
778
+	}
779
+
780
+
781
+
782
+	/**
783
+	 *     _load_and_instantiate_reg_step
784
+	 *
785
+	 * @access    private
786
+	 * @param array $reg_step
787
+	 * @param int   $order
788
+	 * @return bool
789
+	 */
790
+	private function _load_and_instantiate_reg_step($reg_step = array(), $order = 0)
791
+	{
792
+		// we need a file_path, class_name, and slug to add a reg step
793
+		if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) {
794
+			// if editing a specific step, but this is NOT that step... (and it's not the 'finalize_registration' step)
795
+			if (
796
+				$this->checkout->reg_url_link
797
+				&& $this->checkout->step !== $reg_step['slug']
798
+				&& $reg_step['slug'] !== 'finalize_registration'
799
+				// normally at this point we would NOT load the reg step, but this filter can change that
800
+				&& apply_filters(
801
+					'FHEE__Single_Page_Checkout___load_and_instantiate_reg_step__bypass_reg_step',
802
+					true,
803
+					$reg_step,
804
+					$this->checkout
805
+				)
806
+			) {
807
+				return true;
808
+			}
809
+			// instantiate step class using file path and class name
810
+			$reg_step_obj = EE_Registry::instance()->load_file(
811
+				$reg_step['file_path'],
812
+				$reg_step['class_name'],
813
+				'class',
814
+				$this->checkout,
815
+				false
816
+			);
817
+			// did we gets the goods ?
818
+			if ($reg_step_obj instanceof EE_SPCO_Reg_Step) {
819
+				// set reg step order based on config
820
+				$reg_step_obj->set_order($order);
821
+				// add instantiated reg step object to the master reg steps array
822
+				$this->checkout->add_reg_step($reg_step_obj);
823
+			} else {
824
+				EE_Error::add_error(
825
+					__('The current step could not be set.', 'event_espresso'),
826
+					__FILE__, __FUNCTION__, __LINE__
827
+				);
828
+				return false;
829
+			}
830
+		} else {
831
+			if (WP_DEBUG) {
832
+				EE_Error::add_error(
833
+					sprintf(
834
+						__(
835
+							'A registration step could not be loaded. One or more of the following data points is invalid:%4$s%5$sFile Path: %1$s%6$s%5$sClass Name: %2$s%6$s%5$sSlug: %3$s%6$s%7$s',
836
+							'event_espresso'
837
+						),
838
+						isset($reg_step['file_path']) ? $reg_step['file_path'] : '',
839
+						isset($reg_step['class_name']) ? $reg_step['class_name'] : '',
840
+						isset($reg_step['slug']) ? $reg_step['slug'] : '',
841
+						'<ul>',
842
+						'<li>',
843
+						'</li>',
844
+						'</ul>'
845
+					),
846
+					__FILE__, __FUNCTION__, __LINE__
847
+				);
848
+			}
849
+			return false;
850
+		}
851
+		return true;
852
+	}
853
+
854
+
855
+	/**
856
+	 * _verify_transaction_and_get_registrations
857
+	 *
858
+	 * @access private
859
+	 * @return bool
860
+	 * @throws InvalidDataTypeException
861
+	 * @throws InvalidEntityException
862
+	 * @throws EE_Error
863
+	 */
864
+	private function _verify_transaction_and_get_registrations()
865
+	{
866
+		// was there already a valid transaction in the checkout from the session ?
867
+		if ( ! $this->checkout->transaction instanceof EE_Transaction) {
868
+			// get transaction from db or session
869
+			$this->checkout->transaction = $this->checkout->reg_url_link && ! is_admin()
870
+				? $this->_get_transaction_and_cart_for_previous_visit()
871
+				: $this->_get_cart_for_current_session_and_setup_new_transaction();
872
+			if ( ! $this->checkout->transaction instanceof EE_Transaction) {
873
+				EE_Error::add_error(
874
+					__('Your Registration and Transaction information could not be retrieved from the db.',
875
+						'event_espresso'),
876
+					__FILE__, __FUNCTION__, __LINE__
877
+				);
878
+				$this->checkout->transaction = EE_Transaction::new_instance();
879
+				// add some style and make it dance
880
+				$this->add_styles_and_scripts();
881
+				EED_Single_Page_Checkout::$_initialized = true;
882
+				return false;
883
+			}
884
+			// and the registrations for the transaction
885
+			$this->_get_registrations($this->checkout->transaction);
886
+		}
887
+		return true;
888
+	}
889
+
890
+
891
+
892
+	/**
893
+	 * _get_transaction_and_cart_for_previous_visit
894
+	 *
895
+	 * @access private
896
+	 * @return mixed EE_Transaction|NULL
897
+	 */
898
+	private function _get_transaction_and_cart_for_previous_visit()
899
+	{
900
+		/** @var $TXN_model EEM_Transaction */
901
+		$TXN_model = EE_Registry::instance()->load_model('Transaction');
902
+		// because the reg_url_link is present in the request,
903
+		// this is a return visit to SPCO, so we'll get the transaction data from the db
904
+		$transaction = $TXN_model->get_transaction_from_reg_url_link($this->checkout->reg_url_link);
905
+		// verify transaction
906
+		if ($transaction instanceof EE_Transaction) {
907
+			// and get the cart that was used for that transaction
908
+			$this->checkout->cart = $this->_get_cart_for_transaction($transaction);
909
+			return $transaction;
910
+		}
911
+		EE_Error::add_error(
912
+			__('Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso'),
913
+			__FILE__, __FUNCTION__, __LINE__
914
+		);
915
+		return null;
916
+
917
+	}
918
+
919
+
920
+
921
+	/**
922
+	 * _get_cart_for_transaction
923
+	 *
924
+	 * @access private
925
+	 * @param EE_Transaction $transaction
926
+	 * @return EE_Cart
927
+	 */
928
+	private function _get_cart_for_transaction($transaction)
929
+	{
930
+		return $this->checkout->get_cart_for_transaction($transaction);
931
+	}
932
+
933
+
934
+
935
+	/**
936
+	 * get_cart_for_transaction
937
+	 *
938
+	 * @access public
939
+	 * @param EE_Transaction $transaction
940
+	 * @return EE_Cart
941
+	 */
942
+	public function get_cart_for_transaction(EE_Transaction $transaction)
943
+	{
944
+		return $this->checkout->get_cart_for_transaction($transaction);
945
+	}
946
+
947
+
948
+
949
+	/**
950
+	 * _get_transaction_and_cart_for_current_session
951
+	 *    generates a new EE_Transaction object and adds it to the $_transaction property.
952
+	 *
953
+	 * @access private
954
+	 * @return EE_Transaction
955
+	 * @throws EE_Error
956
+	 */
957
+	private function _get_cart_for_current_session_and_setup_new_transaction()
958
+	{
959
+		//  if there's no transaction, then this is the FIRST visit to SPCO
960
+		// so load up the cart ( passing nothing for the TXN because it doesn't exist yet )
961
+		$this->checkout->cart = $this->_get_cart_for_transaction(null);
962
+		// and then create a new transaction
963
+		$transaction = $this->_initialize_transaction();
964
+		// verify transaction
965
+		if ($transaction instanceof EE_Transaction) {
966
+			// save it so that we have an ID for other objects to use
967
+			$transaction->save();
968
+			// and save TXN data to the cart
969
+			$this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn($transaction->ID());
970
+		} else {
971
+			EE_Error::add_error(
972
+				__('A Valid Transaction could not be initialized.', 'event_espresso'),
973
+				__FILE__, __FUNCTION__, __LINE__
974
+			);
975
+		}
976
+		return $transaction;
977
+	}
978
+
979
+
980
+
981
+	/**
982
+	 *    generates a new EE_Transaction object and adds it to the $_transaction property.
983
+	 *
984
+	 * @access private
985
+	 * @return mixed EE_Transaction|NULL
986
+	 */
987
+	private function _initialize_transaction()
988
+	{
989
+		try {
990
+			// ensure cart totals have been calculated
991
+			$this->checkout->cart->get_grand_total()->recalculate_total_including_taxes();
992
+			// grab the cart grand total
993
+			$cart_total = $this->checkout->cart->get_cart_grand_total();
994
+			// create new TXN
995
+			$transaction = EE_Transaction::new_instance(
996
+				array(
997
+					'TXN_reg_steps' => $this->checkout->initialize_txn_reg_steps_array(),
998
+					'TXN_total'     => $cart_total > 0 ? $cart_total : 0,
999
+					'TXN_paid'      => 0,
1000
+					'STS_ID'        => EEM_Transaction::failed_status_code,
1001
+				)
1002
+			);
1003
+			// save it so that we have an ID for other objects to use
1004
+			$transaction->save();
1005
+			// set cron job for following up on TXNs after their session has expired
1006
+			EE_Cron_Tasks::schedule_expired_transaction_check(
1007
+				EE_Registry::instance()->SSN->expiration() + 1,
1008
+				$transaction->ID()
1009
+			);
1010
+			return $transaction;
1011
+		} catch (Exception $e) {
1012
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
1013
+		}
1014
+		return null;
1015
+	}
1016
+
1017
+
1018
+	/**
1019
+	 * _get_registrations
1020
+	 *
1021
+	 * @access private
1022
+	 * @param EE_Transaction $transaction
1023
+	 * @return void
1024
+	 * @throws InvalidDataTypeException
1025
+	 * @throws InvalidEntityException
1026
+	 * @throws EE_Error
1027
+	 */
1028
+	private function _get_registrations(EE_Transaction $transaction)
1029
+	{
1030
+		// first step: grab the registrants  { : o
1031
+		$registrations = $transaction->registrations($this->checkout->reg_cache_where_params, false);
1032
+		$this->checkout->total_ticket_count = count($registrations);
1033
+		// verify registrations have been set
1034
+		if (empty($registrations)) {
1035
+			// if no cached registrations, then check the db
1036
+			$registrations = $transaction->registrations($this->checkout->reg_cache_where_params, false);
1037
+			// still nothing ? well as long as this isn't a revisit
1038
+			if (empty($registrations) && ! $this->checkout->revisit) {
1039
+				// generate new registrations from scratch
1040
+				$registrations = $this->_initialize_registrations($transaction);
1041
+			}
1042
+		}
1043
+		// sort by their original registration order
1044
+		usort($registrations, array('EED_Single_Page_Checkout', 'sort_registrations_by_REG_count'));
1045
+		// then loop thru the array
1046
+		foreach ($registrations as $registration) {
1047
+			// verify each registration
1048
+			if ($registration instanceof EE_Registration) {
1049
+				// we display all attendee info for the primary registrant
1050
+				if ($this->checkout->reg_url_link === $registration->reg_url_link()
1051
+					&& $registration->is_primary_registrant()
1052
+				) {
1053
+					$this->checkout->primary_revisit = true;
1054
+					break;
1055
+				}
1056
+				if ($this->checkout->revisit && $this->checkout->reg_url_link !== $registration->reg_url_link()) {
1057
+					// but hide info if it doesn't belong to you
1058
+					$transaction->clear_cache('Registration', $registration->ID());
1059
+					$this->checkout->total_ticket_count--;
1060
+				}
1061
+				$this->checkout->set_reg_status_updated($registration->ID(), false);
1062
+			}
1063
+		}
1064
+	}
1065
+
1066
+
1067
+	/**
1068
+	 *    adds related EE_Registration objects for each ticket in the cart to the current EE_Transaction object
1069
+	 *
1070
+	 * @access private
1071
+	 * @param EE_Transaction $transaction
1072
+	 * @return    array
1073
+	 * @throws InvalidDataTypeException
1074
+	 * @throws InvalidEntityException
1075
+	 * @throws EE_Error
1076
+	 */
1077
+	private function _initialize_registrations(EE_Transaction $transaction)
1078
+	{
1079
+		$att_nmbr = 0;
1080
+		$registrations = array();
1081
+		if ($transaction instanceof EE_Transaction) {
1082
+			/** @type EE_Registration_Processor $registration_processor */
1083
+			$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
1084
+			$this->checkout->total_ticket_count = $this->checkout->cart->all_ticket_quantity_count();
1085
+			// now let's add the cart items to the $transaction
1086
+			foreach ($this->checkout->cart->get_tickets() as $line_item) {
1087
+				//do the following for each ticket of this type they selected
1088
+				for ($x = 1; $x <= $line_item->quantity(); $x++) {
1089
+					$att_nmbr++;
1090
+					/** @var EventEspresso\core\services\commands\registration\CreateRegistrationCommand $CreateRegistrationCommand */
1091
+					$CreateRegistrationCommand = EE_Registry::instance()->create(
1092
+						'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
1093
+						array(
1094
+							$transaction,
1095
+							$line_item,
1096
+							$att_nmbr,
1097
+							$this->checkout->total_ticket_count,
1098
+						)
1099
+					);
1100
+					// override capabilities for frontend registrations
1101
+					if ( ! is_admin()) {
1102
+						$CreateRegistrationCommand->setCapCheck(
1103
+							new PublicCapabilities('', 'create_new_registration')
1104
+						);
1105
+					}
1106
+					$registration = EE_Registry::instance()->BUS->execute($CreateRegistrationCommand);
1107
+					if ( ! $registration instanceof EE_Registration) {
1108
+						throw new InvalidEntityException($registration, 'EE_Registration');
1109
+					}
1110
+					$registrations[ $registration->ID() ] = $registration;
1111
+				}
1112
+			}
1113
+			$registration_processor->fix_reg_final_price_rounding_issue($transaction);
1114
+		}
1115
+		return $registrations;
1116
+	}
1117
+
1118
+
1119
+
1120
+	/**
1121
+	 * sorts registrations by REG_count
1122
+	 *
1123
+	 * @access public
1124
+	 * @param EE_Registration $reg_A
1125
+	 * @param EE_Registration $reg_B
1126
+	 * @return int
1127
+	 */
1128
+	public static function sort_registrations_by_REG_count(EE_Registration $reg_A, EE_Registration $reg_B)
1129
+	{
1130
+		// this shouldn't ever happen within the same TXN, but oh well
1131
+		if ($reg_A->count() === $reg_B->count()) {
1132
+			return 0;
1133
+		}
1134
+		return ($reg_A->count() > $reg_B->count()) ? 1 : -1;
1135
+	}
1136
+
1137
+
1138
+
1139
+	/**
1140
+	 *    _final_verifications
1141
+	 * just makes sure that everything is set up correctly before proceeding
1142
+	 *
1143
+	 * @access    private
1144
+	 * @return    bool
1145
+	 * @throws EE_Error
1146
+	 */
1147
+	private function _final_verifications()
1148
+	{
1149
+		// filter checkout
1150
+		$this->checkout = apply_filters(
1151
+			'FHEE__EED_Single_Page_Checkout___final_verifications__checkout',
1152
+			$this->checkout
1153
+		);
1154
+		//verify that current step is still set correctly
1155
+		if ( ! $this->checkout->current_step instanceof EE_SPCO_Reg_Step) {
1156
+			EE_Error::add_error(
1157
+				__('We\'re sorry but the registration process can not proceed because one or more registration steps were not setup correctly. Please refresh the page and try again or contact support.', 'event_espresso'),
1158
+				__FILE__,
1159
+				__FUNCTION__,
1160
+				__LINE__
1161
+			);
1162
+			return false;
1163
+		}
1164
+		// if returning to SPCO, then verify that primary registrant is set
1165
+		if ( ! empty($this->checkout->reg_url_link)) {
1166
+			$valid_registrant = $this->checkout->transaction->primary_registration();
1167
+			if ( ! $valid_registrant instanceof EE_Registration) {
1168
+				EE_Error::add_error(
1169
+					__('We\'re sorry but there appears to be an error with the "reg_url_link" or the primary registrant for this transaction. Please refresh the page and try again or contact support.', 'event_espresso'),
1170
+					__FILE__,
1171
+					__FUNCTION__,
1172
+					__LINE__
1173
+				);
1174
+				return false;
1175
+			}
1176
+			$valid_registrant = null;
1177
+			foreach (
1178
+				$this->checkout->transaction->registrations($this->checkout->reg_cache_where_params) as $registration
1179
+			) {
1180
+				if (
1181
+					$registration instanceof EE_Registration
1182
+					&& $registration->reg_url_link() === $this->checkout->reg_url_link
1183
+				) {
1184
+					$valid_registrant = $registration;
1185
+				}
1186
+			}
1187
+			if ( ! $valid_registrant instanceof EE_Registration) {
1188
+				// hmmm... maybe we have the wrong session because the user is opening multiple tabs ?
1189
+				if (EED_Single_Page_Checkout::$_checkout_verified) {
1190
+					// clear the session, mark the checkout as unverified, and try again
1191
+					EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
1192
+					EED_Single_Page_Checkout::$_initialized = false;
1193
+					EED_Single_Page_Checkout::$_checkout_verified = false;
1194
+					$this->_initialize();
1195
+					EE_Error::reset_notices();
1196
+					return false;
1197
+				}
1198
+				EE_Error::add_error(
1199
+					__(
1200
+						'We\'re sorry but there appears to be an error with the "reg_url_link" or the transaction itself. Please refresh the page and try again or contact support.',
1201
+						'event_espresso'
1202
+					),
1203
+					__FILE__,
1204
+					__FUNCTION__,
1205
+					__LINE__
1206
+				);
1207
+				return false;
1208
+			}
1209
+		}
1210
+		// now that things have been kinda sufficiently verified,
1211
+		// let's add the checkout to the session so that it's available to other systems
1212
+		EE_Registry::instance()->SSN->set_checkout($this->checkout);
1213
+		return true;
1214
+	}
1215
+
1216
+
1217
+
1218
+	/**
1219
+	 *    _initialize_reg_steps
1220
+	 * first makes sure that EE_Transaction_Processor::set_reg_step_initiated() is called as required
1221
+	 * then loops thru all of the active reg steps and calls the initialize_reg_step() method
1222
+	 *
1223
+	 * @access    private
1224
+	 * @param bool $reinitializing
1225
+	 * @throws EE_Error
1226
+	 */
1227
+	private function _initialize_reg_steps($reinitializing = false)
1228
+	{
1229
+		$this->checkout->set_reg_step_initiated($this->checkout->current_step);
1230
+		// loop thru all steps to call their individual "initialize" methods and set i18n strings for JS
1231
+		foreach ($this->checkout->reg_steps as $reg_step) {
1232
+			if ( ! $reg_step->initialize_reg_step()) {
1233
+				// if not initialized then maybe this step is being removed...
1234
+				if ( ! $reinitializing && $reg_step->is_current_step()) {
1235
+					// if it was the current step, then we need to start over here
1236
+					$this->_initialize_reg_steps(true);
1237
+					return;
1238
+				}
1239
+				continue;
1240
+			}
1241
+			// add css and JS for current step
1242
+			$reg_step->enqueue_styles_and_scripts();
1243
+			// i18n
1244
+			$reg_step->translate_js_strings();
1245
+			if ($reg_step->is_current_step()) {
1246
+				// the text that appears on the reg step form submit button
1247
+				$reg_step->set_submit_button_text();
1248
+			}
1249
+		}
1250
+		// dynamically creates hook point like: AHEE__Single_Page_Checkout___initialize_reg_step__attendee_information
1251
+		do_action(
1252
+			"AHEE__Single_Page_Checkout___initialize_reg_step__{$this->checkout->current_step->slug()}",
1253
+			$this->checkout->current_step
1254
+		);
1255
+	}
1256
+
1257
+
1258
+
1259
+	/**
1260
+	 * _check_form_submission
1261
+	 *
1262
+	 * @access private
1263
+	 * @return boolean
1264
+	 */
1265
+	private function _check_form_submission()
1266
+	{
1267
+		//does this request require the reg form to be generated ?
1268
+		if ($this->checkout->generate_reg_form) {
1269
+			// ever heard that song by Blue Rodeo ?
1270
+			try {
1271
+				$this->checkout->current_step->reg_form = $this->checkout->current_step->generate_reg_form();
1272
+				// if not displaying a form, then check for form submission
1273
+				if (
1274
+					$this->checkout->process_form_submission
1275
+					&& $this->checkout->current_step->reg_form->was_submitted()
1276
+				) {
1277
+					// clear out any old data in case this step is being run again
1278
+					$this->checkout->current_step->set_valid_data(array());
1279
+					// capture submitted form data
1280
+					$this->checkout->current_step->reg_form->receive_form_submission(
1281
+						apply_filters(
1282
+							'FHEE__Single_Page_Checkout___check_form_submission__request_params',
1283
+							EE_Registry::instance()->REQ->params(),
1284
+							$this->checkout
1285
+						)
1286
+					);
1287
+					// validate submitted form data
1288
+					if ( ! $this->checkout->continue_reg || ! $this->checkout->current_step->reg_form->is_valid()) {
1289
+						// thou shall not pass !!!
1290
+						$this->checkout->continue_reg = false;
1291
+						// any form validation errors?
1292
+						if ($this->checkout->current_step->reg_form->submission_error_message() !== '') {
1293
+							EE_Error::add_error(
1294
+								$this->checkout->current_step->reg_form->submission_error_message(),
1295
+								__FILE__, __FUNCTION__, __LINE__
1296
+							);
1297
+						}
1298
+						// well not really... what will happen is
1299
+						// we'll just get redirected back to redo the current step
1300
+						$this->go_to_next_step();
1301
+						return false;
1302
+					}
1303
+				}
1304
+			} catch (EE_Error $e) {
1305
+				$e->get_error();
1306
+			}
1307
+		}
1308
+		return true;
1309
+	}
1310
+
1311
+
1312
+
1313
+	/**
1314
+	 * _process_action
1315
+	 *
1316
+	 * @access private
1317
+	 * @return void
1318
+	 * @throws EE_Error
1319
+	 */
1320
+	private function _process_form_action()
1321
+	{
1322
+		// what cha wanna do?
1323
+		switch ($this->checkout->action) {
1324
+			// AJAX next step reg form
1325
+			case 'display_spco_reg_step' :
1326
+				$this->checkout->redirect = false;
1327
+				if (EE_Registry::instance()->REQ->ajax) {
1328
+					$this->checkout->json_response->set_reg_step_html(
1329
+						$this->checkout->current_step->display_reg_form()
1330
+					);
1331
+				}
1332
+				break;
1333
+			default :
1334
+				// meh... do one of those other steps first
1335
+				if (
1336
+					! empty($this->checkout->action)
1337
+					&& is_callable(array($this->checkout->current_step, $this->checkout->action))
1338
+				) {
1339
+					// dynamically creates hook point like:
1340
+					//   AHEE__Single_Page_Checkout__before_attendee_information__process_reg_step
1341
+					do_action(
1342
+						"AHEE__Single_Page_Checkout__before_{$this->checkout->current_step->slug()}__{$this->checkout->action}",
1343
+						$this->checkout->current_step
1344
+					);
1345
+					// call action on current step
1346
+					if (call_user_func(array($this->checkout->current_step, $this->checkout->action))) {
1347
+						// good registrant, you get to proceed
1348
+						if (
1349
+							$this->checkout->current_step->success_message() !== ''
1350
+							&& apply_filters(
1351
+								'FHEE__Single_Page_Checkout___process_form_action__display_success',
1352
+								false
1353
+							)
1354
+						) {
1355
+							EE_Error::add_success(
1356
+								$this->checkout->current_step->success_message()
1357
+								. '<br />' . $this->checkout->next_step->_instructions()
1358
+							);
1359
+						}
1360
+						// pack it up, pack it in...
1361
+						$this->_setup_redirect();
1362
+					}
1363
+					// dynamically creates hook point like:
1364
+					//  AHEE__Single_Page_Checkout__after_payment_options__process_reg_step
1365
+					do_action(
1366
+						"AHEE__Single_Page_Checkout__after_{$this->checkout->current_step->slug()}__{$this->checkout->action}",
1367
+						$this->checkout->current_step
1368
+					);
1369
+				} else {
1370
+					EE_Error::add_error(
1371
+						sprintf(
1372
+							__(
1373
+								'The requested form action "%s" does not exist for the current "%s" registration step.',
1374
+								'event_espresso'
1375
+							),
1376
+							$this->checkout->action,
1377
+							$this->checkout->current_step->name()
1378
+						),
1379
+						__FILE__,
1380
+						__FUNCTION__,
1381
+						__LINE__
1382
+					);
1383
+				}
1384
+			// end default
1385
+		}
1386
+		// store our progress so far
1387
+		$this->checkout->stash_transaction_and_checkout();
1388
+		// advance to the next step! If you pass GO, collect $200
1389
+		$this->go_to_next_step();
1390
+	}
1391
+
1392
+
1393
+
1394
+	/**
1395
+	 *        add_styles_and_scripts
1396
+	 *
1397
+	 * @access        public
1398
+	 * @return        void
1399
+	 */
1400
+	public function add_styles_and_scripts()
1401
+	{
1402
+		// i18n
1403
+		$this->translate_js_strings();
1404
+		if ($this->checkout->admin_request) {
1405
+			add_action('admin_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10);
1406
+		} else {
1407
+			add_action('wp_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10);
1408
+		}
1409
+	}
1410
+
1411
+
1412
+
1413
+	/**
1414
+	 *        translate_js_strings
1415
+	 *
1416
+	 * @access        public
1417
+	 * @return        void
1418
+	 */
1419
+	public function translate_js_strings()
1420
+	{
1421
+		EE_Registry::$i18n_js_strings['revisit'] = $this->checkout->revisit;
1422
+		EE_Registry::$i18n_js_strings['e_reg_url_link'] = $this->checkout->reg_url_link;
1423
+		EE_Registry::$i18n_js_strings['server_error'] = __(
1424
+			'An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again or contact support.',
1425
+			'event_espresso'
1426
+		);
1427
+		EE_Registry::$i18n_js_strings['invalid_json_response'] = __(
1428
+			'An invalid response was returned from the server while attempting to process your request. Please refresh the page and try again or contact support.',
1429
+			'event_espresso'
1430
+		);
1431
+		EE_Registry::$i18n_js_strings['validation_error'] = __(
1432
+			'There appears to be a problem with the form validation configuration! Please check the admin settings or contact support.',
1433
+			'event_espresso'
1434
+		);
1435
+		EE_Registry::$i18n_js_strings['invalid_payment_method'] = __(
1436
+			'There appears to be a problem with the payment method configuration! Please refresh the page and try again or contact support.',
1437
+			'event_espresso'
1438
+		);
1439
+		EE_Registry::$i18n_js_strings['reg_step_error'] = __(
1440
+			'This registration step could not be completed. Please refresh the page and try again.',
1441
+			'event_espresso'
1442
+		);
1443
+		EE_Registry::$i18n_js_strings['invalid_coupon'] = __(
1444
+			'We\'re sorry but that coupon code does not appear to be valid. If this is incorrect, please contact the site administrator.',
1445
+			'event_espresso'
1446
+		);
1447
+		EE_Registry::$i18n_js_strings['process_registration'] = sprintf(
1448
+			__(
1449
+				'Please wait while we process your registration.%sDo not refresh the page or navigate away while this is happening.%sThank you for your patience.',
1450
+				'event_espresso'
1451
+			),
1452
+			'<br/>',
1453
+			'<br/>'
1454
+		);
1455
+		EE_Registry::$i18n_js_strings['language'] = get_bloginfo('language');
1456
+		EE_Registry::$i18n_js_strings['EESID'] = EE_Registry::instance()->SSN->id();
1457
+		EE_Registry::$i18n_js_strings['currency'] = EE_Registry::instance()->CFG->currency;
1458
+		EE_Registry::$i18n_js_strings['datepicker_yearRange'] = '-150:+20';
1459
+		EE_Registry::$i18n_js_strings['timer_years'] = __('years', 'event_espresso');
1460
+		EE_Registry::$i18n_js_strings['timer_months'] = __('months', 'event_espresso');
1461
+		EE_Registry::$i18n_js_strings['timer_weeks'] = __('weeks', 'event_espresso');
1462
+		EE_Registry::$i18n_js_strings['timer_days'] = __('days', 'event_espresso');
1463
+		EE_Registry::$i18n_js_strings['timer_hours'] = __('hours', 'event_espresso');
1464
+		EE_Registry::$i18n_js_strings['timer_minutes'] = __('minutes', 'event_espresso');
1465
+		EE_Registry::$i18n_js_strings['timer_seconds'] = __('seconds', 'event_espresso');
1466
+		EE_Registry::$i18n_js_strings['timer_year'] = __('year', 'event_espresso');
1467
+		EE_Registry::$i18n_js_strings['timer_month'] = __('month', 'event_espresso');
1468
+		EE_Registry::$i18n_js_strings['timer_week'] = __('week', 'event_espresso');
1469
+		EE_Registry::$i18n_js_strings['timer_day'] = __('day', 'event_espresso');
1470
+		EE_Registry::$i18n_js_strings['timer_hour'] = __('hour', 'event_espresso');
1471
+		EE_Registry::$i18n_js_strings['timer_minute'] = __('minute', 'event_espresso');
1472
+		EE_Registry::$i18n_js_strings['timer_second'] = __('second', 'event_espresso');
1473
+		EE_Registry::$i18n_js_strings['registration_expiration_notice'] = EED_Single_Page_Checkout::getRegistrationExpirationNotice();
1474
+		EE_Registry::$i18n_js_strings['ajax_submit'] = apply_filters(
1475
+			'FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit',
1476
+			true
1477
+		);
1478
+		EE_Registry::$i18n_js_strings['session_extension'] = absint(
1479
+			apply_filters('FHEE__EE_Session__extend_expiration__seconds_added', 10 * MINUTE_IN_SECONDS)
1480
+		);
1481
+		EE_Registry::$i18n_js_strings['session_expiration'] = gmdate(
1482
+			'M d, Y H:i:s',
1483
+			EE_Registry::instance()->SSN->expiration() + (get_option('gmt_offset') * HOUR_IN_SECONDS)
1484
+		);
1485
+	}
1486
+
1487
+
1488
+
1489
+	/**
1490
+	 *    enqueue_styles_and_scripts
1491
+	 *
1492
+	 * @access        public
1493
+	 * @return        void
1494
+	 * @throws EE_Error
1495
+	 */
1496
+	public function enqueue_styles_and_scripts()
1497
+	{
1498
+		// load css
1499
+		wp_register_style(
1500
+			'single_page_checkout',
1501
+			SPCO_CSS_URL . 'single_page_checkout.css',
1502
+			array('espresso_default'),
1503
+			EVENT_ESPRESSO_VERSION
1504
+		);
1505
+		wp_enqueue_style('single_page_checkout');
1506
+		// load JS
1507
+		wp_register_script(
1508
+			'jquery_plugin',
1509
+			EE_THIRD_PARTY_URL . 'jquery	.plugin.min.js',
1510
+			array('jquery'),
1511
+			'1.0.1',
1512
+			true
1513
+		);
1514
+		wp_register_script(
1515
+			'jquery_countdown',
1516
+			EE_THIRD_PARTY_URL . 'jquery	.countdown.min.js',
1517
+			array('jquery_plugin'),
1518
+			'2.0.2',
1519
+			true
1520
+		);
1521
+		wp_register_script(
1522
+			'single_page_checkout',
1523
+			SPCO_JS_URL . 'single_page_checkout.js',
1524
+			array('espresso_core', 'underscore', 'ee_form_section_validation', 'jquery_countdown'),
1525
+			EVENT_ESPRESSO_VERSION,
1526
+			true
1527
+		);
1528
+		if ($this->checkout->registration_form instanceof EE_Form_Section_Proper) {
1529
+			$this->checkout->registration_form->enqueue_js();
1530
+		}
1531
+		if ($this->checkout->current_step->reg_form instanceof EE_Form_Section_Proper) {
1532
+			$this->checkout->current_step->reg_form->enqueue_js();
1533
+		}
1534
+		wp_enqueue_script('single_page_checkout');
1535
+		/**
1536
+		 * global action hook for enqueueing styles and scripts with
1537
+		 * spco calls.
1538
+		 */
1539
+		do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts', $this);
1540
+		/**
1541
+		 * dynamic action hook for enqueueing styles and scripts with spco calls.
1542
+		 * The hook will end up being something like:
1543
+		 *      AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__attendee_information
1544
+		 */
1545
+		do_action(
1546
+			'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__' . $this->checkout->current_step->slug(),
1547
+			$this
1548
+		);
1549
+	}
1550
+
1551
+
1552
+
1553
+	/**
1554
+	 *    display the Registration Single Page Checkout Form
1555
+	 *
1556
+	 * @access    private
1557
+	 * @return    void
1558
+	 * @throws EE_Error
1559
+	 */
1560
+	private function _display_spco_reg_form()
1561
+	{
1562
+		// if registering via the admin, just display the reg form for the current step
1563
+		if ($this->checkout->admin_request) {
1564
+			EE_Registry::instance()->REQ->add_output($this->checkout->current_step->display_reg_form());
1565
+		} else {
1566
+			// add powered by EE msg
1567
+			add_action('AHEE__SPCO__reg_form_footer', array('EED_Single_Page_Checkout', 'display_registration_footer'));
1568
+			$empty_cart = count(
1569
+				$this->checkout->transaction->registrations($this->checkout->reg_cache_where_params)
1570
+			) < 1;
1571
+			EE_Registry::$i18n_js_strings['empty_cart'] = $empty_cart;
1572
+			$cookies_not_set_msg = '';
1573
+			if ($empty_cart) {
1574
+				$cookies_not_set_msg = apply_filters(
1575
+					'FHEE__Single_Page_Checkout__display_spco_reg_form__cookies_not_set_msg',
1576
+					sprintf(
1577
+						__(
1578
+							'%1$s%3$sIt appears your browser is not currently set to accept Cookies%4$s%5$sIn order to register for events, you need to enable cookies.%7$sIf you require assistance, then click the following link to learn how to %8$senable cookies%9$s%6$s%2$s',
1579
+							'event_espresso'
1580
+						),
1581
+						'<div class="ee-attention hidden" id="ee-cookies-not-set-msg">',
1582
+						'</div>',
1583
+						'<h6 class="important-notice">',
1584
+						'</h6>',
1585
+						'<p>',
1586
+						'</p>',
1587
+						'<br />',
1588
+						'<a href="http://www.whatarecookies.com/enable.asp" target="_blank">',
1589
+						'</a>'
1590
+					)
1591
+				);
1592
+			}
1593
+			$this->checkout->registration_form = new EE_Form_Section_Proper(
1594
+				array(
1595
+					'name'            => 'single-page-checkout',
1596
+					'html_id'         => 'ee-single-page-checkout-dv',
1597
+					'layout_strategy' =>
1598
+						new EE_Template_Layout(
1599
+							array(
1600
+								'layout_template_file' => SPCO_TEMPLATES_PATH . 'registration_page_wrapper.template.php',
1601
+								'template_args'        => array(
1602
+									'empty_cart'              => $empty_cart,
1603
+									'revisit'                 => $this->checkout->revisit,
1604
+									'reg_steps'               => $this->checkout->reg_steps,
1605
+									'next_step'               => $this->checkout->next_step instanceof EE_SPCO_Reg_Step
1606
+										? $this->checkout->next_step->slug()
1607
+										: '',
1608
+									'empty_msg'               => apply_filters(
1609
+										'FHEE__Single_Page_Checkout__display_spco_reg_form__empty_msg',
1610
+										sprintf(
1611
+											__(
1612
+												'You need to %1$sReturn to Events list%2$sselect at least one event%3$s before you can proceed with the registration process.',
1613
+												'event_espresso'
1614
+											),
1615
+											'<a href="'
1616
+											. get_post_type_archive_link('espresso_events')
1617
+											. '" title="',
1618
+											'">',
1619
+											'</a>'
1620
+										)
1621
+									),
1622
+									'cookies_not_set_msg'     => $cookies_not_set_msg,
1623
+									'registration_time_limit' => $this->checkout->get_registration_time_limit(),
1624
+									'session_expiration'      => gmdate(
1625
+										'M d, Y H:i:s',
1626
+										EE_Registry::instance()->SSN->expiration()
1627
+										+ (get_option('gmt_offset') * HOUR_IN_SECONDS)
1628
+									),
1629
+								),
1630
+							)
1631
+						),
1632
+				)
1633
+			);
1634
+			// load template and add to output sent that gets filtered into the_content()
1635
+			EE_Registry::instance()->REQ->add_output($this->checkout->registration_form->get_html());
1636
+		}
1637
+	}
1638
+
1639
+
1640
+
1641
+	/**
1642
+	 *    add_extra_finalize_registration_inputs
1643
+	 *
1644
+	 * @access    public
1645
+	 * @param $next_step
1646
+	 * @internal  param string $label
1647
+	 * @return void
1648
+	 */
1649
+	public function add_extra_finalize_registration_inputs($next_step)
1650
+	{
1651
+		if ($next_step === 'finalize_registration') {
1652
+			echo '<div id="spco-extra-finalize_registration-inputs-dv"></div>';
1653
+		}
1654
+	}
1655
+
1656
+
1657
+
1658
+	/**
1659
+	 *    display_registration_footer
1660
+	 *
1661
+	 * @access    public
1662
+	 * @return    string
1663
+	 */
1664
+	public static function display_registration_footer()
1665
+	{
1666
+		if (
1667
+		apply_filters(
1668
+			'FHEE__EE_Front__Controller__show_reg_footer',
1669
+			EE_Registry::instance()->CFG->admin->show_reg_footer
1670
+		)
1671
+		) {
1672
+			add_filter(
1673
+				'FHEE__EEH_Template__powered_by_event_espresso__url',
1674
+				function ($url) {
1675
+					return apply_filters('FHEE__EE_Front_Controller__registration_footer__url', $url);
1676
+				}
1677
+			);
1678
+			echo apply_filters(
1679
+				'FHEE__EE_Front_Controller__display_registration_footer',
1680
+				\EEH_Template::powered_by_event_espresso(
1681
+					'',
1682
+					'espresso-registration-footer-dv',
1683
+					array('utm_content' => 'registration_checkout')
1684
+				)
1685
+			);
1686
+		}
1687
+		return '';
1688
+	}
1689
+
1690
+
1691
+
1692
+	/**
1693
+	 *    unlock_transaction
1694
+	 *
1695
+	 * @access    public
1696
+	 * @return    void
1697
+	 * @throws EE_Error
1698
+	 */
1699
+	public function unlock_transaction()
1700
+	{
1701
+		if ($this->checkout->transaction instanceof EE_Transaction) {
1702
+			$this->checkout->transaction->unlock();
1703
+		}
1704
+	}
1705
+
1706
+
1707
+
1708
+	/**
1709
+	 *        _setup_redirect
1710
+	 *
1711
+	 * @access    private
1712
+	 * @return void
1713
+	 */
1714
+	private function _setup_redirect()
1715
+	{
1716
+		if ($this->checkout->continue_reg && $this->checkout->next_step instanceof EE_SPCO_Reg_Step) {
1717
+			$this->checkout->redirect = true;
1718
+			if (empty($this->checkout->redirect_url)) {
1719
+				$this->checkout->redirect_url = $this->checkout->next_step->reg_step_url();
1720
+			}
1721
+			$this->checkout->redirect_url = apply_filters(
1722
+				'FHEE__EED_Single_Page_Checkout___setup_redirect__checkout_redirect_url',
1723
+				$this->checkout->redirect_url,
1724
+				$this->checkout
1725
+			);
1726
+		}
1727
+	}
1728
+
1729
+
1730
+
1731
+	/**
1732
+	 *   handle ajax message responses and redirects
1733
+	 *
1734
+	 * @access public
1735
+	 * @return void
1736
+	 * @throws EE_Error
1737
+	 */
1738
+	public function go_to_next_step()
1739
+	{
1740
+		if (EE_Registry::instance()->REQ->ajax) {
1741
+			// capture contents of output buffer we started earlier in the request, and insert into JSON response
1742
+			$this->checkout->json_response->set_unexpected_errors(ob_get_clean());
1743
+		}
1744
+		$this->unlock_transaction();
1745
+		// just return for these conditions
1746
+		if (
1747
+			$this->checkout->admin_request
1748
+			|| $this->checkout->action === 'redirect_form'
1749
+			|| $this->checkout->action === 'update_checkout'
1750
+		) {
1751
+			return;
1752
+		}
1753
+		// AJAX response
1754
+		$this->_handle_json_response();
1755
+		// redirect to next step or the Thank You page
1756
+		$this->_handle_html_redirects();
1757
+		// hmmm... must be something wrong, so let's just display the form again !
1758
+		$this->_display_spco_reg_form();
1759
+	}
1760
+
1761
+
1762
+
1763
+	/**
1764
+	 *   _handle_json_response
1765
+	 *
1766
+	 * @access protected
1767
+	 * @return void
1768
+	 */
1769
+	protected function _handle_json_response()
1770
+	{
1771
+		// if this is an ajax request
1772
+		if (EE_Registry::instance()->REQ->ajax) {
1773
+			// DEBUG LOG
1774
+			//$this->checkout->log(
1775
+			//	__CLASS__, __FUNCTION__, __LINE__,
1776
+			//	array(
1777
+			//		'json_response_redirect_url' => $this->checkout->json_response->redirect_url(),
1778
+			//		'redirect'                   => $this->checkout->redirect,
1779
+			//		'continue_reg'               => $this->checkout->continue_reg,
1780
+			//	)
1781
+			//);
1782
+			$this->checkout->json_response->set_registration_time_limit(
1783
+				$this->checkout->get_registration_time_limit()
1784
+			);
1785
+			$this->checkout->json_response->set_payment_amount($this->checkout->amount_owing);
1786
+			// just send the ajax (
1787
+			$json_response = apply_filters(
1788
+				'FHEE__EE_Single_Page_Checkout__JSON_response',
1789
+				$this->checkout->json_response
1790
+			);
1791
+			echo $json_response;
1792
+			exit();
1793
+		}
1794
+	}
1795
+
1796
+
1797
+
1798
+	/**
1799
+	 *   _handle_redirects
1800
+	 *
1801
+	 * @access protected
1802
+	 * @return void
1803
+	 */
1804
+	protected function _handle_html_redirects()
1805
+	{
1806
+		// going somewhere ?
1807
+		if ($this->checkout->redirect && ! empty($this->checkout->redirect_url)) {
1808
+			// store notices in a transient
1809
+			EE_Error::get_notices(false, true, true);
1810
+			// DEBUG LOG
1811
+			//$this->checkout->log(
1812
+			//	__CLASS__, __FUNCTION__, __LINE__,
1813
+			//	array(
1814
+			//		'headers_sent' => headers_sent(),
1815
+			//		'redirect_url'     => $this->checkout->redirect_url,
1816
+			//		'headers_list'    => headers_list(),
1817
+			//	)
1818
+			//);
1819
+			wp_safe_redirect($this->checkout->redirect_url);
1820
+			exit();
1821
+		}
1822
+	}
1823
+
1824
+
1825
+
1826
+	/**
1827
+	 *   set_checkout_anchor
1828
+	 *
1829
+	 * @access public
1830
+	 * @return void
1831
+	 */
1832
+	public function set_checkout_anchor()
1833
+	{
1834
+		echo '<a id="checkout" style="float: left; margin-left: -999em;"></a>';
1835
+	}
1836
+
1837
+	/**
1838
+	 *    getRegistrationExpirationNotice
1839
+	 *
1840
+	 * @since 4.9.59.p
1841
+	 * @access    public
1842
+	 * @return    string
1843
+	 */
1844
+	public static function getRegistrationExpirationNotice()
1845
+	{
1846
+		return sprintf(
1847
+			__('%1$sWe\'re sorry, but your registration time has expired.%2$s%3$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please accept our apologies for any inconvenience this may have caused.%8$s',
1848
+				'event_espresso'),
1849
+			'<h4 class="important-notice">',
1850
+			'</h4>',
1851
+			'<br />',
1852
+			'<p>',
1853
+			'<a href="' . get_post_type_archive_link('espresso_events') . '" title="',
1854
+			'">',
1855
+			'</a>',
1856
+			'</p>'
1857
+		);
1858
+	}
1859 1859
 
1860 1860
 }
1861 1861
 // End of file EED_Single_Page_Checkout.module.php
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -219,19 +219,19 @@  discard block
 block discarded – undo
219 219
      */
220 220
     public static function set_definitions()
221 221
     {
222
-        if(defined('SPCO_BASE_PATH')) {
222
+        if (defined('SPCO_BASE_PATH')) {
223 223
             return;
224 224
         }
225 225
         define(
226 226
             'SPCO_BASE_PATH',
227
-            rtrim(str_replace(array('\\', '/'), DS, plugin_dir_path(__FILE__)), DS) . DS
227
+            rtrim(str_replace(array('\\', '/'), DS, plugin_dir_path(__FILE__)), DS).DS
228 228
         );
229
-        define('SPCO_CSS_URL', plugin_dir_url(__FILE__) . 'css' . DS);
230
-        define('SPCO_IMG_URL', plugin_dir_url(__FILE__) . 'img' . DS);
231
-        define('SPCO_JS_URL', plugin_dir_url(__FILE__) . 'js' . DS);
232
-        define('SPCO_INC_PATH', SPCO_BASE_PATH . 'inc' . DS);
233
-        define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH . 'reg_steps' . DS);
234
-        define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH . 'templates' . DS);
229
+        define('SPCO_CSS_URL', plugin_dir_url(__FILE__).'css'.DS);
230
+        define('SPCO_IMG_URL', plugin_dir_url(__FILE__).'img'.DS);
231
+        define('SPCO_JS_URL', plugin_dir_url(__FILE__).'js'.DS);
232
+        define('SPCO_INC_PATH', SPCO_BASE_PATH.'inc'.DS);
233
+        define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH.'reg_steps'.DS);
234
+        define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH.'templates'.DS);
235 235
         EEH_Autoloader::register_autoloaders_for_each_file_in_folder(SPCO_BASE_PATH, true);
236 236
         EE_Registry::$i18n_js_strings['registration_expiration_notice'] = EED_Single_Page_Checkout::getRegistrationExpirationNotice();
237 237
     }
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
             return;
253 253
         }
254 254
         // filter list of reg_steps
255
-        $reg_steps_to_load = (array)apply_filters(
255
+        $reg_steps_to_load = (array) apply_filters(
256 256
             'AHEE__SPCO__load_reg_steps__reg_steps_to_load',
257 257
             EED_Single_Page_Checkout::get_reg_steps()
258 258
         );
@@ -304,19 +304,19 @@  discard block
 block discarded – undo
304 304
         if (empty($reg_steps)) {
305 305
             $reg_steps = array(
306 306
                 10  => array(
307
-                    'file_path'  => SPCO_REG_STEPS_PATH . 'attendee_information',
307
+                    'file_path'  => SPCO_REG_STEPS_PATH.'attendee_information',
308 308
                     'class_name' => 'EE_SPCO_Reg_Step_Attendee_Information',
309 309
                     'slug'       => 'attendee_information',
310 310
                     'has_hooks'  => false,
311 311
                 ),
312 312
                 30  => array(
313
-                    'file_path'  => SPCO_REG_STEPS_PATH . 'payment_options',
313
+                    'file_path'  => SPCO_REG_STEPS_PATH.'payment_options',
314 314
                     'class_name' => 'EE_SPCO_Reg_Step_Payment_Options',
315 315
                     'slug'       => 'payment_options',
316 316
                     'has_hooks'  => true,
317 317
                 ),
318 318
                 999 => array(
319
-                    'file_path'  => SPCO_REG_STEPS_PATH . 'finalize_registration',
319
+                    'file_path'  => SPCO_REG_STEPS_PATH.'finalize_registration',
320 320
                     'class_name' => 'EE_SPCO_Reg_Step_Finalize_Registration',
321 321
                     'slug'       => 'finalize_registration',
322 322
                     'has_hooks'  => false,
@@ -500,7 +500,7 @@  discard block
 block discarded – undo
500 500
             // DEBUG LOG
501 501
             //$this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ );
502 502
             // get reg form
503
-            if( ! $this->_check_form_submission()) {
503
+            if ( ! $this->_check_form_submission()) {
504 504
                 EED_Single_Page_Checkout::$_initialized = true;
505 505
                 return;
506 506
             }
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
         );
542 542
         // is session still valid ?
543 543
         if ($clear_session_requested
544
-            || ( EE_Registry::instance()->SSN->expired()
544
+            || (EE_Registry::instance()->SSN->expired()
545 545
               && EE_Registry::instance()->REQ->get('e_reg_url_link', '') === ''
546 546
             )
547 547
         ) {
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
             // EE_Registry::instance()->SSN->reset_cart();
551 551
             // EE_Registry::instance()->SSN->reset_checkout();
552 552
             // EE_Registry::instance()->SSN->reset_transaction();
553
-            if (! $clear_session_requested) {
553
+            if ( ! $clear_session_requested) {
554 554
                 EE_Error::add_attention(
555 555
                     EE_Registry::$i18n_js_strings['registration_expiration_notice'],
556 556
                     __FILE__, __FUNCTION__, __LINE__
@@ -741,7 +741,7 @@  discard block
 block discarded – undo
741 741
                     return false;
742 742
                 }
743 743
             }
744
-            if(isset($this->checkout->reg_steps['registration_confirmation'])){
744
+            if (isset($this->checkout->reg_steps['registration_confirmation'])) {
745 745
                 // skip the registration_confirmation page ?
746 746
                 if (EE_Registry::instance()->CFG->registration->skip_reg_confirmation) {
747 747
                     // just remove it from the reg steps array
@@ -1107,7 +1107,7 @@  discard block
 block discarded – undo
1107 1107
                     if ( ! $registration instanceof EE_Registration) {
1108 1108
                         throw new InvalidEntityException($registration, 'EE_Registration');
1109 1109
                     }
1110
-                    $registrations[ $registration->ID() ] = $registration;
1110
+                    $registrations[$registration->ID()] = $registration;
1111 1111
                 }
1112 1112
             }
1113 1113
             $registration_processor->fix_reg_final_price_rounding_issue($transaction);
@@ -1354,7 +1354,7 @@  discard block
 block discarded – undo
1354 1354
                         ) {
1355 1355
                             EE_Error::add_success(
1356 1356
                                 $this->checkout->current_step->success_message()
1357
-                                . '<br />' . $this->checkout->next_step->_instructions()
1357
+                                . '<br />'.$this->checkout->next_step->_instructions()
1358 1358
                             );
1359 1359
                         }
1360 1360
                         // pack it up, pack it in...
@@ -1498,7 +1498,7 @@  discard block
 block discarded – undo
1498 1498
         // load css
1499 1499
         wp_register_style(
1500 1500
             'single_page_checkout',
1501
-            SPCO_CSS_URL . 'single_page_checkout.css',
1501
+            SPCO_CSS_URL.'single_page_checkout.css',
1502 1502
             array('espresso_default'),
1503 1503
             EVENT_ESPRESSO_VERSION
1504 1504
         );
@@ -1506,21 +1506,21 @@  discard block
 block discarded – undo
1506 1506
         // load JS
1507 1507
         wp_register_script(
1508 1508
             'jquery_plugin',
1509
-            EE_THIRD_PARTY_URL . 'jquery	.plugin.min.js',
1509
+            EE_THIRD_PARTY_URL.'jquery	.plugin.min.js',
1510 1510
             array('jquery'),
1511 1511
             '1.0.1',
1512 1512
             true
1513 1513
         );
1514 1514
         wp_register_script(
1515 1515
             'jquery_countdown',
1516
-            EE_THIRD_PARTY_URL . 'jquery	.countdown.min.js',
1516
+            EE_THIRD_PARTY_URL.'jquery	.countdown.min.js',
1517 1517
             array('jquery_plugin'),
1518 1518
             '2.0.2',
1519 1519
             true
1520 1520
         );
1521 1521
         wp_register_script(
1522 1522
             'single_page_checkout',
1523
-            SPCO_JS_URL . 'single_page_checkout.js',
1523
+            SPCO_JS_URL.'single_page_checkout.js',
1524 1524
             array('espresso_core', 'underscore', 'ee_form_section_validation', 'jquery_countdown'),
1525 1525
             EVENT_ESPRESSO_VERSION,
1526 1526
             true
@@ -1543,7 +1543,7 @@  discard block
 block discarded – undo
1543 1543
          *      AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__attendee_information
1544 1544
          */
1545 1545
         do_action(
1546
-            'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__' . $this->checkout->current_step->slug(),
1546
+            'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__'.$this->checkout->current_step->slug(),
1547 1547
             $this
1548 1548
         );
1549 1549
     }
@@ -1597,7 +1597,7 @@  discard block
 block discarded – undo
1597 1597
                     'layout_strategy' =>
1598 1598
                         new EE_Template_Layout(
1599 1599
                             array(
1600
-                                'layout_template_file' => SPCO_TEMPLATES_PATH . 'registration_page_wrapper.template.php',
1600
+                                'layout_template_file' => SPCO_TEMPLATES_PATH.'registration_page_wrapper.template.php',
1601 1601
                                 'template_args'        => array(
1602 1602
                                     'empty_cart'              => $empty_cart,
1603 1603
                                     'revisit'                 => $this->checkout->revisit,
@@ -1671,7 +1671,7 @@  discard block
 block discarded – undo
1671 1671
         ) {
1672 1672
             add_filter(
1673 1673
                 'FHEE__EEH_Template__powered_by_event_espresso__url',
1674
-                function ($url) {
1674
+                function($url) {
1675 1675
                     return apply_filters('FHEE__EE_Front_Controller__registration_footer__url', $url);
1676 1676
                 }
1677 1677
             );
@@ -1850,7 +1850,7 @@  discard block
 block discarded – undo
1850 1850
             '</h4>',
1851 1851
             '<br />',
1852 1852
             '<p>',
1853
-            '<a href="' . get_post_type_archive_link('espresso_events') . '" title="',
1853
+            '<a href="'.get_post_type_archive_link('espresso_events').'" title="',
1854 1854
             '">',
1855 1855
             '</a>',
1856 1856
             '</p>'
Please login to merge, or discard this patch.