Completed
Branch FET-9222-rest-api-writes (1e6651)
by
unknown
81:25 queued 66:40
created
core/services/assets/Registry.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
         global $wp_version;
72 72
         wp_register_script(
73 73
             'eejs-core',
74
-            EE_PLUGIN_DIR_URL . 'core/services/assets/core_assets/eejs-core.js',
74
+            EE_PLUGIN_DIR_URL.'core/services/assets/core_assets/eejs-core.js',
75 75
             array(),
76 76
             EVENT_ESPRESSO_VERSION,
77 77
             true
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
             //js.api
82 82
             wp_register_script(
83 83
                 'eejs-api',
84
-                EE_LIBRARIES_URL . 'rest_api/assets/js/eejs-api.min.js',
84
+                EE_LIBRARIES_URL.'rest_api/assets/js/eejs-api.min.js',
85 85
                 array('underscore', 'eejs-core'),
86 86
                 EVENT_ESPRESSO_VERSION,
87 87
                 true
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
             $this->jsdata['eejs_api_nonce'] = wp_create_nonce('wp_rest');
90 90
             $this->jsdata['paths'] = array('rest_route' => rest_url('ee/v4.8.36/'));
91 91
         }
92
-        if (! is_admin()) {
92
+        if ( ! is_admin()) {
93 93
             $this->loadCoreCss();
94 94
         }
95 95
         $this->loadCoreJs();
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
      */
183 183
     public function addTemplate($template_reference, $template_content)
184 184
     {
185
-        if (! isset($this->jsdata['templates'])) {
185
+        if ( ! isset($this->jsdata['templates'])) {
186 186
             $this->jsdata['templates'] = array();
187 187
         }
188 188
         //no overrides allowed.
@@ -279,9 +279,9 @@  discard block
 block discarded – undo
279 279
     private function loadCoreCss()
280 280
     {
281 281
         if ($this->template_config->enable_default_style) {
282
-            $default_stylesheet_path = is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')
283
-                ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css'
284
-                : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css';
282
+            $default_stylesheet_path = is_readable(EVENT_ESPRESSO_UPLOAD_DIR.'css/style.css')
283
+                ? EVENT_ESPRESSO_UPLOAD_DIR.'css/espresso_default.css'
284
+                : EE_GLOBAL_ASSETS_URL.'css/espresso_default.css';
285 285
             wp_register_style(
286 286
                 'espresso_default',
287 287
                 $default_stylesheet_path,
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
             if ($this->template_config->custom_style_sheet !== null) {
293 293
                 wp_register_style(
294 294
                     'espresso_custom_css',
295
-                    EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet,
295
+                    EVENT_ESPRESSO_UPLOAD_URL.'css/'.$this->template_config->custom_style_sheet,
296 296
                     array('espresso_default'),
297 297
                     EVENT_ESPRESSO_VERSION
298 298
                 );
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
         // load core js
311 311
         wp_register_script(
312 312
             'espresso_core',
313
-            EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
313
+            EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js',
314 314
             array('jquery'),
315 315
             EVENT_ESPRESSO_VERSION,
316 316
             true
@@ -328,14 +328,14 @@  discard block
 block discarded – undo
328 328
         // register jQuery Validate and additional methods
329 329
         wp_register_script(
330 330
             'jquery-validate',
331
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js',
331
+            EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.min.js',
332 332
             array('jquery'),
333 333
             '1.15.0',
334 334
             true
335 335
         );
336 336
         wp_register_script(
337 337
             'jquery-validate-extra-methods',
338
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js',
338
+            EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.additional-methods.min.js',
339 339
             array('jquery', 'jquery-validate'),
340 340
             '1.15.0',
341 341
             true
@@ -353,14 +353,14 @@  discard block
 block discarded – undo
353 353
         // @link http://josscrowcroft.github.io/accounting.js/
354 354
         wp_register_script(
355 355
             'ee-accounting-core',
356
-            EE_THIRD_PARTY_URL . 'accounting/accounting.js',
356
+            EE_THIRD_PARTY_URL.'accounting/accounting.js',
357 357
             array('underscore'),
358 358
             '0.3.2',
359 359
             true
360 360
         );
361 361
         wp_register_script(
362 362
             'ee-accounting',
363
-            EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js',
363
+            EE_GLOBAL_ASSETS_URL.'scripts/ee-accounting-config.js',
364 364
             array('ee-accounting-core'),
365 365
             EVENT_ESPRESSO_VERSION,
366 366
             true
Please login to merge, or discard this patch.
Indentation   +384 added lines, -384 removed lines patch added patch discarded remove patch
@@ -23,394 +23,394 @@
 block discarded – undo
23 23
 class Registry
24 24
 {
25 25
 
26
-    /**
27
-     * @var EE_Template_Config $template_config
28
-     */
29
-    protected $template_config;
30
-
31
-    /**
32
-     * @var EE_Currency_Config $currency_config
33
-     */
34
-    protected $currency_config;
35
-
36
-    /**
37
-     * This holds the jsdata data object that will be exposed on pages that enqueue the `eejs-core` script.
38
-     *
39
-     * @var array
40
-     */
41
-    protected $jsdata = array();
42
-
43
-
44
-
45
-    /**
46
-     * Registry constructor.
47
-     * Hooking into WP actions for script registry.
48
-     *
49
-     * @param EE_Template_Config $template_config
50
-     * @param EE_Currency_Config $currency_config
51
-     */
52
-    public function __construct(EE_Template_Config $template_config, EE_Currency_Config $currency_config)
53
-    {
54
-        $this->template_config = $template_config;
55
-        $this->currency_config = $currency_config;
56
-        add_action('wp_enqueue_scripts', array($this, 'scripts'), 1);
57
-        add_action('admin_enqueue_scripts', array($this, 'scripts'), 1);
58
-        add_action('wp_print_footer_scripts', array($this, 'enqueueData'), 1);
59
-        add_action('admin_print_footer_scripts', array($this, 'enqueueData'), 1);
60
-    }
61
-
62
-
63
-
64
-    /**
65
-     * Callback for the WP script actions.
66
-     * Used to register globally accessible core scripts.
67
-     * Also used to add the eejs.data object to the source for any js having eejs-core as a dependency.
68
-     */
69
-    public function scripts()
70
-    {
71
-        global $wp_version;
72
-        wp_register_script(
73
-            'eejs-core',
74
-            EE_PLUGIN_DIR_URL . 'core/services/assets/core_assets/eejs-core.js',
75
-            array(),
76
-            EVENT_ESPRESSO_VERSION,
77
-            true
78
-        );
79
-        //only run this if WordPress 4.4.0 > is in use.
80
-        if (version_compare($wp_version, '4.4.0', '>')) {
81
-            //js.api
82
-            wp_register_script(
83
-                'eejs-api',
84
-                EE_LIBRARIES_URL . 'rest_api/assets/js/eejs-api.min.js',
85
-                array('underscore', 'eejs-core'),
86
-                EVENT_ESPRESSO_VERSION,
87
-                true
88
-            );
89
-            $this->jsdata['eejs_api_nonce'] = wp_create_nonce('wp_rest');
90
-            $this->jsdata['paths'] = array('rest_route' => rest_url('ee/v4.8.36/'));
91
-        }
92
-        if (! is_admin()) {
93
-            $this->loadCoreCss();
94
-        }
95
-        $this->loadCoreJs();
96
-        $this->loadJqueryValidate();
97
-        $this->loadAccountingJs();
98
-        $this->loadQtipJs();
99
-    }
100
-
101
-
102
-
103
-    /**
104
-     * Call back for the script print in frontend and backend.
105
-     * Used to call wp_localize_scripts so that data can be added throughout the runtime until this later hook point.
106
-     *
107
-     * @since 4.9.31.rc.015
108
-     */
109
-    public function enqueueData()
110
-    {
111
-        wp_localize_script('eejs-core', 'eejs', array('data' => $this->jsdata));
112
-        wp_localize_script('espresso_core', 'eei18n', EE_Registry::$i18n_js_strings);
113
-        $this->localizeAccountingJs();
114
-    }
115
-
116
-
117
-
118
-    /**
119
-     * Used to add data to eejs.data object.
120
-     * Note:  Overriding existing data is not allowed.
121
-     * Data will be accessible as a javascript object when you list `eejs-core` as a dependency for your javascript.
122
-     * If the data you add is something like this:
123
-     *  $this->addData( 'my_plugin_data', array( 'foo' => 'gar' ) );
124
-     * It will be exposed in the page source as:
125
-     *  eejs.data.my_plugin_data.foo == gar
126
-     *
127
-     * @param string       $key   Key used to access your data
128
-     * @param string|array $value Value to attach to key
129
-     * @throws InvalidArgumentException
130
-     */
131
-    public function addData($key, $value)
132
-    {
133
-        if ($this->verifyDataNotExisting($key)) {
134
-            $this->jsdata[$key] = $value;
135
-        }
136
-    }
137
-
138
-
139
-
140
-    /**
141
-     * Similar to addData except this allows for users to push values to an existing key where the values on key are
142
-     * elements in an array.
143
-     * When you use this method, the value you include will be appended to the end of an array on $key.
144
-     * So if the $key was 'test' and you added a value of 'my_data' then it would be represented in the javascript
145
-     * object like this, eejs.data.test = [ my_data,
146
-     * ]
147
-     * If there has already been a scalar value attached to the data object given key, then
148
-     * this will throw an exception.
149
-     *
150
-     * @param string       $key   Key to attach data to.
151
-     * @param string|array $value Value being registered.
152
-     * @throws InvalidArgumentException
153
-     */
154
-    public function pushData($key, $value)
155
-    {
156
-        if (isset($this->jsdata[$key])
157
-            && ! is_array($this->jsdata[$key])
158
-        ) {
159
-            throw new invalidArgumentException(
160
-                sprintf(
161
-                    __(
162
-                        'The value for %1$s is already set and it is not an array. The %2$s method can only be used to
26
+	/**
27
+	 * @var EE_Template_Config $template_config
28
+	 */
29
+	protected $template_config;
30
+
31
+	/**
32
+	 * @var EE_Currency_Config $currency_config
33
+	 */
34
+	protected $currency_config;
35
+
36
+	/**
37
+	 * This holds the jsdata data object that will be exposed on pages that enqueue the `eejs-core` script.
38
+	 *
39
+	 * @var array
40
+	 */
41
+	protected $jsdata = array();
42
+
43
+
44
+
45
+	/**
46
+	 * Registry constructor.
47
+	 * Hooking into WP actions for script registry.
48
+	 *
49
+	 * @param EE_Template_Config $template_config
50
+	 * @param EE_Currency_Config $currency_config
51
+	 */
52
+	public function __construct(EE_Template_Config $template_config, EE_Currency_Config $currency_config)
53
+	{
54
+		$this->template_config = $template_config;
55
+		$this->currency_config = $currency_config;
56
+		add_action('wp_enqueue_scripts', array($this, 'scripts'), 1);
57
+		add_action('admin_enqueue_scripts', array($this, 'scripts'), 1);
58
+		add_action('wp_print_footer_scripts', array($this, 'enqueueData'), 1);
59
+		add_action('admin_print_footer_scripts', array($this, 'enqueueData'), 1);
60
+	}
61
+
62
+
63
+
64
+	/**
65
+	 * Callback for the WP script actions.
66
+	 * Used to register globally accessible core scripts.
67
+	 * Also used to add the eejs.data object to the source for any js having eejs-core as a dependency.
68
+	 */
69
+	public function scripts()
70
+	{
71
+		global $wp_version;
72
+		wp_register_script(
73
+			'eejs-core',
74
+			EE_PLUGIN_DIR_URL . 'core/services/assets/core_assets/eejs-core.js',
75
+			array(),
76
+			EVENT_ESPRESSO_VERSION,
77
+			true
78
+		);
79
+		//only run this if WordPress 4.4.0 > is in use.
80
+		if (version_compare($wp_version, '4.4.0', '>')) {
81
+			//js.api
82
+			wp_register_script(
83
+				'eejs-api',
84
+				EE_LIBRARIES_URL . 'rest_api/assets/js/eejs-api.min.js',
85
+				array('underscore', 'eejs-core'),
86
+				EVENT_ESPRESSO_VERSION,
87
+				true
88
+			);
89
+			$this->jsdata['eejs_api_nonce'] = wp_create_nonce('wp_rest');
90
+			$this->jsdata['paths'] = array('rest_route' => rest_url('ee/v4.8.36/'));
91
+		}
92
+		if (! is_admin()) {
93
+			$this->loadCoreCss();
94
+		}
95
+		$this->loadCoreJs();
96
+		$this->loadJqueryValidate();
97
+		$this->loadAccountingJs();
98
+		$this->loadQtipJs();
99
+	}
100
+
101
+
102
+
103
+	/**
104
+	 * Call back for the script print in frontend and backend.
105
+	 * Used to call wp_localize_scripts so that data can be added throughout the runtime until this later hook point.
106
+	 *
107
+	 * @since 4.9.31.rc.015
108
+	 */
109
+	public function enqueueData()
110
+	{
111
+		wp_localize_script('eejs-core', 'eejs', array('data' => $this->jsdata));
112
+		wp_localize_script('espresso_core', 'eei18n', EE_Registry::$i18n_js_strings);
113
+		$this->localizeAccountingJs();
114
+	}
115
+
116
+
117
+
118
+	/**
119
+	 * Used to add data to eejs.data object.
120
+	 * Note:  Overriding existing data is not allowed.
121
+	 * Data will be accessible as a javascript object when you list `eejs-core` as a dependency for your javascript.
122
+	 * If the data you add is something like this:
123
+	 *  $this->addData( 'my_plugin_data', array( 'foo' => 'gar' ) );
124
+	 * It will be exposed in the page source as:
125
+	 *  eejs.data.my_plugin_data.foo == gar
126
+	 *
127
+	 * @param string       $key   Key used to access your data
128
+	 * @param string|array $value Value to attach to key
129
+	 * @throws InvalidArgumentException
130
+	 */
131
+	public function addData($key, $value)
132
+	{
133
+		if ($this->verifyDataNotExisting($key)) {
134
+			$this->jsdata[$key] = $value;
135
+		}
136
+	}
137
+
138
+
139
+
140
+	/**
141
+	 * Similar to addData except this allows for users to push values to an existing key where the values on key are
142
+	 * elements in an array.
143
+	 * When you use this method, the value you include will be appended to the end of an array on $key.
144
+	 * So if the $key was 'test' and you added a value of 'my_data' then it would be represented in the javascript
145
+	 * object like this, eejs.data.test = [ my_data,
146
+	 * ]
147
+	 * If there has already been a scalar value attached to the data object given key, then
148
+	 * this will throw an exception.
149
+	 *
150
+	 * @param string       $key   Key to attach data to.
151
+	 * @param string|array $value Value being registered.
152
+	 * @throws InvalidArgumentException
153
+	 */
154
+	public function pushData($key, $value)
155
+	{
156
+		if (isset($this->jsdata[$key])
157
+			&& ! is_array($this->jsdata[$key])
158
+		) {
159
+			throw new invalidArgumentException(
160
+				sprintf(
161
+					__(
162
+						'The value for %1$s is already set and it is not an array. The %2$s method can only be used to
163 163
                          push values to this data element when it is an array.',
164
-                        'event_espresso'
165
-                    ),
166
-                    $key,
167
-                    __METHOD__
168
-                )
169
-            );
170
-        }
171
-        $this->jsdata[$key][] = $value;
172
-    }
173
-
174
-
175
-
176
-    /**
177
-     * Used to set content used by javascript for a template.
178
-     * Note: Overrides of existing registered templates are not allowed.
179
-     *
180
-     * @param string $template_reference
181
-     * @param string $template_content
182
-     * @throws InvalidArgumentException
183
-     */
184
-    public function addTemplate($template_reference, $template_content)
185
-    {
186
-        if (! isset($this->jsdata['templates'])) {
187
-            $this->jsdata['templates'] = array();
188
-        }
189
-        //no overrides allowed.
190
-        if (isset($this->jsdata['templates'][$template_reference])) {
191
-            throw new invalidArgumentException(
192
-                sprintf(
193
-                    __(
194
-                        'The %1$s key already exists for the templates array in the js data array.  No overrides are allowed.',
195
-                        'event_espresso'
196
-                    ),
197
-                    $template_reference
198
-                )
199
-            );
200
-        }
201
-        $this->jsdata['templates'][$template_reference] = $template_content;
202
-    }
203
-
204
-
205
-
206
-    /**
207
-     * Retrieve the template content already registered for the given reference.
208
-     *
209
-     * @param string $template_reference
210
-     * @return string
211
-     */
212
-    public function getTemplate($template_reference)
213
-    {
214
-        return isset($this->jsdata['templates'], $this->jsdata['templates'][$template_reference])
215
-            ? $this->jsdata['templates'][$template_reference]
216
-            : '';
217
-    }
218
-
219
-
220
-
221
-    /**
222
-     * Retrieve registered data.
223
-     *
224
-     * @param string $key Name of key to attach data to.
225
-     * @return mixed                If there is no for the given key, then false is returned.
226
-     */
227
-    public function getData($key)
228
-    {
229
-        return isset($this->jsdata[$key])
230
-            ? $this->jsdata[$key]
231
-            : false;
232
-    }
233
-
234
-
235
-
236
-    /**
237
-     * Verifies whether the given data exists already on the jsdata array.
238
-     * Overriding data is not allowed.
239
-     *
240
-     * @param string $key Index for data.
241
-     * @return bool        If valid then return true.
242
-     * @throws InvalidArgumentException if data already exists.
243
-     */
244
-    protected function verifyDataNotExisting($key)
245
-    {
246
-        if (isset($this->jsdata[$key])) {
247
-            if (is_array($this->jsdata[$key])) {
248
-                throw new InvalidArgumentException(
249
-                    sprintf(
250
-                        __(
251
-                            'The value for %1$s already exists in the Registry::eejs object.
164
+						'event_espresso'
165
+					),
166
+					$key,
167
+					__METHOD__
168
+				)
169
+			);
170
+		}
171
+		$this->jsdata[$key][] = $value;
172
+	}
173
+
174
+
175
+
176
+	/**
177
+	 * Used to set content used by javascript for a template.
178
+	 * Note: Overrides of existing registered templates are not allowed.
179
+	 *
180
+	 * @param string $template_reference
181
+	 * @param string $template_content
182
+	 * @throws InvalidArgumentException
183
+	 */
184
+	public function addTemplate($template_reference, $template_content)
185
+	{
186
+		if (! isset($this->jsdata['templates'])) {
187
+			$this->jsdata['templates'] = array();
188
+		}
189
+		//no overrides allowed.
190
+		if (isset($this->jsdata['templates'][$template_reference])) {
191
+			throw new invalidArgumentException(
192
+				sprintf(
193
+					__(
194
+						'The %1$s key already exists for the templates array in the js data array.  No overrides are allowed.',
195
+						'event_espresso'
196
+					),
197
+					$template_reference
198
+				)
199
+			);
200
+		}
201
+		$this->jsdata['templates'][$template_reference] = $template_content;
202
+	}
203
+
204
+
205
+
206
+	/**
207
+	 * Retrieve the template content already registered for the given reference.
208
+	 *
209
+	 * @param string $template_reference
210
+	 * @return string
211
+	 */
212
+	public function getTemplate($template_reference)
213
+	{
214
+		return isset($this->jsdata['templates'], $this->jsdata['templates'][$template_reference])
215
+			? $this->jsdata['templates'][$template_reference]
216
+			: '';
217
+	}
218
+
219
+
220
+
221
+	/**
222
+	 * Retrieve registered data.
223
+	 *
224
+	 * @param string $key Name of key to attach data to.
225
+	 * @return mixed                If there is no for the given key, then false is returned.
226
+	 */
227
+	public function getData($key)
228
+	{
229
+		return isset($this->jsdata[$key])
230
+			? $this->jsdata[$key]
231
+			: false;
232
+	}
233
+
234
+
235
+
236
+	/**
237
+	 * Verifies whether the given data exists already on the jsdata array.
238
+	 * Overriding data is not allowed.
239
+	 *
240
+	 * @param string $key Index for data.
241
+	 * @return bool        If valid then return true.
242
+	 * @throws InvalidArgumentException if data already exists.
243
+	 */
244
+	protected function verifyDataNotExisting($key)
245
+	{
246
+		if (isset($this->jsdata[$key])) {
247
+			if (is_array($this->jsdata[$key])) {
248
+				throw new InvalidArgumentException(
249
+					sprintf(
250
+						__(
251
+							'The value for %1$s already exists in the Registry::eejs object.
252 252
                             Overrides are not allowed. Since the value of this data is an array, you may want to use the
253 253
                             %2$s method to push your value to the array.',
254
-                            'event_espresso'
255
-                        ),
256
-                        $key,
257
-                        'pushData()'
258
-                    )
259
-                );
260
-            }
261
-            throw new InvalidArgumentException(
262
-                sprintf(
263
-                    __(
264
-                        'The value for %1$s already exists in the Registry::eejs object. Overrides are not
254
+							'event_espresso'
255
+						),
256
+						$key,
257
+						'pushData()'
258
+					)
259
+				);
260
+			}
261
+			throw new InvalidArgumentException(
262
+				sprintf(
263
+					__(
264
+						'The value for %1$s already exists in the Registry::eejs object. Overrides are not
265 265
                         allowed.  Consider attaching your value to a different key',
266
-                        'event_espresso'
267
-                    ),
268
-                    $key
269
-                )
270
-            );
271
-        }
272
-        return true;
273
-    }
274
-
275
-
276
-
277
-    /**
278
-     * registers core default stylesheets
279
-     */
280
-    private function loadCoreCss()
281
-    {
282
-        if ($this->template_config->enable_default_style) {
283
-            $default_stylesheet_path = is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')
284
-                ? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css'
285
-                : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css';
286
-            wp_register_style(
287
-                'espresso_default',
288
-                $default_stylesheet_path,
289
-                array('dashicons'),
290
-                EVENT_ESPRESSO_VERSION
291
-            );
292
-            //Load custom style sheet if available
293
-            if ($this->template_config->custom_style_sheet !== null) {
294
-                wp_register_style(
295
-                    'espresso_custom_css',
296
-                    EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet,
297
-                    array('espresso_default'),
298
-                    EVENT_ESPRESSO_VERSION
299
-                );
300
-            }
301
-        }
302
-    }
303
-
304
-
305
-
306
-    /**
307
-     * registers core default javascript
308
-     */
309
-    private function loadCoreJs()
310
-    {
311
-        // load core js
312
-        wp_register_script(
313
-            'espresso_core',
314
-            EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
315
-            array('jquery'),
316
-            EVENT_ESPRESSO_VERSION,
317
-            true
318
-        );
319
-    }
320
-
321
-
322
-
323
-    /**
324
-     * registers jQuery Validate for form validation
325
-     */
326
-    private function loadJqueryValidate()
327
-    {
328
-        // register jQuery Validate and additional methods
329
-        wp_register_script(
330
-            'jquery-validate',
331
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js',
332
-            array('jquery'),
333
-            '1.15.0',
334
-            true
335
-        );
336
-        wp_register_script(
337
-            'jquery-validate-extra-methods',
338
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js',
339
-            array('jquery', 'jquery-validate'),
340
-            '1.15.0',
341
-            true
342
-        );
343
-    }
344
-
345
-
346
-
347
-    /**
348
-     * registers accounting.js for performing client-side calculations
349
-     */
350
-    private function loadAccountingJs()
351
-    {
352
-        //accounting.js library
353
-        // @link http://josscrowcroft.github.io/accounting.js/
354
-        wp_register_script(
355
-            'ee-accounting-core',
356
-            EE_THIRD_PARTY_URL . 'accounting/accounting.js',
357
-            array('underscore'),
358
-            '0.3.2',
359
-            true
360
-        );
361
-        wp_register_script(
362
-            'ee-accounting',
363
-            EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js',
364
-            array('ee-accounting-core'),
365
-            EVENT_ESPRESSO_VERSION,
366
-            true
367
-        );
368
-    }
369
-
370
-
371
-
372
-    /**
373
-     * registers accounting.js for performing client-side calculations
374
-     */
375
-    private function localizeAccountingJs()
376
-    {
377
-        wp_localize_script(
378
-            'ee-accounting',
379
-            'EE_ACCOUNTING_CFG',
380
-            array(
381
-                'currency' => array(
382
-                    'symbol'    => $this->currency_config->sign,
383
-                    'format'    => array(
384
-                        'pos'  => $this->currency_config->sign_b4 ? '%s%v' : '%v%s',
385
-                        'neg'  => $this->currency_config->sign_b4 ? '- %s%v' : '- %v%s',
386
-                        'zero' => $this->currency_config->sign_b4 ? '%s--' : '--%s',
387
-                    ),
388
-                    'decimal'   => $this->currency_config->dec_mrk,
389
-                    'thousand'  => $this->currency_config->thsnds,
390
-                    'precision' => $this->currency_config->dec_plc,
391
-                ),
392
-                'number'   => array(
393
-                    'precision' => 0,
394
-                    'thousand'  => $this->currency_config->thsnds,
395
-                    'decimal'   => $this->currency_config->dec_mrk,
396
-                ),
397
-            )
398
-        );
399
-    }
400
-
401
-
402
-
403
-    /**
404
-     * registers assets for cleaning your ears
405
-     */
406
-    private function loadQtipJs()
407
-    {
408
-        // qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook,
409
-        // can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' );
410
-        if (apply_filters('FHEE_load_qtip', false)) {
411
-            EEH_Qtip_Loader::instance()->register_and_enqueue();
412
-        }
413
-    }
266
+						'event_espresso'
267
+					),
268
+					$key
269
+				)
270
+			);
271
+		}
272
+		return true;
273
+	}
274
+
275
+
276
+
277
+	/**
278
+	 * registers core default stylesheets
279
+	 */
280
+	private function loadCoreCss()
281
+	{
282
+		if ($this->template_config->enable_default_style) {
283
+			$default_stylesheet_path = is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')
284
+				? EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css'
285
+				: EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css';
286
+			wp_register_style(
287
+				'espresso_default',
288
+				$default_stylesheet_path,
289
+				array('dashicons'),
290
+				EVENT_ESPRESSO_VERSION
291
+			);
292
+			//Load custom style sheet if available
293
+			if ($this->template_config->custom_style_sheet !== null) {
294
+				wp_register_style(
295
+					'espresso_custom_css',
296
+					EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet,
297
+					array('espresso_default'),
298
+					EVENT_ESPRESSO_VERSION
299
+				);
300
+			}
301
+		}
302
+	}
303
+
304
+
305
+
306
+	/**
307
+	 * registers core default javascript
308
+	 */
309
+	private function loadCoreJs()
310
+	{
311
+		// load core js
312
+		wp_register_script(
313
+			'espresso_core',
314
+			EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
315
+			array('jquery'),
316
+			EVENT_ESPRESSO_VERSION,
317
+			true
318
+		);
319
+	}
320
+
321
+
322
+
323
+	/**
324
+	 * registers jQuery Validate for form validation
325
+	 */
326
+	private function loadJqueryValidate()
327
+	{
328
+		// register jQuery Validate and additional methods
329
+		wp_register_script(
330
+			'jquery-validate',
331
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js',
332
+			array('jquery'),
333
+			'1.15.0',
334
+			true
335
+		);
336
+		wp_register_script(
337
+			'jquery-validate-extra-methods',
338
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.additional-methods.min.js',
339
+			array('jquery', 'jquery-validate'),
340
+			'1.15.0',
341
+			true
342
+		);
343
+	}
344
+
345
+
346
+
347
+	/**
348
+	 * registers accounting.js for performing client-side calculations
349
+	 */
350
+	private function loadAccountingJs()
351
+	{
352
+		//accounting.js library
353
+		// @link http://josscrowcroft.github.io/accounting.js/
354
+		wp_register_script(
355
+			'ee-accounting-core',
356
+			EE_THIRD_PARTY_URL . 'accounting/accounting.js',
357
+			array('underscore'),
358
+			'0.3.2',
359
+			true
360
+		);
361
+		wp_register_script(
362
+			'ee-accounting',
363
+			EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js',
364
+			array('ee-accounting-core'),
365
+			EVENT_ESPRESSO_VERSION,
366
+			true
367
+		);
368
+	}
369
+
370
+
371
+
372
+	/**
373
+	 * registers accounting.js for performing client-side calculations
374
+	 */
375
+	private function localizeAccountingJs()
376
+	{
377
+		wp_localize_script(
378
+			'ee-accounting',
379
+			'EE_ACCOUNTING_CFG',
380
+			array(
381
+				'currency' => array(
382
+					'symbol'    => $this->currency_config->sign,
383
+					'format'    => array(
384
+						'pos'  => $this->currency_config->sign_b4 ? '%s%v' : '%v%s',
385
+						'neg'  => $this->currency_config->sign_b4 ? '- %s%v' : '- %v%s',
386
+						'zero' => $this->currency_config->sign_b4 ? '%s--' : '--%s',
387
+					),
388
+					'decimal'   => $this->currency_config->dec_mrk,
389
+					'thousand'  => $this->currency_config->thsnds,
390
+					'precision' => $this->currency_config->dec_plc,
391
+				),
392
+				'number'   => array(
393
+					'precision' => 0,
394
+					'thousand'  => $this->currency_config->thsnds,
395
+					'decimal'   => $this->currency_config->dec_mrk,
396
+				),
397
+			)
398
+		);
399
+	}
400
+
401
+
402
+
403
+	/**
404
+	 * registers assets for cleaning your ears
405
+	 */
406
+	private function loadQtipJs()
407
+	{
408
+		// qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook,
409
+		// can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' );
410
+		if (apply_filters('FHEE_load_qtip', false)) {
411
+			EEH_Qtip_Loader::instance()->register_and_enqueue();
412
+		}
413
+	}
414 414
 
415 415
 
416 416
 
Please login to merge, or discard this patch.
modules/single_page_checkout/EED_Single_Page_Checkout.module.php 2 patches
Indentation   +1849 added lines, -1849 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
 use EventEspresso\core\exceptions\InvalidEntityException;
6 6
 
7 7
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
8
-    exit('No direct script access allowed');
8
+	exit('No direct script access allowed');
9 9
 }
10 10
 
11 11
 
@@ -20,1854 +20,1854 @@  discard block
 block discarded – undo
20 20
 class EED_Single_Page_Checkout extends EED_Module
21 21
 {
22 22
 
23
-    /**
24
-     * $_initialized - has the SPCO controller already been initialized ?
25
-     *
26
-     * @access private
27
-     * @var bool $_initialized
28
-     */
29
-    private static $_initialized = false;
30
-
31
-
32
-    /**
33
-     * $_checkout_verified - is the EE_Checkout verified as correct for this request ?
34
-     *
35
-     * @access private
36
-     * @var bool $_valid_checkout
37
-     */
38
-    private static $_checkout_verified = true;
39
-
40
-    /**
41
-     *    $_reg_steps_array - holds initial array of reg steps
42
-     *
43
-     * @access private
44
-     * @var array $_reg_steps_array
45
-     */
46
-    private static $_reg_steps_array = array();
47
-
48
-    /**
49
-     *    $checkout - EE_Checkout object for handling the properties of the current checkout process
50
-     *
51
-     * @access public
52
-     * @var EE_Checkout $checkout
53
-     */
54
-    public $checkout;
55
-
56
-
57
-
58
-    /**
59
-     * @return EED_Module|EED_Single_Page_Checkout
60
-     */
61
-    public static function instance()
62
-    {
63
-        add_filter('EED_Single_Page_Checkout__SPCO_active', '__return_true');
64
-        return parent::get_instance(__CLASS__);
65
-    }
66
-
67
-
68
-
69
-    /**
70
-     * @return EE_CART
71
-     */
72
-    public function cart()
73
-    {
74
-        return $this->checkout->cart;
75
-    }
76
-
77
-
78
-
79
-    /**
80
-     * @return EE_Transaction
81
-     */
82
-    public function transaction()
83
-    {
84
-        return $this->checkout->transaction;
85
-    }
86
-
87
-
88
-
89
-    /**
90
-     *    set_hooks - for hooking into EE Core, other modules, etc
91
-     *
92
-     * @access    public
93
-     * @return    void
94
-     * @throws EE_Error
95
-     */
96
-    public static function set_hooks()
97
-    {
98
-        EED_Single_Page_Checkout::set_definitions();
99
-    }
100
-
101
-
102
-
103
-    /**
104
-     *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
105
-     *
106
-     * @access    public
107
-     * @return    void
108
-     * @throws EE_Error
109
-     */
110
-    public static function set_hooks_admin()
111
-    {
112
-        EED_Single_Page_Checkout::set_definitions();
113
-        if ( ! (defined('DOING_AJAX') && DOING_AJAX)) {
114
-            return;
115
-        }
116
-        // going to start an output buffer in case anything gets accidentally output
117
-        // that might disrupt our JSON response
118
-        ob_start();
119
-        EED_Single_Page_Checkout::load_request_handler();
120
-        EED_Single_Page_Checkout::load_reg_steps();
121
-        // set ajax hooks
122
-        add_action('wp_ajax_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step'));
123
-        add_action('wp_ajax_nopriv_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step'));
124
-        add_action('wp_ajax_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step'));
125
-        add_action('wp_ajax_nopriv_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step'));
126
-        add_action('wp_ajax_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step'));
127
-        add_action('wp_ajax_nopriv_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step'));
128
-    }
129
-
130
-
131
-
132
-    /**
133
-     *    process ajax request
134
-     *
135
-     * @param string $ajax_action
136
-     * @throws EE_Error
137
-     */
138
-    public static function process_ajax_request($ajax_action)
139
-    {
140
-        EE_Registry::instance()->REQ->set('action', $ajax_action);
141
-        EED_Single_Page_Checkout::instance()->_initialize();
142
-    }
143
-
144
-
145
-
146
-    /**
147
-     *    ajax display registration step
148
-     *
149
-     * @throws EE_Error
150
-     */
151
-    public static function display_reg_step()
152
-    {
153
-        EED_Single_Page_Checkout::process_ajax_request('display_spco_reg_step');
154
-    }
155
-
156
-
157
-
158
-    /**
159
-     *    ajax process registration step
160
-     *
161
-     * @throws EE_Error
162
-     */
163
-    public static function process_reg_step()
164
-    {
165
-        EED_Single_Page_Checkout::process_ajax_request('process_reg_step');
166
-    }
167
-
168
-
169
-
170
-    /**
171
-     *    ajax process registration step
172
-     *
173
-     * @throws EE_Error
174
-     */
175
-    public static function update_reg_step()
176
-    {
177
-        EED_Single_Page_Checkout::process_ajax_request('update_reg_step');
178
-    }
179
-
180
-
181
-
182
-    /**
183
-     *   update_checkout
184
-     *
185
-     * @access public
186
-     * @return void
187
-     * @throws EE_Error
188
-     */
189
-    public static function update_checkout()
190
-    {
191
-        EED_Single_Page_Checkout::process_ajax_request('update_checkout');
192
-    }
193
-
194
-
195
-
196
-    /**
197
-     *    load_request_handler
198
-     *
199
-     * @access    public
200
-     * @return    void
201
-     */
202
-    public static function load_request_handler()
203
-    {
204
-        // load core Request_Handler class
205
-        if (EE_Registry::instance()->REQ !== null) {
206
-            EE_Registry::instance()->load_core('Request_Handler');
207
-        }
208
-    }
209
-
210
-
211
-
212
-    /**
213
-     *    set_definitions
214
-     *
215
-     * @access    public
216
-     * @return    void
217
-     * @throws EE_Error
218
-     */
219
-    public static function set_definitions()
220
-    {
221
-        if(defined('SPCO_BASE_PATH')) {
222
-            return;
223
-        }
224
-        define(
225
-            'SPCO_BASE_PATH',
226
-            rtrim(str_replace(array('\\', '/'), DS, plugin_dir_path(__FILE__)), DS) . DS
227
-        );
228
-        define('SPCO_CSS_URL', plugin_dir_url(__FILE__) . 'css' . DS);
229
-        define('SPCO_IMG_URL', plugin_dir_url(__FILE__) . 'img' . DS);
230
-        define('SPCO_JS_URL', plugin_dir_url(__FILE__) . 'js' . DS);
231
-        define('SPCO_INC_PATH', SPCO_BASE_PATH . 'inc' . DS);
232
-        define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH . 'reg_steps' . DS);
233
-        define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH . 'templates' . DS);
234
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(SPCO_BASE_PATH, true);
235
-        EE_Registry::$i18n_js_strings['registration_expiration_notice'] = sprintf(
236
-            __('%1$sWe\'re sorry, but you\'re registration time has expired.%2$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 except our apologies for any inconvenience this may have caused.%8$s',
237
-                'event_espresso'),
238
-            '<h4 class="important-notice">',
239
-            '</h4>',
240
-            '<br />',
241
-            '<p>',
242
-            '<a href="' . get_post_type_archive_link('espresso_events') . '" title="',
243
-            '">',
244
-            '</a>',
245
-            '</p>'
246
-        );
247
-    }
248
-
249
-
250
-
251
-    /**
252
-     * load_reg_steps
253
-     * loads and instantiates each reg step based on the EE_Registry::instance()->CFG->registration->reg_steps array
254
-     *
255
-     * @access    private
256
-     * @throws EE_Error
257
-     */
258
-    public static function load_reg_steps()
259
-    {
260
-        static $reg_steps_loaded = false;
261
-        if ($reg_steps_loaded) {
262
-            return;
263
-        }
264
-        // filter list of reg_steps
265
-        $reg_steps_to_load = (array)apply_filters(
266
-            'AHEE__SPCO__load_reg_steps__reg_steps_to_load',
267
-            EED_Single_Page_Checkout::get_reg_steps()
268
-        );
269
-        // sort by key (order)
270
-        ksort($reg_steps_to_load);
271
-        // loop through folders
272
-        foreach ($reg_steps_to_load as $order => $reg_step) {
273
-            // we need a
274
-            if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) {
275
-                // copy over to the reg_steps_array
276
-                EED_Single_Page_Checkout::$_reg_steps_array[$order] = $reg_step;
277
-                // register custom key route for each reg step
278
-                // ie: step=>"slug" - this is the entire reason we load the reg steps array now
279
-                EE_Config::register_route(
280
-                    $reg_step['slug'],
281
-                    'EED_Single_Page_Checkout',
282
-                    'run',
283
-                    'step'
284
-                );
285
-                // add AJAX or other hooks
286
-                if (isset($reg_step['has_hooks']) && $reg_step['has_hooks']) {
287
-                    // setup autoloaders if necessary
288
-                    if ( ! class_exists($reg_step['class_name'])) {
289
-                        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(
290
-                            $reg_step['file_path'],
291
-                            true
292
-                        );
293
-                    }
294
-                    if (is_callable($reg_step['class_name'], 'set_hooks')) {
295
-                        call_user_func(array($reg_step['class_name'], 'set_hooks'));
296
-                    }
297
-                }
298
-            }
299
-        }
300
-        $reg_steps_loaded = true;
301
-    }
302
-
303
-
304
-
305
-    /**
306
-     *    get_reg_steps
307
-     *
308
-     * @access    public
309
-     * @return    array
310
-     */
311
-    public static function get_reg_steps()
312
-    {
313
-        $reg_steps = EE_Registry::instance()->CFG->registration->reg_steps;
314
-        if (empty($reg_steps)) {
315
-            $reg_steps = array(
316
-                10  => array(
317
-                    'file_path'  => SPCO_REG_STEPS_PATH . 'attendee_information',
318
-                    'class_name' => 'EE_SPCO_Reg_Step_Attendee_Information',
319
-                    'slug'       => 'attendee_information',
320
-                    'has_hooks'  => false,
321
-                ),
322
-                20  => array(
323
-                    'file_path'  => SPCO_REG_STEPS_PATH . 'registration_confirmation',
324
-                    'class_name' => 'EE_SPCO_Reg_Step_Registration_Confirmation',
325
-                    'slug'       => 'registration_confirmation',
326
-                    'has_hooks'  => false,
327
-                ),
328
-                30  => array(
329
-                    'file_path'  => SPCO_REG_STEPS_PATH . 'payment_options',
330
-                    'class_name' => 'EE_SPCO_Reg_Step_Payment_Options',
331
-                    'slug'       => 'payment_options',
332
-                    'has_hooks'  => true,
333
-                ),
334
-                999 => array(
335
-                    'file_path'  => SPCO_REG_STEPS_PATH . 'finalize_registration',
336
-                    'class_name' => 'EE_SPCO_Reg_Step_Finalize_Registration',
337
-                    'slug'       => 'finalize_registration',
338
-                    'has_hooks'  => false,
339
-                ),
340
-            );
341
-        }
342
-        return $reg_steps;
343
-    }
344
-
345
-
346
-
347
-    /**
348
-     *    registration_checkout_for_admin
349
-     *
350
-     * @access    public
351
-     * @return    string
352
-     * @throws EE_Error
353
-     */
354
-    public static function registration_checkout_for_admin()
355
-    {
356
-        EED_Single_Page_Checkout::load_request_handler();
357
-        EE_Registry::instance()->REQ->set('step', 'attendee_information');
358
-        EE_Registry::instance()->REQ->set('action', 'display_spco_reg_step');
359
-        EE_Registry::instance()->REQ->set('process_form_submission', false);
360
-        EED_Single_Page_Checkout::instance()->_initialize();
361
-        EED_Single_Page_Checkout::instance()->_display_spco_reg_form();
362
-        return EE_Registry::instance()->REQ->get_output();
363
-    }
364
-
365
-
366
-
367
-    /**
368
-     * process_registration_from_admin
369
-     *
370
-     * @access public
371
-     * @return \EE_Transaction
372
-     * @throws EE_Error
373
-     */
374
-    public static function process_registration_from_admin()
375
-    {
376
-        EED_Single_Page_Checkout::load_request_handler();
377
-        EE_Registry::instance()->REQ->set('step', 'attendee_information');
378
-        EE_Registry::instance()->REQ->set('action', 'process_reg_step');
379
-        EE_Registry::instance()->REQ->set('process_form_submission', true);
380
-        EED_Single_Page_Checkout::instance()->_initialize();
381
-        if (EED_Single_Page_Checkout::instance()->checkout->current_step->completed()) {
382
-            $final_reg_step = end(EED_Single_Page_Checkout::instance()->checkout->reg_steps);
383
-            if ($final_reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration) {
384
-                EED_Single_Page_Checkout::instance()->checkout->set_reg_step_initiated($final_reg_step);
385
-                if ($final_reg_step->process_reg_step()) {
386
-                    $final_reg_step->set_completed();
387
-                    EED_Single_Page_Checkout::instance()->checkout->update_txn_reg_steps_array();
388
-                    return EED_Single_Page_Checkout::instance()->checkout->transaction;
389
-                }
390
-            }
391
-        }
392
-        return null;
393
-    }
394
-
395
-
396
-
397
-    /**
398
-     *    run
399
-     *
400
-     * @access    public
401
-     * @param WP_Query $WP_Query
402
-     * @return    void
403
-     * @throws EE_Error
404
-     */
405
-    public function run($WP_Query)
406
-    {
407
-        if (
408
-            $WP_Query instanceof WP_Query
409
-            && $WP_Query->is_main_query()
410
-            && apply_filters('FHEE__EED_Single_Page_Checkout__run', true)
411
-            && $this->_is_reg_checkout()
412
-        ) {
413
-            $this->_initialize();
414
-        }
415
-    }
416
-
417
-
418
-
419
-    /**
420
-     * determines whether current url matches reg page url
421
-     *
422
-     * @return bool
423
-     */
424
-    protected function _is_reg_checkout()
425
-    {
426
-        // get current permalink for reg page without any extra query args
427
-        $reg_page_url = \get_permalink(EE_Config::instance()->core->reg_page_id);
428
-        // get request URI for current request, but without the scheme or host
429
-        $current_request_uri = \EEH_URL::filter_input_server_url('REQUEST_URI');
430
-        $current_request_uri = html_entity_decode($current_request_uri);
431
-        // get array of query args from the current request URI
432
-        $query_args = \EEH_URL::get_query_string($current_request_uri);
433
-        // grab page id if it is set
434
-        $page_id = isset($query_args['page_id']) ? absint($query_args['page_id']) : 0;
435
-        // and remove the page id from the query args (we will re-add it later)
436
-        unset($query_args['page_id']);
437
-        // now strip all query args from current request URI
438
-        $current_request_uri = remove_query_arg(array_keys($query_args), $current_request_uri);
439
-        // and re-add the page id if it was set
440
-        if ($page_id) {
441
-            $current_request_uri = add_query_arg('page_id', $page_id, $current_request_uri);
442
-        }
443
-        // remove slashes and ?
444
-        $current_request_uri = trim($current_request_uri, '?/');
445
-        // is current request URI part of the known full reg page URL ?
446
-        return ! empty($current_request_uri) && strpos($reg_page_url, $current_request_uri) !== false;
447
-    }
448
-
449
-
450
-
451
-    /**
452
-     * @param WP_Query $wp_query
453
-     * @return    void
454
-     * @throws EE_Error
455
-     */
456
-    public static function init($wp_query)
457
-    {
458
-        EED_Single_Page_Checkout::instance()->run($wp_query);
459
-    }
460
-
461
-
462
-
463
-    /**
464
-     *    _initialize - initial module setup
465
-     *
466
-     * @access    private
467
-     * @throws EE_Error
468
-     * @return    void
469
-     */
470
-    private function _initialize()
471
-    {
472
-        // ensure SPCO doesn't run twice
473
-        if (EED_Single_Page_Checkout::$_initialized) {
474
-            return;
475
-        }
476
-        try {
477
-            EED_Single_Page_Checkout::load_reg_steps();
478
-            $this->_verify_session();
479
-            // setup the EE_Checkout object
480
-            $this->checkout = $this->_initialize_checkout();
481
-            // filter checkout
482
-            $this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout);
483
-            // get the $_GET
484
-            $this->_get_request_vars();
485
-            if ($this->_block_bots()) {
486
-                return;
487
-            }
488
-            // filter continue_reg
489
-            $this->checkout->continue_reg = apply_filters(
490
-                'FHEE__EED_Single_Page_Checkout__init___continue_reg',
491
-                true,
492
-                $this->checkout
493
-            );
494
-            // load the reg steps array
495
-            if ( ! $this->_load_and_instantiate_reg_steps()) {
496
-                EED_Single_Page_Checkout::$_initialized = true;
497
-                return;
498
-            }
499
-            // set the current step
500
-            $this->checkout->set_current_step($this->checkout->step);
501
-            // and the next step
502
-            $this->checkout->set_next_step();
503
-            // verify that everything has been setup correctly
504
-            if ( ! ($this->_verify_transaction_and_get_registrations() && $this->_final_verifications())) {
505
-                EED_Single_Page_Checkout::$_initialized = true;
506
-                return;
507
-            }
508
-            // lock the transaction
509
-            $this->checkout->transaction->lock();
510
-            // make sure all of our cached objects are added to their respective model entity mappers
511
-            $this->checkout->refresh_all_entities();
512
-            // set amount owing
513
-            $this->checkout->amount_owing = $this->checkout->transaction->remaining();
514
-            // initialize each reg step, which gives them the chance to potentially alter the process
515
-            $this->_initialize_reg_steps();
516
-            // DEBUG LOG
517
-            //$this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ );
518
-            // get reg form
519
-            if( ! $this->_check_form_submission()) {
520
-                EED_Single_Page_Checkout::$_initialized = true;
521
-                return;
522
-            }
523
-            // checkout the action!!!
524
-            $this->_process_form_action();
525
-            // add some style and make it dance
526
-            $this->add_styles_and_scripts();
527
-            // kk... SPCO has successfully run
528
-            EED_Single_Page_Checkout::$_initialized = true;
529
-            // set no cache headers and constants
530
-            EE_System::do_not_cache();
531
-            // add anchor
532
-            add_action('loop_start', array($this, 'set_checkout_anchor'), 1);
533
-            // remove transaction lock
534
-            add_action('shutdown', array($this, 'unlock_transaction'), 1);
535
-        } catch (Exception $e) {
536
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
537
-        }
538
-    }
539
-
540
-
541
-
542
-    /**
543
-     *    _verify_session
544
-     * checks that the session is valid and not expired
545
-     *
546
-     * @access    private
547
-     * @throws EE_Error
548
-     */
549
-    private function _verify_session()
550
-    {
551
-        if ( ! EE_Registry::instance()->SSN instanceof EE_Session) {
552
-            throw new EE_Error(__('The EE_Session class could not be loaded.', 'event_espresso'));
553
-        }
554
-        // is session still valid ?
555
-        if (
556
-            EE_Registry::instance()->SSN->expired()
557
-            && EE_Registry::instance()->REQ->get('e_reg_url_link', '') === ''
558
-        ) {
559
-            $this->checkout = new EE_Checkout();
560
-            EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
561
-            // EE_Registry::instance()->SSN->reset_cart();
562
-            // EE_Registry::instance()->SSN->reset_checkout();
563
-            // EE_Registry::instance()->SSN->reset_transaction();
564
-            EE_Error::add_attention(
565
-                EE_Registry::$i18n_js_strings['registration_expiration_notice'],
566
-                __FILE__, __FUNCTION__, __LINE__
567
-            );
568
-            // EE_Registry::instance()->SSN->reset_expired();
569
-        }
570
-    }
571
-
572
-
573
-
574
-    /**
575
-     *    _initialize_checkout
576
-     * loads and instantiates EE_Checkout
577
-     *
578
-     * @access    private
579
-     * @throws EE_Error
580
-     * @return EE_Checkout
581
-     */
582
-    private function _initialize_checkout()
583
-    {
584
-        // look in session for existing checkout
585
-        /** @type EE_Checkout $checkout */
586
-        $checkout = EE_Registry::instance()->SSN->checkout();
587
-        // verify
588
-        if ( ! $checkout instanceof EE_Checkout) {
589
-            // instantiate EE_Checkout object for handling the properties of the current checkout process
590
-            $checkout = EE_Registry::instance()->load_file(
591
-                SPCO_INC_PATH,
592
-                'EE_Checkout',
593
-                'class', array(),
594
-                false
595
-            );
596
-        } else {
597
-            if ($checkout->current_step->is_final_step() && $checkout->exit_spco() === true) {
598
-                $this->unlock_transaction();
599
-                wp_safe_redirect($checkout->redirect_url);
600
-                exit();
601
-            }
602
-        }
603
-        $checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout);
604
-        // verify again
605
-        if ( ! $checkout instanceof EE_Checkout) {
606
-            throw new EE_Error(__('The EE_Checkout class could not be loaded.', 'event_espresso'));
607
-        }
608
-        // reset anything that needs a clean slate for each request
609
-        $checkout->reset_for_current_request();
610
-        return $checkout;
611
-    }
612
-
613
-
614
-
615
-    /**
616
-     *    _get_request_vars
617
-     *
618
-     * @access    private
619
-     * @return    void
620
-     * @throws EE_Error
621
-     */
622
-    private function _get_request_vars()
623
-    {
624
-        // load classes
625
-        EED_Single_Page_Checkout::load_request_handler();
626
-        //make sure this request is marked as belonging to EE
627
-        EE_Registry::instance()->REQ->set_espresso_page(true);
628
-        // which step is being requested ?
629
-        $this->checkout->step = EE_Registry::instance()->REQ->get('step', $this->_get_first_step());
630
-        // which step is being edited ?
631
-        $this->checkout->edit_step = EE_Registry::instance()->REQ->get('edit_step', '');
632
-        // and what we're doing on the current step
633
-        $this->checkout->action = EE_Registry::instance()->REQ->get('action', 'display_spco_reg_step');
634
-        // timestamp
635
-        $this->checkout->uts = EE_Registry::instance()->REQ->get('uts', 0);
636
-        // returning to edit ?
637
-        $this->checkout->reg_url_link = EE_Registry::instance()->REQ->get('e_reg_url_link', '');
638
-        // or some other kind of revisit ?
639
-        $this->checkout->revisit = filter_var(
640
-            EE_Registry::instance()->REQ->get('revisit', false),
641
-            FILTER_VALIDATE_BOOLEAN
642
-        );
643
-        // and whether or not to generate a reg form for this request
644
-        $this->checkout->generate_reg_form = filter_var(
645
-            EE_Registry::instance()->REQ->get('generate_reg_form', true),
646
-            FILTER_VALIDATE_BOOLEAN
647
-        );
648
-        // and whether or not to process a reg form submission for this request
649
-        $this->checkout->process_form_submission = filter_var(
650
-            EE_Registry::instance()->REQ->get(
651
-                'process_form_submission',
652
-                $this->checkout->action === 'process_reg_step'
653
-            ),
654
-            FILTER_VALIDATE_BOOLEAN
655
-        );
656
-        $this->checkout->process_form_submission = filter_var(
657
-            $this->checkout->action !== 'display_spco_reg_step'
658
-                ? $this->checkout->process_form_submission
659
-                : false,
660
-            FILTER_VALIDATE_BOOLEAN
661
-        );
662
-        // $this->_display_request_vars();
663
-    }
664
-
665
-
666
-
667
-    /**
668
-     *  _display_request_vars
669
-     *
670
-     * @access    protected
671
-     * @return    void
672
-     */
673
-    protected function _display_request_vars()
674
-    {
675
-        if ( ! WP_DEBUG) {
676
-            return;
677
-        }
678
-        EEH_Debug_Tools::printr($_REQUEST, '$_REQUEST', __FILE__, __LINE__);
679
-        EEH_Debug_Tools::printr($this->checkout->step, '$this->checkout->step', __FILE__, __LINE__);
680
-        EEH_Debug_Tools::printr($this->checkout->edit_step, '$this->checkout->edit_step', __FILE__, __LINE__);
681
-        EEH_Debug_Tools::printr($this->checkout->action, '$this->checkout->action', __FILE__, __LINE__);
682
-        EEH_Debug_Tools::printr($this->checkout->reg_url_link, '$this->checkout->reg_url_link', __FILE__, __LINE__);
683
-        EEH_Debug_Tools::printr($this->checkout->revisit, '$this->checkout->revisit', __FILE__, __LINE__);
684
-        EEH_Debug_Tools::printr($this->checkout->generate_reg_form, '$this->checkout->generate_reg_form', __FILE__, __LINE__);
685
-        EEH_Debug_Tools::printr($this->checkout->process_form_submission, '$this->checkout->process_form_submission', __FILE__, __LINE__);
686
-    }
687
-
688
-
689
-
690
-    /**
691
-     * _block_bots
692
-     * checks that the incoming request has either of the following set:
693
-     *  a uts (unix timestamp) which indicates that the request was redirected from the Ticket Selector
694
-     *  a REG URL Link, which indicates that the request is a return visit to SPCO for a valid TXN
695
-     * so if you're not coming from the Ticket Selector nor returning for a valid IP...
696
-     * then where you coming from man?
697
-     *
698
-     * @return boolean
699
-     */
700
-    private function _block_bots()
701
-    {
702
-        $invalid_checkout_access = EED_Invalid_Checkout_Access::getInvalidCheckoutAccess();
703
-        if ($invalid_checkout_access->checkoutAccessIsInvalid($this->checkout)) {
704
-            return true;
705
-        }
706
-        return false;
707
-    }
708
-
709
-
710
-
711
-    /**
712
-     *    _get_first_step
713
-     *  gets slug for first step in $_reg_steps_array
714
-     *
715
-     * @access    private
716
-     * @throws EE_Error
717
-     * @return    string
718
-     */
719
-    private function _get_first_step()
720
-    {
721
-        $first_step = reset(EED_Single_Page_Checkout::$_reg_steps_array);
722
-        return isset($first_step['slug']) ? $first_step['slug'] : 'attendee_information';
723
-    }
724
-
725
-
726
-
727
-    /**
728
-     *    _load_and_instantiate_reg_steps
729
-     *  instantiates each reg step based on the loaded reg_steps array
730
-     *
731
-     * @access    private
732
-     * @throws EE_Error
733
-     * @return    bool
734
-     */
735
-    private function _load_and_instantiate_reg_steps()
736
-    {
737
-        do_action('AHEE__Single_Page_Checkout___load_and_instantiate_reg_steps__start', $this->checkout);
738
-        // have reg_steps already been instantiated ?
739
-        if (
740
-            empty($this->checkout->reg_steps)
741
-            || apply_filters('FHEE__Single_Page_Checkout__load_reg_steps__reload_reg_steps', false, $this->checkout)
742
-        ) {
743
-            // if not, then loop through raw reg steps array
744
-            foreach (EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step) {
745
-                if ( ! $this->_load_and_instantiate_reg_step($reg_step, $order)) {
746
-                    return false;
747
-                }
748
-            }
749
-            EE_Registry::instance()->CFG->registration->skip_reg_confirmation = true;
750
-            EE_Registry::instance()->CFG->registration->reg_confirmation_last = true;
751
-            // skip the registration_confirmation page ?
752
-            if (EE_Registry::instance()->CFG->registration->skip_reg_confirmation) {
753
-                // just remove it from the reg steps array
754
-                $this->checkout->remove_reg_step('registration_confirmation', false);
755
-            } else if (
756
-                isset($this->checkout->reg_steps['registration_confirmation'])
757
-                && EE_Registry::instance()->CFG->registration->reg_confirmation_last
758
-            ) {
759
-                // set the order to something big like 100
760
-                $this->checkout->set_reg_step_order('registration_confirmation', 100);
761
-            }
762
-            // filter the array for good luck
763
-            $this->checkout->reg_steps = apply_filters(
764
-                'FHEE__Single_Page_Checkout__load_reg_steps__reg_steps',
765
-                $this->checkout->reg_steps
766
-            );
767
-            // finally re-sort based on the reg step class order properties
768
-            $this->checkout->sort_reg_steps();
769
-        } else {
770
-            foreach ($this->checkout->reg_steps as $reg_step) {
771
-                // set all current step stati to FALSE
772
-                $reg_step->set_is_current_step(false);
773
-            }
774
-        }
775
-        if (empty($this->checkout->reg_steps)) {
776
-            EE_Error::add_error(
777
-                __('No Reg Steps were loaded..', 'event_espresso'),
778
-                __FILE__, __FUNCTION__, __LINE__
779
-            );
780
-            return false;
781
-        }
782
-        // make reg step details available to JS
783
-        $this->checkout->set_reg_step_JSON_info();
784
-        return true;
785
-    }
786
-
787
-
788
-
789
-    /**
790
-     *     _load_and_instantiate_reg_step
791
-     *
792
-     * @access    private
793
-     * @param array $reg_step
794
-     * @param int   $order
795
-     * @return bool
796
-     */
797
-    private function _load_and_instantiate_reg_step($reg_step = array(), $order = 0)
798
-    {
799
-        // we need a file_path, class_name, and slug to add a reg step
800
-        if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) {
801
-            // if editing a specific step, but this is NOT that step... (and it's not the 'finalize_registration' step)
802
-            if (
803
-                $this->checkout->reg_url_link
804
-                && $this->checkout->step !== $reg_step['slug']
805
-                && $reg_step['slug'] !== 'finalize_registration'
806
-                // normally at this point we would NOT load the reg step, but this filter can change that
807
-                && apply_filters(
808
-                    'FHEE__Single_Page_Checkout___load_and_instantiate_reg_step__bypass_reg_step',
809
-                    true,
810
-                    $reg_step,
811
-                    $this->checkout
812
-                )
813
-            ) {
814
-                return true;
815
-            }
816
-            // instantiate step class using file path and class name
817
-            $reg_step_obj = EE_Registry::instance()->load_file(
818
-                $reg_step['file_path'],
819
-                $reg_step['class_name'],
820
-                'class',
821
-                $this->checkout,
822
-                false
823
-            );
824
-            // did we gets the goods ?
825
-            if ($reg_step_obj instanceof EE_SPCO_Reg_Step) {
826
-                // set reg step order based on config
827
-                $reg_step_obj->set_order($order);
828
-                // add instantiated reg step object to the master reg steps array
829
-                $this->checkout->add_reg_step($reg_step_obj);
830
-            } else {
831
-                EE_Error::add_error(
832
-                    __('The current step could not be set.', 'event_espresso'),
833
-                    __FILE__, __FUNCTION__, __LINE__
834
-                );
835
-                return false;
836
-            }
837
-        } else {
838
-            if (WP_DEBUG) {
839
-                EE_Error::add_error(
840
-                    sprintf(
841
-                        __(
842
-                            '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',
843
-                            'event_espresso'
844
-                        ),
845
-                        isset($reg_step['file_path']) ? $reg_step['file_path'] : '',
846
-                        isset($reg_step['class_name']) ? $reg_step['class_name'] : '',
847
-                        isset($reg_step['slug']) ? $reg_step['slug'] : '',
848
-                        '<ul>',
849
-                        '<li>',
850
-                        '</li>',
851
-                        '</ul>'
852
-                    ),
853
-                    __FILE__, __FUNCTION__, __LINE__
854
-                );
855
-            }
856
-            return false;
857
-        }
858
-        return true;
859
-    }
860
-
861
-
862
-    /**
863
-     * _verify_transaction_and_get_registrations
864
-     *
865
-     * @access private
866
-     * @return bool
867
-     * @throws InvalidDataTypeException
868
-     * @throws InvalidEntityException
869
-     * @throws EE_Error
870
-     */
871
-    private function _verify_transaction_and_get_registrations()
872
-    {
873
-        // was there already a valid transaction in the checkout from the session ?
874
-        if ( ! $this->checkout->transaction instanceof EE_Transaction) {
875
-            // get transaction from db or session
876
-            $this->checkout->transaction = $this->checkout->reg_url_link && ! is_admin()
877
-                ? $this->_get_transaction_and_cart_for_previous_visit()
878
-                : $this->_get_cart_for_current_session_and_setup_new_transaction();
879
-            if ( ! $this->checkout->transaction instanceof EE_Transaction) {
880
-                EE_Error::add_error(
881
-                    __('Your Registration and Transaction information could not be retrieved from the db.',
882
-                        'event_espresso'),
883
-                    __FILE__, __FUNCTION__, __LINE__
884
-                );
885
-                $this->checkout->transaction = EE_Transaction::new_instance();
886
-                // add some style and make it dance
887
-                $this->add_styles_and_scripts();
888
-                EED_Single_Page_Checkout::$_initialized = true;
889
-                return false;
890
-            }
891
-            // and the registrations for the transaction
892
-            $this->_get_registrations($this->checkout->transaction);
893
-        }
894
-        return true;
895
-    }
896
-
897
-
898
-
899
-    /**
900
-     * _get_transaction_and_cart_for_previous_visit
901
-     *
902
-     * @access private
903
-     * @return mixed EE_Transaction|NULL
904
-     */
905
-    private function _get_transaction_and_cart_for_previous_visit()
906
-    {
907
-        /** @var $TXN_model EEM_Transaction */
908
-        $TXN_model = EE_Registry::instance()->load_model('Transaction');
909
-        // because the reg_url_link is present in the request,
910
-        // this is a return visit to SPCO, so we'll get the transaction data from the db
911
-        $transaction = $TXN_model->get_transaction_from_reg_url_link($this->checkout->reg_url_link);
912
-        // verify transaction
913
-        if ($transaction instanceof EE_Transaction) {
914
-            // and get the cart that was used for that transaction
915
-            $this->checkout->cart = $this->_get_cart_for_transaction($transaction);
916
-            return $transaction;
917
-        }
918
-        EE_Error::add_error(
919
-            __('Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso'),
920
-            __FILE__, __FUNCTION__, __LINE__
921
-        );
922
-        return null;
923
-
924
-    }
925
-
926
-
927
-
928
-    /**
929
-     * _get_cart_for_transaction
930
-     *
931
-     * @access private
932
-     * @param EE_Transaction $transaction
933
-     * @return EE_Cart
934
-     */
935
-    private function _get_cart_for_transaction($transaction)
936
-    {
937
-        return $this->checkout->get_cart_for_transaction($transaction);
938
-    }
939
-
940
-
941
-
942
-    /**
943
-     * get_cart_for_transaction
944
-     *
945
-     * @access public
946
-     * @param EE_Transaction $transaction
947
-     * @return EE_Cart
948
-     */
949
-    public function get_cart_for_transaction(EE_Transaction $transaction)
950
-    {
951
-        return $this->checkout->get_cart_for_transaction($transaction);
952
-    }
953
-
954
-
955
-
956
-    /**
957
-     * _get_transaction_and_cart_for_current_session
958
-     *    generates a new EE_Transaction object and adds it to the $_transaction property.
959
-     *
960
-     * @access private
961
-     * @return EE_Transaction
962
-     * @throws EE_Error
963
-     */
964
-    private function _get_cart_for_current_session_and_setup_new_transaction()
965
-    {
966
-        //  if there's no transaction, then this is the FIRST visit to SPCO
967
-        // so load up the cart ( passing nothing for the TXN because it doesn't exist yet )
968
-        $this->checkout->cart = $this->_get_cart_for_transaction(null);
969
-        // and then create a new transaction
970
-        $transaction = $this->_initialize_transaction();
971
-        // verify transaction
972
-        if ($transaction instanceof EE_Transaction) {
973
-            // save it so that we have an ID for other objects to use
974
-            $transaction->save();
975
-            // and save TXN data to the cart
976
-            $this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn($transaction->ID());
977
-        } else {
978
-            EE_Error::add_error(
979
-                __('A Valid Transaction could not be initialized.', 'event_espresso'),
980
-                __FILE__, __FUNCTION__, __LINE__
981
-            );
982
-        }
983
-        return $transaction;
984
-    }
985
-
986
-
987
-
988
-    /**
989
-     *    generates a new EE_Transaction object and adds it to the $_transaction property.
990
-     *
991
-     * @access private
992
-     * @return mixed EE_Transaction|NULL
993
-     */
994
-    private function _initialize_transaction()
995
-    {
996
-        try {
997
-            // ensure cart totals have been calculated
998
-            $this->checkout->cart->get_grand_total()->recalculate_total_including_taxes();
999
-            // grab the cart grand total
1000
-            $cart_total = $this->checkout->cart->get_cart_grand_total();
1001
-            // create new TXN
1002
-            $transaction = EE_Transaction::new_instance(
1003
-                array(
1004
-                    'TXN_reg_steps' => $this->checkout->initialize_txn_reg_steps_array(),
1005
-                    'TXN_total'     => $cart_total > 0 ? $cart_total : 0,
1006
-                    'TXN_paid'      => 0,
1007
-                    'STS_ID'        => EEM_Transaction::failed_status_code,
1008
-                )
1009
-            );
1010
-            // save it so that we have an ID for other objects to use
1011
-            $transaction->save();
1012
-            // set cron job for following up on TXNs after their session has expired
1013
-            EE_Cron_Tasks::schedule_expired_transaction_check(
1014
-                EE_Registry::instance()->SSN->expiration() + 1,
1015
-                $transaction->ID()
1016
-            );
1017
-            return $transaction;
1018
-        } catch (Exception $e) {
1019
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
1020
-        }
1021
-        return null;
1022
-    }
1023
-
1024
-
1025
-    /**
1026
-     * _get_registrations
1027
-     *
1028
-     * @access private
1029
-     * @param EE_Transaction $transaction
1030
-     * @return void
1031
-     * @throws InvalidDataTypeException
1032
-     * @throws InvalidEntityException
1033
-     * @throws EE_Error
1034
-     */
1035
-    private function _get_registrations(EE_Transaction $transaction)
1036
-    {
1037
-        // first step: grab the registrants  { : o
1038
-        $registrations = $transaction->registrations($this->checkout->reg_cache_where_params, true);
1039
-        // verify registrations have been set
1040
-        if (empty($registrations)) {
1041
-            // if no cached registrations, then check the db
1042
-            $registrations = $transaction->registrations($this->checkout->reg_cache_where_params, false);
1043
-            // still nothing ? well as long as this isn't a revisit
1044
-            if (empty($registrations) && ! $this->checkout->revisit) {
1045
-                // generate new registrations from scratch
1046
-                $registrations = $this->_initialize_registrations($transaction);
1047
-            }
1048
-        }
1049
-        // sort by their original registration order
1050
-        usort($registrations, array('EED_Single_Page_Checkout', 'sort_registrations_by_REG_count'));
1051
-        // then loop thru the array
1052
-        foreach ($registrations as $registration) {
1053
-            // verify each registration
1054
-            if ($registration instanceof EE_Registration) {
1055
-                // we display all attendee info for the primary registrant
1056
-                if ($this->checkout->reg_url_link === $registration->reg_url_link()
1057
-                    && $registration->is_primary_registrant()
1058
-                ) {
1059
-                    $this->checkout->primary_revisit = true;
1060
-                    break;
1061
-                }
1062
-                if ($this->checkout->revisit
1063
-                           && $this->checkout->reg_url_link !== $registration->reg_url_link()
1064
-                ) {
1065
-                    // but hide info if it doesn't belong to you
1066
-                    $transaction->clear_cache('Registration', $registration->ID());
1067
-                }
1068
-                $this->checkout->set_reg_status_updated($registration->ID(), false);
1069
-            }
1070
-        }
1071
-    }
1072
-
1073
-
1074
-    /**
1075
-     *    adds related EE_Registration objects for each ticket in the cart to the current EE_Transaction object
1076
-     *
1077
-     * @access private
1078
-     * @param EE_Transaction $transaction
1079
-     * @return    array
1080
-     * @throws InvalidDataTypeException
1081
-     * @throws InvalidEntityException
1082
-     * @throws EE_Error
1083
-     */
1084
-    private function _initialize_registrations(EE_Transaction $transaction)
1085
-    {
1086
-        $att_nmbr = 0;
1087
-        $registrations = array();
1088
-        if ($transaction instanceof EE_Transaction) {
1089
-            /** @type EE_Registration_Processor $registration_processor */
1090
-            $registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
1091
-            $this->checkout->total_ticket_count = $this->checkout->cart->all_ticket_quantity_count();
1092
-            // now let's add the cart items to the $transaction
1093
-            foreach ($this->checkout->cart->get_tickets() as $line_item) {
1094
-                //do the following for each ticket of this type they selected
1095
-                for ($x = 1; $x <= $line_item->quantity(); $x++) {
1096
-                    $att_nmbr++;
1097
-                    /** @var EventEspresso\core\services\commands\registration\CreateRegistrationCommand $CreateRegistrationCommand */
1098
-                    $CreateRegistrationCommand = EE_Registry::instance()->create(
1099
-                        'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
1100
-                        array(
1101
-                            $transaction,
1102
-                            $line_item,
1103
-                            $att_nmbr,
1104
-                            $this->checkout->total_ticket_count,
1105
-                        )
1106
-                    );
1107
-                    // override capabilities for frontend registrations
1108
-                    if ( ! is_admin()) {
1109
-                        $CreateRegistrationCommand->setCapCheck(
1110
-                            new PublicCapabilities('', 'create_new_registration')
1111
-                        );
1112
-                    }
1113
-                    $registration = EE_Registry::instance()->BUS->execute($CreateRegistrationCommand);
1114
-                    if ( ! $registration instanceof EE_Registration) {
1115
-                        throw new InvalidEntityException($registration, 'EE_Registration');
1116
-                    }
1117
-                    $registrations[ $registration->ID() ] = $registration;
1118
-                }
1119
-            }
1120
-            $registration_processor->fix_reg_final_price_rounding_issue($transaction);
1121
-        }
1122
-        return $registrations;
1123
-    }
1124
-
1125
-
1126
-
1127
-    /**
1128
-     * sorts registrations by REG_count
1129
-     *
1130
-     * @access public
1131
-     * @param EE_Registration $reg_A
1132
-     * @param EE_Registration $reg_B
1133
-     * @return int
1134
-     */
1135
-    public static function sort_registrations_by_REG_count(EE_Registration $reg_A, EE_Registration $reg_B)
1136
-    {
1137
-        // this shouldn't ever happen within the same TXN, but oh well
1138
-        if ($reg_A->count() === $reg_B->count()) {
1139
-            return 0;
1140
-        }
1141
-        return ($reg_A->count() > $reg_B->count()) ? 1 : -1;
1142
-    }
1143
-
1144
-
1145
-
1146
-    /**
1147
-     *    _final_verifications
1148
-     * just makes sure that everything is set up correctly before proceeding
1149
-     *
1150
-     * @access    private
1151
-     * @return    bool
1152
-     * @throws EE_Error
1153
-     */
1154
-    private function _final_verifications()
1155
-    {
1156
-        // filter checkout
1157
-        $this->checkout = apply_filters(
1158
-            'FHEE__EED_Single_Page_Checkout___final_verifications__checkout',
1159
-            $this->checkout
1160
-        );
1161
-        //verify that current step is still set correctly
1162
-        if ( ! $this->checkout->current_step instanceof EE_SPCO_Reg_Step) {
1163
-            EE_Error::add_error(
1164
-                __('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'),
1165
-                __FILE__,
1166
-                __FUNCTION__,
1167
-                __LINE__
1168
-            );
1169
-            return false;
1170
-        }
1171
-        // if returning to SPCO, then verify that primary registrant is set
1172
-        if ( ! empty($this->checkout->reg_url_link)) {
1173
-            $valid_registrant = $this->checkout->transaction->primary_registration();
1174
-            if ( ! $valid_registrant instanceof EE_Registration) {
1175
-                EE_Error::add_error(
1176
-                    __('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'),
1177
-                    __FILE__,
1178
-                    __FUNCTION__,
1179
-                    __LINE__
1180
-                );
1181
-                return false;
1182
-            }
1183
-            $valid_registrant = null;
1184
-            foreach (
1185
-                $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params) as $registration
1186
-            ) {
1187
-                if (
1188
-                    $registration instanceof EE_Registration
1189
-                    && $registration->reg_url_link() === $this->checkout->reg_url_link
1190
-                ) {
1191
-                    $valid_registrant = $registration;
1192
-                }
1193
-            }
1194
-            if ( ! $valid_registrant instanceof EE_Registration) {
1195
-                // hmmm... maybe we have the wrong session because the user is opening multiple tabs ?
1196
-                if (EED_Single_Page_Checkout::$_checkout_verified) {
1197
-                    // clear the session, mark the checkout as unverified, and try again
1198
-                    EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
1199
-                    EED_Single_Page_Checkout::$_initialized = false;
1200
-                    EED_Single_Page_Checkout::$_checkout_verified = false;
1201
-                    $this->_initialize();
1202
-                    EE_Error::reset_notices();
1203
-                    return false;
1204
-                }
1205
-                EE_Error::add_error(
1206
-                    __(
1207
-                        '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.',
1208
-                        'event_espresso'
1209
-                    ),
1210
-                    __FILE__,
1211
-                    __FUNCTION__,
1212
-                    __LINE__
1213
-                );
1214
-                return false;
1215
-            }
1216
-        }
1217
-        // now that things have been kinda sufficiently verified,
1218
-        // let's add the checkout to the session so that it's available to other systems
1219
-        EE_Registry::instance()->SSN->set_checkout($this->checkout);
1220
-        return true;
1221
-    }
1222
-
1223
-
1224
-
1225
-    /**
1226
-     *    _initialize_reg_steps
1227
-     * first makes sure that EE_Transaction_Processor::set_reg_step_initiated() is called as required
1228
-     * then loops thru all of the active reg steps and calls the initialize_reg_step() method
1229
-     *
1230
-     * @access    private
1231
-     * @param bool $reinitializing
1232
-     * @throws EE_Error
1233
-     */
1234
-    private function _initialize_reg_steps($reinitializing = false)
1235
-    {
1236
-        $this->checkout->set_reg_step_initiated($this->checkout->current_step);
1237
-        // loop thru all steps to call their individual "initialize" methods and set i18n strings for JS
1238
-        foreach ($this->checkout->reg_steps as $reg_step) {
1239
-            if ( ! $reg_step->initialize_reg_step()) {
1240
-                // if not initialized then maybe this step is being removed...
1241
-                if ( ! $reinitializing && $reg_step->is_current_step()) {
1242
-                    // if it was the current step, then we need to start over here
1243
-                    $this->_initialize_reg_steps(true);
1244
-                    return;
1245
-                }
1246
-                continue;
1247
-            }
1248
-            // add css and JS for current step
1249
-            $reg_step->enqueue_styles_and_scripts();
1250
-            // i18n
1251
-            $reg_step->translate_js_strings();
1252
-            if ($reg_step->is_current_step()) {
1253
-                // the text that appears on the reg step form submit button
1254
-                $reg_step->set_submit_button_text();
1255
-            }
1256
-        }
1257
-        // dynamically creates hook point like: AHEE__Single_Page_Checkout___initialize_reg_step__attendee_information
1258
-        do_action(
1259
-            "AHEE__Single_Page_Checkout___initialize_reg_step__{$this->checkout->current_step->slug()}",
1260
-            $this->checkout->current_step
1261
-        );
1262
-    }
1263
-
1264
-
1265
-
1266
-    /**
1267
-     * _check_form_submission
1268
-     *
1269
-     * @access private
1270
-     * @return boolean
1271
-     */
1272
-    private function _check_form_submission()
1273
-    {
1274
-        //does this request require the reg form to be generated ?
1275
-        if ($this->checkout->generate_reg_form) {
1276
-            // ever heard that song by Blue Rodeo ?
1277
-            try {
1278
-                $this->checkout->current_step->reg_form = $this->checkout->current_step->generate_reg_form();
1279
-                // if not displaying a form, then check for form submission
1280
-                if (
1281
-                    $this->checkout->process_form_submission
1282
-                    && $this->checkout->current_step->reg_form->was_submitted()
1283
-                ) {
1284
-                    // clear out any old data in case this step is being run again
1285
-                    $this->checkout->current_step->set_valid_data(array());
1286
-                    // capture submitted form data
1287
-                    $this->checkout->current_step->reg_form->receive_form_submission(
1288
-                        apply_filters(
1289
-                            'FHEE__Single_Page_Checkout___check_form_submission__request_params',
1290
-                            EE_Registry::instance()->REQ->params(),
1291
-                            $this->checkout
1292
-                        )
1293
-                    );
1294
-                    // validate submitted form data
1295
-                    if ( ! $this->checkout->continue_reg || ! $this->checkout->current_step->reg_form->is_valid()) {
1296
-                        // thou shall not pass !!!
1297
-                        $this->checkout->continue_reg = false;
1298
-                        // any form validation errors?
1299
-                        if ($this->checkout->current_step->reg_form->submission_error_message() !== '') {
1300
-                            $submission_error_messages = array();
1301
-                            // bad, bad, bad registrant
1302
-                            foreach (
1303
-                                $this->checkout->current_step->reg_form->get_validation_errors_accumulated()
1304
-                                as $validation_error
1305
-                            ) {
1306
-                                if ($validation_error instanceof EE_Validation_Error) {
1307
-                                    $submission_error_messages[] = sprintf(
1308
-                                        __('%s : %s', 'event_espresso'),
1309
-                                        $validation_error->get_form_section()->html_label_text(),
1310
-                                        $validation_error->getMessage()
1311
-                                    );
1312
-                                }
1313
-                            }
1314
-                            EE_Error::add_error(
1315
-                                implode('<br />', $submission_error_messages),
1316
-                                __FILE__, __FUNCTION__, __LINE__
1317
-                            );
1318
-                        }
1319
-                        // well not really... what will happen is
1320
-                        // we'll just get redirected back to redo the current step
1321
-                        $this->go_to_next_step();
1322
-                        return false;
1323
-                    }
1324
-                }
1325
-            } catch (EE_Error $e) {
1326
-                $e->get_error();
1327
-            }
1328
-        }
1329
-        return true;
1330
-    }
1331
-
1332
-
1333
-
1334
-    /**
1335
-     * _process_action
1336
-     *
1337
-     * @access private
1338
-     * @return void
1339
-     * @throws EE_Error
1340
-     */
1341
-    private function _process_form_action()
1342
-    {
1343
-        // what cha wanna do?
1344
-        switch ($this->checkout->action) {
1345
-            // AJAX next step reg form
1346
-            case 'display_spco_reg_step' :
1347
-                $this->checkout->redirect = false;
1348
-                if (EE_Registry::instance()->REQ->ajax) {
1349
-                    $this->checkout->json_response->set_reg_step_html(
1350
-                        $this->checkout->current_step->display_reg_form()
1351
-                    );
1352
-                }
1353
-                break;
1354
-            default :
1355
-                // meh... do one of those other steps first
1356
-                if (
1357
-                    ! empty($this->checkout->action)
1358
-                    && is_callable(array($this->checkout->current_step, $this->checkout->action))
1359
-                ) {
1360
-                    // dynamically creates hook point like:
1361
-                    //   AHEE__Single_Page_Checkout__before_attendee_information__process_reg_step
1362
-                    do_action(
1363
-                        "AHEE__Single_Page_Checkout__before_{$this->checkout->current_step->slug()}__{$this->checkout->action}",
1364
-                        $this->checkout->current_step
1365
-                    );
1366
-                    // call action on current step
1367
-                    if (call_user_func(array($this->checkout->current_step, $this->checkout->action))) {
1368
-                        // good registrant, you get to proceed
1369
-                        if (
1370
-                            $this->checkout->current_step->success_message() !== ''
1371
-                            && apply_filters(
1372
-                                'FHEE__Single_Page_Checkout___process_form_action__display_success',
1373
-                                false
1374
-                            )
1375
-                        ) {
1376
-                            EE_Error::add_success(
1377
-                                $this->checkout->current_step->success_message()
1378
-                                . '<br />' . $this->checkout->next_step->_instructions()
1379
-                            );
1380
-                        }
1381
-                        // pack it up, pack it in...
1382
-                        $this->_setup_redirect();
1383
-                    }
1384
-                    // dynamically creates hook point like:
1385
-                    //  AHEE__Single_Page_Checkout__after_payment_options__process_reg_step
1386
-                    do_action(
1387
-                        "AHEE__Single_Page_Checkout__after_{$this->checkout->current_step->slug()}__{$this->checkout->action}",
1388
-                        $this->checkout->current_step
1389
-                    );
1390
-                } else {
1391
-                    EE_Error::add_error(
1392
-                        sprintf(
1393
-                            __(
1394
-                                'The requested form action "%s" does not exist for the current "%s" registration step.',
1395
-                                'event_espresso'
1396
-                            ),
1397
-                            $this->checkout->action,
1398
-                            $this->checkout->current_step->name()
1399
-                        ),
1400
-                        __FILE__,
1401
-                        __FUNCTION__,
1402
-                        __LINE__
1403
-                    );
1404
-                }
1405
-            // end default
1406
-        }
1407
-        // store our progress so far
1408
-        $this->checkout->stash_transaction_and_checkout();
1409
-        // advance to the next step! If you pass GO, collect $200
1410
-        $this->go_to_next_step();
1411
-    }
1412
-
1413
-
1414
-
1415
-    /**
1416
-     *        add_styles_and_scripts
1417
-     *
1418
-     * @access        public
1419
-     * @return        void
1420
-     */
1421
-    public function add_styles_and_scripts()
1422
-    {
1423
-        // i18n
1424
-        $this->translate_js_strings();
1425
-        if ($this->checkout->admin_request) {
1426
-            add_action('admin_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10);
1427
-        } else {
1428
-            add_action('wp_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10);
1429
-        }
1430
-    }
1431
-
1432
-
1433
-
1434
-    /**
1435
-     *        translate_js_strings
1436
-     *
1437
-     * @access        public
1438
-     * @return        void
1439
-     */
1440
-    public function translate_js_strings()
1441
-    {
1442
-        EE_Registry::$i18n_js_strings['revisit'] = $this->checkout->revisit;
1443
-        EE_Registry::$i18n_js_strings['e_reg_url_link'] = $this->checkout->reg_url_link;
1444
-        EE_Registry::$i18n_js_strings['server_error'] = __(
1445
-            'An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again or contact support.',
1446
-            'event_espresso'
1447
-        );
1448
-        EE_Registry::$i18n_js_strings['invalid_json_response'] = __(
1449
-            'An invalid response was returned from the server while attempting to process your request. Please refresh the page and try again or contact support.',
1450
-            'event_espresso'
1451
-        );
1452
-        EE_Registry::$i18n_js_strings['validation_error'] = __(
1453
-            'There appears to be a problem with the form validation configuration! Please check the admin settings or contact support.',
1454
-            'event_espresso'
1455
-        );
1456
-        EE_Registry::$i18n_js_strings['invalid_payment_method'] = __(
1457
-            'There appears to be a problem with the payment method configuration! Please refresh the page and try again or contact support.',
1458
-            'event_espresso'
1459
-        );
1460
-        EE_Registry::$i18n_js_strings['reg_step_error'] = __(
1461
-            'This registration step could not be completed. Please refresh the page and try again.',
1462
-            'event_espresso'
1463
-        );
1464
-        EE_Registry::$i18n_js_strings['invalid_coupon'] = __(
1465
-            'We\'re sorry but that coupon code does not appear to be valid. If this is incorrect, please contact the site administrator.',
1466
-            'event_espresso'
1467
-        );
1468
-        EE_Registry::$i18n_js_strings['process_registration'] = sprintf(
1469
-            __(
1470
-                'Please wait while we process your registration.%sDo not refresh the page or navigate away while this is happening.%sThank you for your patience.',
1471
-                'event_espresso'
1472
-            ),
1473
-            '<br/>',
1474
-            '<br/>'
1475
-        );
1476
-        EE_Registry::$i18n_js_strings['language'] = get_bloginfo('language');
1477
-        EE_Registry::$i18n_js_strings['EESID'] = EE_Registry::instance()->SSN->id();
1478
-        EE_Registry::$i18n_js_strings['currency'] = EE_Registry::instance()->CFG->currency;
1479
-        EE_Registry::$i18n_js_strings['datepicker_yearRange'] = '-150:+20';
1480
-        EE_Registry::$i18n_js_strings['timer_years'] = __('years', 'event_espresso');
1481
-        EE_Registry::$i18n_js_strings['timer_months'] = __('months', 'event_espresso');
1482
-        EE_Registry::$i18n_js_strings['timer_weeks'] = __('weeks', 'event_espresso');
1483
-        EE_Registry::$i18n_js_strings['timer_days'] = __('days', 'event_espresso');
1484
-        EE_Registry::$i18n_js_strings['timer_hours'] = __('hours', 'event_espresso');
1485
-        EE_Registry::$i18n_js_strings['timer_minutes'] = __('minutes', 'event_espresso');
1486
-        EE_Registry::$i18n_js_strings['timer_seconds'] = __('seconds', 'event_espresso');
1487
-        EE_Registry::$i18n_js_strings['timer_year'] = __('year', 'event_espresso');
1488
-        EE_Registry::$i18n_js_strings['timer_month'] = __('month', 'event_espresso');
1489
-        EE_Registry::$i18n_js_strings['timer_week'] = __('week', 'event_espresso');
1490
-        EE_Registry::$i18n_js_strings['timer_day'] = __('day', 'event_espresso');
1491
-        EE_Registry::$i18n_js_strings['timer_hour'] = __('hour', 'event_espresso');
1492
-        EE_Registry::$i18n_js_strings['timer_minute'] = __('minute', 'event_espresso');
1493
-        EE_Registry::$i18n_js_strings['timer_second'] = __('second', 'event_espresso');
1494
-        EE_Registry::$i18n_js_strings['registration_expiration_notice'] = sprintf(
1495
-            __(
1496
-                '%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 except our apologies for any inconvenience this may have caused.%8$s',
1497
-                'event_espresso'
1498
-            ),
1499
-            '<h4 class="important-notice">',
1500
-            '</h4>',
1501
-            '<br />',
1502
-            '<p>',
1503
-            '<a href="' . get_post_type_archive_link('espresso_events') . '" title="',
1504
-            '">',
1505
-            '</a>',
1506
-            '</p>'
1507
-        );
1508
-        EE_Registry::$i18n_js_strings['ajax_submit'] = apply_filters(
1509
-            'FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit',
1510
-            true
1511
-        );
1512
-        EE_Registry::$i18n_js_strings['session_extension'] = absint(
1513
-            apply_filters('FHEE__EE_Session__extend_expiration__seconds_added', 10 * MINUTE_IN_SECONDS)
1514
-        );
1515
-        EE_Registry::$i18n_js_strings['session_expiration'] = gmdate(
1516
-            'M d, Y H:i:s',
1517
-            EE_Registry::instance()->SSN->expiration() + (get_option('gmt_offset') * HOUR_IN_SECONDS)
1518
-        );
1519
-    }
1520
-
1521
-
1522
-
1523
-    /**
1524
-     *    enqueue_styles_and_scripts
1525
-     *
1526
-     * @access        public
1527
-     * @return        void
1528
-     * @throws EE_Error
1529
-     */
1530
-    public function enqueue_styles_and_scripts()
1531
-    {
1532
-        // load css
1533
-        wp_register_style(
1534
-            'single_page_checkout',
1535
-            SPCO_CSS_URL . 'single_page_checkout.css',
1536
-            array('espresso_default'),
1537
-            EVENT_ESPRESSO_VERSION
1538
-        );
1539
-        wp_enqueue_style('single_page_checkout');
1540
-        // load JS
1541
-        wp_register_script(
1542
-            'jquery_plugin',
1543
-            EE_THIRD_PARTY_URL . 'jquery	.plugin.min.js',
1544
-            array('jquery'),
1545
-            '1.0.1',
1546
-            true
1547
-        );
1548
-        wp_register_script(
1549
-            'jquery_countdown',
1550
-            EE_THIRD_PARTY_URL . 'jquery	.countdown.min.js',
1551
-            array('jquery_plugin'),
1552
-            '2.0.2',
1553
-            true
1554
-        );
1555
-        wp_register_script(
1556
-            'single_page_checkout',
1557
-            SPCO_JS_URL . 'single_page_checkout.js',
1558
-            array('espresso_core', 'underscore', 'ee_form_section_validation', 'jquery_countdown'),
1559
-            EVENT_ESPRESSO_VERSION,
1560
-            true
1561
-        );
1562
-        if ($this->checkout->registration_form instanceof EE_Form_Section_Proper) {
1563
-            $this->checkout->registration_form->enqueue_js();
1564
-        }
1565
-        if ($this->checkout->current_step->reg_form instanceof EE_Form_Section_Proper) {
1566
-            $this->checkout->current_step->reg_form->enqueue_js();
1567
-        }
1568
-        wp_enqueue_script('single_page_checkout');
1569
-        /**
1570
-         * global action hook for enqueueing styles and scripts with
1571
-         * spco calls.
1572
-         */
1573
-        do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts', $this);
1574
-        /**
1575
-         * dynamic action hook for enqueueing styles and scripts with spco calls.
1576
-         * The hook will end up being something like:
1577
-         *      AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__attendee_information
1578
-         */
1579
-        do_action(
1580
-            'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__' . $this->checkout->current_step->slug(),
1581
-            $this
1582
-        );
1583
-    }
1584
-
1585
-
1586
-
1587
-    /**
1588
-     *    display the Registration Single Page Checkout Form
1589
-     *
1590
-     * @access    private
1591
-     * @return    void
1592
-     * @throws EE_Error
1593
-     */
1594
-    private function _display_spco_reg_form()
1595
-    {
1596
-        // if registering via the admin, just display the reg form for the current step
1597
-        if ($this->checkout->admin_request) {
1598
-            EE_Registry::instance()->REQ->add_output($this->checkout->current_step->display_reg_form());
1599
-        } else {
1600
-            // add powered by EE msg
1601
-            add_action('AHEE__SPCO__reg_form_footer', array('EED_Single_Page_Checkout', 'display_registration_footer'));
1602
-            $empty_cart = count(
1603
-                $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params)
1604
-            ) < 1;
1605
-            EE_Registry::$i18n_js_strings['empty_cart'] = $empty_cart;
1606
-            $cookies_not_set_msg = '';
1607
-            if ($empty_cart && ! isset($_COOKIE['ee_cookie_test'])) {
1608
-                $cookies_not_set_msg = apply_filters(
1609
-                    'FHEE__Single_Page_Checkout__display_spco_reg_form__cookies_not_set_msg',
1610
-                    sprintf(
1611
-                        __(
1612
-                            '%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',
1613
-                            'event_espresso'
1614
-                        ),
1615
-                        '<div class="ee-attention">',
1616
-                        '</div>',
1617
-                        '<h6 class="important-notice">',
1618
-                        '</h6>',
1619
-                        '<p>',
1620
-                        '</p>',
1621
-                        '<br />',
1622
-                        '<a href="http://www.whatarecookies.com/enable.asp" target="_blank">',
1623
-                        '</a>'
1624
-                    )
1625
-                );
1626
-            }
1627
-            $this->checkout->registration_form = new EE_Form_Section_Proper(
1628
-                array(
1629
-                    'name'            => 'single-page-checkout',
1630
-                    'html_id'         => 'ee-single-page-checkout-dv',
1631
-                    'layout_strategy' =>
1632
-                        new EE_Template_Layout(
1633
-                            array(
1634
-                                'layout_template_file' => SPCO_TEMPLATES_PATH . 'registration_page_wrapper.template.php',
1635
-                                'template_args'        => array(
1636
-                                    'empty_cart'              => $empty_cart,
1637
-                                    'revisit'                 => $this->checkout->revisit,
1638
-                                    'reg_steps'               => $this->checkout->reg_steps,
1639
-                                    'next_step'               => $this->checkout->next_step instanceof EE_SPCO_Reg_Step
1640
-                                        ? $this->checkout->next_step->slug()
1641
-                                        : '',
1642
-                                    'cancel_page_url'         => $this->checkout->cancel_page_url,
1643
-                                    'empty_msg'               => apply_filters(
1644
-                                        'FHEE__Single_Page_Checkout__display_spco_reg_form__empty_msg',
1645
-                                        sprintf(
1646
-                                            __(
1647
-                                                'You need to %1$sReturn to Events list%2$sselect at least one event%3$s before you can proceed with the registration process.',
1648
-                                                'event_espresso'
1649
-                                            ),
1650
-                                            '<a href="'
1651
-                                            . get_post_type_archive_link('espresso_events')
1652
-                                            . '" title="',
1653
-                                            '">',
1654
-                                            '</a>'
1655
-                                        )
1656
-                                    ),
1657
-                                    'cookies_not_set_msg'     => $cookies_not_set_msg,
1658
-                                    'registration_time_limit' => $this->checkout->get_registration_time_limit(),
1659
-                                    'session_expiration'      => gmdate(
1660
-                                        'M d, Y H:i:s',
1661
-                                        EE_Registry::instance()->SSN->expiration()
1662
-                                        + (get_option('gmt_offset') * HOUR_IN_SECONDS)
1663
-                                    ),
1664
-                                ),
1665
-                            )
1666
-                        ),
1667
-                )
1668
-            );
1669
-            // load template and add to output sent that gets filtered into the_content()
1670
-            EE_Registry::instance()->REQ->add_output($this->checkout->registration_form->get_html());
1671
-        }
1672
-    }
1673
-
1674
-
1675
-
1676
-    /**
1677
-     *    add_extra_finalize_registration_inputs
1678
-     *
1679
-     * @access    public
1680
-     * @param $next_step
1681
-     * @internal  param string $label
1682
-     * @return void
1683
-     */
1684
-    public function add_extra_finalize_registration_inputs($next_step)
1685
-    {
1686
-        if ($next_step === 'finalize_registration') {
1687
-            echo '<div id="spco-extra-finalize_registration-inputs-dv"></div>';
1688
-        }
1689
-    }
1690
-
1691
-
1692
-
1693
-    /**
1694
-     *    display_registration_footer
1695
-     *
1696
-     * @access    public
1697
-     * @return    string
1698
-     */
1699
-    public static function display_registration_footer()
1700
-    {
1701
-        if (
1702
-        apply_filters(
1703
-            'FHEE__EE_Front__Controller__show_reg_footer',
1704
-            EE_Registry::instance()->CFG->admin->show_reg_footer
1705
-        )
1706
-        ) {
1707
-            add_filter(
1708
-                'FHEE__EEH_Template__powered_by_event_espresso__url',
1709
-                function ($url) {
1710
-                    return apply_filters('FHEE__EE_Front_Controller__registration_footer__url', $url);
1711
-                }
1712
-            );
1713
-            echo apply_filters(
1714
-                'FHEE__EE_Front_Controller__display_registration_footer',
1715
-                \EEH_Template::powered_by_event_espresso(
1716
-                    '',
1717
-                    'espresso-registration-footer-dv',
1718
-                    array('utm_content' => 'registration_checkout')
1719
-                )
1720
-            );
1721
-        }
1722
-        return '';
1723
-    }
1724
-
1725
-
1726
-
1727
-    /**
1728
-     *    unlock_transaction
1729
-     *
1730
-     * @access    public
1731
-     * @return    void
1732
-     * @throws EE_Error
1733
-     */
1734
-    public function unlock_transaction()
1735
-    {
1736
-        if ($this->checkout->transaction instanceof EE_Transaction) {
1737
-            $this->checkout->transaction->unlock();
1738
-        }
1739
-    }
1740
-
1741
-
1742
-
1743
-    /**
1744
-     *        _setup_redirect
1745
-     *
1746
-     * @access    private
1747
-     * @return void
1748
-     */
1749
-    private function _setup_redirect()
1750
-    {
1751
-        if ($this->checkout->continue_reg && $this->checkout->next_step instanceof EE_SPCO_Reg_Step) {
1752
-            $this->checkout->redirect = true;
1753
-            if (empty($this->checkout->redirect_url)) {
1754
-                $this->checkout->redirect_url = $this->checkout->next_step->reg_step_url();
1755
-            }
1756
-            $this->checkout->redirect_url = apply_filters(
1757
-                'FHEE__EED_Single_Page_Checkout___setup_redirect__checkout_redirect_url',
1758
-                $this->checkout->redirect_url,
1759
-                $this->checkout
1760
-            );
1761
-        }
1762
-    }
1763
-
1764
-
1765
-
1766
-    /**
1767
-     *   handle ajax message responses and redirects
1768
-     *
1769
-     * @access public
1770
-     * @return void
1771
-     * @throws EE_Error
1772
-     */
1773
-    public function go_to_next_step()
1774
-    {
1775
-        if (EE_Registry::instance()->REQ->ajax) {
1776
-            // capture contents of output buffer we started earlier in the request, and insert into JSON response
1777
-            $this->checkout->json_response->set_unexpected_errors(ob_get_clean());
1778
-        }
1779
-        $this->unlock_transaction();
1780
-        // just return for these conditions
1781
-        if (
1782
-            $this->checkout->admin_request
1783
-            || $this->checkout->action === 'redirect_form'
1784
-            || $this->checkout->action === 'update_checkout'
1785
-        ) {
1786
-            return;
1787
-        }
1788
-        // AJAX response
1789
-        $this->_handle_json_response();
1790
-        // redirect to next step or the Thank You page
1791
-        $this->_handle_html_redirects();
1792
-        // hmmm... must be something wrong, so let's just display the form again !
1793
-        $this->_display_spco_reg_form();
1794
-    }
1795
-
1796
-
1797
-
1798
-    /**
1799
-     *   _handle_json_response
1800
-     *
1801
-     * @access protected
1802
-     * @return void
1803
-     */
1804
-    protected function _handle_json_response()
1805
-    {
1806
-        // if this is an ajax request
1807
-        if (EE_Registry::instance()->REQ->ajax) {
1808
-            // DEBUG LOG
1809
-            //$this->checkout->log(
1810
-            //	__CLASS__, __FUNCTION__, __LINE__,
1811
-            //	array(
1812
-            //		'json_response_redirect_url' => $this->checkout->json_response->redirect_url(),
1813
-            //		'redirect'                   => $this->checkout->redirect,
1814
-            //		'continue_reg'               => $this->checkout->continue_reg,
1815
-            //	)
1816
-            //);
1817
-            $this->checkout->json_response->set_registration_time_limit(
1818
-                $this->checkout->get_registration_time_limit()
1819
-            );
1820
-            $this->checkout->json_response->set_payment_amount($this->checkout->amount_owing);
1821
-            // just send the ajax (
1822
-            $json_response = apply_filters(
1823
-                'FHEE__EE_Single_Page_Checkout__JSON_response',
1824
-                $this->checkout->json_response
1825
-            );
1826
-            echo $json_response;
1827
-            exit();
1828
-        }
1829
-    }
1830
-
1831
-
1832
-
1833
-    /**
1834
-     *   _handle_redirects
1835
-     *
1836
-     * @access protected
1837
-     * @return void
1838
-     */
1839
-    protected function _handle_html_redirects()
1840
-    {
1841
-        // going somewhere ?
1842
-        if ($this->checkout->redirect && ! empty($this->checkout->redirect_url)) {
1843
-            // store notices in a transient
1844
-            EE_Error::get_notices(false, true, true);
1845
-            // DEBUG LOG
1846
-            //$this->checkout->log(
1847
-            //	__CLASS__, __FUNCTION__, __LINE__,
1848
-            //	array(
1849
-            //		'headers_sent' => headers_sent(),
1850
-            //		'redirect_url'     => $this->checkout->redirect_url,
1851
-            //		'headers_list'    => headers_list(),
1852
-            //	)
1853
-            //);
1854
-            wp_safe_redirect($this->checkout->redirect_url);
1855
-            exit();
1856
-        }
1857
-    }
1858
-
1859
-
1860
-
1861
-    /**
1862
-     *   set_checkout_anchor
1863
-     *
1864
-     * @access public
1865
-     * @return void
1866
-     */
1867
-    public function set_checkout_anchor()
1868
-    {
1869
-        echo '<a id="checkout" style="float: left; margin-left: -999em;"></a>';
1870
-    }
23
+	/**
24
+	 * $_initialized - has the SPCO controller already been initialized ?
25
+	 *
26
+	 * @access private
27
+	 * @var bool $_initialized
28
+	 */
29
+	private static $_initialized = false;
30
+
31
+
32
+	/**
33
+	 * $_checkout_verified - is the EE_Checkout verified as correct for this request ?
34
+	 *
35
+	 * @access private
36
+	 * @var bool $_valid_checkout
37
+	 */
38
+	private static $_checkout_verified = true;
39
+
40
+	/**
41
+	 *    $_reg_steps_array - holds initial array of reg steps
42
+	 *
43
+	 * @access private
44
+	 * @var array $_reg_steps_array
45
+	 */
46
+	private static $_reg_steps_array = array();
47
+
48
+	/**
49
+	 *    $checkout - EE_Checkout object for handling the properties of the current checkout process
50
+	 *
51
+	 * @access public
52
+	 * @var EE_Checkout $checkout
53
+	 */
54
+	public $checkout;
55
+
56
+
57
+
58
+	/**
59
+	 * @return EED_Module|EED_Single_Page_Checkout
60
+	 */
61
+	public static function instance()
62
+	{
63
+		add_filter('EED_Single_Page_Checkout__SPCO_active', '__return_true');
64
+		return parent::get_instance(__CLASS__);
65
+	}
66
+
67
+
68
+
69
+	/**
70
+	 * @return EE_CART
71
+	 */
72
+	public function cart()
73
+	{
74
+		return $this->checkout->cart;
75
+	}
76
+
77
+
78
+
79
+	/**
80
+	 * @return EE_Transaction
81
+	 */
82
+	public function transaction()
83
+	{
84
+		return $this->checkout->transaction;
85
+	}
86
+
87
+
88
+
89
+	/**
90
+	 *    set_hooks - for hooking into EE Core, other modules, etc
91
+	 *
92
+	 * @access    public
93
+	 * @return    void
94
+	 * @throws EE_Error
95
+	 */
96
+	public static function set_hooks()
97
+	{
98
+		EED_Single_Page_Checkout::set_definitions();
99
+	}
100
+
101
+
102
+
103
+	/**
104
+	 *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
105
+	 *
106
+	 * @access    public
107
+	 * @return    void
108
+	 * @throws EE_Error
109
+	 */
110
+	public static function set_hooks_admin()
111
+	{
112
+		EED_Single_Page_Checkout::set_definitions();
113
+		if ( ! (defined('DOING_AJAX') && DOING_AJAX)) {
114
+			return;
115
+		}
116
+		// going to start an output buffer in case anything gets accidentally output
117
+		// that might disrupt our JSON response
118
+		ob_start();
119
+		EED_Single_Page_Checkout::load_request_handler();
120
+		EED_Single_Page_Checkout::load_reg_steps();
121
+		// set ajax hooks
122
+		add_action('wp_ajax_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step'));
123
+		add_action('wp_ajax_nopriv_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step'));
124
+		add_action('wp_ajax_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step'));
125
+		add_action('wp_ajax_nopriv_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step'));
126
+		add_action('wp_ajax_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step'));
127
+		add_action('wp_ajax_nopriv_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step'));
128
+	}
129
+
130
+
131
+
132
+	/**
133
+	 *    process ajax request
134
+	 *
135
+	 * @param string $ajax_action
136
+	 * @throws EE_Error
137
+	 */
138
+	public static function process_ajax_request($ajax_action)
139
+	{
140
+		EE_Registry::instance()->REQ->set('action', $ajax_action);
141
+		EED_Single_Page_Checkout::instance()->_initialize();
142
+	}
143
+
144
+
145
+
146
+	/**
147
+	 *    ajax display registration step
148
+	 *
149
+	 * @throws EE_Error
150
+	 */
151
+	public static function display_reg_step()
152
+	{
153
+		EED_Single_Page_Checkout::process_ajax_request('display_spco_reg_step');
154
+	}
155
+
156
+
157
+
158
+	/**
159
+	 *    ajax process registration step
160
+	 *
161
+	 * @throws EE_Error
162
+	 */
163
+	public static function process_reg_step()
164
+	{
165
+		EED_Single_Page_Checkout::process_ajax_request('process_reg_step');
166
+	}
167
+
168
+
169
+
170
+	/**
171
+	 *    ajax process registration step
172
+	 *
173
+	 * @throws EE_Error
174
+	 */
175
+	public static function update_reg_step()
176
+	{
177
+		EED_Single_Page_Checkout::process_ajax_request('update_reg_step');
178
+	}
179
+
180
+
181
+
182
+	/**
183
+	 *   update_checkout
184
+	 *
185
+	 * @access public
186
+	 * @return void
187
+	 * @throws EE_Error
188
+	 */
189
+	public static function update_checkout()
190
+	{
191
+		EED_Single_Page_Checkout::process_ajax_request('update_checkout');
192
+	}
193
+
194
+
195
+
196
+	/**
197
+	 *    load_request_handler
198
+	 *
199
+	 * @access    public
200
+	 * @return    void
201
+	 */
202
+	public static function load_request_handler()
203
+	{
204
+		// load core Request_Handler class
205
+		if (EE_Registry::instance()->REQ !== null) {
206
+			EE_Registry::instance()->load_core('Request_Handler');
207
+		}
208
+	}
209
+
210
+
211
+
212
+	/**
213
+	 *    set_definitions
214
+	 *
215
+	 * @access    public
216
+	 * @return    void
217
+	 * @throws EE_Error
218
+	 */
219
+	public static function set_definitions()
220
+	{
221
+		if(defined('SPCO_BASE_PATH')) {
222
+			return;
223
+		}
224
+		define(
225
+			'SPCO_BASE_PATH',
226
+			rtrim(str_replace(array('\\', '/'), DS, plugin_dir_path(__FILE__)), DS) . DS
227
+		);
228
+		define('SPCO_CSS_URL', plugin_dir_url(__FILE__) . 'css' . DS);
229
+		define('SPCO_IMG_URL', plugin_dir_url(__FILE__) . 'img' . DS);
230
+		define('SPCO_JS_URL', plugin_dir_url(__FILE__) . 'js' . DS);
231
+		define('SPCO_INC_PATH', SPCO_BASE_PATH . 'inc' . DS);
232
+		define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH . 'reg_steps' . DS);
233
+		define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH . 'templates' . DS);
234
+		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(SPCO_BASE_PATH, true);
235
+		EE_Registry::$i18n_js_strings['registration_expiration_notice'] = sprintf(
236
+			__('%1$sWe\'re sorry, but you\'re registration time has expired.%2$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 except our apologies for any inconvenience this may have caused.%8$s',
237
+				'event_espresso'),
238
+			'<h4 class="important-notice">',
239
+			'</h4>',
240
+			'<br />',
241
+			'<p>',
242
+			'<a href="' . get_post_type_archive_link('espresso_events') . '" title="',
243
+			'">',
244
+			'</a>',
245
+			'</p>'
246
+		);
247
+	}
248
+
249
+
250
+
251
+	/**
252
+	 * load_reg_steps
253
+	 * loads and instantiates each reg step based on the EE_Registry::instance()->CFG->registration->reg_steps array
254
+	 *
255
+	 * @access    private
256
+	 * @throws EE_Error
257
+	 */
258
+	public static function load_reg_steps()
259
+	{
260
+		static $reg_steps_loaded = false;
261
+		if ($reg_steps_loaded) {
262
+			return;
263
+		}
264
+		// filter list of reg_steps
265
+		$reg_steps_to_load = (array)apply_filters(
266
+			'AHEE__SPCO__load_reg_steps__reg_steps_to_load',
267
+			EED_Single_Page_Checkout::get_reg_steps()
268
+		);
269
+		// sort by key (order)
270
+		ksort($reg_steps_to_load);
271
+		// loop through folders
272
+		foreach ($reg_steps_to_load as $order => $reg_step) {
273
+			// we need a
274
+			if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) {
275
+				// copy over to the reg_steps_array
276
+				EED_Single_Page_Checkout::$_reg_steps_array[$order] = $reg_step;
277
+				// register custom key route for each reg step
278
+				// ie: step=>"slug" - this is the entire reason we load the reg steps array now
279
+				EE_Config::register_route(
280
+					$reg_step['slug'],
281
+					'EED_Single_Page_Checkout',
282
+					'run',
283
+					'step'
284
+				);
285
+				// add AJAX or other hooks
286
+				if (isset($reg_step['has_hooks']) && $reg_step['has_hooks']) {
287
+					// setup autoloaders if necessary
288
+					if ( ! class_exists($reg_step['class_name'])) {
289
+						EEH_Autoloader::register_autoloaders_for_each_file_in_folder(
290
+							$reg_step['file_path'],
291
+							true
292
+						);
293
+					}
294
+					if (is_callable($reg_step['class_name'], 'set_hooks')) {
295
+						call_user_func(array($reg_step['class_name'], 'set_hooks'));
296
+					}
297
+				}
298
+			}
299
+		}
300
+		$reg_steps_loaded = true;
301
+	}
302
+
303
+
304
+
305
+	/**
306
+	 *    get_reg_steps
307
+	 *
308
+	 * @access    public
309
+	 * @return    array
310
+	 */
311
+	public static function get_reg_steps()
312
+	{
313
+		$reg_steps = EE_Registry::instance()->CFG->registration->reg_steps;
314
+		if (empty($reg_steps)) {
315
+			$reg_steps = array(
316
+				10  => array(
317
+					'file_path'  => SPCO_REG_STEPS_PATH . 'attendee_information',
318
+					'class_name' => 'EE_SPCO_Reg_Step_Attendee_Information',
319
+					'slug'       => 'attendee_information',
320
+					'has_hooks'  => false,
321
+				),
322
+				20  => array(
323
+					'file_path'  => SPCO_REG_STEPS_PATH . 'registration_confirmation',
324
+					'class_name' => 'EE_SPCO_Reg_Step_Registration_Confirmation',
325
+					'slug'       => 'registration_confirmation',
326
+					'has_hooks'  => false,
327
+				),
328
+				30  => array(
329
+					'file_path'  => SPCO_REG_STEPS_PATH . 'payment_options',
330
+					'class_name' => 'EE_SPCO_Reg_Step_Payment_Options',
331
+					'slug'       => 'payment_options',
332
+					'has_hooks'  => true,
333
+				),
334
+				999 => array(
335
+					'file_path'  => SPCO_REG_STEPS_PATH . 'finalize_registration',
336
+					'class_name' => 'EE_SPCO_Reg_Step_Finalize_Registration',
337
+					'slug'       => 'finalize_registration',
338
+					'has_hooks'  => false,
339
+				),
340
+			);
341
+		}
342
+		return $reg_steps;
343
+	}
344
+
345
+
346
+
347
+	/**
348
+	 *    registration_checkout_for_admin
349
+	 *
350
+	 * @access    public
351
+	 * @return    string
352
+	 * @throws EE_Error
353
+	 */
354
+	public static function registration_checkout_for_admin()
355
+	{
356
+		EED_Single_Page_Checkout::load_request_handler();
357
+		EE_Registry::instance()->REQ->set('step', 'attendee_information');
358
+		EE_Registry::instance()->REQ->set('action', 'display_spco_reg_step');
359
+		EE_Registry::instance()->REQ->set('process_form_submission', false);
360
+		EED_Single_Page_Checkout::instance()->_initialize();
361
+		EED_Single_Page_Checkout::instance()->_display_spco_reg_form();
362
+		return EE_Registry::instance()->REQ->get_output();
363
+	}
364
+
365
+
366
+
367
+	/**
368
+	 * process_registration_from_admin
369
+	 *
370
+	 * @access public
371
+	 * @return \EE_Transaction
372
+	 * @throws EE_Error
373
+	 */
374
+	public static function process_registration_from_admin()
375
+	{
376
+		EED_Single_Page_Checkout::load_request_handler();
377
+		EE_Registry::instance()->REQ->set('step', 'attendee_information');
378
+		EE_Registry::instance()->REQ->set('action', 'process_reg_step');
379
+		EE_Registry::instance()->REQ->set('process_form_submission', true);
380
+		EED_Single_Page_Checkout::instance()->_initialize();
381
+		if (EED_Single_Page_Checkout::instance()->checkout->current_step->completed()) {
382
+			$final_reg_step = end(EED_Single_Page_Checkout::instance()->checkout->reg_steps);
383
+			if ($final_reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration) {
384
+				EED_Single_Page_Checkout::instance()->checkout->set_reg_step_initiated($final_reg_step);
385
+				if ($final_reg_step->process_reg_step()) {
386
+					$final_reg_step->set_completed();
387
+					EED_Single_Page_Checkout::instance()->checkout->update_txn_reg_steps_array();
388
+					return EED_Single_Page_Checkout::instance()->checkout->transaction;
389
+				}
390
+			}
391
+		}
392
+		return null;
393
+	}
394
+
395
+
396
+
397
+	/**
398
+	 *    run
399
+	 *
400
+	 * @access    public
401
+	 * @param WP_Query $WP_Query
402
+	 * @return    void
403
+	 * @throws EE_Error
404
+	 */
405
+	public function run($WP_Query)
406
+	{
407
+		if (
408
+			$WP_Query instanceof WP_Query
409
+			&& $WP_Query->is_main_query()
410
+			&& apply_filters('FHEE__EED_Single_Page_Checkout__run', true)
411
+			&& $this->_is_reg_checkout()
412
+		) {
413
+			$this->_initialize();
414
+		}
415
+	}
416
+
417
+
418
+
419
+	/**
420
+	 * determines whether current url matches reg page url
421
+	 *
422
+	 * @return bool
423
+	 */
424
+	protected function _is_reg_checkout()
425
+	{
426
+		// get current permalink for reg page without any extra query args
427
+		$reg_page_url = \get_permalink(EE_Config::instance()->core->reg_page_id);
428
+		// get request URI for current request, but without the scheme or host
429
+		$current_request_uri = \EEH_URL::filter_input_server_url('REQUEST_URI');
430
+		$current_request_uri = html_entity_decode($current_request_uri);
431
+		// get array of query args from the current request URI
432
+		$query_args = \EEH_URL::get_query_string($current_request_uri);
433
+		// grab page id if it is set
434
+		$page_id = isset($query_args['page_id']) ? absint($query_args['page_id']) : 0;
435
+		// and remove the page id from the query args (we will re-add it later)
436
+		unset($query_args['page_id']);
437
+		// now strip all query args from current request URI
438
+		$current_request_uri = remove_query_arg(array_keys($query_args), $current_request_uri);
439
+		// and re-add the page id if it was set
440
+		if ($page_id) {
441
+			$current_request_uri = add_query_arg('page_id', $page_id, $current_request_uri);
442
+		}
443
+		// remove slashes and ?
444
+		$current_request_uri = trim($current_request_uri, '?/');
445
+		// is current request URI part of the known full reg page URL ?
446
+		return ! empty($current_request_uri) && strpos($reg_page_url, $current_request_uri) !== false;
447
+	}
448
+
449
+
450
+
451
+	/**
452
+	 * @param WP_Query $wp_query
453
+	 * @return    void
454
+	 * @throws EE_Error
455
+	 */
456
+	public static function init($wp_query)
457
+	{
458
+		EED_Single_Page_Checkout::instance()->run($wp_query);
459
+	}
460
+
461
+
462
+
463
+	/**
464
+	 *    _initialize - initial module setup
465
+	 *
466
+	 * @access    private
467
+	 * @throws EE_Error
468
+	 * @return    void
469
+	 */
470
+	private function _initialize()
471
+	{
472
+		// ensure SPCO doesn't run twice
473
+		if (EED_Single_Page_Checkout::$_initialized) {
474
+			return;
475
+		}
476
+		try {
477
+			EED_Single_Page_Checkout::load_reg_steps();
478
+			$this->_verify_session();
479
+			// setup the EE_Checkout object
480
+			$this->checkout = $this->_initialize_checkout();
481
+			// filter checkout
482
+			$this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout);
483
+			// get the $_GET
484
+			$this->_get_request_vars();
485
+			if ($this->_block_bots()) {
486
+				return;
487
+			}
488
+			// filter continue_reg
489
+			$this->checkout->continue_reg = apply_filters(
490
+				'FHEE__EED_Single_Page_Checkout__init___continue_reg',
491
+				true,
492
+				$this->checkout
493
+			);
494
+			// load the reg steps array
495
+			if ( ! $this->_load_and_instantiate_reg_steps()) {
496
+				EED_Single_Page_Checkout::$_initialized = true;
497
+				return;
498
+			}
499
+			// set the current step
500
+			$this->checkout->set_current_step($this->checkout->step);
501
+			// and the next step
502
+			$this->checkout->set_next_step();
503
+			// verify that everything has been setup correctly
504
+			if ( ! ($this->_verify_transaction_and_get_registrations() && $this->_final_verifications())) {
505
+				EED_Single_Page_Checkout::$_initialized = true;
506
+				return;
507
+			}
508
+			// lock the transaction
509
+			$this->checkout->transaction->lock();
510
+			// make sure all of our cached objects are added to their respective model entity mappers
511
+			$this->checkout->refresh_all_entities();
512
+			// set amount owing
513
+			$this->checkout->amount_owing = $this->checkout->transaction->remaining();
514
+			// initialize each reg step, which gives them the chance to potentially alter the process
515
+			$this->_initialize_reg_steps();
516
+			// DEBUG LOG
517
+			//$this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ );
518
+			// get reg form
519
+			if( ! $this->_check_form_submission()) {
520
+				EED_Single_Page_Checkout::$_initialized = true;
521
+				return;
522
+			}
523
+			// checkout the action!!!
524
+			$this->_process_form_action();
525
+			// add some style and make it dance
526
+			$this->add_styles_and_scripts();
527
+			// kk... SPCO has successfully run
528
+			EED_Single_Page_Checkout::$_initialized = true;
529
+			// set no cache headers and constants
530
+			EE_System::do_not_cache();
531
+			// add anchor
532
+			add_action('loop_start', array($this, 'set_checkout_anchor'), 1);
533
+			// remove transaction lock
534
+			add_action('shutdown', array($this, 'unlock_transaction'), 1);
535
+		} catch (Exception $e) {
536
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
537
+		}
538
+	}
539
+
540
+
541
+
542
+	/**
543
+	 *    _verify_session
544
+	 * checks that the session is valid and not expired
545
+	 *
546
+	 * @access    private
547
+	 * @throws EE_Error
548
+	 */
549
+	private function _verify_session()
550
+	{
551
+		if ( ! EE_Registry::instance()->SSN instanceof EE_Session) {
552
+			throw new EE_Error(__('The EE_Session class could not be loaded.', 'event_espresso'));
553
+		}
554
+		// is session still valid ?
555
+		if (
556
+			EE_Registry::instance()->SSN->expired()
557
+			&& EE_Registry::instance()->REQ->get('e_reg_url_link', '') === ''
558
+		) {
559
+			$this->checkout = new EE_Checkout();
560
+			EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
561
+			// EE_Registry::instance()->SSN->reset_cart();
562
+			// EE_Registry::instance()->SSN->reset_checkout();
563
+			// EE_Registry::instance()->SSN->reset_transaction();
564
+			EE_Error::add_attention(
565
+				EE_Registry::$i18n_js_strings['registration_expiration_notice'],
566
+				__FILE__, __FUNCTION__, __LINE__
567
+			);
568
+			// EE_Registry::instance()->SSN->reset_expired();
569
+		}
570
+	}
571
+
572
+
573
+
574
+	/**
575
+	 *    _initialize_checkout
576
+	 * loads and instantiates EE_Checkout
577
+	 *
578
+	 * @access    private
579
+	 * @throws EE_Error
580
+	 * @return EE_Checkout
581
+	 */
582
+	private function _initialize_checkout()
583
+	{
584
+		// look in session for existing checkout
585
+		/** @type EE_Checkout $checkout */
586
+		$checkout = EE_Registry::instance()->SSN->checkout();
587
+		// verify
588
+		if ( ! $checkout instanceof EE_Checkout) {
589
+			// instantiate EE_Checkout object for handling the properties of the current checkout process
590
+			$checkout = EE_Registry::instance()->load_file(
591
+				SPCO_INC_PATH,
592
+				'EE_Checkout',
593
+				'class', array(),
594
+				false
595
+			);
596
+		} else {
597
+			if ($checkout->current_step->is_final_step() && $checkout->exit_spco() === true) {
598
+				$this->unlock_transaction();
599
+				wp_safe_redirect($checkout->redirect_url);
600
+				exit();
601
+			}
602
+		}
603
+		$checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout);
604
+		// verify again
605
+		if ( ! $checkout instanceof EE_Checkout) {
606
+			throw new EE_Error(__('The EE_Checkout class could not be loaded.', 'event_espresso'));
607
+		}
608
+		// reset anything that needs a clean slate for each request
609
+		$checkout->reset_for_current_request();
610
+		return $checkout;
611
+	}
612
+
613
+
614
+
615
+	/**
616
+	 *    _get_request_vars
617
+	 *
618
+	 * @access    private
619
+	 * @return    void
620
+	 * @throws EE_Error
621
+	 */
622
+	private function _get_request_vars()
623
+	{
624
+		// load classes
625
+		EED_Single_Page_Checkout::load_request_handler();
626
+		//make sure this request is marked as belonging to EE
627
+		EE_Registry::instance()->REQ->set_espresso_page(true);
628
+		// which step is being requested ?
629
+		$this->checkout->step = EE_Registry::instance()->REQ->get('step', $this->_get_first_step());
630
+		// which step is being edited ?
631
+		$this->checkout->edit_step = EE_Registry::instance()->REQ->get('edit_step', '');
632
+		// and what we're doing on the current step
633
+		$this->checkout->action = EE_Registry::instance()->REQ->get('action', 'display_spco_reg_step');
634
+		// timestamp
635
+		$this->checkout->uts = EE_Registry::instance()->REQ->get('uts', 0);
636
+		// returning to edit ?
637
+		$this->checkout->reg_url_link = EE_Registry::instance()->REQ->get('e_reg_url_link', '');
638
+		// or some other kind of revisit ?
639
+		$this->checkout->revisit = filter_var(
640
+			EE_Registry::instance()->REQ->get('revisit', false),
641
+			FILTER_VALIDATE_BOOLEAN
642
+		);
643
+		// and whether or not to generate a reg form for this request
644
+		$this->checkout->generate_reg_form = filter_var(
645
+			EE_Registry::instance()->REQ->get('generate_reg_form', true),
646
+			FILTER_VALIDATE_BOOLEAN
647
+		);
648
+		// and whether or not to process a reg form submission for this request
649
+		$this->checkout->process_form_submission = filter_var(
650
+			EE_Registry::instance()->REQ->get(
651
+				'process_form_submission',
652
+				$this->checkout->action === 'process_reg_step'
653
+			),
654
+			FILTER_VALIDATE_BOOLEAN
655
+		);
656
+		$this->checkout->process_form_submission = filter_var(
657
+			$this->checkout->action !== 'display_spco_reg_step'
658
+				? $this->checkout->process_form_submission
659
+				: false,
660
+			FILTER_VALIDATE_BOOLEAN
661
+		);
662
+		// $this->_display_request_vars();
663
+	}
664
+
665
+
666
+
667
+	/**
668
+	 *  _display_request_vars
669
+	 *
670
+	 * @access    protected
671
+	 * @return    void
672
+	 */
673
+	protected function _display_request_vars()
674
+	{
675
+		if ( ! WP_DEBUG) {
676
+			return;
677
+		}
678
+		EEH_Debug_Tools::printr($_REQUEST, '$_REQUEST', __FILE__, __LINE__);
679
+		EEH_Debug_Tools::printr($this->checkout->step, '$this->checkout->step', __FILE__, __LINE__);
680
+		EEH_Debug_Tools::printr($this->checkout->edit_step, '$this->checkout->edit_step', __FILE__, __LINE__);
681
+		EEH_Debug_Tools::printr($this->checkout->action, '$this->checkout->action', __FILE__, __LINE__);
682
+		EEH_Debug_Tools::printr($this->checkout->reg_url_link, '$this->checkout->reg_url_link', __FILE__, __LINE__);
683
+		EEH_Debug_Tools::printr($this->checkout->revisit, '$this->checkout->revisit', __FILE__, __LINE__);
684
+		EEH_Debug_Tools::printr($this->checkout->generate_reg_form, '$this->checkout->generate_reg_form', __FILE__, __LINE__);
685
+		EEH_Debug_Tools::printr($this->checkout->process_form_submission, '$this->checkout->process_form_submission', __FILE__, __LINE__);
686
+	}
687
+
688
+
689
+
690
+	/**
691
+	 * _block_bots
692
+	 * checks that the incoming request has either of the following set:
693
+	 *  a uts (unix timestamp) which indicates that the request was redirected from the Ticket Selector
694
+	 *  a REG URL Link, which indicates that the request is a return visit to SPCO for a valid TXN
695
+	 * so if you're not coming from the Ticket Selector nor returning for a valid IP...
696
+	 * then where you coming from man?
697
+	 *
698
+	 * @return boolean
699
+	 */
700
+	private function _block_bots()
701
+	{
702
+		$invalid_checkout_access = EED_Invalid_Checkout_Access::getInvalidCheckoutAccess();
703
+		if ($invalid_checkout_access->checkoutAccessIsInvalid($this->checkout)) {
704
+			return true;
705
+		}
706
+		return false;
707
+	}
708
+
709
+
710
+
711
+	/**
712
+	 *    _get_first_step
713
+	 *  gets slug for first step in $_reg_steps_array
714
+	 *
715
+	 * @access    private
716
+	 * @throws EE_Error
717
+	 * @return    string
718
+	 */
719
+	private function _get_first_step()
720
+	{
721
+		$first_step = reset(EED_Single_Page_Checkout::$_reg_steps_array);
722
+		return isset($first_step['slug']) ? $first_step['slug'] : 'attendee_information';
723
+	}
724
+
725
+
726
+
727
+	/**
728
+	 *    _load_and_instantiate_reg_steps
729
+	 *  instantiates each reg step based on the loaded reg_steps array
730
+	 *
731
+	 * @access    private
732
+	 * @throws EE_Error
733
+	 * @return    bool
734
+	 */
735
+	private function _load_and_instantiate_reg_steps()
736
+	{
737
+		do_action('AHEE__Single_Page_Checkout___load_and_instantiate_reg_steps__start', $this->checkout);
738
+		// have reg_steps already been instantiated ?
739
+		if (
740
+			empty($this->checkout->reg_steps)
741
+			|| apply_filters('FHEE__Single_Page_Checkout__load_reg_steps__reload_reg_steps', false, $this->checkout)
742
+		) {
743
+			// if not, then loop through raw reg steps array
744
+			foreach (EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step) {
745
+				if ( ! $this->_load_and_instantiate_reg_step($reg_step, $order)) {
746
+					return false;
747
+				}
748
+			}
749
+			EE_Registry::instance()->CFG->registration->skip_reg_confirmation = true;
750
+			EE_Registry::instance()->CFG->registration->reg_confirmation_last = true;
751
+			// skip the registration_confirmation page ?
752
+			if (EE_Registry::instance()->CFG->registration->skip_reg_confirmation) {
753
+				// just remove it from the reg steps array
754
+				$this->checkout->remove_reg_step('registration_confirmation', false);
755
+			} else if (
756
+				isset($this->checkout->reg_steps['registration_confirmation'])
757
+				&& EE_Registry::instance()->CFG->registration->reg_confirmation_last
758
+			) {
759
+				// set the order to something big like 100
760
+				$this->checkout->set_reg_step_order('registration_confirmation', 100);
761
+			}
762
+			// filter the array for good luck
763
+			$this->checkout->reg_steps = apply_filters(
764
+				'FHEE__Single_Page_Checkout__load_reg_steps__reg_steps',
765
+				$this->checkout->reg_steps
766
+			);
767
+			// finally re-sort based on the reg step class order properties
768
+			$this->checkout->sort_reg_steps();
769
+		} else {
770
+			foreach ($this->checkout->reg_steps as $reg_step) {
771
+				// set all current step stati to FALSE
772
+				$reg_step->set_is_current_step(false);
773
+			}
774
+		}
775
+		if (empty($this->checkout->reg_steps)) {
776
+			EE_Error::add_error(
777
+				__('No Reg Steps were loaded..', 'event_espresso'),
778
+				__FILE__, __FUNCTION__, __LINE__
779
+			);
780
+			return false;
781
+		}
782
+		// make reg step details available to JS
783
+		$this->checkout->set_reg_step_JSON_info();
784
+		return true;
785
+	}
786
+
787
+
788
+
789
+	/**
790
+	 *     _load_and_instantiate_reg_step
791
+	 *
792
+	 * @access    private
793
+	 * @param array $reg_step
794
+	 * @param int   $order
795
+	 * @return bool
796
+	 */
797
+	private function _load_and_instantiate_reg_step($reg_step = array(), $order = 0)
798
+	{
799
+		// we need a file_path, class_name, and slug to add a reg step
800
+		if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) {
801
+			// if editing a specific step, but this is NOT that step... (and it's not the 'finalize_registration' step)
802
+			if (
803
+				$this->checkout->reg_url_link
804
+				&& $this->checkout->step !== $reg_step['slug']
805
+				&& $reg_step['slug'] !== 'finalize_registration'
806
+				// normally at this point we would NOT load the reg step, but this filter can change that
807
+				&& apply_filters(
808
+					'FHEE__Single_Page_Checkout___load_and_instantiate_reg_step__bypass_reg_step',
809
+					true,
810
+					$reg_step,
811
+					$this->checkout
812
+				)
813
+			) {
814
+				return true;
815
+			}
816
+			// instantiate step class using file path and class name
817
+			$reg_step_obj = EE_Registry::instance()->load_file(
818
+				$reg_step['file_path'],
819
+				$reg_step['class_name'],
820
+				'class',
821
+				$this->checkout,
822
+				false
823
+			);
824
+			// did we gets the goods ?
825
+			if ($reg_step_obj instanceof EE_SPCO_Reg_Step) {
826
+				// set reg step order based on config
827
+				$reg_step_obj->set_order($order);
828
+				// add instantiated reg step object to the master reg steps array
829
+				$this->checkout->add_reg_step($reg_step_obj);
830
+			} else {
831
+				EE_Error::add_error(
832
+					__('The current step could not be set.', 'event_espresso'),
833
+					__FILE__, __FUNCTION__, __LINE__
834
+				);
835
+				return false;
836
+			}
837
+		} else {
838
+			if (WP_DEBUG) {
839
+				EE_Error::add_error(
840
+					sprintf(
841
+						__(
842
+							'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',
843
+							'event_espresso'
844
+						),
845
+						isset($reg_step['file_path']) ? $reg_step['file_path'] : '',
846
+						isset($reg_step['class_name']) ? $reg_step['class_name'] : '',
847
+						isset($reg_step['slug']) ? $reg_step['slug'] : '',
848
+						'<ul>',
849
+						'<li>',
850
+						'</li>',
851
+						'</ul>'
852
+					),
853
+					__FILE__, __FUNCTION__, __LINE__
854
+				);
855
+			}
856
+			return false;
857
+		}
858
+		return true;
859
+	}
860
+
861
+
862
+	/**
863
+	 * _verify_transaction_and_get_registrations
864
+	 *
865
+	 * @access private
866
+	 * @return bool
867
+	 * @throws InvalidDataTypeException
868
+	 * @throws InvalidEntityException
869
+	 * @throws EE_Error
870
+	 */
871
+	private function _verify_transaction_and_get_registrations()
872
+	{
873
+		// was there already a valid transaction in the checkout from the session ?
874
+		if ( ! $this->checkout->transaction instanceof EE_Transaction) {
875
+			// get transaction from db or session
876
+			$this->checkout->transaction = $this->checkout->reg_url_link && ! is_admin()
877
+				? $this->_get_transaction_and_cart_for_previous_visit()
878
+				: $this->_get_cart_for_current_session_and_setup_new_transaction();
879
+			if ( ! $this->checkout->transaction instanceof EE_Transaction) {
880
+				EE_Error::add_error(
881
+					__('Your Registration and Transaction information could not be retrieved from the db.',
882
+						'event_espresso'),
883
+					__FILE__, __FUNCTION__, __LINE__
884
+				);
885
+				$this->checkout->transaction = EE_Transaction::new_instance();
886
+				// add some style and make it dance
887
+				$this->add_styles_and_scripts();
888
+				EED_Single_Page_Checkout::$_initialized = true;
889
+				return false;
890
+			}
891
+			// and the registrations for the transaction
892
+			$this->_get_registrations($this->checkout->transaction);
893
+		}
894
+		return true;
895
+	}
896
+
897
+
898
+
899
+	/**
900
+	 * _get_transaction_and_cart_for_previous_visit
901
+	 *
902
+	 * @access private
903
+	 * @return mixed EE_Transaction|NULL
904
+	 */
905
+	private function _get_transaction_and_cart_for_previous_visit()
906
+	{
907
+		/** @var $TXN_model EEM_Transaction */
908
+		$TXN_model = EE_Registry::instance()->load_model('Transaction');
909
+		// because the reg_url_link is present in the request,
910
+		// this is a return visit to SPCO, so we'll get the transaction data from the db
911
+		$transaction = $TXN_model->get_transaction_from_reg_url_link($this->checkout->reg_url_link);
912
+		// verify transaction
913
+		if ($transaction instanceof EE_Transaction) {
914
+			// and get the cart that was used for that transaction
915
+			$this->checkout->cart = $this->_get_cart_for_transaction($transaction);
916
+			return $transaction;
917
+		}
918
+		EE_Error::add_error(
919
+			__('Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso'),
920
+			__FILE__, __FUNCTION__, __LINE__
921
+		);
922
+		return null;
923
+
924
+	}
925
+
926
+
927
+
928
+	/**
929
+	 * _get_cart_for_transaction
930
+	 *
931
+	 * @access private
932
+	 * @param EE_Transaction $transaction
933
+	 * @return EE_Cart
934
+	 */
935
+	private function _get_cart_for_transaction($transaction)
936
+	{
937
+		return $this->checkout->get_cart_for_transaction($transaction);
938
+	}
939
+
940
+
941
+
942
+	/**
943
+	 * get_cart_for_transaction
944
+	 *
945
+	 * @access public
946
+	 * @param EE_Transaction $transaction
947
+	 * @return EE_Cart
948
+	 */
949
+	public function get_cart_for_transaction(EE_Transaction $transaction)
950
+	{
951
+		return $this->checkout->get_cart_for_transaction($transaction);
952
+	}
953
+
954
+
955
+
956
+	/**
957
+	 * _get_transaction_and_cart_for_current_session
958
+	 *    generates a new EE_Transaction object and adds it to the $_transaction property.
959
+	 *
960
+	 * @access private
961
+	 * @return EE_Transaction
962
+	 * @throws EE_Error
963
+	 */
964
+	private function _get_cart_for_current_session_and_setup_new_transaction()
965
+	{
966
+		//  if there's no transaction, then this is the FIRST visit to SPCO
967
+		// so load up the cart ( passing nothing for the TXN because it doesn't exist yet )
968
+		$this->checkout->cart = $this->_get_cart_for_transaction(null);
969
+		// and then create a new transaction
970
+		$transaction = $this->_initialize_transaction();
971
+		// verify transaction
972
+		if ($transaction instanceof EE_Transaction) {
973
+			// save it so that we have an ID for other objects to use
974
+			$transaction->save();
975
+			// and save TXN data to the cart
976
+			$this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn($transaction->ID());
977
+		} else {
978
+			EE_Error::add_error(
979
+				__('A Valid Transaction could not be initialized.', 'event_espresso'),
980
+				__FILE__, __FUNCTION__, __LINE__
981
+			);
982
+		}
983
+		return $transaction;
984
+	}
985
+
986
+
987
+
988
+	/**
989
+	 *    generates a new EE_Transaction object and adds it to the $_transaction property.
990
+	 *
991
+	 * @access private
992
+	 * @return mixed EE_Transaction|NULL
993
+	 */
994
+	private function _initialize_transaction()
995
+	{
996
+		try {
997
+			// ensure cart totals have been calculated
998
+			$this->checkout->cart->get_grand_total()->recalculate_total_including_taxes();
999
+			// grab the cart grand total
1000
+			$cart_total = $this->checkout->cart->get_cart_grand_total();
1001
+			// create new TXN
1002
+			$transaction = EE_Transaction::new_instance(
1003
+				array(
1004
+					'TXN_reg_steps' => $this->checkout->initialize_txn_reg_steps_array(),
1005
+					'TXN_total'     => $cart_total > 0 ? $cart_total : 0,
1006
+					'TXN_paid'      => 0,
1007
+					'STS_ID'        => EEM_Transaction::failed_status_code,
1008
+				)
1009
+			);
1010
+			// save it so that we have an ID for other objects to use
1011
+			$transaction->save();
1012
+			// set cron job for following up on TXNs after their session has expired
1013
+			EE_Cron_Tasks::schedule_expired_transaction_check(
1014
+				EE_Registry::instance()->SSN->expiration() + 1,
1015
+				$transaction->ID()
1016
+			);
1017
+			return $transaction;
1018
+		} catch (Exception $e) {
1019
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
1020
+		}
1021
+		return null;
1022
+	}
1023
+
1024
+
1025
+	/**
1026
+	 * _get_registrations
1027
+	 *
1028
+	 * @access private
1029
+	 * @param EE_Transaction $transaction
1030
+	 * @return void
1031
+	 * @throws InvalidDataTypeException
1032
+	 * @throws InvalidEntityException
1033
+	 * @throws EE_Error
1034
+	 */
1035
+	private function _get_registrations(EE_Transaction $transaction)
1036
+	{
1037
+		// first step: grab the registrants  { : o
1038
+		$registrations = $transaction->registrations($this->checkout->reg_cache_where_params, true);
1039
+		// verify registrations have been set
1040
+		if (empty($registrations)) {
1041
+			// if no cached registrations, then check the db
1042
+			$registrations = $transaction->registrations($this->checkout->reg_cache_where_params, false);
1043
+			// still nothing ? well as long as this isn't a revisit
1044
+			if (empty($registrations) && ! $this->checkout->revisit) {
1045
+				// generate new registrations from scratch
1046
+				$registrations = $this->_initialize_registrations($transaction);
1047
+			}
1048
+		}
1049
+		// sort by their original registration order
1050
+		usort($registrations, array('EED_Single_Page_Checkout', 'sort_registrations_by_REG_count'));
1051
+		// then loop thru the array
1052
+		foreach ($registrations as $registration) {
1053
+			// verify each registration
1054
+			if ($registration instanceof EE_Registration) {
1055
+				// we display all attendee info for the primary registrant
1056
+				if ($this->checkout->reg_url_link === $registration->reg_url_link()
1057
+					&& $registration->is_primary_registrant()
1058
+				) {
1059
+					$this->checkout->primary_revisit = true;
1060
+					break;
1061
+				}
1062
+				if ($this->checkout->revisit
1063
+						   && $this->checkout->reg_url_link !== $registration->reg_url_link()
1064
+				) {
1065
+					// but hide info if it doesn't belong to you
1066
+					$transaction->clear_cache('Registration', $registration->ID());
1067
+				}
1068
+				$this->checkout->set_reg_status_updated($registration->ID(), false);
1069
+			}
1070
+		}
1071
+	}
1072
+
1073
+
1074
+	/**
1075
+	 *    adds related EE_Registration objects for each ticket in the cart to the current EE_Transaction object
1076
+	 *
1077
+	 * @access private
1078
+	 * @param EE_Transaction $transaction
1079
+	 * @return    array
1080
+	 * @throws InvalidDataTypeException
1081
+	 * @throws InvalidEntityException
1082
+	 * @throws EE_Error
1083
+	 */
1084
+	private function _initialize_registrations(EE_Transaction $transaction)
1085
+	{
1086
+		$att_nmbr = 0;
1087
+		$registrations = array();
1088
+		if ($transaction instanceof EE_Transaction) {
1089
+			/** @type EE_Registration_Processor $registration_processor */
1090
+			$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
1091
+			$this->checkout->total_ticket_count = $this->checkout->cart->all_ticket_quantity_count();
1092
+			// now let's add the cart items to the $transaction
1093
+			foreach ($this->checkout->cart->get_tickets() as $line_item) {
1094
+				//do the following for each ticket of this type they selected
1095
+				for ($x = 1; $x <= $line_item->quantity(); $x++) {
1096
+					$att_nmbr++;
1097
+					/** @var EventEspresso\core\services\commands\registration\CreateRegistrationCommand $CreateRegistrationCommand */
1098
+					$CreateRegistrationCommand = EE_Registry::instance()->create(
1099
+						'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
1100
+						array(
1101
+							$transaction,
1102
+							$line_item,
1103
+							$att_nmbr,
1104
+							$this->checkout->total_ticket_count,
1105
+						)
1106
+					);
1107
+					// override capabilities for frontend registrations
1108
+					if ( ! is_admin()) {
1109
+						$CreateRegistrationCommand->setCapCheck(
1110
+							new PublicCapabilities('', 'create_new_registration')
1111
+						);
1112
+					}
1113
+					$registration = EE_Registry::instance()->BUS->execute($CreateRegistrationCommand);
1114
+					if ( ! $registration instanceof EE_Registration) {
1115
+						throw new InvalidEntityException($registration, 'EE_Registration');
1116
+					}
1117
+					$registrations[ $registration->ID() ] = $registration;
1118
+				}
1119
+			}
1120
+			$registration_processor->fix_reg_final_price_rounding_issue($transaction);
1121
+		}
1122
+		return $registrations;
1123
+	}
1124
+
1125
+
1126
+
1127
+	/**
1128
+	 * sorts registrations by REG_count
1129
+	 *
1130
+	 * @access public
1131
+	 * @param EE_Registration $reg_A
1132
+	 * @param EE_Registration $reg_B
1133
+	 * @return int
1134
+	 */
1135
+	public static function sort_registrations_by_REG_count(EE_Registration $reg_A, EE_Registration $reg_B)
1136
+	{
1137
+		// this shouldn't ever happen within the same TXN, but oh well
1138
+		if ($reg_A->count() === $reg_B->count()) {
1139
+			return 0;
1140
+		}
1141
+		return ($reg_A->count() > $reg_B->count()) ? 1 : -1;
1142
+	}
1143
+
1144
+
1145
+
1146
+	/**
1147
+	 *    _final_verifications
1148
+	 * just makes sure that everything is set up correctly before proceeding
1149
+	 *
1150
+	 * @access    private
1151
+	 * @return    bool
1152
+	 * @throws EE_Error
1153
+	 */
1154
+	private function _final_verifications()
1155
+	{
1156
+		// filter checkout
1157
+		$this->checkout = apply_filters(
1158
+			'FHEE__EED_Single_Page_Checkout___final_verifications__checkout',
1159
+			$this->checkout
1160
+		);
1161
+		//verify that current step is still set correctly
1162
+		if ( ! $this->checkout->current_step instanceof EE_SPCO_Reg_Step) {
1163
+			EE_Error::add_error(
1164
+				__('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'),
1165
+				__FILE__,
1166
+				__FUNCTION__,
1167
+				__LINE__
1168
+			);
1169
+			return false;
1170
+		}
1171
+		// if returning to SPCO, then verify that primary registrant is set
1172
+		if ( ! empty($this->checkout->reg_url_link)) {
1173
+			$valid_registrant = $this->checkout->transaction->primary_registration();
1174
+			if ( ! $valid_registrant instanceof EE_Registration) {
1175
+				EE_Error::add_error(
1176
+					__('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'),
1177
+					__FILE__,
1178
+					__FUNCTION__,
1179
+					__LINE__
1180
+				);
1181
+				return false;
1182
+			}
1183
+			$valid_registrant = null;
1184
+			foreach (
1185
+				$this->checkout->transaction->registrations($this->checkout->reg_cache_where_params) as $registration
1186
+			) {
1187
+				if (
1188
+					$registration instanceof EE_Registration
1189
+					&& $registration->reg_url_link() === $this->checkout->reg_url_link
1190
+				) {
1191
+					$valid_registrant = $registration;
1192
+				}
1193
+			}
1194
+			if ( ! $valid_registrant instanceof EE_Registration) {
1195
+				// hmmm... maybe we have the wrong session because the user is opening multiple tabs ?
1196
+				if (EED_Single_Page_Checkout::$_checkout_verified) {
1197
+					// clear the session, mark the checkout as unverified, and try again
1198
+					EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
1199
+					EED_Single_Page_Checkout::$_initialized = false;
1200
+					EED_Single_Page_Checkout::$_checkout_verified = false;
1201
+					$this->_initialize();
1202
+					EE_Error::reset_notices();
1203
+					return false;
1204
+				}
1205
+				EE_Error::add_error(
1206
+					__(
1207
+						'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.',
1208
+						'event_espresso'
1209
+					),
1210
+					__FILE__,
1211
+					__FUNCTION__,
1212
+					__LINE__
1213
+				);
1214
+				return false;
1215
+			}
1216
+		}
1217
+		// now that things have been kinda sufficiently verified,
1218
+		// let's add the checkout to the session so that it's available to other systems
1219
+		EE_Registry::instance()->SSN->set_checkout($this->checkout);
1220
+		return true;
1221
+	}
1222
+
1223
+
1224
+
1225
+	/**
1226
+	 *    _initialize_reg_steps
1227
+	 * first makes sure that EE_Transaction_Processor::set_reg_step_initiated() is called as required
1228
+	 * then loops thru all of the active reg steps and calls the initialize_reg_step() method
1229
+	 *
1230
+	 * @access    private
1231
+	 * @param bool $reinitializing
1232
+	 * @throws EE_Error
1233
+	 */
1234
+	private function _initialize_reg_steps($reinitializing = false)
1235
+	{
1236
+		$this->checkout->set_reg_step_initiated($this->checkout->current_step);
1237
+		// loop thru all steps to call their individual "initialize" methods and set i18n strings for JS
1238
+		foreach ($this->checkout->reg_steps as $reg_step) {
1239
+			if ( ! $reg_step->initialize_reg_step()) {
1240
+				// if not initialized then maybe this step is being removed...
1241
+				if ( ! $reinitializing && $reg_step->is_current_step()) {
1242
+					// if it was the current step, then we need to start over here
1243
+					$this->_initialize_reg_steps(true);
1244
+					return;
1245
+				}
1246
+				continue;
1247
+			}
1248
+			// add css and JS for current step
1249
+			$reg_step->enqueue_styles_and_scripts();
1250
+			// i18n
1251
+			$reg_step->translate_js_strings();
1252
+			if ($reg_step->is_current_step()) {
1253
+				// the text that appears on the reg step form submit button
1254
+				$reg_step->set_submit_button_text();
1255
+			}
1256
+		}
1257
+		// dynamically creates hook point like: AHEE__Single_Page_Checkout___initialize_reg_step__attendee_information
1258
+		do_action(
1259
+			"AHEE__Single_Page_Checkout___initialize_reg_step__{$this->checkout->current_step->slug()}",
1260
+			$this->checkout->current_step
1261
+		);
1262
+	}
1263
+
1264
+
1265
+
1266
+	/**
1267
+	 * _check_form_submission
1268
+	 *
1269
+	 * @access private
1270
+	 * @return boolean
1271
+	 */
1272
+	private function _check_form_submission()
1273
+	{
1274
+		//does this request require the reg form to be generated ?
1275
+		if ($this->checkout->generate_reg_form) {
1276
+			// ever heard that song by Blue Rodeo ?
1277
+			try {
1278
+				$this->checkout->current_step->reg_form = $this->checkout->current_step->generate_reg_form();
1279
+				// if not displaying a form, then check for form submission
1280
+				if (
1281
+					$this->checkout->process_form_submission
1282
+					&& $this->checkout->current_step->reg_form->was_submitted()
1283
+				) {
1284
+					// clear out any old data in case this step is being run again
1285
+					$this->checkout->current_step->set_valid_data(array());
1286
+					// capture submitted form data
1287
+					$this->checkout->current_step->reg_form->receive_form_submission(
1288
+						apply_filters(
1289
+							'FHEE__Single_Page_Checkout___check_form_submission__request_params',
1290
+							EE_Registry::instance()->REQ->params(),
1291
+							$this->checkout
1292
+						)
1293
+					);
1294
+					// validate submitted form data
1295
+					if ( ! $this->checkout->continue_reg || ! $this->checkout->current_step->reg_form->is_valid()) {
1296
+						// thou shall not pass !!!
1297
+						$this->checkout->continue_reg = false;
1298
+						// any form validation errors?
1299
+						if ($this->checkout->current_step->reg_form->submission_error_message() !== '') {
1300
+							$submission_error_messages = array();
1301
+							// bad, bad, bad registrant
1302
+							foreach (
1303
+								$this->checkout->current_step->reg_form->get_validation_errors_accumulated()
1304
+								as $validation_error
1305
+							) {
1306
+								if ($validation_error instanceof EE_Validation_Error) {
1307
+									$submission_error_messages[] = sprintf(
1308
+										__('%s : %s', 'event_espresso'),
1309
+										$validation_error->get_form_section()->html_label_text(),
1310
+										$validation_error->getMessage()
1311
+									);
1312
+								}
1313
+							}
1314
+							EE_Error::add_error(
1315
+								implode('<br />', $submission_error_messages),
1316
+								__FILE__, __FUNCTION__, __LINE__
1317
+							);
1318
+						}
1319
+						// well not really... what will happen is
1320
+						// we'll just get redirected back to redo the current step
1321
+						$this->go_to_next_step();
1322
+						return false;
1323
+					}
1324
+				}
1325
+			} catch (EE_Error $e) {
1326
+				$e->get_error();
1327
+			}
1328
+		}
1329
+		return true;
1330
+	}
1331
+
1332
+
1333
+
1334
+	/**
1335
+	 * _process_action
1336
+	 *
1337
+	 * @access private
1338
+	 * @return void
1339
+	 * @throws EE_Error
1340
+	 */
1341
+	private function _process_form_action()
1342
+	{
1343
+		// what cha wanna do?
1344
+		switch ($this->checkout->action) {
1345
+			// AJAX next step reg form
1346
+			case 'display_spco_reg_step' :
1347
+				$this->checkout->redirect = false;
1348
+				if (EE_Registry::instance()->REQ->ajax) {
1349
+					$this->checkout->json_response->set_reg_step_html(
1350
+						$this->checkout->current_step->display_reg_form()
1351
+					);
1352
+				}
1353
+				break;
1354
+			default :
1355
+				// meh... do one of those other steps first
1356
+				if (
1357
+					! empty($this->checkout->action)
1358
+					&& is_callable(array($this->checkout->current_step, $this->checkout->action))
1359
+				) {
1360
+					// dynamically creates hook point like:
1361
+					//   AHEE__Single_Page_Checkout__before_attendee_information__process_reg_step
1362
+					do_action(
1363
+						"AHEE__Single_Page_Checkout__before_{$this->checkout->current_step->slug()}__{$this->checkout->action}",
1364
+						$this->checkout->current_step
1365
+					);
1366
+					// call action on current step
1367
+					if (call_user_func(array($this->checkout->current_step, $this->checkout->action))) {
1368
+						// good registrant, you get to proceed
1369
+						if (
1370
+							$this->checkout->current_step->success_message() !== ''
1371
+							&& apply_filters(
1372
+								'FHEE__Single_Page_Checkout___process_form_action__display_success',
1373
+								false
1374
+							)
1375
+						) {
1376
+							EE_Error::add_success(
1377
+								$this->checkout->current_step->success_message()
1378
+								. '<br />' . $this->checkout->next_step->_instructions()
1379
+							);
1380
+						}
1381
+						// pack it up, pack it in...
1382
+						$this->_setup_redirect();
1383
+					}
1384
+					// dynamically creates hook point like:
1385
+					//  AHEE__Single_Page_Checkout__after_payment_options__process_reg_step
1386
+					do_action(
1387
+						"AHEE__Single_Page_Checkout__after_{$this->checkout->current_step->slug()}__{$this->checkout->action}",
1388
+						$this->checkout->current_step
1389
+					);
1390
+				} else {
1391
+					EE_Error::add_error(
1392
+						sprintf(
1393
+							__(
1394
+								'The requested form action "%s" does not exist for the current "%s" registration step.',
1395
+								'event_espresso'
1396
+							),
1397
+							$this->checkout->action,
1398
+							$this->checkout->current_step->name()
1399
+						),
1400
+						__FILE__,
1401
+						__FUNCTION__,
1402
+						__LINE__
1403
+					);
1404
+				}
1405
+			// end default
1406
+		}
1407
+		// store our progress so far
1408
+		$this->checkout->stash_transaction_and_checkout();
1409
+		// advance to the next step! If you pass GO, collect $200
1410
+		$this->go_to_next_step();
1411
+	}
1412
+
1413
+
1414
+
1415
+	/**
1416
+	 *        add_styles_and_scripts
1417
+	 *
1418
+	 * @access        public
1419
+	 * @return        void
1420
+	 */
1421
+	public function add_styles_and_scripts()
1422
+	{
1423
+		// i18n
1424
+		$this->translate_js_strings();
1425
+		if ($this->checkout->admin_request) {
1426
+			add_action('admin_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10);
1427
+		} else {
1428
+			add_action('wp_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10);
1429
+		}
1430
+	}
1431
+
1432
+
1433
+
1434
+	/**
1435
+	 *        translate_js_strings
1436
+	 *
1437
+	 * @access        public
1438
+	 * @return        void
1439
+	 */
1440
+	public function translate_js_strings()
1441
+	{
1442
+		EE_Registry::$i18n_js_strings['revisit'] = $this->checkout->revisit;
1443
+		EE_Registry::$i18n_js_strings['e_reg_url_link'] = $this->checkout->reg_url_link;
1444
+		EE_Registry::$i18n_js_strings['server_error'] = __(
1445
+			'An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again or contact support.',
1446
+			'event_espresso'
1447
+		);
1448
+		EE_Registry::$i18n_js_strings['invalid_json_response'] = __(
1449
+			'An invalid response was returned from the server while attempting to process your request. Please refresh the page and try again or contact support.',
1450
+			'event_espresso'
1451
+		);
1452
+		EE_Registry::$i18n_js_strings['validation_error'] = __(
1453
+			'There appears to be a problem with the form validation configuration! Please check the admin settings or contact support.',
1454
+			'event_espresso'
1455
+		);
1456
+		EE_Registry::$i18n_js_strings['invalid_payment_method'] = __(
1457
+			'There appears to be a problem with the payment method configuration! Please refresh the page and try again or contact support.',
1458
+			'event_espresso'
1459
+		);
1460
+		EE_Registry::$i18n_js_strings['reg_step_error'] = __(
1461
+			'This registration step could not be completed. Please refresh the page and try again.',
1462
+			'event_espresso'
1463
+		);
1464
+		EE_Registry::$i18n_js_strings['invalid_coupon'] = __(
1465
+			'We\'re sorry but that coupon code does not appear to be valid. If this is incorrect, please contact the site administrator.',
1466
+			'event_espresso'
1467
+		);
1468
+		EE_Registry::$i18n_js_strings['process_registration'] = sprintf(
1469
+			__(
1470
+				'Please wait while we process your registration.%sDo not refresh the page or navigate away while this is happening.%sThank you for your patience.',
1471
+				'event_espresso'
1472
+			),
1473
+			'<br/>',
1474
+			'<br/>'
1475
+		);
1476
+		EE_Registry::$i18n_js_strings['language'] = get_bloginfo('language');
1477
+		EE_Registry::$i18n_js_strings['EESID'] = EE_Registry::instance()->SSN->id();
1478
+		EE_Registry::$i18n_js_strings['currency'] = EE_Registry::instance()->CFG->currency;
1479
+		EE_Registry::$i18n_js_strings['datepicker_yearRange'] = '-150:+20';
1480
+		EE_Registry::$i18n_js_strings['timer_years'] = __('years', 'event_espresso');
1481
+		EE_Registry::$i18n_js_strings['timer_months'] = __('months', 'event_espresso');
1482
+		EE_Registry::$i18n_js_strings['timer_weeks'] = __('weeks', 'event_espresso');
1483
+		EE_Registry::$i18n_js_strings['timer_days'] = __('days', 'event_espresso');
1484
+		EE_Registry::$i18n_js_strings['timer_hours'] = __('hours', 'event_espresso');
1485
+		EE_Registry::$i18n_js_strings['timer_minutes'] = __('minutes', 'event_espresso');
1486
+		EE_Registry::$i18n_js_strings['timer_seconds'] = __('seconds', 'event_espresso');
1487
+		EE_Registry::$i18n_js_strings['timer_year'] = __('year', 'event_espresso');
1488
+		EE_Registry::$i18n_js_strings['timer_month'] = __('month', 'event_espresso');
1489
+		EE_Registry::$i18n_js_strings['timer_week'] = __('week', 'event_espresso');
1490
+		EE_Registry::$i18n_js_strings['timer_day'] = __('day', 'event_espresso');
1491
+		EE_Registry::$i18n_js_strings['timer_hour'] = __('hour', 'event_espresso');
1492
+		EE_Registry::$i18n_js_strings['timer_minute'] = __('minute', 'event_espresso');
1493
+		EE_Registry::$i18n_js_strings['timer_second'] = __('second', 'event_espresso');
1494
+		EE_Registry::$i18n_js_strings['registration_expiration_notice'] = sprintf(
1495
+			__(
1496
+				'%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 except our apologies for any inconvenience this may have caused.%8$s',
1497
+				'event_espresso'
1498
+			),
1499
+			'<h4 class="important-notice">',
1500
+			'</h4>',
1501
+			'<br />',
1502
+			'<p>',
1503
+			'<a href="' . get_post_type_archive_link('espresso_events') . '" title="',
1504
+			'">',
1505
+			'</a>',
1506
+			'</p>'
1507
+		);
1508
+		EE_Registry::$i18n_js_strings['ajax_submit'] = apply_filters(
1509
+			'FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit',
1510
+			true
1511
+		);
1512
+		EE_Registry::$i18n_js_strings['session_extension'] = absint(
1513
+			apply_filters('FHEE__EE_Session__extend_expiration__seconds_added', 10 * MINUTE_IN_SECONDS)
1514
+		);
1515
+		EE_Registry::$i18n_js_strings['session_expiration'] = gmdate(
1516
+			'M d, Y H:i:s',
1517
+			EE_Registry::instance()->SSN->expiration() + (get_option('gmt_offset') * HOUR_IN_SECONDS)
1518
+		);
1519
+	}
1520
+
1521
+
1522
+
1523
+	/**
1524
+	 *    enqueue_styles_and_scripts
1525
+	 *
1526
+	 * @access        public
1527
+	 * @return        void
1528
+	 * @throws EE_Error
1529
+	 */
1530
+	public function enqueue_styles_and_scripts()
1531
+	{
1532
+		// load css
1533
+		wp_register_style(
1534
+			'single_page_checkout',
1535
+			SPCO_CSS_URL . 'single_page_checkout.css',
1536
+			array('espresso_default'),
1537
+			EVENT_ESPRESSO_VERSION
1538
+		);
1539
+		wp_enqueue_style('single_page_checkout');
1540
+		// load JS
1541
+		wp_register_script(
1542
+			'jquery_plugin',
1543
+			EE_THIRD_PARTY_URL . 'jquery	.plugin.min.js',
1544
+			array('jquery'),
1545
+			'1.0.1',
1546
+			true
1547
+		);
1548
+		wp_register_script(
1549
+			'jquery_countdown',
1550
+			EE_THIRD_PARTY_URL . 'jquery	.countdown.min.js',
1551
+			array('jquery_plugin'),
1552
+			'2.0.2',
1553
+			true
1554
+		);
1555
+		wp_register_script(
1556
+			'single_page_checkout',
1557
+			SPCO_JS_URL . 'single_page_checkout.js',
1558
+			array('espresso_core', 'underscore', 'ee_form_section_validation', 'jquery_countdown'),
1559
+			EVENT_ESPRESSO_VERSION,
1560
+			true
1561
+		);
1562
+		if ($this->checkout->registration_form instanceof EE_Form_Section_Proper) {
1563
+			$this->checkout->registration_form->enqueue_js();
1564
+		}
1565
+		if ($this->checkout->current_step->reg_form instanceof EE_Form_Section_Proper) {
1566
+			$this->checkout->current_step->reg_form->enqueue_js();
1567
+		}
1568
+		wp_enqueue_script('single_page_checkout');
1569
+		/**
1570
+		 * global action hook for enqueueing styles and scripts with
1571
+		 * spco calls.
1572
+		 */
1573
+		do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts', $this);
1574
+		/**
1575
+		 * dynamic action hook for enqueueing styles and scripts with spco calls.
1576
+		 * The hook will end up being something like:
1577
+		 *      AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__attendee_information
1578
+		 */
1579
+		do_action(
1580
+			'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__' . $this->checkout->current_step->slug(),
1581
+			$this
1582
+		);
1583
+	}
1584
+
1585
+
1586
+
1587
+	/**
1588
+	 *    display the Registration Single Page Checkout Form
1589
+	 *
1590
+	 * @access    private
1591
+	 * @return    void
1592
+	 * @throws EE_Error
1593
+	 */
1594
+	private function _display_spco_reg_form()
1595
+	{
1596
+		// if registering via the admin, just display the reg form for the current step
1597
+		if ($this->checkout->admin_request) {
1598
+			EE_Registry::instance()->REQ->add_output($this->checkout->current_step->display_reg_form());
1599
+		} else {
1600
+			// add powered by EE msg
1601
+			add_action('AHEE__SPCO__reg_form_footer', array('EED_Single_Page_Checkout', 'display_registration_footer'));
1602
+			$empty_cart = count(
1603
+				$this->checkout->transaction->registrations($this->checkout->reg_cache_where_params)
1604
+			) < 1;
1605
+			EE_Registry::$i18n_js_strings['empty_cart'] = $empty_cart;
1606
+			$cookies_not_set_msg = '';
1607
+			if ($empty_cart && ! isset($_COOKIE['ee_cookie_test'])) {
1608
+				$cookies_not_set_msg = apply_filters(
1609
+					'FHEE__Single_Page_Checkout__display_spco_reg_form__cookies_not_set_msg',
1610
+					sprintf(
1611
+						__(
1612
+							'%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',
1613
+							'event_espresso'
1614
+						),
1615
+						'<div class="ee-attention">',
1616
+						'</div>',
1617
+						'<h6 class="important-notice">',
1618
+						'</h6>',
1619
+						'<p>',
1620
+						'</p>',
1621
+						'<br />',
1622
+						'<a href="http://www.whatarecookies.com/enable.asp" target="_blank">',
1623
+						'</a>'
1624
+					)
1625
+				);
1626
+			}
1627
+			$this->checkout->registration_form = new EE_Form_Section_Proper(
1628
+				array(
1629
+					'name'            => 'single-page-checkout',
1630
+					'html_id'         => 'ee-single-page-checkout-dv',
1631
+					'layout_strategy' =>
1632
+						new EE_Template_Layout(
1633
+							array(
1634
+								'layout_template_file' => SPCO_TEMPLATES_PATH . 'registration_page_wrapper.template.php',
1635
+								'template_args'        => array(
1636
+									'empty_cart'              => $empty_cart,
1637
+									'revisit'                 => $this->checkout->revisit,
1638
+									'reg_steps'               => $this->checkout->reg_steps,
1639
+									'next_step'               => $this->checkout->next_step instanceof EE_SPCO_Reg_Step
1640
+										? $this->checkout->next_step->slug()
1641
+										: '',
1642
+									'cancel_page_url'         => $this->checkout->cancel_page_url,
1643
+									'empty_msg'               => apply_filters(
1644
+										'FHEE__Single_Page_Checkout__display_spco_reg_form__empty_msg',
1645
+										sprintf(
1646
+											__(
1647
+												'You need to %1$sReturn to Events list%2$sselect at least one event%3$s before you can proceed with the registration process.',
1648
+												'event_espresso'
1649
+											),
1650
+											'<a href="'
1651
+											. get_post_type_archive_link('espresso_events')
1652
+											. '" title="',
1653
+											'">',
1654
+											'</a>'
1655
+										)
1656
+									),
1657
+									'cookies_not_set_msg'     => $cookies_not_set_msg,
1658
+									'registration_time_limit' => $this->checkout->get_registration_time_limit(),
1659
+									'session_expiration'      => gmdate(
1660
+										'M d, Y H:i:s',
1661
+										EE_Registry::instance()->SSN->expiration()
1662
+										+ (get_option('gmt_offset') * HOUR_IN_SECONDS)
1663
+									),
1664
+								),
1665
+							)
1666
+						),
1667
+				)
1668
+			);
1669
+			// load template and add to output sent that gets filtered into the_content()
1670
+			EE_Registry::instance()->REQ->add_output($this->checkout->registration_form->get_html());
1671
+		}
1672
+	}
1673
+
1674
+
1675
+
1676
+	/**
1677
+	 *    add_extra_finalize_registration_inputs
1678
+	 *
1679
+	 * @access    public
1680
+	 * @param $next_step
1681
+	 * @internal  param string $label
1682
+	 * @return void
1683
+	 */
1684
+	public function add_extra_finalize_registration_inputs($next_step)
1685
+	{
1686
+		if ($next_step === 'finalize_registration') {
1687
+			echo '<div id="spco-extra-finalize_registration-inputs-dv"></div>';
1688
+		}
1689
+	}
1690
+
1691
+
1692
+
1693
+	/**
1694
+	 *    display_registration_footer
1695
+	 *
1696
+	 * @access    public
1697
+	 * @return    string
1698
+	 */
1699
+	public static function display_registration_footer()
1700
+	{
1701
+		if (
1702
+		apply_filters(
1703
+			'FHEE__EE_Front__Controller__show_reg_footer',
1704
+			EE_Registry::instance()->CFG->admin->show_reg_footer
1705
+		)
1706
+		) {
1707
+			add_filter(
1708
+				'FHEE__EEH_Template__powered_by_event_espresso__url',
1709
+				function ($url) {
1710
+					return apply_filters('FHEE__EE_Front_Controller__registration_footer__url', $url);
1711
+				}
1712
+			);
1713
+			echo apply_filters(
1714
+				'FHEE__EE_Front_Controller__display_registration_footer',
1715
+				\EEH_Template::powered_by_event_espresso(
1716
+					'',
1717
+					'espresso-registration-footer-dv',
1718
+					array('utm_content' => 'registration_checkout')
1719
+				)
1720
+			);
1721
+		}
1722
+		return '';
1723
+	}
1724
+
1725
+
1726
+
1727
+	/**
1728
+	 *    unlock_transaction
1729
+	 *
1730
+	 * @access    public
1731
+	 * @return    void
1732
+	 * @throws EE_Error
1733
+	 */
1734
+	public function unlock_transaction()
1735
+	{
1736
+		if ($this->checkout->transaction instanceof EE_Transaction) {
1737
+			$this->checkout->transaction->unlock();
1738
+		}
1739
+	}
1740
+
1741
+
1742
+
1743
+	/**
1744
+	 *        _setup_redirect
1745
+	 *
1746
+	 * @access    private
1747
+	 * @return void
1748
+	 */
1749
+	private function _setup_redirect()
1750
+	{
1751
+		if ($this->checkout->continue_reg && $this->checkout->next_step instanceof EE_SPCO_Reg_Step) {
1752
+			$this->checkout->redirect = true;
1753
+			if (empty($this->checkout->redirect_url)) {
1754
+				$this->checkout->redirect_url = $this->checkout->next_step->reg_step_url();
1755
+			}
1756
+			$this->checkout->redirect_url = apply_filters(
1757
+				'FHEE__EED_Single_Page_Checkout___setup_redirect__checkout_redirect_url',
1758
+				$this->checkout->redirect_url,
1759
+				$this->checkout
1760
+			);
1761
+		}
1762
+	}
1763
+
1764
+
1765
+
1766
+	/**
1767
+	 *   handle ajax message responses and redirects
1768
+	 *
1769
+	 * @access public
1770
+	 * @return void
1771
+	 * @throws EE_Error
1772
+	 */
1773
+	public function go_to_next_step()
1774
+	{
1775
+		if (EE_Registry::instance()->REQ->ajax) {
1776
+			// capture contents of output buffer we started earlier in the request, and insert into JSON response
1777
+			$this->checkout->json_response->set_unexpected_errors(ob_get_clean());
1778
+		}
1779
+		$this->unlock_transaction();
1780
+		// just return for these conditions
1781
+		if (
1782
+			$this->checkout->admin_request
1783
+			|| $this->checkout->action === 'redirect_form'
1784
+			|| $this->checkout->action === 'update_checkout'
1785
+		) {
1786
+			return;
1787
+		}
1788
+		// AJAX response
1789
+		$this->_handle_json_response();
1790
+		// redirect to next step or the Thank You page
1791
+		$this->_handle_html_redirects();
1792
+		// hmmm... must be something wrong, so let's just display the form again !
1793
+		$this->_display_spco_reg_form();
1794
+	}
1795
+
1796
+
1797
+
1798
+	/**
1799
+	 *   _handle_json_response
1800
+	 *
1801
+	 * @access protected
1802
+	 * @return void
1803
+	 */
1804
+	protected function _handle_json_response()
1805
+	{
1806
+		// if this is an ajax request
1807
+		if (EE_Registry::instance()->REQ->ajax) {
1808
+			// DEBUG LOG
1809
+			//$this->checkout->log(
1810
+			//	__CLASS__, __FUNCTION__, __LINE__,
1811
+			//	array(
1812
+			//		'json_response_redirect_url' => $this->checkout->json_response->redirect_url(),
1813
+			//		'redirect'                   => $this->checkout->redirect,
1814
+			//		'continue_reg'               => $this->checkout->continue_reg,
1815
+			//	)
1816
+			//);
1817
+			$this->checkout->json_response->set_registration_time_limit(
1818
+				$this->checkout->get_registration_time_limit()
1819
+			);
1820
+			$this->checkout->json_response->set_payment_amount($this->checkout->amount_owing);
1821
+			// just send the ajax (
1822
+			$json_response = apply_filters(
1823
+				'FHEE__EE_Single_Page_Checkout__JSON_response',
1824
+				$this->checkout->json_response
1825
+			);
1826
+			echo $json_response;
1827
+			exit();
1828
+		}
1829
+	}
1830
+
1831
+
1832
+
1833
+	/**
1834
+	 *   _handle_redirects
1835
+	 *
1836
+	 * @access protected
1837
+	 * @return void
1838
+	 */
1839
+	protected function _handle_html_redirects()
1840
+	{
1841
+		// going somewhere ?
1842
+		if ($this->checkout->redirect && ! empty($this->checkout->redirect_url)) {
1843
+			// store notices in a transient
1844
+			EE_Error::get_notices(false, true, true);
1845
+			// DEBUG LOG
1846
+			//$this->checkout->log(
1847
+			//	__CLASS__, __FUNCTION__, __LINE__,
1848
+			//	array(
1849
+			//		'headers_sent' => headers_sent(),
1850
+			//		'redirect_url'     => $this->checkout->redirect_url,
1851
+			//		'headers_list'    => headers_list(),
1852
+			//	)
1853
+			//);
1854
+			wp_safe_redirect($this->checkout->redirect_url);
1855
+			exit();
1856
+		}
1857
+	}
1858
+
1859
+
1860
+
1861
+	/**
1862
+	 *   set_checkout_anchor
1863
+	 *
1864
+	 * @access public
1865
+	 * @return void
1866
+	 */
1867
+	public function set_checkout_anchor()
1868
+	{
1869
+		echo '<a id="checkout" style="float: left; margin-left: -999em;"></a>';
1870
+	}
1871 1871
 
1872 1872
 
1873 1873
 
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -218,19 +218,19 @@  discard block
 block discarded – undo
218 218
      */
219 219
     public static function set_definitions()
220 220
     {
221
-        if(defined('SPCO_BASE_PATH')) {
221
+        if (defined('SPCO_BASE_PATH')) {
222 222
             return;
223 223
         }
224 224
         define(
225 225
             'SPCO_BASE_PATH',
226
-            rtrim(str_replace(array('\\', '/'), DS, plugin_dir_path(__FILE__)), DS) . DS
226
+            rtrim(str_replace(array('\\', '/'), DS, plugin_dir_path(__FILE__)), DS).DS
227 227
         );
228
-        define('SPCO_CSS_URL', plugin_dir_url(__FILE__) . 'css' . DS);
229
-        define('SPCO_IMG_URL', plugin_dir_url(__FILE__) . 'img' . DS);
230
-        define('SPCO_JS_URL', plugin_dir_url(__FILE__) . 'js' . DS);
231
-        define('SPCO_INC_PATH', SPCO_BASE_PATH . 'inc' . DS);
232
-        define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH . 'reg_steps' . DS);
233
-        define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH . 'templates' . DS);
228
+        define('SPCO_CSS_URL', plugin_dir_url(__FILE__).'css'.DS);
229
+        define('SPCO_IMG_URL', plugin_dir_url(__FILE__).'img'.DS);
230
+        define('SPCO_JS_URL', plugin_dir_url(__FILE__).'js'.DS);
231
+        define('SPCO_INC_PATH', SPCO_BASE_PATH.'inc'.DS);
232
+        define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH.'reg_steps'.DS);
233
+        define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH.'templates'.DS);
234 234
         EEH_Autoloader::register_autoloaders_for_each_file_in_folder(SPCO_BASE_PATH, true);
235 235
         EE_Registry::$i18n_js_strings['registration_expiration_notice'] = sprintf(
236 236
             __('%1$sWe\'re sorry, but you\'re registration time has expired.%2$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 except our apologies for any inconvenience this may have caused.%8$s',
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
             '</h4>',
240 240
             '<br />',
241 241
             '<p>',
242
-            '<a href="' . get_post_type_archive_link('espresso_events') . '" title="',
242
+            '<a href="'.get_post_type_archive_link('espresso_events').'" title="',
243 243
             '">',
244 244
             '</a>',
245 245
             '</p>'
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
             return;
263 263
         }
264 264
         // filter list of reg_steps
265
-        $reg_steps_to_load = (array)apply_filters(
265
+        $reg_steps_to_load = (array) apply_filters(
266 266
             'AHEE__SPCO__load_reg_steps__reg_steps_to_load',
267 267
             EED_Single_Page_Checkout::get_reg_steps()
268 268
         );
@@ -314,25 +314,25 @@  discard block
 block discarded – undo
314 314
         if (empty($reg_steps)) {
315 315
             $reg_steps = array(
316 316
                 10  => array(
317
-                    'file_path'  => SPCO_REG_STEPS_PATH . 'attendee_information',
317
+                    'file_path'  => SPCO_REG_STEPS_PATH.'attendee_information',
318 318
                     'class_name' => 'EE_SPCO_Reg_Step_Attendee_Information',
319 319
                     'slug'       => 'attendee_information',
320 320
                     'has_hooks'  => false,
321 321
                 ),
322 322
                 20  => array(
323
-                    'file_path'  => SPCO_REG_STEPS_PATH . 'registration_confirmation',
323
+                    'file_path'  => SPCO_REG_STEPS_PATH.'registration_confirmation',
324 324
                     'class_name' => 'EE_SPCO_Reg_Step_Registration_Confirmation',
325 325
                     'slug'       => 'registration_confirmation',
326 326
                     'has_hooks'  => false,
327 327
                 ),
328 328
                 30  => array(
329
-                    'file_path'  => SPCO_REG_STEPS_PATH . 'payment_options',
329
+                    'file_path'  => SPCO_REG_STEPS_PATH.'payment_options',
330 330
                     'class_name' => 'EE_SPCO_Reg_Step_Payment_Options',
331 331
                     'slug'       => 'payment_options',
332 332
                     'has_hooks'  => true,
333 333
                 ),
334 334
                 999 => array(
335
-                    'file_path'  => SPCO_REG_STEPS_PATH . 'finalize_registration',
335
+                    'file_path'  => SPCO_REG_STEPS_PATH.'finalize_registration',
336 336
                     'class_name' => 'EE_SPCO_Reg_Step_Finalize_Registration',
337 337
                     'slug'       => 'finalize_registration',
338 338
                     'has_hooks'  => false,
@@ -516,7 +516,7 @@  discard block
 block discarded – undo
516 516
             // DEBUG LOG
517 517
             //$this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ );
518 518
             // get reg form
519
-            if( ! $this->_check_form_submission()) {
519
+            if ( ! $this->_check_form_submission()) {
520 520
                 EED_Single_Page_Checkout::$_initialized = true;
521 521
                 return;
522 522
             }
@@ -1114,7 +1114,7 @@  discard block
 block discarded – undo
1114 1114
                     if ( ! $registration instanceof EE_Registration) {
1115 1115
                         throw new InvalidEntityException($registration, 'EE_Registration');
1116 1116
                     }
1117
-                    $registrations[ $registration->ID() ] = $registration;
1117
+                    $registrations[$registration->ID()] = $registration;
1118 1118
                 }
1119 1119
             }
1120 1120
             $registration_processor->fix_reg_final_price_rounding_issue($transaction);
@@ -1375,7 +1375,7 @@  discard block
 block discarded – undo
1375 1375
                         ) {
1376 1376
                             EE_Error::add_success(
1377 1377
                                 $this->checkout->current_step->success_message()
1378
-                                . '<br />' . $this->checkout->next_step->_instructions()
1378
+                                . '<br />'.$this->checkout->next_step->_instructions()
1379 1379
                             );
1380 1380
                         }
1381 1381
                         // pack it up, pack it in...
@@ -1500,7 +1500,7 @@  discard block
 block discarded – undo
1500 1500
             '</h4>',
1501 1501
             '<br />',
1502 1502
             '<p>',
1503
-            '<a href="' . get_post_type_archive_link('espresso_events') . '" title="',
1503
+            '<a href="'.get_post_type_archive_link('espresso_events').'" title="',
1504 1504
             '">',
1505 1505
             '</a>',
1506 1506
             '</p>'
@@ -1532,7 +1532,7 @@  discard block
 block discarded – undo
1532 1532
         // load css
1533 1533
         wp_register_style(
1534 1534
             'single_page_checkout',
1535
-            SPCO_CSS_URL . 'single_page_checkout.css',
1535
+            SPCO_CSS_URL.'single_page_checkout.css',
1536 1536
             array('espresso_default'),
1537 1537
             EVENT_ESPRESSO_VERSION
1538 1538
         );
@@ -1540,21 +1540,21 @@  discard block
 block discarded – undo
1540 1540
         // load JS
1541 1541
         wp_register_script(
1542 1542
             'jquery_plugin',
1543
-            EE_THIRD_PARTY_URL . 'jquery	.plugin.min.js',
1543
+            EE_THIRD_PARTY_URL.'jquery	.plugin.min.js',
1544 1544
             array('jquery'),
1545 1545
             '1.0.1',
1546 1546
             true
1547 1547
         );
1548 1548
         wp_register_script(
1549 1549
             'jquery_countdown',
1550
-            EE_THIRD_PARTY_URL . 'jquery	.countdown.min.js',
1550
+            EE_THIRD_PARTY_URL.'jquery	.countdown.min.js',
1551 1551
             array('jquery_plugin'),
1552 1552
             '2.0.2',
1553 1553
             true
1554 1554
         );
1555 1555
         wp_register_script(
1556 1556
             'single_page_checkout',
1557
-            SPCO_JS_URL . 'single_page_checkout.js',
1557
+            SPCO_JS_URL.'single_page_checkout.js',
1558 1558
             array('espresso_core', 'underscore', 'ee_form_section_validation', 'jquery_countdown'),
1559 1559
             EVENT_ESPRESSO_VERSION,
1560 1560
             true
@@ -1577,7 +1577,7 @@  discard block
 block discarded – undo
1577 1577
          *      AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__attendee_information
1578 1578
          */
1579 1579
         do_action(
1580
-            'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__' . $this->checkout->current_step->slug(),
1580
+            'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__'.$this->checkout->current_step->slug(),
1581 1581
             $this
1582 1582
         );
1583 1583
     }
@@ -1631,7 +1631,7 @@  discard block
 block discarded – undo
1631 1631
                     'layout_strategy' =>
1632 1632
                         new EE_Template_Layout(
1633 1633
                             array(
1634
-                                'layout_template_file' => SPCO_TEMPLATES_PATH . 'registration_page_wrapper.template.php',
1634
+                                'layout_template_file' => SPCO_TEMPLATES_PATH.'registration_page_wrapper.template.php',
1635 1635
                                 'template_args'        => array(
1636 1636
                                     'empty_cart'              => $empty_cart,
1637 1637
                                     'revisit'                 => $this->checkout->revisit,
@@ -1706,7 +1706,7 @@  discard block
 block discarded – undo
1706 1706
         ) {
1707 1707
             add_filter(
1708 1708
                 'FHEE__EEH_Template__powered_by_event_espresso__url',
1709
-                function ($url) {
1709
+                function($url) {
1710 1710
                     return apply_filters('FHEE__EE_Front_Controller__registration_footer__url', $url);
1711 1711
                 }
1712 1712
             );
Please login to merge, or discard this patch.
modules/bot_trap/EED_Bot_Trap.module.php 2 patches
Indentation   +292 added lines, -292 removed lines patch added patch discarded remove patch
@@ -17,323 +17,323 @@
 block discarded – undo
17 17
 {
18 18
 
19 19
 
20
-    /**
21
-     * @return EED_Bot_Trap|EED_Module
22
-     */
23
-    public static function instance()
24
-    {
25
-        return parent::get_instance(__CLASS__);
26
-    }
20
+	/**
21
+	 * @return EED_Bot_Trap|EED_Module
22
+	 */
23
+	public static function instance()
24
+	{
25
+		return parent::get_instance(__CLASS__);
26
+	}
27 27
 
28 28
 
29
-    /**
30
-     * set_hooks - for hooking into EE Core, other modules, etc
31
-     *
32
-     * @return void
33
-     */
34
-    public static function set_hooks()
35
-    {
36
-        if (
37
-            apply_filters('FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true) &&
38
-            \EE_Registry::instance()->CFG->registration->use_bot_trap
39
-        ) {
40
-            \EED_Bot_Trap::set_trap();
41
-            // redirect bots to bogus success page
42
-            \EE_Config::register_route('ticket_selection_received', 'EED_Bot_Trap', 'display_bot_trap_success');
43
-        }
44
-    }
29
+	/**
30
+	 * set_hooks - for hooking into EE Core, other modules, etc
31
+	 *
32
+	 * @return void
33
+	 */
34
+	public static function set_hooks()
35
+	{
36
+		if (
37
+			apply_filters('FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true) &&
38
+			\EE_Registry::instance()->CFG->registration->use_bot_trap
39
+		) {
40
+			\EED_Bot_Trap::set_trap();
41
+			// redirect bots to bogus success page
42
+			\EE_Config::register_route('ticket_selection_received', 'EED_Bot_Trap', 'display_bot_trap_success');
43
+		}
44
+	}
45 45
 
46 46
 
47
-    /**
48
-     * set_hooks_admin - for hooking into EE Admin Core, other modules, etc
49
-     *
50
-     * @return void
51
-     */
52
-    public static function set_trap()
53
-    {
54
-        define('EE_BOT_TRAP_BASE_URL', plugin_dir_url(__FILE__) . DS);
55
-        add_action(
56
-            'AHEE__ticket_selector_chart__template__after_ticket_selector',
57
-            array('EED_Bot_Trap', 'generate_bot_trap'),
58
-            10, 2
59
-        );
60
-        add_action(
61
-            'EED_Ticket_Selector__process_ticket_selections__before',
62
-            array('EED_Bot_Trap', 'process_bot_trap'),
63
-            1, 2
64
-        );
65
-    }
47
+	/**
48
+	 * set_hooks_admin - for hooking into EE Admin Core, other modules, etc
49
+	 *
50
+	 * @return void
51
+	 */
52
+	public static function set_trap()
53
+	{
54
+		define('EE_BOT_TRAP_BASE_URL', plugin_dir_url(__FILE__) . DS);
55
+		add_action(
56
+			'AHEE__ticket_selector_chart__template__after_ticket_selector',
57
+			array('EED_Bot_Trap', 'generate_bot_trap'),
58
+			10, 2
59
+		);
60
+		add_action(
61
+			'EED_Ticket_Selector__process_ticket_selections__before',
62
+			array('EED_Bot_Trap', 'process_bot_trap'),
63
+			1, 2
64
+		);
65
+	}
66 66
 
67 67
 
68
-    /**
69
-     * set_hooks_admin - for hooking into EE Admin Core, other modules, etc
70
-     *
71
-     * @return void
72
-     */
73
-    public static function set_hooks_admin()
74
-    {
75
-        if (
76
-            defined('DOING_AJAX')
77
-            && DOING_AJAX
78
-            && apply_filters('FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true)
79
-            && \EE_Registry::instance()->CFG->registration->use_bot_trap
80
-        ) {
81
-            \EED_Bot_Trap::set_trap();
82
-        }
83
-        add_action(
84
-            'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template',
85
-            array('EED_Bot_Trap', 'bot_trap_settings_form'),
86
-            5
87
-        );
88
-        add_filter(
89
-            'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration',
90
-            array('EED_Bot_Trap', 'update_bot_trap_settings_form'),
91
-            10, 1
92
-        );
93
-    }
68
+	/**
69
+	 * set_hooks_admin - for hooking into EE Admin Core, other modules, etc
70
+	 *
71
+	 * @return void
72
+	 */
73
+	public static function set_hooks_admin()
74
+	{
75
+		if (
76
+			defined('DOING_AJAX')
77
+			&& DOING_AJAX
78
+			&& apply_filters('FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true)
79
+			&& \EE_Registry::instance()->CFG->registration->use_bot_trap
80
+		) {
81
+			\EED_Bot_Trap::set_trap();
82
+		}
83
+		add_action(
84
+			'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template',
85
+			array('EED_Bot_Trap', 'bot_trap_settings_form'),
86
+			5
87
+		);
88
+		add_filter(
89
+			'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration',
90
+			array('EED_Bot_Trap', 'update_bot_trap_settings_form'),
91
+			10, 1
92
+		);
93
+	}
94 94
 
95 95
 
96
-    /**
97
-     * run - initial module setup
98
-     *
99
-     * @param WP $WP
100
-     * @return void
101
-     */
102
-    public function run($WP)
103
-    {
104
-    }
96
+	/**
97
+	 * run - initial module setup
98
+	 *
99
+	 * @param WP $WP
100
+	 * @return void
101
+	 */
102
+	public function run($WP)
103
+	{
104
+	}
105 105
 
106 106
 
107
-    /**
108
-     * generate_bot_trap
109
-     *
110
-     * @return void
111
-     * @throws RuntimeException
112
-     */
113
-    public static function generate_bot_trap()
114
-    {
115
-        $do_not_enter = esc_html__('please do not enter anything in this input', 'event_espresso');
116
-        $time = microtime(true);
117
-        $html = '<div class="tkt-slctr-request-processor-dv" style="float:left; margin:0 0 0 -999em; height: 0;">';
118
-        $html .= '<label for="tkt-slctr-request-processor-email-' . $time . '">' . $do_not_enter . '</label>';
119
-        $html .= '<input type="email" id="tkt-slctr-request-processor-email-';
120
-        $html .= $time . '" name="tkt-slctr-request-processor-email" value=""/>';
121
-        $html .= '<input type="hidden" name="tkt-slctr-request-processor-token" value="';
122
-        if (EE_Registry::instance()->CFG->registration->use_encryption) {
123
-            EE_Registry::instance()->load_core('EE_Encryption');
124
-            $html .= EE_Encryption::instance()->encrypt($time);
125
-        } else {
126
-            $html .= $time;
127
-        }
128
-        $html .= '"/>';
129
-        $html .= '</div><!-- .tkt-slctr-request-processor-dv -->';
130
-        echo $html;
131
-    }
107
+	/**
108
+	 * generate_bot_trap
109
+	 *
110
+	 * @return void
111
+	 * @throws RuntimeException
112
+	 */
113
+	public static function generate_bot_trap()
114
+	{
115
+		$do_not_enter = esc_html__('please do not enter anything in this input', 'event_espresso');
116
+		$time = microtime(true);
117
+		$html = '<div class="tkt-slctr-request-processor-dv" style="float:left; margin:0 0 0 -999em; height: 0;">';
118
+		$html .= '<label for="tkt-slctr-request-processor-email-' . $time . '">' . $do_not_enter . '</label>';
119
+		$html .= '<input type="email" id="tkt-slctr-request-processor-email-';
120
+		$html .= $time . '" name="tkt-slctr-request-processor-email" value=""/>';
121
+		$html .= '<input type="hidden" name="tkt-slctr-request-processor-token" value="';
122
+		if (EE_Registry::instance()->CFG->registration->use_encryption) {
123
+			EE_Registry::instance()->load_core('EE_Encryption');
124
+			$html .= EE_Encryption::instance()->encrypt($time);
125
+		} else {
126
+			$html .= $time;
127
+		}
128
+		$html .= '"/>';
129
+		$html .= '</div><!-- .tkt-slctr-request-processor-dv -->';
130
+		echo $html;
131
+	}
132 132
 
133 133
 
134
-    /**
135
-     * process_bot_trap
136
-     *
137
-     * @param array|string $triggered_trap_callback Callback that will be executed for handling the
138
-     *                                              response if the bot trap is triggered.
139
-     *                                              It should receive one argument: a boolean indicating
140
-     *                                              whether the trap was triggered by suspicious timing or not.
141
-     * @throws RuntimeException
142
-     */
143
-    public static function process_bot_trap($triggered_trap_callback = array())
144
-    {
145
-        // what's your email address Mr. Bot ?
146
-        $empty_trap = isset($_REQUEST['tkt-slctr-request-processor-email'])
147
-            && $_REQUEST['tkt-slctr-request-processor-email'] === '';
148
-        // get encrypted timestamp for when the form was originally displayed
149
-        $bot_trap_timestamp = isset($_REQUEST['tkt-slctr-request-processor-token'])
150
-            ? sanitize_text_field($_REQUEST['tkt-slctr-request-processor-token'])
151
-            : '';
152
-        // decrypt and convert to absolute  integer
153
-        if (EE_Registry::instance()->CFG->registration->use_encryption) {
154
-            EE_Registry::instance()->load_core('EE_Encryption');
155
-            $bot_trap_timestamp = absint(EE_Encryption::instance()->decrypt($bot_trap_timestamp));
156
-        } else {
157
-            $bot_trap_timestamp = absint($bot_trap_timestamp);
158
-        }
159
-        // ticket form submitted too impossibly fast ( after now ) or more than an hour later ???
160
-        $suspicious_timing = $bot_trap_timestamp > time() || $bot_trap_timestamp < (time() - HOUR_IN_SECONDS);
161
-        // are we human ?
162
-        if ($empty_trap && !$suspicious_timing) {
163
-            do_action('AHEE__EED_Bot_Trap__process_bot_trap__trap_not_triggered');
164
-            return;
165
-        }
166
-        // check the given callback is valid first before executing
167
-        if (!is_callable($triggered_trap_callback)) {
168
-            // invalid callback so lets just sub in our default.
169
-            $triggered_trap_callback = array('EED_Bot_Trap', 'triggered_trap_response');
170
-        }
171
-        call_user_func($triggered_trap_callback, $suspicious_timing);
172
-    }
134
+	/**
135
+	 * process_bot_trap
136
+	 *
137
+	 * @param array|string $triggered_trap_callback Callback that will be executed for handling the
138
+	 *                                              response if the bot trap is triggered.
139
+	 *                                              It should receive one argument: a boolean indicating
140
+	 *                                              whether the trap was triggered by suspicious timing or not.
141
+	 * @throws RuntimeException
142
+	 */
143
+	public static function process_bot_trap($triggered_trap_callback = array())
144
+	{
145
+		// what's your email address Mr. Bot ?
146
+		$empty_trap = isset($_REQUEST['tkt-slctr-request-processor-email'])
147
+			&& $_REQUEST['tkt-slctr-request-processor-email'] === '';
148
+		// get encrypted timestamp for when the form was originally displayed
149
+		$bot_trap_timestamp = isset($_REQUEST['tkt-slctr-request-processor-token'])
150
+			? sanitize_text_field($_REQUEST['tkt-slctr-request-processor-token'])
151
+			: '';
152
+		// decrypt and convert to absolute  integer
153
+		if (EE_Registry::instance()->CFG->registration->use_encryption) {
154
+			EE_Registry::instance()->load_core('EE_Encryption');
155
+			$bot_trap_timestamp = absint(EE_Encryption::instance()->decrypt($bot_trap_timestamp));
156
+		} else {
157
+			$bot_trap_timestamp = absint($bot_trap_timestamp);
158
+		}
159
+		// ticket form submitted too impossibly fast ( after now ) or more than an hour later ???
160
+		$suspicious_timing = $bot_trap_timestamp > time() || $bot_trap_timestamp < (time() - HOUR_IN_SECONDS);
161
+		// are we human ?
162
+		if ($empty_trap && !$suspicious_timing) {
163
+			do_action('AHEE__EED_Bot_Trap__process_bot_trap__trap_not_triggered');
164
+			return;
165
+		}
166
+		// check the given callback is valid first before executing
167
+		if (!is_callable($triggered_trap_callback)) {
168
+			// invalid callback so lets just sub in our default.
169
+			$triggered_trap_callback = array('EED_Bot_Trap', 'triggered_trap_response');
170
+		}
171
+		call_user_func($triggered_trap_callback, $suspicious_timing);
172
+	}
173 173
 
174 174
 
175
-    /**
176
-     * This is the default callback executed by EED_Bot_Trap::process_bot_trap that handles the response.
177
-     *
178
-     * @param bool $suspicious_timing If true, then the bot trap was triggered due to the suspicious timing test.
179
-     */
180
-    public static function triggered_trap_response($suspicious_timing)
181
-    {
182
-        // UH OH...
183
-        $redirect_url = add_query_arg(
184
-            array('ee' => 'ticket_selection_received'),
185
-            EE_Registry::instance()->CFG->core->reg_page_url()
186
-        );
187
-        if ($suspicious_timing) {
188
-            $redirect_url = add_query_arg(
189
-                array(
190
-                    'ee-notice' => urlencode(
191
-                        esc_html__(
192
-                            'We\'re sorry, but your ticket selections could not be processed due to a server timing error. Please hit the back button on your browser and try again.',
193
-                            'event_espresso'
194
-                        )
195
-                    )
196
-                ),
197
-                $redirect_url
198
-            );
199
-        }
200
-        $redirect_url = apply_filters('FHEE__EED_Bot_Trap__process_bot_trap__redirect_url', $redirect_url);
201
-        // if AJAX, return the redirect URL
202
-        if (defined('DOING_AJAX') && DOING_AJAX) {
203
-            echo wp_json_encode(
204
-                array_merge(
205
-                    EE_Error::get_notices(false),
206
-                    array(
207
-                        'redirect_url' => $redirect_url
208
-                    )
209
-                )
210
-            );
211
-            exit();
212
-        }
213
-        wp_safe_redirect($redirect_url);
214
-        exit();
215
-    }
175
+	/**
176
+	 * This is the default callback executed by EED_Bot_Trap::process_bot_trap that handles the response.
177
+	 *
178
+	 * @param bool $suspicious_timing If true, then the bot trap was triggered due to the suspicious timing test.
179
+	 */
180
+	public static function triggered_trap_response($suspicious_timing)
181
+	{
182
+		// UH OH...
183
+		$redirect_url = add_query_arg(
184
+			array('ee' => 'ticket_selection_received'),
185
+			EE_Registry::instance()->CFG->core->reg_page_url()
186
+		);
187
+		if ($suspicious_timing) {
188
+			$redirect_url = add_query_arg(
189
+				array(
190
+					'ee-notice' => urlencode(
191
+						esc_html__(
192
+							'We\'re sorry, but your ticket selections could not be processed due to a server timing error. Please hit the back button on your browser and try again.',
193
+							'event_espresso'
194
+						)
195
+					)
196
+				),
197
+				$redirect_url
198
+			);
199
+		}
200
+		$redirect_url = apply_filters('FHEE__EED_Bot_Trap__process_bot_trap__redirect_url', $redirect_url);
201
+		// if AJAX, return the redirect URL
202
+		if (defined('DOING_AJAX') && DOING_AJAX) {
203
+			echo wp_json_encode(
204
+				array_merge(
205
+					EE_Error::get_notices(false),
206
+					array(
207
+						'redirect_url' => $redirect_url
208
+					)
209
+				)
210
+			);
211
+			exit();
212
+		}
213
+		wp_safe_redirect($redirect_url);
214
+		exit();
215
+	}
216 216
 
217 217
 
218
-    /**
219
-     * display_bot_trap_success
220
-     * shows a "success" screen to bots so that they (ie: the ppl managing them)
221
-     * think the form was submitted successfully
222
-     *
223
-     * @return void
224
-     */
225
-    public static function display_bot_trap_success()
226
-    {
227
-        add_filter('FHEE__EED_Single_Page_Checkout__run', '__return_false');
228
-        $bot_notice = esc_html__(
229
-            'Thank you so much. Your ticket selections have been received for consideration.',
230
-            'event_espresso'
231
-        );
232
-        $bot_notice = isset($_REQUEST['ee-notice']) && $_REQUEST['ee-notice'] !== ''
233
-            ? sanitize_text_field(stripslashes($_REQUEST['ee-notice']))
234
-            : $bot_notice;
235
-        EE_Registry::instance()->REQ->add_output(EEH_HTML::div($bot_notice, '', 'ee-attention'));
236
-    }
218
+	/**
219
+	 * display_bot_trap_success
220
+	 * shows a "success" screen to bots so that they (ie: the ppl managing them)
221
+	 * think the form was submitted successfully
222
+	 *
223
+	 * @return void
224
+	 */
225
+	public static function display_bot_trap_success()
226
+	{
227
+		add_filter('FHEE__EED_Single_Page_Checkout__run', '__return_false');
228
+		$bot_notice = esc_html__(
229
+			'Thank you so much. Your ticket selections have been received for consideration.',
230
+			'event_espresso'
231
+		);
232
+		$bot_notice = isset($_REQUEST['ee-notice']) && $_REQUEST['ee-notice'] !== ''
233
+			? sanitize_text_field(stripslashes($_REQUEST['ee-notice']))
234
+			: $bot_notice;
235
+		EE_Registry::instance()->REQ->add_output(EEH_HTML::div($bot_notice, '', 'ee-attention'));
236
+	}
237 237
 
238 238
 
239 239
 
240
-    /***********************************    ADMIN    **********************************/
240
+	/***********************************    ADMIN    **********************************/
241 241
 
242 242
 
243
-    /**
244
-     * bot_trap_settings_form
245
-     *
246
-     * @return void
247
-     * @throws EE_Error
248
-     */
249
-    public static function bot_trap_settings_form()
250
-    {
251
-        EED_Bot_Trap::_bot_trap_settings_form()->enqueue_js();
252
-        echo EED_Bot_Trap::_bot_trap_settings_form()->get_html();
253
-    }
243
+	/**
244
+	 * bot_trap_settings_form
245
+	 *
246
+	 * @return void
247
+	 * @throws EE_Error
248
+	 */
249
+	public static function bot_trap_settings_form()
250
+	{
251
+		EED_Bot_Trap::_bot_trap_settings_form()->enqueue_js();
252
+		echo EED_Bot_Trap::_bot_trap_settings_form()->get_html();
253
+	}
254 254
 
255 255
 
256
-    /**
257
-     * _bot_trap_settings_form
258
-     *
259
-     * @return EE_Form_Section_Proper
260
-     * @throws EE_Error
261
-     */
262
-    protected static function _bot_trap_settings_form()
263
-    {
264
-        return new EE_Form_Section_Proper(
265
-            array(
266
-                'name' => 'bot_trap_settings',
267
-                'html_id' => 'bot_trap_settings',
268
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
269
-                'subsections' => array(
270
-                    'bot_trap_hdr' => new EE_Form_Section_HTML(EEH_HTML::h2(esc_html__('Bot Trap Settings', 'event_espresso'))),
271
-                    'use_bot_trap' => new EE_Yes_No_Input(
272
-                        array(
273
-                            'html_label_text' => esc_html__('Enable Bot Trap', 'event_espresso'),
274
-                            'html_help_text' => esc_html__('The Event Espresso Bot Trap will insert a fake input into your Ticket Selector forms that is hidden from regular site visitors, but visible to spam bots. Because the input asks for an email address, it is irresistible to spam bots who will of course enter text into it. Since regular site visitors can not see this input, any value detected during form submission means a bot has been detected, which will then be blocked from submitting the form.', 'event_espresso'),
275
-                            'default' => EE_Registry::instance()->CFG->registration->use_bot_trap !== null
276
-                                ? EE_Registry::instance()->CFG->registration->use_bot_trap
277
-                                : true,
278
-                            'required' => false
279
-                        )
280
-                    ),
281
-                    'use_encryption' => new EE_Yes_No_Input(
282
-                        array(
283
-                            'html_label_text' => esc_html__('Encrypt Bot Trap Data', 'event_espresso'),
284
-                            'html_help_text' => esc_html__(
285
-                                'One way to detect spam bots is by looking at how long it takes them to submit a form. They are often inhumanly fast, or will submit forms hours, days, or even weeks after the form was first scraped off the web. The Event Espresso Bot Trap will send a timestamp with the Ticket Selector form when it is submitted. By default, this timestamp is encrypted so that the spam bots can not change it, but encryption may cause issues on some servers due to configuration "conflicts". If you continuously get caught in the bot trap, then try setting this option to "No". This may increase the number of spam submissions you receive, but increases server compatibility.',
286
-                                'event_espresso'
287
-                            ),
288
-                            'default' => EE_Registry::instance()->CFG->registration->use_encryption !== null
289
-                                ? EE_Registry::instance()->CFG->registration->use_encryption
290
-                                : true,
291
-                            'required' => false
292
-                        )
293
-                    ),
294
-                )
295
-            )
296
-        );
297
-    }
256
+	/**
257
+	 * _bot_trap_settings_form
258
+	 *
259
+	 * @return EE_Form_Section_Proper
260
+	 * @throws EE_Error
261
+	 */
262
+	protected static function _bot_trap_settings_form()
263
+	{
264
+		return new EE_Form_Section_Proper(
265
+			array(
266
+				'name' => 'bot_trap_settings',
267
+				'html_id' => 'bot_trap_settings',
268
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
269
+				'subsections' => array(
270
+					'bot_trap_hdr' => new EE_Form_Section_HTML(EEH_HTML::h2(esc_html__('Bot Trap Settings', 'event_espresso'))),
271
+					'use_bot_trap' => new EE_Yes_No_Input(
272
+						array(
273
+							'html_label_text' => esc_html__('Enable Bot Trap', 'event_espresso'),
274
+							'html_help_text' => esc_html__('The Event Espresso Bot Trap will insert a fake input into your Ticket Selector forms that is hidden from regular site visitors, but visible to spam bots. Because the input asks for an email address, it is irresistible to spam bots who will of course enter text into it. Since regular site visitors can not see this input, any value detected during form submission means a bot has been detected, which will then be blocked from submitting the form.', 'event_espresso'),
275
+							'default' => EE_Registry::instance()->CFG->registration->use_bot_trap !== null
276
+								? EE_Registry::instance()->CFG->registration->use_bot_trap
277
+								: true,
278
+							'required' => false
279
+						)
280
+					),
281
+					'use_encryption' => new EE_Yes_No_Input(
282
+						array(
283
+							'html_label_text' => esc_html__('Encrypt Bot Trap Data', 'event_espresso'),
284
+							'html_help_text' => esc_html__(
285
+								'One way to detect spam bots is by looking at how long it takes them to submit a form. They are often inhumanly fast, or will submit forms hours, days, or even weeks after the form was first scraped off the web. The Event Espresso Bot Trap will send a timestamp with the Ticket Selector form when it is submitted. By default, this timestamp is encrypted so that the spam bots can not change it, but encryption may cause issues on some servers due to configuration "conflicts". If you continuously get caught in the bot trap, then try setting this option to "No". This may increase the number of spam submissions you receive, but increases server compatibility.',
286
+								'event_espresso'
287
+							),
288
+							'default' => EE_Registry::instance()->CFG->registration->use_encryption !== null
289
+								? EE_Registry::instance()->CFG->registration->use_encryption
290
+								: true,
291
+							'required' => false
292
+						)
293
+					),
294
+				)
295
+			)
296
+		);
297
+	}
298 298
 
299 299
 
300
-    /**
301
-     * update_bot_trap_settings_form
302
-     *
303
-     * @param EE_Registration_Config $EE_Registration_Config
304
-     * @return EE_Registration_Config
305
-     * @throws ReflectionException
306
-     * @throws EE_Error
307
-     */
308
-    public static function update_bot_trap_settings_form(EE_Registration_Config $EE_Registration_Config)
309
-    {
310
-        try {
311
-            $bot_trap_settings_form = EED_Bot_Trap::_bot_trap_settings_form();
312
-            // if not displaying a form, then check for form submission
313
-            if ($bot_trap_settings_form->was_submitted()) {
314
-                // capture form data
315
-                $bot_trap_settings_form->receive_form_submission();
316
-                // validate form data
317
-                if ($bot_trap_settings_form->is_valid()) {
318
-                    // grab validated data from form
319
-                    $valid_data = $bot_trap_settings_form->valid_data();
320
-                    if (isset($valid_data['use_bot_trap'], $valid_data['use_encryption'])) {
321
-                        $EE_Registration_Config->use_bot_trap = $valid_data['use_bot_trap'];
322
-                        $EE_Registration_Config->use_encryption = $valid_data['use_encryption'];
323
-                    } else {
324
-                        EE_Error::add_error(esc_html__('Invalid or missing Bot Trap settings. Please refresh the form and try again.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
325
-                    }
326
-                } else {
327
-                    if ($bot_trap_settings_form->submission_error_message() !== '') {
328
-                        EE_Error::add_error($bot_trap_settings_form->submission_error_message(), __FILE__, __FUNCTION__, __LINE__);
329
-                    }
330
-                }
331
-            }
332
-        } catch (EE_Error $e) {
333
-            $e->get_error();
334
-        }
335
-        return $EE_Registration_Config;
336
-    }
300
+	/**
301
+	 * update_bot_trap_settings_form
302
+	 *
303
+	 * @param EE_Registration_Config $EE_Registration_Config
304
+	 * @return EE_Registration_Config
305
+	 * @throws ReflectionException
306
+	 * @throws EE_Error
307
+	 */
308
+	public static function update_bot_trap_settings_form(EE_Registration_Config $EE_Registration_Config)
309
+	{
310
+		try {
311
+			$bot_trap_settings_form = EED_Bot_Trap::_bot_trap_settings_form();
312
+			// if not displaying a form, then check for form submission
313
+			if ($bot_trap_settings_form->was_submitted()) {
314
+				// capture form data
315
+				$bot_trap_settings_form->receive_form_submission();
316
+				// validate form data
317
+				if ($bot_trap_settings_form->is_valid()) {
318
+					// grab validated data from form
319
+					$valid_data = $bot_trap_settings_form->valid_data();
320
+					if (isset($valid_data['use_bot_trap'], $valid_data['use_encryption'])) {
321
+						$EE_Registration_Config->use_bot_trap = $valid_data['use_bot_trap'];
322
+						$EE_Registration_Config->use_encryption = $valid_data['use_encryption'];
323
+					} else {
324
+						EE_Error::add_error(esc_html__('Invalid or missing Bot Trap settings. Please refresh the form and try again.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
325
+					}
326
+				} else {
327
+					if ($bot_trap_settings_form->submission_error_message() !== '') {
328
+						EE_Error::add_error($bot_trap_settings_form->submission_error_message(), __FILE__, __FUNCTION__, __LINE__);
329
+					}
330
+				}
331
+			}
332
+		} catch (EE_Error $e) {
333
+			$e->get_error();
334
+		}
335
+		return $EE_Registration_Config;
336
+	}
337 337
 
338 338
 
339 339
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
      */
52 52
     public static function set_trap()
53 53
     {
54
-        define('EE_BOT_TRAP_BASE_URL', plugin_dir_url(__FILE__) . DS);
54
+        define('EE_BOT_TRAP_BASE_URL', plugin_dir_url(__FILE__).DS);
55 55
         add_action(
56 56
             'AHEE__ticket_selector_chart__template__after_ticket_selector',
57 57
             array('EED_Bot_Trap', 'generate_bot_trap'),
@@ -115,9 +115,9 @@  discard block
 block discarded – undo
115 115
         $do_not_enter = esc_html__('please do not enter anything in this input', 'event_espresso');
116 116
         $time = microtime(true);
117 117
         $html = '<div class="tkt-slctr-request-processor-dv" style="float:left; margin:0 0 0 -999em; height: 0;">';
118
-        $html .= '<label for="tkt-slctr-request-processor-email-' . $time . '">' . $do_not_enter . '</label>';
118
+        $html .= '<label for="tkt-slctr-request-processor-email-'.$time.'">'.$do_not_enter.'</label>';
119 119
         $html .= '<input type="email" id="tkt-slctr-request-processor-email-';
120
-        $html .= $time . '" name="tkt-slctr-request-processor-email" value=""/>';
120
+        $html .= $time.'" name="tkt-slctr-request-processor-email" value=""/>';
121 121
         $html .= '<input type="hidden" name="tkt-slctr-request-processor-token" value="';
122 122
         if (EE_Registry::instance()->CFG->registration->use_encryption) {
123 123
             EE_Registry::instance()->load_core('EE_Encryption');
@@ -159,12 +159,12 @@  discard block
 block discarded – undo
159 159
         // ticket form submitted too impossibly fast ( after now ) or more than an hour later ???
160 160
         $suspicious_timing = $bot_trap_timestamp > time() || $bot_trap_timestamp < (time() - HOUR_IN_SECONDS);
161 161
         // are we human ?
162
-        if ($empty_trap && !$suspicious_timing) {
162
+        if ($empty_trap && ! $suspicious_timing) {
163 163
             do_action('AHEE__EED_Bot_Trap__process_bot_trap__trap_not_triggered');
164 164
             return;
165 165
         }
166 166
         // check the given callback is valid first before executing
167
-        if (!is_callable($triggered_trap_callback)) {
167
+        if ( ! is_callable($triggered_trap_callback)) {
168 168
             // invalid callback so lets just sub in our default.
169 169
             $triggered_trap_callback = array('EED_Bot_Trap', 'triggered_trap_response');
170 170
         }
Please login to merge, or discard this patch.
modules/thank_you_page/EED_Thank_You_Page.module.php 1 patch
Indentation   +916 added lines, -916 removed lines patch added patch discarded remove patch
@@ -14,757 +14,757 @@  discard block
 block discarded – undo
14 14
 class EED_Thank_You_Page extends EED_Module
15 15
 {
16 16
 
17
-    /**
18
-     * time in seconds to wait for the IPN to arrive before telling the registrant to bugger off ( 1200s = 20 minutes )
19
-     */
20
-    const IPN_wait_time = 1200;
21
-
22
-    /**
23
-     * The transaction specified by the reg_url_link passed from the Request, or from the Session
24
-     *
25
-     * @var EE_Transaction $_current_txn
26
-     */
27
-    private $_current_txn;
28
-
29
-    /**
30
-     * @var EE_Registration $_primary_registrant
31
-     */
32
-    private $_primary_registrant;
33
-
34
-    /**
35
-     * The reg_url_link passed from the Request, or from the Session
36
-     *
37
-     * @var string $_reg_url_link
38
-     */
39
-    private $_reg_url_link;
40
-
41
-    /**
42
-     * whether the incoming reg_url_link is for the primary registrant or not
43
-     *
44
-     * @var boolean $_is_primary
45
-     */
46
-    private $_is_primary;
47
-
48
-    /**
49
-     * The URL for revisiting the SPCO attendee information step
50
-     *
51
-     * @var string $_SPCO_attendee_information_url
52
-     */
53
-    private $_SPCO_attendee_information_url;
54
-
55
-    /**
56
-     * The URL for revisiting the SPCO payment options step
57
-     *
58
-     * @var string $_SPCO_payment_options_url
59
-     */
60
-    private $_SPCO_payment_options_url;
61
-
62
-    /**
63
-     * whether to display the Payment Options link
64
-     *
65
-     * @var boolean $_show_try_pay_again_link
66
-     */
67
-    private $_show_try_pay_again_link = false;
68
-
69
-    /**
70
-     * whether payments are allowed at this time
71
-     *
72
-     * @var boolean $_payments_closed
73
-     */
74
-    private $_payments_closed = false;
75
-
76
-    /**
77
-     * whether the selected payment method is Bank, Check , Invoice, etc
78
-     *
79
-     * @var boolean $_is_offline_payment_method
80
-     */
81
-    private $_is_offline_payment_method = true;
82
-
83
-
84
-
85
-    /**
86
-     * @return EED_Module|EED_Thank_You_Page
87
-     */
88
-    public static function instance()
89
-    {
90
-        return parent::get_instance(__CLASS__);
91
-    }
92
-
93
-
94
-    /**
95
-     * set_hooks - for hooking into EE Core, modules, etc
96
-     *
97
-     * @return void
98
-     */
99
-    public static function set_hooks()
100
-    {
101
-        add_action('wp_loaded', array('EED_Thank_You_Page', 'set_definitions'), 2);
102
-    }
103
-
104
-
105
-
106
-    /**
107
-     * set_hooks_admin - for hooking into EE Admin Core, modules, etc
108
-     *
109
-     * @return void
110
-     */
111
-    public static function set_hooks_admin()
112
-    {
113
-        // AJAX for IPN monitoring
114
-        add_filter('heartbeat_received', array('EED_Thank_You_Page', 'thank_you_page_IPN_monitor'), 10, 3);
115
-        add_filter(
116
-            'heartbeat_nopriv_received',
117
-            array('EED_Thank_You_Page', 'thank_you_page_IPN_monitor'),
118
-            10,
119
-            3
120
-        );
121
-        add_action(
122
-            'wp_ajax_espresso_resend_reg_confirmation_email',
123
-            array('EED_Thank_You_Page', 'resend_reg_confirmation_email'),
124
-            10,
125
-            2
126
-        );
127
-        add_action(
128
-            'wp_ajax_nopriv_espresso_resend_reg_confirmation_email',
129
-            array('EED_Thank_You_Page', 'resend_reg_confirmation_email'),
130
-            10,
131
-            2
132
-        );
133
-    }
134
-
135
-
136
-
137
-    /**
138
-     * set_definitions
139
-     *
140
-     * @return void
141
-     */
142
-    public static function set_definitions()
143
-    {
144
-        define('THANK_YOU_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets' . DS);
145
-        define('THANK_YOU_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)) . 'templates' . DS);
146
-    }
147
-
148
-
149
-
150
-    /**
151
-     * get_txn
152
-     *
153
-     * @return EE_Transaction
154
-     */
155
-    public function get_txn()
156
-    {
157
-        if ($this->_current_txn instanceof EE_Transaction) {
158
-            return $this->_current_txn;
159
-        }
160
-        $TXN_model = EE_Registry::instance()->load_model('Transaction');
161
-        if ( ! $TXN_model instanceof EEM_Transaction) {
162
-            EE_Error::add_error(
163
-                __('The transaction model could not be established.', 'event_espresso'),
164
-                __FILE__,
165
-                __FUNCTION__,
166
-                __LINE__
167
-            );
168
-            return null;
169
-        }
170
-        //get the transaction. yes, we may have just loaded it, but it may have been updated, or this may be via an ajax request
171
-        $this->_current_txn = $TXN_model->get_transaction_from_reg_url_link($this->_reg_url_link);
172
-        // verify TXN
173
-        if (WP_DEBUG && ! $this->_current_txn instanceof EE_Transaction) {
174
-            EE_Error::add_error(
175
-                __(
176
-                    'No transaction information could be retrieved or the transaction data is not of the correct type.',
177
-                    'event_espresso'
178
-                ),
179
-                __FILE__,
180
-                __FUNCTION__,
181
-                __LINE__
182
-            );
183
-            return null;
184
-        }
185
-        return $this->_current_txn;
186
-    }
187
-
188
-
189
-
190
-    /**
191
-     * get_txn_payments
192
-     *
193
-     * @param int $since
194
-     * @return mixed array of EE_Payment || FALSE
195
-     * @throws \EE_Error
196
-     */
197
-    public function get_txn_payments($since = 0)
198
-    {
199
-        if ( ! $this->get_txn()) {
200
-            return false;
201
-        }
202
-        $args = array('order_by' => array('PAY_timestamp' => 'ASC'));
203
-        if ($since > 0) {
204
-            $args[0] = array('PAY_timestamp' => array('>', $since));
205
-        }
206
-        // get array of payments with most recent first
207
-        return $this->_current_txn->payments($args);
208
-    }
209
-
210
-
211
-
212
-    /**
213
-     * get_reg_url_link
214
-     *
215
-     * @return void
216
-     */
217
-    private function _get_reg_url_link()
218
-    {
219
-        if ( ! empty($this->_reg_url_link)) {
220
-            return;
221
-        }
222
-        // only do thank you page stuff if we have a REG_url_link in the url
223
-        if (WP_DEBUG && ! EE_Registry::instance()->REQ->is_set('e_reg_url_link')) {
224
-            EE_Error::add_error(
225
-                __(
226
-                    'No transaction information could be retrieved because the registration URL link is missing or invalid.',
227
-                    'event_espresso'
228
-                ),
229
-                __FILE__,
230
-                __FUNCTION__,
231
-                __LINE__
232
-            );
233
-            return;
234
-        }
235
-        // check for reg_url_link
236
-        $this->_reg_url_link = EE_Registry::instance()->REQ->get('e_reg_url_link');
237
-    }
238
-
239
-
240
-
241
-    /**
242
-     * set_reg_url_link
243
-     *
244
-     * @param string $reg_url_link
245
-     */
246
-    public function set_reg_url_link($reg_url_link = null)
247
-    {
248
-        $this->_reg_url_link = ! empty($reg_url_link) ? $reg_url_link : $this->_reg_url_link;
249
-    }
250
-
251
-
252
-
253
-    /**
254
-     * run - initial module setup
255
-     * this method is primarily used for activating resources in the EE_Front_Controller thru the use of filters
256
-     *
257
-     * @param WP $WP
258
-     * @return void
259
-     * @throws \EE_Error
260
-     */
261
-    public function run($WP)
262
-    {
263
-
264
-    }
265
-
266
-
267
-
268
-    /**
269
-     * load_resources
270
-     *
271
-     * @return void
272
-     * @throws \EE_Error
273
-     */
274
-    public function load_resources() {
275
-        $this->_get_reg_url_link();
276
-        // resend_reg_confirmation_email ?
277
-        if (EE_Registry::instance()->REQ->is_set('resend')) {
278
-            EED_Thank_You_Page::resend_reg_confirmation_email();
279
-        }
280
-        EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
281
-        $this->_translate_strings();
282
-        // load assets
283
-        add_action('wp_enqueue_scripts', array($this, 'load_js'), 10);
284
-    }
285
-
286
-
287
-
288
-    /**
289
-     * load_js
290
-     *
291
-     * @return void
292
-     */
293
-    protected function _translate_strings()
294
-    {
295
-        EE_Registry::$i18n_js_strings['e_reg_url_link'] = $this->_reg_url_link;
296
-        EE_Registry::$i18n_js_strings['initial_access'] = time();
297
-        EE_Registry::$i18n_js_strings['IPN_wait_time'] = EED_Thank_You_Page::IPN_wait_time;
298
-        EE_Registry::$i18n_js_strings['TXN_complete'] = EEM_Transaction::complete_status_code;
299
-        EE_Registry::$i18n_js_strings['TXN_incomplete'] = EEM_Transaction::incomplete_status_code;
300
-        EE_Registry::$i18n_js_strings['checking_for_new_payments'] = __(
301
-            'checking for new payments...',
302
-            'event_espresso'
303
-        );
304
-        EE_Registry::$i18n_js_strings['loading_payment_info'] = __(
305
-            'loading payment information...',
306
-            'event_espresso'
307
-        );
308
-        EE_Registry::$i18n_js_strings['server_error'] = __(
309
-            'An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again.',
310
-            'event_espresso'
311
-        );
312
-        EE_Registry::$i18n_js_strings['slow_IPN'] = apply_filters(
313
-            'EED_Thank_You_Page__load_js__slow_IPN',
314
-            sprintf(
315
-                __(
316
-                    '%sThe Payment Notification appears to be taking longer than usual to arrive. Maybe check back later or just wait for your payment and registration confirmation results to be sent to you via email. We apologize for any inconvenience this may have caused.%s',
317
-                    'event_espresso'
318
-                ),
319
-                '<div id="espresso-thank-you-page-slow-IPN-dv" class="ee-attention jst-left">',
320
-                '</div>'
321
-            )
322
-        );
323
-    }
324
-
325
-
326
-
327
-    /**
328
-     * load_js
329
-     *
330
-     * @return void
331
-     */
332
-    public function load_js()
333
-    {
334
-        wp_register_script(
335
-            'thank_you_page',
336
-            THANK_YOU_ASSETS_URL . 'thank_you_page.js',
337
-            array('espresso_core', 'heartbeat'),
338
-            EVENT_ESPRESSO_VERSION,
339
-            true
340
-        );
341
-        wp_enqueue_script('thank_you_page');
342
-        wp_enqueue_style('espresso_default');
343
-    }
344
-
345
-
346
-
347
-    /**
348
-     * init
349
-     *
350
-     * @return void
351
-     * @throws \EE_Error
352
-     */
353
-    public function init()
354
-    {
355
-        $this->_get_reg_url_link();
356
-        if ( ! $this->get_txn()) {
357
-            echo EEH_HTML::div(
358
-                EEH_HTML::h4(__('We\'re sorry...', 'event_espresso'), '', '') .
359
-                sprintf(
360
-                    __(
361
-                        'This is a system page for displaying transaction information after a purchase.%1$sYou are most likely seeing this notice because you have navigated to this page%1$sthrough some means other than completing a transaction.%1$sSorry for the disappointment, but you will most likely find nothing of interest here.%1$s%1$s',
362
-                        'event_espresso'
363
-                    ),
364
-                    '<br/>'
365
-                ),
366
-                '',
367
-                'ee-attention'
368
-            );
369
-            return null;
370
-        }
371
-        // if we've made it to the Thank You page, then let's toggle any "Failed" transactions to "Incomplete"
372
-        if ($this->_current_txn->status_ID() === EEM_Transaction::failed_status_code) {
373
-            $this->_current_txn->set_status(EEM_Transaction::incomplete_status_code);
374
-            $this->_current_txn->save();
375
-        }
376
-        $this->_primary_registrant = $this->_current_txn->primary_registration() instanceof EE_Registration
377
-            ? $this->_current_txn->primary_registration()
378
-            : null;
379
-        $this->_is_primary = $this->_primary_registrant->reg_url_link() === $this->_reg_url_link ? true : false;
380
-        $show_try_pay_again_link_default = apply_filters(
381
-            'AFEE__EED_Thank_You_Page__init__show_try_pay_again_link_default',
382
-            true
383
-        );
384
-        $this->_show_try_pay_again_link = $show_try_pay_again_link_default;
385
-        // txn status ?
386
-        if ($this->_current_txn->is_completed()) {
387
-            $this->_show_try_pay_again_link = $show_try_pay_again_link_default;
388
-        } else if (
389
-            $this->_current_txn->is_incomplete()
390
-            && ($this->_primary_registrant->is_approved()
391
-                || $this->_primary_registrant->is_pending_payment())
392
-        ) {
393
-            $this->_show_try_pay_again_link = true;
394
-        } else if ($this->_primary_registrant->is_approved() || $this->_primary_registrant->is_pending_payment()) {
395
-            // its pending
396
-            $this->_show_try_pay_again_link = isset(
397
-                                                  EE_Registry::instance()->CFG->registration->show_pending_payment_options
398
-                                              )
399
-                                              && EE_Registry::instance()->CFG->registration->show_pending_payment_options
400
-                ? true
401
-                : $show_try_pay_again_link_default;
402
-        }
403
-        $this->_payments_closed = ! $this->_current_txn->payment_method() instanceof EE_Payment_Method
404
-            ? true
405
-            : false;
406
-        $this->_is_offline_payment_method = false;
407
-        if (
408
-            // if payment method is unknown
409
-            ! $this->_current_txn->payment_method() instanceof EE_Payment_Method
410
-            || (
411
-                // or is an offline payment method
412
-                $this->_current_txn->payment_method() instanceof EE_Payment_Method
413
-                && $this->_current_txn->payment_method()->is_off_line()
414
-            )
415
-        ) {
416
-            $this->_is_offline_payment_method = true;
417
-        }
418
-        // link to SPCO
419
-        $revisit_spco_url = add_query_arg(
420
-            array('ee' => '_register', 'revisit' => true, 'e_reg_url_link' => $this->_reg_url_link),
421
-            EE_Registry::instance()->CFG->core->reg_page_url()
422
-        );
423
-        // link to SPCO payment_options
424
-        $this->_SPCO_payment_options_url = $this->_primary_registrant instanceof EE_Registration
425
-            ? $this->_primary_registrant->payment_overview_url()
426
-            : add_query_arg(
427
-                array('step' => 'payment_options'),
428
-                $revisit_spco_url
429
-            );
430
-        // link to SPCO attendee_information
431
-        $this->_SPCO_attendee_information_url = $this->_primary_registrant instanceof EE_Registration
432
-            ? $this->_primary_registrant->edit_attendee_information_url()
433
-            : false;
434
-        do_action('AHEE__EED_Thank_You_Page__init_end', $this->_current_txn);
435
-        // set no cache headers and constants
436
-        EE_System::do_not_cache();
437
-    }
438
-
439
-
440
-
441
-    /**
442
-     * display_thank_you_page_results
443
-     *
444
-     * @return string
445
-     * @throws \EE_Error
446
-     */
447
-    public function thank_you_page_results()
448
-    {
449
-        $this->init();
450
-        if ( ! $this->_current_txn instanceof EE_Transaction) {
451
-            return EE_Error::get_notices();
452
-        }
453
-        // link to receipt
454
-        $template_args['TXN_receipt_url'] = $this->_current_txn->receipt_url('html');
455
-        if ( ! empty($template_args['TXN_receipt_url'])) {
456
-            $template_args['order_conf_desc'] = __(
457
-                '%1$sCongratulations%2$sYour registration has been successfully processed.%3$sCheck your email for your registration confirmation or click the button below to view / download / print a full description of your purchases and registration information.',
458
-                'event_espresso'
459
-            );
460
-        } else {
461
-            $template_args['order_conf_desc'] = __(
462
-                '%1$sCongratulations%2$sYour registration has been successfully processed.%3$sCheck your email for your registration confirmation.',
463
-                'event_espresso'
464
-            );
465
-        }
466
-        $template_args['transaction'] = $this->_current_txn;
467
-        $template_args['revisit'] = EE_Registry::instance()->REQ->get('revisit', false);
468
-        add_action('AHEE__thank_you_page_overview_template__content', array($this, 'get_registration_details'));
469
-        if ($this->_is_primary && ! $this->_current_txn->is_free()) {
470
-            add_action('AHEE__thank_you_page_overview_template__content', array($this, 'get_ajax_content'));
471
-        }
472
-        return EEH_Template::locate_template(
473
-            THANK_YOU_TEMPLATES_PATH . 'thank-you-page-overview.template.php',
474
-            $template_args,
475
-            true,
476
-            true
477
-        );
478
-    }
479
-
480
-
481
-
482
-    /**
483
-     * thank_you_page_IPN_monitor
484
-     * this basically just pulls the TXN based on the reg_url_link sent from the server,
485
-     * then checks that the TXN status is not failed, and that no other errors have been generated.
486
-     * it also calculates the IPN wait time since the Thank You page was first loaded
487
-     *
488
-     * @param array $response
489
-     * @param array $data
490
-     * @return array
491
-     * @throws \EE_Error
492
-     */
493
-    public static function thank_you_page_IPN_monitor($response = array(), $data = array())
494
-    {
495
-        // does this heartbeat contain our data ?
496
-        if ( ! isset($data['espresso_thank_you_page'])) {
497
-            return $response;
498
-        }
499
-        // check for reg_url_link in the incoming heartbeat data
500
-        if ( ! isset($data['espresso_thank_you_page']['e_reg_url_link'])) {
501
-            $response['espresso_thank_you_page'] = array(
502
-                'errors' => ! empty($notices['errors'])
503
-                    ? $notices['errors']
504
-                    : __(
505
-                        'No transaction information could be retrieved because the registration URL link is missing or invalid.',
506
-                        'event_espresso'
507
-                    )
508
-            );
509
-            return $response;
510
-        }
511
-        // kk heartbeat has our data
512
-        $response['espresso_thank_you_page'] = array();
513
-        // set_definitions, instantiate the thank you page class, and get the ball rolling
514
-        EED_Thank_You_Page::set_definitions();
515
-        /** @var $espresso_thank_you_page EED_Thank_You_Page */
516
-        $espresso_thank_you_page = EED_Thank_You_Page::instance();
517
-        $espresso_thank_you_page->set_reg_url_link($data['espresso_thank_you_page']['e_reg_url_link']);
518
-        $espresso_thank_you_page->init();
519
-        //get TXN
520
-        $TXN = $espresso_thank_you_page->get_txn();
521
-        // no TXN? then get out
522
-        if ( ! $TXN instanceof EE_Transaction) {
523
-            $notices = EE_Error::get_notices();
524
-            $response['espresso_thank_you_page'] = array(
525
-                'errors' => ! empty($notices['errors'])
526
-                    ? $notices['errors']
527
-                    : sprintf(
528
-                        __(
529
-                            'The information for your transaction could not be retrieved from the server or the transaction data received was invalid because of a technical reason. (%s)',
530
-                            'event_espresso'
531
-                        ),
532
-                        __LINE__
533
-                    )
534
-            );
535
-            return $response;
536
-        }
537
-        // grab transient of TXN's status
538
-        $txn_status = isset($data['espresso_thank_you_page']['txn_status'])
539
-            ? $data['espresso_thank_you_page']['txn_status']
540
-            : null;
541
-        // has the TXN status changed since we last checked (or empty because this is the first time running through this code)?
542
-        if ($txn_status !== $TXN->status_ID()) {
543
-            // switch between two possible basic outcomes
544
-            switch ($TXN->status_ID()) {
545
-                // TXN has been updated in some way
546
-                case EEM_Transaction::overpaid_status_code:
547
-                case EEM_Transaction::complete_status_code:
548
-                case EEM_Transaction::incomplete_status_code:
549
-                    // send updated TXN results back to client,
550
-                    $response['espresso_thank_you_page'] = array(
551
-                        'transaction_details' => $espresso_thank_you_page->get_transaction_details(),
552
-                        'txn_status'          => $TXN->status_ID()
553
-                    );
554
-                    break;
555
-                // or we have a bad TXN, or really slow IPN, so calculate the wait time and send that back...
556
-                case EEM_Transaction::failed_status_code:
557
-                default:
558
-                    // keep on waiting...
559
-                    return $espresso_thank_you_page->_update_server_wait_time($data['espresso_thank_you_page']);
560
-            }
561
-            // or is the TXN still failed (never been updated) ???
562
-        } else if ($TXN->failed()) {
563
-            // keep on waiting...
564
-            return $espresso_thank_you_page->_update_server_wait_time($data['espresso_thank_you_page']);
565
-        }
566
-        // TXN is happening so let's get the payments now
567
-        // if we've already gotten payments then the heartbeat data will contain the timestamp of the last time we checked
568
-        $since = isset($data['espresso_thank_you_page']['get_payments_since'])
569
-            ? $data['espresso_thank_you_page']['get_payments_since']
570
-            : 0;
571
-        // then check for payments
572
-        $payments = $espresso_thank_you_page->get_txn_payments($since);
573
-        // has a payment been processed ?
574
-        if ( ! empty($payments) || $espresso_thank_you_page->_is_offline_payment_method) {
575
-            if ($since) {
576
-                $response['espresso_thank_you_page'] = array(
577
-                    'new_payments'        => $espresso_thank_you_page->get_new_payments($payments),
578
-                    'transaction_details' => $espresso_thank_you_page->get_transaction_details(),
579
-                    'txn_status'          => $TXN->status_ID()
580
-                );
581
-            } else {
582
-                $response['espresso_thank_you_page']['payment_details'] = $espresso_thank_you_page->get_payment_details(
583
-                    $payments
584
-                );
585
-            }
586
-            // reset time to check for payments
587
-            $response['espresso_thank_you_page']['get_payments_since'] = time();
588
-        } else {
589
-            $response['espresso_thank_you_page']['get_payments_since'] = $since;
590
-        }
591
-        return $response;
592
-    }
593
-
594
-
595
-
596
-    /**
597
-     * _update_server_wait_time
598
-     *
599
-     * @param array $thank_you_page_data thank you page portion of the incoming JSON array from the WP heartbeat data
600
-     * @return array
601
-     * @throws \EE_Error
602
-     */
603
-    private function _update_server_wait_time($thank_you_page_data = array())
604
-    {
605
-        $response['espresso_thank_you_page'] = array(
606
-            'still_waiting' => isset($thank_you_page_data['initial_access'])
607
-                ? time() - $thank_you_page_data['initial_access']
608
-                : 0,
609
-            'txn_status'    => $this->_current_txn->status_ID()
610
-        );
611
-        return $response;
612
-    }
613
-
614
-
615
-
616
-    /**
617
-     * get_registration_details
618
-     *
619
-     * @throws \EE_Error
620
-     */
621
-    public function get_registration_details()
622
-    {
623
-        //prepare variables for displaying
624
-        $template_args = array();
625
-        $template_args['transaction'] = $this->_current_txn;
626
-        $template_args['reg_url_link'] = $this->_reg_url_link;
627
-        $template_args['is_primary'] = $this->_is_primary;
628
-        $template_args['SPCO_attendee_information_url'] = $this->_SPCO_attendee_information_url;
629
-        $template_args['resend_reg_confirmation_url'] = add_query_arg(
630
-            array('token' => $this->_reg_url_link, 'resend_reg_confirmation' => 'true'),
631
-            EE_Registry::instance()->CFG->core->thank_you_page_url()
632
-        );
633
-        // verify template arguments
634
-        EEH_Template_Validator::verify_instanceof($template_args['transaction'], '$transaction', 'EE_Transaction');
635
-        EEH_Template_Validator::verify_isnt_null(
636
-            $template_args['SPCO_attendee_information_url'],
637
-            '$SPCO_attendee_information_url'
638
-        );
639
-        echo EEH_Template::locate_template(
640
-            THANK_YOU_TEMPLATES_PATH . 'thank-you-page-registration-details.template.php',
641
-            $template_args,
642
-            true,
643
-            true
644
-        );
645
-    }
646
-
647
-
648
-
649
-    /**
650
-     * resend_reg_confirmation_email
651
-     *
652
-     * @throws \EE_Error
653
-     */
654
-    public static function resend_reg_confirmation_email()
655
-    {
656
-        EE_Registry::instance()->load_core('Request_Handler');
657
-        $reg_url_link = EE_Registry::instance()->REQ->get('token');
658
-        // was a REG_ID passed ?
659
-        if ($reg_url_link) {
660
-            $registration = EE_Registry::instance()->load_model('Registration')->get_one(
661
-                array(array('REG_url_link' => $reg_url_link))
662
-            );
663
-            if ($registration instanceof EE_Registration) {
664
-                // resend email
665
-                EED_Messages::process_resend(array('_REG_ID' => $registration->ID()));
666
-            } else {
667
-                EE_Error::add_error(
668
-                    __(
669
-                        'The Registration Confirmation email could not be sent because a valid Registration could not be retrieved from the database.',
670
-                        'event_espresso'
671
-                    ),
672
-                    __FILE__,
673
-                    __FUNCTION__,
674
-                    __LINE__
675
-                );
676
-            }
677
-        } else {
678
-            EE_Error::add_error(
679
-                __(
680
-                    'The Registration Confirmation email could not be sent because a registration token is missing or invalid.',
681
-                    'event_espresso'
682
-                ),
683
-                __FILE__,
684
-                __FUNCTION__,
685
-                __LINE__
686
-            );
687
-        }
688
-        // request sent via AJAX ?
689
-        if (EE_FRONT_AJAX) {
690
-            echo wp_json_encode(EE_Error::get_notices(false));
691
-            die();
692
-            // or was JS disabled ?
693
-        } else {
694
-            // save errors so that they get picked up on the next request
695
-            EE_Error::get_notices(true, true);
696
-            wp_safe_redirect(
697
-                add_query_arg(
698
-                    array('e_reg_url_link' => $reg_url_link),
699
-                    EE_Registry::instance()->CFG->core->thank_you_page_url()
700
-                )
701
-            );
702
-        }
703
-    }
704
-
705
-
706
-
707
-    /**
708
-     * get_ajax_content
709
-     *
710
-     * @return void
711
-     * @throws \EE_Error
712
-     */
713
-    public function get_ajax_content()
714
-    {
715
-        if ( ! $this->get_txn()) {
716
-            return;
717
-        }
718
-        // first determine which event(s) require pre-approval or not
719
-        $events = array();
720
-        $events_requiring_pre_approval = array();
721
-        foreach ($this->_current_txn->registrations() as $registration) {
722
-            if ($registration instanceof EE_Registration) {
723
-                $event = $registration->event();
724
-                if ($event instanceof EE_Event) {
725
-                    if ($registration->is_not_approved() && $registration->event() instanceof EE_Event) {
726
-                        $events_requiring_pre_approval[$event->ID()] = $event;
727
-                    } else {
728
-                        $events[$event->ID()] = $event;
729
-                    }
730
-                }
731
-            }
732
-        }
733
-        $this->display_details_for_events_requiring_pre_approval($events_requiring_pre_approval);
734
-        $this->display_details_for_events($events);
735
-    }
736
-
737
-
738
-
739
-    /**
740
-     * display_details_for_events
741
-     *
742
-     * @param EE_Event[] $events
743
-     * @return void
744
-     */
745
-    public function display_details_for_events($events = array())
746
-    {
747
-        if ( ! empty($events)) {
748
-            ?>
17
+	/**
18
+	 * time in seconds to wait for the IPN to arrive before telling the registrant to bugger off ( 1200s = 20 minutes )
19
+	 */
20
+	const IPN_wait_time = 1200;
21
+
22
+	/**
23
+	 * The transaction specified by the reg_url_link passed from the Request, or from the Session
24
+	 *
25
+	 * @var EE_Transaction $_current_txn
26
+	 */
27
+	private $_current_txn;
28
+
29
+	/**
30
+	 * @var EE_Registration $_primary_registrant
31
+	 */
32
+	private $_primary_registrant;
33
+
34
+	/**
35
+	 * The reg_url_link passed from the Request, or from the Session
36
+	 *
37
+	 * @var string $_reg_url_link
38
+	 */
39
+	private $_reg_url_link;
40
+
41
+	/**
42
+	 * whether the incoming reg_url_link is for the primary registrant or not
43
+	 *
44
+	 * @var boolean $_is_primary
45
+	 */
46
+	private $_is_primary;
47
+
48
+	/**
49
+	 * The URL for revisiting the SPCO attendee information step
50
+	 *
51
+	 * @var string $_SPCO_attendee_information_url
52
+	 */
53
+	private $_SPCO_attendee_information_url;
54
+
55
+	/**
56
+	 * The URL for revisiting the SPCO payment options step
57
+	 *
58
+	 * @var string $_SPCO_payment_options_url
59
+	 */
60
+	private $_SPCO_payment_options_url;
61
+
62
+	/**
63
+	 * whether to display the Payment Options link
64
+	 *
65
+	 * @var boolean $_show_try_pay_again_link
66
+	 */
67
+	private $_show_try_pay_again_link = false;
68
+
69
+	/**
70
+	 * whether payments are allowed at this time
71
+	 *
72
+	 * @var boolean $_payments_closed
73
+	 */
74
+	private $_payments_closed = false;
75
+
76
+	/**
77
+	 * whether the selected payment method is Bank, Check , Invoice, etc
78
+	 *
79
+	 * @var boolean $_is_offline_payment_method
80
+	 */
81
+	private $_is_offline_payment_method = true;
82
+
83
+
84
+
85
+	/**
86
+	 * @return EED_Module|EED_Thank_You_Page
87
+	 */
88
+	public static function instance()
89
+	{
90
+		return parent::get_instance(__CLASS__);
91
+	}
92
+
93
+
94
+	/**
95
+	 * set_hooks - for hooking into EE Core, modules, etc
96
+	 *
97
+	 * @return void
98
+	 */
99
+	public static function set_hooks()
100
+	{
101
+		add_action('wp_loaded', array('EED_Thank_You_Page', 'set_definitions'), 2);
102
+	}
103
+
104
+
105
+
106
+	/**
107
+	 * set_hooks_admin - for hooking into EE Admin Core, modules, etc
108
+	 *
109
+	 * @return void
110
+	 */
111
+	public static function set_hooks_admin()
112
+	{
113
+		// AJAX for IPN monitoring
114
+		add_filter('heartbeat_received', array('EED_Thank_You_Page', 'thank_you_page_IPN_monitor'), 10, 3);
115
+		add_filter(
116
+			'heartbeat_nopriv_received',
117
+			array('EED_Thank_You_Page', 'thank_you_page_IPN_monitor'),
118
+			10,
119
+			3
120
+		);
121
+		add_action(
122
+			'wp_ajax_espresso_resend_reg_confirmation_email',
123
+			array('EED_Thank_You_Page', 'resend_reg_confirmation_email'),
124
+			10,
125
+			2
126
+		);
127
+		add_action(
128
+			'wp_ajax_nopriv_espresso_resend_reg_confirmation_email',
129
+			array('EED_Thank_You_Page', 'resend_reg_confirmation_email'),
130
+			10,
131
+			2
132
+		);
133
+	}
134
+
135
+
136
+
137
+	/**
138
+	 * set_definitions
139
+	 *
140
+	 * @return void
141
+	 */
142
+	public static function set_definitions()
143
+	{
144
+		define('THANK_YOU_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets' . DS);
145
+		define('THANK_YOU_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)) . 'templates' . DS);
146
+	}
147
+
148
+
149
+
150
+	/**
151
+	 * get_txn
152
+	 *
153
+	 * @return EE_Transaction
154
+	 */
155
+	public function get_txn()
156
+	{
157
+		if ($this->_current_txn instanceof EE_Transaction) {
158
+			return $this->_current_txn;
159
+		}
160
+		$TXN_model = EE_Registry::instance()->load_model('Transaction');
161
+		if ( ! $TXN_model instanceof EEM_Transaction) {
162
+			EE_Error::add_error(
163
+				__('The transaction model could not be established.', 'event_espresso'),
164
+				__FILE__,
165
+				__FUNCTION__,
166
+				__LINE__
167
+			);
168
+			return null;
169
+		}
170
+		//get the transaction. yes, we may have just loaded it, but it may have been updated, or this may be via an ajax request
171
+		$this->_current_txn = $TXN_model->get_transaction_from_reg_url_link($this->_reg_url_link);
172
+		// verify TXN
173
+		if (WP_DEBUG && ! $this->_current_txn instanceof EE_Transaction) {
174
+			EE_Error::add_error(
175
+				__(
176
+					'No transaction information could be retrieved or the transaction data is not of the correct type.',
177
+					'event_espresso'
178
+				),
179
+				__FILE__,
180
+				__FUNCTION__,
181
+				__LINE__
182
+			);
183
+			return null;
184
+		}
185
+		return $this->_current_txn;
186
+	}
187
+
188
+
189
+
190
+	/**
191
+	 * get_txn_payments
192
+	 *
193
+	 * @param int $since
194
+	 * @return mixed array of EE_Payment || FALSE
195
+	 * @throws \EE_Error
196
+	 */
197
+	public function get_txn_payments($since = 0)
198
+	{
199
+		if ( ! $this->get_txn()) {
200
+			return false;
201
+		}
202
+		$args = array('order_by' => array('PAY_timestamp' => 'ASC'));
203
+		if ($since > 0) {
204
+			$args[0] = array('PAY_timestamp' => array('>', $since));
205
+		}
206
+		// get array of payments with most recent first
207
+		return $this->_current_txn->payments($args);
208
+	}
209
+
210
+
211
+
212
+	/**
213
+	 * get_reg_url_link
214
+	 *
215
+	 * @return void
216
+	 */
217
+	private function _get_reg_url_link()
218
+	{
219
+		if ( ! empty($this->_reg_url_link)) {
220
+			return;
221
+		}
222
+		// only do thank you page stuff if we have a REG_url_link in the url
223
+		if (WP_DEBUG && ! EE_Registry::instance()->REQ->is_set('e_reg_url_link')) {
224
+			EE_Error::add_error(
225
+				__(
226
+					'No transaction information could be retrieved because the registration URL link is missing or invalid.',
227
+					'event_espresso'
228
+				),
229
+				__FILE__,
230
+				__FUNCTION__,
231
+				__LINE__
232
+			);
233
+			return;
234
+		}
235
+		// check for reg_url_link
236
+		$this->_reg_url_link = EE_Registry::instance()->REQ->get('e_reg_url_link');
237
+	}
238
+
239
+
240
+
241
+	/**
242
+	 * set_reg_url_link
243
+	 *
244
+	 * @param string $reg_url_link
245
+	 */
246
+	public function set_reg_url_link($reg_url_link = null)
247
+	{
248
+		$this->_reg_url_link = ! empty($reg_url_link) ? $reg_url_link : $this->_reg_url_link;
249
+	}
250
+
251
+
252
+
253
+	/**
254
+	 * run - initial module setup
255
+	 * this method is primarily used for activating resources in the EE_Front_Controller thru the use of filters
256
+	 *
257
+	 * @param WP $WP
258
+	 * @return void
259
+	 * @throws \EE_Error
260
+	 */
261
+	public function run($WP)
262
+	{
263
+
264
+	}
265
+
266
+
267
+
268
+	/**
269
+	 * load_resources
270
+	 *
271
+	 * @return void
272
+	 * @throws \EE_Error
273
+	 */
274
+	public function load_resources() {
275
+		$this->_get_reg_url_link();
276
+		// resend_reg_confirmation_email ?
277
+		if (EE_Registry::instance()->REQ->is_set('resend')) {
278
+			EED_Thank_You_Page::resend_reg_confirmation_email();
279
+		}
280
+		EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
281
+		$this->_translate_strings();
282
+		// load assets
283
+		add_action('wp_enqueue_scripts', array($this, 'load_js'), 10);
284
+	}
285
+
286
+
287
+
288
+	/**
289
+	 * load_js
290
+	 *
291
+	 * @return void
292
+	 */
293
+	protected function _translate_strings()
294
+	{
295
+		EE_Registry::$i18n_js_strings['e_reg_url_link'] = $this->_reg_url_link;
296
+		EE_Registry::$i18n_js_strings['initial_access'] = time();
297
+		EE_Registry::$i18n_js_strings['IPN_wait_time'] = EED_Thank_You_Page::IPN_wait_time;
298
+		EE_Registry::$i18n_js_strings['TXN_complete'] = EEM_Transaction::complete_status_code;
299
+		EE_Registry::$i18n_js_strings['TXN_incomplete'] = EEM_Transaction::incomplete_status_code;
300
+		EE_Registry::$i18n_js_strings['checking_for_new_payments'] = __(
301
+			'checking for new payments...',
302
+			'event_espresso'
303
+		);
304
+		EE_Registry::$i18n_js_strings['loading_payment_info'] = __(
305
+			'loading payment information...',
306
+			'event_espresso'
307
+		);
308
+		EE_Registry::$i18n_js_strings['server_error'] = __(
309
+			'An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again.',
310
+			'event_espresso'
311
+		);
312
+		EE_Registry::$i18n_js_strings['slow_IPN'] = apply_filters(
313
+			'EED_Thank_You_Page__load_js__slow_IPN',
314
+			sprintf(
315
+				__(
316
+					'%sThe Payment Notification appears to be taking longer than usual to arrive. Maybe check back later or just wait for your payment and registration confirmation results to be sent to you via email. We apologize for any inconvenience this may have caused.%s',
317
+					'event_espresso'
318
+				),
319
+				'<div id="espresso-thank-you-page-slow-IPN-dv" class="ee-attention jst-left">',
320
+				'</div>'
321
+			)
322
+		);
323
+	}
324
+
325
+
326
+
327
+	/**
328
+	 * load_js
329
+	 *
330
+	 * @return void
331
+	 */
332
+	public function load_js()
333
+	{
334
+		wp_register_script(
335
+			'thank_you_page',
336
+			THANK_YOU_ASSETS_URL . 'thank_you_page.js',
337
+			array('espresso_core', 'heartbeat'),
338
+			EVENT_ESPRESSO_VERSION,
339
+			true
340
+		);
341
+		wp_enqueue_script('thank_you_page');
342
+		wp_enqueue_style('espresso_default');
343
+	}
344
+
345
+
346
+
347
+	/**
348
+	 * init
349
+	 *
350
+	 * @return void
351
+	 * @throws \EE_Error
352
+	 */
353
+	public function init()
354
+	{
355
+		$this->_get_reg_url_link();
356
+		if ( ! $this->get_txn()) {
357
+			echo EEH_HTML::div(
358
+				EEH_HTML::h4(__('We\'re sorry...', 'event_espresso'), '', '') .
359
+				sprintf(
360
+					__(
361
+						'This is a system page for displaying transaction information after a purchase.%1$sYou are most likely seeing this notice because you have navigated to this page%1$sthrough some means other than completing a transaction.%1$sSorry for the disappointment, but you will most likely find nothing of interest here.%1$s%1$s',
362
+						'event_espresso'
363
+					),
364
+					'<br/>'
365
+				),
366
+				'',
367
+				'ee-attention'
368
+			);
369
+			return null;
370
+		}
371
+		// if we've made it to the Thank You page, then let's toggle any "Failed" transactions to "Incomplete"
372
+		if ($this->_current_txn->status_ID() === EEM_Transaction::failed_status_code) {
373
+			$this->_current_txn->set_status(EEM_Transaction::incomplete_status_code);
374
+			$this->_current_txn->save();
375
+		}
376
+		$this->_primary_registrant = $this->_current_txn->primary_registration() instanceof EE_Registration
377
+			? $this->_current_txn->primary_registration()
378
+			: null;
379
+		$this->_is_primary = $this->_primary_registrant->reg_url_link() === $this->_reg_url_link ? true : false;
380
+		$show_try_pay_again_link_default = apply_filters(
381
+			'AFEE__EED_Thank_You_Page__init__show_try_pay_again_link_default',
382
+			true
383
+		);
384
+		$this->_show_try_pay_again_link = $show_try_pay_again_link_default;
385
+		// txn status ?
386
+		if ($this->_current_txn->is_completed()) {
387
+			$this->_show_try_pay_again_link = $show_try_pay_again_link_default;
388
+		} else if (
389
+			$this->_current_txn->is_incomplete()
390
+			&& ($this->_primary_registrant->is_approved()
391
+				|| $this->_primary_registrant->is_pending_payment())
392
+		) {
393
+			$this->_show_try_pay_again_link = true;
394
+		} else if ($this->_primary_registrant->is_approved() || $this->_primary_registrant->is_pending_payment()) {
395
+			// its pending
396
+			$this->_show_try_pay_again_link = isset(
397
+												  EE_Registry::instance()->CFG->registration->show_pending_payment_options
398
+											  )
399
+											  && EE_Registry::instance()->CFG->registration->show_pending_payment_options
400
+				? true
401
+				: $show_try_pay_again_link_default;
402
+		}
403
+		$this->_payments_closed = ! $this->_current_txn->payment_method() instanceof EE_Payment_Method
404
+			? true
405
+			: false;
406
+		$this->_is_offline_payment_method = false;
407
+		if (
408
+			// if payment method is unknown
409
+			! $this->_current_txn->payment_method() instanceof EE_Payment_Method
410
+			|| (
411
+				// or is an offline payment method
412
+				$this->_current_txn->payment_method() instanceof EE_Payment_Method
413
+				&& $this->_current_txn->payment_method()->is_off_line()
414
+			)
415
+		) {
416
+			$this->_is_offline_payment_method = true;
417
+		}
418
+		// link to SPCO
419
+		$revisit_spco_url = add_query_arg(
420
+			array('ee' => '_register', 'revisit' => true, 'e_reg_url_link' => $this->_reg_url_link),
421
+			EE_Registry::instance()->CFG->core->reg_page_url()
422
+		);
423
+		// link to SPCO payment_options
424
+		$this->_SPCO_payment_options_url = $this->_primary_registrant instanceof EE_Registration
425
+			? $this->_primary_registrant->payment_overview_url()
426
+			: add_query_arg(
427
+				array('step' => 'payment_options'),
428
+				$revisit_spco_url
429
+			);
430
+		// link to SPCO attendee_information
431
+		$this->_SPCO_attendee_information_url = $this->_primary_registrant instanceof EE_Registration
432
+			? $this->_primary_registrant->edit_attendee_information_url()
433
+			: false;
434
+		do_action('AHEE__EED_Thank_You_Page__init_end', $this->_current_txn);
435
+		// set no cache headers and constants
436
+		EE_System::do_not_cache();
437
+	}
438
+
439
+
440
+
441
+	/**
442
+	 * display_thank_you_page_results
443
+	 *
444
+	 * @return string
445
+	 * @throws \EE_Error
446
+	 */
447
+	public function thank_you_page_results()
448
+	{
449
+		$this->init();
450
+		if ( ! $this->_current_txn instanceof EE_Transaction) {
451
+			return EE_Error::get_notices();
452
+		}
453
+		// link to receipt
454
+		$template_args['TXN_receipt_url'] = $this->_current_txn->receipt_url('html');
455
+		if ( ! empty($template_args['TXN_receipt_url'])) {
456
+			$template_args['order_conf_desc'] = __(
457
+				'%1$sCongratulations%2$sYour registration has been successfully processed.%3$sCheck your email for your registration confirmation or click the button below to view / download / print a full description of your purchases and registration information.',
458
+				'event_espresso'
459
+			);
460
+		} else {
461
+			$template_args['order_conf_desc'] = __(
462
+				'%1$sCongratulations%2$sYour registration has been successfully processed.%3$sCheck your email for your registration confirmation.',
463
+				'event_espresso'
464
+			);
465
+		}
466
+		$template_args['transaction'] = $this->_current_txn;
467
+		$template_args['revisit'] = EE_Registry::instance()->REQ->get('revisit', false);
468
+		add_action('AHEE__thank_you_page_overview_template__content', array($this, 'get_registration_details'));
469
+		if ($this->_is_primary && ! $this->_current_txn->is_free()) {
470
+			add_action('AHEE__thank_you_page_overview_template__content', array($this, 'get_ajax_content'));
471
+		}
472
+		return EEH_Template::locate_template(
473
+			THANK_YOU_TEMPLATES_PATH . 'thank-you-page-overview.template.php',
474
+			$template_args,
475
+			true,
476
+			true
477
+		);
478
+	}
479
+
480
+
481
+
482
+	/**
483
+	 * thank_you_page_IPN_monitor
484
+	 * this basically just pulls the TXN based on the reg_url_link sent from the server,
485
+	 * then checks that the TXN status is not failed, and that no other errors have been generated.
486
+	 * it also calculates the IPN wait time since the Thank You page was first loaded
487
+	 *
488
+	 * @param array $response
489
+	 * @param array $data
490
+	 * @return array
491
+	 * @throws \EE_Error
492
+	 */
493
+	public static function thank_you_page_IPN_monitor($response = array(), $data = array())
494
+	{
495
+		// does this heartbeat contain our data ?
496
+		if ( ! isset($data['espresso_thank_you_page'])) {
497
+			return $response;
498
+		}
499
+		// check for reg_url_link in the incoming heartbeat data
500
+		if ( ! isset($data['espresso_thank_you_page']['e_reg_url_link'])) {
501
+			$response['espresso_thank_you_page'] = array(
502
+				'errors' => ! empty($notices['errors'])
503
+					? $notices['errors']
504
+					: __(
505
+						'No transaction information could be retrieved because the registration URL link is missing or invalid.',
506
+						'event_espresso'
507
+					)
508
+			);
509
+			return $response;
510
+		}
511
+		// kk heartbeat has our data
512
+		$response['espresso_thank_you_page'] = array();
513
+		// set_definitions, instantiate the thank you page class, and get the ball rolling
514
+		EED_Thank_You_Page::set_definitions();
515
+		/** @var $espresso_thank_you_page EED_Thank_You_Page */
516
+		$espresso_thank_you_page = EED_Thank_You_Page::instance();
517
+		$espresso_thank_you_page->set_reg_url_link($data['espresso_thank_you_page']['e_reg_url_link']);
518
+		$espresso_thank_you_page->init();
519
+		//get TXN
520
+		$TXN = $espresso_thank_you_page->get_txn();
521
+		// no TXN? then get out
522
+		if ( ! $TXN instanceof EE_Transaction) {
523
+			$notices = EE_Error::get_notices();
524
+			$response['espresso_thank_you_page'] = array(
525
+				'errors' => ! empty($notices['errors'])
526
+					? $notices['errors']
527
+					: sprintf(
528
+						__(
529
+							'The information for your transaction could not be retrieved from the server or the transaction data received was invalid because of a technical reason. (%s)',
530
+							'event_espresso'
531
+						),
532
+						__LINE__
533
+					)
534
+			);
535
+			return $response;
536
+		}
537
+		// grab transient of TXN's status
538
+		$txn_status = isset($data['espresso_thank_you_page']['txn_status'])
539
+			? $data['espresso_thank_you_page']['txn_status']
540
+			: null;
541
+		// has the TXN status changed since we last checked (or empty because this is the first time running through this code)?
542
+		if ($txn_status !== $TXN->status_ID()) {
543
+			// switch between two possible basic outcomes
544
+			switch ($TXN->status_ID()) {
545
+				// TXN has been updated in some way
546
+				case EEM_Transaction::overpaid_status_code:
547
+				case EEM_Transaction::complete_status_code:
548
+				case EEM_Transaction::incomplete_status_code:
549
+					// send updated TXN results back to client,
550
+					$response['espresso_thank_you_page'] = array(
551
+						'transaction_details' => $espresso_thank_you_page->get_transaction_details(),
552
+						'txn_status'          => $TXN->status_ID()
553
+					);
554
+					break;
555
+				// or we have a bad TXN, or really slow IPN, so calculate the wait time and send that back...
556
+				case EEM_Transaction::failed_status_code:
557
+				default:
558
+					// keep on waiting...
559
+					return $espresso_thank_you_page->_update_server_wait_time($data['espresso_thank_you_page']);
560
+			}
561
+			// or is the TXN still failed (never been updated) ???
562
+		} else if ($TXN->failed()) {
563
+			// keep on waiting...
564
+			return $espresso_thank_you_page->_update_server_wait_time($data['espresso_thank_you_page']);
565
+		}
566
+		// TXN is happening so let's get the payments now
567
+		// if we've already gotten payments then the heartbeat data will contain the timestamp of the last time we checked
568
+		$since = isset($data['espresso_thank_you_page']['get_payments_since'])
569
+			? $data['espresso_thank_you_page']['get_payments_since']
570
+			: 0;
571
+		// then check for payments
572
+		$payments = $espresso_thank_you_page->get_txn_payments($since);
573
+		// has a payment been processed ?
574
+		if ( ! empty($payments) || $espresso_thank_you_page->_is_offline_payment_method) {
575
+			if ($since) {
576
+				$response['espresso_thank_you_page'] = array(
577
+					'new_payments'        => $espresso_thank_you_page->get_new_payments($payments),
578
+					'transaction_details' => $espresso_thank_you_page->get_transaction_details(),
579
+					'txn_status'          => $TXN->status_ID()
580
+				);
581
+			} else {
582
+				$response['espresso_thank_you_page']['payment_details'] = $espresso_thank_you_page->get_payment_details(
583
+					$payments
584
+				);
585
+			}
586
+			// reset time to check for payments
587
+			$response['espresso_thank_you_page']['get_payments_since'] = time();
588
+		} else {
589
+			$response['espresso_thank_you_page']['get_payments_since'] = $since;
590
+		}
591
+		return $response;
592
+	}
593
+
594
+
595
+
596
+	/**
597
+	 * _update_server_wait_time
598
+	 *
599
+	 * @param array $thank_you_page_data thank you page portion of the incoming JSON array from the WP heartbeat data
600
+	 * @return array
601
+	 * @throws \EE_Error
602
+	 */
603
+	private function _update_server_wait_time($thank_you_page_data = array())
604
+	{
605
+		$response['espresso_thank_you_page'] = array(
606
+			'still_waiting' => isset($thank_you_page_data['initial_access'])
607
+				? time() - $thank_you_page_data['initial_access']
608
+				: 0,
609
+			'txn_status'    => $this->_current_txn->status_ID()
610
+		);
611
+		return $response;
612
+	}
613
+
614
+
615
+
616
+	/**
617
+	 * get_registration_details
618
+	 *
619
+	 * @throws \EE_Error
620
+	 */
621
+	public function get_registration_details()
622
+	{
623
+		//prepare variables for displaying
624
+		$template_args = array();
625
+		$template_args['transaction'] = $this->_current_txn;
626
+		$template_args['reg_url_link'] = $this->_reg_url_link;
627
+		$template_args['is_primary'] = $this->_is_primary;
628
+		$template_args['SPCO_attendee_information_url'] = $this->_SPCO_attendee_information_url;
629
+		$template_args['resend_reg_confirmation_url'] = add_query_arg(
630
+			array('token' => $this->_reg_url_link, 'resend_reg_confirmation' => 'true'),
631
+			EE_Registry::instance()->CFG->core->thank_you_page_url()
632
+		);
633
+		// verify template arguments
634
+		EEH_Template_Validator::verify_instanceof($template_args['transaction'], '$transaction', 'EE_Transaction');
635
+		EEH_Template_Validator::verify_isnt_null(
636
+			$template_args['SPCO_attendee_information_url'],
637
+			'$SPCO_attendee_information_url'
638
+		);
639
+		echo EEH_Template::locate_template(
640
+			THANK_YOU_TEMPLATES_PATH . 'thank-you-page-registration-details.template.php',
641
+			$template_args,
642
+			true,
643
+			true
644
+		);
645
+	}
646
+
647
+
648
+
649
+	/**
650
+	 * resend_reg_confirmation_email
651
+	 *
652
+	 * @throws \EE_Error
653
+	 */
654
+	public static function resend_reg_confirmation_email()
655
+	{
656
+		EE_Registry::instance()->load_core('Request_Handler');
657
+		$reg_url_link = EE_Registry::instance()->REQ->get('token');
658
+		// was a REG_ID passed ?
659
+		if ($reg_url_link) {
660
+			$registration = EE_Registry::instance()->load_model('Registration')->get_one(
661
+				array(array('REG_url_link' => $reg_url_link))
662
+			);
663
+			if ($registration instanceof EE_Registration) {
664
+				// resend email
665
+				EED_Messages::process_resend(array('_REG_ID' => $registration->ID()));
666
+			} else {
667
+				EE_Error::add_error(
668
+					__(
669
+						'The Registration Confirmation email could not be sent because a valid Registration could not be retrieved from the database.',
670
+						'event_espresso'
671
+					),
672
+					__FILE__,
673
+					__FUNCTION__,
674
+					__LINE__
675
+				);
676
+			}
677
+		} else {
678
+			EE_Error::add_error(
679
+				__(
680
+					'The Registration Confirmation email could not be sent because a registration token is missing or invalid.',
681
+					'event_espresso'
682
+				),
683
+				__FILE__,
684
+				__FUNCTION__,
685
+				__LINE__
686
+			);
687
+		}
688
+		// request sent via AJAX ?
689
+		if (EE_FRONT_AJAX) {
690
+			echo wp_json_encode(EE_Error::get_notices(false));
691
+			die();
692
+			// or was JS disabled ?
693
+		} else {
694
+			// save errors so that they get picked up on the next request
695
+			EE_Error::get_notices(true, true);
696
+			wp_safe_redirect(
697
+				add_query_arg(
698
+					array('e_reg_url_link' => $reg_url_link),
699
+					EE_Registry::instance()->CFG->core->thank_you_page_url()
700
+				)
701
+			);
702
+		}
703
+	}
704
+
705
+
706
+
707
+	/**
708
+	 * get_ajax_content
709
+	 *
710
+	 * @return void
711
+	 * @throws \EE_Error
712
+	 */
713
+	public function get_ajax_content()
714
+	{
715
+		if ( ! $this->get_txn()) {
716
+			return;
717
+		}
718
+		// first determine which event(s) require pre-approval or not
719
+		$events = array();
720
+		$events_requiring_pre_approval = array();
721
+		foreach ($this->_current_txn->registrations() as $registration) {
722
+			if ($registration instanceof EE_Registration) {
723
+				$event = $registration->event();
724
+				if ($event instanceof EE_Event) {
725
+					if ($registration->is_not_approved() && $registration->event() instanceof EE_Event) {
726
+						$events_requiring_pre_approval[$event->ID()] = $event;
727
+					} else {
728
+						$events[$event->ID()] = $event;
729
+					}
730
+				}
731
+			}
732
+		}
733
+		$this->display_details_for_events_requiring_pre_approval($events_requiring_pre_approval);
734
+		$this->display_details_for_events($events);
735
+	}
736
+
737
+
738
+
739
+	/**
740
+	 * display_details_for_events
741
+	 *
742
+	 * @param EE_Event[] $events
743
+	 * @return void
744
+	 */
745
+	public function display_details_for_events($events = array())
746
+	{
747
+		if ( ! empty($events)) {
748
+			?>
749 749
             <div id="espresso-thank-you-page-ajax-content-dv">
750 750
                 <div id="espresso-thank-you-page-ajax-transaction-dv"></div>
751 751
                 <div id="espresso-thank-you-page-ajax-payment-dv"></div>
752 752
                 <div id="espresso-thank-you-page-ajax-loading-dv">
753 753
                     <div id="ee-ajax-loading-dv" class="float-left lt-blue-text">
754 754
                         <span class="dashicons dashicons-upload"></span><span id="ee-ajax-loading-msg-spn"><?php _e(
755
-                                'loading transaction and payment information...',
756
-                                'event_espresso'
757
-                            ); ?></span>
755
+								'loading transaction and payment information...',
756
+								'event_espresso'
757
+							); ?></span>
758 758
                     </div>
759 759
                     <?php if ( ! $this->_is_offline_payment_method && ! $this->_payments_closed) : ?>
760 760
                         <p id="ee-ajax-loading-pg" class="highlight-bg small-text clear">
761 761
                             <?php echo apply_filters(
762
-                                'EED_Thank_You_Page__get_ajax_content__waiting_for_IPN_msg',
763
-                                __(
764
-                                    'Some payment gateways can take 15 minutes or more to return their payment notification, so please be patient if you require payment confirmation as soon as possible. Please note that as soon as everything is finalized, we will send your full payment and registration confirmation results to you via email.',
765
-                                    'event_espresso'
766
-                                )
767
-                            ); ?>
762
+								'EED_Thank_You_Page__get_ajax_content__waiting_for_IPN_msg',
763
+								__(
764
+									'Some payment gateways can take 15 minutes or more to return their payment notification, so please be patient if you require payment confirmation as soon as possible. Please note that as soon as everything is finalized, we will send your full payment and registration confirmation results to you via email.',
765
+									'event_espresso'
766
+								)
767
+							); ?>
768 768
                             <br/>
769 769
                             <span class="jst-rght ee-block small-text lt-grey-text">
770 770
 								<?php _e('current wait time ', 'event_espresso'); ?>
@@ -775,120 +775,120 @@  discard block
 block discarded – undo
775 775
                 <div class="clear"></div>
776 776
             </div>
777 777
             <?php
778
-        }
779
-    }
778
+		}
779
+	}
780 780
 
781 781
 
782 782
 
783
-    /**
784
-     * display_details_for_events_requiring_pre_approval
785
-     *
786
-     * @param EE_Event[] $events
787
-     * @return void
788
-     */
789
-    public function display_details_for_events_requiring_pre_approval($events = array())
790
-    {
791
-        if ( ! empty($events)) {
792
-            ?>
783
+	/**
784
+	 * display_details_for_events_requiring_pre_approval
785
+	 *
786
+	 * @param EE_Event[] $events
787
+	 * @return void
788
+	 */
789
+	public function display_details_for_events_requiring_pre_approval($events = array())
790
+	{
791
+		if ( ! empty($events)) {
792
+			?>
793 793
             <div id="espresso-thank-you-page-not-approved-message-dv">
794 794
                 <h4 class="orange-text"><?php _e('Important Notice:', 'event_espresso'); ?></h4>
795 795
                 <p id="events-requiring-pre-approval-pg" class="small-text">
796 796
                     <?php echo apply_filters(
797
-                        'AHEE__EED_Thank_You_Page__get_ajax_content__not_approved_message',
798
-                        __(
799
-                            'The following Event(s) you have registered for do not require payment at this time and will not be billed for during this transaction. Billing will only occur after all attendees have been approved by the event organizer. You will be notified when your registration has been processed. If this is a free event, then no billing will occur.',
800
-                            'event_espresso'
801
-                        )
802
-                    ); ?>
797
+						'AHEE__EED_Thank_You_Page__get_ajax_content__not_approved_message',
798
+						__(
799
+							'The following Event(s) you have registered for do not require payment at this time and will not be billed for during this transaction. Billing will only occur after all attendees have been approved by the event organizer. You will be notified when your registration has been processed. If this is a free event, then no billing will occur.',
800
+							'event_espresso'
801
+						)
802
+					); ?>
803 803
                 </p>
804 804
                 <ul class="events-requiring-pre-approval-ul">
805 805
                     <?php foreach ($events as $event) {
806
-                        if ($event instanceof EE_Event) {
807
-                            echo '<li><span class="dashicons dashicons-marker ee-icon-size-16 orange-text"></span>',
808
-                            $event->name(),
809
-                            '</li>';
810
-                        }
811
-                    } ?>
806
+						if ($event instanceof EE_Event) {
807
+							echo '<li><span class="dashicons dashicons-marker ee-icon-size-16 orange-text"></span>',
808
+							$event->name(),
809
+							'</li>';
810
+						}
811
+					} ?>
812 812
                 </ul>
813 813
                 <div class="clear"></div>
814 814
             </div>
815 815
             <?php
816
-        }
817
-    }
818
-
819
-
820
-
821
-    /**
822
-     * get_transaction_details
823
-     *
824
-     * @return string
825
-     * @throws \EE_Error
826
-     */
827
-    public function get_transaction_details()
828
-    {
829
-        //prepare variables for displaying
830
-        $template_args = array();
831
-        $template_args['transaction'] = $this->_current_txn;
832
-        $template_args['reg_url_link'] = $this->_reg_url_link;
833
-        $template_args['primary_registrant_name'] = $this->_primary_registrant->attendee()->full_name(true);
834
-        // link to SPCO payment_options
835
-        $template_args['show_try_pay_again_link'] = $this->_show_try_pay_again_link;
836
-        $template_args['SPCO_payment_options_url'] = $this->_SPCO_payment_options_url;
837
-        // verify template arguments
838
-        EEH_Template_Validator::verify_instanceof($template_args['transaction'], '$transaction', 'EE_Transaction');
839
-        EEH_Template_Validator::verify_isnt_null(
840
-            $template_args['show_try_pay_again_link'],
841
-            '$show_try_pay_again_link'
842
-        );
843
-        EEH_Template_Validator::verify_isnt_null(
844
-            $template_args['SPCO_payment_options_url'],
845
-            '$SPCO_payment_options_url'
846
-        );
847
-        return EEH_Template::locate_template(
848
-            THANK_YOU_TEMPLATES_PATH . 'thank-you-page-transaction-details.template.php',
849
-            $template_args,
850
-            true,
851
-            true
852
-        );
853
-    }
854
-
855
-
856
-
857
-    /**
858
-     * get_payment_row_html
859
-     *
860
-     * @param EE_Payment $payment
861
-     * @return string
862
-     * @throws \EE_Error
863
-     */
864
-    public function get_payment_row_html($payment = null)
865
-    {
866
-        $html = '';
867
-        if ($payment instanceof EE_Payment) {
868
-            if (
869
-                $payment->payment_method() instanceof EE_Payment_Method
870
-                && $payment->status() === EEM_Payment::status_id_failed
871
-                && $payment->payment_method()->is_off_site()
872
-            ) {
873
-                // considering the registrant has made it to the Thank You page,
874
-                // any failed payments may actually be pending and the IPN is just slow
875
-                // so let's
876
-                $payment->set_status(EEM_Payment::status_id_pending);
877
-            }
878
-            $payment_declined_msg = $payment->STS_ID() === EEM_Payment::status_id_declined
879
-                ? '<br /><span class="small-text">' . $payment->gateway_response() . '</span>'
880
-                : '';
881
-            $html .= '
816
+		}
817
+	}
818
+
819
+
820
+
821
+	/**
822
+	 * get_transaction_details
823
+	 *
824
+	 * @return string
825
+	 * @throws \EE_Error
826
+	 */
827
+	public function get_transaction_details()
828
+	{
829
+		//prepare variables for displaying
830
+		$template_args = array();
831
+		$template_args['transaction'] = $this->_current_txn;
832
+		$template_args['reg_url_link'] = $this->_reg_url_link;
833
+		$template_args['primary_registrant_name'] = $this->_primary_registrant->attendee()->full_name(true);
834
+		// link to SPCO payment_options
835
+		$template_args['show_try_pay_again_link'] = $this->_show_try_pay_again_link;
836
+		$template_args['SPCO_payment_options_url'] = $this->_SPCO_payment_options_url;
837
+		// verify template arguments
838
+		EEH_Template_Validator::verify_instanceof($template_args['transaction'], '$transaction', 'EE_Transaction');
839
+		EEH_Template_Validator::verify_isnt_null(
840
+			$template_args['show_try_pay_again_link'],
841
+			'$show_try_pay_again_link'
842
+		);
843
+		EEH_Template_Validator::verify_isnt_null(
844
+			$template_args['SPCO_payment_options_url'],
845
+			'$SPCO_payment_options_url'
846
+		);
847
+		return EEH_Template::locate_template(
848
+			THANK_YOU_TEMPLATES_PATH . 'thank-you-page-transaction-details.template.php',
849
+			$template_args,
850
+			true,
851
+			true
852
+		);
853
+	}
854
+
855
+
856
+
857
+	/**
858
+	 * get_payment_row_html
859
+	 *
860
+	 * @param EE_Payment $payment
861
+	 * @return string
862
+	 * @throws \EE_Error
863
+	 */
864
+	public function get_payment_row_html($payment = null)
865
+	{
866
+		$html = '';
867
+		if ($payment instanceof EE_Payment) {
868
+			if (
869
+				$payment->payment_method() instanceof EE_Payment_Method
870
+				&& $payment->status() === EEM_Payment::status_id_failed
871
+				&& $payment->payment_method()->is_off_site()
872
+			) {
873
+				// considering the registrant has made it to the Thank You page,
874
+				// any failed payments may actually be pending and the IPN is just slow
875
+				// so let's
876
+				$payment->set_status(EEM_Payment::status_id_pending);
877
+			}
878
+			$payment_declined_msg = $payment->STS_ID() === EEM_Payment::status_id_declined
879
+				? '<br /><span class="small-text">' . $payment->gateway_response() . '</span>'
880
+				: '';
881
+			$html .= '
882 882
 				<tr>
883 883
 					<td>
884 884
 						' . $payment->timestamp() . '
885 885
 					</td>
886 886
 					<td>
887 887
 						' . (
888
-                $payment->payment_method() instanceof EE_Payment_Method
889
-                    ? $payment->payment_method()->name()
890
-                    : __('Unknown', 'event_espresso')
891
-                ) . '
888
+				$payment->payment_method() instanceof EE_Payment_Method
889
+					? $payment->payment_method()->name()
890
+					: __('Unknown', 'event_espresso')
891
+				) . '
892 892
 					</td>
893 893
 					<td class="jst-rght">
894 894
 						' . EEH_Template::format_currency($payment->amount()) . '
@@ -897,87 +897,87 @@  discard block
 block discarded – undo
897 897
 						' . $payment->pretty_status(true) . $payment_declined_msg . '
898 898
 					</td>
899 899
 				</tr>';
900
-            do_action('AHEE__thank_you_page_payment_details_template__after_each_payment', $payment);
901
-        }
902
-        return $html;
903
-    }
904
-
905
-
906
-
907
-    /**
908
-     * get_payment_details
909
-     *
910
-     * @param array $payments
911
-     * @return string
912
-     * @throws \EE_Error
913
-     */
914
-    public function get_payment_details($payments = array())
915
-    {
916
-        //prepare variables for displaying
917
-        $template_args = array();
918
-        $template_args['transaction'] = $this->_current_txn;
919
-        $template_args['reg_url_link'] = $this->_reg_url_link;
920
-        $template_args['payments'] = array();
921
-        foreach ($payments as $payment) {
922
-            $template_args['payments'][] = $this->get_payment_row_html($payment);
923
-        }
924
-        //create a hacky payment object, but dont save it
925
-        $payment = EE_Payment::new_instance(
926
-            array(
927
-                'TXN_ID'        => $this->_current_txn->ID(),
928
-                'STS_ID'        => EEM_Payment::status_id_pending,
929
-                'PAY_timestamp' => time(),
930
-                'PAY_amount'    => $this->_current_txn->total(),
931
-                'PMD_ID'        => $this->_current_txn->payment_method_ID()
932
-            )
933
-        );
934
-        $payment_method = $this->_current_txn->payment_method();
935
-        if ($payment_method instanceof EE_Payment_Method && $payment_method->type_obj() instanceof EE_PMT_Base) {
936
-            $template_args['gateway_content'] = $payment_method->type_obj()->payment_overview_content($payment);
937
-        } else {
938
-            $template_args['gateway_content'] = '';
939
-        }
940
-        // link to SPCO payment_options
941
-        $template_args['show_try_pay_again_link'] = $this->_show_try_pay_again_link;
942
-        $template_args['SPCO_payment_options_url'] = $this->_SPCO_payment_options_url;
943
-        // verify template arguments
944
-        EEH_Template_Validator::verify_instanceof($template_args['transaction'], '$transaction', 'EE_Transaction');
945
-        EEH_Template_Validator::verify_isnt_null($template_args['payments'], '$payments');
946
-        EEH_Template_Validator::verify_isnt_null(
947
-            $template_args['show_try_pay_again_link'],
948
-            '$show_try_pay_again_link'
949
-        );
950
-        EEH_Template_Validator::verify_isnt_null($template_args['gateway_content'], '$gateway_content');
951
-        EEH_Template_Validator::verify_isnt_null(
952
-            $template_args['SPCO_payment_options_url'],
953
-            '$SPCO_payment_options_url'
954
-        );
955
-        return EEH_Template::locate_template(
956
-            THANK_YOU_TEMPLATES_PATH . 'thank-you-page-payment-details.template.php',
957
-            $template_args,
958
-            true,
959
-            true
960
-        );
961
-    }
962
-
963
-
964
-
965
-    /**
966
-     * get_payment_details
967
-     *
968
-     * @param array $payments
969
-     * @return string
970
-     * @throws \EE_Error
971
-     */
972
-    public function get_new_payments($payments = array())
973
-    {
974
-        $payments_html = '';
975
-        //prepare variables for displaying
976
-        foreach ($payments as $payment) {
977
-            $payments_html .= $this->get_payment_row_html($payment);
978
-        }
979
-        return $payments_html;
980
-    }
900
+			do_action('AHEE__thank_you_page_payment_details_template__after_each_payment', $payment);
901
+		}
902
+		return $html;
903
+	}
904
+
905
+
906
+
907
+	/**
908
+	 * get_payment_details
909
+	 *
910
+	 * @param array $payments
911
+	 * @return string
912
+	 * @throws \EE_Error
913
+	 */
914
+	public function get_payment_details($payments = array())
915
+	{
916
+		//prepare variables for displaying
917
+		$template_args = array();
918
+		$template_args['transaction'] = $this->_current_txn;
919
+		$template_args['reg_url_link'] = $this->_reg_url_link;
920
+		$template_args['payments'] = array();
921
+		foreach ($payments as $payment) {
922
+			$template_args['payments'][] = $this->get_payment_row_html($payment);
923
+		}
924
+		//create a hacky payment object, but dont save it
925
+		$payment = EE_Payment::new_instance(
926
+			array(
927
+				'TXN_ID'        => $this->_current_txn->ID(),
928
+				'STS_ID'        => EEM_Payment::status_id_pending,
929
+				'PAY_timestamp' => time(),
930
+				'PAY_amount'    => $this->_current_txn->total(),
931
+				'PMD_ID'        => $this->_current_txn->payment_method_ID()
932
+			)
933
+		);
934
+		$payment_method = $this->_current_txn->payment_method();
935
+		if ($payment_method instanceof EE_Payment_Method && $payment_method->type_obj() instanceof EE_PMT_Base) {
936
+			$template_args['gateway_content'] = $payment_method->type_obj()->payment_overview_content($payment);
937
+		} else {
938
+			$template_args['gateway_content'] = '';
939
+		}
940
+		// link to SPCO payment_options
941
+		$template_args['show_try_pay_again_link'] = $this->_show_try_pay_again_link;
942
+		$template_args['SPCO_payment_options_url'] = $this->_SPCO_payment_options_url;
943
+		// verify template arguments
944
+		EEH_Template_Validator::verify_instanceof($template_args['transaction'], '$transaction', 'EE_Transaction');
945
+		EEH_Template_Validator::verify_isnt_null($template_args['payments'], '$payments');
946
+		EEH_Template_Validator::verify_isnt_null(
947
+			$template_args['show_try_pay_again_link'],
948
+			'$show_try_pay_again_link'
949
+		);
950
+		EEH_Template_Validator::verify_isnt_null($template_args['gateway_content'], '$gateway_content');
951
+		EEH_Template_Validator::verify_isnt_null(
952
+			$template_args['SPCO_payment_options_url'],
953
+			'$SPCO_payment_options_url'
954
+		);
955
+		return EEH_Template::locate_template(
956
+			THANK_YOU_TEMPLATES_PATH . 'thank-you-page-payment-details.template.php',
957
+			$template_args,
958
+			true,
959
+			true
960
+		);
961
+	}
962
+
963
+
964
+
965
+	/**
966
+	 * get_payment_details
967
+	 *
968
+	 * @param array $payments
969
+	 * @return string
970
+	 * @throws \EE_Error
971
+	 */
972
+	public function get_new_payments($payments = array())
973
+	{
974
+		$payments_html = '';
975
+		//prepare variables for displaying
976
+		foreach ($payments as $payment) {
977
+			$payments_html .= $this->get_payment_row_html($payment);
978
+		}
979
+		return $payments_html;
980
+	}
981 981
 
982 982
 
983 983
 }
Please login to merge, or discard this patch.
caffeinated/modules/event_single_caff/EED_Event_Single_Caff.module.php 2 patches
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -118,37 +118,37 @@
 block discarded – undo
118 118
 	 * @return EE_Template_Config
119 119
 	 */
120 120
 	public static function update_template_settings( $CFG, $REQ ) {
121
-        $display_order_event = $CFG->EED_Event_Single->display_order_event !== null
122
-            ? $CFG->EED_Event_Single->display_order_event
123
-            : EED_Event_Single::EVENT_DETAILS_PRIORITY;
121
+		$display_order_event = $CFG->EED_Event_Single->display_order_event !== null
122
+			? $CFG->EED_Event_Single->display_order_event
123
+			: EED_Event_Single::EVENT_DETAILS_PRIORITY;
124 124
 		$display_order_datetimes = $CFG->EED_Event_Single->display_order_datetimes !== null
125
-            ? $CFG->EED_Event_Single->display_order_datetimes
126
-            : EED_Event_Single::EVENT_DATETIMES_PRIORITY;
127
-        $display_order_tickets = $CFG->EED_Event_Single->display_order_tickets !== null
128
-            ? $CFG->EED_Event_Single->display_order_tickets
129
-            : EED_Event_Single::EVENT_TICKETS_PRIORITY;
125
+			? $CFG->EED_Event_Single->display_order_datetimes
126
+			: EED_Event_Single::EVENT_DATETIMES_PRIORITY;
127
+		$display_order_tickets = $CFG->EED_Event_Single->display_order_tickets !== null
128
+			? $CFG->EED_Event_Single->display_order_tickets
129
+			: EED_Event_Single::EVENT_TICKETS_PRIORITY;
130 130
 		$display_order_venue = $CFG->EED_Event_Single->display_order_venue !== null
131
-            ? $CFG->EED_Event_Single->display_order_venue
132
-            : EED_Event_Single::EVENT_VENUES_PRIORITY;
131
+			? $CFG->EED_Event_Single->display_order_venue
132
+			: EED_Event_Single::EVENT_VENUES_PRIORITY;
133 133
 		$CFG->EED_Event_Single = new EE_Event_Single_Config();
134 134
 		$CFG->EED_Event_Single->display_status_banner_single = ! empty( $REQ['display_status_banner_single'] )
135
-            && $REQ['display_status_banner_single'];
135
+			&& $REQ['display_status_banner_single'];
136 136
 		$CFG->EED_Event_Single->display_venue = ! empty( $REQ['display_venue'] ) && $REQ['display_venue'];
137 137
 		$CFG->EED_Event_Single->use_sortable_display_order = ! empty( $REQ[ 'EED_Events_Single_use_sortable_display_order' ] )
138
-            ? absint( $REQ[ 'EED_Events_Single_use_sortable_display_order' ] )
139
-            : 0;
138
+			? absint( $REQ[ 'EED_Events_Single_use_sortable_display_order' ] )
139
+			: 0;
140 140
 		$CFG->EED_Event_Single->display_order_event = $CFG->EED_Event_Single->use_sortable_display_order
141
-            ? $display_order_event
142
-            : EED_Event_Single::EVENT_DETAILS_PRIORITY;
141
+			? $display_order_event
142
+			: EED_Event_Single::EVENT_DETAILS_PRIORITY;
143 143
 		$CFG->EED_Event_Single->display_order_datetimes = $CFG->EED_Event_Single->use_sortable_display_order
144
-            ? $display_order_datetimes
145
-            : EED_Event_Single::EVENT_DATETIMES_PRIORITY;
144
+			? $display_order_datetimes
145
+			: EED_Event_Single::EVENT_DATETIMES_PRIORITY;
146 146
 		$CFG->EED_Event_Single->display_order_tickets = $CFG->EED_Event_Single->use_sortable_display_order
147
-            ? $display_order_tickets
148
-            : EED_Event_Single::EVENT_TICKETS_PRIORITY;
147
+			? $display_order_tickets
148
+			: EED_Event_Single::EVENT_TICKETS_PRIORITY;
149 149
 		$CFG->EED_Event_Single->display_order_venue = $CFG->EED_Event_Single->use_sortable_display_order
150
-            ? $display_order_venue
151
-            : EED_Event_Single::EVENT_VENUES_PRIORITY;
150
+			? $display_order_venue
151
+			: EED_Event_Single::EVENT_VENUES_PRIORITY;
152 152
 		do_action( 'AHEE__EED_Event_Single__update_template_settings__after_update', $CFG, $REQ );
153 153
 		return $CFG;
154 154
 	}
Please login to merge, or discard this patch.
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	 * @return EED_Event_Single_Caff
30 30
 	 */
31 31
 	public static function instance() {
32
-		return parent::get_instance( __CLASS__ );
32
+		return parent::get_instance(__CLASS__);
33 33
 	}
34 34
 
35 35
 
@@ -50,34 +50,34 @@  discard block
 block discarded – undo
50 50
 	 *  @return 	void
51 51
 	 */
52 52
 	public static function set_hooks_admin() {
53
-		define( 'EVENT_SINGLE_CAFF_TEMPLATES_PATH', plugin_dir_path( __FILE__ ) . 'templates' . DS );
54
-		define( 'EVENT_SINGLE_CAFF_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets' . DS );
53
+		define('EVENT_SINGLE_CAFF_TEMPLATES_PATH', plugin_dir_path(__FILE__).'templates'.DS);
54
+		define('EVENT_SINGLE_CAFF_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS);
55 55
 		add_action(
56 56
 			'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_events__template_settings',
57
-			array( 'EED_Event_Single_Caff', 'load_scripts_styles' ),
57
+			array('EED_Event_Single_Caff', 'load_scripts_styles'),
58 58
 			10
59 59
 		);
60
-		add_action( 'AHEE__template_settings__template__before_settings_form', array( 'EED_Event_Single_Caff', 'template_settings_form' ), 10 );
61
-		add_filter( 'FHEE__General_Settings_Admin_Page__update_template_settings__data', array( 'EED_Event_Single_Caff', 'update_template_settings' ), 10, 2 );
60
+		add_action('AHEE__template_settings__template__before_settings_form', array('EED_Event_Single_Caff', 'template_settings_form'), 10);
61
+		add_filter('FHEE__General_Settings_Admin_Page__update_template_settings__data', array('EED_Event_Single_Caff', 'update_template_settings'), 10, 2);
62 62
 		// AJAX
63
-		add_action( 'wp_ajax_espresso_update_event_single_order', array( 'EED_Event_Single_Caff', 'update_event_single_order' ) );
64
-		add_action( 'wp_ajax_nopriv_espresso_update_event_single_order', array( 'EED_Event_Single_Caff', 'update_event_single_order' ) );
63
+		add_action('wp_ajax_espresso_update_event_single_order', array('EED_Event_Single_Caff', 'update_event_single_order'));
64
+		add_action('wp_ajax_nopriv_espresso_update_event_single_order', array('EED_Event_Single_Caff', 'update_event_single_order'));
65 65
 
66 66
 	}
67 67
 
68 68
 
69 69
 
70 70
 	public static function load_scripts_styles() {
71
-		add_action( 'admin_enqueue_scripts', array( 'EED_Event_Single_Caff', 'enqueue_scripts_styles' ), 10 );
71
+		add_action('admin_enqueue_scripts', array('EED_Event_Single_Caff', 'enqueue_scripts_styles'), 10);
72 72
 	}
73 73
 
74 74
 
75 75
 
76 76
 	public static function enqueue_scripts_styles() {
77
-		wp_register_style( 'eed-event-single-sortable', EVENT_SINGLE_CAFF_ASSETS_URL . 'eed_event_single_sortable.css', array(), EVENT_ESPRESSO_VERSION );
78
-		wp_enqueue_style( 'eed-event-single-sortable' );
79
-		wp_register_script( 'eed-event-single-sortable', EVENT_SINGLE_CAFF_ASSETS_URL . 'eed_event_single_sortable.js', array( 'jquery-ui-sortable' ), EVENT_ESPRESSO_VERSION, true );
80
-		wp_enqueue_script( 'eed-event-single-sortable' );
77
+		wp_register_style('eed-event-single-sortable', EVENT_SINGLE_CAFF_ASSETS_URL.'eed_event_single_sortable.css', array(), EVENT_ESPRESSO_VERSION);
78
+		wp_enqueue_style('eed-event-single-sortable');
79
+		wp_register_script('eed-event-single-sortable', EVENT_SINGLE_CAFF_ASSETS_URL.'eed_event_single_sortable.js', array('jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, true);
80
+		wp_enqueue_script('eed-event-single-sortable');
81 81
 	}
82 82
 
83 83
 
@@ -91,21 +91,21 @@  discard block
 block discarded – undo
91 91
 	 */
92 92
 	public static function template_settings_form() {
93 93
 		$config = EE_Registry::instance()->CFG->template_settings;
94
-		$config = isset( $config->EED_Event_Single ) && $config->EED_Event_Single instanceof EE_Event_Single_Config ? $config->EED_Event_Single : new EE_Event_Single_Config();
95
-		$config->use_sortable_display_order = isset( $config->use_sortable_display_order ) ? $config->use_sortable_display_order : false;
96
-		$config = apply_filters( 'FHEE__EED_Event_Single__template_settings_form__event_list_config', $config );
94
+		$config = isset($config->EED_Event_Single) && $config->EED_Event_Single instanceof EE_Event_Single_Config ? $config->EED_Event_Single : new EE_Event_Single_Config();
95
+		$config->use_sortable_display_order = isset($config->use_sortable_display_order) ? $config->use_sortable_display_order : false;
96
+		$config = apply_filters('FHEE__EED_Event_Single__template_settings_form__event_list_config', $config);
97 97
 
98 98
 		$event_single_order_array = array();
99
-		$event_single_order_array[ $config->display_order_tickets ] = 'tickets';
100
-		$event_single_order_array[ $config->display_order_datetimes ] = 'datetimes';
101
-		$event_single_order_array[ $config->display_order_event ] = 'event';
102
-		$event_single_order_array[ $config->display_order_venue ] = 'venue';
99
+		$event_single_order_array[$config->display_order_tickets] = 'tickets';
100
+		$event_single_order_array[$config->display_order_datetimes] = 'datetimes';
101
+		$event_single_order_array[$config->display_order_event] = 'event';
102
+		$event_single_order_array[$config->display_order_venue] = 'venue';
103 103
 		// get template parts
104
-		$template_parts = EED_Event_Single::instance()->initialize_template_parts( $config );
104
+		$template_parts = EED_Event_Single::instance()->initialize_template_parts($config);
105 105
 		// convert to array so that we can add more properties
106
-		$config = get_object_vars( $config );
107
-		$config[ 'event_single_display_order' ] = $template_parts->generate_sortable_list_of_template_parts( 'event-single-sortable-js', '', 'single-sortable-li single-sortable-js' );
108
-		EEH_Template::display_template( EVENT_SINGLE_CAFF_TEMPLATES_PATH . 'admin-event-single-settings.template.php', $config );
106
+		$config = get_object_vars($config);
107
+		$config['event_single_display_order'] = $template_parts->generate_sortable_list_of_template_parts('event-single-sortable-js', '', 'single-sortable-li single-sortable-js');
108
+		EEH_Template::display_template(EVENT_SINGLE_CAFF_TEMPLATES_PATH.'admin-event-single-settings.template.php', $config);
109 109
 	}
110 110
 
111 111
 
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 	 * @param array $REQ
118 118
 	 * @return EE_Template_Config
119 119
 	 */
120
-	public static function update_template_settings( $CFG, $REQ ) {
120
+	public static function update_template_settings($CFG, $REQ) {
121 121
         $display_order_event = $CFG->EED_Event_Single->display_order_event !== null
122 122
             ? $CFG->EED_Event_Single->display_order_event
123 123
             : EED_Event_Single::EVENT_DETAILS_PRIORITY;
@@ -131,11 +131,11 @@  discard block
 block discarded – undo
131 131
             ? $CFG->EED_Event_Single->display_order_venue
132 132
             : EED_Event_Single::EVENT_VENUES_PRIORITY;
133 133
 		$CFG->EED_Event_Single = new EE_Event_Single_Config();
134
-		$CFG->EED_Event_Single->display_status_banner_single = ! empty( $REQ['display_status_banner_single'] )
134
+		$CFG->EED_Event_Single->display_status_banner_single = ! empty($REQ['display_status_banner_single'])
135 135
             && $REQ['display_status_banner_single'];
136
-		$CFG->EED_Event_Single->display_venue = ! empty( $REQ['display_venue'] ) && $REQ['display_venue'];
137
-		$CFG->EED_Event_Single->use_sortable_display_order = ! empty( $REQ[ 'EED_Events_Single_use_sortable_display_order' ] )
138
-            ? absint( $REQ[ 'EED_Events_Single_use_sortable_display_order' ] )
136
+		$CFG->EED_Event_Single->display_venue = ! empty($REQ['display_venue']) && $REQ['display_venue'];
137
+		$CFG->EED_Event_Single->use_sortable_display_order = ! empty($REQ['EED_Events_Single_use_sortable_display_order'])
138
+            ? absint($REQ['EED_Events_Single_use_sortable_display_order'])
139 139
             : 0;
140 140
 		$CFG->EED_Event_Single->display_order_event = $CFG->EED_Event_Single->use_sortable_display_order
141 141
             ? $display_order_event
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 		$CFG->EED_Event_Single->display_order_venue = $CFG->EED_Event_Single->use_sortable_display_order
150 150
             ? $display_order_venue
151 151
             : EED_Event_Single::EVENT_VENUES_PRIORITY;
152
-		do_action( 'AHEE__EED_Event_Single__update_template_settings__after_update', $CFG, $REQ );
152
+		do_action('AHEE__EED_Event_Single__update_template_settings__after_update', $CFG, $REQ);
153 153
 		return $CFG;
154 154
 	}
155 155
 
@@ -163,23 +163,23 @@  discard block
 block discarded – undo
163 163
 	 */
164 164
 	public static function update_event_single_order() {
165 165
 		$config_saved = false;
166
-		$template_parts = sanitize_text_field( $_POST[ 'elements' ] );
167
-		if ( ! empty( $template_parts ) ) {
168
-			$template_parts = explode( ',', trim( $template_parts, ',' ) );
169
-			foreach ( $template_parts as $key => $template_part ) {
166
+		$template_parts = sanitize_text_field($_POST['elements']);
167
+		if ( ! empty($template_parts)) {
168
+			$template_parts = explode(',', trim($template_parts, ','));
169
+			foreach ($template_parts as $key => $template_part) {
170 170
 				$template_part = "display_order_$template_part";
171
-				$priority = ( $key * 10 ) + EED_Event_Single::EVENT_DETAILS_PRIORITY;
171
+				$priority = ($key * 10) + EED_Event_Single::EVENT_DETAILS_PRIORITY;
172 172
 				EE_Registry::instance()->CFG->template_settings->EED_Event_Single->{$template_part} = $priority;
173
-				do_action( "AHEE__EED_Event_Single__update_event_single_order__$template_part", $priority );
173
+				do_action("AHEE__EED_Event_Single__update_event_single_order__$template_part", $priority);
174 174
 			}
175
-			$config_saved = EE_Registry::instance()->CFG->update_espresso_config( false, false );
175
+			$config_saved = EE_Registry::instance()->CFG->update_espresso_config(false, false);
176 176
 		}
177
-		if ( $config_saved ) {
178
-			EE_Error::add_success( __( 'Display Order has been successfully updated.', 'event_espresso' ) );
177
+		if ($config_saved) {
178
+			EE_Error::add_success(__('Display Order has been successfully updated.', 'event_espresso'));
179 179
 		} else {
180
-			EE_Error::add_error( __( 'Display Order was not updated.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
180
+			EE_Error::add_error(__('Display Order was not updated.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
181 181
 		}
182
-		echo wp_json_encode( EE_Error::get_notices( false ));
182
+		echo wp_json_encode(EE_Error::get_notices(false));
183 183
 		exit();
184 184
 	}
185 185
 
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 	 * @param WP $WP
193 193
 	 * @return    void
194 194
 	 */
195
-	public function run( $WP ) {
195
+	public function run($WP) {
196 196
 	}
197 197
 
198 198
 
Please login to merge, or discard this patch.
caffeinated/modules/events_archive_caff/EED_Events_Archive_Caff.module.php 2 patches
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -86,52 +86,52 @@  discard block
 block discarded – undo
86 86
 		$gen_set_admin = EE_Registry::instance()->LIB->EE_Admin_Page_Loader->get_admin_page_object( 'general_settings' );
87 87
 		if ( $gen_set_admin instanceof General_Settings_Admin_Page ) {
88 88
 			remove_action(
89
-			    'AHEE__template_settings__template__before_settings_form',
90
-                array( $gen_set_admin, 'template_settings_caff_features' ),
91
-                100
92
-            );
89
+				'AHEE__template_settings__template__before_settings_form',
90
+				array( $gen_set_admin, 'template_settings_caff_features' ),
91
+				100
92
+			);
93 93
 		}
94 94
 		// first just grab the template settings
95 95
 		$config = EE_Registry::instance()->CFG->template_settings;
96 96
 		// then if the Event Archive config is valid, use that, else create a new one
97 97
 		$config = isset( $config->EED_Events_Archive ) && $config->EED_Events_Archive instanceof EE_Events_Archive_Config
98
-            ? $config->EED_Events_Archive
99
-            : new EE_Events_Archive_Config();
98
+			? $config->EED_Events_Archive
99
+			: new EE_Events_Archive_Config();
100 100
 		$config = apply_filters( 'FHEE__EED_Events_Archive__template_settings_form__event_list_config', $config );
101 101
 		$config->display_status_banner = isset( $config->display_status_banner )
102
-            ? $config->display_status_banner
103
-            : 0;
102
+			? $config->display_status_banner
103
+			: 0;
104 104
 		$config->display_description = isset( $config->display_description )
105
-            ? $config->display_description
106
-            : 1;
105
+			? $config->display_description
106
+			: 1;
107 107
 		$config->display_ticket_selector = isset( $config->display_ticket_selector )
108
-            ? $config->display_ticket_selector
109
-            : 0;
108
+			? $config->display_ticket_selector
109
+			: 0;
110 110
 		$config->display_datetimes = isset( $config->display_datetimes )
111
-            ? $config->display_datetimes
112
-            : 1;
111
+			? $config->display_datetimes
112
+			: 1;
113 113
 		$config->display_venue = isset( $config->display_venue )
114
-            ? $config->display_venue
115
-            : 0;
114
+			? $config->display_venue
115
+			: 0;
116 116
 		$config->display_expired_events = isset( $config->display_expired_events )
117
-            ? $config->display_expired_events
118
-            : 0;
117
+			? $config->display_expired_events
118
+			: 0;
119 119
 		// display order options
120 120
 		$config->use_sortable_display_order = isset( $config->use_sortable_display_order  )
121
-            ? $config->use_sortable_display_order
122
-            : false;
121
+			? $config->use_sortable_display_order
122
+			: false;
123 123
 		$config->display_order_tickets = isset( $config->display_order_tickets  )
124
-            ? $config->display_order_tickets
125
-            : 120;
124
+			? $config->display_order_tickets
125
+			: 120;
126 126
 		$config->display_order_datetimes = isset( $config->display_order_datetimes  )
127
-            ? $config->display_order_datetimes
128
-            : 110;
127
+			? $config->display_order_datetimes
128
+			: 110;
129 129
 		$config->display_order_event = isset( $config->display_order_event  )
130
-            ? $config->display_order_event
131
-            : 100;
130
+			? $config->display_order_event
131
+			: 100;
132 132
 		$config->display_order_venue = isset( $config->display_order_venue  )
133
-            ? $config->display_order_venue
134
-            : 130;
133
+			? $config->display_order_venue
134
+			: 130;
135 135
 		// get template parts
136 136
 		$template_parts = EED_Events_Archive::instance()->initialize_template_parts( $config );
137 137
 		// convert to array so that we can add more properties
@@ -165,17 +165,17 @@  discard block
 block discarded – undo
165 165
 			$config->display_expired_events = isset( $REQ['EED_Events_Archive_display_expired_events'] ) ? absint( $REQ['EED_Events_Archive_display_expired_events'] ) : 0;
166 166
 			$config->use_sortable_display_order = isset( $REQ['EED_Events_Archive_use_sortable_display_order'] ) ? absint( $REQ['EED_Events_Archive_use_sortable_display_order'] ) : 0;
167 167
 			$config->display_order_event = isset( $CFG->EED_Events_Archive->display_order_event ) && $config->use_sortable_display_order
168
-                ? $CFG->EED_Events_Archive->display_order_event
169
-                : EED_Events_Archive::EVENT_DETAILS_PRIORITY;
168
+				? $CFG->EED_Events_Archive->display_order_event
169
+				: EED_Events_Archive::EVENT_DETAILS_PRIORITY;
170 170
 			$config->display_order_datetimes = isset( $CFG->EED_Events_Archive->display_order_datetimes ) && $config->use_sortable_display_order
171
-                ? $CFG->EED_Events_Archive->display_order_datetimes
172
-                : EED_Events_Archive::EVENT_DATETIMES_PRIORITY;
171
+				? $CFG->EED_Events_Archive->display_order_datetimes
172
+				: EED_Events_Archive::EVENT_DATETIMES_PRIORITY;
173 173
 			$config->display_order_tickets = isset( $CFG->EED_Events_Archive->display_order_tickets ) && $config->use_sortable_display_order
174
-                ? $CFG->EED_Events_Archive->display_order_tickets
175
-                : EED_Events_Archive::EVENT_TICKETS_PRIORITY;
174
+				? $CFG->EED_Events_Archive->display_order_tickets
175
+				: EED_Events_Archive::EVENT_TICKETS_PRIORITY;
176 176
 			$config->display_order_venue = isset( $CFG->EED_Events_Archive->display_order_venue ) && $config->use_sortable_display_order
177
-                ? $CFG->EED_Events_Archive->display_order_venue
178
-                : EED_Events_Archive::EVENT_VENUES_PRIORITY;
177
+				? $CFG->EED_Events_Archive->display_order_venue
178
+				: EED_Events_Archive::EVENT_VENUES_PRIORITY;
179 179
 		}
180 180
 		$CFG->EED_Events_Archive = $config;
181 181
 		do_action( 'AHEE__EED_Events_Archive__update_template_settings__after_update', $CFG, $REQ );
Please login to merge, or discard this patch.
Spacing   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	 * @return EED_Events_Archive_Caff
29 29
 	 */
30 30
 	public static function instance() {
31
-		return parent::get_instance( __CLASS__ );
31
+		return parent::get_instance(__CLASS__);
32 32
 	}
33 33
 
34 34
 
@@ -49,13 +49,13 @@  discard block
 block discarded – undo
49 49
 	 *  @return 	void
50 50
 	 */
51 51
 	public static function set_hooks_admin() {
52
-		define( 'EVENTS_ARCHIVE_CAFF_TEMPLATES_PATH', str_replace( '\\', DS, plugin_dir_path( __FILE__ )) . 'templates' . DS );
53
-		define( 'EVENT_ARCHIVE_CAFF_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets' . DS );
54
-		add_action( 'AHEE__template_settings__template__before_settings_form', array( 'EED_Events_Archive_Caff', 'template_settings_form' ), 10 );
55
-		add_filter( 'FHEE__General_Settings_Admin_Page__update_template_settings__data', array( 'EED_Events_Archive_Caff', 'update_template_settings' ), 10, 2 );
52
+		define('EVENTS_ARCHIVE_CAFF_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)).'templates'.DS);
53
+		define('EVENT_ARCHIVE_CAFF_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS);
54
+		add_action('AHEE__template_settings__template__before_settings_form', array('EED_Events_Archive_Caff', 'template_settings_form'), 10);
55
+		add_filter('FHEE__General_Settings_Admin_Page__update_template_settings__data', array('EED_Events_Archive_Caff', 'update_template_settings'), 10, 2);
56 56
 		// AJAX
57
-		add_action( 'wp_ajax_espresso_update_event_archive_order', array( 'EED_Events_Archive_Caff', 'update_event_archive_order' ) );
58
-		add_action( 'wp_ajax_nopriv_espresso_update_event_archive_order', array( 'EED_Events_Archive_Caff', 'update_event_archive_order' ) );
57
+		add_action('wp_ajax_espresso_update_event_archive_order', array('EED_Events_Archive_Caff', 'update_event_archive_order'));
58
+		add_action('wp_ajax_nopriv_espresso_update_event_archive_order', array('EED_Events_Archive_Caff', 'update_event_archive_order'));
59 59
 	}
60 60
 
61 61
 
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	 * @param    WP $WP
69 69
 	 * @return    void
70 70
 	 */
71
-	public function run( $WP ) {
71
+	public function run($WP) {
72 72
 	}
73 73
 
74 74
 
@@ -83,61 +83,61 @@  discard block
 block discarded – undo
83 83
 	 */
84 84
 	public static function template_settings_form() {
85 85
 		// grab general settings admin page and remove the existing hook callback
86
-		$gen_set_admin = EE_Registry::instance()->LIB->EE_Admin_Page_Loader->get_admin_page_object( 'general_settings' );
87
-		if ( $gen_set_admin instanceof General_Settings_Admin_Page ) {
86
+		$gen_set_admin = EE_Registry::instance()->LIB->EE_Admin_Page_Loader->get_admin_page_object('general_settings');
87
+		if ($gen_set_admin instanceof General_Settings_Admin_Page) {
88 88
 			remove_action(
89 89
 			    'AHEE__template_settings__template__before_settings_form',
90
-                array( $gen_set_admin, 'template_settings_caff_features' ),
90
+                array($gen_set_admin, 'template_settings_caff_features'),
91 91
                 100
92 92
             );
93 93
 		}
94 94
 		// first just grab the template settings
95 95
 		$config = EE_Registry::instance()->CFG->template_settings;
96 96
 		// then if the Event Archive config is valid, use that, else create a new one
97
-		$config = isset( $config->EED_Events_Archive ) && $config->EED_Events_Archive instanceof EE_Events_Archive_Config
97
+		$config = isset($config->EED_Events_Archive) && $config->EED_Events_Archive instanceof EE_Events_Archive_Config
98 98
             ? $config->EED_Events_Archive
99 99
             : new EE_Events_Archive_Config();
100
-		$config = apply_filters( 'FHEE__EED_Events_Archive__template_settings_form__event_list_config', $config );
101
-		$config->display_status_banner = isset( $config->display_status_banner )
100
+		$config = apply_filters('FHEE__EED_Events_Archive__template_settings_form__event_list_config', $config);
101
+		$config->display_status_banner = isset($config->display_status_banner)
102 102
             ? $config->display_status_banner
103 103
             : 0;
104
-		$config->display_description = isset( $config->display_description )
104
+		$config->display_description = isset($config->display_description)
105 105
             ? $config->display_description
106 106
             : 1;
107
-		$config->display_ticket_selector = isset( $config->display_ticket_selector )
107
+		$config->display_ticket_selector = isset($config->display_ticket_selector)
108 108
             ? $config->display_ticket_selector
109 109
             : 0;
110
-		$config->display_datetimes = isset( $config->display_datetimes )
110
+		$config->display_datetimes = isset($config->display_datetimes)
111 111
             ? $config->display_datetimes
112 112
             : 1;
113
-		$config->display_venue = isset( $config->display_venue )
113
+		$config->display_venue = isset($config->display_venue)
114 114
             ? $config->display_venue
115 115
             : 0;
116
-		$config->display_expired_events = isset( $config->display_expired_events )
116
+		$config->display_expired_events = isset($config->display_expired_events)
117 117
             ? $config->display_expired_events
118 118
             : 0;
119 119
 		// display order options
120
-		$config->use_sortable_display_order = isset( $config->use_sortable_display_order  )
120
+		$config->use_sortable_display_order = isset($config->use_sortable_display_order)
121 121
             ? $config->use_sortable_display_order
122 122
             : false;
123
-		$config->display_order_tickets = isset( $config->display_order_tickets  )
123
+		$config->display_order_tickets = isset($config->display_order_tickets)
124 124
             ? $config->display_order_tickets
125 125
             : 120;
126
-		$config->display_order_datetimes = isset( $config->display_order_datetimes  )
126
+		$config->display_order_datetimes = isset($config->display_order_datetimes)
127 127
             ? $config->display_order_datetimes
128 128
             : 110;
129
-		$config->display_order_event = isset( $config->display_order_event  )
129
+		$config->display_order_event = isset($config->display_order_event)
130 130
             ? $config->display_order_event
131 131
             : 100;
132
-		$config->display_order_venue = isset( $config->display_order_venue  )
132
+		$config->display_order_venue = isset($config->display_order_venue)
133 133
             ? $config->display_order_venue
134 134
             : 130;
135 135
 		// get template parts
136
-		$template_parts = EED_Events_Archive::instance()->initialize_template_parts( $config );
136
+		$template_parts = EED_Events_Archive::instance()->initialize_template_parts($config);
137 137
 		// convert to array so that we can add more properties
138
-		$config = get_object_vars( $config );
139
-		$config[ 'event_archive_display_order' ] = $template_parts->generate_sortable_list_of_template_parts( 'event-archive-sortable-js', '', 'archive-sortable-li archive-sortable-js' );
140
-		EEH_Template::display_template( EVENTS_ARCHIVE_CAFF_TEMPLATES_PATH . 'admin-event-list-settings.template.php', $config );
138
+		$config = get_object_vars($config);
139
+		$config['event_archive_display_order'] = $template_parts->generate_sortable_list_of_template_parts('event-archive-sortable-js', '', 'archive-sortable-li archive-sortable-js');
140
+		EEH_Template::display_template(EVENTS_ARCHIVE_CAFF_TEMPLATES_PATH.'admin-event-list-settings.template.php', $config);
141 141
 	}
142 142
 
143 143
 
@@ -153,32 +153,32 @@  discard block
 block discarded – undo
153 153
 	 *  @param 	array $REQ
154 154
 	 *  @return    EE_Events_Archive_Config
155 155
 	 */
156
-	public static function update_template_settings( $CFG, $REQ ) {
156
+	public static function update_template_settings($CFG, $REQ) {
157 157
 		$config = new EE_Events_Archive_Config();
158 158
 		// unless we are resetting the config...
159
-		if ( ! isset( $REQ['EED_Events_Archive_reset_event_list_settings'] ) || absint( $REQ['EED_Events_Archive_reset_event_list_settings'] ) !== 1 ) {
160
-			$config->display_status_banner = isset( $REQ['EED_Events_Archive_display_status_banner'] ) ? absint( $REQ['EED_Events_Archive_display_status_banner'] ) : 0;
161
-			$config->display_description = isset( $REQ['EED_Events_Archive_display_description'] ) ? absint( $REQ['EED_Events_Archive_display_description'] ) : 1;
162
-			$config->display_ticket_selector = isset( $REQ['EED_Events_Archive_display_ticket_selector'] ) ? absint( $REQ['EED_Events_Archive_display_ticket_selector'] ) : 0;
163
-			$config->display_datetimes = isset( $REQ['EED_Events_Archive_display_datetimes'] ) ? absint( $REQ['EED_Events_Archive_display_datetimes'] ) : 1;
164
-			$config->display_venue = isset( $REQ['EED_Events_Archive_display_venue'] ) ? absint( $REQ['EED_Events_Archive_display_venue'] ) : 0;
165
-			$config->display_expired_events = isset( $REQ['EED_Events_Archive_display_expired_events'] ) ? absint( $REQ['EED_Events_Archive_display_expired_events'] ) : 0;
166
-			$config->use_sortable_display_order = isset( $REQ['EED_Events_Archive_use_sortable_display_order'] ) ? absint( $REQ['EED_Events_Archive_use_sortable_display_order'] ) : 0;
167
-			$config->display_order_event = isset( $CFG->EED_Events_Archive->display_order_event ) && $config->use_sortable_display_order
159
+		if ( ! isset($REQ['EED_Events_Archive_reset_event_list_settings']) || absint($REQ['EED_Events_Archive_reset_event_list_settings']) !== 1) {
160
+			$config->display_status_banner = isset($REQ['EED_Events_Archive_display_status_banner']) ? absint($REQ['EED_Events_Archive_display_status_banner']) : 0;
161
+			$config->display_description = isset($REQ['EED_Events_Archive_display_description']) ? absint($REQ['EED_Events_Archive_display_description']) : 1;
162
+			$config->display_ticket_selector = isset($REQ['EED_Events_Archive_display_ticket_selector']) ? absint($REQ['EED_Events_Archive_display_ticket_selector']) : 0;
163
+			$config->display_datetimes = isset($REQ['EED_Events_Archive_display_datetimes']) ? absint($REQ['EED_Events_Archive_display_datetimes']) : 1;
164
+			$config->display_venue = isset($REQ['EED_Events_Archive_display_venue']) ? absint($REQ['EED_Events_Archive_display_venue']) : 0;
165
+			$config->display_expired_events = isset($REQ['EED_Events_Archive_display_expired_events']) ? absint($REQ['EED_Events_Archive_display_expired_events']) : 0;
166
+			$config->use_sortable_display_order = isset($REQ['EED_Events_Archive_use_sortable_display_order']) ? absint($REQ['EED_Events_Archive_use_sortable_display_order']) : 0;
167
+			$config->display_order_event = isset($CFG->EED_Events_Archive->display_order_event) && $config->use_sortable_display_order
168 168
                 ? $CFG->EED_Events_Archive->display_order_event
169 169
                 : EED_Events_Archive::EVENT_DETAILS_PRIORITY;
170
-			$config->display_order_datetimes = isset( $CFG->EED_Events_Archive->display_order_datetimes ) && $config->use_sortable_display_order
170
+			$config->display_order_datetimes = isset($CFG->EED_Events_Archive->display_order_datetimes) && $config->use_sortable_display_order
171 171
                 ? $CFG->EED_Events_Archive->display_order_datetimes
172 172
                 : EED_Events_Archive::EVENT_DATETIMES_PRIORITY;
173
-			$config->display_order_tickets = isset( $CFG->EED_Events_Archive->display_order_tickets ) && $config->use_sortable_display_order
173
+			$config->display_order_tickets = isset($CFG->EED_Events_Archive->display_order_tickets) && $config->use_sortable_display_order
174 174
                 ? $CFG->EED_Events_Archive->display_order_tickets
175 175
                 : EED_Events_Archive::EVENT_TICKETS_PRIORITY;
176
-			$config->display_order_venue = isset( $CFG->EED_Events_Archive->display_order_venue ) && $config->use_sortable_display_order
176
+			$config->display_order_venue = isset($CFG->EED_Events_Archive->display_order_venue) && $config->use_sortable_display_order
177 177
                 ? $CFG->EED_Events_Archive->display_order_venue
178 178
                 : EED_Events_Archive::EVENT_VENUES_PRIORITY;
179 179
 		}
180 180
 		$CFG->EED_Events_Archive = $config;
181
-		do_action( 'AHEE__EED_Events_Archive__update_template_settings__after_update', $CFG, $REQ );
181
+		do_action('AHEE__EED_Events_Archive__update_template_settings__after_update', $CFG, $REQ);
182 182
 		return $CFG;
183 183
 	}
184 184
 
@@ -192,12 +192,12 @@  discard block
 block discarded – undo
192 192
 	 */
193 193
 	public static function update_event_archive_order() {
194 194
 		$config_saved = false;
195
-		$template_parts = sanitize_text_field( $_POST[ 'elements' ] );
196
-		if ( ! empty( $template_parts ) ) {
197
-			$template_parts = explode( ',', trim( $template_parts, ',' ) );
198
-			foreach ( $template_parts as $key => $template_part ) {
195
+		$template_parts = sanitize_text_field($_POST['elements']);
196
+		if ( ! empty($template_parts)) {
197
+			$template_parts = explode(',', trim($template_parts, ','));
198
+			foreach ($template_parts as $key => $template_part) {
199 199
 				$template_part = "display_order_$template_part";
200
-				$priority = ( $key * 10 ) + EED_Events_Archive::EVENT_DETAILS_PRIORITY;
200
+				$priority = ($key * 10) + EED_Events_Archive::EVENT_DETAILS_PRIORITY;
201 201
 				if (
202 202
 					property_exists(
203 203
 						EE_Registry::instance()->CFG->template_settings->EED_Events_Archive,
@@ -206,16 +206,16 @@  discard block
 block discarded – undo
206 206
 				) {
207 207
 					EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->{$template_part} = $priority;
208 208
 				}
209
-				do_action( "AHEE__EED_Events_Archive__update_event_archive_order__$template_part", $priority );
209
+				do_action("AHEE__EED_Events_Archive__update_event_archive_order__$template_part", $priority);
210 210
 			}
211
-			$config_saved = EE_Registry::instance()->CFG->update_espresso_config( false, false );
211
+			$config_saved = EE_Registry::instance()->CFG->update_espresso_config(false, false);
212 212
 		}
213
-		if ( $config_saved ) {
214
-			EE_Error::add_success( __( 'Display Order has been successfully updated.', 'event_espresso' ) );
213
+		if ($config_saved) {
214
+			EE_Error::add_success(__('Display Order has been successfully updated.', 'event_espresso'));
215 215
 		} else {
216
-			EE_Error::add_error( __( 'Display Order was not updated.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
216
+			EE_Error::add_error(__('Display Order was not updated.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
217 217
 		}
218
-		echo wp_json_encode( EE_Error::get_notices( false ) );
218
+		echo wp_json_encode(EE_Error::get_notices(false));
219 219
 		exit();
220 220
 	}
221 221
 
Please login to merge, or discard this patch.
core/libraries/template_parts/EE_Template_Part_Manager.class.php 2 patches
Indentation   +193 added lines, -193 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 //namespace EventEspresso\core\libraries\templates;
3 3
 if (!defined('EVENT_ESPRESSO_VERSION')) {
4
-    exit('No direct script access allowed');
4
+	exit('No direct script access allowed');
5 5
 }
6 6
 
7 7
 
@@ -19,198 +19,198 @@  discard block
 block discarded – undo
19 19
 class EE_Template_Part_Manager
20 20
 {
21 21
 
22
-    /**
23
-     * @param EE_Template_Part_PriorityQueue $template_parts
24
-     */
25
-    protected $template_parts;
26
-
27
-    /**
28
-     * @param array $priorities
29
-     */
30
-    protected $priorities = array();
31
-
32
-    /**
33
-     * @param int $event_desc_priority
34
-     */
35
-    protected $event_desc_priority;
36
-
37
-    /**
38
-     * @param string $before_event_content
39
-     */
40
-    protected $before_event_content;
41
-
42
-    /**
43
-     * @param string $event_content
44
-     */
45
-    protected $event_content;
46
-
47
-    /**
48
-     * @param string $after_event_content
49
-     */
50
-    protected $after_event_content;
51
-
52
-
53
-    /**
54
-     *    class constructor
55
-     */
56
-    public function __construct()
57
-    {
58
-        $this->template_parts = new EE_Template_Part_PriorityQueue();
59
-    }
60
-
61
-
62
-    /**
63
-     *    add_template_part
64
-     *
65
-     *    used for setting the details about a particular template part
66
-     *
67
-     * @param string $name - just a simple string identifier - do NOT use 'event'
68
-     * @param string $label - template part label displayed in admin
69
-     * @param string $template - name or path of template to be used by EEH_Template::locate_template()
70
-     * @param int $priority - order in which template parts should be applied
71
-     */
72
-    public function add_template_part($name, $label, $template, $priority)
73
-    {
74
-        // SplPriorityQueue doesn't play nice with multiple items having the same priority
75
-        // so if the incoming priority is already occupied, then let's increment it by one,
76
-        // and then pass everything back into this method and try again with the new priority
77
-        if (isset($this->priorities[$priority])) {
78
-            $priority++;
79
-            $this->add_template_part($name, $label, $template, $priority);
80
-            return;
81
-        }
82
-        // kk now we can mark this priority as being occupied
83
-        $this->priorities[$priority] = true;
84
-        // create the template part and add to the queue
85
-        $this->template_parts->insert(
86
-            new EE_Template_Part($name, $label, $template, $priority),
87
-            $priority
88
-        );
89
-        if ($name === 'event') {
90
-            $this->event_desc_priority = $priority;
91
-        }
92
-    }
93
-
94
-
95
-    /**
96
-     *    apply_template_part_filters
97
-     *
98
-     *    adds template parts to the supplied content
99
-     *    according to the details set when the template parts were added
100
-     *
101
-     * @access public
102
-     * @param string $content
103
-     * @return string
104
-     */
105
-    public function apply_template_part_filters($content = '')
106
-    {
107
-        $this->template_parts->rewind();
108
-        // loop through template parts and position content
109
-        while ($this->template_parts->valid()) {
110
-            $this->_position_template_part(
111
-                $content,
112
-                $this->template_parts->current()->template(),
113
-                $this->template_parts->current()->priority()
114
-            );
115
-            $this->template_parts->next();
116
-        }
117
-        // now simply add our three strings of content together
118
-        return $this->before_event_content . $this->event_content . $this->after_event_content;
119
-    }
120
-
121
-
122
-    /**
123
-     *    position_template_part
124
-     *
125
-     * based on the priority of the incoming template part
126
-     * relative to the known event description template part priority,
127
-     * this method will assign template parts to one of the following:
128
-     *        $this->before_event_content
129
-     *        $this->event_content
130
-     *        $this->after_event_content
131
-     *
132
-     * @access protected
133
-     * @param string $content
134
-     * @param string $template
135
-     * @param int $priority
136
-     * @return void
137
-     */
138
-    protected function _position_template_part($content, $template, $priority)
139
-    {
140
-        // Event Description content is the actual incoming content itself
141
-        if ($priority === $this->event_desc_priority) {
142
-            $this->event_content = $content;
143
-        } else if ($priority < $this->event_desc_priority) {
144
-            // everything BEFORE the Event Description
145
-            $this->before_event_content .= EEH_Template::locate_template($template);
146
-        } else if ($priority > $this->event_desc_priority) {
147
-            // everything AFTER the Event Description
148
-            $this->after_event_content .= EEH_Template::locate_template($template);
149
-        }
150
-    }
151
-
152
-
153
-    /**
154
-     *    generate_sortable_list_of_template_parts
155
-     *
156
-     *    creates an HTML list (<ul>) with list items (<li>) for each template part,
157
-     *    in a format that can be used as a sortable list in the admin
158
-     *
159
-     * @access public
160
-     * @param string $list_css_id
161
-     * @param string $list_css_class
162
-     * @param string $list_item_css_class
163
-     * @param string $list_item_css_id_prefix
164
-     * @return string
165
-     */
166
-    public function generate_sortable_list_of_template_parts(
167
-        $list_css_id = '',
168
-        $list_css_class = '',
169
-        $list_item_css_class = '',
170
-        $list_item_css_id_prefix = ''
171
-    )
172
-    {
173
-        $event_archive_display_order = EEH_HTML::ul($list_css_id, $list_css_class);
174
-        $this->template_parts->rewind();
175
-        // loop through template parts and add template content
176
-        while ($this->template_parts->valid()) {
177
-            $event_archive_display_order .= EEH_HTML::li(
178
-                EEH_HTML::span('', '', 'dashicons dashicons-arrow-up-alt2') .
179
-                EEH_HTML::span('', '', 'dashicons dashicons-arrow-down-alt2') .
180
-                $this->template_parts->current()->label(),
181
-                $list_item_css_id_prefix . $this->template_parts->current()->name(),
182
-                $list_item_css_class
183
-            );
184
-            $this->template_parts->next();
185
-        }
186
-        $event_archive_display_order .= EEH_HTML::ulx();
187
-        return $event_archive_display_order;
188
-    }
189
-
190
-
191
-    /**
192
-     *    display_template_parts
193
-     *
194
-     * just for debugging purposes
195
-     *
196
-     * @access    public
197
-     * @return void
198
-     */
199
-    public function display_template_parts()
200
-    {
201
-        if (WP_DEBUG) {
202
-            $this->template_parts->rewind();
203
-            while ($this->template_parts->valid()) {
204
-                EEH_Debug_Tools::printr(
205
-                    $this->template_parts->current(),
206
-                    'template_part',
207
-                    __FILE__,
208
-                    __LINE__
209
-                );
210
-                $this->template_parts->next();
211
-            }
212
-        }
213
-    }
22
+	/**
23
+	 * @param EE_Template_Part_PriorityQueue $template_parts
24
+	 */
25
+	protected $template_parts;
26
+
27
+	/**
28
+	 * @param array $priorities
29
+	 */
30
+	protected $priorities = array();
31
+
32
+	/**
33
+	 * @param int $event_desc_priority
34
+	 */
35
+	protected $event_desc_priority;
36
+
37
+	/**
38
+	 * @param string $before_event_content
39
+	 */
40
+	protected $before_event_content;
41
+
42
+	/**
43
+	 * @param string $event_content
44
+	 */
45
+	protected $event_content;
46
+
47
+	/**
48
+	 * @param string $after_event_content
49
+	 */
50
+	protected $after_event_content;
51
+
52
+
53
+	/**
54
+	 *    class constructor
55
+	 */
56
+	public function __construct()
57
+	{
58
+		$this->template_parts = new EE_Template_Part_PriorityQueue();
59
+	}
60
+
61
+
62
+	/**
63
+	 *    add_template_part
64
+	 *
65
+	 *    used for setting the details about a particular template part
66
+	 *
67
+	 * @param string $name - just a simple string identifier - do NOT use 'event'
68
+	 * @param string $label - template part label displayed in admin
69
+	 * @param string $template - name or path of template to be used by EEH_Template::locate_template()
70
+	 * @param int $priority - order in which template parts should be applied
71
+	 */
72
+	public function add_template_part($name, $label, $template, $priority)
73
+	{
74
+		// SplPriorityQueue doesn't play nice with multiple items having the same priority
75
+		// so if the incoming priority is already occupied, then let's increment it by one,
76
+		// and then pass everything back into this method and try again with the new priority
77
+		if (isset($this->priorities[$priority])) {
78
+			$priority++;
79
+			$this->add_template_part($name, $label, $template, $priority);
80
+			return;
81
+		}
82
+		// kk now we can mark this priority as being occupied
83
+		$this->priorities[$priority] = true;
84
+		// create the template part and add to the queue
85
+		$this->template_parts->insert(
86
+			new EE_Template_Part($name, $label, $template, $priority),
87
+			$priority
88
+		);
89
+		if ($name === 'event') {
90
+			$this->event_desc_priority = $priority;
91
+		}
92
+	}
93
+
94
+
95
+	/**
96
+	 *    apply_template_part_filters
97
+	 *
98
+	 *    adds template parts to the supplied content
99
+	 *    according to the details set when the template parts were added
100
+	 *
101
+	 * @access public
102
+	 * @param string $content
103
+	 * @return string
104
+	 */
105
+	public function apply_template_part_filters($content = '')
106
+	{
107
+		$this->template_parts->rewind();
108
+		// loop through template parts and position content
109
+		while ($this->template_parts->valid()) {
110
+			$this->_position_template_part(
111
+				$content,
112
+				$this->template_parts->current()->template(),
113
+				$this->template_parts->current()->priority()
114
+			);
115
+			$this->template_parts->next();
116
+		}
117
+		// now simply add our three strings of content together
118
+		return $this->before_event_content . $this->event_content . $this->after_event_content;
119
+	}
120
+
121
+
122
+	/**
123
+	 *    position_template_part
124
+	 *
125
+	 * based on the priority of the incoming template part
126
+	 * relative to the known event description template part priority,
127
+	 * this method will assign template parts to one of the following:
128
+	 *        $this->before_event_content
129
+	 *        $this->event_content
130
+	 *        $this->after_event_content
131
+	 *
132
+	 * @access protected
133
+	 * @param string $content
134
+	 * @param string $template
135
+	 * @param int $priority
136
+	 * @return void
137
+	 */
138
+	protected function _position_template_part($content, $template, $priority)
139
+	{
140
+		// Event Description content is the actual incoming content itself
141
+		if ($priority === $this->event_desc_priority) {
142
+			$this->event_content = $content;
143
+		} else if ($priority < $this->event_desc_priority) {
144
+			// everything BEFORE the Event Description
145
+			$this->before_event_content .= EEH_Template::locate_template($template);
146
+		} else if ($priority > $this->event_desc_priority) {
147
+			// everything AFTER the Event Description
148
+			$this->after_event_content .= EEH_Template::locate_template($template);
149
+		}
150
+	}
151
+
152
+
153
+	/**
154
+	 *    generate_sortable_list_of_template_parts
155
+	 *
156
+	 *    creates an HTML list (<ul>) with list items (<li>) for each template part,
157
+	 *    in a format that can be used as a sortable list in the admin
158
+	 *
159
+	 * @access public
160
+	 * @param string $list_css_id
161
+	 * @param string $list_css_class
162
+	 * @param string $list_item_css_class
163
+	 * @param string $list_item_css_id_prefix
164
+	 * @return string
165
+	 */
166
+	public function generate_sortable_list_of_template_parts(
167
+		$list_css_id = '',
168
+		$list_css_class = '',
169
+		$list_item_css_class = '',
170
+		$list_item_css_id_prefix = ''
171
+	)
172
+	{
173
+		$event_archive_display_order = EEH_HTML::ul($list_css_id, $list_css_class);
174
+		$this->template_parts->rewind();
175
+		// loop through template parts and add template content
176
+		while ($this->template_parts->valid()) {
177
+			$event_archive_display_order .= EEH_HTML::li(
178
+				EEH_HTML::span('', '', 'dashicons dashicons-arrow-up-alt2') .
179
+				EEH_HTML::span('', '', 'dashicons dashicons-arrow-down-alt2') .
180
+				$this->template_parts->current()->label(),
181
+				$list_item_css_id_prefix . $this->template_parts->current()->name(),
182
+				$list_item_css_class
183
+			);
184
+			$this->template_parts->next();
185
+		}
186
+		$event_archive_display_order .= EEH_HTML::ulx();
187
+		return $event_archive_display_order;
188
+	}
189
+
190
+
191
+	/**
192
+	 *    display_template_parts
193
+	 *
194
+	 * just for debugging purposes
195
+	 *
196
+	 * @access    public
197
+	 * @return void
198
+	 */
199
+	public function display_template_parts()
200
+	{
201
+		if (WP_DEBUG) {
202
+			$this->template_parts->rewind();
203
+			while ($this->template_parts->valid()) {
204
+				EEH_Debug_Tools::printr(
205
+					$this->template_parts->current(),
206
+					'template_part',
207
+					__FILE__,
208
+					__LINE__
209
+				);
210
+				$this->template_parts->next();
211
+			}
212
+		}
213
+	}
214 214
 }
215 215
 // End of file EE_Template_Part_Manager.class.php
216 216
 // Location: /EE_Template_Part_Manager.class.php
217 217
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 //namespace EventEspresso\core\libraries\templates;
3
-if (!defined('EVENT_ESPRESSO_VERSION')) {
3
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
4 4
     exit('No direct script access allowed');
5 5
 }
6 6
 
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
             $this->template_parts->next();
116 116
         }
117 117
         // now simply add our three strings of content together
118
-        return $this->before_event_content . $this->event_content . $this->after_event_content;
118
+        return $this->before_event_content.$this->event_content.$this->after_event_content;
119 119
     }
120 120
 
121 121
 
@@ -175,10 +175,10 @@  discard block
 block discarded – undo
175 175
         // loop through template parts and add template content
176 176
         while ($this->template_parts->valid()) {
177 177
             $event_archive_display_order .= EEH_HTML::li(
178
-                EEH_HTML::span('', '', 'dashicons dashicons-arrow-up-alt2') .
179
-                EEH_HTML::span('', '', 'dashicons dashicons-arrow-down-alt2') .
178
+                EEH_HTML::span('', '', 'dashicons dashicons-arrow-up-alt2').
179
+                EEH_HTML::span('', '', 'dashicons dashicons-arrow-down-alt2').
180 180
                 $this->template_parts->current()->label(),
181
-                $list_item_css_id_prefix . $this->template_parts->current()->name(),
181
+                $list_item_css_id_prefix.$this->template_parts->current()->name(),
182 182
                 $list_item_css_class
183 183
             );
184 184
             $this->template_parts->next();
Please login to merge, or discard this patch.
core/EE_Configurable.core.php 2 patches
Indentation   +139 added lines, -139 removed lines patch added patch discarded remove patch
@@ -12,145 +12,145 @@
 block discarded – undo
12 12
 abstract class EE_Configurable extends EE_Base
13 13
 {
14 14
 
15
-    /**
16
-     * @var $_config
17
-     * @type EE_Config_Base
18
-     */
19
-    protected $_config;
20
-
21
-    /**
22
-     * @var $_config_section
23
-     * @type string
24
-     */
25
-    protected $_config_section = '';
26
-
27
-    /**
28
-     * @var $_config_class
29
-     * @type string
30
-     */
31
-    protected $_config_class = '';
32
-
33
-    /**
34
-     * @var $_config_name
35
-     * @type string
36
-     */
37
-    protected $_config_name = '';
38
-
39
-
40
-    /**
41
-     * @param string $config_section
42
-     */
43
-    public function set_config_section($config_section = '')
44
-    {
45
-        $this->_config_section = !empty($config_section) ? $config_section : 'modules';
46
-    }
47
-
48
-
49
-    /**
50
-     * @return mixed
51
-     */
52
-    public function config_section()
53
-    {
54
-        return $this->_config_section;
55
-    }
56
-
57
-
58
-    /**
59
-     * @param string $config_class
60
-     */
61
-    public function set_config_class($config_class = '')
62
-    {
63
-        $this->_config_class = $config_class;
64
-    }
65
-
66
-
67
-    /**
68
-     * @return mixed
69
-     */
70
-    public function config_class()
71
-    {
72
-        return $this->_config_class;
73
-    }
74
-
75
-
76
-    /**
77
-     * @param mixed $config_name
78
-     */
79
-    public function set_config_name($config_name)
80
-    {
81
-        $this->_config_name = !empty($config_name) ? $config_name : get_called_class();
82
-    }
83
-
84
-
85
-    /**
86
-     * @return mixed
87
-     */
88
-    public function config_name()
89
-    {
90
-        return $this->_config_name;
91
-    }
92
-
93
-
94
-    /**
95
-     *    set_config
96
-     *    this method integrates directly with EE_Config to set up the config object for this class
97
-     *
98
-     * @access    protected
99
-     * @param    EE_Config_Base $config_obj
100
-     * @return    mixed    EE_Config_Base | NULL
101
-     */
102
-    protected function _set_config(EE_Config_Base $config_obj = null)
103
-    {
104
-        return EE_Config::instance()->set_config(
105
-            $this->config_section(),
106
-            $this->config_name(),
107
-            $this->config_class(),
108
-            $config_obj
109
-        );
110
-    }
111
-
112
-
113
-    /**
114
-     *    _update_config
115
-     *    this method integrates directly with EE_Config to update an existing config object for this class
116
-     *
117
-     * @access    protected
118
-     * @param    EE_Config_Base $config_obj
119
-     * @throws \EE_Error
120
-     * @return    mixed    EE_Config_Base | NULL
121
-     */
122
-    public function _update_config(EE_Config_Base $config_obj = null)
123
-    {
124
-        $config_class = $this->config_class();
125
-        if (!$config_obj instanceof $config_class) {
126
-            throw new EE_Error(
127
-                sprintf(
128
-                    __('The "%1$s" class is not an instance of %2$s.', 'event_espresso'),
129
-                    print_r($config_obj, true),
130
-                    $config_class
131
-                )
132
-            );
133
-        }
134
-        return EE_Config::instance()->update_config($this->config_section(), $this->config_name(), $config_obj);
135
-    }
136
-
137
-
138
-    /**
139
-     * gets the class's config object
140
-     *
141
-     * @return EE_Config_Base
142
-     */
143
-    public function config()
144
-    {
145
-        if (empty($this->_config)) {
146
-            $this->_config = EE_Config::instance()->get_config(
147
-                $this->config_section(),
148
-                $this->config_name(),
149
-                $this->config_class()
150
-            );
151
-        }
152
-        return $this->_config;
153
-    }
15
+	/**
16
+	 * @var $_config
17
+	 * @type EE_Config_Base
18
+	 */
19
+	protected $_config;
20
+
21
+	/**
22
+	 * @var $_config_section
23
+	 * @type string
24
+	 */
25
+	protected $_config_section = '';
26
+
27
+	/**
28
+	 * @var $_config_class
29
+	 * @type string
30
+	 */
31
+	protected $_config_class = '';
32
+
33
+	/**
34
+	 * @var $_config_name
35
+	 * @type string
36
+	 */
37
+	protected $_config_name = '';
38
+
39
+
40
+	/**
41
+	 * @param string $config_section
42
+	 */
43
+	public function set_config_section($config_section = '')
44
+	{
45
+		$this->_config_section = !empty($config_section) ? $config_section : 'modules';
46
+	}
47
+
48
+
49
+	/**
50
+	 * @return mixed
51
+	 */
52
+	public function config_section()
53
+	{
54
+		return $this->_config_section;
55
+	}
56
+
57
+
58
+	/**
59
+	 * @param string $config_class
60
+	 */
61
+	public function set_config_class($config_class = '')
62
+	{
63
+		$this->_config_class = $config_class;
64
+	}
65
+
66
+
67
+	/**
68
+	 * @return mixed
69
+	 */
70
+	public function config_class()
71
+	{
72
+		return $this->_config_class;
73
+	}
74
+
75
+
76
+	/**
77
+	 * @param mixed $config_name
78
+	 */
79
+	public function set_config_name($config_name)
80
+	{
81
+		$this->_config_name = !empty($config_name) ? $config_name : get_called_class();
82
+	}
83
+
84
+
85
+	/**
86
+	 * @return mixed
87
+	 */
88
+	public function config_name()
89
+	{
90
+		return $this->_config_name;
91
+	}
92
+
93
+
94
+	/**
95
+	 *    set_config
96
+	 *    this method integrates directly with EE_Config to set up the config object for this class
97
+	 *
98
+	 * @access    protected
99
+	 * @param    EE_Config_Base $config_obj
100
+	 * @return    mixed    EE_Config_Base | NULL
101
+	 */
102
+	protected function _set_config(EE_Config_Base $config_obj = null)
103
+	{
104
+		return EE_Config::instance()->set_config(
105
+			$this->config_section(),
106
+			$this->config_name(),
107
+			$this->config_class(),
108
+			$config_obj
109
+		);
110
+	}
111
+
112
+
113
+	/**
114
+	 *    _update_config
115
+	 *    this method integrates directly with EE_Config to update an existing config object for this class
116
+	 *
117
+	 * @access    protected
118
+	 * @param    EE_Config_Base $config_obj
119
+	 * @throws \EE_Error
120
+	 * @return    mixed    EE_Config_Base | NULL
121
+	 */
122
+	public function _update_config(EE_Config_Base $config_obj = null)
123
+	{
124
+		$config_class = $this->config_class();
125
+		if (!$config_obj instanceof $config_class) {
126
+			throw new EE_Error(
127
+				sprintf(
128
+					__('The "%1$s" class is not an instance of %2$s.', 'event_espresso'),
129
+					print_r($config_obj, true),
130
+					$config_class
131
+				)
132
+			);
133
+		}
134
+		return EE_Config::instance()->update_config($this->config_section(), $this->config_name(), $config_obj);
135
+	}
136
+
137
+
138
+	/**
139
+	 * gets the class's config object
140
+	 *
141
+	 * @return EE_Config_Base
142
+	 */
143
+	public function config()
144
+	{
145
+		if (empty($this->_config)) {
146
+			$this->_config = EE_Config::instance()->get_config(
147
+				$this->config_section(),
148
+				$this->config_name(),
149
+				$this->config_class()
150
+			);
151
+		}
152
+		return $this->_config;
153
+	}
154 154
 
155 155
 
156 156
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
      */
43 43
     public function set_config_section($config_section = '')
44 44
     {
45
-        $this->_config_section = !empty($config_section) ? $config_section : 'modules';
45
+        $this->_config_section = ! empty($config_section) ? $config_section : 'modules';
46 46
     }
47 47
 
48 48
 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
      */
79 79
     public function set_config_name($config_name)
80 80
     {
81
-        $this->_config_name = !empty($config_name) ? $config_name : get_called_class();
81
+        $this->_config_name = ! empty($config_name) ? $config_name : get_called_class();
82 82
     }
83 83
 
84 84
 
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
     public function _update_config(EE_Config_Base $config_obj = null)
123 123
     {
124 124
         $config_class = $this->config_class();
125
-        if (!$config_obj instanceof $config_class) {
125
+        if ( ! $config_obj instanceof $config_class) {
126 126
             throw new EE_Error(
127 127
                 sprintf(
128 128
                     __('The "%1$s" class is not an instance of %2$s.', 'event_espresso'),
Please login to merge, or discard this patch.
modules/events_archive/EED_Events_Archive.module.php 2 patches
Indentation   +172 added lines, -172 removed lines patch added patch discarded remove patch
@@ -14,13 +14,13 @@  discard block
 block discarded – undo
14 14
  */
15 15
 class EED_Events_Archive  extends EED_Module {
16 16
 
17
-    const EVENT_DETAILS_PRIORITY = 100;
18
-    const EVENT_DATETIMES_PRIORITY = 110;
19
-    const EVENT_TICKETS_PRIORITY = 120;
20
-    const EVENT_VENUES_PRIORITY = 130;
17
+	const EVENT_DETAILS_PRIORITY = 100;
18
+	const EVENT_DATETIMES_PRIORITY = 110;
19
+	const EVENT_TICKETS_PRIORITY = 120;
20
+	const EVENT_VENUES_PRIORITY = 130;
21 21
 
22 22
 
23
-    public static $espresso_event_list_ID = 0;
23
+	public static $espresso_event_list_ID = 0;
24 24
 	public static $espresso_grid_event_lists = array();
25 25
 
26 26
 	/**
@@ -28,19 +28,19 @@  discard block
 block discarded – undo
28 28
 	 */
29 29
 	protected static $using_get_the_excerpt = false;
30 30
 
31
-    /**
32
-     * Used to flag when the event list is being called from an external iframe.
33
-     *
34
-     * @var bool $iframe
35
-     */
36
-    protected static $iframe = false;
31
+	/**
32
+	 * Used to flag when the event list is being called from an external iframe.
33
+	 *
34
+	 * @var bool $iframe
35
+	 */
36
+	protected static $iframe = false;
37 37
 
38
-    /**
38
+	/**
39 39
 	 * @var \EventEspresso\core\libraries\iframe_display\EventListIframeEmbedButton $_iframe_embed_button
40 40
 	 */
41 41
 	private static $_iframe_embed_button;
42 42
 
43
-    /**
43
+	/**
44 44
 	 * @type EE_Template_Part_Manager $template_parts
45 45
 	 */
46 46
 	protected $template_parts;
@@ -210,9 +210,9 @@  discard block
 block discarded – undo
210 210
 
211 211
 
212 212
 	/**
213
-     * most likely called by the ESPRESSO_EVENTS shortcode which uses this module to do some of it's lifting
214
-     *
215
-     * @return    void
213
+	 * most likely called by the ESPRESSO_EVENTS shortcode which uses this module to do some of it's lifting
214
+	 *
215
+	 * @return    void
216 216
 	 */
217 217
 	public function event_list() {
218 218
 		// ensure valid EE_Events_Archive_Config() object exists
@@ -223,36 +223,36 @@  discard block
 block discarded – undo
223 223
 
224 224
 
225 225
 
226
-    /**
227
-     * @access    public
228
-     * @return    void
229
-     * @throws \EE_Error
230
-     * @throws \DomainException
231
-     */
226
+	/**
227
+	 * @access    public
228
+	 * @return    void
229
+	 * @throws \EE_Error
230
+	 * @throws \DomainException
231
+	 */
232 232
 	public function event_list_iframe() {
233
-        \EED_Events_Archive::$iframe = true;
233
+		\EED_Events_Archive::$iframe = true;
234 234
 		$event_list_iframe = new EventsArchiveIframe( $this );
235 235
 		$event_list_iframe->display();
236 236
 	}
237 237
 
238 238
 
239 239
 
240
-    /**
241
-     * @access public
242
-     * @return string
243
-     */
240
+	/**
241
+	 * @access public
242
+	 * @return string
243
+	 */
244 244
 	public static function is_iframe() {
245
-        return \EED_Events_Archive::$iframe;
245
+		return \EED_Events_Archive::$iframe;
246 246
 	}
247 247
 
248 248
 
249 249
 
250
-    /**
251
-     * @access public
252
-     * @return string
253
-     */
250
+	/**
251
+	 * @access public
252
+	 * @return string
253
+	 */
254 254
 	public static function link_target() {
255
-        return \EED_Events_Archive::$iframe ? ' target="_blank"' : '';
255
+		return \EED_Events_Archive::$iframe ? ' target="_blank"' : '';
256 256
 	}
257 257
 
258 258
 
@@ -280,10 +280,10 @@  discard block
 block discarded – undo
280 280
 			}
281 281
 			// if NOT a custom template
282 282
 			if (
283
-                apply_filters('FHEE__EED_Event_Archive__template_include__allow_custom_selected_template', false)
283
+				apply_filters('FHEE__EED_Event_Archive__template_include__allow_custom_selected_template', false)
284 284
 				|| EE_Registry::instance()
285
-                    ->load_core( 'Front_Controller' )
286
-                    ->get_selected_template() !== 'archive-espresso_events.php'
285
+					->load_core( 'Front_Controller' )
286
+					->get_selected_template() !== 'archive-espresso_events.php'
287 287
 			) {
288 288
 				// don't display entry meta because the existing theme will take care of that
289 289
 				add_filter( 'FHEE__EED_Events_Archive__template_include__events_list_active', '__return_true' );
@@ -291,16 +291,16 @@  discard block
 block discarded – undo
291 291
 				EEH_Template::load_espresso_theme_functions();
292 292
 				// because we don't know if the theme is using the_excerpt()
293 293
 				add_filter(
294
-				    'the_excerpt',
295
-                    array( 'EED_Events_Archive', 'event_details' ),
296
-                    EED_Events_Archive::EVENT_DETAILS_PRIORITY
297
-                );
294
+					'the_excerpt',
295
+					array( 'EED_Events_Archive', 'event_details' ),
296
+					EED_Events_Archive::EVENT_DETAILS_PRIORITY
297
+				);
298 298
 				// or the_content
299 299
 				add_filter(
300
-				    'the_content',
301
-                    array( 'EED_Events_Archive', 'event_details' ),
302
-                    EED_Events_Archive::EVENT_DETAILS_PRIORITY
303
-                );
300
+					'the_content',
301
+					array( 'EED_Events_Archive', 'event_details' ),
302
+					EED_Events_Archive::EVENT_DETAILS_PRIORITY
303
+				);
304 304
 				// and just in case they are running get_the_excerpt() which DESTROYS things
305 305
 				add_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1, 1 );
306 306
 				// don't display entry meta because the existing theme will take care of that
@@ -325,15 +325,15 @@  discard block
 block discarded – undo
325 325
 		}
326 326
 		if ( apply_filters( 'FHEE__EED_Events_Archive__get_the_excerpt__theme_uses_get_the_excerpt', false ) ) {
327 327
 			remove_filter(
328
-			    'the_excerpt',
329
-                array( 'EED_Events_Archive', 'event_details' ),
330
-                EED_Events_Archive::EVENT_DETAILS_PRIORITY
331
-            );
328
+				'the_excerpt',
329
+				array( 'EED_Events_Archive', 'event_details' ),
330
+				EED_Events_Archive::EVENT_DETAILS_PRIORITY
331
+			);
332 332
 			remove_filter(
333
-			    'the_content',
334
-                array( 'EED_Events_Archive', 'event_details' ),
335
-                EED_Events_Archive::EVENT_DETAILS_PRIORITY
336
-            );
333
+				'the_content',
334
+				array( 'EED_Events_Archive', 'event_details' ),
335
+				EED_Events_Archive::EVENT_DETAILS_PRIORITY
336
+			);
337 337
 			$excerpt = EED_Events_Archive::event_details( $excerpt );
338 338
 		} else {
339 339
 			EED_Events_Archive::$using_get_the_excerpt = true;
@@ -424,17 +424,17 @@  discard block
 block discarded – undo
424 424
 		// no further password checks required atm
425 425
 		add_filter( 'FHEE__EED_Events_Archive__event_details__no_post_password_required', '__return_true' );
426 426
 		// we need to first remove this callback from being applied to the_content() or the_excerpt()
427
-        // (otherwise it will recurse and blow up the interweb)
427
+		// (otherwise it will recurse and blow up the interweb)
428 428
 		remove_filter(
429
-		    'the_excerpt',
430
-            array( 'EED_Events_Archive', 'event_details' ),
431
-            EED_Events_Archive::EVENT_DETAILS_PRIORITY
432
-        );
429
+			'the_excerpt',
430
+			array( 'EED_Events_Archive', 'event_details' ),
431
+			EED_Events_Archive::EVENT_DETAILS_PRIORITY
432
+		);
433 433
 		remove_filter(
434
-		    'the_content',
435
-            array( 'EED_Events_Archive', 'event_details' ),
436
-            EED_Events_Archive::EVENT_DETAILS_PRIORITY
437
-        );
434
+			'the_content',
435
+			array( 'EED_Events_Archive', 'event_details' ),
436
+			EED_Events_Archive::EVENT_DETAILS_PRIORITY
437
+		);
438 438
 		remove_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1 );
439 439
 		// now add additional content depending on whether event is using the_excerpt() or the_content()
440 440
 		EED_Events_Archive::instance()->template_parts = EED_Events_Archive::instance()->initialize_template_parts();
@@ -442,20 +442,20 @@  discard block
 block discarded – undo
442 442
 		$content = EED_Events_Archive::instance()->template_parts->apply_template_part_filters( $content );
443 443
 		// re-add our main filters (or else the next event won't have them)
444 444
 		add_filter(
445
-		    'the_excerpt',
446
-            array( 'EED_Events_Archive', 'event_details' ),
447
-            EED_Events_Archive::EVENT_DETAILS_PRIORITY
448
-        );
445
+			'the_excerpt',
446
+			array( 'EED_Events_Archive', 'event_details' ),
447
+			EED_Events_Archive::EVENT_DETAILS_PRIORITY
448
+		);
449 449
 		add_filter(
450
-		    'the_content',
451
-            array( 'EED_Events_Archive', 'event_details' ),
452
-            EED_Events_Archive::EVENT_DETAILS_PRIORITY
453
-        );
450
+			'the_content',
451
+			array( 'EED_Events_Archive', 'event_details' ),
452
+			EED_Events_Archive::EVENT_DETAILS_PRIORITY
453
+		);
454 454
 		add_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1, 1 );
455 455
 		remove_filter(
456
-		    'FHEE__EED_Events_Archive__event_details__no_post_password_required',
457
-            '__return_true'
458
-        );
456
+			'FHEE__EED_Events_Archive__event_details__no_post_password_required',
457
+			'__return_true'
458
+		);
459 459
 		return $content;
460 460
 	}
461 461
 
@@ -471,15 +471,15 @@  discard block
 block discarded – undo
471 471
 		// we need to first remove this callback from being applied to the_content()
472 472
 		// (otherwise it will recurse and blow up the interweb)
473 473
 		remove_filter(
474
-		    'the_excerpt',
475
-            array( 'EED_Events_Archive', 'event_details' ),
476
-            EED_Events_Archive::EVENT_DETAILS_PRIORITY
477
-        );
474
+			'the_excerpt',
475
+			array( 'EED_Events_Archive', 'event_details' ),
476
+			EED_Events_Archive::EVENT_DETAILS_PRIORITY
477
+		);
478 478
 		remove_filter(
479
-		    'the_content',
480
-            array( 'EED_Events_Archive', 'event_details' ),
481
-            EED_Events_Archive::EVENT_DETAILS_PRIORITY
482
-        );
479
+			'the_content',
480
+			array( 'EED_Events_Archive', 'event_details' ),
481
+			EED_Events_Archive::EVENT_DETAILS_PRIORITY
482
+		);
483 483
 		remove_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1 );
484 484
 		//now add additional content depending on whether event is using the_excerpt() or the_content()
485 485
 		EED_Events_Archive::_add_additional_excerpt_filters();
@@ -489,15 +489,15 @@  discard block
 block discarded – undo
489 489
 		$content = EEH_Template::locate_template( 'content-espresso_events-details.php' );
490 490
 		// re-add our main filters (or else the next event won't have them)
491 491
 		add_filter(
492
-		    'the_excerpt',
493
-            array( 'EED_Events_Archive', 'event_details' ),
494
-            EED_Events_Archive::EVENT_DETAILS_PRIORITY
495
-        );
492
+			'the_excerpt',
493
+			array( 'EED_Events_Archive', 'event_details' ),
494
+			EED_Events_Archive::EVENT_DETAILS_PRIORITY
495
+		);
496 496
 		add_filter(
497
-		    'the_content',
498
-            array( 'EED_Events_Archive', 'event_details' ),
499
-            EED_Events_Archive::EVENT_DETAILS_PRIORITY
500
-        );
497
+			'the_content',
498
+			array( 'EED_Events_Archive', 'event_details' ),
499
+			EED_Events_Archive::EVENT_DETAILS_PRIORITY
500
+		);
501 501
 		add_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1, 1 );
502 502
 		// but remove the other filters so that they don't get applied to the next post
503 503
 		EED_Events_Archive::_remove_additional_events_archive_filters();
@@ -574,20 +574,20 @@  discard block
 block discarded – undo
574 574
 	 */
575 575
 	private static function _add_additional_excerpt_filters() {
576 576
 		add_filter(
577
-		    'the_excerpt',
578
-            array( 'EED_Events_Archive', 'event_datetimes' ),
579
-            EED_Events_Archive::EVENT_DATETIMES_PRIORITY
580
-        );
577
+			'the_excerpt',
578
+			array( 'EED_Events_Archive', 'event_datetimes' ),
579
+			EED_Events_Archive::EVENT_DATETIMES_PRIORITY
580
+		);
581 581
 		add_filter(
582
-		    'the_excerpt',
583
-            array( 'EED_Events_Archive', 'event_tickets' ),
584
-            EED_Events_Archive::EVENT_TICKETS_PRIORITY
585
-        );
582
+			'the_excerpt',
583
+			array( 'EED_Events_Archive', 'event_tickets' ),
584
+			EED_Events_Archive::EVENT_TICKETS_PRIORITY
585
+		);
586 586
 		add_filter(
587
-		    'the_excerpt',
588
-            array( 'EED_Events_Archive', 'event_venues' ),
589
-            EED_Events_Archive::EVENT_VENUES_PRIORITY
590
-        );
587
+			'the_excerpt',
588
+			array( 'EED_Events_Archive', 'event_venues' ),
589
+			EED_Events_Archive::EVENT_VENUES_PRIORITY
590
+		);
591 591
 	}
592 592
 
593 593
 
@@ -600,20 +600,20 @@  discard block
 block discarded – undo
600 600
 	 */
601 601
 	private static function _add_additional_content_filters() {
602 602
 		add_filter(
603
-		    'the_content',
604
-            array( 'EED_Events_Archive', 'event_datetimes' ),
605
-            EED_Events_Archive::EVENT_DATETIMES_PRIORITY
606
-        );
603
+			'the_content',
604
+			array( 'EED_Events_Archive', 'event_datetimes' ),
605
+			EED_Events_Archive::EVENT_DATETIMES_PRIORITY
606
+		);
607 607
 		add_filter(
608
-		    'the_content',
609
-            array( 'EED_Events_Archive', 'event_tickets' ),
610
-            EED_Events_Archive::EVENT_TICKETS_PRIORITY
611
-        );
608
+			'the_content',
609
+			array( 'EED_Events_Archive', 'event_tickets' ),
610
+			EED_Events_Archive::EVENT_TICKETS_PRIORITY
611
+		);
612 612
 		add_filter(
613
-		    'the_content',
614
-            array( 'EED_Events_Archive', 'event_venues' ),
615
-            EED_Events_Archive::EVENT_VENUES_PRIORITY
616
-        );
613
+			'the_content',
614
+			array( 'EED_Events_Archive', 'event_venues' ),
615
+			EED_Events_Archive::EVENT_VENUES_PRIORITY
616
+		);
617 617
 	}
618 618
 
619 619
 
@@ -626,35 +626,35 @@  discard block
 block discarded – undo
626 626
 	 */
627 627
 	private static function _remove_additional_events_archive_filters() {
628 628
 		remove_filter(
629
-		    'the_excerpt',
630
-            array( 'EED_Events_Archive', 'event_datetimes' ),
631
-            EED_Events_Archive::EVENT_DATETIMES_PRIORITY
632
-        );
629
+			'the_excerpt',
630
+			array( 'EED_Events_Archive', 'event_datetimes' ),
631
+			EED_Events_Archive::EVENT_DATETIMES_PRIORITY
632
+		);
633 633
 		remove_filter(
634
-		    'the_excerpt',
635
-            array( 'EED_Events_Archive', 'event_tickets' ),
636
-            EED_Events_Archive::EVENT_TICKETS_PRIORITY
637
-        );
634
+			'the_excerpt',
635
+			array( 'EED_Events_Archive', 'event_tickets' ),
636
+			EED_Events_Archive::EVENT_TICKETS_PRIORITY
637
+		);
638 638
 		remove_filter(
639
-		    'the_excerpt',
640
-            array( 'EED_Events_Archive', 'event_venues' ),
641
-            EED_Events_Archive::EVENT_VENUES_PRIORITY
642
-        );
639
+			'the_excerpt',
640
+			array( 'EED_Events_Archive', 'event_venues' ),
641
+			EED_Events_Archive::EVENT_VENUES_PRIORITY
642
+		);
643 643
 		remove_filter(
644
-		    'the_content',
645
-            array( 'EED_Events_Archive', 'event_datetimes' ),
646
-            EED_Events_Archive::EVENT_DATETIMES_PRIORITY
647
-        );
644
+			'the_content',
645
+			array( 'EED_Events_Archive', 'event_datetimes' ),
646
+			EED_Events_Archive::EVENT_DATETIMES_PRIORITY
647
+		);
648 648
 		remove_filter(
649
-		    'the_content',
650
-            array( 'EED_Events_Archive', 'event_tickets' ),
651
-            EED_Events_Archive::EVENT_TICKETS_PRIORITY
652
-        );
649
+			'the_content',
650
+			array( 'EED_Events_Archive', 'event_tickets' ),
651
+			EED_Events_Archive::EVENT_TICKETS_PRIORITY
652
+		);
653 653
 		remove_filter(
654
-		    'the_content',
655
-            array( 'EED_Events_Archive', 'event_venues' ),
656
-            EED_Events_Archive::EVENT_VENUES_PRIORITY
657
-        );
654
+			'the_content',
655
+			array( 'EED_Events_Archive', 'event_venues' ),
656
+			EED_Events_Archive::EVENT_VENUES_PRIORITY
657
+		);
658 658
 	}
659 659
 
660 660
 
@@ -669,50 +669,50 @@  discard block
 block discarded – undo
669 669
 		//remove_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1 );
670 670
 		remove_filter( 'the_title', array( 'EED_Events_Archive', 'the_title' ), 1 );
671 671
 		remove_filter(
672
-		    'the_excerpt',
673
-            array( 'EED_Events_Archive', 'event_details' ),
674
-            EED_Events_Archive::EVENT_DETAILS_PRIORITY
675
-        );
672
+			'the_excerpt',
673
+			array( 'EED_Events_Archive', 'event_details' ),
674
+			EED_Events_Archive::EVENT_DETAILS_PRIORITY
675
+		);
676 676
 		remove_filter(
677
-		    'the_excerpt',
678
-            array( 'EED_Events_Archive', 'event_datetimes' ),
679
-            EED_Events_Archive::EVENT_DATETIMES_PRIORITY
680
-        );
677
+			'the_excerpt',
678
+			array( 'EED_Events_Archive', 'event_datetimes' ),
679
+			EED_Events_Archive::EVENT_DATETIMES_PRIORITY
680
+		);
681 681
 		remove_filter(
682
-		    'the_excerpt',
683
-            array( 'EED_Events_Archive', 'event_tickets' ),
684
-            EED_Events_Archive::EVENT_TICKETS_PRIORITY
685
-        );
682
+			'the_excerpt',
683
+			array( 'EED_Events_Archive', 'event_tickets' ),
684
+			EED_Events_Archive::EVENT_TICKETS_PRIORITY
685
+		);
686 686
 		remove_filter(
687
-		    'the_excerpt',
688
-            array( 'EED_Events_Archive', 'event_venues' ),
689
-            EED_Events_Archive::EVENT_VENUES_PRIORITY
690
-        );
687
+			'the_excerpt',
688
+			array( 'EED_Events_Archive', 'event_venues' ),
689
+			EED_Events_Archive::EVENT_VENUES_PRIORITY
690
+		);
691 691
 		remove_filter(
692
-		    'the_content',
693
-            array( 'EED_Events_Archive', 'event_details' ),
694
-            EED_Events_Archive::EVENT_DETAILS_PRIORITY
695
-        );
692
+			'the_content',
693
+			array( 'EED_Events_Archive', 'event_details' ),
694
+			EED_Events_Archive::EVENT_DETAILS_PRIORITY
695
+		);
696 696
 		remove_filter(
697
-		    'the_content',
698
-            array( 'EED_Events_Archive', 'event_datetimes' ),
699
-            EED_Events_Archive::EVENT_DATETIMES_PRIORITY
700
-        );
697
+			'the_content',
698
+			array( 'EED_Events_Archive', 'event_datetimes' ),
699
+			EED_Events_Archive::EVENT_DATETIMES_PRIORITY
700
+		);
701 701
 		remove_filter(
702
-		    'the_content',
703
-            array( 'EED_Events_Archive', 'event_tickets' ),
704
-            EED_Events_Archive::EVENT_TICKETS_PRIORITY
705
-        );
702
+			'the_content',
703
+			array( 'EED_Events_Archive', 'event_tickets' ),
704
+			EED_Events_Archive::EVENT_TICKETS_PRIORITY
705
+		);
706 706
 		remove_filter(
707
-		    'the_content',
708
-            array( 'EED_Events_Archive', 'event_venues' ),
709
-            EED_Events_Archive::EVENT_VENUES_PRIORITY
710
-        );
707
+			'the_content',
708
+			array( 'EED_Events_Archive', 'event_venues' ),
709
+			EED_Events_Archive::EVENT_VENUES_PRIORITY
710
+		);
711 711
 		// don't display entry meta because the existing theme will take care of that
712 712
 		remove_filter(
713
-		    'FHEE__content_espresso_events_details_template__display_entry_meta',
714
-            '__return_false'
715
-        );
713
+			'FHEE__content_espresso_events_details_template__display_entry_meta',
714
+			'__return_false'
715
+		);
716 716
 	}
717 717
 
718 718
 
@@ -727,7 +727,7 @@  discard block
 block discarded – undo
727 727
 	 *  @return 	void
728 728
 	 */
729 729
 	public function load_event_list_assets() {
730
-        do_action( 'AHEE__EED_Events_Archive__before_load_assets' );
730
+		do_action( 'AHEE__EED_Events_Archive__before_load_assets' );
731 731
 		add_filter( 'FHEE_load_EE_Session', '__return_true' );
732 732
 		add_filter( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true' );
733 733
 		add_action('wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ), 10 );
Please login to merge, or discard this patch.
Spacing   +175 added lines, -175 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 use EventEspresso\core\libraries\iframe_display\EventListIframeEmbedButton;
4 4
 use EventEspresso\modules\events_archive\EventsArchiveIframe;
5 5
 
6
-defined( 'EVENT_ESPRESSO_VERSION') || exit('No direct script access allowed');
6
+defined('EVENT_ESPRESSO_VERSION') || exit('No direct script access allowed');
7 7
 
8 8
 /**
9 9
  * Event List
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 	 * @return EED_Events_Archive
52 52
 	 */
53 53
 	public static function instance() {
54
-		return parent::get_instance( __CLASS__ );
54
+		return parent::get_instance(__CLASS__);
55 55
 	}
56 56
 
57 57
 
@@ -63,10 +63,10 @@  discard block
 block discarded – undo
63 63
 	 *  @return 	void
64 64
 	 */
65 65
 	public static function set_hooks() {
66
-		EE_Config::register_route( EE_Registry::instance()->CFG->core->event_cpt_slug, 'Events_Archive', 'run' );
67
-		EE_Config::register_route( 'event_list', 'Events_Archive', 'event_list' );
68
-		EE_Config::register_route( 'iframe', 'Events_Archive', 'event_list_iframe', 'event_list' );
69
-		add_action( 'wp_loaded', array( 'EED_Events_Archive', 'set_definitions' ), 2 );
66
+		EE_Config::register_route(EE_Registry::instance()->CFG->core->event_cpt_slug, 'Events_Archive', 'run');
67
+		EE_Config::register_route('event_list', 'Events_Archive', 'event_list');
68
+		EE_Config::register_route('iframe', 'Events_Archive', 'event_list_iframe', 'event_list');
69
+		add_action('wp_loaded', array('EED_Events_Archive', 'set_definitions'), 2);
70 70
 	}
71 71
 
72 72
 	/**
@@ -76,12 +76,12 @@  discard block
 block discarded – undo
76 76
 	 *  @return 	void
77 77
 	 */
78 78
 	public static function set_hooks_admin() {
79
-		add_action( 'wp_loaded', array( 'EED_Events_Archive', 'set_definitions' ), 2 );
79
+		add_action('wp_loaded', array('EED_Events_Archive', 'set_definitions'), 2);
80 80
 		// hook into the end of the \EE_Admin_Page::_load_page_dependencies()
81 81
 		// to load assets for "espresso_events" page on the "default" route (action)
82 82
 		add_action(
83 83
 			'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_events__default',
84
-			array( 'EED_Events_Archive', 'event_list_iframe_embed_button' ),
84
+			array('EED_Events_Archive', 'event_list_iframe_embed_button'),
85 85
 			10
86 86
 		);
87 87
 	}
@@ -96,8 +96,8 @@  discard block
 block discarded – undo
96 96
 	 *  @return 	void
97 97
 	 */
98 98
 	public static function set_definitions() {
99
-		define( 'EVENTS_ARCHIVE_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets' . DS );
100
-		define( 'EVENTS_ARCHIVE_TEMPLATES_PATH', str_replace( '\\', DS, plugin_dir_path( __FILE__ )) . 'templates' . DS );
99
+		define('EVENTS_ARCHIVE_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS);
100
+		define('EVENTS_ARCHIVE_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)).'templates'.DS);
101 101
 	}
102 102
 
103 103
 
@@ -105,10 +105,10 @@  discard block
 block discarded – undo
105 105
 	/**
106 106
 	 * set up EE_Events_Archive_Config
107 107
 	 */
108
-	protected function set_config(){
109
-		$this->set_config_section( 'template_settings' );
110
-		$this->set_config_class( 'EE_Events_Archive_Config' );
111
-		$this->set_config_name( 'EED_Events_Archive' );
108
+	protected function set_config() {
109
+		$this->set_config_section('template_settings');
110
+		$this->set_config_class('EE_Events_Archive_Config');
111
+		$this->set_config_name('EED_Events_Archive');
112 112
 	}
113 113
 
114 114
 
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 	 * @return EventListIframeEmbedButton
118 118
 	 */
119 119
 	public static function get_iframe_embed_button() {
120
-		if ( ! self::$_iframe_embed_button instanceof EventListIframeEmbedButton ) {
120
+		if ( ! self::$_iframe_embed_button instanceof EventListIframeEmbedButton) {
121 121
 			self::$_iframe_embed_button = new EventListIframeEmbedButton();
122 122
 		}
123 123
 		return self::$_iframe_embed_button;
@@ -143,35 +143,35 @@  discard block
 block discarded – undo
143 143
 	 * @param \EE_Events_Archive_Config $config
144 144
 	 * @return \EE_Template_Part_Manager
145 145
 	 */
146
-	public function initialize_template_parts( EE_Events_Archive_Config $config = null ) {
146
+	public function initialize_template_parts(EE_Events_Archive_Config $config = null) {
147 147
 		$config = $config instanceof EE_Events_Archive_Config ? $config : $this->config();
148 148
 		EEH_Autoloader::instance()->register_template_part_autoloaders();
149 149
 		$template_parts = new EE_Template_Part_Manager();
150 150
 		$template_parts->add_template_part(
151 151
 			'tickets',
152
-			__( 'Ticket Selector', 'event_espresso' ),
152
+			__('Ticket Selector', 'event_espresso'),
153 153
 			'content-espresso_events-tickets.php',
154 154
 			$config->display_order_tickets
155 155
 		);
156 156
 		$template_parts->add_template_part(
157 157
 			'datetimes',
158
-			__( 'Dates and Times', 'event_espresso' ),
158
+			__('Dates and Times', 'event_espresso'),
159 159
 			'content-espresso_events-datetimes.php',
160 160
 			$config->display_order_datetimes
161 161
 		);
162 162
 		$template_parts->add_template_part(
163 163
 			'event',
164
-			__( 'Event Description', 'event_espresso' ),
164
+			__('Event Description', 'event_espresso'),
165 165
 			'content-espresso_events-details.php',
166 166
 			$config->display_order_event
167 167
 		);
168 168
 		$template_parts->add_template_part(
169 169
 			'venue',
170
-			__( 'Venue Information', 'event_espresso' ),
170
+			__('Venue Information', 'event_espresso'),
171 171
 			'content-espresso_events-venues.php',
172 172
 			$config->display_order_venue
173 173
 		);
174
-		do_action( 'AHEE__EED_Event_Archive__initialize_template_parts', $template_parts );
174
+		do_action('AHEE__EED_Event_Archive__initialize_template_parts', $template_parts);
175 175
 		return $template_parts;
176 176
 	}
177 177
 
@@ -184,8 +184,8 @@  discard block
 block discarded – undo
184 184
 	 * @param WP $WP
185 185
 	 * @return    void
186 186
 	 */
187
-	public function run( $WP ) {
188
-		do_action( 'AHEE__EED_Events_Archive__before_run' );
187
+	public function run($WP) {
188
+		do_action('AHEE__EED_Events_Archive__before_run');
189 189
 		// ensure valid EE_Events_Archive_Config() object exists
190 190
 		$this->set_config();
191 191
 		/** @type EE_Events_Archive_Config $config */
@@ -197,14 +197,14 @@  discard block
 block discarded – undo
197 197
 		EEH_Event_Query::add_query_filters();
198 198
 		// set params that will get used by the filters
199 199
 		EEH_Event_Query::set_query_params(
200
-			'', 	// month
201
-			'', 	// category
202
-			$config->display_expired_events, 	// show_expired
203
-			'start_date', 	// orderby
200
+			'', // month
201
+			'', // category
202
+			$config->display_expired_events, // show_expired
203
+			'start_date', // orderby
204 204
 			'ASC' 	// sort
205 205
 		);
206 206
 		// check what template is loaded
207
-		add_filter( 'template_include',  array( $this, 'template_include' ), 999, 1 );
207
+		add_filter('template_include', array($this, 'template_include'), 999, 1);
208 208
 	}
209 209
 
210 210
 
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
      */
232 232
 	public function event_list_iframe() {
233 233
         \EED_Events_Archive::$iframe = true;
234
-		$event_list_iframe = new EventsArchiveIframe( $this );
234
+		$event_list_iframe = new EventsArchiveIframe($this);
235 235
 		$event_list_iframe->display();
236 236
 	}
237 237
 
@@ -269,42 +269,42 @@  discard block
 block discarded – undo
269 269
 	 * @param string $template
270 270
 	 * @return    string
271 271
 	 */
272
-	public function template_include( $template = '' ) {
272
+	public function template_include($template = '') {
273 273
 		// don't add content filter for dedicated EE child themes or private posts
274
-		if ( ! EEH_Template::is_espresso_theme() ) {
274
+		if ( ! EEH_Template::is_espresso_theme()) {
275 275
 			/** @type EE_Events_Archive_Config $config */
276 276
 			$config = $this->config();
277 277
 			// add status banner ?
278
-			if ( $config->display_status_banner ) {
279
-				add_filter( 'the_title', array( 'EED_Events_Archive', 'the_title' ), 100, 2 );
278
+			if ($config->display_status_banner) {
279
+				add_filter('the_title', array('EED_Events_Archive', 'the_title'), 100, 2);
280 280
 			}
281 281
 			// if NOT a custom template
282 282
 			if (
283 283
                 apply_filters('FHEE__EED_Event_Archive__template_include__allow_custom_selected_template', false)
284 284
 				|| EE_Registry::instance()
285
-                    ->load_core( 'Front_Controller' )
285
+                    ->load_core('Front_Controller')
286 286
                     ->get_selected_template() !== 'archive-espresso_events.php'
287 287
 			) {
288 288
 				// don't display entry meta because the existing theme will take care of that
289
-				add_filter( 'FHEE__EED_Events_Archive__template_include__events_list_active', '__return_true' );
289
+				add_filter('FHEE__EED_Events_Archive__template_include__events_list_active', '__return_true');
290 290
 			// load functions.php file for the theme (loaded by WP if using child theme)
291 291
 				EEH_Template::load_espresso_theme_functions();
292 292
 				// because we don't know if the theme is using the_excerpt()
293 293
 				add_filter(
294 294
 				    'the_excerpt',
295
-                    array( 'EED_Events_Archive', 'event_details' ),
295
+                    array('EED_Events_Archive', 'event_details'),
296 296
                     EED_Events_Archive::EVENT_DETAILS_PRIORITY
297 297
                 );
298 298
 				// or the_content
299 299
 				add_filter(
300 300
 				    'the_content',
301
-                    array( 'EED_Events_Archive', 'event_details' ),
301
+                    array('EED_Events_Archive', 'event_details'),
302 302
                     EED_Events_Archive::EVENT_DETAILS_PRIORITY
303 303
                 );
304 304
 				// and just in case they are running get_the_excerpt() which DESTROYS things
305
-				add_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1, 1 );
305
+				add_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1, 1);
306 306
 				// don't display entry meta because the existing theme will take care of that
307
-				add_filter( 'FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false' );
307
+				add_filter('FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false');
308 308
 			}
309 309
 		}
310 310
 		return $template;
@@ -319,25 +319,25 @@  discard block
 block discarded – undo
319 319
 	 * 	@param		string 	$excerpt
320 320
 	 * 	@return 		string
321 321
 	 */
322
-	public static function get_the_excerpt( $excerpt = '' ) {
323
-		if ( post_password_required() ) {
322
+	public static function get_the_excerpt($excerpt = '') {
323
+		if (post_password_required()) {
324 324
 			return $excerpt;
325 325
 		}
326
-		if ( apply_filters( 'FHEE__EED_Events_Archive__get_the_excerpt__theme_uses_get_the_excerpt', false ) ) {
326
+		if (apply_filters('FHEE__EED_Events_Archive__get_the_excerpt__theme_uses_get_the_excerpt', false)) {
327 327
 			remove_filter(
328 328
 			    'the_excerpt',
329
-                array( 'EED_Events_Archive', 'event_details' ),
329
+                array('EED_Events_Archive', 'event_details'),
330 330
                 EED_Events_Archive::EVENT_DETAILS_PRIORITY
331 331
             );
332 332
 			remove_filter(
333 333
 			    'the_content',
334
-                array( 'EED_Events_Archive', 'event_details' ),
334
+                array('EED_Events_Archive', 'event_details'),
335 335
                 EED_Events_Archive::EVENT_DETAILS_PRIORITY
336 336
             );
337
-			$excerpt = EED_Events_Archive::event_details( $excerpt );
337
+			$excerpt = EED_Events_Archive::event_details($excerpt);
338 338
 		} else {
339 339
 			EED_Events_Archive::$using_get_the_excerpt = true;
340
-			add_filter( 'wp_trim_excerpt', array( 'EED_Events_Archive', 'end_get_the_excerpt' ), 999, 1 );
340
+			add_filter('wp_trim_excerpt', array('EED_Events_Archive', 'end_get_the_excerpt'), 999, 1);
341 341
 		}
342 342
 		return $excerpt;
343 343
 	}
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
 	 * @param  string $text
352 352
 	 * @return string
353 353
 	 */
354
-	public static function end_get_the_excerpt( $text = '' ) {
354
+	public static function end_get_the_excerpt($text = '') {
355 355
 		EED_Events_Archive::$using_get_the_excerpt = false;
356 356
 		return $text;
357 357
 	}
@@ -366,10 +366,10 @@  discard block
 block discarded – undo
366 366
 	 * @param 		string 		$id
367 367
 	 * @return 		string
368 368
 	 */
369
-	public static function the_title( $title = '', $id = '' ) {
369
+	public static function the_title($title = '', $id = '') {
370 370
 	global $post;
371
-	if ( $post instanceof WP_Post ) {
372
-		return in_the_loop() && $post->ID == $id ? espresso_event_status_banner( $post->ID  ) . $title :  $title;
371
+	if ($post instanceof WP_Post) {
372
+		return in_the_loop() && $post->ID == $id ? espresso_event_status_banner($post->ID).$title : $title;
373 373
 	}
374 374
 	return $title;
375 375
 }
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
 	 * 	@param		string 	$content
384 384
 	 * 	@return 		string
385 385
 	 */
386
-	public static function event_details( $content ) {
386
+	public static function event_details($content) {
387 387
 		global $post;
388 388
 		static $current_post_ID = 0;
389 389
 		if (
@@ -392,8 +392,8 @@  discard block
 block discarded – undo
392 392
 			&& ! EED_Events_Archive::$using_get_the_excerpt
393 393
 			&& ! post_password_required()
394 394
 			&& (
395
-				apply_filters( 'FHEE__EES_Espresso_Events__process_shortcode__true', false )
396
-				|| ! apply_filters( 'FHEE__content_espresso_events__template_loaded', false )
395
+				apply_filters('FHEE__EES_Espresso_Events__process_shortcode__true', false)
396
+				|| ! apply_filters('FHEE__content_espresso_events__template_loaded', false)
397 397
 			)
398 398
 		) {
399 399
 			// Set current post ID to prevent showing content twice, but only if headers have definitely been sent.
@@ -402,8 +402,8 @@  discard block
 block discarded – undo
402 402
 			// We want to allow those plugins to still do their thing and have access to our content, but depending on
403 403
 			// how your event content is being displayed (shortcode, CPT route, etc), this filter can get applied twice,
404 404
 			// so the following allows this filter to be applied multiple times, but only once for real
405
-			$current_post_ID = did_action( 'loop_start' ) ? $post->ID : 0;
406
-			if ( EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->use_sortable_display_order ) {
405
+			$current_post_ID = did_action('loop_start') ? $post->ID : 0;
406
+			if (EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->use_sortable_display_order) {
407 407
 				$content = \EED_Events_Archive::use_sortable_display_order();
408 408
 			} else {
409 409
 				$content = \EED_Events_Archive::use_filterable_display_order();
@@ -422,36 +422,36 @@  discard block
 block discarded – undo
422 422
 	 */
423 423
 	protected static function use_sortable_display_order() {
424 424
 		// no further password checks required atm
425
-		add_filter( 'FHEE__EED_Events_Archive__event_details__no_post_password_required', '__return_true' );
425
+		add_filter('FHEE__EED_Events_Archive__event_details__no_post_password_required', '__return_true');
426 426
 		// we need to first remove this callback from being applied to the_content() or the_excerpt()
427 427
         // (otherwise it will recurse and blow up the interweb)
428 428
 		remove_filter(
429 429
 		    'the_excerpt',
430
-            array( 'EED_Events_Archive', 'event_details' ),
430
+            array('EED_Events_Archive', 'event_details'),
431 431
             EED_Events_Archive::EVENT_DETAILS_PRIORITY
432 432
         );
433 433
 		remove_filter(
434 434
 		    'the_content',
435
-            array( 'EED_Events_Archive', 'event_details' ),
435
+            array('EED_Events_Archive', 'event_details'),
436 436
             EED_Events_Archive::EVENT_DETAILS_PRIORITY
437 437
         );
438
-		remove_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1 );
438
+		remove_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1);
439 439
 		// now add additional content depending on whether event is using the_excerpt() or the_content()
440 440
 		EED_Events_Archive::instance()->template_parts = EED_Events_Archive::instance()->initialize_template_parts();
441
-		$content = EEH_Template::locate_template( 'content-espresso_events-details.php' );
442
-		$content = EED_Events_Archive::instance()->template_parts->apply_template_part_filters( $content );
441
+		$content = EEH_Template::locate_template('content-espresso_events-details.php');
442
+		$content = EED_Events_Archive::instance()->template_parts->apply_template_part_filters($content);
443 443
 		// re-add our main filters (or else the next event won't have them)
444 444
 		add_filter(
445 445
 		    'the_excerpt',
446
-            array( 'EED_Events_Archive', 'event_details' ),
446
+            array('EED_Events_Archive', 'event_details'),
447 447
             EED_Events_Archive::EVENT_DETAILS_PRIORITY
448 448
         );
449 449
 		add_filter(
450 450
 		    'the_content',
451
-            array( 'EED_Events_Archive', 'event_details' ),
451
+            array('EED_Events_Archive', 'event_details'),
452 452
             EED_Events_Archive::EVENT_DETAILS_PRIORITY
453 453
         );
454
-		add_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1, 1 );
454
+		add_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1, 1);
455 455
 		remove_filter(
456 456
 		    'FHEE__EED_Events_Archive__event_details__no_post_password_required',
457 457
             '__return_true'
@@ -472,36 +472,36 @@  discard block
 block discarded – undo
472 472
 		// (otherwise it will recurse and blow up the interweb)
473 473
 		remove_filter(
474 474
 		    'the_excerpt',
475
-            array( 'EED_Events_Archive', 'event_details' ),
475
+            array('EED_Events_Archive', 'event_details'),
476 476
             EED_Events_Archive::EVENT_DETAILS_PRIORITY
477 477
         );
478 478
 		remove_filter(
479 479
 		    'the_content',
480
-            array( 'EED_Events_Archive', 'event_details' ),
480
+            array('EED_Events_Archive', 'event_details'),
481 481
             EED_Events_Archive::EVENT_DETAILS_PRIORITY
482 482
         );
483
-		remove_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1 );
483
+		remove_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1);
484 484
 		//now add additional content depending on whether event is using the_excerpt() or the_content()
485 485
 		EED_Events_Archive::_add_additional_excerpt_filters();
486 486
 		EED_Events_Archive::_add_additional_content_filters();
487
-		do_action( 'AHEE__EED_Events_Archive__use_filterable_display_order__after_add_filters' );
487
+		do_action('AHEE__EED_Events_Archive__use_filterable_display_order__after_add_filters');
488 488
 		// now load our template
489
-		$content = EEH_Template::locate_template( 'content-espresso_events-details.php' );
489
+		$content = EEH_Template::locate_template('content-espresso_events-details.php');
490 490
 		// re-add our main filters (or else the next event won't have them)
491 491
 		add_filter(
492 492
 		    'the_excerpt',
493
-            array( 'EED_Events_Archive', 'event_details' ),
493
+            array('EED_Events_Archive', 'event_details'),
494 494
             EED_Events_Archive::EVENT_DETAILS_PRIORITY
495 495
         );
496 496
 		add_filter(
497 497
 		    'the_content',
498
-            array( 'EED_Events_Archive', 'event_details' ),
498
+            array('EED_Events_Archive', 'event_details'),
499 499
             EED_Events_Archive::EVENT_DETAILS_PRIORITY
500 500
         );
501
-		add_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1, 1 );
501
+		add_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1, 1);
502 502
 		// but remove the other filters so that they don't get applied to the next post
503 503
 		EED_Events_Archive::_remove_additional_events_archive_filters();
504
-		do_action( 'AHEE__EED_Events_Archive__use_filterable_display_order__after_remove_filters' );
504
+		do_action('AHEE__EED_Events_Archive__use_filterable_display_order__after_remove_filters');
505 505
 		// we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt)
506 506
 		//return ! empty( $template ) ? $template : $content;
507 507
 		return $content;
@@ -516,11 +516,11 @@  discard block
 block discarded – undo
516 516
 	 * 	@param		string 	$content
517 517
 	 *  	@return 		string
518 518
 	 */
519
-	public static function event_datetimes( $content ) {
520
-		if ( post_password_required() ) {
519
+	public static function event_datetimes($content) {
520
+		if (post_password_required()) {
521 521
 			return $content;
522 522
 		}
523
-		return EEH_Template::locate_template( 'content-espresso_events-datetimes.php' ) . $content;
523
+		return EEH_Template::locate_template('content-espresso_events-datetimes.php').$content;
524 524
 	}
525 525
 
526 526
 	/**
@@ -530,11 +530,11 @@  discard block
 block discarded – undo
530 530
 	 * 	@param		string 	$content
531 531
 	 *  	@return 		string
532 532
 	 */
533
-	public static function event_tickets( $content ) {
534
-		if ( post_password_required() ) {
533
+	public static function event_tickets($content) {
534
+		if (post_password_required()) {
535 535
 			return $content;
536 536
 		}
537
-		return EEH_Template::locate_template( 'content-espresso_events-tickets.php' ) . $content;
537
+		return EEH_Template::locate_template('content-espresso_events-tickets.php').$content;
538 538
 	}
539 539
 
540 540
 
@@ -546,8 +546,8 @@  discard block
 block discarded – undo
546 546
 	 * @param    string $content
547 547
 	 * @return    string
548 548
 	 */
549
-	public static function event_venue( $content ) {
550
-		return EED_Events_Archive::event_venues( $content );
549
+	public static function event_venue($content) {
550
+		return EED_Events_Archive::event_venues($content);
551 551
 	}
552 552
 
553 553
 	/**
@@ -557,11 +557,11 @@  discard block
 block discarded – undo
557 557
 	 * 	@param		string 	$content
558 558
 	 *  	@return 		string
559 559
 	 */
560
-	public static function event_venues( $content ) {
561
-		if ( post_password_required() ) {
560
+	public static function event_venues($content) {
561
+		if (post_password_required()) {
562 562
 			return $content;
563 563
 		}
564
-		return $content . EEH_Template::locate_template( 'content-espresso_events-venues.php' );
564
+		return $content.EEH_Template::locate_template('content-espresso_events-venues.php');
565 565
 	}
566 566
 
567 567
 
@@ -575,17 +575,17 @@  discard block
 block discarded – undo
575 575
 	private static function _add_additional_excerpt_filters() {
576 576
 		add_filter(
577 577
 		    'the_excerpt',
578
-            array( 'EED_Events_Archive', 'event_datetimes' ),
578
+            array('EED_Events_Archive', 'event_datetimes'),
579 579
             EED_Events_Archive::EVENT_DATETIMES_PRIORITY
580 580
         );
581 581
 		add_filter(
582 582
 		    'the_excerpt',
583
-            array( 'EED_Events_Archive', 'event_tickets' ),
583
+            array('EED_Events_Archive', 'event_tickets'),
584 584
             EED_Events_Archive::EVENT_TICKETS_PRIORITY
585 585
         );
586 586
 		add_filter(
587 587
 		    'the_excerpt',
588
-            array( 'EED_Events_Archive', 'event_venues' ),
588
+            array('EED_Events_Archive', 'event_venues'),
589 589
             EED_Events_Archive::EVENT_VENUES_PRIORITY
590 590
         );
591 591
 	}
@@ -601,17 +601,17 @@  discard block
 block discarded – undo
601 601
 	private static function _add_additional_content_filters() {
602 602
 		add_filter(
603 603
 		    'the_content',
604
-            array( 'EED_Events_Archive', 'event_datetimes' ),
604
+            array('EED_Events_Archive', 'event_datetimes'),
605 605
             EED_Events_Archive::EVENT_DATETIMES_PRIORITY
606 606
         );
607 607
 		add_filter(
608 608
 		    'the_content',
609
-            array( 'EED_Events_Archive', 'event_tickets' ),
609
+            array('EED_Events_Archive', 'event_tickets'),
610 610
             EED_Events_Archive::EVENT_TICKETS_PRIORITY
611 611
         );
612 612
 		add_filter(
613 613
 		    'the_content',
614
-            array( 'EED_Events_Archive', 'event_venues' ),
614
+            array('EED_Events_Archive', 'event_venues'),
615 615
             EED_Events_Archive::EVENT_VENUES_PRIORITY
616 616
         );
617 617
 	}
@@ -627,32 +627,32 @@  discard block
 block discarded – undo
627 627
 	private static function _remove_additional_events_archive_filters() {
628 628
 		remove_filter(
629 629
 		    'the_excerpt',
630
-            array( 'EED_Events_Archive', 'event_datetimes' ),
630
+            array('EED_Events_Archive', 'event_datetimes'),
631 631
             EED_Events_Archive::EVENT_DATETIMES_PRIORITY
632 632
         );
633 633
 		remove_filter(
634 634
 		    'the_excerpt',
635
-            array( 'EED_Events_Archive', 'event_tickets' ),
635
+            array('EED_Events_Archive', 'event_tickets'),
636 636
             EED_Events_Archive::EVENT_TICKETS_PRIORITY
637 637
         );
638 638
 		remove_filter(
639 639
 		    'the_excerpt',
640
-            array( 'EED_Events_Archive', 'event_venues' ),
640
+            array('EED_Events_Archive', 'event_venues'),
641 641
             EED_Events_Archive::EVENT_VENUES_PRIORITY
642 642
         );
643 643
 		remove_filter(
644 644
 		    'the_content',
645
-            array( 'EED_Events_Archive', 'event_datetimes' ),
645
+            array('EED_Events_Archive', 'event_datetimes'),
646 646
             EED_Events_Archive::EVENT_DATETIMES_PRIORITY
647 647
         );
648 648
 		remove_filter(
649 649
 		    'the_content',
650
-            array( 'EED_Events_Archive', 'event_tickets' ),
650
+            array('EED_Events_Archive', 'event_tickets'),
651 651
             EED_Events_Archive::EVENT_TICKETS_PRIORITY
652 652
         );
653 653
 		remove_filter(
654 654
 		    'the_content',
655
-            array( 'EED_Events_Archive', 'event_venues' ),
655
+            array('EED_Events_Archive', 'event_venues'),
656 656
             EED_Events_Archive::EVENT_VENUES_PRIORITY
657 657
         );
658 658
 	}
@@ -667,45 +667,45 @@  discard block
 block discarded – undo
667 667
 	 */
668 668
 	public static function remove_all_events_archive_filters() {
669 669
 		//remove_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1 );
670
-		remove_filter( 'the_title', array( 'EED_Events_Archive', 'the_title' ), 1 );
670
+		remove_filter('the_title', array('EED_Events_Archive', 'the_title'), 1);
671 671
 		remove_filter(
672 672
 		    'the_excerpt',
673
-            array( 'EED_Events_Archive', 'event_details' ),
673
+            array('EED_Events_Archive', 'event_details'),
674 674
             EED_Events_Archive::EVENT_DETAILS_PRIORITY
675 675
         );
676 676
 		remove_filter(
677 677
 		    'the_excerpt',
678
-            array( 'EED_Events_Archive', 'event_datetimes' ),
678
+            array('EED_Events_Archive', 'event_datetimes'),
679 679
             EED_Events_Archive::EVENT_DATETIMES_PRIORITY
680 680
         );
681 681
 		remove_filter(
682 682
 		    'the_excerpt',
683
-            array( 'EED_Events_Archive', 'event_tickets' ),
683
+            array('EED_Events_Archive', 'event_tickets'),
684 684
             EED_Events_Archive::EVENT_TICKETS_PRIORITY
685 685
         );
686 686
 		remove_filter(
687 687
 		    'the_excerpt',
688
-            array( 'EED_Events_Archive', 'event_venues' ),
688
+            array('EED_Events_Archive', 'event_venues'),
689 689
             EED_Events_Archive::EVENT_VENUES_PRIORITY
690 690
         );
691 691
 		remove_filter(
692 692
 		    'the_content',
693
-            array( 'EED_Events_Archive', 'event_details' ),
693
+            array('EED_Events_Archive', 'event_details'),
694 694
             EED_Events_Archive::EVENT_DETAILS_PRIORITY
695 695
         );
696 696
 		remove_filter(
697 697
 		    'the_content',
698
-            array( 'EED_Events_Archive', 'event_datetimes' ),
698
+            array('EED_Events_Archive', 'event_datetimes'),
699 699
             EED_Events_Archive::EVENT_DATETIMES_PRIORITY
700 700
         );
701 701
 		remove_filter(
702 702
 		    'the_content',
703
-            array( 'EED_Events_Archive', 'event_tickets' ),
703
+            array('EED_Events_Archive', 'event_tickets'),
704 704
             EED_Events_Archive::EVENT_TICKETS_PRIORITY
705 705
         );
706 706
 		remove_filter(
707 707
 		    'the_content',
708
-            array( 'EED_Events_Archive', 'event_venues' ),
708
+            array('EED_Events_Archive', 'event_venues'),
709 709
             EED_Events_Archive::EVENT_VENUES_PRIORITY
710 710
         );
711 711
 		// don't display entry meta because the existing theme will take care of that
@@ -727,12 +727,12 @@  discard block
 block discarded – undo
727 727
 	 *  @return 	void
728 728
 	 */
729 729
 	public function load_event_list_assets() {
730
-        do_action( 'AHEE__EED_Events_Archive__before_load_assets' );
731
-		add_filter( 'FHEE_load_EE_Session', '__return_true' );
732
-		add_filter( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true' );
733
-		add_action('wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ), 10 );
734
-		if ( EE_Registry::instance()->CFG->map_settings->use_google_maps ) {
735
-			add_action('wp_enqueue_scripts', array( 'EEH_Maps', 'espresso_google_map_js' ), 11 );
730
+        do_action('AHEE__EED_Events_Archive__before_load_assets');
731
+		add_filter('FHEE_load_EE_Session', '__return_true');
732
+		add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
733
+		add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10);
734
+		if (EE_Registry::instance()->CFG->map_settings->use_google_maps) {
735
+			add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11);
736 736
 		}
737 737
 	}
738 738
 
@@ -749,13 +749,13 @@  discard block
 block discarded – undo
749 749
 	 */
750 750
 	public function wp_enqueue_scripts() {
751 751
 		// get some style
752
-		if ( apply_filters( 'FHEE_enable_default_espresso_css', FALSE ) ) {
752
+		if (apply_filters('FHEE_enable_default_espresso_css', FALSE)) {
753 753
 			// first check uploads folder
754
-			if ( EEH_File::is_readable( get_stylesheet_directory() . $this->theme . DS . 'style.css' )) {
755
-				wp_register_style( $this->theme, get_stylesheet_directory_uri() . $this->theme . DS . 'style.css', array( 'dashicons', 'espresso_default' ));
754
+			if (EEH_File::is_readable(get_stylesheet_directory().$this->theme.DS.'style.css')) {
755
+				wp_register_style($this->theme, get_stylesheet_directory_uri().$this->theme.DS.'style.css', array('dashicons', 'espresso_default'));
756 756
 			} else {
757 757
 		}
758
-		wp_enqueue_style( $this->theme );
758
+		wp_enqueue_style($this->theme);
759 759
 
760 760
 	}
761 761
 }
@@ -773,8 +773,8 @@  discard block
 block discarded – undo
773 773
 	 */
774 774
 	public static function template_settings_form() {
775 775
 	$template_settings = EE_Registry::instance()->CFG->template_settings;
776
-	$template_settings->EED_Events_Archive = isset( $template_settings->EED_Events_Archive ) ? $template_settings->EED_Events_Archive : new EE_Events_Archive_Config();
777
-	$template_settings->EED_Events_Archive = apply_filters( 'FHEE__EED_Events_Archive__template_settings_form__event_list_config', $template_settings->EED_Events_Archive );
776
+	$template_settings->EED_Events_Archive = isset($template_settings->EED_Events_Archive) ? $template_settings->EED_Events_Archive : new EE_Events_Archive_Config();
777
+	$template_settings->EED_Events_Archive = apply_filters('FHEE__EED_Events_Archive__template_settings_form__event_list_config', $template_settings->EED_Events_Archive);
778 778
 	$events_archive_settings = array(
779 779
 		'display_status_banner' => 0,
780 780
 		'display_description' => 1,
@@ -783,8 +783,8 @@  discard block
 block discarded – undo
783 783
 		'display_venue' => 0,
784 784
 		'display_expired_events' => 0
785 785
 	);
786
-	$events_archive_settings = array_merge( $events_archive_settings, (array)$template_settings->EED_Events_Archive );
787
-	EEH_Template::display_template( EVENTS_ARCHIVE_TEMPLATES_PATH . 'admin-event-list-settings.template.php', $events_archive_settings );
786
+	$events_archive_settings = array_merge($events_archive_settings, (array) $template_settings->EED_Events_Archive);
787
+	EEH_Template::display_template(EVENTS_ARCHIVE_TEMPLATES_PATH.'admin-event-list-settings.template.php', $events_archive_settings);
788 788
 }
789 789
 
790 790
 
@@ -800,16 +800,16 @@  discard block
 block discarded – undo
800 800
 	 *  @param 	EE_Request_Handler $REQ
801 801
 	 *  @return 	EE_Template_Config
802 802
 	 */
803
-	public static function update_template_settings( $CFG, $REQ ) {
803
+	public static function update_template_settings($CFG, $REQ) {
804 804
 		$CFG->EED_Events_Archive = new EE_Events_Archive_Config();
805 805
 		// unless we are resetting the config...
806
-		if ( ! isset( $REQ['EED_Events_Archive_reset_event_list_settings'] ) || absint( $REQ['EED_Events_Archive_reset_event_list_settings'] ) !== 1 ) {
807
-			$CFG->EED_Events_Archive->display_status_banner = isset( $REQ['EED_Events_Archive_display_status_banner'] ) ? absint( $REQ['EED_Events_Archive_display_status_banner'] ) : 0;
808
-			$CFG->EED_Events_Archive->display_description = isset( $REQ['EED_Events_Archive_display_description'] ) ? absint( $REQ['EED_Events_Archive_display_description'] ) : 1;
809
-			$CFG->EED_Events_Archive->display_ticket_selector = isset( $REQ['EED_Events_Archive_display_ticket_selector'] ) ? absint( $REQ['EED_Events_Archive_display_ticket_selector'] ) : 0;
810
-			$CFG->EED_Events_Archive->display_datetimes = isset( $REQ['EED_Events_Archive_display_datetimes'] ) ? absint( $REQ['EED_Events_Archive_display_datetimes'] ) : 1;
811
-			$CFG->EED_Events_Archive->display_venue = isset( $REQ['EED_Events_Archive_display_venue'] ) ? absint( $REQ['EED_Events_Archive_display_venue'] ) : 0;
812
-			$CFG->EED_Events_Archive->display_expired_events = isset( $REQ['EED_Events_Archive_display_expired_events'] ) ? absint( $REQ['EED_Events_Archive_display_expired_events'] ) : 0;			}
806
+		if ( ! isset($REQ['EED_Events_Archive_reset_event_list_settings']) || absint($REQ['EED_Events_Archive_reset_event_list_settings']) !== 1) {
807
+			$CFG->EED_Events_Archive->display_status_banner = isset($REQ['EED_Events_Archive_display_status_banner']) ? absint($REQ['EED_Events_Archive_display_status_banner']) : 0;
808
+			$CFG->EED_Events_Archive->display_description = isset($REQ['EED_Events_Archive_display_description']) ? absint($REQ['EED_Events_Archive_display_description']) : 1;
809
+			$CFG->EED_Events_Archive->display_ticket_selector = isset($REQ['EED_Events_Archive_display_ticket_selector']) ? absint($REQ['EED_Events_Archive_display_ticket_selector']) : 0;
810
+			$CFG->EED_Events_Archive->display_datetimes = isset($REQ['EED_Events_Archive_display_datetimes']) ? absint($REQ['EED_Events_Archive_display_datetimes']) : 1;
811
+			$CFG->EED_Events_Archive->display_venue = isset($REQ['EED_Events_Archive_display_venue']) ? absint($REQ['EED_Events_Archive_display_venue']) : 0;
812
+			$CFG->EED_Events_Archive->display_expired_events = isset($REQ['EED_Events_Archive_display_expired_events']) ? absint($REQ['EED_Events_Archive_display_expired_events']) : 0; }
813 813
 		return $CFG;
814 814
 	}
815 815
 
@@ -822,10 +822,10 @@  discard block
 block discarded – undo
822 822
 	 * @param string $extra_class
823 823
 	 * @return    string
824 824
 	 */
825
-	public static function event_list_css( $extra_class = '' ) {
826
-		$event_list_css = ! empty( $extra_class ) ? array( $extra_class ) : array();
825
+	public static function event_list_css($extra_class = '') {
826
+		$event_list_css = ! empty($extra_class) ? array($extra_class) : array();
827 827
 		$event_list_css[] = 'espresso-event-list-event';
828
-		return implode( ' ', $event_list_css );
828
+		return implode(' ', $event_list_css);
829 829
 	}
830 830
 
831 831
 
@@ -852,9 +852,9 @@  discard block
 block discarded – undo
852 852
 	 * @param $value
853 853
 	 * @return    bool
854 854
 	 */
855
-	public static function display_description( $value ) {
855
+	public static function display_description($value) {
856 856
 		$config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive;
857
-		$display_description= isset( $config->display_description ) ? $config->display_description : 1;
857
+		$display_description = isset($config->display_description) ? $config->display_description : 1;
858 858
 		return $display_description === $value ? TRUE : FALSE;
859 859
 	}
860 860
 
@@ -867,7 +867,7 @@  discard block
 block discarded – undo
867 867
 	 */
868 868
 	public static function display_ticket_selector() {
869 869
 		$config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive;
870
-		return isset( $config->display_ticket_selector ) && $config->display_ticket_selector ? TRUE : FALSE;
870
+		return isset($config->display_ticket_selector) && $config->display_ticket_selector ? TRUE : FALSE;
871 871
 	}
872 872
 
873 873
 
@@ -880,7 +880,7 @@  discard block
 block discarded – undo
880 880
 	 */
881 881
 	public static function display_venue() {
882 882
 		$config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive;
883
-		return isset( $config->display_venue ) && $config->display_venue && EEH_Venue_View::venue_name() ? TRUE : FALSE;
883
+		return isset($config->display_venue) && $config->display_venue && EEH_Venue_View::venue_name() ? TRUE : FALSE;
884 884
 	}
885 885
 
886 886
 
@@ -892,7 +892,7 @@  discard block
 block discarded – undo
892 892
 	 */
893 893
 	public static function display_datetimes() {
894 894
 		$config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive;
895
-		return isset( $config->display_datetimes ) && $config->display_datetimes ? TRUE : FALSE;
895
+		return isset($config->display_datetimes) && $config->display_datetimes ? TRUE : FALSE;
896 896
 }
897 897
 
898 898
 
@@ -907,7 +907,7 @@  discard block
 block discarded – undo
907 907
 	 *  @return 	string
908 908
 	 */
909 909
 	public static function event_list_title() {
910
-		return apply_filters( 'FHEE__archive_espresso_events_template__upcoming_events_h1', __( 'Upcoming Events', 'event_espresso' ));
910
+		return apply_filters('FHEE__archive_espresso_events_template__upcoming_events_h1', __('Upcoming Events', 'event_espresso'));
911 911
 	}
912 912
 
913 913
 
@@ -916,11 +916,11 @@  discard block
 block discarded – undo
916 916
 	/**
917 917
 	 * 	@since 4.4.0
918 918
 	 */
919
-	public static function _doing_it_wrong_notice( $function = '' ) {
919
+	public static function _doing_it_wrong_notice($function = '') {
920 920
 		EE_Error::doing_it_wrong(
921 921
 			__FUNCTION__,
922 922
 			sprintf(
923
-				__( 'EED_Events_Archive::%1$s was moved to EEH_Event_Query::%1$s:%2$sPlease update your existing code because the method it calls will be removed in version %3$s', 'event_espresso' ),
923
+				__('EED_Events_Archive::%1$s was moved to EEH_Event_Query::%1$s:%2$sPlease update your existing code because the method it calls will be removed in version %3$s', 'event_espresso'),
924 924
 				$function,
925 925
 				'<br />',
926 926
 				'4.6.0'
@@ -942,89 +942,89 @@  discard block
 block discarded – undo
942 942
 	 * 	@deprecated
943 943
 	 * 	@since 4.4.0
944 944
 	 */
945
-	public function posts_fields( $SQL, WP_Query $wp_query ) {
946
-		EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ );
947
-		return EEH_Event_Query::posts_fields( $SQL, $wp_query );
945
+	public function posts_fields($SQL, WP_Query $wp_query) {
946
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
947
+		return EEH_Event_Query::posts_fields($SQL, $wp_query);
948 948
 	}
949 949
 	/**
950 950
 	 * 	@deprecated
951 951
 	 * 	@since 4.4.0
952 952
 	 */
953
-	public static function posts_fields_sql_for_orderby( $orderby_params = array() ) {
954
-		EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ );
955
-		return EEH_Event_Query::posts_fields_sql_for_orderby( $orderby_params );
953
+	public static function posts_fields_sql_for_orderby($orderby_params = array()) {
954
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
955
+		return EEH_Event_Query::posts_fields_sql_for_orderby($orderby_params);
956 956
 	}
957 957
 	/**
958 958
 	 * 	@deprecated
959 959
 	 * 	@since 4.4.0
960 960
 	 */
961
-	public function posts_join( $SQL, WP_Query $wp_query ) {
962
-		EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ );
963
-		return EEH_Event_Query::posts_join( $SQL, $wp_query );
961
+	public function posts_join($SQL, WP_Query $wp_query) {
962
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
963
+		return EEH_Event_Query::posts_join($SQL, $wp_query);
964 964
 	}
965 965
 	/**
966 966
 	 * 	@deprecated
967 967
 	 * 	@since 4.4.0
968 968
 	 */
969
-	public static function posts_join_sql_for_terms( $join_terms = NULL ) {
970
-		EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ );
971
-		return EEH_Event_Query::posts_join_sql_for_terms( $join_terms );
969
+	public static function posts_join_sql_for_terms($join_terms = NULL) {
970
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
971
+		return EEH_Event_Query::posts_join_sql_for_terms($join_terms);
972 972
 	}
973 973
 	/**
974 974
 	 * 	@deprecated
975 975
 	 * 	@since 4.4.0
976 976
 	 */
977
-	public static function posts_join_for_orderby( $orderby_params = array() ) {
978
-		EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ );
979
-		return EEH_Event_Query::posts_join_for_orderby( $orderby_params );
977
+	public static function posts_join_for_orderby($orderby_params = array()) {
978
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
979
+		return EEH_Event_Query::posts_join_for_orderby($orderby_params);
980 980
 	}
981 981
 	/**
982 982
 	 * 	@deprecated
983 983
 	 * 	@since 4.4.0
984 984
 	 */
985
-	public function posts_where( $SQL, WP_Query $wp_query ) {
986
-		EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ );
987
-		return EEH_Event_Query::posts_where( $SQL, $wp_query );
985
+	public function posts_where($SQL, WP_Query $wp_query) {
986
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
987
+		return EEH_Event_Query::posts_where($SQL, $wp_query);
988 988
 	}
989 989
 	/**
990 990
 	 * 	@deprecated
991 991
 	 * 	@since 4.4.0
992 992
 	 */
993
-	public static function posts_where_sql_for_show_expired( $show_expired = FALSE ) {
994
-		EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ );
995
-		return EEH_Event_Query::posts_where_sql_for_show_expired( $show_expired );
993
+	public static function posts_where_sql_for_show_expired($show_expired = FALSE) {
994
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
995
+		return EEH_Event_Query::posts_where_sql_for_show_expired($show_expired);
996 996
 	}
997 997
 	/**
998 998
 	 * 	@deprecated
999 999
 	 * 	@since 4.4.0
1000 1000
 	 */
1001
-	public static function posts_where_sql_for_event_category_slug( $event_category_slug = NULL ) {
1002
-		EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ );
1003
-		return EEH_Event_Query::posts_where_sql_for_event_category_slug( $event_category_slug );
1001
+	public static function posts_where_sql_for_event_category_slug($event_category_slug = NULL) {
1002
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1003
+		return EEH_Event_Query::posts_where_sql_for_event_category_slug($event_category_slug);
1004 1004
 	}
1005 1005
 	/**
1006 1006
 	 * 	@deprecated
1007 1007
 	 * 	@since 4.4.0
1008 1008
 	 */
1009
-	public static function posts_where_sql_for_event_list_month( $month = NULL ) {
1010
-		EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ );
1011
-		return EEH_Event_Query::posts_where_sql_for_event_list_month( $month );
1009
+	public static function posts_where_sql_for_event_list_month($month = NULL) {
1010
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1011
+		return EEH_Event_Query::posts_where_sql_for_event_list_month($month);
1012 1012
 	}
1013 1013
 	/**
1014 1014
 	 * 	@deprecated
1015 1015
 	 * 	@since 4.4.0
1016 1016
 	 */
1017
-	public function posts_orderby( $SQL, WP_Query $wp_query ) {
1018
-		EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ );
1019
-		return EEH_Event_Query::posts_orderby( $SQL, $wp_query );
1017
+	public function posts_orderby($SQL, WP_Query $wp_query) {
1018
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1019
+		return EEH_Event_Query::posts_orderby($SQL, $wp_query);
1020 1020
 	}
1021 1021
 	/**
1022 1022
 	 * 	@deprecated
1023 1023
 	 * 	@since 4.4.0
1024 1024
 	 */
1025
-	public static function posts_orderby_sql( $orderby_params = array(), $sort = 'ASC' ) {
1026
-		EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ );
1027
-		return EEH_Event_Query::posts_orderby_sql( $orderby_params, $sort );
1025
+	public static function posts_orderby_sql($orderby_params = array(), $sort = 'ASC') {
1026
+		EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__);
1027
+		return EEH_Event_Query::posts_orderby_sql($orderby_params, $sort);
1028 1028
 	}
1029 1029
 
1030 1030
 
@@ -1055,8 +1055,8 @@  discard block
 block discarded – undo
1055 1055
  * @param string $extra_class
1056 1056
  * @return string
1057 1057
  */
1058
-function espresso_event_list_css( $extra_class = '' ) {
1059
-	return EED_Events_Archive::event_list_css( $extra_class );
1058
+function espresso_event_list_css($extra_class = '') {
1059
+	return EED_Events_Archive::event_list_css($extra_class);
1060 1060
 }
1061 1061
 
1062 1062
 /**
@@ -1070,14 +1070,14 @@  discard block
 block discarded – undo
1070 1070
  * @return bool
1071 1071
  */
1072 1072
 function espresso_display_full_description_in_event_list() {
1073
-	return EED_Events_Archive::display_description( 2 );
1073
+	return EED_Events_Archive::display_description(2);
1074 1074
 }
1075 1075
 
1076 1076
 /**
1077 1077
  * @return bool
1078 1078
  */
1079 1079
 function espresso_display_excerpt_in_event_list() {
1080
-	return EED_Events_Archive::display_description( 1 );
1080
+	return EED_Events_Archive::display_description(1);
1081 1081
 }
1082 1082
 
1083 1083
 /**
Please login to merge, or discard this patch.