Completed
Branch master (8f2259)
by
unknown
16:51 queued 14:33
created
modules/ticket_selector/ProcessTicketSelector.php 2 patches
Indentation   +494 added lines, -494 removed lines patch added patch discarded remove patch
@@ -33,523 +33,523 @@
 block discarded – undo
33 33
 class ProcessTicketSelector
34 34
 {
35 35
 
36
-    /**
37
-     * @var EE_Cart $cart
38
-     */
39
-    private $cart;
36
+	/**
37
+	 * @var EE_Cart $cart
38
+	 */
39
+	private $cart;
40 40
 
41
-    /**
42
-     * @var EE_Core_Config $core_config
43
-     */
44
-    private $core_config;
41
+	/**
42
+	 * @var EE_Core_Config $core_config
43
+	 */
44
+	private $core_config;
45 45
 
46
-    /**
47
-     * @var RequestInterface $request
48
-     */
49
-    private $request;
46
+	/**
47
+	 * @var RequestInterface $request
48
+	 */
49
+	private $request;
50 50
 
51
-    /**
52
-     * @var EE_Session $session
53
-     */
54
-    private $session;
51
+	/**
52
+	 * @var EE_Session $session
53
+	 */
54
+	private $session;
55 55
 
56
-    /**
57
-     * @var EEM_Ticket $ticket_model
58
-     */
59
-    private $ticket_model;
56
+	/**
57
+	 * @var EEM_Ticket $ticket_model
58
+	 */
59
+	private $ticket_model;
60 60
 
61
-    /**
62
-     * @var TicketDatetimeAvailabilityTracker $tracker
63
-     */
64
-    private $tracker;
61
+	/**
62
+	 * @var TicketDatetimeAvailabilityTracker $tracker
63
+	 */
64
+	private $tracker;
65 65
 
66 66
 
67
-    /**
68
-     * ProcessTicketSelector constructor.
69
-     * NOTE: PLZ use the Loader to instantiate this class if need be
70
-     * so that all dependencies get injected correctly (which will happen automatically)
71
-     * Null values for parameters are only for backwards compatibility but will be removed later on.
72
-     *
73
-     * @param EE_Core_Config                    $core_config
74
-     * @param RequestInterface                           $request
75
-     * @param EE_Session                        $session
76
-     * @param EEM_Ticket                        $ticket_model
77
-     * @param TicketDatetimeAvailabilityTracker $tracker
78
-     * @throws InvalidArgumentException
79
-     * @throws InvalidDataTypeException
80
-     * @throws InvalidInterfaceException
81
-     */
82
-    public function __construct(
83
-        EE_Core_Config $core_config = null,
84
-        RequestInterface $request = null,
85
-        EE_Session $session = null,
86
-        EEM_Ticket $ticket_model = null,
87
-        TicketDatetimeAvailabilityTracker $tracker = null
88
-    ) {
89
-        $loader = LoaderFactory::getLoader();
90
-        $this->core_config = $core_config instanceof EE_Core_Config
91
-            ? $core_config
92
-            : $loader->getShared('EE_Core_Config');
93
-        $this->request = $request instanceof RequestInterface
94
-            ? $request
95
-            : $loader->getShared('EventEspresso\core\services\request\Request');
96
-        $this->session = $session instanceof EE_Session
97
-            ? $session
98
-            : $loader->getShared('EE_Session');
99
-        $this->ticket_model = $ticket_model instanceof EEM_Ticket
100
-            ? $ticket_model
101
-            : $loader->getShared('EEM_Ticket');
102
-        $this->tracker = $tracker instanceof TicketDatetimeAvailabilityTracker
103
-            ? $tracker
104
-            : $loader->getShared('EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker');
105
-    }
67
+	/**
68
+	 * ProcessTicketSelector constructor.
69
+	 * NOTE: PLZ use the Loader to instantiate this class if need be
70
+	 * so that all dependencies get injected correctly (which will happen automatically)
71
+	 * Null values for parameters are only for backwards compatibility but will be removed later on.
72
+	 *
73
+	 * @param EE_Core_Config                    $core_config
74
+	 * @param RequestInterface                           $request
75
+	 * @param EE_Session                        $session
76
+	 * @param EEM_Ticket                        $ticket_model
77
+	 * @param TicketDatetimeAvailabilityTracker $tracker
78
+	 * @throws InvalidArgumentException
79
+	 * @throws InvalidDataTypeException
80
+	 * @throws InvalidInterfaceException
81
+	 */
82
+	public function __construct(
83
+		EE_Core_Config $core_config = null,
84
+		RequestInterface $request = null,
85
+		EE_Session $session = null,
86
+		EEM_Ticket $ticket_model = null,
87
+		TicketDatetimeAvailabilityTracker $tracker = null
88
+	) {
89
+		$loader = LoaderFactory::getLoader();
90
+		$this->core_config = $core_config instanceof EE_Core_Config
91
+			? $core_config
92
+			: $loader->getShared('EE_Core_Config');
93
+		$this->request = $request instanceof RequestInterface
94
+			? $request
95
+			: $loader->getShared('EventEspresso\core\services\request\Request');
96
+		$this->session = $session instanceof EE_Session
97
+			? $session
98
+			: $loader->getShared('EE_Session');
99
+		$this->ticket_model = $ticket_model instanceof EEM_Ticket
100
+			? $ticket_model
101
+			: $loader->getShared('EEM_Ticket');
102
+		$this->tracker = $tracker instanceof TicketDatetimeAvailabilityTracker
103
+			? $tracker
104
+			: $loader->getShared('EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker');
105
+	}
106 106
 
107 107
 
108
-    /**
109
-     * cancelTicketSelections
110
-     *
111
-     * @return bool
112
-     * @throws EE_Error
113
-     * @throws InvalidArgumentException
114
-     * @throws InvalidInterfaceException
115
-     * @throws InvalidDataTypeException
116
-     * @throws ReflectionException
117
-     */
118
-    public function cancelTicketSelections()
119
-    {
120
-        // check nonce
121
-        if (! $this->processTicketSelectorNonce('cancel_ticket_selections')) {
122
-            return false;
123
-        }
124
-        $this->session->clear_session(__CLASS__, __FUNCTION__);
125
-        if ($this->request->requestParamIsSet('event_id')) {
126
-            EEH_URL::safeRedirectAndExit(
127
-                EEH_Event_View::event_link_url(
128
-                    $this->request->getRequestParam('event_id', 0, 'int')
129
-                )
130
-            );
131
-        }
132
-        EEH_URL::safeRedirectAndExit(
133
-            site_url('/' . $this->core_config->event_cpt_slug . '/')
134
-        );
135
-        return true;
136
-    }
108
+	/**
109
+	 * cancelTicketSelections
110
+	 *
111
+	 * @return bool
112
+	 * @throws EE_Error
113
+	 * @throws InvalidArgumentException
114
+	 * @throws InvalidInterfaceException
115
+	 * @throws InvalidDataTypeException
116
+	 * @throws ReflectionException
117
+	 */
118
+	public function cancelTicketSelections()
119
+	{
120
+		// check nonce
121
+		if (! $this->processTicketSelectorNonce('cancel_ticket_selections')) {
122
+			return false;
123
+		}
124
+		$this->session->clear_session(__CLASS__, __FUNCTION__);
125
+		if ($this->request->requestParamIsSet('event_id')) {
126
+			EEH_URL::safeRedirectAndExit(
127
+				EEH_Event_View::event_link_url(
128
+					$this->request->getRequestParam('event_id', 0, 'int')
129
+				)
130
+			);
131
+		}
132
+		EEH_URL::safeRedirectAndExit(
133
+			site_url('/' . $this->core_config->event_cpt_slug . '/')
134
+		);
135
+		return true;
136
+	}
137 137
 
138 138
 
139
-    /**
140
-     * processTicketSelectorNonce
141
-     *
142
-     * @param  string $nonce_name
143
-     * @param string  $id
144
-     * @return bool
145
-     */
146
-    private function processTicketSelectorNonce($nonce_name, $id = '')
147
-    {
148
-        $nonce_name_with_id = ! empty($id) ? "{$nonce_name}_nonce_{$id}" : "{$nonce_name}_nonce";
149
-        if (
150
-            ! $this->request->isAdmin()
151
-            && (
152
-                ! $this->request->requestParamIsSet($nonce_name_with_id)
153
-                || ! wp_verify_nonce(
154
-                    $this->request->getRequestParam($nonce_name_with_id),
155
-                    $nonce_name
156
-                )
157
-            )
158
-        ) {
159
-            EE_Error::add_error(
160
-                sprintf(
161
-                    esc_html__(
162
-                        'We\'re sorry but your request failed to pass a security check.%sPlease click the back button on your browser and try again.',
163
-                        'event_espresso'
164
-                    ),
165
-                    '<br/>'
166
-                ),
167
-                __FILE__,
168
-                __FUNCTION__,
169
-                __LINE__
170
-            );
171
-            return false;
172
-        }
173
-        return true;
174
-    }
139
+	/**
140
+	 * processTicketSelectorNonce
141
+	 *
142
+	 * @param  string $nonce_name
143
+	 * @param string  $id
144
+	 * @return bool
145
+	 */
146
+	private function processTicketSelectorNonce($nonce_name, $id = '')
147
+	{
148
+		$nonce_name_with_id = ! empty($id) ? "{$nonce_name}_nonce_{$id}" : "{$nonce_name}_nonce";
149
+		if (
150
+			! $this->request->isAdmin()
151
+			&& (
152
+				! $this->request->requestParamIsSet($nonce_name_with_id)
153
+				|| ! wp_verify_nonce(
154
+					$this->request->getRequestParam($nonce_name_with_id),
155
+					$nonce_name
156
+				)
157
+			)
158
+		) {
159
+			EE_Error::add_error(
160
+				sprintf(
161
+					esc_html__(
162
+						'We\'re sorry but your request failed to pass a security check.%sPlease click the back button on your browser and try again.',
163
+						'event_espresso'
164
+					),
165
+					'<br/>'
166
+				),
167
+				__FILE__,
168
+				__FUNCTION__,
169
+				__LINE__
170
+			);
171
+			return false;
172
+		}
173
+		return true;
174
+	}
175 175
 
176 176
 
177
-    /**
178
-     * process_ticket_selections
179
-     *
180
-     * @return bool
181
-     * @throws EE_Error
182
-     * @throws InvalidArgumentException
183
-     * @throws InvalidDataTypeException
184
-     * @throws InvalidInterfaceException
185
-     * @throws ReflectionException
186
-     */
187
-    public function processTicketSelections()
188
-    {
189
-        do_action('EED_Ticket_Selector__process_ticket_selections__before');
190
-        if ($this->request->isBot()) {
191
-            EEH_URL::safeRedirectAndExit(
192
-                apply_filters(
193
-                    'FHEE__EE_Ticket_Selector__process_ticket_selections__bot_redirect_url',
194
-                    site_url()
195
-                )
196
-            );
197
-        }
198
-        // do we have an event id?
199
-        $id = $this->getEventId();
200
-        // we should really only have 1 registration in the works now
201
-        // (ie, no MER) so unless otherwise requested, clear the session
202
-        if (apply_filters('FHEE__EE_Ticket_Selector__process_ticket_selections__clear_session', true)) {
203
-            $this->session->clear_session(__CLASS__, __FUNCTION__);
204
-        }
205
-        // validate/sanitize/filter data
206
-        $valid = apply_filters(
207
-            'FHEE__EED_Ticket_Selector__process_ticket_selections__valid_post_data',
208
-            $this->validatePostData($id)
209
-        );
210
-        // check total tickets ordered vs max number of attendees that can register
211
-        if (! empty($valid) && $valid['total_tickets'] > $valid['max_atndz']) {
212
-            $this->maxAttendeesViolation($valid);
213
-        } else {
214
-            // all data appears to be valid
215
-            if ($this->processSuccessfulCart($this->addTicketsToCart($valid))) {
216
-                return true;
217
-            }
218
-        }
219
-        // die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< KILL BEFORE REDIRECT
220
-        // at this point, just return if registration is being made from admin
221
-        if ($this->request->isAdmin() || $this->request->isFrontAjax()) {
222
-            return false;
223
-        }
224
-        if ($valid['return_url']) {
225
-            EEH_URL::safeRedirectAndExit($valid['return_url']);
226
-        }
227
-        if ($id) {
228
-            EEH_URL::safeRedirectAndExit(get_permalink($id));
229
-        }
230
-        echo EE_Error::get_notices(); // already escaped
231
-        return false;
232
-    }
177
+	/**
178
+	 * process_ticket_selections
179
+	 *
180
+	 * @return bool
181
+	 * @throws EE_Error
182
+	 * @throws InvalidArgumentException
183
+	 * @throws InvalidDataTypeException
184
+	 * @throws InvalidInterfaceException
185
+	 * @throws ReflectionException
186
+	 */
187
+	public function processTicketSelections()
188
+	{
189
+		do_action('EED_Ticket_Selector__process_ticket_selections__before');
190
+		if ($this->request->isBot()) {
191
+			EEH_URL::safeRedirectAndExit(
192
+				apply_filters(
193
+					'FHEE__EE_Ticket_Selector__process_ticket_selections__bot_redirect_url',
194
+					site_url()
195
+				)
196
+			);
197
+		}
198
+		// do we have an event id?
199
+		$id = $this->getEventId();
200
+		// we should really only have 1 registration in the works now
201
+		// (ie, no MER) so unless otherwise requested, clear the session
202
+		if (apply_filters('FHEE__EE_Ticket_Selector__process_ticket_selections__clear_session', true)) {
203
+			$this->session->clear_session(__CLASS__, __FUNCTION__);
204
+		}
205
+		// validate/sanitize/filter data
206
+		$valid = apply_filters(
207
+			'FHEE__EED_Ticket_Selector__process_ticket_selections__valid_post_data',
208
+			$this->validatePostData($id)
209
+		);
210
+		// check total tickets ordered vs max number of attendees that can register
211
+		if (! empty($valid) && $valid['total_tickets'] > $valid['max_atndz']) {
212
+			$this->maxAttendeesViolation($valid);
213
+		} else {
214
+			// all data appears to be valid
215
+			if ($this->processSuccessfulCart($this->addTicketsToCart($valid))) {
216
+				return true;
217
+			}
218
+		}
219
+		// die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< KILL BEFORE REDIRECT
220
+		// at this point, just return if registration is being made from admin
221
+		if ($this->request->isAdmin() || $this->request->isFrontAjax()) {
222
+			return false;
223
+		}
224
+		if ($valid['return_url']) {
225
+			EEH_URL::safeRedirectAndExit($valid['return_url']);
226
+		}
227
+		if ($id) {
228
+			EEH_URL::safeRedirectAndExit(get_permalink($id));
229
+		}
230
+		echo EE_Error::get_notices(); // already escaped
231
+		return false;
232
+	}
233 233
 
234 234
 
235
-    /**
236
-     * @return int
237
-     */
238
-    private function getEventId()
239
-    {
240
-        // do we have an event id?
241
-        if (! $this->request->requestParamIsSet('tkt-slctr-event-id')) {
242
-            // $_POST['tkt-slctr-event-id'] was not set ?!?!?!?
243
-            EE_Error::add_error(
244
-                sprintf(
245
-                    esc_html__(
246
-                        'An event id was not provided or was not received.%sPlease click the back button on your browser and try again.',
247
-                        'event_espresso'
248
-                    ),
249
-                    '<br/>'
250
-                ),
251
-                __FILE__,
252
-                __FUNCTION__,
253
-                __LINE__
254
-            );
255
-        }
256
-        // if event id is valid
257
-        return $this->request->getRequestParam('tkt-slctr-event-id', 0, 'int');
258
-    }
235
+	/**
236
+	 * @return int
237
+	 */
238
+	private function getEventId()
239
+	{
240
+		// do we have an event id?
241
+		if (! $this->request->requestParamIsSet('tkt-slctr-event-id')) {
242
+			// $_POST['tkt-slctr-event-id'] was not set ?!?!?!?
243
+			EE_Error::add_error(
244
+				sprintf(
245
+					esc_html__(
246
+						'An event id was not provided or was not received.%sPlease click the back button on your browser and try again.',
247
+						'event_espresso'
248
+					),
249
+					'<br/>'
250
+				),
251
+				__FILE__,
252
+				__FUNCTION__,
253
+				__LINE__
254
+			);
255
+		}
256
+		// if event id is valid
257
+		return $this->request->getRequestParam('tkt-slctr-event-id', 0, 'int');
258
+	}
259 259
 
260 260
 
261
-    /**
262
-     * validate_post_data
263
-     *
264
-     * @param int $id
265
-     * @return array
266
-     */
267
-    private function validatePostData($id = 0)
268
-    {
269
-        if (! $id) {
270
-            EE_Error::add_error(
271
-                esc_html__('The event id provided was not valid.', 'event_espresso'),
272
-                __FILE__,
273
-                __FUNCTION__,
274
-                __LINE__
275
-            );
276
-            return array();
277
-        }
278
-        // start with an empty array()
279
-        $valid_data = array();
280
-        // grab valid id
281
-        $valid_data['id'] = $id;
282
-        // array of other form names
283
-        $inputs_to_clean = array(
284
-            'max_atndz'  => 'tkt-slctr-max-atndz-',
285
-            'rows'       => 'tkt-slctr-rows-',
286
-            'qty'        => 'tkt-slctr-qty-',
287
-            'ticket_id'  => 'tkt-slctr-ticket-id-',
288
-            'return_url' => 'tkt-slctr-return-url-',
289
-        );
290
-        // let's track the total number of tickets ordered.'
291
-        $valid_data['total_tickets'] = 0;
292
-        // cycle through $inputs_to_clean array
293
-        foreach ($inputs_to_clean as $what => $input_to_clean) {
294
-            // check for POST data
295
-            if ($this->request->requestParamIsSet($input_to_clean . $id)) {
296
-                switch ($what) {
297
-                    // integers
298
-                    case 'event_id':
299
-                    case 'rows':
300
-                    case 'max_atndz':
301
-                        $valid_data[ $what ] = $this->request->getRequestParam($input_to_clean . $id, 0, 'int');
302
-                        break;
303
-                    // arrays of integers
304
-                    case 'qty':
305
-                        /** @var array $row_qty */
306
-                        $row_qty = $this->request->getRequestParam($input_to_clean . $id, [], 'arrayOf|int');
307
-                        // if qty is coming from a radio button input, then we need to assemble an array of rows
308
-                        if (! is_array($row_qty)) {
309
-                            /** @var string $row_qty */
310
-                            // get number of rows
311
-                            $rows = $this->request->getRequestParam('tkt-slctr-rows-' . $id, 1, 'int');
312
-                            // explode integers by the dash
313
-                            $row_qty = explode('-', $row_qty);
314
-                            $row = isset($row_qty[0]) ? absint($row_qty[0]) : 1;
315
-                            $qty = isset($row_qty[1]) ? absint($row_qty[1]) : 0;
316
-                            $row_qty = array($row => $qty);
317
-                            for ($x = 1; $x <= $rows; $x++) {
318
-                                if (! isset($row_qty[ $x ])) {
319
-                                    $row_qty[ $x ] = 0;
320
-                                }
321
-                            }
322
-                        }
323
-                        ksort($row_qty);
324
-                        // cycle thru values
325
-                        foreach ($row_qty as $qty) {
326
-                            $qty = absint($qty);
327
-                            // sanitize as integers
328
-                            $valid_data[ $what ][] = $qty;
329
-                            $valid_data['total_tickets'] += $qty;
330
-                        }
331
-                        break;
332
-                    // array of integers
333
-                    case 'ticket_id':
334
-                        $ticket_ids = (array) $this->request->getRequestParam($input_to_clean . $id, [], 'arrayOf|int');
335
-                        // cycle thru values
336
-                        foreach ($ticket_ids as $key => $value) {
337
-                            // allow only integers
338
-                            $valid_data[ $what ][ $key ] = absint($value);
339
-                        }
340
-                        break;
341
-                    case 'return_url':
342
-                        // grab and sanitize return-url
343
-                        $input_value = $this->request->getRequestParam($input_to_clean . $id, '', 'url');
344
-                        // was the request coming from an iframe ? if so, then:
345
-                        if (strpos($input_value, 'event_list=iframe')) {
346
-                            // get anchor fragment
347
-                            $input_value = explode('#', $input_value);
348
-                            $input_value = end($input_value);
349
-                            // use event list url instead, but append anchor
350
-                            $input_value = EEH_Event_View::event_archive_url() . '#' . $input_value;
351
-                        }
352
-                        $valid_data[ $what ] = $input_value;
353
-                        break;
354
-                }    // end switch $what
355
-            }
356
-        }    // end foreach $inputs_to_clean
357
-        return $valid_data;
358
-    }
261
+	/**
262
+	 * validate_post_data
263
+	 *
264
+	 * @param int $id
265
+	 * @return array
266
+	 */
267
+	private function validatePostData($id = 0)
268
+	{
269
+		if (! $id) {
270
+			EE_Error::add_error(
271
+				esc_html__('The event id provided was not valid.', 'event_espresso'),
272
+				__FILE__,
273
+				__FUNCTION__,
274
+				__LINE__
275
+			);
276
+			return array();
277
+		}
278
+		// start with an empty array()
279
+		$valid_data = array();
280
+		// grab valid id
281
+		$valid_data['id'] = $id;
282
+		// array of other form names
283
+		$inputs_to_clean = array(
284
+			'max_atndz'  => 'tkt-slctr-max-atndz-',
285
+			'rows'       => 'tkt-slctr-rows-',
286
+			'qty'        => 'tkt-slctr-qty-',
287
+			'ticket_id'  => 'tkt-slctr-ticket-id-',
288
+			'return_url' => 'tkt-slctr-return-url-',
289
+		);
290
+		// let's track the total number of tickets ordered.'
291
+		$valid_data['total_tickets'] = 0;
292
+		// cycle through $inputs_to_clean array
293
+		foreach ($inputs_to_clean as $what => $input_to_clean) {
294
+			// check for POST data
295
+			if ($this->request->requestParamIsSet($input_to_clean . $id)) {
296
+				switch ($what) {
297
+					// integers
298
+					case 'event_id':
299
+					case 'rows':
300
+					case 'max_atndz':
301
+						$valid_data[ $what ] = $this->request->getRequestParam($input_to_clean . $id, 0, 'int');
302
+						break;
303
+					// arrays of integers
304
+					case 'qty':
305
+						/** @var array $row_qty */
306
+						$row_qty = $this->request->getRequestParam($input_to_clean . $id, [], 'arrayOf|int');
307
+						// if qty is coming from a radio button input, then we need to assemble an array of rows
308
+						if (! is_array($row_qty)) {
309
+							/** @var string $row_qty */
310
+							// get number of rows
311
+							$rows = $this->request->getRequestParam('tkt-slctr-rows-' . $id, 1, 'int');
312
+							// explode integers by the dash
313
+							$row_qty = explode('-', $row_qty);
314
+							$row = isset($row_qty[0]) ? absint($row_qty[0]) : 1;
315
+							$qty = isset($row_qty[1]) ? absint($row_qty[1]) : 0;
316
+							$row_qty = array($row => $qty);
317
+							for ($x = 1; $x <= $rows; $x++) {
318
+								if (! isset($row_qty[ $x ])) {
319
+									$row_qty[ $x ] = 0;
320
+								}
321
+							}
322
+						}
323
+						ksort($row_qty);
324
+						// cycle thru values
325
+						foreach ($row_qty as $qty) {
326
+							$qty = absint($qty);
327
+							// sanitize as integers
328
+							$valid_data[ $what ][] = $qty;
329
+							$valid_data['total_tickets'] += $qty;
330
+						}
331
+						break;
332
+					// array of integers
333
+					case 'ticket_id':
334
+						$ticket_ids = (array) $this->request->getRequestParam($input_to_clean . $id, [], 'arrayOf|int');
335
+						// cycle thru values
336
+						foreach ($ticket_ids as $key => $value) {
337
+							// allow only integers
338
+							$valid_data[ $what ][ $key ] = absint($value);
339
+						}
340
+						break;
341
+					case 'return_url':
342
+						// grab and sanitize return-url
343
+						$input_value = $this->request->getRequestParam($input_to_clean . $id, '', 'url');
344
+						// was the request coming from an iframe ? if so, then:
345
+						if (strpos($input_value, 'event_list=iframe')) {
346
+							// get anchor fragment
347
+							$input_value = explode('#', $input_value);
348
+							$input_value = end($input_value);
349
+							// use event list url instead, but append anchor
350
+							$input_value = EEH_Event_View::event_archive_url() . '#' . $input_value;
351
+						}
352
+						$valid_data[ $what ] = $input_value;
353
+						break;
354
+				}    // end switch $what
355
+			}
356
+		}    // end foreach $inputs_to_clean
357
+		return $valid_data;
358
+	}
359 359
 
360 360
 
361
-    /**
362
-     * @param array $valid
363
-     */
364
-    private function maxAttendeesViolation(array $valid)
365
-    {
366
-        // ordering too many tickets !!!
367
-        $total_tickets_string = esc_html(
368
-            _n(
369
-                'You have attempted to purchase %s ticket.',
370
-                'You have attempted to purchase %s tickets.',
371
-                $valid['total_tickets'],
372
-                'event_espresso'
373
-            )
374
-        );
375
-        $limit_error_1 = sprintf($total_tickets_string, $valid['total_tickets']);
376
-        // dev only message
377
-        $max_attendees_string = esc_html(
378
-            _n(
379
-                'The registration limit for this event is %s ticket per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.',
380
-                'The registration limit for this event is %s tickets per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.',
381
-                $valid['max_atndz'],
382
-                'event_espresso'
383
-            )
384
-        );
385
-        $limit_error_2 = sprintf($max_attendees_string, $valid['max_atndz'], $valid['max_atndz']);
386
-        EE_Error::add_error($limit_error_1 . '<br/>' . $limit_error_2, __FILE__, __FUNCTION__, __LINE__);
387
-    }
361
+	/**
362
+	 * @param array $valid
363
+	 */
364
+	private function maxAttendeesViolation(array $valid)
365
+	{
366
+		// ordering too many tickets !!!
367
+		$total_tickets_string = esc_html(
368
+			_n(
369
+				'You have attempted to purchase %s ticket.',
370
+				'You have attempted to purchase %s tickets.',
371
+				$valid['total_tickets'],
372
+				'event_espresso'
373
+			)
374
+		);
375
+		$limit_error_1 = sprintf($total_tickets_string, $valid['total_tickets']);
376
+		// dev only message
377
+		$max_attendees_string = esc_html(
378
+			_n(
379
+				'The registration limit for this event is %s ticket per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.',
380
+				'The registration limit for this event is %s tickets per registration, therefore the total number of tickets you may purchase at a time can not exceed %s.',
381
+				$valid['max_atndz'],
382
+				'event_espresso'
383
+			)
384
+		);
385
+		$limit_error_2 = sprintf($max_attendees_string, $valid['max_atndz'], $valid['max_atndz']);
386
+		EE_Error::add_error($limit_error_1 . '<br/>' . $limit_error_2, __FILE__, __FUNCTION__, __LINE__);
387
+	}
388 388
 
389 389
 
390
-    /**
391
-     * @param array $valid
392
-     * @return int
393
-     * @throws EE_Error
394
-     * @throws InvalidArgumentException
395
-     * @throws InvalidDataTypeException
396
-     * @throws InvalidInterfaceException
397
-     */
398
-    private function addTicketsToCart(array $valid)
399
-    {
400
-        $tickets_added = 0;
401
-        $tickets_selected = false;
402
-        if (! empty($valid) && $valid['total_tickets'] > 0) {
403
-            // load cart using factory because we don't want to do so until actually needed
404
-            $this->cart = CartFactory::getCart();
405
-            // if the user is an admin that can edit registrations,
406
-            // then we'll also allow them to add any tickets, even if they are expired
407
-            $current_user_is_admin = current_user_can('ee_edit_registrations');
408
-            // \EEH_Debug_Tools::printr($current_user_is_admin, '$current_user_is_admin', __FILE__, __LINE__);
409
-            // cycle thru the number of data rows sent from the event listing
410
-            for ($x = 0; $x < $valid['rows']; $x++) {
411
-                // does this row actually contain a ticket quantity?
412
-                if (isset($valid['qty'][ $x ]) && $valid['qty'][ $x ] > 0) {
413
-                    // YES we have a ticket quantity
414
-                    $tickets_selected = true;
415
-                    $valid_ticket = false;
416
-                    if (isset($valid['ticket_id'][ $x ])) {
417
-                        // get ticket via the ticket id we put in the form
418
-                        $ticket = $this->ticket_model->get_one_by_ID($valid['ticket_id'][ $x ]);
419
-                        // \EEH_Debug_Tools::printr($ticket->is_on_sale(), '$ticket->is_on_sale()', __FILE__, __LINE__);
420
-                        if ($ticket instanceof EE_Ticket && ($ticket->is_on_sale() || $current_user_is_admin)) {
421
-                            $valid_ticket = true;
422
-                            $tickets_added += $this->addTicketToCart(
423
-                                $ticket,
424
-                                $valid['qty'][ $x ]
425
-                            );
426
-                        }
427
-                    }
428
-                    if ($valid_ticket !== true) {
429
-                        // nothing added to cart retrieved
430
-                        EE_Error::add_error(
431
-                            sprintf(
432
-                                esc_html__(
433
-                                    'A valid ticket could not be retrieved for the event.%sPlease click the back button on your browser and try again.',
434
-                                    'event_espresso'
435
-                                ),
436
-                                '<br/>'
437
-                            ),
438
-                            __FILE__,
439
-                            __FUNCTION__,
440
-                            __LINE__
441
-                        );
442
-                    }
443
-                    if (EE_Error::has_error()) {
444
-                        break;
445
-                    }
446
-                }
447
-            }
448
-        }
449
-        do_action(
450
-            'AHEE__EE_Ticket_Selector__process_ticket_selections__after_tickets_added_to_cart',
451
-            $this->cart,
452
-            $this
453
-        );
454
-        if (! apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__tckts_slctd', $tickets_selected)) {
455
-            // no ticket quantities were selected
456
-            EE_Error::add_error(
457
-                esc_html__('You need to select a ticket quantity before you can proceed.', 'event_espresso'),
458
-                __FILE__,
459
-                __FUNCTION__,
460
-                __LINE__
461
-            );
462
-        }
463
-        return $tickets_added;
464
-    }
390
+	/**
391
+	 * @param array $valid
392
+	 * @return int
393
+	 * @throws EE_Error
394
+	 * @throws InvalidArgumentException
395
+	 * @throws InvalidDataTypeException
396
+	 * @throws InvalidInterfaceException
397
+	 */
398
+	private function addTicketsToCart(array $valid)
399
+	{
400
+		$tickets_added = 0;
401
+		$tickets_selected = false;
402
+		if (! empty($valid) && $valid['total_tickets'] > 0) {
403
+			// load cart using factory because we don't want to do so until actually needed
404
+			$this->cart = CartFactory::getCart();
405
+			// if the user is an admin that can edit registrations,
406
+			// then we'll also allow them to add any tickets, even if they are expired
407
+			$current_user_is_admin = current_user_can('ee_edit_registrations');
408
+			// \EEH_Debug_Tools::printr($current_user_is_admin, '$current_user_is_admin', __FILE__, __LINE__);
409
+			// cycle thru the number of data rows sent from the event listing
410
+			for ($x = 0; $x < $valid['rows']; $x++) {
411
+				// does this row actually contain a ticket quantity?
412
+				if (isset($valid['qty'][ $x ]) && $valid['qty'][ $x ] > 0) {
413
+					// YES we have a ticket quantity
414
+					$tickets_selected = true;
415
+					$valid_ticket = false;
416
+					if (isset($valid['ticket_id'][ $x ])) {
417
+						// get ticket via the ticket id we put in the form
418
+						$ticket = $this->ticket_model->get_one_by_ID($valid['ticket_id'][ $x ]);
419
+						// \EEH_Debug_Tools::printr($ticket->is_on_sale(), '$ticket->is_on_sale()', __FILE__, __LINE__);
420
+						if ($ticket instanceof EE_Ticket && ($ticket->is_on_sale() || $current_user_is_admin)) {
421
+							$valid_ticket = true;
422
+							$tickets_added += $this->addTicketToCart(
423
+								$ticket,
424
+								$valid['qty'][ $x ]
425
+							);
426
+						}
427
+					}
428
+					if ($valid_ticket !== true) {
429
+						// nothing added to cart retrieved
430
+						EE_Error::add_error(
431
+							sprintf(
432
+								esc_html__(
433
+									'A valid ticket could not be retrieved for the event.%sPlease click the back button on your browser and try again.',
434
+									'event_espresso'
435
+								),
436
+								'<br/>'
437
+							),
438
+							__FILE__,
439
+							__FUNCTION__,
440
+							__LINE__
441
+						);
442
+					}
443
+					if (EE_Error::has_error()) {
444
+						break;
445
+					}
446
+				}
447
+			}
448
+		}
449
+		do_action(
450
+			'AHEE__EE_Ticket_Selector__process_ticket_selections__after_tickets_added_to_cart',
451
+			$this->cart,
452
+			$this
453
+		);
454
+		if (! apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__tckts_slctd', $tickets_selected)) {
455
+			// no ticket quantities were selected
456
+			EE_Error::add_error(
457
+				esc_html__('You need to select a ticket quantity before you can proceed.', 'event_espresso'),
458
+				__FILE__,
459
+				__FUNCTION__,
460
+				__LINE__
461
+			);
462
+		}
463
+		return $tickets_added;
464
+	}
465 465
 
466 466
 
467
-    /**
468
-     * adds a ticket to the cart
469
-     *
470
-     * @param EE_Ticket $ticket
471
-     * @param int       $qty
472
-     * @return bool TRUE on success, FALSE on fail
473
-     * @throws InvalidArgumentException
474
-     * @throws InvalidInterfaceException
475
-     * @throws InvalidDataTypeException
476
-     * @throws EE_Error
477
-     */
478
-    private function addTicketToCart(EE_Ticket $ticket, $qty = 1)
479
-    {
480
-        // get the number of spaces left for this datetime ticket
481
-        $available_spaces = $this->tracker->ticketDatetimeAvailability($ticket);
482
-        // compare available spaces against the number of tickets being purchased
483
-        if ($available_spaces >= $qty) {
484
-            // allow addons to prevent a ticket from being added to cart
485
-            if (
486
-                ! apply_filters(
487
-                    'FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_add_to_cart',
488
-                    true,
489
-                    $ticket,
490
-                    $qty,
491
-                    $available_spaces
492
-                )
493
-            ) {
494
-                return false;
495
-            }
496
-            $qty = absint(apply_filters('FHEE__EE_Ticket_Selector___add_ticket_to_cart__ticket_qty', $qty, $ticket));
497
-            // add event to cart
498
-            if ($this->cart->add_ticket_to_cart($ticket, $qty)) {
499
-                $this->tracker->recalculateTicketDatetimeAvailability($ticket, $qty);
500
-                return true;
501
-            }
502
-            return false;
503
-        }
504
-        $this->tracker->processAvailabilityError($ticket, $qty, $this->cart->all_ticket_quantity_count());
505
-        return false;
506
-    }
467
+	/**
468
+	 * adds a ticket to the cart
469
+	 *
470
+	 * @param EE_Ticket $ticket
471
+	 * @param int       $qty
472
+	 * @return bool TRUE on success, FALSE on fail
473
+	 * @throws InvalidArgumentException
474
+	 * @throws InvalidInterfaceException
475
+	 * @throws InvalidDataTypeException
476
+	 * @throws EE_Error
477
+	 */
478
+	private function addTicketToCart(EE_Ticket $ticket, $qty = 1)
479
+	{
480
+		// get the number of spaces left for this datetime ticket
481
+		$available_spaces = $this->tracker->ticketDatetimeAvailability($ticket);
482
+		// compare available spaces against the number of tickets being purchased
483
+		if ($available_spaces >= $qty) {
484
+			// allow addons to prevent a ticket from being added to cart
485
+			if (
486
+				! apply_filters(
487
+					'FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_add_to_cart',
488
+					true,
489
+					$ticket,
490
+					$qty,
491
+					$available_spaces
492
+				)
493
+			) {
494
+				return false;
495
+			}
496
+			$qty = absint(apply_filters('FHEE__EE_Ticket_Selector___add_ticket_to_cart__ticket_qty', $qty, $ticket));
497
+			// add event to cart
498
+			if ($this->cart->add_ticket_to_cart($ticket, $qty)) {
499
+				$this->tracker->recalculateTicketDatetimeAvailability($ticket, $qty);
500
+				return true;
501
+			}
502
+			return false;
503
+		}
504
+		$this->tracker->processAvailabilityError($ticket, $qty, $this->cart->all_ticket_quantity_count());
505
+		return false;
506
+	}
507 507
 
508 508
 
509
-    /**
510
-     * @param $tickets_added
511
-     * @return bool
512
-     * @throws InvalidInterfaceException
513
-     * @throws InvalidDataTypeException
514
-     * @throws EE_Error
515
-     * @throws InvalidArgumentException
516
-     */
517
-    private function processSuccessfulCart($tickets_added)
518
-    {
519
-        // exit('KILL REDIRECT BEFORE CART UPDATE'); // <<<<<<<<<<<<<<<<< KILL REDIRECT HERE BEFORE CART UPDATE
520
-        if (apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__success', $tickets_added)) {
521
-            // make sure cart is loaded
522
-            if (! $this->cart instanceof EE_Cart) {
523
-                $this->cart = CartFactory::getCart();
524
-            }
525
-            do_action(
526
-                'FHEE__EE_Ticket_Selector__process_ticket_selections__before_redirecting_to_checkout',
527
-                $this->cart,
528
-                $this
529
-            );
530
-            $this->cart->recalculate_all_cart_totals();
531
-            $this->cart->save_cart(false);
532
-            // exit('KILL REDIRECT AFTER CART UPDATE'); // <<<<<<<<  OR HERE TO KILL REDIRECT AFTER CART UPDATE
533
-            // just return TRUE for registrations being made from admin
534
-            if ($this->request->isAdmin() || $this->request->isFrontAjax()) {
535
-                return true;
536
-            }
537
-            EEH_URL::safeRedirectAndExit(
538
-                apply_filters(
539
-                    'FHEE__EE_Ticket_Selector__process_ticket_selections__success_redirect_url',
540
-                    $this->core_config->reg_page_url()
541
-                )
542
-            );
543
-        }
544
-        if (! EE_Error::has_error() && ! EE_Error::has_error(true, 'attention')) {
545
-            // nothing added to cart
546
-            EE_Error::add_attention(
547
-                esc_html__('No tickets were added for the event', 'event_espresso'),
548
-                __FILE__,
549
-                __FUNCTION__,
550
-                __LINE__
551
-            );
552
-        }
553
-        return false;
554
-    }
509
+	/**
510
+	 * @param $tickets_added
511
+	 * @return bool
512
+	 * @throws InvalidInterfaceException
513
+	 * @throws InvalidDataTypeException
514
+	 * @throws EE_Error
515
+	 * @throws InvalidArgumentException
516
+	 */
517
+	private function processSuccessfulCart($tickets_added)
518
+	{
519
+		// exit('KILL REDIRECT BEFORE CART UPDATE'); // <<<<<<<<<<<<<<<<< KILL REDIRECT HERE BEFORE CART UPDATE
520
+		if (apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__success', $tickets_added)) {
521
+			// make sure cart is loaded
522
+			if (! $this->cart instanceof EE_Cart) {
523
+				$this->cart = CartFactory::getCart();
524
+			}
525
+			do_action(
526
+				'FHEE__EE_Ticket_Selector__process_ticket_selections__before_redirecting_to_checkout',
527
+				$this->cart,
528
+				$this
529
+			);
530
+			$this->cart->recalculate_all_cart_totals();
531
+			$this->cart->save_cart(false);
532
+			// exit('KILL REDIRECT AFTER CART UPDATE'); // <<<<<<<<  OR HERE TO KILL REDIRECT AFTER CART UPDATE
533
+			// just return TRUE for registrations being made from admin
534
+			if ($this->request->isAdmin() || $this->request->isFrontAjax()) {
535
+				return true;
536
+			}
537
+			EEH_URL::safeRedirectAndExit(
538
+				apply_filters(
539
+					'FHEE__EE_Ticket_Selector__process_ticket_selections__success_redirect_url',
540
+					$this->core_config->reg_page_url()
541
+				)
542
+			);
543
+		}
544
+		if (! EE_Error::has_error() && ! EE_Error::has_error(true, 'attention')) {
545
+			// nothing added to cart
546
+			EE_Error::add_attention(
547
+				esc_html__('No tickets were added for the event', 'event_espresso'),
548
+				__FILE__,
549
+				__FUNCTION__,
550
+				__LINE__
551
+			);
552
+		}
553
+		return false;
554
+	}
555 555
 }
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
     public function cancelTicketSelections()
119 119
     {
120 120
         // check nonce
121
-        if (! $this->processTicketSelectorNonce('cancel_ticket_selections')) {
121
+        if ( ! $this->processTicketSelectorNonce('cancel_ticket_selections')) {
122 122
             return false;
123 123
         }
124 124
         $this->session->clear_session(__CLASS__, __FUNCTION__);
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
             );
131 131
         }
132 132
         EEH_URL::safeRedirectAndExit(
133
-            site_url('/' . $this->core_config->event_cpt_slug . '/')
133
+            site_url('/'.$this->core_config->event_cpt_slug.'/')
134 134
         );
135 135
         return true;
136 136
     }
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
             $this->validatePostData($id)
209 209
         );
210 210
         // check total tickets ordered vs max number of attendees that can register
211
-        if (! empty($valid) && $valid['total_tickets'] > $valid['max_atndz']) {
211
+        if ( ! empty($valid) && $valid['total_tickets'] > $valid['max_atndz']) {
212 212
             $this->maxAttendeesViolation($valid);
213 213
         } else {
214 214
             // all data appears to be valid
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
     private function getEventId()
239 239
     {
240 240
         // do we have an event id?
241
-        if (! $this->request->requestParamIsSet('tkt-slctr-event-id')) {
241
+        if ( ! $this->request->requestParamIsSet('tkt-slctr-event-id')) {
242 242
             // $_POST['tkt-slctr-event-id'] was not set ?!?!?!?
243 243
             EE_Error::add_error(
244 244
                 sprintf(
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
      */
267 267
     private function validatePostData($id = 0)
268 268
     {
269
-        if (! $id) {
269
+        if ( ! $id) {
270 270
             EE_Error::add_error(
271 271
                 esc_html__('The event id provided was not valid.', 'event_espresso'),
272 272
                 __FILE__,
@@ -292,31 +292,31 @@  discard block
 block discarded – undo
292 292
         // cycle through $inputs_to_clean array
293 293
         foreach ($inputs_to_clean as $what => $input_to_clean) {
294 294
             // check for POST data
295
-            if ($this->request->requestParamIsSet($input_to_clean . $id)) {
295
+            if ($this->request->requestParamIsSet($input_to_clean.$id)) {
296 296
                 switch ($what) {
297 297
                     // integers
298 298
                     case 'event_id':
299 299
                     case 'rows':
300 300
                     case 'max_atndz':
301
-                        $valid_data[ $what ] = $this->request->getRequestParam($input_to_clean . $id, 0, 'int');
301
+                        $valid_data[$what] = $this->request->getRequestParam($input_to_clean.$id, 0, 'int');
302 302
                         break;
303 303
                     // arrays of integers
304 304
                     case 'qty':
305 305
                         /** @var array $row_qty */
306
-                        $row_qty = $this->request->getRequestParam($input_to_clean . $id, [], 'arrayOf|int');
306
+                        $row_qty = $this->request->getRequestParam($input_to_clean.$id, [], 'arrayOf|int');
307 307
                         // if qty is coming from a radio button input, then we need to assemble an array of rows
308
-                        if (! is_array($row_qty)) {
308
+                        if ( ! is_array($row_qty)) {
309 309
                             /** @var string $row_qty */
310 310
                             // get number of rows
311
-                            $rows = $this->request->getRequestParam('tkt-slctr-rows-' . $id, 1, 'int');
311
+                            $rows = $this->request->getRequestParam('tkt-slctr-rows-'.$id, 1, 'int');
312 312
                             // explode integers by the dash
313 313
                             $row_qty = explode('-', $row_qty);
314 314
                             $row = isset($row_qty[0]) ? absint($row_qty[0]) : 1;
315 315
                             $qty = isset($row_qty[1]) ? absint($row_qty[1]) : 0;
316 316
                             $row_qty = array($row => $qty);
317 317
                             for ($x = 1; $x <= $rows; $x++) {
318
-                                if (! isset($row_qty[ $x ])) {
319
-                                    $row_qty[ $x ] = 0;
318
+                                if ( ! isset($row_qty[$x])) {
319
+                                    $row_qty[$x] = 0;
320 320
                                 }
321 321
                             }
322 322
                         }
@@ -325,31 +325,31 @@  discard block
 block discarded – undo
325 325
                         foreach ($row_qty as $qty) {
326 326
                             $qty = absint($qty);
327 327
                             // sanitize as integers
328
-                            $valid_data[ $what ][] = $qty;
328
+                            $valid_data[$what][] = $qty;
329 329
                             $valid_data['total_tickets'] += $qty;
330 330
                         }
331 331
                         break;
332 332
                     // array of integers
333 333
                     case 'ticket_id':
334
-                        $ticket_ids = (array) $this->request->getRequestParam($input_to_clean . $id, [], 'arrayOf|int');
334
+                        $ticket_ids = (array) $this->request->getRequestParam($input_to_clean.$id, [], 'arrayOf|int');
335 335
                         // cycle thru values
336 336
                         foreach ($ticket_ids as $key => $value) {
337 337
                             // allow only integers
338
-                            $valid_data[ $what ][ $key ] = absint($value);
338
+                            $valid_data[$what][$key] = absint($value);
339 339
                         }
340 340
                         break;
341 341
                     case 'return_url':
342 342
                         // grab and sanitize return-url
343
-                        $input_value = $this->request->getRequestParam($input_to_clean . $id, '', 'url');
343
+                        $input_value = $this->request->getRequestParam($input_to_clean.$id, '', 'url');
344 344
                         // was the request coming from an iframe ? if so, then:
345 345
                         if (strpos($input_value, 'event_list=iframe')) {
346 346
                             // get anchor fragment
347 347
                             $input_value = explode('#', $input_value);
348 348
                             $input_value = end($input_value);
349 349
                             // use event list url instead, but append anchor
350
-                            $input_value = EEH_Event_View::event_archive_url() . '#' . $input_value;
350
+                            $input_value = EEH_Event_View::event_archive_url().'#'.$input_value;
351 351
                         }
352
-                        $valid_data[ $what ] = $input_value;
352
+                        $valid_data[$what] = $input_value;
353 353
                         break;
354 354
                 }    // end switch $what
355 355
             }
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
             )
384 384
         );
385 385
         $limit_error_2 = sprintf($max_attendees_string, $valid['max_atndz'], $valid['max_atndz']);
386
-        EE_Error::add_error($limit_error_1 . '<br/>' . $limit_error_2, __FILE__, __FUNCTION__, __LINE__);
386
+        EE_Error::add_error($limit_error_1.'<br/>'.$limit_error_2, __FILE__, __FUNCTION__, __LINE__);
387 387
     }
388 388
 
389 389
 
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
     {
400 400
         $tickets_added = 0;
401 401
         $tickets_selected = false;
402
-        if (! empty($valid) && $valid['total_tickets'] > 0) {
402
+        if ( ! empty($valid) && $valid['total_tickets'] > 0) {
403 403
             // load cart using factory because we don't want to do so until actually needed
404 404
             $this->cart = CartFactory::getCart();
405 405
             // if the user is an admin that can edit registrations,
@@ -409,19 +409,19 @@  discard block
 block discarded – undo
409 409
             // cycle thru the number of data rows sent from the event listing
410 410
             for ($x = 0; $x < $valid['rows']; $x++) {
411 411
                 // does this row actually contain a ticket quantity?
412
-                if (isset($valid['qty'][ $x ]) && $valid['qty'][ $x ] > 0) {
412
+                if (isset($valid['qty'][$x]) && $valid['qty'][$x] > 0) {
413 413
                     // YES we have a ticket quantity
414 414
                     $tickets_selected = true;
415 415
                     $valid_ticket = false;
416
-                    if (isset($valid['ticket_id'][ $x ])) {
416
+                    if (isset($valid['ticket_id'][$x])) {
417 417
                         // get ticket via the ticket id we put in the form
418
-                        $ticket = $this->ticket_model->get_one_by_ID($valid['ticket_id'][ $x ]);
418
+                        $ticket = $this->ticket_model->get_one_by_ID($valid['ticket_id'][$x]);
419 419
                         // \EEH_Debug_Tools::printr($ticket->is_on_sale(), '$ticket->is_on_sale()', __FILE__, __LINE__);
420 420
                         if ($ticket instanceof EE_Ticket && ($ticket->is_on_sale() || $current_user_is_admin)) {
421 421
                             $valid_ticket = true;
422 422
                             $tickets_added += $this->addTicketToCart(
423 423
                                 $ticket,
424
-                                $valid['qty'][ $x ]
424
+                                $valid['qty'][$x]
425 425
                             );
426 426
                         }
427 427
                     }
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
             $this->cart,
452 452
             $this
453 453
         );
454
-        if (! apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__tckts_slctd', $tickets_selected)) {
454
+        if ( ! apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__tckts_slctd', $tickets_selected)) {
455 455
             // no ticket quantities were selected
456 456
             EE_Error::add_error(
457 457
                 esc_html__('You need to select a ticket quantity before you can proceed.', 'event_espresso'),
@@ -519,7 +519,7 @@  discard block
 block discarded – undo
519 519
         // exit('KILL REDIRECT BEFORE CART UPDATE'); // <<<<<<<<<<<<<<<<< KILL REDIRECT HERE BEFORE CART UPDATE
520 520
         if (apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__success', $tickets_added)) {
521 521
             // make sure cart is loaded
522
-            if (! $this->cart instanceof EE_Cart) {
522
+            if ( ! $this->cart instanceof EE_Cart) {
523 523
                 $this->cart = CartFactory::getCart();
524 524
             }
525 525
             do_action(
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
                 )
542 542
             );
543 543
         }
544
-        if (! EE_Error::has_error() && ! EE_Error::has_error(true, 'attention')) {
544
+        if ( ! EE_Error::has_error() && ! EE_Error::has_error(true, 'attention')) {
545 545
             // nothing added to cart
546 546
             EE_Error::add_attention(
547 547
                 esc_html__('No tickets were added for the event', 'event_espresso'),
Please login to merge, or discard this patch.
espresso.php 1 patch
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -38,103 +38,103 @@
 block discarded – undo
38 38
  * @since           4.0
39 39
  */
40 40
 if (function_exists('espresso_version')) {
41
-    if (! function_exists('espresso_duplicate_plugin_error')) {
42
-        /**
43
-         *    espresso_duplicate_plugin_error
44
-         *    displays if more than one version of EE is activated at the same time
45
-         */
46
-        function espresso_duplicate_plugin_error()
47
-        {
48
-            ?>
41
+	if (! function_exists('espresso_duplicate_plugin_error')) {
42
+		/**
43
+		 *    espresso_duplicate_plugin_error
44
+		 *    displays if more than one version of EE is activated at the same time
45
+		 */
46
+		function espresso_duplicate_plugin_error()
47
+		{
48
+			?>
49 49
             <div class="error">
50 50
                 <p>
51 51
                     <?php
52
-                    echo esc_html__(
53
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
-                        'event_espresso'
55
-                    ); ?>
52
+					echo esc_html__(
53
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
+						'event_espresso'
55
+					); ?>
56 56
                 </p>
57 57
             </div>
58 58
             <?php
59
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
60
-        }
61
-    }
62
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
59
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
60
+		}
61
+	}
62
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
63 63
 } else {
64
-    define('EE_MIN_PHP_VER_REQUIRED', '5.6.2');
65
-    if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
-        /**
67
-         * espresso_minimum_php_version_error
68
-         *
69
-         * @return void
70
-         */
71
-        function espresso_minimum_php_version_error()
72
-        {
73
-            ?>
64
+	define('EE_MIN_PHP_VER_REQUIRED', '5.6.2');
65
+	if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
+		/**
67
+		 * espresso_minimum_php_version_error
68
+		 *
69
+		 * @return void
70
+		 */
71
+		function espresso_minimum_php_version_error()
72
+		{
73
+			?>
74 74
             <div class="error">
75 75
                 <p>
76 76
                     <?php
77
-                    printf(
78
-                        esc_html__(
79
-                            'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
-                            'event_espresso'
81
-                        ),
82
-                        EE_MIN_PHP_VER_REQUIRED,
83
-                        PHP_VERSION,
84
-                        '<br/>',
85
-                        '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
-                    );
87
-                    ?>
77
+					printf(
78
+						esc_html__(
79
+							'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
+							'event_espresso'
81
+						),
82
+						EE_MIN_PHP_VER_REQUIRED,
83
+						PHP_VERSION,
84
+						'<br/>',
85
+						'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
+					);
87
+					?>
88 88
                 </p>
89 89
             </div>
90 90
             <?php
91
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
92
-        }
91
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
92
+		}
93 93
 
94
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
-    } else {
96
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
-        /**
98
-         * espresso_version
99
-         * Returns the plugin version
100
-         *
101
-         * @return string
102
-         */
103
-        function espresso_version()
104
-        {
105
-            return apply_filters('FHEE__espresso__espresso_version', '4.10.15.rc.009');
106
-        }
94
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
+	} else {
96
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
+		/**
98
+		 * espresso_version
99
+		 * Returns the plugin version
100
+		 *
101
+		 * @return string
102
+		 */
103
+		function espresso_version()
104
+		{
105
+			return apply_filters('FHEE__espresso__espresso_version', '4.10.15.rc.009');
106
+		}
107 107
 
108
-        /**
109
-         * espresso_plugin_activation
110
-         * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
-         */
112
-        function espresso_plugin_activation()
113
-        {
114
-            update_option('ee_espresso_activation', true);
115
-        }
108
+		/**
109
+		 * espresso_plugin_activation
110
+		 * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
+		 */
112
+		function espresso_plugin_activation()
113
+		{
114
+			update_option('ee_espresso_activation', true);
115
+		}
116 116
 
117
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
117
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
118 118
 
119
-        require_once __DIR__ . '/core/bootstrap_espresso.php';
120
-        bootstrap_espresso();
121
-    }
119
+		require_once __DIR__ . '/core/bootstrap_espresso.php';
120
+		bootstrap_espresso();
121
+	}
122 122
 }
123 123
 if (! function_exists('espresso_deactivate_plugin')) {
124
-    /**
125
-     *    deactivate_plugin
126
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
-     *
128
-     * @access public
129
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
-     * @return    void
131
-     */
132
-    function espresso_deactivate_plugin($plugin_basename = '')
133
-    {
134
-        if (! function_exists('deactivate_plugins')) {
135
-            require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
-        }
137
-        unset($_GET['activate'], $_REQUEST['activate']);
138
-        deactivate_plugins($plugin_basename);
139
-    }
124
+	/**
125
+	 *    deactivate_plugin
126
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
+	 *
128
+	 * @access public
129
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
+	 * @return    void
131
+	 */
132
+	function espresso_deactivate_plugin($plugin_basename = '')
133
+	{
134
+		if (! function_exists('deactivate_plugins')) {
135
+			require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
+		}
137
+		unset($_GET['activate'], $_REQUEST['activate']);
138
+		deactivate_plugins($plugin_basename);
139
+	}
140 140
 }
Please login to merge, or discard this patch.