Completed
Branch BUG-8698-ticket-sellouts (d652f0)
by
unknown
198:01 queued 171:26
created
core/db_models/EEM_Registration.model.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -257,7 +257,7 @@
 block discarded – undo
257 257
 	* 		@param	int	$TXN_ID
258 258
 	* 		@param    int		$ATT_ID
259 259
 	* 		@param    int		$att_nmbr 	in case the ATT_ID is the same for multiple registrations (same details used) then the attendee number is required
260
-	*		@return 		mixed		array on success, FALSE on fail
260
+	*		@return 		EE_Base_Class|null		array on success, FALSE on fail
261 261
 	*/
262 262
 	public function get_registration_for_transaction_attendee( $TXN_ID = 0, $ATT_ID = 0, $att_nmbr = 0 ) {
263 263
 		return $this->get_one(array(
Please login to merge, or discard this patch.
Spacing   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
2
-require_once ( EE_MODELS . 'EEM_Soft_Delete_Base.model.php' );
3
-require_once ( EE_CLASSES . 'EE_Registration.class.php' );
2
+require_once (EE_MODELS.'EEM_Soft_Delete_Base.model.php');
3
+require_once (EE_CLASSES.'EE_Registration.class.php');
4 4
 /**
5 5
  *
6 6
  * Registration Model
@@ -92,31 +92,31 @@  discard block
 block discarded – undo
92 92
 	 *    Note this just sends the timezone info to the date time model field objects.  Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option)
93 93
 	 * @return \EEM_Registration
94 94
 	 */
95
-	protected function __construct( $timezone ) {
96
-		$this->singular_item = __('Registration','event_espresso');
97
-		$this->plural_item = __('Registrations','event_espresso');
95
+	protected function __construct($timezone) {
96
+		$this->singular_item = __('Registration', 'event_espresso');
97
+		$this->plural_item = __('Registrations', 'event_espresso');
98 98
 
99 99
 		$this->_tables = array(
100
-			'Registration'=>new EE_Primary_Table('esp_registration','REG_ID')
100
+			'Registration'=>new EE_Primary_Table('esp_registration', 'REG_ID')
101 101
 		);
102 102
 		$this->_fields = array(
103 103
 			'Registration'=>array(
104
-				'REG_ID'=>new EE_Primary_Key_Int_Field('REG_ID', __('Registration ID','event_espresso')),
105
-				'EVT_ID'=>new EE_Foreign_Key_Int_Field('EVT_ID', __('Event ID','event_espresso'), false, 0, 'Event'),
106
-				'ATT_ID'=>new EE_Foreign_Key_Int_Field('ATT_ID', __('Attendee ID','event_espresso'), false, 0, 'Attendee'),
107
-				'TXN_ID'=>new EE_Foreign_Key_Int_Field('TXN_ID', __('Transaction ID','event_espresso'), false, 0, 'Transaction'),
108
-				'TKT_ID'=>new EE_Foreign_Key_Int_Field('TKT_ID', __('Ticket ID','event_espresso'), false, 0, 'Ticket'),
109
-				'STS_ID'=>new EE_Foreign_Key_String_Field('STS_ID', __('Status ID','event_espresso'), false, EEM_Registration::status_id_incomplete, 'Status'),
110
-				'REG_date'=>new EE_Datetime_Field('REG_date', __('Time registration occurred','event_espresso'), false, time(), $timezone ),
111
-				'REG_final_price'=>new EE_Money_Field('REG_final_price', __('Registration\'s share of the transaction total','event_espresso'), false, 0),
112
-				'REG_paid'=>new EE_Money_Field('REG_paid', __('Amount paid to date towards registration','event_espresso'), false, 0),
113
-				'REG_session'=>new EE_Plain_Text_Field('REG_session', __('Session ID of registration','event_espresso'), false, ''),
114
-				'REG_code'=>new EE_Plain_Text_Field('REG_code', __('Unique Code for this registration','event_espresso'), false, ''),
115
-				'REG_url_link'=>new EE_Plain_Text_Field('REG_url_link', __('String to be used in URL for identifying registration','event_espresso'), false, ''),
116
-				'REG_count'=>new EE_Integer_Field('REG_count', __('Count of this registration in the group registration ','event_espresso'), true, 1),
117
-				'REG_group_size'=>new EE_Integer_Field('REG_group_size', __('Number of registrations on this group','event_espresso'), false, 1),
118
-				'REG_att_is_going'=>new EE_Boolean_Field('REG_att_is_going', __('Flag indicating the registrant plans on attending','event_espresso'), false, false),
119
-				'REG_deleted' => new EE_Trashed_Flag_Field('REG_deleted', __('Flag indicating if registration has been archived or not.', 'event_espresso'), false, false )
104
+				'REG_ID'=>new EE_Primary_Key_Int_Field('REG_ID', __('Registration ID', 'event_espresso')),
105
+				'EVT_ID'=>new EE_Foreign_Key_Int_Field('EVT_ID', __('Event ID', 'event_espresso'), false, 0, 'Event'),
106
+				'ATT_ID'=>new EE_Foreign_Key_Int_Field('ATT_ID', __('Attendee ID', 'event_espresso'), false, 0, 'Attendee'),
107
+				'TXN_ID'=>new EE_Foreign_Key_Int_Field('TXN_ID', __('Transaction ID', 'event_espresso'), false, 0, 'Transaction'),
108
+				'TKT_ID'=>new EE_Foreign_Key_Int_Field('TKT_ID', __('Ticket ID', 'event_espresso'), false, 0, 'Ticket'),
109
+				'STS_ID'=>new EE_Foreign_Key_String_Field('STS_ID', __('Status ID', 'event_espresso'), false, EEM_Registration::status_id_incomplete, 'Status'),
110
+				'REG_date'=>new EE_Datetime_Field('REG_date', __('Time registration occurred', 'event_espresso'), false, time(), $timezone),
111
+				'REG_final_price'=>new EE_Money_Field('REG_final_price', __('Registration\'s share of the transaction total', 'event_espresso'), false, 0),
112
+				'REG_paid'=>new EE_Money_Field('REG_paid', __('Amount paid to date towards registration', 'event_espresso'), false, 0),
113
+				'REG_session'=>new EE_Plain_Text_Field('REG_session', __('Session ID of registration', 'event_espresso'), false, ''),
114
+				'REG_code'=>new EE_Plain_Text_Field('REG_code', __('Unique Code for this registration', 'event_espresso'), false, ''),
115
+				'REG_url_link'=>new EE_Plain_Text_Field('REG_url_link', __('String to be used in URL for identifying registration', 'event_espresso'), false, ''),
116
+				'REG_count'=>new EE_Integer_Field('REG_count', __('Count of this registration in the group registration ', 'event_espresso'), true, 1),
117
+				'REG_group_size'=>new EE_Integer_Field('REG_group_size', __('Number of registrations on this group', 'event_espresso'), false, 1),
118
+				'REG_att_is_going'=>new EE_Boolean_Field('REG_att_is_going', __('Flag indicating the registrant plans on attending', 'event_espresso'), false, false),
119
+				'REG_deleted' => new EE_Trashed_Flag_Field('REG_deleted', __('Flag indicating if registration has been archived or not.', 'event_espresso'), false, false)
120 120
 			)
121 121
 		);
122 122
 		$this->_model_relations = array(
@@ -128,11 +128,11 @@  discard block
 block discarded – undo
128 128
 			'Answer'=>new EE_Has_Many_Relation(),
129 129
 			'Checkin'=>new EE_Has_Many_Relation(),
130 130
 			'Registration_Payment' => new EE_Has_Many_Relation(),
131
-			'Payment'=>new EE_HABTM_Relation( 'Registration_Payment' ),
131
+			'Payment'=>new EE_HABTM_Relation('Registration_Payment'),
132 132
 		);
133 133
 		$this->_model_chain_to_wp_user = 'Event';
134 134
 
135
-		parent::__construct( $timezone );
135
+		parent::__construct($timezone);
136 136
 	}
137 137
 
138 138
 
@@ -165,9 +165,9 @@  discard block
 block discarded – undo
165 165
 	 *		@param bool  $translated If true will return the values as singular localized strings
166 166
 	 *		@return array
167 167
 	 */
168
-	public static function reg_status_array( $exclude = array(), $translated = FALSE ) {
169
-		EEM_Registration::instance()->_get_registration_status_array( $exclude );
170
-		return $translated ? EEM_Status::instance()->localized_status( self::$_reg_status, FALSE, 'sentence') : self::$_reg_status;
168
+	public static function reg_status_array($exclude = array(), $translated = FALSE) {
169
+		EEM_Registration::instance()->_get_registration_status_array($exclude);
170
+		return $translated ? EEM_Status::instance()->localized_status(self::$_reg_status, FALSE, 'sentence') : self::$_reg_status;
171 171
 	}
172 172
 
173 173
 
@@ -178,19 +178,19 @@  discard block
 block discarded – undo
178 178
 	 * @param array $exclude
179 179
 	 * @return array
180 180
 	 */
181
-	private function _get_registration_status_array( $exclude = array() ) {
181
+	private function _get_registration_status_array($exclude = array()) {
182 182
 		//in the very rare circumstance that we are deleting a model's table's data
183 183
 		//and the table hasn't actually been created, this could have an error
184 184
 		/** @type WPDB $wpdb */
185 185
 		global $wpdb;
186
-		EE_Registry::instance()->load_helper( 'Activation' );
187
-		if( EEH_Activation::table_exists( $wpdb->prefix . 'esp_status' ) ){
188
-			$SQL = 'SELECT STS_ID, STS_code FROM '. $wpdb->prefix . 'esp_status WHERE STS_type = "registration"';
189
-			$results = $wpdb->get_results( $SQL );
186
+		EE_Registry::instance()->load_helper('Activation');
187
+		if (EEH_Activation::table_exists($wpdb->prefix.'esp_status')) {
188
+			$SQL = 'SELECT STS_ID, STS_code FROM '.$wpdb->prefix.'esp_status WHERE STS_type = "registration"';
189
+			$results = $wpdb->get_results($SQL);
190 190
 			self::$_reg_status = array();
191
-			foreach ( $results as $status ) {
192
-				if ( ! in_array( $status->STS_ID, $exclude )) {
193
-					self::$_reg_status[ $status->STS_ID ] = $status->STS_code;
191
+			foreach ($results as $status) {
192
+				if ( ! in_array($status->STS_ID, $exclude)) {
193
+					self::$_reg_status[$status->STS_ID] = $status->STS_code;
194 194
 				}
195 195
 			}
196 196
 		}
@@ -205,15 +205,15 @@  discard block
 block discarded – undo
205 205
 	 * @param  array  $where_params Array of query_params as described in the comments for EEM_Base::get_all()
206 206
 	 * @return wpdb results array
207 207
 	 */
208
-	public function get_reg_months_and_years( $where_params ) {
208
+	public function get_reg_months_and_years($where_params) {
209 209
 		$query_params[0] = $where_params;
210 210
 		$query_params['group_by'] = array('reg_year', 'reg_month');
211
-		$query_params['order_by'] = array( 'REG_date' => 'DESC' );
211
+		$query_params['order_by'] = array('REG_date' => 'DESC');
212 212
 		$columns_to_select = array(
213 213
 			'reg_year' => array('YEAR(REG_date)', '%s'),
214 214
 			'reg_month' => array('MONTHNAME(REG_date)', '%s')
215 215
 			);
216
-		return $this->_get_all_wpdb_results( $query_params, OBJECT, $columns_to_select );
216
+		return $this->_get_all_wpdb_results($query_params, OBJECT, $columns_to_select);
217 217
 	}
218 218
 
219 219
 
@@ -225,11 +225,11 @@  discard block
 block discarded – undo
225 225
 	* 		@param		int		$ATT_ID
226 226
 	*		@return 	EE_Registration[]
227 227
 	*/
228
-	public function get_all_registrations_for_attendee( $ATT_ID = 0 ) {
229
-		if ( ! $ATT_ID ) {
228
+	public function get_all_registrations_for_attendee($ATT_ID = 0) {
229
+		if ( ! $ATT_ID) {
230 230
 			return FALSE;
231 231
 		}
232
-		return $this->get_all( array( array( 'ATT_ID' => $ATT_ID )));
232
+		return $this->get_all(array(array('ATT_ID' => $ATT_ID)));
233 233
 	}
234 234
 
235 235
 
@@ -240,8 +240,8 @@  discard block
 block discarded – undo
240 240
 	 * @param string $REG_url_link
241 241
 	 * @return EE_Registration
242 242
 	 */
243
-	public function get_registration_for_reg_url_link($REG_url_link){
244
-		if(!$REG_url_link){
243
+	public function get_registration_for_reg_url_link($REG_url_link) {
244
+		if ( ! $REG_url_link) {
245 245
 			return false;
246 246
 		}
247 247
 		return $this->get_one(array(array('REG_url_link'=>$REG_url_link)));
@@ -259,13 +259,13 @@  discard block
 block discarded – undo
259 259
 	* 		@param    int		$att_nmbr 	in case the ATT_ID is the same for multiple registrations (same details used) then the attendee number is required
260 260
 	*		@return 		mixed		array on success, FALSE on fail
261 261
 	*/
262
-	public function get_registration_for_transaction_attendee( $TXN_ID = 0, $ATT_ID = 0, $att_nmbr = 0 ) {
262
+	public function get_registration_for_transaction_attendee($TXN_ID = 0, $ATT_ID = 0, $att_nmbr = 0) {
263 263
 		return $this->get_one(array(
264 264
 			array(
265 265
 				'TXN_ID'=>$TXN_ID,
266 266
 				'ATT_ID'=>$ATT_ID
267 267
 			),
268
-			'limit'=>array( min( ( $att_nmbr-1 ), 0 ), 1 )
268
+			'limit'=>array(min(($att_nmbr - 1), 0), 1)
269 269
 		));
270 270
 	}
271 271
 
@@ -277,12 +277,12 @@  discard block
 block discarded – undo
277 277
 	 *		@param $period string which can be passed to php's strtotime function (eg "-1 month")
278 278
 	 *		@return stdClass[] with properties regDate and total
279 279
 	*/
280
-	public function get_registrations_per_day_report( $period = '-1 month' ) {
280
+	public function get_registrations_per_day_report($period = '-1 month') {
281 281
 
282
-		$sql_date = $this->convert_datetime_for_query( 'REG_date', date("Y-m-d H:i:s", strtotime($period) ), 'Y-m-d H:i:s', 'UTC' );
283
-		$where = array( 'REG_date' => array( '>=', $sql_date ), 'STS_ID' => array( '!=', EEM_Registration::status_id_incomplete ) );
282
+		$sql_date = $this->convert_datetime_for_query('REG_date', date("Y-m-d H:i:s", strtotime($period)), 'Y-m-d H:i:s', 'UTC');
283
+		$where = array('REG_date' => array('>=', $sql_date), 'STS_ID' => array('!=', EEM_Registration::status_id_incomplete));
284 284
 
285
-		if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_registrations', 'reg_per_day_report' ) ) {
285
+		if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_day_report')) {
286 286
 			$where['Event.EVT_wp_user'] = get_current_user_id();
287 287
 		}
288 288
 
@@ -294,8 +294,8 @@  discard block
 block discarded – undo
294 294
 				),
295 295
 				OBJECT,
296 296
 				array(
297
-					'regDate'=>array('DATE(Registration.REG_date)','%s'),
298
-					'total'=>array('count(REG_ID)','%d')
297
+					'regDate'=>array('DATE(Registration.REG_date)', '%s'),
298
+					'total'=>array('count(REG_ID)', '%d')
299 299
 				));
300 300
 		return $results;
301 301
 	}
@@ -310,23 +310,23 @@  discard block
 block discarded – undo
310 310
 	 * @param $period string which can be passed to php's strtotime function (eg "-1 month")
311 311
 	 *		@return stdClass[] each with properties event_name, reg_limit, and total
312 312
 	*/
313
-	public function get_registrations_per_event_report( $period = '-1 month' ) {
313
+	public function get_registrations_per_event_report($period = '-1 month') {
314 314
 
315
-		$date_sql = $this->convert_datetime_for_query( 'REG_date', date( "Y-m-d H:i:s", strtotime( $period )), 'Y-m-d H:i:s', 'UTC' );
316
-		$where = array( 'REG_date' => array( '>=', $date_sql ), 'STS_ID' => array( '!=', EEM_Registration::status_id_incomplete ) );
315
+		$date_sql = $this->convert_datetime_for_query('REG_date', date("Y-m-d H:i:s", strtotime($period)), 'Y-m-d H:i:s', 'UTC');
316
+		$where = array('REG_date' => array('>=', $date_sql), 'STS_ID' => array('!=', EEM_Registration::status_id_incomplete));
317 317
 
318
-		if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_registrations', 'reg_per_event_report' ) ) {
318
+		if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) {
319 319
 			$where['Event.EVT_wp_user'] = get_current_user_id();
320 320
 		}
321 321
 		$results = $this->_get_all_wpdb_results(array(
322 322
 			$where,
323 323
 			'group_by'=>'Event.EVT_name',
324 324
 			'order_by'=>'Event.EVT_name',
325
-			'limit'=>array(0,24)),
325
+			'limit'=>array(0, 24)),
326 326
 			OBJECT,
327 327
 			array(
328
-				'event_name'=>array('Event_CPT.post_title','%s'),
329
-				'total'=>array('COUNT(REG_ID)','%s')
328
+				'event_name'=>array('Event_CPT.post_title', '%s'),
329
+				'total'=>array('COUNT(REG_ID)', '%s')
330 330
 			)
331 331
 		);
332 332
 
@@ -340,11 +340,11 @@  discard block
 block discarded – undo
340 340
 	 * @param int $TXN_ID
341 341
 	 * @return EE_Registration
342 342
 	 */
343
-	public function get_primary_registration_for_transaction_ID( $TXN_ID = 0){
344
-		if( ! $TXN_ID ){
343
+	public function get_primary_registration_for_transaction_ID($TXN_ID = 0) {
344
+		if ( ! $TXN_ID) {
345 345
 			return false;
346 346
 		}
347
-		return $this->get_one(array(array('TXN_ID'=>$TXN_ID,'REG_count'=>  EEM_Registration::PRIMARY_REGISTRANT_COUNT)));
347
+		return $this->get_one(array(array('TXN_ID'=>$TXN_ID, 'REG_count'=>  EEM_Registration::PRIMARY_REGISTRANT_COUNT)));
348 348
 	}
349 349
 
350 350
 
@@ -356,11 +356,11 @@  discard block
 block discarded – undo
356 356
 	 *		@param boolean $for_incomplete_payments
357 357
 	 *		@return int
358 358
 	 */
359
-	public function get_event_registration_count ( $EVT_ID, $for_incomplete_payments = FALSE ) {
359
+	public function get_event_registration_count($EVT_ID, $for_incomplete_payments = FALSE) {
360 360
 		// we only count approved registrations towards registration limits
361
-		$query_params = array( array( 'EVT_ID' => $EVT_ID, 'STS_ID' => self::status_id_approved ) );
362
-		if( $for_incomplete_payments ){
363
-			$query_params[0]['Transaction.STS_ID']=array('!=',  EEM_Transaction::complete_status_code);
361
+		$query_params = array(array('EVT_ID' => $EVT_ID, 'STS_ID' => self::status_id_approved));
362
+		if ($for_incomplete_payments) {
363
+			$query_params[0]['Transaction.STS_ID'] = array('!=', EEM_Transaction::complete_status_code);
364 364
 		}
365 365
 
366 366
 		return $this->count($query_params);
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
 		/** @type WPDB $wpdb */
377 377
 		global $wpdb;
378 378
 		return $wpdb->query(
379
-				'DELETE r FROM ' . $this->table() . ' r LEFT JOIN ' . EEM_Transaction::instance()->table() . ' t ON r.TXN_ID = t.TXN_ID WHERE t.TXN_ID IS NULL' );
379
+				'DELETE r FROM '.$this->table().' r LEFT JOIN '.EEM_Transaction::instance()->table().' t ON r.TXN_ID = t.TXN_ID WHERE t.TXN_ID IS NULL' );
380 380
 	}
381 381
 
382 382
 
Please login to merge, or discard this patch.
core/db_models/EEM_Soft_Delete_Base.model.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 	 * Sum all the deleted items.
147 147
 	 * @param array $query_params like EEM_Base::get_all
148 148
 	 * @param string $field_to_sum
149
-	 * @return int
149
+	 * @return double
150 150
 	 */
151 151
 	public function sum_deleted($query_params = null, $field_to_sum = null){
152 152
 		$query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params);
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 	 * @param boolean $allow_blocking if TRUE, matched objects will only be deleted if there is no related model info
196 196
 	 * that blocks it (ie, there' sno other data that depends on this data); if false, deletes regardless of other objects
197 197
 	 * which may depend on it. Its generally advisable to always leave this as TRUE, otherwise you could easily corrupt your DB
198
-	 * @return boolean success
198
+	 * @return integer success
199 199
 	 */
200 200
 	public function delete_permanently($query_params = array(), $allow_blocking = true){
201 201
 		$query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params);
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 	/**
279 279
 	 * Updates all the items of this model which match the $query params, regardless of whether
280 280
 	 * they've been soft-deleted or not
281
-	 * @param array $field_n_values like EEM_Base::update's $fields_n_value
281
+	 * @param array $fields_n_values like EEM_Base::update's $fields_n_value
282 282
 	 * @param array $query_params like EEM_base::get_all's $query_params
283 283
 	 * @param boolean $keep_model_objs_in_sync if TRUE, makes sure we ALSO update model objects
284 284
 	 * in this model's entity map according to $fields_n_values that match $query_params. This
Please login to merge, or discard this patch.
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
2
-require_once( EE_MODELS . 'EEM_Base.model.php');
2
+require_once(EE_MODELS.'EEM_Base.model.php');
3 3
 /**
4 4
  * EEM_Soft_Delete_Base
5 5
  *
@@ -25,13 +25,13 @@  discard block
 block discarded – undo
25 25
  * @subpackage		includes/models/
26 26
  * @author				Michael Nelson
27 27
  */
28
-abstract class EEM_Soft_Delete_Base extends EEM_Base{
28
+abstract class EEM_Soft_Delete_Base extends EEM_Base {
29 29
 
30 30
 	/**
31 31
 	 * @param null $timezone
32 32
 	 */
33 33
 	protected function __construct($timezone = NULL) {
34
-		if( ! $this->_default_where_conditions_strategy instanceof EE_Default_Where_Conditions ){
34
+		if ( ! $this->_default_where_conditions_strategy instanceof EE_Default_Where_Conditions) {
35 35
 			$this->_default_where_conditions_strategy = new EE_Soft_Delete_Where_Conditions();
36 36
 		}
37 37
 		parent::__construct($timezone);
@@ -42,12 +42,12 @@  discard block
 block discarded – undo
42 42
 	 * @return string
43 43
 	 * @throws EE_Error
44 44
 	 */
45
-	public function deleted_field_name(){
45
+	public function deleted_field_name() {
46 46
 		$field = $this->get_a_field_of_type('EE_Trashed_Flag_Field');
47
-		if($field){
47
+		if ($field) {
48 48
 			return $field->get_name();
49
-		}else{
50
-			throw new EE_Error(sprintf(__('We are trying to find the deleted flag field on %s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in %s constructor?','event_espresso'),get_class($this),get_class($this)));
49
+		} else {
50
+			throw new EE_Error(sprintf(__('We are trying to find the deleted flag field on %s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in %s constructor?', 'event_espresso'), get_class($this), get_class($this)));
51 51
 		}
52 52
 	}
53 53
 
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 	 * @param array $query_params like EEM_Base::get_all's $query_params
58 58
 	 * @return EE_Soft_Delete_Base_Class
59 59
 	 */
60
-	public function get_one_deleted($query_params = array()){
60
+	public function get_one_deleted($query_params = array()) {
61 61
 		$query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params);
62 62
 		return parent::get_one($query_params);
63 63
 	}
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 	 * @param array $query_params like EEM_base::get_all's $query_params
68 68
 	 * @return EE_Soft_Delete_Base_Class
69 69
 	 */
70
-	public function get_one_deleted_or_undeleted($query_params = array()){
70
+	public function get_one_deleted_or_undeleted($query_params = array()) {
71 71
 		$query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params);
72 72
 		return parent::get_one($query_params);
73 73
 	}
@@ -77,11 +77,11 @@  discard block
 block discarded – undo
77 77
 	 * @param int|string $id
78 78
 	 * @return EE_Soft_Delete_Base_Class
79 79
 	 */
80
-	public function get_one_by_ID_but_ignore_deleted($id){
80
+	public function get_one_by_ID_but_ignore_deleted($id) {
81 81
 		return $this->get_one( 
82 82
 			$this->alter_query_params_to_restrict_by_ID( 
83 83
 				$id,
84
-				array( 'default_where_conditions' => 'default' ) 
84
+				array('default_where_conditions' => 'default') 
85 85
 			) 
86 86
 		);
87 87
 	}
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 	 * @param bool 	 $distinct if we want to only count the distinct values for the column then you can trigger that by the setting $distinct to TRUE;
94 94
 	 * @return int
95 95
 	 */
96
-	public function count_deleted($query_params = null, $field_to_count = null, $distinct = FALSE){
96
+	public function count_deleted($query_params = null, $field_to_count = null, $distinct = FALSE) {
97 97
 		$query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params);
98 98
 		return parent::count($query_params, $field_to_count, $distinct);
99 99
 	}
@@ -103,9 +103,9 @@  discard block
 block discarded – undo
103 103
 	 * @param array $query_params like EEM_Base::get_all's $query_params
104 104
 	 * @return array like EEM_Base::get_all's $query_params
105 105
 	 */
106
-	protected function _alter_query_params_so_only_trashed_items_included($query_params){
107
-		$deletedFlagFieldName=$this->deleted_field_name();
108
-		$query_params[0][$deletedFlagFieldName]=true;
106
+	protected function _alter_query_params_so_only_trashed_items_included($query_params) {
107
+		$deletedFlagFieldName = $this->deleted_field_name();
108
+		$query_params[0][$deletedFlagFieldName] = true;
109 109
 		return $query_params;
110 110
 	}
111 111
 
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 	 * @param array $query_params
115 115
 	 * @return array
116 116
 	 */
117
-	public function alter_query_params_so_deleted_and_undeleted_items_included( $query_params = array() ){
117
+	public function alter_query_params_so_deleted_and_undeleted_items_included($query_params = array()) {
118 118
 		return $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params);
119 119
 	}
120 120
 
@@ -123,8 +123,8 @@  discard block
 block discarded – undo
123 123
 	 * @param array $query_params
124 124
 	 * @return array
125 125
 	 */
126
-	protected function _alter_query_params_so_deleted_and_undeleted_items_included($query_params){
127
-		if( ! isset( $query_params[ 'default_where_conditions' ] ) ) {
126
+	protected function _alter_query_params_so_deleted_and_undeleted_items_included($query_params) {
127
+		if ( ! isset($query_params['default_where_conditions'])) {
128 128
 			$query_params['default_where_conditions'] = 'minimum';
129 129
 		}
130 130
 		return $query_params;
@@ -137,9 +137,9 @@  discard block
 block discarded – undo
137 137
 	 * @param bool 	 $distinct if we want to only count the distinct values for the column then you can trigger that by the setting $distinct to TRUE;
138 138
 	 * @return int
139 139
 	 */
140
-	public function count_deleted_and_undeleted($query_params = null, $field_to_count = null, $distinct = FALSE){
140
+	public function count_deleted_and_undeleted($query_params = null, $field_to_count = null, $distinct = FALSE) {
141 141
 		$query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params);
142
-		return parent::count($query_params,$field_to_count, $distinct);
142
+		return parent::count($query_params, $field_to_count, $distinct);
143 143
 	}
144 144
 
145 145
 	/**
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 	 * @param string $field_to_sum
149 149
 	 * @return int
150 150
 	 */
151
-	public function sum_deleted($query_params = null, $field_to_sum = null){
151
+	public function sum_deleted($query_params = null, $field_to_sum = null) {
152 152
 		$query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params);
153 153
 		return parent::sum($query_params, $field_to_sum);
154 154
 	}
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 	 * @param string $field_to_sum
160 160
 	 * @reutrn int
161 161
 	 */
162
-	public function sum_deleted_and_undeleted($query_params = null, $field_to_sum = null){
162
+	public function sum_deleted_and_undeleted($query_params = null, $field_to_sum = null) {
163 163
 		$query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params);
164 164
 		parent::sum($query_params, $field_to_sum);
165 165
 	}
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 	 * @param array $query_params like EEM_Base::get_all
170 170
 	 * @return EE_Soft_Delete_Base_Class[]
171 171
 	 */
172
-	public function get_all_deleted_and_undeleted($query_params = array()){
172
+	public function get_all_deleted_and_undeleted($query_params = array()) {
173 173
 		$query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params);
174 174
 		return parent::get_all($query_params);
175 175
 	}
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 	 * @param array $query_params like EEM_Base::get_all
180 180
 	 * @return EE_Soft_Delete_Base_Class[]
181 181
 	 */
182
-	public function get_all_deleted($query_params = array()){
182
+	public function get_all_deleted($query_params = array()) {
183 183
 		$query_params = $this->_alter_query_params_so_only_trashed_items_included($query_params);
184 184
 		return parent::get_all($query_params);
185 185
 	}
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 	 * which may depend on it. Its generally advisable to always leave this as TRUE, otherwise you could easily corrupt your DB
198 198
 	 * @return boolean success
199 199
 	 */
200
-	public function delete_permanently($query_params = array(), $allow_blocking = true){
200
+	public function delete_permanently($query_params = array(), $allow_blocking = true) {
201 201
 		$query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params);
202 202
 		return parent::delete_permanently($query_params, $allow_blocking);
203 203
 	}
@@ -208,8 +208,8 @@  discard block
 block discarded – undo
208 208
 	 * @param mixed $ID int if primary key is an int, string otherwise
209 209
 	 * @return boolean success
210 210
 	 */
211
-	public function restore_by_ID($ID=FALSE){
212
-		return $this->delete_or_restore_by_ID(false,$ID);
211
+	public function restore_by_ID($ID = FALSE) {
212
+		return $this->delete_or_restore_by_ID(false, $ID);
213 213
 	}
214 214
 	/**
215 215
 	 * For deleting or restoring a particular item. Note that this model is a SOFT-DELETABLE model! However,
@@ -218,14 +218,14 @@  discard block
 block discarded – undo
218 218
 	 * @param mixed $ID int if primary key is an int, string otherwise
219 219
 	 * @return boolean
220 220
 	 */
221
-	public function delete_or_restore_by_ID($delete=true,$ID=FALSE){
222
-		if ( ! $ID ) {
221
+	public function delete_or_restore_by_ID($delete = true, $ID = FALSE) {
222
+		if ( ! $ID) {
223 223
 			return FALSE;
224 224
 		}
225 225
 		if ( 
226 226
 			$this->delete_or_restore(
227 227
 				$delete, 
228
-				$this->alter_query_params_to_restrict_by_ID( $ID ) 
228
+				$this->alter_query_params_to_restrict_by_ID($ID) 
229 229
 			)
230 230
 		) {
231 231
 			return TRUE;
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
 	 * @param bool  $block_deletes
246 246
 	 * @return boolean
247 247
 	 */
248
-	public function delete($query_params = array(), $block_deletes = false){
248
+	public function delete($query_params = array(), $block_deletes = false) {
249 249
 		//no matter what, we WON'T block soft deletes.
250 250
 		return $this->delete_or_restore(true, $query_params);
251 251
 	}
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 	 * @param array $query_params like EEM_Base::get_all
257 257
 	 * @return boolean
258 258
 	 */
259
-	public function restore($query_params = array()){
259
+	public function restore($query_params = array()) {
260 260
 		return $this->delete_or_restore(false, $query_params);
261 261
 	}
262 262
 	/**
@@ -265,10 +265,10 @@  discard block
 block discarded – undo
265 265
 	 * @param array $query_params like EEM_Base::get_all
266 266
 	 * @return boolean
267 267
 	 */
268
-	function delete_or_restore($delete=true,$query_params = array()){
269
-		$deletedFlagFieldName=$this->deleted_field_name();
268
+	function delete_or_restore($delete = true, $query_params = array()) {
269
+		$deletedFlagFieldName = $this->deleted_field_name();
270 270
 		$query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params);
271
-		if ( $this->update (array($deletedFlagFieldName=>$delete), $query_params )) {
271
+		if ($this->update(array($deletedFlagFieldName=>$delete), $query_params)) {
272 272
 			return TRUE;
273 273
 		} else {
274 274
 			return FALSE;
@@ -286,8 +286,8 @@  discard block
 block discarded – undo
286 286
 	 * be aware that model objects being used could get out-of-sync with the database
287 287
 	 * @return int number of items updated
288 288
 	 */
289
-	public function update_deleted_and_undeleted($fields_n_values, $query_params, $keep_model_objs_in_sync = TRUE ){
289
+	public function update_deleted_and_undeleted($fields_n_values, $query_params, $keep_model_objs_in_sync = TRUE) {
290 290
 		$query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params);
291
-		return $this->update($fields_n_values, $query_params, $keep_model_objs_in_sync );
291
+		return $this->update($fields_n_values, $query_params, $keep_model_objs_in_sync);
292 292
 	}
293 293
 }
Please login to merge, or discard this patch.
core/db_models/strategies/EE_CPT_Minimum_Where_Conditions.strategy.php 3 patches
Doc Comments   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,6 +7,10 @@  discard block
 block discarded – undo
7 7
 
8 8
 	protected $_post_type;
9 9
 	protected $_meta_field;
10
+
11
+	/**
12
+	 * @param string $post_type
13
+	 */
10 14
 	function __construct($post_type, $meta_field_to_chk = ''){
11 15
 		$this->_post_type = $post_type;
12 16
 		$this->_meta_field = $meta_field_to_chk;
@@ -27,7 +31,6 @@  discard block
 block discarded – undo
27 31
 	}
28 32
 	/**
29 33
 	 * Gets the where default where conditions for a custom post type model
30
-	 * @param string $model_relation_path. Eg, from Event to Payment, this should be "Registration.Transaction.Payment"
31 34
 	 * @return array like EEM_Base::get_all's $query_params's index [0] (where conditions)
32 35
 	 */
33 36
 	protected function _get_default_where_conditions() {
Please login to merge, or discard this patch.
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -3,18 +3,18 @@
 block discarded – undo
3 3
 	exit( 'No direct script access allowed' );
4 4
 }
5 5
 /**
6
- *
7
- * Class EE_CPT_Minimum_Where_Conditions
8
-  * 
9
- * Strategy specifically for adding where conditions specific to CPT models.
10
- * But only sets the minimum, so any row of the right type will get used
11
- *
12
- * @package         Event Espresso
13
- * @subpackage    core/db_models
14
- * @author				Mike Nelson
15
- * @since		 	   4.8.29.rc.010
16
- *
17
- */
6
+	 *
7
+	 * Class EE_CPT_Minimum_Where_Conditions
8
+	 * 
9
+	 * Strategy specifically for adding where conditions specific to CPT models.
10
+	 * But only sets the minimum, so any row of the right type will get used
11
+	 *
12
+	 * @package         Event Espresso
13
+	 * @subpackage    core/db_models
14
+	 * @author				Mike Nelson
15
+	 * @since		 	   4.8.29.rc.010
16
+	 *
17
+	 */
18 18
 class EE_CPT_Minimum_Where_Conditions extends EE_Default_Where_Conditions{
19 19
 
20 20
 	protected $_post_type;
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
3
-	exit( 'No direct script access allowed' );
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3
+	exit('No direct script access allowed');
4 4
 }
5 5
 /**
6 6
  *
@@ -15,11 +15,11 @@  discard block
 block discarded – undo
15 15
  * @since		 	   4.8.29.rc.010
16 16
  *
17 17
  */
18
-class EE_CPT_Minimum_Where_Conditions extends EE_Default_Where_Conditions{
18
+class EE_CPT_Minimum_Where_Conditions extends EE_Default_Where_Conditions {
19 19
 
20 20
 	protected $_post_type;
21 21
 	protected $_meta_field;
22
-	function __construct($post_type, $meta_field_to_chk = ''){
22
+	function __construct($post_type, $meta_field_to_chk = '') {
23 23
 		$this->_post_type = $post_type;
24 24
 		$this->_meta_field = $meta_field_to_chk;
25 25
 	}
@@ -29,10 +29,10 @@  discard block
 block discarded – undo
29 29
 	 * @param string $column column name
30 30
 	 * @return EE_Model_Field_Base
31 31
 	 */
32
-	protected function _get_field_on_column($column){
32
+	protected function _get_field_on_column($column) {
33 33
 		$all_fields = $this->_model->field_settings(true);
34
-		foreach($all_fields as $field_name => $field_obj){
35
-			if($column == $field_obj->get_table_column()){
34
+		foreach ($all_fields as $field_name => $field_obj) {
35
+			if ($column == $field_obj->get_table_column()) {
36 36
 				return $field_obj;
37 37
 			}
38 38
 		}
Please login to merge, or discard this patch.
core/db_models/strategies/EE_CPT_Where_Conditions.strategy.php 3 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,6 @@
 block discarded – undo
17 17
 class EE_CPT_Where_Conditions extends EE_CPT_Minimum_Where_Conditions{
18 18
 	/**
19 19
 	 * Gets the where default where conditions for a custom post type model
20
-	 * @param string $model_relation_path. Eg, from Event to Payment, this should be "Registration.Transaction.Payment"
21 20
 	 * @return array like EEM_Base::get_all's $query_params's index [0] (where conditions)
22 21
 	 */
23 22
 	protected function _get_default_where_conditions() {
Please login to merge, or discard this patch.
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -3,17 +3,17 @@
 block discarded – undo
3 3
 	exit( 'No direct script access allowed' );
4 4
 }
5 5
 /**
6
- *
7
- * Class EE_Default_Where_Conditions
8
-  * 
9
- * Strategy specifically for adding where conditions specific to CPT models.
10
- *
11
- * @package         Event Espresso
12
- * @subpackage    core/db_models
13
- * @author				Mike Nelson
14
- * * @since		 	   4.6.0
15
- *
16
- */
6
+	 *
7
+	 * Class EE_Default_Where_Conditions
8
+	 * 
9
+	 * Strategy specifically for adding where conditions specific to CPT models.
10
+	 *
11
+	 * @package         Event Espresso
12
+	 * @subpackage    core/db_models
13
+	 * @author				Mike Nelson
14
+	 * * @since		 	   4.6.0
15
+	 *
16
+	 */
17 17
 class EE_CPT_Where_Conditions extends EE_CPT_Minimum_Where_Conditions{
18 18
 	/**
19 19
 	 * Gets the where default where conditions for a custom post type model
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
3
-	exit( 'No direct script access allowed' );
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3
+	exit('No direct script access allowed');
4 4
 }
5 5
 /**
6 6
  *
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
  * * @since		 	   4.6.0
15 15
  *
16 16
  */
17
-class EE_CPT_Where_Conditions extends EE_CPT_Minimum_Where_Conditions{
17
+class EE_CPT_Where_Conditions extends EE_CPT_Minimum_Where_Conditions {
18 18
 	/**
19 19
 	 * Gets the where default where conditions for a custom post type model
20 20
 	 * @param string $model_relation_path. Eg, from Event to Payment, this should be "Registration.Transaction.Payment"
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 		return array_merge( 
26 26
 			parent::_get_default_where_conditions(),
27 27
 			array( 
28
-				$status_field->get_name() => array('NOT IN',array('auto-draft','trash') )
28
+				$status_field->get_name() => array('NOT IN', array('auto-draft', 'trash'))
29 29
 			)
30 30
 		);
31 31
 	}
Please login to merge, or discard this patch.
modules/ticket_sales_monitor/EED_Ticket_Sales_Monitor.module.php 2 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 	 * @access    protected
239 239
 	 * @param    \EE_Ticket $ticket
240 240
 	 * @param int           $quantity
241
-	 * @return bool
241
+	 * @return integer
242 242
 	 * @throws \EE_Error
243 243
 	 */
244 244
 	protected function _reserve_ticket( EE_Ticket $ticket, $quantity = 1 ) {
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 	 * @access protected
258 258
 	 * @param  EE_Ticket $ticket
259 259
 	 * @param  int       $quantity
260
-	 * @return bool
260
+	 * @return integer
261 261
 	 * @throws \EE_Error
262 262
 	 */
263 263
 	protected function _release_reserved_ticket( EE_Ticket $ticket, $quantity = 1 ) {
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 	 *
281 281
 	 * @access 	protected
282 282
 	 * @param 	\EE_Ticket   $ticket
283
-	 * @return 	bool
283
+	 * @return 	boolean|null
284 284
 	 * @throws \EE_Error
285 285
 	 */
286 286
 	protected function _ticket_sold_out( EE_Ticket $ticket ) {
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 	 *
300 300
 	 * @access    protected
301 301
 	 * @param    \EE_Ticket $ticket
302
-	 * @return bool
302
+	 * @return boolean|null
303 303
 	 */
304 304
 	protected function _ticket_quantity_decremented( EE_Ticket $ticket ) {
305 305
 		if ( self::debug ) {
Please login to merge, or discard this patch.
Spacing   +166 added lines, -166 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
3
-	exit( 'No direct script access allowed' );
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3
+	exit('No direct script access allowed');
4 4
 }
5 5
 /**
6 6
  * Class EED_Ticket_Sales_Monitor
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  */
18 18
 class EED_Ticket_Sales_Monitor extends EED_Module {
19 19
 
20
-	const debug = false; 	//	true false
20
+	const debug = false; //	true false
21 21
 
22 22
 	/**
23 23
 	 * an array of raw ticket data from EED_Ticket_Selector
@@ -59,58 +59,58 @@  discard block
 block discarded – undo
59 59
 	 */
60 60
 	public static function set_hooks() {
61 61
 		// check ticket reserves AFTER MER does it's check (hence priority 20)
62
-		add_filter( 'FHEE__EE_Ticket_Selector___add_ticket_to_cart__ticket_qty',
63
-			array( 'EED_Ticket_Sales_Monitor', 'validate_ticket_sale' ),
62
+		add_filter('FHEE__EE_Ticket_Selector___add_ticket_to_cart__ticket_qty',
63
+			array('EED_Ticket_Sales_Monitor', 'validate_ticket_sale'),
64 64
 			20, 3
65 65
 		);
66 66
 		// add notices for sold out tickets
67
-		add_action( 'AHEE__EE_Ticket_Selector__process_ticket_selections__after_tickets_added_to_cart',
68
-			array( 'EED_Ticket_Sales_Monitor', 'post_notices' ),
67
+		add_action('AHEE__EE_Ticket_Selector__process_ticket_selections__after_tickets_added_to_cart',
68
+			array('EED_Ticket_Sales_Monitor', 'post_notices'),
69 69
 			10
70 70
 		);
71 71
 		// handle ticket quantities adjusted in cart
72 72
 		add_action(
73 73
 			'FHEE__EED_Multi_Event_Registration__adjust_line_item_quantity__line_item_quantity_updated',
74
-			array( 'EED_Ticket_Sales_Monitor', 'ticket_quantity_updated' ),
74
+			array('EED_Ticket_Sales_Monitor', 'ticket_quantity_updated'),
75 75
 			10, 2
76 76
 		);
77 77
 		// handle tickets deleted from cart
78 78
 		add_action(
79 79
 			'FHEE__EED_Multi_Event_Registration__delete_ticket__ticket_removed_from_cart',
80
-			array( 'EED_Ticket_Sales_Monitor', 'ticket_removed_from_cart' ),
80
+			array('EED_Ticket_Sales_Monitor', 'ticket_removed_from_cart'),
81 81
 			10, 2
82 82
 		);
83 83
 		// handle emptied carts
84 84
 		add_action(
85 85
 			'AHEE__EE_Session__reset_cart__before_reset',
86
-			array( 'EED_Ticket_Sales_Monitor', 'session_cart_reset' ),
86
+			array('EED_Ticket_Sales_Monitor', 'session_cart_reset'),
87 87
 			10, 1
88 88
 		);
89 89
 		add_action(
90 90
 			'AHEE__EED_Multi_Event_Registration__empty_event_cart__before_delete_cart',
91
-			array( 'EED_Ticket_Sales_Monitor', 'session_cart_reset' ),
91
+			array('EED_Ticket_Sales_Monitor', 'session_cart_reset'),
92 92
 			10, 1
93 93
 		);
94 94
 		// handle cancelled registrations
95 95
 		add_action(
96 96
 			'AHEE__EE_Session__reset_checkout__before_reset',
97
-			array( 'EED_Ticket_Sales_Monitor', 'session_checkout_reset' ),
97
+			array('EED_Ticket_Sales_Monitor', 'session_checkout_reset'),
98 98
 			10, 1
99 99
 		);
100 100
 		// cron tasks
101 101
 		add_action(
102 102
 			'AHEE__EE_Cron_Tasks__finalize_abandoned_transactions__abandoned_transaction',
103
-			array( 'EED_Ticket_Sales_Monitor', 'process_abandoned_transactions' ),
103
+			array('EED_Ticket_Sales_Monitor', 'process_abandoned_transactions'),
104 104
 			10, 1
105 105
 		);
106 106
 		add_action(
107 107
 			'AHEE__EE_Cron_Tasks__process_expired_transactions__incomplete_transaction',
108
-			array( 'EED_Ticket_Sales_Monitor', 'process_abandoned_transactions' ),
108
+			array('EED_Ticket_Sales_Monitor', 'process_abandoned_transactions'),
109 109
 			10, 1
110 110
 		);
111 111
 		add_action(
112 112
 			'AHEE__EE_Cron_Tasks__process_expired_transactions__failed_transaction',
113
-			array( 'EED_Ticket_Sales_Monitor', 'process_failed_transactions' ),
113
+			array('EED_Ticket_Sales_Monitor', 'process_failed_transactions'),
114 114
 			10, 1
115 115
 		);
116 116
 
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 	 * @return EED_Ticket_Sales_Monitor
135 135
 	 */
136 136
 	public static function instance() {
137
-		return parent::get_instance( __CLASS__ );
137
+		return parent::get_instance(__CLASS__);
138 138
 	}
139 139
 
140 140
 
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 	 * @param WP_Query $WP_Query
147 147
 	 * @return    void
148 148
 	 */
149
-	public function run( $WP_Query ) {
149
+	public function run($WP_Query) {
150 150
 	}
151 151
 
152 152
 
@@ -164,14 +164,14 @@  discard block
 block discarded – undo
164 164
 	 * @param \EE_Ticket $ticket
165 165
 	 * @return bool
166 166
 	 */
167
-	public static function validate_ticket_sale( $qty = 1, EE_Ticket $ticket  ) {
168
-		$qty = absint( $qty );
169
-		if ( $qty > 0 ) {
170
-			$qty = EED_Ticket_Sales_Monitor::instance()->_validate_ticket_sale( $ticket, $qty );
167
+	public static function validate_ticket_sale($qty = 1, EE_Ticket $ticket) {
168
+		$qty = absint($qty);
169
+		if ($qty > 0) {
170
+			$qty = EED_Ticket_Sales_Monitor::instance()->_validate_ticket_sale($ticket, $qty);
171 171
 		}
172
-		if ( self::debug ) {
173
-			echo "\n\n " . __LINE__ . ") " . __METHOD__ . "() <br />";
174
-			echo "\n qty: " . $qty;
172
+		if (self::debug) {
173
+			echo "\n\n ".__LINE__.") ".__METHOD__."() <br />";
174
+			echo "\n qty: ".$qty;
175 175
 		}
176 176
 		return $qty;
177 177
 	}
@@ -187,45 +187,45 @@  discard block
 block discarded – undo
187 187
 	 * @param int          $qty
188 188
 	 * @return int
189 189
 	 */
190
-	protected function _validate_ticket_sale( EE_Ticket $ticket, $qty = 1 ) {
191
-		if ( self::debug ) {
192
-			echo "\n\n " . __LINE__ . ") " . __METHOD__ . "() <br />";
190
+	protected function _validate_ticket_sale(EE_Ticket $ticket, $qty = 1) {
191
+		if (self::debug) {
192
+			echo "\n\n ".__LINE__.") ".__METHOD__."() <br />";
193 193
 		}
194
-		if ( ! $ticket instanceof EE_Ticket ) {
194
+		if ( ! $ticket instanceof EE_Ticket) {
195 195
 			return 0;
196 196
 		}
197
-		if ( self::debug ) {
198
-			echo "\n . ticket->ID: " . $ticket->ID() . '<br />';
199
-			echo "\n . original ticket->reserved: " . $ticket->reserved() . '<br />';
197
+		if (self::debug) {
198
+			echo "\n . ticket->ID: ".$ticket->ID().'<br />';
199
+			echo "\n . original ticket->reserved: ".$ticket->reserved().'<br />';
200 200
 		}
201 201
 		$ticket->refresh_from_db();
202 202
 		// first let's determine the ticket availability based on sales
203
-		$available = $ticket->qty( 'saleable' );
204
-		if ( self::debug ) {
205
-			echo "\n . . . ticket->qty: " . $ticket->qty() . '<br />';
206
-			echo "\n . . . ticket->sold: " . $ticket->sold() . '<br />';
207
-			echo "\n . . . ticket->reserved: " . $ticket->reserved() . '<br />';
208
-			echo "\n . . . ticket->qty(saleable): " . $ticket->qty( 'saleable' ) . '<br />';
209
-			echo "\n . . . available: " . $available . '<br />';
210
-		}
211
-		if ( $available < 1 ) {
212
-			$this->_ticket_sold_out( $ticket );
203
+		$available = $ticket->qty('saleable');
204
+		if (self::debug) {
205
+			echo "\n . . . ticket->qty: ".$ticket->qty().'<br />';
206
+			echo "\n . . . ticket->sold: ".$ticket->sold().'<br />';
207
+			echo "\n . . . ticket->reserved: ".$ticket->reserved().'<br />';
208
+			echo "\n . . . ticket->qty(saleable): ".$ticket->qty('saleable').'<br />';
209
+			echo "\n . . . available: ".$available.'<br />';
210
+		}
211
+		if ($available < 1) {
212
+			$this->_ticket_sold_out($ticket);
213 213
 			return 0;
214 214
 		}
215
-		if ( self::debug ) {
216
-			echo "\n . . . qty: " . $qty . '<br />';
215
+		if (self::debug) {
216
+			echo "\n . . . qty: ".$qty.'<br />';
217 217
 		}
218
-		if ( $available < $qty ) {
218
+		if ($available < $qty) {
219 219
 			$qty = $available;
220
-			if ( self::debug ) {
221
-				echo "\n . . . QTY ADJUSTED: " . $qty . '<br />';
220
+			if (self::debug) {
221
+				echo "\n . . . QTY ADJUSTED: ".$qty.'<br />';
222 222
 			}
223
-			$this->_ticket_quantity_decremented( $ticket );
223
+			$this->_ticket_quantity_decremented($ticket);
224 224
 		}
225
-		if ( self::debug ) {
226
-			echo "\n\n . . . INCREASE RESERVED: " . $qty . '<br/><br/>';
225
+		if (self::debug) {
226
+			echo "\n\n . . . INCREASE RESERVED: ".$qty.'<br/><br/>';
227 227
 		}
228
-		$this->_reserve_ticket( $ticket, $qty );
228
+		$this->_reserve_ticket($ticket, $qty);
229 229
 		return $qty;
230 230
 	}
231 231
 
@@ -241,11 +241,11 @@  discard block
 block discarded – undo
241 241
 	 * @return bool
242 242
 	 * @throws \EE_Error
243 243
 	 */
244
-	protected function _reserve_ticket( EE_Ticket $ticket, $quantity = 1 ) {
245
-		if ( self::debug ) {
246
-			echo "\n\n . . . INCREASE RESERVED: " . $quantity . '<br/><br/>';
244
+	protected function _reserve_ticket(EE_Ticket $ticket, $quantity = 1) {
245
+		if (self::debug) {
246
+			echo "\n\n . . . INCREASE RESERVED: ".$quantity.'<br/><br/>';
247 247
 		}
248
-		$ticket->increase_reserved( $quantity );
248
+		$ticket->increase_reserved($quantity);
249 249
 		return $ticket->save();
250 250
 	}
251 251
 
@@ -260,14 +260,14 @@  discard block
 block discarded – undo
260 260
 	 * @return bool
261 261
 	 * @throws \EE_Error
262 262
 	 */
263
-	protected function _release_reserved_ticket( EE_Ticket $ticket, $quantity = 1 ) {
264
-		if ( self::debug ) {
265
-			echo "\n . . . ticket->ID: " . $ticket->ID() . '<br />';
266
-			echo "\n . . . ticket->reserved: " . $ticket->reserved() . '<br />';
263
+	protected function _release_reserved_ticket(EE_Ticket $ticket, $quantity = 1) {
264
+		if (self::debug) {
265
+			echo "\n . . . ticket->ID: ".$ticket->ID().'<br />';
266
+			echo "\n . . . ticket->reserved: ".$ticket->reserved().'<br />';
267 267
 		}
268
-		$ticket->decrease_reserved( $quantity );
269
-		if ( self::debug ) {
270
-			echo "\n . . . ticket->reserved: " . $ticket->reserved() . '<br />';
268
+		$ticket->decrease_reserved($quantity);
269
+		if (self::debug) {
270
+			echo "\n . . . ticket->reserved: ".$ticket->reserved().'<br />';
271 271
 		}
272 272
 		return $ticket->save() ? 1 : 0;
273 273
 	}
@@ -283,12 +283,12 @@  discard block
 block discarded – undo
283 283
 	 * @return 	bool
284 284
 	 * @throws \EE_Error
285 285
 	 */
286
-	protected function _ticket_sold_out( EE_Ticket $ticket ) {
287
-		if ( self::debug ) {
288
-			echo "\n\n " . __LINE__ . ") " . __METHOD__ . "() <br />";
289
-			echo "\n . . ticket->name: " . $this->_get_ticket_and_event_name( $ticket ) . '<br />';
286
+	protected function _ticket_sold_out(EE_Ticket $ticket) {
287
+		if (self::debug) {
288
+			echo "\n\n ".__LINE__.") ".__METHOD__."() <br />";
289
+			echo "\n . . ticket->name: ".$this->_get_ticket_and_event_name($ticket).'<br />';
290 290
 		}
291
-		$this->sold_out_tickets[] = $this->_get_ticket_and_event_name( $ticket );
291
+		$this->sold_out_tickets[] = $this->_get_ticket_and_event_name($ticket);
292 292
 	}
293 293
 
294 294
 
@@ -301,12 +301,12 @@  discard block
 block discarded – undo
301 301
 	 * @param    \EE_Ticket $ticket
302 302
 	 * @return bool
303 303
 	 */
304
-	protected function _ticket_quantity_decremented( EE_Ticket $ticket ) {
305
-		if ( self::debug ) {
306
-			echo "\n\n " . __LINE__ . ") " . __METHOD__ . "() <br />";
307
-			echo "\n . . ticket->name: " . $this->_get_ticket_and_event_name( $ticket ) . '<br />';
304
+	protected function _ticket_quantity_decremented(EE_Ticket $ticket) {
305
+		if (self::debug) {
306
+			echo "\n\n ".__LINE__.") ".__METHOD__."() <br />";
307
+			echo "\n . . ticket->name: ".$this->_get_ticket_and_event_name($ticket).'<br />';
308 308
 		}
309
-		$this->decremented_tickets[] = $this->_get_ticket_and_event_name( $ticket );
309
+		$this->decremented_tickets[] = $this->_get_ticket_and_event_name($ticket);
310 310
 	}
311 311
 
312 312
 
@@ -319,11 +319,11 @@  discard block
 block discarded – undo
319 319
 	 * @param    \EE_Ticket $ticket
320 320
 	 * @return string
321 321
 	 */
322
-	protected function _get_ticket_and_event_name( EE_Ticket $ticket ) {
322
+	protected function _get_ticket_and_event_name(EE_Ticket $ticket) {
323 323
 		$event = $ticket->get_related_event();
324
-		if ( $event instanceof EE_Event ) {
324
+		if ($event instanceof EE_Event) {
325 325
 			$ticket_name = sprintf(
326
-				_x( '%1$s for %2$s', 'ticket name for event name', 'event_espresso' ),
326
+				_x('%1$s for %2$s', 'ticket name for event name', 'event_espresso'),
327 327
 				$ticket->name(),
328 328
 				$event->name()
329 329
 			);
@@ -348,13 +348,13 @@  discard block
 block discarded – undo
348 348
 	 * @param  int          $quantity
349 349
 	 * @return void
350 350
 	 */
351
-	public static function ticket_quantity_updated( EE_Line_Item $line_item, $quantity = 1 ) {
352
-		$ticket = EEM_Ticket::instance()->get_one_by_ID( absint( $line_item->OBJ_ID() ) );
353
-		if ( $ticket instanceof EE_Ticket ) {
354
-			if ( $quantity > 0 ) {
355
-				EED_Ticket_Sales_Monitor::instance()->_reserve_ticket( $ticket, $quantity );
351
+	public static function ticket_quantity_updated(EE_Line_Item $line_item, $quantity = 1) {
352
+		$ticket = EEM_Ticket::instance()->get_one_by_ID(absint($line_item->OBJ_ID()));
353
+		if ($ticket instanceof EE_Ticket) {
354
+			if ($quantity > 0) {
355
+				EED_Ticket_Sales_Monitor::instance()->_reserve_ticket($ticket, $quantity);
356 356
 			} else {
357
-				EED_Ticket_Sales_Monitor::instance()->_release_reserved_ticket( $ticket, $quantity );
357
+				EED_Ticket_Sales_Monitor::instance()->_release_reserved_ticket($ticket, $quantity);
358 358
 			}
359 359
 		}
360 360
 	}
@@ -370,8 +370,8 @@  discard block
 block discarded – undo
370 370
 	 * @param  int       $quantity
371 371
 	 * @return void
372 372
 	 */
373
-	public static function ticket_removed_from_cart( EE_Ticket $ticket, $quantity = 1 ) {
374
-		EED_Ticket_Sales_Monitor::instance()->_release_reserved_ticket( $ticket, $quantity );
373
+	public static function ticket_removed_from_cart(EE_Ticket $ticket, $quantity = 1) {
374
+		EED_Ticket_Sales_Monitor::instance()->_release_reserved_ticket($ticket, $quantity);
375 375
 	}
376 376
 
377 377
 
@@ -399,34 +399,34 @@  discard block
 block discarded – undo
399 399
 	 * @return    void
400 400
 	 */
401 401
 	protected function _post_notices() {
402
-		if ( self::debug ) {
403
-			echo "\n\n " . __LINE__ . ") " . __METHOD__ . "() <br />";
402
+		if (self::debug) {
403
+			echo "\n\n ".__LINE__.") ".__METHOD__."() <br />";
404 404
 		}
405
-		if ( ! empty( $this->sold_out_tickets ) ) {
405
+		if ( ! empty($this->sold_out_tickets)) {
406 406
 			EE_Error::add_attention(
407 407
 				sprintf(
408 408
 					apply_filters(
409 409
 						'FHEE__EED_Ticket_Sales_Monitor___post_notices__sold_out_tickets_notice',
410
-						__( 'We\'re sorry...%1$sThe following items have sold out since you first viewed this page, and can no longer be registered for:%1$s%1$s%2$s%1$s%1$sPlease note that availability can change at any time due to cancellations, so please check back again later if registration for this event(s) is important to you.', 'event_espresso' )
410
+						__('We\'re sorry...%1$sThe following items have sold out since you first viewed this page, and can no longer be registered for:%1$s%1$s%2$s%1$s%1$sPlease note that availability can change at any time due to cancellations, so please check back again later if registration for this event(s) is important to you.', 'event_espresso')
411 411
 					),
412 412
 					'<br />',
413
-					implode( '<br />', $this->sold_out_tickets )
413
+					implode('<br />', $this->sold_out_tickets)
414 414
 				)
415 415
 			);
416 416
 			// alter code flow in the Ticket Selector for better UX
417
-			add_filter( 'FHEE__EED_Ticket_Selector__process_ticket_selections__tckts_slctd', '__return_true' );
418
-			add_filter( 'FHEE__EED_Ticket_Selector__process_ticket_selections__success', '__return_false' );
417
+			add_filter('FHEE__EED_Ticket_Selector__process_ticket_selections__tckts_slctd', '__return_true');
418
+			add_filter('FHEE__EED_Ticket_Selector__process_ticket_selections__success', '__return_false');
419 419
 			$this->sold_out_tickets = array();
420 420
 		}
421
-		if ( ! empty( $this->decremented_tickets ) ) {
421
+		if ( ! empty($this->decremented_tickets)) {
422 422
 			EE_Error::add_attention(
423 423
 				sprintf(
424 424
 					apply_filters(
425 425
 						'FHEE__EED_Ticket_Sales_Monitor___ticket_quantity_decremented__notice',
426
-						__( 'We\'re sorry...%1$sDue to sales that have occurred since you first viewed the last page, the following items have had their quantities adjusted to match the current available amount:%1$s%1$s%2$s%1$s%1$sPlease note that availability can change at any time due to cancellations, so please check back again later if registration for this event(s) is important to you.', 'event_espresso' )
426
+						__('We\'re sorry...%1$sDue to sales that have occurred since you first viewed the last page, the following items have had their quantities adjusted to match the current available amount:%1$s%1$s%2$s%1$s%1$sPlease note that availability can change at any time due to cancellations, so please check back again later if registration for this event(s) is important to you.', 'event_espresso')
427 427
 					),
428 428
 					'<br />',
429
-					implode( '<br />', $this->decremented_tickets )
429
+					implode('<br />', $this->decremented_tickets)
430 430
 				)
431 431
 			);
432 432
 			$this->decremented_tickets = array();
@@ -448,27 +448,27 @@  discard block
 block discarded – undo
448 448
 	 * @param 	EE_Transaction 	$transaction
449 449
 	 * @return int
450 450
 	 */
451
-	protected function _release_all_reserved_tickets_for_transaction( EE_Transaction $transaction ) {
452
-		if ( self::debug ) {
453
-			echo "\n\n " . __LINE__ . ") " . __METHOD__ . "() <br />";
454
-			echo "\n . transaction->ID: " . $transaction->ID() . '<br />';
451
+	protected function _release_all_reserved_tickets_for_transaction(EE_Transaction $transaction) {
452
+		if (self::debug) {
453
+			echo "\n\n ".__LINE__.") ".__METHOD__."() <br />";
454
+			echo "\n . transaction->ID: ".$transaction->ID().'<br />';
455 455
 		}
456 456
 		/** @type EE_Transaction_Processor $transaction_processor */
457
-		$transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' );
457
+		$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
458 458
 		// check if 'finalize_registration' step has been completed...
459
-		$finalized = $transaction_processor->reg_step_completed( $transaction, 'finalize_registration' );
460
-		if ( self::debug ) {
459
+		$finalized = $transaction_processor->reg_step_completed($transaction, 'finalize_registration');
460
+		if (self::debug) {
461 461
 			// DEBUG LOG
462 462
 			EEH_Debug_Tools::log(
463 463
 				__CLASS__, __FUNCTION__, __LINE__,
464
-				array( 'finalized' => $finalized ),
465
-				false, 'EE_Transaction: ' . $transaction->ID()
464
+				array('finalized' => $finalized),
465
+				false, 'EE_Transaction: '.$transaction->ID()
466 466
 			);
467 467
 		}
468 468
 		// how many tickets were released
469 469
 		$count = 0;
470
-		if ( self::debug ) {
471
-			echo "\n . . . finalized: " . $finalized . '<br />';
470
+		if (self::debug) {
471
+			echo "\n . . . finalized: ".$finalized.'<br />';
472 472
 		}
473 473
 		$release_tickets_with_TXN_status = array(
474 474
 			EEM_Transaction::failed_status_code,
@@ -476,13 +476,13 @@  discard block
 block discarded – undo
476 476
 			EEM_Transaction::incomplete_status_code,
477 477
 		);
478 478
 		// if the session is getting cleared BEFORE the TXN has been finalized
479
-		if ( ! $finalized || in_array( $transaction->status_ID(), $release_tickets_with_TXN_status ) ) {
479
+		if ( ! $finalized || in_array($transaction->status_ID(), $release_tickets_with_TXN_status)) {
480 480
 			// let's cancel any reserved tickets
481 481
 			$registrations = $transaction->registrations();
482
-			if ( ! empty( $registrations ) ) {
483
-				foreach ( $registrations as $registration ) {
484
-					if ( $registration instanceof EE_Registration ) {
485
-						$count += $this->_release_reserved_ticket_for_registration( $registration, $transaction );
482
+			if ( ! empty($registrations)) {
483
+				foreach ($registrations as $registration) {
484
+					if ($registration instanceof EE_Registration) {
485
+						$count += $this->_release_reserved_ticket_for_registration($registration, $transaction);
486 486
 					}
487 487
 				}
488 488
 			}
@@ -503,12 +503,12 @@  discard block
 block discarded – undo
503 503
 	 * @return 	int
504 504
 	 * @throws 	\EE_Error
505 505
 	 */
506
-	protected function _release_reserved_ticket_for_registration( EE_Registration $registration, EE_Transaction $transaction ) {
507
-		if ( self::debug ) {
508
-			echo "\n\n " . __LINE__ . ") " . __METHOD__ . "() <br />";
509
-			echo "\n . . registration->ID: " . $registration->ID() . '<br />';
510
-			echo "\n . . registration->status_ID: " . $registration->status_ID() . '<br />';
511
-			echo "\n . . transaction->status_ID(): " . $transaction->status_ID() . '<br />';
506
+	protected function _release_reserved_ticket_for_registration(EE_Registration $registration, EE_Transaction $transaction) {
507
+		if (self::debug) {
508
+			echo "\n\n ".__LINE__.") ".__METHOD__."() <br />";
509
+			echo "\n . . registration->ID: ".$registration->ID().'<br />';
510
+			echo "\n . . registration->status_ID: ".$registration->status_ID().'<br />';
511
+			echo "\n . . transaction->status_ID(): ".$transaction->status_ID().'<br />';
512 512
 		}
513 513
 		if (
514 514
 			// release Tickets for Failed Transactions and Abandoned Transactions
@@ -521,8 +521,8 @@  discard block
 block discarded – undo
521 521
 			)
522 522
 		) {
523 523
 			$ticket = $registration->ticket();
524
-			if ( $ticket instanceof EE_Ticket ) {
525
-				return $this->_release_reserved_ticket( $ticket );
524
+			if ($ticket instanceof EE_Ticket) {
525
+				return $this->_release_reserved_ticket($ticket);
526 526
 			}
527 527
 		}
528 528
 		return 0;
@@ -542,20 +542,20 @@  discard block
 block discarded – undo
542 542
 	 * @param    EE_Session $session
543 543
 	 * @return    void
544 544
 	 */
545
-	public static function session_cart_reset( EE_Session $session ) {
546
-		if ( self::debug ) {
547
-			echo "\n\n " . __LINE__ . ") " . __METHOD__ . "() <br />";
545
+	public static function session_cart_reset(EE_Session $session) {
546
+		if (self::debug) {
547
+			echo "\n\n ".__LINE__.") ".__METHOD__."() <br />";
548 548
 		}
549 549
 		$cart = $session->cart();
550
-		if ( $cart instanceof EE_Cart ) {
551
-			if ( self::debug ) {
552
-				echo "\n\n cart instanceof EE_Cart: " . "<br />";
550
+		if ($cart instanceof EE_Cart) {
551
+			if (self::debug) {
552
+				echo "\n\n cart instanceof EE_Cart: "."<br />";
553 553
 			}
554
-			EED_Ticket_Sales_Monitor::instance()->_session_cart_reset( $cart );
554
+			EED_Ticket_Sales_Monitor::instance()->_session_cart_reset($cart);
555 555
 		} else {
556
-			if ( self::debug ) {
557
-				echo "\n\n invalid EE_Cart: " . "<br />";
558
-				var_dump( $cart );
556
+			if (self::debug) {
557
+				echo "\n\n invalid EE_Cart: "."<br />";
558
+				var_dump($cart);
559 559
 			}
560 560
 		}
561 561
 	}
@@ -570,30 +570,30 @@  discard block
 block discarded – undo
570 570
 	 * @param    EE_Cart $cart
571 571
 	 * @return    void
572 572
 	 */
573
-	protected function _session_cart_reset( EE_Cart $cart ) {
574
-		if ( self::debug ) {
575
-			echo "\n\n " . __LINE__ . ") " . __METHOD__ . "() <br />";
573
+	protected function _session_cart_reset(EE_Cart $cart) {
574
+		if (self::debug) {
575
+			echo "\n\n ".__LINE__.") ".__METHOD__."() <br />";
576 576
 		}
577
-		EE_Registry::instance()->load_helper( 'Line_Item' );
577
+		EE_Registry::instance()->load_helper('Line_Item');
578 578
 		$ticket_line_items = $cart->get_tickets();
579
-		if ( empty( $ticket_line_items ) ) {
579
+		if (empty($ticket_line_items)) {
580 580
 			return;
581 581
 		}
582
-		foreach ( $ticket_line_items as $ticket_line_item ) {
583
-			if ( self::debug ) {
584
-				echo "\n . ticket_line_item->ID(): " . $ticket_line_item->ID() . "<br />";
582
+		foreach ($ticket_line_items as $ticket_line_item) {
583
+			if (self::debug) {
584
+				echo "\n . ticket_line_item->ID(): ".$ticket_line_item->ID()."<br />";
585 585
 			}
586
-			if ( $ticket_line_item instanceof EE_Line_Item && $ticket_line_item->OBJ_type() == 'Ticket' ) {
587
-				if ( self::debug ) {
588
-					echo "\n . . ticket_line_item->OBJ_ID(): " . $ticket_line_item->OBJ_ID() . "<br />";
586
+			if ($ticket_line_item instanceof EE_Line_Item && $ticket_line_item->OBJ_type() == 'Ticket') {
587
+				if (self::debug) {
588
+					echo "\n . . ticket_line_item->OBJ_ID(): ".$ticket_line_item->OBJ_ID()."<br />";
589 589
 				}
590
-				$ticket = EEM_Ticket::instance()->get_one_by_ID( $ticket_line_item->OBJ_ID() );
591
-				if ( $ticket instanceof EE_Ticket ) {
592
-					if ( self::debug ) {
593
-						echo "\n . . ticket->ID(): " . $ticket->ID() . "<br />";
594
-						echo "\n . . ticket_line_item->quantity(): " . $ticket_line_item->quantity() . "<br />";
590
+				$ticket = EEM_Ticket::instance()->get_one_by_ID($ticket_line_item->OBJ_ID());
591
+				if ($ticket instanceof EE_Ticket) {
592
+					if (self::debug) {
593
+						echo "\n . . ticket->ID(): ".$ticket->ID()."<br />";
594
+						echo "\n . . ticket_line_item->quantity(): ".$ticket_line_item->quantity()."<br />";
595 595
 					}
596
-					$this->_release_reserved_ticket( $ticket, $ticket_line_item->quantity() );
596
+					$this->_release_reserved_ticket($ticket, $ticket_line_item->quantity());
597 597
 				}
598 598
 			}
599 599
 		}
@@ -613,10 +613,10 @@  discard block
 block discarded – undo
613 613
 	 * @param    EE_Session $session
614 614
 	 * @return    void
615 615
 	 */
616
-	public static function session_checkout_reset( EE_Session $session ) {
616
+	public static function session_checkout_reset(EE_Session $session) {
617 617
 		$checkout = $session->checkout();
618
-		if ( $checkout instanceof EE_Checkout ) {
619
-			EED_Ticket_Sales_Monitor::instance()->_session_checkout_reset( $checkout );
618
+		if ($checkout instanceof EE_Checkout) {
619
+			EED_Ticket_Sales_Monitor::instance()->_session_checkout_reset($checkout);
620 620
 		}
621 621
 	}
622 622
 
@@ -630,15 +630,15 @@  discard block
 block discarded – undo
630 630
 	 * @param    EE_Checkout $checkout
631 631
 	 * @return    void
632 632
 	 */
633
-	protected function _session_checkout_reset( EE_Checkout $checkout ) {
634
-		if ( self::debug ) {
635
-			echo "\n\n " . __LINE__ . ") " . __METHOD__ . "() <br />";
633
+	protected function _session_checkout_reset(EE_Checkout $checkout) {
634
+		if (self::debug) {
635
+			echo "\n\n ".__LINE__.") ".__METHOD__."() <br />";
636 636
 		}
637 637
 		// we want to release the each registration's reserved tickets if the session was cleared, but not if this is a revisit
638
-		if ( $checkout->revisit || ! $checkout->transaction instanceof EE_Transaction ) {
638
+		if ($checkout->revisit || ! $checkout->transaction instanceof EE_Transaction) {
639 639
 			return;
640 640
 		}
641
-		$this->_release_all_reserved_tickets_for_transaction( $checkout->transaction );
641
+		$this->_release_all_reserved_tickets_for_transaction($checkout->transaction);
642 642
 	}
643 643
 
644 644
 
@@ -654,7 +654,7 @@  discard block
 block discarded – undo
654 654
 	 * @param    EE_Session $session
655 655
 	 * @return    void
656 656
 	 */
657
-	public static function session_expired_reset( EE_Session $session ) {
657
+	public static function session_expired_reset(EE_Session $session) {
658 658
 
659 659
 	}
660 660
 
@@ -673,30 +673,30 @@  discard block
 block discarded – undo
673 673
 	 * @param    EE_Transaction $transaction
674 674
 	 * @return    void
675 675
 	 */
676
-	public static function process_abandoned_transactions( EE_Transaction $transaction ) {
676
+	public static function process_abandoned_transactions(EE_Transaction $transaction) {
677 677
 		// is this TXN free or has any money been paid towards this TXN? If so, then leave it alone
678
-		if ( $transaction->is_free() || $transaction->paid() > 0 ) {
679
-			if ( self::debug ) {
678
+		if ($transaction->is_free() || $transaction->paid() > 0) {
679
+			if (self::debug) {
680 680
 				// DEBUG LOG
681 681
 				EEH_Debug_Tools::log(
682 682
 					__CLASS__, __FUNCTION__, __LINE__,
683
-					array( $transaction ),
684
-					false, 'EE_Transaction: ' . $transaction->ID()
683
+					array($transaction),
684
+					false, 'EE_Transaction: '.$transaction->ID()
685 685
 				);
686 686
 			}
687 687
 			return;
688 688
 		}
689 689
 		// have their been any successful payments made ?
690 690
 		$payments = $transaction->payments();
691
-		foreach ( $payments as $payment ) {
692
-			if ( $payment instanceof EE_Payment ) {
693
-				if ( $payment->status() === EEM_Payment::status_id_approved ) {
694
-					if ( self::debug ) {
691
+		foreach ($payments as $payment) {
692
+			if ($payment instanceof EE_Payment) {
693
+				if ($payment->status() === EEM_Payment::status_id_approved) {
694
+					if (self::debug) {
695 695
 						// DEBUG LOG
696 696
 						EEH_Debug_Tools::log(
697 697
 							__CLASS__, __FUNCTION__, __LINE__,
698
-							array( $payment ),
699
-							false, 'EE_Transaction: ' . $transaction->ID()
698
+							array($payment),
699
+							false, 'EE_Transaction: '.$transaction->ID()
700 700
 						);
701 701
 					}
702 702
 					return;
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
 			}
705 705
 		}
706 706
 		// since you haven't even attempted to pay for your ticket...
707
-		EED_Ticket_Sales_Monitor::instance()->_release_all_reserved_tickets_for_transaction( $transaction );
707
+		EED_Ticket_Sales_Monitor::instance()->_release_all_reserved_tickets_for_transaction($transaction);
708 708
 	}
709 709
 
710 710
 
@@ -721,9 +721,9 @@  discard block
 block discarded – undo
721 721
 	 * @param    EE_Transaction $transaction
722 722
 	 * @return    void
723 723
 	 */
724
-	public static function process_failed_transactions( EE_Transaction $transaction ) {
724
+	public static function process_failed_transactions(EE_Transaction $transaction) {
725 725
 		// since you haven't even attempted to pay for your ticket...
726
-		EED_Ticket_Sales_Monitor::instance()->_release_all_reserved_tickets_for_transaction( $transaction );
726
+		EED_Ticket_Sales_Monitor::instance()->_release_all_reserved_tickets_for_transaction($transaction);
727 727
 	}
728 728
 
729 729
 
Please login to merge, or discard this patch.
modules/ticket_selector/EED_Ticket_Selector.module.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
 	 *
542 542
 	 * @access        public
543 543
 	 * @access        public
544
-	 * @return        string
544
+	 * @return        false|null
545 545
 	 */
546 546
 	public static function cancel_ticket_selections() {
547 547
 		// check nonce
@@ -608,7 +608,7 @@  discard block
 block discarded – undo
608 608
 	 *
609 609
 	 *	@access public
610 610
 	 * 	@access 		public
611
-	 * 	@return		bool
611
+	 * 	@return		boolean|null
612 612
 	 */
613 613
 	public function process_ticket_selections() {
614 614
 		do_action( 'EED_Ticket_Selector__process_ticket_selections__before' );
Please login to merge, or discard this patch.
Spacing   +231 added lines, -231 removed lines patch added patch discarded remove patch
@@ -57,15 +57,15 @@  discard block
 block discarded – undo
57 57
 	 * @return EED_Ticket_Selector
58 58
 	 */
59 59
 	public static function instance() {
60
-		return parent::get_instance( __CLASS__ );
60
+		return parent::get_instance(__CLASS__);
61 61
 	}
62 62
 
63 63
 
64 64
 
65
-	protected function set_config(){
66
-		$this->set_config_section( 'template_settings' );
67
-		$this->set_config_class( 'EE_Ticket_Selector_Config' );
68
-		$this->set_config_name( 'EED_Ticket_Selector' );
65
+	protected function set_config() {
66
+		$this->set_config_section('template_settings');
67
+		$this->set_config_class('EE_Ticket_Selector_Config');
68
+		$this->set_config_name('EED_Ticket_Selector');
69 69
 	}
70 70
 
71 71
 
@@ -80,15 +80,15 @@  discard block
 block discarded – undo
80 80
 	 */
81 81
 	public static function set_hooks() {
82 82
 		// routing
83
-		EE_Config::register_route( 'iframe', 'EED_Ticket_Selector', 'ticket_selector_iframe', 'ticket_selector' );
84
-		EE_Config::register_route( 'process_ticket_selections', 'EED_Ticket_Selector', 'process_ticket_selections' );
85
-		EE_Config::register_route( 'cancel_ticket_selections', 'EED_Ticket_Selector', 'cancel_ticket_selections' );
86
-		add_action( 'wp_loaded', array( 'EED_Ticket_Selector', 'set_definitions' ), 2 );
83
+		EE_Config::register_route('iframe', 'EED_Ticket_Selector', 'ticket_selector_iframe', 'ticket_selector');
84
+		EE_Config::register_route('process_ticket_selections', 'EED_Ticket_Selector', 'process_ticket_selections');
85
+		EE_Config::register_route('cancel_ticket_selections', 'EED_Ticket_Selector', 'cancel_ticket_selections');
86
+		add_action('wp_loaded', array('EED_Ticket_Selector', 'set_definitions'), 2);
87 87
 		//add_action( 'AHEE_event_details_before_post', array( 'EED_Ticket_Selector', 'ticket_selector_form_open' ), 10, 1 );
88
-		add_action( 'AHEE_event_details_header_bottom', array( 'EED_Ticket_Selector', 'display_ticket_selector' ), 10, 1 );
88
+		add_action('AHEE_event_details_header_bottom', array('EED_Ticket_Selector', 'display_ticket_selector'), 10, 1);
89 89
 		//add_action( 'AHEE__ticket_selector_chart__template__after_ticket_selector', array( 'EED_Ticket_Selector', 'display_ticket_selector_submit' ), 10, 1 );
90 90
 		//add_action( 'AHEE_event_details_after_post', array( 'EED_Ticket_Selector', 'ticket_selector_form_close' ), 10 );
91
-		add_action( 'wp_enqueue_scripts', array( 'EED_Ticket_Selector', 'load_tckt_slctr_assets' ), 10 );
91
+		add_action('wp_enqueue_scripts', array('EED_Ticket_Selector', 'load_tckt_slctr_assets'), 10);
92 92
 	}
93 93
 
94 94
 
@@ -100,10 +100,10 @@  discard block
 block discarded – undo
100 100
 	 *  @return 	void
101 101
 	 */
102 102
 	public static function set_hooks_admin() {
103
-		add_action( 'wp_loaded', array( 'EED_Ticket_Selector', 'set_definitions' ), 2 );
103
+		add_action('wp_loaded', array('EED_Ticket_Selector', 'set_definitions'), 2);
104 104
 		//add button for iframe code to event editor.
105
-		add_filter( 'get_sample_permalink_html', array( 'EED_Ticket_Selector', 'iframe_code_button' ), 10, 4 );
106
-		add_action( 'admin_enqueue_scripts', array( 'EED_Ticket_Selector', 'load_tckt_slctr_assets_admin' ), 10 );
105
+		add_filter('get_sample_permalink_html', array('EED_Ticket_Selector', 'iframe_code_button'), 10, 4);
106
+		add_action('admin_enqueue_scripts', array('EED_Ticket_Selector', 'load_tckt_slctr_assets_admin'), 10);
107 107
 	}
108 108
 
109 109
 
@@ -115,15 +115,15 @@  discard block
 block discarded – undo
115 115
 	 *  @return 	void
116 116
 	 */
117 117
 	public static function set_definitions() {
118
-		define( 'TICKET_SELECTOR_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets' . DS );
119
-		define( 'TICKET_SELECTOR_TEMPLATES_PATH', str_replace( '\\', DS, plugin_dir_path( __FILE__ )) . 'templates' . DS );
118
+		define('TICKET_SELECTOR_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS);
119
+		define('TICKET_SELECTOR_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)).'templates'.DS);
120 120
 
121 121
 		//if config is not set, initialize
122 122
 		//If config is not set, set it.
123
-		if ( ! isset( EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector ) ) {
123
+		if ( ! isset(EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector)) {
124 124
 			EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = new EE_Ticket_Selector_Config();
125 125
 		}
126
-		EE_Registry::$i18n_js_strings[ 'ts_embed_iframe_title' ] = __( 'Copy and Paste the following:', 'event_espresso' );
126
+		EE_Registry::$i18n_js_strings['ts_embed_iframe_title'] = __('Copy and Paste the following:', 'event_espresso');
127 127
 	}
128 128
 
129 129
 
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 	 * 	@param	object 			$WP
135 135
 	 * 	@return 	void
136 136
 	 */
137
-	public function run( $WP ) {}
137
+	public function run($WP) {}
138 138
 
139 139
 
140 140
 	/**
@@ -146,23 +146,23 @@  discard block
 block discarded – undo
146 146
 	public function ticket_selector_iframe() {
147 147
 		self::$_in_iframe = true;
148 148
 		/** @type EEM_Event $EEM_Event */
149
-		$EEM_Event = EE_Registry::instance()->load_model( 'Event' );
149
+		$EEM_Event = EE_Registry::instance()->load_model('Event');
150 150
 		$event = $EEM_Event->get_one_by_ID(
151
-			EE_Registry::instance()->REQ->get( 'event', 0 )
151
+			EE_Registry::instance()->REQ->get('event', 0)
152 152
 		);
153
-		EE_Registry::instance()->REQ->set_espresso_page( true );
154
-		$template_args['ticket_selector'] = EED_Ticket_Selector::display_ticket_selector( $event );
153
+		EE_Registry::instance()->REQ->set_espresso_page(true);
154
+		$template_args['ticket_selector'] = EED_Ticket_Selector::display_ticket_selector($event);
155 155
 		$template_args['css'] = apply_filters(
156 156
 			'FHEE__EED_Ticket_Selector__ticket_selector_iframe__css',
157 157
 			array(
158
-				TICKET_SELECTOR_ASSETS_URL . 'ticket_selector_embed.css?ver=' . EVENT_ESPRESSO_VERSION,
159
-				TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css?ver=' . EVENT_ESPRESSO_VERSION,
160
-				includes_url( 'css/dashicons.min.css?ver=' . $GLOBALS['wp_version'] ),
161
-				EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css?ver=' . EVENT_ESPRESSO_VERSION
158
+				TICKET_SELECTOR_ASSETS_URL.'ticket_selector_embed.css?ver='.EVENT_ESPRESSO_VERSION,
159
+				TICKET_SELECTOR_ASSETS_URL.'ticket_selector.css?ver='.EVENT_ESPRESSO_VERSION,
160
+				includes_url('css/dashicons.min.css?ver='.$GLOBALS['wp_version']),
161
+				EE_GLOBAL_ASSETS_URL.'css/espresso_default.css?ver='.EVENT_ESPRESSO_VERSION
162 162
 			)
163 163
 		);
164
-		EE_Registry::$i18n_js_strings[ 'ticket_selector_iframe' ] = true;
165
-		EE_Registry::$i18n_js_strings[ 'EEDTicketSelectorMsg' ] = __( 'Please choose at least one ticket before continuing.', 'event_espresso' );
164
+		EE_Registry::$i18n_js_strings['ticket_selector_iframe'] = true;
165
+		EE_Registry::$i18n_js_strings['EEDTicketSelectorMsg'] = __('Please choose at least one ticket before continuing.', 'event_espresso');
166 166
 		$template_args['eei18n'] = apply_filters(
167 167
 			'FHEE__EED_Ticket_Selector__ticket_selector_iframe__eei18n_js_strings',
168 168
 			EE_Registry::localize_i18n_js_strings()
@@ -170,19 +170,19 @@  discard block
 block discarded – undo
170 170
 		$template_args['js'] = apply_filters(
171 171
 			'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js',
172 172
 			array(
173
-				includes_url( 'js/jquery/jquery.js?ver=' . $GLOBALS['wp_version'] ),
174
-				EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js?ver=' . EVENT_ESPRESSO_VERSION,
175
-				TICKET_SELECTOR_ASSETS_URL . 'ticket_selector_iframe_embed.js?ver=' . EVENT_ESPRESSO_VERSION
173
+				includes_url('js/jquery/jquery.js?ver='.$GLOBALS['wp_version']),
174
+				EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js?ver='.EVENT_ESPRESSO_VERSION,
175
+				TICKET_SELECTOR_ASSETS_URL.'ticket_selector_iframe_embed.js?ver='.EVENT_ESPRESSO_VERSION
176 176
 			)
177 177
 		);
178 178
 		EE_Registry::instance()->load_helper('Template');
179
-		$template_args[ 'notices' ] = EEH_Template::display_template(
180
-			EE_TEMPLATES . 'espresso-ajax-notices.template.php',
179
+		$template_args['notices'] = EEH_Template::display_template(
180
+			EE_TEMPLATES.'espresso-ajax-notices.template.php',
181 181
 			array(),
182 182
 			true
183 183
 		);
184 184
 		EEH_Template::display_template(
185
-			TICKET_SELECTOR_TEMPLATES_PATH . 'ticket_selector_chart_iframe.template.php',
185
+			TICKET_SELECTOR_TEMPLATES_PATH.'ticket_selector_chart_iframe.template.php',
186 186
 			$template_args
187 187
 		);
188 188
 		exit;
@@ -201,23 +201,23 @@  discard block
 block discarded – undo
201 201
 	 *
202 202
 	 * @return string The new html string for the permalink area.
203 203
 	 */
204
-	public static function iframe_code_button( $permalink_string, $id, $new_title, $new_slug ) {
204
+	public static function iframe_code_button($permalink_string, $id, $new_title, $new_slug) {
205 205
 		//make sure this is ONLY when editing and the event id has been set.
206
-		if ( ! empty( $id ) )  {
207
-			$post = get_post( $id );
206
+		if ( ! empty($id)) {
207
+			$post = get_post($id);
208 208
 
209 209
 			//if NOT event then let's get out.
210
-			if ( $post->post_type !== 'espresso_events' ) {
210
+			if ($post->post_type !== 'espresso_events') {
211 211
 				return $permalink_string;
212 212
 			}
213 213
 
214
-			$ticket_selector_url = add_query_arg( array( 'ticket_selector' => 'iframe', 'event' => $id ), site_url() );
214
+			$ticket_selector_url = add_query_arg(array('ticket_selector' => 'iframe', 'event' => $id), site_url());
215 215
 
216
-			$permalink_string .= '<a id="js-ticket-selector-embed-trigger" class="button button-small" href="#"  tabindex="-1">' . __('Embed', 'event_espresso') . '</a> ';
216
+			$permalink_string .= '<a id="js-ticket-selector-embed-trigger" class="button button-small" href="#"  tabindex="-1">'.__('Embed', 'event_espresso').'</a> ';
217 217
 			$permalink_string .= '
218 218
 <div id="js-ts-iframe" style="display:none">
219 219
 	<div style="width:100%; height: 500px;">
220
-		<iframe src="' . $ticket_selector_url . '" width="100%" height="100%"></iframe>
220
+		<iframe src="' . $ticket_selector_url.'" width="100%" height="100%"></iframe>
221 221
 	</div>
222 222
 </div>';
223 223
 		}
@@ -236,22 +236,22 @@  discard block
 block discarded – undo
236 236
 	 * @param 	mixed $event
237 237
 	 * @return 	bool
238 238
 	 */
239
-	protected static function set_event( $event = null ) {
240
-		if( $event === null ) {
239
+	protected static function set_event($event = null) {
240
+		if ($event === null) {
241 241
 			global $post;
242 242
 			$event = $post;
243 243
 		}
244
-		if ( $event instanceof EE_Event ) {
244
+		if ($event instanceof EE_Event) {
245 245
 			self::$_event = $event;
246
-		} else if ( $event instanceof WP_Post && isset( $event->EE_Event ) && $event->EE_Event instanceof EE_Event ) {
246
+		} else if ($event instanceof WP_Post && isset($event->EE_Event) && $event->EE_Event instanceof EE_Event) {
247 247
 			self::$_event = $event->EE_Event;
248
-		} else if ( $event instanceof WP_Post && $event->post_type == 'espresso_events' ) {
249
-			$event->EE_Event = EEM_Event::instance()->instantiate_class_from_post_object( $event );
248
+		} else if ($event instanceof WP_Post && $event->post_type == 'espresso_events') {
249
+			$event->EE_Event = EEM_Event::instance()->instantiate_class_from_post_object($event);
250 250
 			self::$_event = $event->EE_Event;
251 251
 		} else {
252
-			$user_msg = __( 'No Event object or an invalid Event object was supplied.', 'event_espresso' );
253
-			$dev_msg = $user_msg . __( 'In order to generate a ticket selector, please ensure you are passing either an EE_Event object or a WP_Post object of the post type "espresso_event" to the EE_Ticket_Selector class constructor.', 'event_espresso' );
254
-			EE_Error::add_error( $user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__ );
252
+			$user_msg = __('No Event object or an invalid Event object was supplied.', 'event_espresso');
253
+			$dev_msg = $user_msg.__('In order to generate a ticket selector, please ensure you are passing either an EE_Event object or a WP_Post object of the post type "espresso_event" to the EE_Ticket_Selector class constructor.', 'event_espresso');
254
+			EE_Error::add_error($user_msg.'||'.$dev_msg, __FILE__, __FUNCTION__, __LINE__);
255 255
 			return false;
256 256
 		}
257 257
 		return true;
@@ -270,11 +270,11 @@  discard block
 block discarded – undo
270 270
 	 * @param 	bool 	$view_details
271 271
 	 * @return 	string
272 272
 	 */
273
-	public static function display_ticket_selector( $event = NULL, $view_details = FALSE ) {
273
+	public static function display_ticket_selector($event = NULL, $view_details = FALSE) {
274 274
 		// reset filter for displaying submit button
275
-		remove_filter( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true' );
275
+		remove_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
276 276
 		// poke and prod incoming event till it tells us what it is
277
-		if ( ! EED_Ticket_Selector::set_event( $event )) {
277
+		if ( ! EED_Ticket_Selector::set_event($event)) {
278 278
 			return false;
279 279
 		}
280 280
 		$event_post = self::$_event instanceof EE_Event ? self::$_event->ID() : $event;
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 			&& (
286 286
 				! self::$_event->display_ticket_selector()
287 287
 				|| $view_details
288
-				|| post_password_required( $event_post )
288
+				|| post_password_required($event_post)
289 289
 				|| (
290 290
 					$_event_active_status != EE_Datetime::active
291 291
 					&& $_event_active_status != EE_Datetime::upcoming
@@ -303,70 +303,70 @@  discard block
 block discarded – undo
303 303
 		$template_args = array();
304 304
 		$template_args['event_status'] = $_event_active_status;
305 305
 
306
-		$template_args['date_format'] = apply_filters( 'FHEE__EED_Ticket_Selector__display_ticket_selector__date_format', get_option( 'date_format' ) );
307
-		$template_args['time_format'] = apply_filters( 'FHEE__EED_Ticket_Selector__display_ticket_selector__time_format', get_option( 'time_format' ) );
306
+		$template_args['date_format'] = apply_filters('FHEE__EED_Ticket_Selector__display_ticket_selector__date_format', get_option('date_format'));
307
+		$template_args['time_format'] = apply_filters('FHEE__EED_Ticket_Selector__display_ticket_selector__time_format', get_option('time_format'));
308 308
 
309 309
 		$template_args['EVT_ID'] = self::$_event->ID();
310 310
 		$template_args['event'] = self::$_event;
311 311
 
312 312
 		// is the event expired ?
313 313
 		$template_args['event_is_expired'] = self::$_event->is_expired();
314
-		if ( $template_args['event_is_expired'] ) {
315
-			return '<div class="ee-event-expired-notice"><span class="important-notice">' . __( 'We\'re sorry, but all tickets sales have ended because the event is expired.', 'event_espresso' ) . '</span></div>';
314
+		if ($template_args['event_is_expired']) {
315
+			return '<div class="ee-event-expired-notice"><span class="important-notice">'.__('We\'re sorry, but all tickets sales have ended because the event is expired.', 'event_espresso').'</span></div>';
316 316
 		}
317 317
 
318 318
 		$ticket_query_args = array(
319
-			array( 'Datetime.EVT_ID' => self::$_event->ID() ),
320
-			'order_by' => array( 'TKT_order' => 'ASC', 'TKT_required' => 'DESC', 'TKT_start_date' => 'ASC', 'TKT_end_date' => 'ASC' , 'Datetime.DTT_EVT_start' => 'DESC' )
319
+			array('Datetime.EVT_ID' => self::$_event->ID()),
320
+			'order_by' => array('TKT_order' => 'ASC', 'TKT_required' => 'DESC', 'TKT_start_date' => 'ASC', 'TKT_end_date' => 'ASC', 'Datetime.DTT_EVT_start' => 'DESC')
321 321
 		);
322 322
 
323
-		if ( ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets ) {
323
+		if ( ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets) {
324 324
 			//use the correct applicable time query depending on what version of core is being run.
325
-			$current_time = method_exists( 'EEM_Datetime', 'current_time_for_query' ) ? time() : current_time('timestamp');
326
-			$ticket_query_args[0]['TKT_end_date'] = array( '>', $current_time );
325
+			$current_time = method_exists('EEM_Datetime', 'current_time_for_query') ? time() : current_time('timestamp');
326
+			$ticket_query_args[0]['TKT_end_date'] = array('>', $current_time);
327 327
 		}
328 328
 
329 329
 		// get all tickets for this event ordered by the datetime
330
-		$template_args['tickets'] = EEM_Ticket::instance()->get_all( $ticket_query_args );
330
+		$template_args['tickets'] = EEM_Ticket::instance()->get_all($ticket_query_args);
331 331
 
332
-		if ( count( $template_args['tickets'] ) < 1 ) {
333
-			return '<div class="ee-event-expired-notice"><span class="important-notice">' . __( 'We\'re sorry, but all ticket sales have ended.', 'event_espresso' ) . '</span></div>';
332
+		if (count($template_args['tickets']) < 1) {
333
+			return '<div class="ee-event-expired-notice"><span class="important-notice">'.__('We\'re sorry, but all ticket sales have ended.', 'event_espresso').'</span></div>';
334 334
 		}
335 335
 
336 336
 		// filter the maximum qty that can appear in the Ticket Selector qty dropdowns
337
-		$template_args['max_atndz'] = apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector__max_tickets', self::$_event->additional_limit() );
338
-		if ( $template_args['max_atndz'] < 1 ) {
339
-			$sales_closed_msg = __( 'We\'re sorry, but ticket sales have been closed at this time. Please check back again later.', 'event_espresso' );
340
-			if ( current_user_can( 'edit_post', self::$_event->ID() )) {
341
-				$sales_closed_msg .=  sprintf(
342
-					__( '%sNote to Event Admin:%sThe "Maximum number of tickets allowed per order for this event" in the Event Registration Options has been set to "0". This effectively turns off ticket sales. %s(click to edit this event)%s', 'event_espresso' ),
337
+		$template_args['max_atndz'] = apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector__max_tickets', self::$_event->additional_limit());
338
+		if ($template_args['max_atndz'] < 1) {
339
+			$sales_closed_msg = __('We\'re sorry, but ticket sales have been closed at this time. Please check back again later.', 'event_espresso');
340
+			if (current_user_can('edit_post', self::$_event->ID())) {
341
+				$sales_closed_msg .= sprintf(
342
+					__('%sNote to Event Admin:%sThe "Maximum number of tickets allowed per order for this event" in the Event Registration Options has been set to "0". This effectively turns off ticket sales. %s(click to edit this event)%s', 'event_espresso'),
343 343
 					'<div class="ee-attention" style="text-align: left;"><b>',
344 344
 					'</b><br />',
345
-					$link = '<span class="edit-link"><a class="post-edit-link" href="' . get_edit_post_link( self::$_event->ID() ) . '">',
345
+					$link = '<span class="edit-link"><a class="post-edit-link" href="'.get_edit_post_link(self::$_event->ID()).'">',
346 346
 					'</a></span></div>'
347 347
 				);
348 348
 			}
349
-			return '<p><span class="important-notice">' . $sales_closed_msg . '</span></p>';
349
+			return '<p><span class="important-notice">'.$sales_closed_msg.'</span></p>';
350 350
 		}
351 351
 
352
-		$templates['ticket_selector'] = TICKET_SELECTOR_TEMPLATES_PATH . 'ticket_selector_chart.template.php';
353
-		$templates['ticket_selector'] = apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector__template_path', $templates['ticket_selector'], self::$_event );
352
+		$templates['ticket_selector'] = TICKET_SELECTOR_TEMPLATES_PATH.'ticket_selector_chart.template.php';
353
+		$templates['ticket_selector'] = apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector__template_path', $templates['ticket_selector'], self::$_event);
354 354
 
355 355
 		// redirecting to another site for registration ??
356 356
 		$external_url = self::$_event->external_url() !== NULL || self::$_event->external_url() !== '' ? self::$_event->external_url() : FALSE;
357 357
 		// set up the form (but not for the admin)
358
-		$ticket_selector = ! is_admin() ? EED_Ticket_Selector::ticket_selector_form_open( self::$_event->ID(), $external_url ) : '';
358
+		$ticket_selector = ! is_admin() ? EED_Ticket_Selector::ticket_selector_form_open(self::$_event->ID(), $external_url) : '';
359 359
 		// if not redirecting to another site for registration
360
-		if ( ! $external_url ) {
361
-			EE_Registry::instance()->load_helper( 'Template' );
362
-			EE_Registry::instance()->load_helper( 'URL' );
360
+		if ( ! $external_url) {
361
+			EE_Registry::instance()->load_helper('Template');
362
+			EE_Registry::instance()->load_helper('URL');
363 363
 			// then display the ticket selector
364
-			$ticket_selector .= EEH_Template::locate_template( $templates['ticket_selector'], $template_args );
364
+			$ticket_selector .= EEH_Template::locate_template($templates['ticket_selector'], $template_args);
365 365
 		} else {
366 366
 			// if not we still need to trigger the display of the submit button
367
-			add_filter( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true' );
367
+			add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true');
368 368
 			//display notice to admin that registration is external
369
-			$ticket_selector .= ! is_admin() ? '' : __( 'Registration is at an external URL for this event.', 'event_espresso' );
369
+			$ticket_selector .= ! is_admin() ? '' : __('Registration is at an external URL for this event.', 'event_espresso');
370 370
 		}
371 371
 		// submit button and form close tag
372 372
 		$ticket_selector .= ! is_admin() ? EED_Ticket_Selector::display_ticket_selector_submit() : '';
@@ -386,27 +386,27 @@  discard block
 block discarded – undo
386 386
 	 * @param 		string $external_url
387 387
 	 * @return 		string
388 388
 	 */
389
-	public static function ticket_selector_form_open( $ID = 0, $external_url = '' ) {
389
+	public static function ticket_selector_form_open($ID = 0, $external_url = '') {
390 390
 		// if redirecting, we don't need any anything else
391
-		if ( $external_url ) {
392
-			EE_Registry::instance()->load_helper( 'URL' );
393
-			$html = '<form method="GET" action="' . EEH_URL::refactor_url( $external_url ) . '">';
394
-			$query_args = EEH_URL::get_query_string( $external_url );
395
-			foreach ( $query_args as $query_arg => $value ) {
396
-				$html .= '<input type="hidden" name="' . $query_arg . '" value="' . $value . '">';
391
+		if ($external_url) {
392
+			EE_Registry::instance()->load_helper('URL');
393
+			$html = '<form method="GET" action="'.EEH_URL::refactor_url($external_url).'">';
394
+			$query_args = EEH_URL::get_query_string($external_url);
395
+			foreach ($query_args as $query_arg => $value) {
396
+				$html .= '<input type="hidden" name="'.$query_arg.'" value="'.$value.'">';
397 397
 			}
398 398
 			return $html;
399 399
 		}
400
-		EE_Registry::instance()->load_helper( 'Event_View' );
401
-		$checkout_url = EEH_Event_View::event_link_url( $ID );
402
-		if ( ! $checkout_url ) {
403
-			EE_Error::add_error( __('The URL for the Event Details page could not be retrieved.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
400
+		EE_Registry::instance()->load_helper('Event_View');
401
+		$checkout_url = EEH_Event_View::event_link_url($ID);
402
+		if ( ! $checkout_url) {
403
+			EE_Error::add_error(__('The URL for the Event Details page could not be retrieved.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
404 404
 		}
405 405
 		$extra_params = self::$_in_iframe ? ' target="_blank"' : '';
406
-		$html = '<form method="POST" action="' . $checkout_url . '"' . $extra_params . '>';
407
-		$html .= wp_nonce_field( 	'process_ticket_selections', 'process_ticket_selections_nonce', TRUE, FALSE );
406
+		$html = '<form method="POST" action="'.$checkout_url.'"'.$extra_params.'>';
407
+		$html .= wp_nonce_field('process_ticket_selections', 'process_ticket_selections_nonce', TRUE, FALSE);
408 408
 		$html .= '<input type="hidden" name="ee" value="process_ticket_selections">';
409
-		$html = apply_filters( 'FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, self::$_event );
409
+		$html = apply_filters('FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, self::$_event);
410 410
 		return $html;
411 411
 	}
412 412
 
@@ -421,23 +421,23 @@  discard block
 block discarded – undo
421 421
 	 * 	@return		string
422 422
 	 */
423 423
 	public static function display_ticket_selector_submit() {
424
-		if ( ! is_admin() ) {
425
-			if ( apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', FALSE ) ) {
424
+		if ( ! is_admin()) {
425
+			if (apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', FALSE)) {
426 426
 				$btn_text = apply_filters(
427 427
 					'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__btn_text',
428
-					__('Register Now', 'event_espresso' ),
428
+					__('Register Now', 'event_espresso'),
429 429
 					self::$_event
430 430
 				);
431
-				$html = '<input id="ticket-selector-submit-'. self::$_event->ID() .'-btn"';
431
+				$html = '<input id="ticket-selector-submit-'.self::$_event->ID().'-btn"';
432 432
 				$html .= ' class="ticket-selector-submit-btn ticket-selector-submit-ajax"';
433
-				$html .= ' type="submit" value="' . $btn_text . '" />';
434
-				$html .= apply_filters( 'FHEE__EE_Ticket_Selector__after_ticket_selector_submit', '', self::$_event );
433
+				$html .= ' type="submit" value="'.$btn_text.'" />';
434
+				$html .= apply_filters('FHEE__EE_Ticket_Selector__after_ticket_selector_submit', '', self::$_event);
435 435
 				$html .= '<div class="clear"><br/></div></form>';
436 436
 				return $html;
437
-			} else if ( is_archive() ) {
438
-				return EED_Ticket_Selector::ticket_selector_form_close() . EED_Ticket_Selector::display_view_details_btn();
439
-			} else if ( EE_Registry::instance()->SSN->cart() instanceof EE_Cart ) {
440
-				if ( ! EE_Registry::instance()->SSN->cart()->all_ticket_quantity_count() ) {
437
+			} else if (is_archive()) {
438
+				return EED_Ticket_Selector::ticket_selector_form_close().EED_Ticket_Selector::display_view_details_btn();
439
+			} else if (EE_Registry::instance()->SSN->cart() instanceof EE_Cart) {
440
+				if ( ! EE_Registry::instance()->SSN->cart()->all_ticket_quantity_count()) {
441 441
 					return '';
442 442
 				}
443 443
 				return EED_Ticket_Selector::display_proceed_btn_when_tickets_in_cart();
@@ -465,12 +465,12 @@  discard block
 block discarded – undo
465 465
 		$html .= '">';
466 466
 		$html .= apply_filters(
467 467
 			'FHEE__EED_Ticket_Selector__proceed_to_registration_btn_txt',
468
-			__( 'Proceed to Registration', 'event_espresso' )
468
+			__('Proceed to Registration', 'event_espresso')
469 469
 		);
470 470
 		$html .= ' <span class="dashicons dashicons-arrow-right-alt2"></span>';
471 471
 		$html .= '</a>';
472 472
 		$html .= '<div class="clear"></div>';
473
-		$cancel_url = EEH_Event_View::event_link_url( self::$_event->ID() );
473
+		$cancel_url = EEH_Event_View::event_link_url(self::$_event->ID());
474 474
 		$cancel_url = add_query_arg(
475 475
 			array(
476 476
 				'ee'       => 'cancel_ticket_selections',
@@ -479,11 +479,11 @@  discard block
 block discarded – undo
479 479
 			),
480 480
 			$cancel_url
481 481
 		);
482
-		$cancel_url = wp_nonce_url( $cancel_url, 'cancel_ticket_selections', 'cancel_ticket_selections_nonce' );
483
-		$html .= '<a class="ticket-selector-submit-btn small-text" href="' . $cancel_url . '">';
482
+		$cancel_url = wp_nonce_url($cancel_url, 'cancel_ticket_selections', 'cancel_ticket_selections_nonce');
483
+		$html .= '<a class="ticket-selector-submit-btn small-text" href="'.$cancel_url.'">';
484 484
 		$html .= apply_filters(
485 485
 			'FHEE__EED_Ticket_Selector__cancel_ticket_selections_txt',
486
-			__( 'cancel ticket selection', 'event_espresso' )
486
+			__('cancel ticket selection', 'event_espresso')
487 487
 		);
488 488
 		$html .= '</a>';
489 489
 		$html .= '<div class="clear"><br/></div>';
@@ -516,8 +516,8 @@  discard block
 block discarded – undo
516 516
 	 * 	@return		string
517 517
 	 */
518 518
 	public static function display_view_details_btn() {
519
-		if ( ! self::$_event->get_permalink() ) {
520
-			EE_Error::add_error( __('The URL for the Event Details page could not be retrieved.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
519
+		if ( ! self::$_event->get_permalink()) {
520
+			EE_Error::add_error(__('The URL for the Event Details page could not be retrieved.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
521 521
 		}
522 522
 		$view_details_btn = '<form method="POST" action="';
523 523
 		$view_details_btn .= apply_filters(
@@ -526,9 +526,9 @@  discard block
 block discarded – undo
526 526
 			self::$_event
527 527
 		);
528 528
 		$view_details_btn .= '">';
529
-		$btn_text = apply_filters( 'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_text', __( 'View Details', 'event_espresso' ), self::$_event );
530
-		$view_details_btn .= '<input id="ticket-selector-submit-'. self::$_event->ID() .'-btn" class="ticket-selector-submit-btn view-details-btn" type="submit" value="' . $btn_text . '" />';
531
-		$view_details_btn .= apply_filters( 'FHEE__EE_Ticket_Selector__after_view_details_btn', '', self::$_event );
529
+		$btn_text = apply_filters('FHEE__EE_Ticket_Selector__display_view_details_btn__btn_text', __('View Details', 'event_espresso'), self::$_event);
530
+		$view_details_btn .= '<input id="ticket-selector-submit-'.self::$_event->ID().'-btn" class="ticket-selector-submit-btn view-details-btn" type="submit" value="'.$btn_text.'" />';
531
+		$view_details_btn .= apply_filters('FHEE__EE_Ticket_Selector__after_view_details_btn', '', self::$_event);
532 532
 		$view_details_btn .= '<div class="clear"><br/></div>';
533 533
 		$view_details_btn .= '</form>';
534 534
 		return $view_details_btn;
@@ -545,19 +545,19 @@  discard block
 block discarded – undo
545 545
 	 */
546 546
 	public static function cancel_ticket_selections() {
547 547
 		// check nonce
548
-		if ( ! EED_Ticket_Selector::process_ticket_selector_nonce( 'cancel_ticket_selections_nonce' ) ) {
548
+		if ( ! EED_Ticket_Selector::process_ticket_selector_nonce('cancel_ticket_selections_nonce')) {
549 549
 			return false;
550 550
 		}
551
-		EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__ );
552
-		if ( EE_Registry::instance()->REQ->is_set( 'event_id' ) ) {
551
+		EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
552
+		if (EE_Registry::instance()->REQ->is_set('event_id')) {
553 553
 			wp_safe_redirect(
554 554
 				EEH_Event_View::event_link_url(
555
-					EE_Registry::instance()->REQ->get( 'event_id' )
555
+					EE_Registry::instance()->REQ->get('event_id')
556 556
 				)
557 557
 			);
558 558
 		} else {
559 559
 			wp_safe_redirect(
560
-				site_url( '/' . EE_Registry::instance()->CFG->core->event_cpt_slug . '/' )
560
+				site_url('/'.EE_Registry::instance()->CFG->core->event_cpt_slug.'/')
561 561
 			);
562 562
 		}
563 563
 		die();
@@ -572,15 +572,15 @@  discard block
 block discarded – undo
572 572
 	 * @param  string $nonce_name
573 573
 	 * @return bool
574 574
 	 */
575
-	public static function process_ticket_selector_nonce( $nonce_name ) {
575
+	public static function process_ticket_selector_nonce($nonce_name) {
576 576
 		if (
577 577
 			! is_admin()
578 578
 			&& (
579
-				! EE_Registry::instance()->REQ->is_set( $nonce_name )
579
+				! EE_Registry::instance()->REQ->is_set($nonce_name)
580 580
 				||
581 581
 				! wp_verify_nonce(
582
-					EE_Registry::instance()->REQ->get( $nonce_name ),
583
-					str_replace( '_nonce', '', $nonce_name )
582
+					EE_Registry::instance()->REQ->get($nonce_name),
583
+					str_replace('_nonce', '', $nonce_name)
584 584
 				)
585 585
 			)
586 586
 		) {
@@ -611,10 +611,10 @@  discard block
 block discarded – undo
611 611
 	 * 	@return		bool
612 612
 	 */
613 613
 	public function process_ticket_selections() {
614
-		do_action( 'EED_Ticket_Selector__process_ticket_selections__before' );
614
+		do_action('EED_Ticket_Selector__process_ticket_selections__before');
615 615
 		//echo "\n\n " . __LINE__ . ") " . __METHOD__ . "() \n";
616 616
 		// check nonce
617
-		if ( ! EED_Ticket_Selector::process_ticket_selector_nonce( 'process_ticket_selections_nonce' ) ) {
617
+		if ( ! EED_Ticket_Selector::process_ticket_selector_nonce('process_ticket_selections_nonce')) {
618 618
 			return false;
619 619
 		}
620 620
 
@@ -624,111 +624,111 @@  discard block
 block discarded – undo
624 624
 		);
625 625
 		//we should really only have 1 registration in the works now (ie, no MER) so clear any previous items in the cart.
626 626
 		// When MER happens this will probably need to be tweaked, possibly wrapped in a conditional checking for some constant defined in MER etc.
627
-		EE_Registry::instance()->load_core( 'Session' );
627
+		EE_Registry::instance()->load_core('Session');
628 628
 		// unless otherwise requested, clear the session
629
-		if ( apply_filters( 'FHEE__EE_Ticket_Selector__process_ticket_selections__clear_session', TRUE )) {
630
-			EE_Registry::instance()->SSN->clear_session( __CLASS__, __FUNCTION__ );
629
+		if (apply_filters('FHEE__EE_Ticket_Selector__process_ticket_selections__clear_session', TRUE)) {
630
+			EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
631 631
 		}
632 632
 		//d( EE_Registry::instance()->SSN );
633 633
 
634
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
634
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
635 635
 		// do we have an event id?
636
-		if ( EE_Registry::instance()->REQ->is_set( 'tkt-slctr-event-id' ) ) {
636
+		if (EE_Registry::instance()->REQ->is_set('tkt-slctr-event-id')) {
637 637
 			// validate/sanitize data
638 638
 			$valid = self::_validate_post_data();
639 639
 			//check total tickets ordered vs max number of attendees that can register
640
-			if ( $valid['total_tickets'] > $valid['max_atndz'] ) {
640
+			if ($valid['total_tickets'] > $valid['max_atndz']) {
641 641
 
642 642
 				// ordering too many tickets !!!
643 643
 				$singular = 'You have attempted to purchase %s ticket.';
644 644
 				$plural = 'You have attempted to purchase %s tickets.';
645
-				$limit_error_1 = sprintf( _n( $singular, $plural, $valid['total_tickets'], 'event_espresso' ), $valid['total_tickets'], $valid['total_tickets'] );
645
+				$limit_error_1 = sprintf(_n($singular, $plural, $valid['total_tickets'], 'event_espresso'), $valid['total_tickets'], $valid['total_tickets']);
646 646
 				// dev only message
647 647
 				$singular = '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.';
648 648
 				$plural = '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.';
649
-				$limit_error_2 = sprintf( _n( $singular, $plural, $valid['max_atndz'], 'event_espresso' ), $valid['max_atndz'], $valid['max_atndz'] );
650
-				EE_Error::add_error( $limit_error_1 . '<br/>' . $limit_error_2, __FILE__, __FUNCTION__, __LINE__ );
649
+				$limit_error_2 = sprintf(_n($singular, $plural, $valid['max_atndz'], 'event_espresso'), $valid['max_atndz'], $valid['max_atndz']);
650
+				EE_Error::add_error($limit_error_1.'<br/>'.$limit_error_2, __FILE__, __FUNCTION__, __LINE__);
651 651
 			} else {
652 652
 
653 653
 				// all data appears to be valid
654 654
 				$tckts_slctd = false;
655 655
 				$tickets_added = 0;
656 656
 				// validate/sanitize data
657
-				$valid = apply_filters( 'FHEE__EED_Ticket_Selector__process_ticket_selections__valid_post_data', $valid );
658
-				if ( $valid[ 'total_tickets' ] >0 ) {
657
+				$valid = apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__valid_post_data', $valid);
658
+				if ($valid['total_tickets'] > 0) {
659 659
 					// load cart
660
-					EE_Registry::instance()->load_core( 'Cart' );
660
+					EE_Registry::instance()->load_core('Cart');
661 661
 
662 662
 					// cycle thru the number of data rows sent from the event listing
663
-					for ( $x = 0; $x < $valid['rows']; $x++ ) {
663
+					for ($x = 0; $x < $valid['rows']; $x++) {
664 664
 						// does this row actually contain a ticket quantity?
665
-						if ( isset( $valid['qty'][$x] ) && $valid['qty'][$x] > 0 ) {
665
+						if (isset($valid['qty'][$x]) && $valid['qty'][$x] > 0) {
666 666
 							// YES we have a ticket quantity
667 667
 							$tckts_slctd = TRUE;
668 668
 							// d( $valid['ticket_obj'][$x] );
669
-							if ( $valid['ticket_obj'][$x] instanceof EE_Ticket ) {
669
+							if ($valid['ticket_obj'][$x] instanceof EE_Ticket) {
670 670
 								// then add ticket to cart
671
-								$tickets_added += self::_add_ticket_to_cart( $valid['ticket_obj'][$x], $valid['qty'][$x] );
671
+								$tickets_added += self::_add_ticket_to_cart($valid['ticket_obj'][$x], $valid['qty'][$x]);
672 672
 								//echo "\n\n " . __LINE__ . ") " . __METHOD__ . "() <br />";
673 673
 								//echo "\n . ticket_added: " . $ticket_added . '<br />';
674
-								if ( EE_Error::has_error() ) {
674
+								if (EE_Error::has_error()) {
675 675
 									break;
676 676
 								}
677 677
 							} else {
678 678
 								// nothing added to cart retrieved
679 679
 								EE_Error::add_error(
680
-									sprintf( __( 'A valid ticket could not be retrieved for the event.%sPlease click the back button on your browser and try again.', 'event_espresso' ), '<br/>' ),
680
+									sprintf(__('A valid ticket could not be retrieved for the event.%sPlease click the back button on your browser and try again.', 'event_espresso'), '<br/>'),
681 681
 									__FILE__, __FUNCTION__, __LINE__
682 682
 								);
683 683
 							}
684 684
 						}
685 685
 					}
686 686
 				}
687
-				do_action( 'AHEE__EE_Ticket_Selector__process_ticket_selections__after_tickets_added_to_cart', EE_Registry::instance()->CART, $this );
687
+				do_action('AHEE__EE_Ticket_Selector__process_ticket_selections__after_tickets_added_to_cart', EE_Registry::instance()->CART, $this);
688 688
 				//d( EE_Registry::instance()->CART );
689 689
 				//die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< KILL REDIRECT HERE BEFORE CART UPDATE
690 690
 
691
-				if ( apply_filters( 'FHEE__EED_Ticket_Selector__process_ticket_selections__tckts_slctd', $tckts_slctd ) ) {
692
-					if ( apply_filters( 'FHEE__EED_Ticket_Selector__process_ticket_selections__success', $tickets_added ) ) {
693
-						do_action( 'FHEE__EE_Ticket_Selector__process_ticket_selections__before_redirecting_to_checkout', EE_Registry::instance()->CART, $this );
691
+				if (apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__tckts_slctd', $tckts_slctd)) {
692
+					if (apply_filters('FHEE__EED_Ticket_Selector__process_ticket_selections__success', $tickets_added)) {
693
+						do_action('FHEE__EE_Ticket_Selector__process_ticket_selections__before_redirecting_to_checkout', EE_Registry::instance()->CART, $this);
694 694
 						EE_Registry::instance()->CART->recalculate_all_cart_totals();
695
-						EE_Registry::instance()->CART->save_cart( FALSE );
695
+						EE_Registry::instance()->CART->save_cart(FALSE);
696 696
 						EE_Registry::instance()->SSN->update();
697 697
 						//d( EE_Registry::instance()->CART );
698 698
 						//die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< OR HERE TO KILL REDIRECT AFTER CART UPDATE
699 699
 						// just return TRUE for registrations being made from admin
700
-						if ( is_admin() ) {
700
+						if (is_admin()) {
701 701
 							return TRUE;
702 702
 						}
703 703
 
704
-						EE_Error::get_notices( false, true );
705
-						wp_safe_redirect( apply_filters( 'FHEE__EE_Ticket_Selector__process_ticket_selections__success_redirect_url', EE_Registry::instance()->CFG->core->reg_page_url() ));
704
+						EE_Error::get_notices(false, true);
705
+						wp_safe_redirect(apply_filters('FHEE__EE_Ticket_Selector__process_ticket_selections__success_redirect_url', EE_Registry::instance()->CFG->core->reg_page_url()));
706 706
 						exit();
707 707
 
708 708
 					} else {
709
-						if ( ! EE_Error::has_error() ) {
709
+						if ( ! EE_Error::has_error()) {
710 710
 							// nothing added to cart
711
-							EE_Error::add_attention( __( 'No tickets were added for the event', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
711
+							EE_Error::add_attention(__('No tickets were added for the event', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
712 712
 						}
713 713
 					}
714 714
 
715 715
 				} else {
716 716
 					// no ticket quantities were selected
717
-					EE_Error::add_error( __( 'You need to select a ticket quantity before you can proceed.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
717
+					EE_Error::add_error(__('You need to select a ticket quantity before you can proceed.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
718 718
 				}
719 719
 			}
720 720
 			//die(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< KILL BEFORE REDIRECT
721 721
 			// at this point, just return if registration is being made from admin
722
-			if ( is_admin() ) {
722
+			if (is_admin()) {
723 723
 				return FALSE;
724 724
 			}
725
-			if ( $valid['return_url'] ) {
726
-				EE_Error::get_notices( FALSE, TRUE );
727
-				wp_safe_redirect( $valid['return_url'] );
725
+			if ($valid['return_url']) {
726
+				EE_Error::get_notices(FALSE, TRUE);
727
+				wp_safe_redirect($valid['return_url']);
728 728
 				exit();
729
-			} elseif ( isset( $event_to_add['id'] )) {
730
-				EE_Error::get_notices( FALSE, TRUE );
731
-				wp_safe_redirect( get_permalink( $event_to_add['id'] ));
729
+			} elseif (isset($event_to_add['id'])) {
730
+				EE_Error::get_notices(FALSE, TRUE);
731
+				wp_safe_redirect(get_permalink($event_to_add['id']));
732 732
 				exit();
733 733
 			} else {
734 734
 				echo EE_Error::get_notices();
@@ -737,7 +737,7 @@  discard block
 block discarded – undo
737 737
 		} else {
738 738
 			// $_POST['tkt-slctr-event-id'] was not set ?!?!?!?
739 739
 			EE_Error::add_error(
740
-				sprintf( __( 'An event id was not provided or was not received.%sPlease click the back button on your browser and try again.', 'event_espresso' ), '<br/>' ),
740
+				sprintf(__('An event id was not provided or was not received.%sPlease click the back button on your browser and try again.', 'event_espresso'), '<br/>'),
741 741
 				__FILE__, __FUNCTION__, __LINE__
742 742
 			);
743 743
 		}
@@ -755,18 +755,18 @@  discard block
 block discarded – undo
755 755
 	 * @return        array  or FALSE
756 756
 	 */
757 757
 	private static function _validate_post_data() {
758
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
758
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
759 759
 
760 760
 		// start with an empty array()
761 761
 		$valid_data = array();
762 762
 		//		d( $_POST );
763 763
 		//if event id is valid
764
-		$id = absint( EE_Registry::instance()->REQ->get( 'tkt-slctr-event-id' ));
765
-		if ( $id ) {
764
+		$id = absint(EE_Registry::instance()->REQ->get('tkt-slctr-event-id'));
765
+		if ($id) {
766 766
 			// grab valid id
767 767
 			$valid_data['id'] = $id;
768 768
 			// grab and sanitize return-url
769
-			$valid_data['return_url'] = esc_url_raw( EE_Registry::instance()->REQ->get( 'tkt-slctr-return-url-' . $id ));
769
+			$valid_data['return_url'] = esc_url_raw(EE_Registry::instance()->REQ->get('tkt-slctr-return-url-'.$id));
770 770
 			// array of other form names
771 771
 			$inputs_to_clean = array(
772 772
 				'event_id' => 'tkt-slctr-event-id',
@@ -779,22 +779,22 @@  discard block
 block discarded – undo
779 779
 			// let's track the total number of tickets ordered.'
780 780
 			$valid_data['total_tickets'] = 0;
781 781
 			// cycle through $inputs_to_clean array
782
-			foreach ( $inputs_to_clean as $what => $input_to_clean ) {
782
+			foreach ($inputs_to_clean as $what => $input_to_clean) {
783 783
 				// check for POST data
784
-				if ( EE_Registry::instance()->REQ->is_set( $input_to_clean . $id )) {
784
+				if (EE_Registry::instance()->REQ->is_set($input_to_clean.$id)) {
785 785
 					// grab value
786
-					$input_value = EE_Registry::instance()->REQ->get( $input_to_clean . $id );
786
+					$input_value = EE_Registry::instance()->REQ->get($input_to_clean.$id);
787 787
 					switch ($what) {
788 788
 
789 789
 						// integers
790 790
 						case 'event_id':
791
-							$valid_data[$what] = absint( $input_value );
791
+							$valid_data[$what] = absint($input_value);
792 792
 							// get event via the event id we put in the form
793
-							$valid_data['event'] = EE_Registry::instance()->load_model( 'Event' )->get_one_by_ID( $valid_data['event_id'] );
793
+							$valid_data['event'] = EE_Registry::instance()->load_model('Event')->get_one_by_ID($valid_data['event_id']);
794 794
 							break;
795 795
 						case 'rows':
796 796
 						case 'max_atndz':
797
-							$valid_data[$what] = absint( $input_value );
797
+							$valid_data[$what] = absint($input_value);
798 798
 							break;
799 799
 
800 800
 						// arrays of integers
@@ -802,27 +802,27 @@  discard block
 block discarded – undo
802 802
 							//							d( $input_value );
803 803
 							$row_qty = $input_value;
804 804
 							// if qty is coming from a radio button input, then we need to assemble an array of rows
805
-							if( ! is_array( $row_qty )) {
805
+							if ( ! is_array($row_qty)) {
806 806
 								// get number of rows
807
-								$rows = EE_Registry::instance()->REQ->is_set( 'tkt-slctr-rows-' . $id ) ? absint( EE_Registry::instance()->REQ->get( 'tkt-slctr-rows-' . $id )) : 1;
807
+								$rows = EE_Registry::instance()->REQ->is_set('tkt-slctr-rows-'.$id) ? absint(EE_Registry::instance()->REQ->get('tkt-slctr-rows-'.$id)) : 1;
808 808
 								//								d( $rows );
809 809
 								// explode ints by the dash
810
-								$row_qty = explode( '-', $row_qty );
811
-								$row = isset( $row_qty[0] ) ? ( absint( $row_qty[0] )) : 1;
812
-								$qty = isset( $row_qty[1] ) ? absint( $row_qty[1] ) : 0;
813
-								$row_qty = array( $row => $qty );
810
+								$row_qty = explode('-', $row_qty);
811
+								$row = isset($row_qty[0]) ? (absint($row_qty[0])) : 1;
812
+								$qty = isset($row_qty[1]) ? absint($row_qty[1]) : 0;
813
+								$row_qty = array($row => $qty);
814 814
 								//								 d( $row_qty );
815
-								for( $x = 1; $x <= $rows; $x++ ) {
816
-									if ( ! isset( $row_qty[$x] )) {
815
+								for ($x = 1; $x <= $rows; $x++) {
816
+									if ( ! isset($row_qty[$x])) {
817 817
 										$row_qty[$x] = 0;
818 818
 									}
819 819
 								}
820 820
 							}
821
-							ksort( $row_qty );
821
+							ksort($row_qty);
822 822
 							//							 d( $row_qty );
823 823
 							// cycle thru values
824
-							foreach ( $row_qty as $qty ) {
825
-								$qty = absint( $qty );
824
+							foreach ($row_qty as $qty) {
825
+								$qty = absint($qty);
826 826
 								// sanitize as integers
827 827
 								$valid_data[$what][] = $qty;
828 828
 								$valid_data['total_tickets'] += $qty;
@@ -833,19 +833,19 @@  discard block
 block discarded – undo
833 833
 						case 'ticket_id':
834 834
 							$value_array = array();
835 835
 							// cycle thru values
836
-							foreach ( $input_value as $key=>$value ) {
836
+							foreach ($input_value as $key=>$value) {
837 837
 								// allow only numbers, letters,  spaces, commas and dashes
838
-								$value_array[ $key ] = wp_strip_all_tags( $value );
838
+								$value_array[$key] = wp_strip_all_tags($value);
839 839
 								// get ticket via the ticket id we put in the form
840
-								$ticket_obj = EE_Registry::instance()->load_model( 'Ticket' )->get_one_by_ID( $value );
841
-								$valid_data['ticket_obj'][ $key ] = $ticket_obj;
840
+								$ticket_obj = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($value);
841
+								$valid_data['ticket_obj'][$key] = $ticket_obj;
842 842
 							}
843
-							$valid_data[ $what ] = $value_array;
843
+							$valid_data[$what] = $value_array;
844 844
 							break;
845 845
 
846 846
 						case 'return_url' :
847 847
 							// grab and sanitize return-url
848
-							$valid_data[$what] = esc_url_raw( $input_value );
848
+							$valid_data[$what] = esc_url_raw($input_value);
849 849
 							break;
850 850
 
851 851
 					} 	// end switch $what
@@ -853,7 +853,7 @@  discard block
 block discarded – undo
853 853
 			} 	// end foreach $inputs_to_clean
854 854
 
855 855
 		} else {
856
-			EE_Error::add_error( __('The event id provided was not valid.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
856
+			EE_Error::add_error(__('The event id provided was not valid.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
857 857
 			return FALSE;
858 858
 		}
859 859
 
@@ -871,12 +871,12 @@  discard block
 block discarded – undo
871 871
 	 * @param int       $qty
872 872
 	 * @return int quantity of tickets added
873 873
 	 */
874
-	private static function _add_ticket_to_cart( EE_Ticket $ticket = NULL, $qty = 1 ) {
875
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
874
+	private static function _add_ticket_to_cart(EE_Ticket $ticket = NULL, $qty = 1) {
875
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
876 876
 		// get the number of spaces left for this datetime ticket
877
-		$available_spaces = self::_ticket_datetime_availability( $ticket );
877
+		$available_spaces = self::_ticket_datetime_availability($ticket);
878 878
 		// compare available spaces against the number of tickets being purchased
879
-		if ( $available_spaces >= $qty ) {
879
+		if ($available_spaces >= $qty) {
880 880
 			// allow addons to prevent a ticket from being added to cart
881 881
 			if (
882 882
 				! apply_filters(
@@ -889,10 +889,10 @@  discard block
 block discarded – undo
889 889
 			) {
890 890
 				return 0;
891 891
 			}
892
-			$qty = apply_filters( 'FHEE__EE_Ticket_Selector___add_ticket_to_cart__ticket_qty', $qty, $ticket );
892
+			$qty = apply_filters('FHEE__EE_Ticket_Selector___add_ticket_to_cart__ticket_qty', $qty, $ticket);
893 893
 			// add event to cart
894
-			if( $qty && EE_Registry::instance()->CART->add_ticket_to_cart( $ticket, $qty )) {
895
-				self::_recalculate_ticket_datetime_availability( $ticket, $qty );
894
+			if ($qty && EE_Registry::instance()->CART->add_ticket_to_cart($ticket, $qty)) {
895
+				self::_recalculate_ticket_datetime_availability($ticket, $qty);
896 896
 				return $qty;
897 897
 			} else {
898 898
 				return 0;
@@ -900,9 +900,9 @@  discard block
 block discarded – undo
900 900
 		} else {
901 901
 			// tickets can not be purchased but let's find the exact number left
902 902
 			// for the last ticket selected PRIOR to subtracting tickets
903
-			$available_spaces = self::_ticket_datetime_availability( $ticket, true );
903
+			$available_spaces = self::_ticket_datetime_availability($ticket, true);
904 904
 			// greedy greedy greedy eh?
905
-			if ( $available_spaces > 0 ) {
905
+			if ($available_spaces > 0) {
906 906
 				if (
907 907
 					apply_filters(
908 908
 						'FHEE__EE_Ticket_Selector___add_ticket_to_cart__allow_display_availability_error',
@@ -912,7 +912,7 @@  discard block
 block discarded – undo
912 912
 						$available_spaces
913 913
 					)
914 914
 				) {
915
-					EED_Ticket_Selector::_display_availability_error( $available_spaces );
915
+					EED_Ticket_Selector::_display_availability_error($available_spaces);
916 916
 				}
917 917
 			} else {
918 918
 				EE_Error::add_error(
@@ -937,10 +937,10 @@  discard block
 block discarded – undo
937 937
 	 * @access    private
938 938
 	 * @param int $available_spaces
939 939
 	 */
940
-	private static function _display_availability_error( $available_spaces = 1 ) {
940
+	private static function _display_availability_error($available_spaces = 1) {
941 941
 		// add error messaging - we're using the _n function that will generate
942 942
 		// the appropriate singular or plural message based on the number of $available_spaces
943
-		if ( EE_Registry::instance()->CART->all_ticket_quantity_count() ) {
943
+		if (EE_Registry::instance()->CART->all_ticket_quantity_count()) {
944 944
 			$msg = sprintf(
945 945
 				_n(
946 946
 					'We\'re sorry, but there is only %1$s available space left for this event at this particular date and time. Please select a different number (or different combination) of tickets by cancelling the current selection and choosing again, or proceed to registration.',
@@ -963,7 +963,7 @@  discard block
 block discarded – undo
963 963
 				'<br />'
964 964
 			);
965 965
 		}
966
-		EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
966
+		EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
967 967
 	}
968 968
 
969 969
 
@@ -978,22 +978,22 @@  discard block
 block discarded – undo
978 978
 	 * @param 	bool         $get_original_ticket_spaces
979 979
 	 * @return 	int
980 980
 	 */
981
-	private static function _ticket_datetime_availability( EE_Ticket $ticket, $get_original_ticket_spaces = FALSE ) {
981
+	private static function _ticket_datetime_availability(EE_Ticket $ticket, $get_original_ticket_spaces = FALSE) {
982 982
 		// if the $_available_spaces array has not been set up yet...
983
-		if ( ! isset( self::$_available_spaces['tickets'][ $ticket->ID() ] )) {
984
-				self::_set_initial_ticket_datetime_availability( $ticket );
983
+		if ( ! isset(self::$_available_spaces['tickets'][$ticket->ID()])) {
984
+				self::_set_initial_ticket_datetime_availability($ticket);
985 985
 		}
986 986
 		$available_spaces = $ticket->qty() - $ticket->sold();
987
-		if ( isset( self::$_available_spaces['tickets'][ $ticket->ID() ] )) {
987
+		if (isset(self::$_available_spaces['tickets'][$ticket->ID()])) {
988 988
 			// loop thru tickets, which will ALSO include individual ticket records AND a total
989
-			foreach ( self::$_available_spaces['tickets'][ $ticket->ID() ] as $DTD_ID => $spaces  ) {
989
+			foreach (self::$_available_spaces['tickets'][$ticket->ID()] as $DTD_ID => $spaces) {
990 990
 				// if we want the original datetime availability BEFORE we started subtracting tickets ?
991
-				if ( $get_original_ticket_spaces ) {
991
+				if ($get_original_ticket_spaces) {
992 992
 					// then grab the available spaces from the "tickets" array and compare with the above to get the lowest number
993
-					$available_spaces = min( $available_spaces, self::$_available_spaces['tickets'][ $ticket->ID() ][ $DTD_ID ] );
993
+					$available_spaces = min($available_spaces, self::$_available_spaces['tickets'][$ticket->ID()][$DTD_ID]);
994 994
 				} else {
995 995
 					// we want the updated ticket availability as stored in the "datetimes" array
996
-					$available_spaces = min( $available_spaces, self::$_available_spaces['datetimes'][ $DTD_ID ] );
996
+					$available_spaces = min($available_spaces, self::$_available_spaces['datetimes'][$DTD_ID]);
997 997
 				}
998 998
 			}
999 999
 		}
@@ -1009,23 +1009,23 @@  discard block
 block discarded – undo
1009 1009
 	 * @param 	EE_Ticket $ticket
1010 1010
 	 * @return 	int
1011 1011
 	 */
1012
-	private static function _set_initial_ticket_datetime_availability( EE_Ticket $ticket ) {
1012
+	private static function _set_initial_ticket_datetime_availability(EE_Ticket $ticket) {
1013 1013
 		// first, get all of the datetimes that are available to this ticket
1014 1014
 		$datetimes = $ticket->get_many_related(
1015 1015
 			'Datetime',
1016
-			array( array( 'DTT_EVT_end' => array( '>=', EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_end' ) ) ), 'order_by' => array( 'DTT_EVT_start' => 'ASC' ))
1016
+			array(array('DTT_EVT_end' => array('>=', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'))), 'order_by' => array('DTT_EVT_start' => 'ASC'))
1017 1017
 		);
1018
-		if ( ! empty( $datetimes )) {
1018
+		if ( ! empty($datetimes)) {
1019 1019
 			// now loop thru all of the datetimes
1020
-			foreach ( $datetimes as $datetime  ) {
1021
-				if ( $datetime instanceof EE_Datetime ) {
1020
+			foreach ($datetimes as $datetime) {
1021
+				if ($datetime instanceof EE_Datetime) {
1022 1022
 					// the number of spaces available for the datetime without considering individual ticket quantities
1023 1023
 					$spaces_remaining = $datetime->spaces_remaining();
1024 1024
 					// save the total available spaces ( the lesser of the ticket qty minus the number of tickets sold or the datetime spaces remaining) to this ticket using the datetime ID as the key
1025
-					self::$_available_spaces['tickets'][ $ticket->ID() ][ $datetime->ID() ] = min(( $ticket->qty() - $ticket->sold() ), $spaces_remaining );
1025
+					self::$_available_spaces['tickets'][$ticket->ID()][$datetime->ID()] = min(($ticket->qty() - $ticket->sold()), $spaces_remaining);
1026 1026
 					// if the remaining spaces for this datetime is already set, then compare that against the datetime spaces remaining, and take the lowest number,
1027 1027
 					// else just take the datetime spaces remaining, and assign to the datetimes array
1028
-					self::$_available_spaces['datetimes'][ $datetime->ID() ] = isset( self::$_available_spaces['datetimes'][ $datetime->ID() ] ) ? min( self::$_available_spaces['datetimes'][ $datetime->ID() ], $spaces_remaining ) : $spaces_remaining;
1028
+					self::$_available_spaces['datetimes'][$datetime->ID()] = isset(self::$_available_spaces['datetimes'][$datetime->ID()]) ? min(self::$_available_spaces['datetimes'][$datetime->ID()], $spaces_remaining) : $spaces_remaining;
1029 1029
 				}
1030 1030
 			}
1031 1031
 		}
@@ -1041,12 +1041,12 @@  discard block
 block discarded – undo
1041 1041
 	 * @param 	int   $qty
1042 1042
 	 * @return 	int
1043 1043
 	 */
1044
-	private static function _recalculate_ticket_datetime_availability( EE_Ticket $ticket, $qty = 0 ) {
1045
-		if ( isset( self::$_available_spaces['tickets'][ $ticket->ID() ] )) {
1044
+	private static function _recalculate_ticket_datetime_availability(EE_Ticket $ticket, $qty = 0) {
1045
+		if (isset(self::$_available_spaces['tickets'][$ticket->ID()])) {
1046 1046
 			// loop thru tickets, which will ALSO include individual ticket records AND a total
1047
-			foreach ( self::$_available_spaces['tickets'][ $ticket->ID() ] as $DTD_ID => $spaces  ) {
1047
+			foreach (self::$_available_spaces['tickets'][$ticket->ID()] as $DTD_ID => $spaces) {
1048 1048
 				// subtract the qty of selected tickets from each datetime's available spaces this ticket has access to,
1049
-				self::$_available_spaces['datetimes'][ $DTD_ID ] = self::$_available_spaces['datetimes'][ $DTD_ID ] - $qty;
1049
+				self::$_available_spaces['datetimes'][$DTD_ID] = self::$_available_spaces['datetimes'][$DTD_ID] - $qty;
1050 1050
 			}
1051 1051
 		}
1052 1052
 	}
@@ -1063,8 +1063,8 @@  discard block
 block discarded – undo
1063 1063
 	*/
1064 1064
 	public static function load_tckt_slctr_assets() {
1065 1065
 		// add some style
1066
-		if ( apply_filters( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', FALSE ) ) {
1067
-			wp_register_style('ticket_selector', TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css');
1066
+		if (apply_filters('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', FALSE)) {
1067
+			wp_register_style('ticket_selector', TICKET_SELECTOR_ASSETS_URL.'ticket_selector.css');
1068 1068
 			wp_enqueue_style('ticket_selector');
1069 1069
 			// make it dance
1070 1070
 			//			wp_register_script('ticket_selector', TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js', array('espresso_core'), '', TRUE);
@@ -1078,9 +1078,9 @@  discard block
 block discarded – undo
1078 1078
 
1079 1079
 	public static function load_tckt_slctr_assets_admin() {
1080 1080
 		//iframe button js on admin event editor page
1081
-		if ( EE_Registry::instance()->REQ->get('page') == 'espresso_events' && EE_Registry::instance()->REQ->get('action') == 'edit' ) {
1082
-			wp_register_script( 'ticket_selector_embed', TICKET_SELECTOR_ASSETS_URL . 'ticket-selector-embed.js', array( 'ee-dialog' ), EVENT_ESPRESSO_VERSION, true );
1083
-			wp_enqueue_script( 'ticket_selector_embed' );
1081
+		if (EE_Registry::instance()->REQ->get('page') == 'espresso_events' && EE_Registry::instance()->REQ->get('action') == 'edit') {
1082
+			wp_register_script('ticket_selector_embed', TICKET_SELECTOR_ASSETS_URL.'ticket-selector-embed.js', array('ee-dialog'), EVENT_ESPRESSO_VERSION, true);
1083
+			wp_enqueue_script('ticket_selector_embed');
1084 1084
 		}
1085 1085
 	}
1086 1086
 
Please login to merge, or discard this patch.
admin_pages/transactions/Transactions_Admin_Page.core.php 1 patch
Spacing   +396 added lines, -396 removed lines patch added patch discarded remove patch
@@ -56,8 +56,8 @@  discard block
 block discarded – undo
56 56
 	 * @param bool $routing
57 57
 	 * @return Transactions_Admin_Page
58 58
 	 */
59
-	public function __construct( $routing = TRUE ) {
60
-		parent::__construct( $routing );
59
+	public function __construct($routing = TRUE) {
60
+		parent::__construct($routing);
61 61
 	}
62 62
 
63 63
 
@@ -80,9 +80,9 @@  discard block
 block discarded – undo
80 80
 	 * @return void
81 81
 	 */
82 82
 	protected function _ajax_hooks() {
83
-		add_action('wp_ajax_espresso_apply_payment', array( $this, 'apply_payments_or_refunds'));
84
-		add_action('wp_ajax_espresso_apply_refund', array( $this, 'apply_payments_or_refunds'));
85
-		add_action('wp_ajax_espresso_delete_payment', array( $this, 'delete_payment'));
83
+		add_action('wp_ajax_espresso_apply_payment', array($this, 'apply_payments_or_refunds'));
84
+		add_action('wp_ajax_espresso_apply_refund', array($this, 'apply_payments_or_refunds'));
85
+		add_action('wp_ajax_espresso_delete_payment', array($this, 'delete_payment'));
86 86
 	}
87 87
 
88 88
 
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 			'buttons' => array(
98 98
 				'add' => __('Add New Transaction', 'event_espresso'),
99 99
 				'edit' => __('Edit Transaction', 'event_espresso'),
100
-				'delete' => __('Delete Transaction','event_espresso')
100
+				'delete' => __('Delete Transaction', 'event_espresso')
101 101
 				)
102 102
 			);
103 103
 	}
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 
114 114
 		$this->_set_transaction_status_array();
115 115
 
116
-		$txn_id = ! empty( $this->_req_data['TXN_ID'] ) && ! is_array( $this->_req_data['TXN_ID'] ) ? $this->_req_data['TXN_ID'] : 0;
116
+		$txn_id = ! empty($this->_req_data['TXN_ID']) && ! is_array($this->_req_data['TXN_ID']) ? $this->_req_data['TXN_ID'] : 0;
117 117
 
118 118
 		$this->_page_routes = array(
119 119
 
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 						'filename' => 'transactions_overview_views_filters_search'
186 186
 					),
187 187
 				),
188
-				'help_tour' => array( 'Transactions_Overview_Help_Tour' ),
188
+				'help_tour' => array('Transactions_Overview_Help_Tour'),
189 189
 				/**
190 190
 				 * commented out because currently we are not displaying tips for transaction list table status but this
191 191
 				 * may change in a later iteration so want to keep the code for then.
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 				'nav' => array(
198 198
 					'label' => __('View Transaction', 'event_espresso'),
199 199
 					'order' => 5,
200
-					'url' => isset($this->_req_data['TXN_ID']) ? add_query_arg(array('TXN_ID' => $this->_req_data['TXN_ID'] ), $this->_current_page_view_url )  : $this->_admin_base_url,
200
+					'url' => isset($this->_req_data['TXN_ID']) ? add_query_arg(array('TXN_ID' => $this->_req_data['TXN_ID']), $this->_current_page_view_url) : $this->_admin_base_url,
201 201
 					'persistent' => FALSE
202 202
 					),
203 203
 				'help_tabs' => array(
@@ -218,8 +218,8 @@  discard block
 block discarded – undo
218 218
 						'filename' => 'transactions_view_transaction_primary_registrant_billing_information'
219 219
 					),
220 220
 				),
221
-				'qtips' => array( 'Transaction_Details_Tips' ),
222
-				'help_tour' => array( 'Transaction_Details_Help_Tour' ),
221
+				'qtips' => array('Transaction_Details_Tips'),
222
+				'help_tour' => array('Transaction_Details_Help_Tour'),
223 223
 				'metaboxes' => array('_transaction_details_metaboxes'),
224 224
 
225 225
 				'require_nonce' => FALSE
@@ -234,10 +234,10 @@  discard block
 block discarded – undo
234 234
 	protected function _add_screen_options() {}
235 235
 	protected function _add_feature_pointers() {}
236 236
 	public function admin_init() {
237
-		EE_Registry::$i18n_js_strings[ 'invalid_server_response' ] = __( 'An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.', 'event_espresso' );
238
-		EE_Registry::$i18n_js_strings[ 'error_occurred' ] = __( 'An error occurred! Please refresh the page and try again.', 'event_espresso' );
239
-		EE_Registry::$i18n_js_strings[ 'txn_status_array' ] = self::$_txn_status;
240
-		EE_Registry::$i18n_js_strings[ 'pay_status_array' ] = self::$_pay_status;
237
+		EE_Registry::$i18n_js_strings['invalid_server_response'] = __('An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.', 'event_espresso');
238
+		EE_Registry::$i18n_js_strings['error_occurred'] = __('An error occurred! Please refresh the page and try again.', 'event_espresso');
239
+		EE_Registry::$i18n_js_strings['txn_status_array'] = self::$_txn_status;
240
+		EE_Registry::$i18n_js_strings['pay_status_array'] = self::$_pay_status;
241 241
 	}
242 242
 	public function admin_notices() {}
243 243
 	public function admin_footer_scripts() {}
@@ -304,14 +304,14 @@  discard block
 block discarded – undo
304 304
 	 */
305 305
 	public function load_scripts_styles() {
306 306
 		//enqueue style
307
-		wp_register_style( 'espresso_txn', TXN_ASSETS_URL . 'espresso_transactions_admin.css', array(), EVENT_ESPRESSO_VERSION );
307
+		wp_register_style('espresso_txn', TXN_ASSETS_URL.'espresso_transactions_admin.css', array(), EVENT_ESPRESSO_VERSION);
308 308
 		wp_enqueue_style('espresso_txn');
309 309
 
310 310
 		//scripts
311 311
 		add_filter('FHEE_load_accounting_js', '__return_true');
312 312
 
313 313
 		//scripts
314
-		wp_register_script('espresso_txn', TXN_ASSETS_URL . 'espresso_transactions_admin.js', array('ee_admin_js', 'ee-datepicker', 'jquery-ui-datepicker', 'jquery-ui-draggable', 'ee-dialog', 'ee-accounting', 'ee-serialize-full-array'), EVENT_ESPRESSO_VERSION, TRUE);
314
+		wp_register_script('espresso_txn', TXN_ASSETS_URL.'espresso_transactions_admin.js', array('ee_admin_js', 'ee-datepicker', 'jquery-ui-datepicker', 'jquery-ui-draggable', 'ee-dialog', 'ee-accounting', 'ee-serialize-full-array'), EVENT_ESPRESSO_VERSION, TRUE);
315 315
 		wp_enqueue_script('espresso_txn');
316 316
 
317 317
 	}
@@ -351,8 +351,8 @@  discard block
 block discarded – undo
351 351
 	 *	@return void
352 352
 	 */
353 353
 	protected function _set_list_table_views_default() {
354
-		$this->_views = array (
355
-			'all' => array (
354
+		$this->_views = array(
355
+			'all' => array(
356 356
 				'slug' 		=> 'all',
357 357
 				'label' 		=> __('View All Transactions', 'event_espresso'),
358 358
 				'count' 	=> 0
@@ -380,20 +380,20 @@  discard block
 block discarded – undo
380 380
 	 *	@return void
381 381
 	 */
382 382
 	private function _set_transaction_object() {
383
-		if ( is_object( $this->_transaction) )
383
+		if (is_object($this->_transaction))
384 384
 			return; //get out we've already set the object
385 385
 
386 386
 	    $TXN = EEM_Transaction::instance();
387 387
 
388
-	    $TXN_ID = ( ! empty( $this->_req_data['TXN_ID'] )) ? absint( $this->_req_data['TXN_ID'] ) : FALSE;
388
+	    $TXN_ID = ( ! empty($this->_req_data['TXN_ID'])) ? absint($this->_req_data['TXN_ID']) : FALSE;
389 389
 
390 390
 	    //get transaction object
391 391
 	    $this->_transaction = $TXN->get_one_by_ID($TXN_ID);
392
-	    $this->_session = !empty( $this->_transaction ) ? $this->_transaction->get('TXN_session_data') : NULL;
392
+	    $this->_session = ! empty($this->_transaction) ? $this->_transaction->get('TXN_session_data') : NULL;
393 393
 
394
-	 	if ( empty( $this->_transaction ) ) {
395
-	    	$error_msg = __('An error occurred and the details for Transaction ID #', 'event_espresso') . $TXN_ID .  __(' could not be retrieved.', 'event_espresso');
396
-			EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ );
394
+	 	if (empty($this->_transaction)) {
395
+	    	$error_msg = __('An error occurred and the details for Transaction ID #', 'event_espresso').$TXN_ID.__(' could not be retrieved.', 'event_espresso');
396
+			EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
397 397
 	    }
398 398
 	}
399 399
 
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
 				),
420 420
 				'view_receipt' => array(
421 421
 					'class' => 'dashicons dashicons-media-default',
422
-					'desc' => __('View Transaction Receipt', 'event_espresso' )
422
+					'desc' => __('View Transaction Receipt', 'event_espresso')
423 423
 				),
424 424
 				'view_registration' => array(
425 425
 					'class' => 'dashicons dashicons-clipboard',
@@ -428,10 +428,10 @@  discard block
 block discarded – undo
428 428
 			)
429 429
 		);
430 430
 
431
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'espresso_transactions_send_payment_reminder' ) ) {
431
+		if (EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'espresso_transactions_send_payment_reminder')) {
432 432
 
433
-			EE_Registry::instance()->load_helper( 'MSG_Template' );
434
-			if ( EEH_MSG_Template::is_mt_active( 'payment_reminder' ) ) {
433
+			EE_Registry::instance()->load_helper('MSG_Template');
434
+			if (EEH_MSG_Template::is_mt_active('payment_reminder')) {
435 435
 				$items['send_payment_reminder'] = array(
436 436
 					'class' => 'dashicons dashicons-email-alt',
437 437
 					'desc' => __('Send Payment Reminder', 'event_espresso')
@@ -452,29 +452,29 @@  discard block
 block discarded – undo
452 452
 			'FHEE__Transactions_Admin_Page___transaction_legend_items__more_items',
453 453
 			array(
454 454
 				'overpaid'   => array(
455
-					'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::overpaid_status_code,
456
-					'desc'  => EEH_Template::pretty_status( EEM_Transaction::overpaid_status_code, FALSE, 'sentence' )
455
+					'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::overpaid_status_code,
456
+					'desc'  => EEH_Template::pretty_status(EEM_Transaction::overpaid_status_code, FALSE, 'sentence')
457 457
 				),
458 458
 				'complete'   => array(
459
-					'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::complete_status_code,
460
-					'desc'  => EEH_Template::pretty_status( EEM_Transaction::complete_status_code, FALSE, 'sentence' )
459
+					'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::complete_status_code,
460
+					'desc'  => EEH_Template::pretty_status(EEM_Transaction::complete_status_code, FALSE, 'sentence')
461 461
 				),
462 462
 				'incomplete' => array(
463
-					'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::incomplete_status_code,
464
-					'desc'  => EEH_Template::pretty_status( EEM_Transaction::incomplete_status_code, FALSE, 'sentence' )
463
+					'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::incomplete_status_code,
464
+					'desc'  => EEH_Template::pretty_status(EEM_Transaction::incomplete_status_code, FALSE, 'sentence')
465 465
 				),
466 466
 				'abandoned'  => array(
467
-					'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::abandoned_status_code,
468
-					'desc'  => EEH_Template::pretty_status( EEM_Transaction::abandoned_status_code, FALSE, 'sentence' )
467
+					'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::abandoned_status_code,
468
+					'desc'  => EEH_Template::pretty_status(EEM_Transaction::abandoned_status_code, FALSE, 'sentence')
469 469
 				),
470 470
 				'failed'     => array(
471
-					'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::failed_status_code,
472
-					'desc'  => EEH_Template::pretty_status( EEM_Transaction::failed_status_code, FALSE, 'sentence' )
471
+					'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::failed_status_code,
472
+					'desc'  => EEH_Template::pretty_status(EEM_Transaction::failed_status_code, FALSE, 'sentence')
473 473
 				)
474 474
 			)
475 475
 		);
476 476
 
477
-		return array_merge( $items, $more_items);
477
+		return array_merge($items, $more_items);
478 478
 	}
479 479
 
480 480
 
@@ -487,9 +487,9 @@  discard block
 block discarded – undo
487 487
 	 */
488 488
 	protected function _transactions_overview_list_table() {
489 489
 		$this->_admin_page_title = __('Transactions', 'event_espresso');
490
-		$event = isset($this->_req_data['EVT_ID']) ? EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID'] ) : NULL;
491
-		$this->_template_args['admin_page_header'] = $event instanceof EE_Event ? sprintf( __('%sViewing Transactions for the Event: %s%s', 'event_espresso'), '<h3>', '<a href="' . EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit', 'post' => $event->ID()), EVENTS_ADMIN_URL ) . '" title="' . esc_attr__('Click to Edit event', 'event_espresso') . '">' . $event->get('EVT_name') . '</a>', '</h3>' ) : '';
492
-		$this->_template_args['after_list_table'] = $this->_display_legend( $this->_transaction_legend_items() );
490
+		$event = isset($this->_req_data['EVT_ID']) ? EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID']) : NULL;
491
+		$this->_template_args['admin_page_header'] = $event instanceof EE_Event ? sprintf(__('%sViewing Transactions for the Event: %s%s', 'event_espresso'), '<h3>', '<a href="'.EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit', 'post' => $event->ID()), EVENTS_ADMIN_URL).'" title="'.esc_attr__('Click to Edit event', 'event_espresso').'">'.$event->get('EVT_name').'</a>', '</h3>') : '';
492
+		$this->_template_args['after_list_table'] = $this->_display_legend($this->_transaction_legend_items());
493 493
 		$this->display_admin_list_table_page_with_no_sidebar();
494 494
 	}
495 495
 
@@ -503,8 +503,8 @@  discard block
 block discarded – undo
503 503
 	*	@return void
504 504
 	*/
505 505
 	protected function _transaction_details() {
506
-		do_action( 'AHEE__Transactions_Admin_Page__transaction_details__start', $this->_transaction );
507
-		EE_Registry::instance()->load_helper( 'MSG_Template' );
506
+		do_action('AHEE__Transactions_Admin_Page__transaction_details__start', $this->_transaction);
507
+		EE_Registry::instance()->load_helper('MSG_Template');
508 508
 
509 509
 		$this->_set_transaction_status_array();
510 510
 
@@ -517,75 +517,75 @@  discard block
 block discarded – undo
517 517
 		$attendee = $primary_registration instanceof EE_Registration ? $primary_registration->attendee() : NULL;
518 518
 
519 519
 		$this->_template_args['txn_nmbr']['value'] = $this->_transaction->ID();
520
-		$this->_template_args['txn_nmbr']['label'] = __( 'Transaction Number', 'event_espresso' );
520
+		$this->_template_args['txn_nmbr']['label'] = __('Transaction Number', 'event_espresso');
521 521
 
522
-		$this->_template_args['txn_datetime']['value'] = $this->_transaction->get_datetime('TXN_timestamp', 'l F j, Y', 'g:i:s a' );
523
-		$this->_template_args['txn_datetime']['label'] = __( 'Date', 'event_espresso' );
522
+		$this->_template_args['txn_datetime']['value'] = $this->_transaction->get_datetime('TXN_timestamp', 'l F j, Y', 'g:i:s a');
523
+		$this->_template_args['txn_datetime']['label'] = __('Date', 'event_espresso');
524 524
 
525
-		$this->_template_args['txn_status']['value'] = self::$_txn_status[ $this->_transaction->get('STS_ID') ];
526
-		$this->_template_args['txn_status']['label'] = __( 'Transaction Status', 'event_espresso' );
527
-		$this->_template_args['txn_status']['class'] = 'status-' . $this->_transaction->get('STS_ID');
525
+		$this->_template_args['txn_status']['value'] = self::$_txn_status[$this->_transaction->get('STS_ID')];
526
+		$this->_template_args['txn_status']['label'] = __('Transaction Status', 'event_espresso');
527
+		$this->_template_args['txn_status']['class'] = 'status-'.$this->_transaction->get('STS_ID');
528 528
 
529 529
 		$this->_template_args['grand_total'] = $this->_transaction->get('TXN_total');
530 530
 		$this->_template_args['total_paid'] = $this->_transaction->get('TXN_paid');
531 531
 
532
-		if ( $attendee instanceof EE_Attendee && EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'espresso_transactions_send_payment_reminder' ) ) {
533
-			EE_Registry::instance()->load_helper( 'MSG_Template' );
534
-			$this->_template_args['send_payment_reminder_button'] = EEH_MSG_Template::is_mt_active( 'payment_reminder' )
532
+		if ($attendee instanceof EE_Attendee && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'espresso_transactions_send_payment_reminder')) {
533
+			EE_Registry::instance()->load_helper('MSG_Template');
534
+			$this->_template_args['send_payment_reminder_button'] = EEH_MSG_Template::is_mt_active('payment_reminder')
535 535
 				 && $this->_transaction->get('STS_ID') != EEM_Transaction::complete_status_code
536 536
 				 && $this->_transaction->get('STS_ID') != EEM_Transaction::overpaid_status_code
537
-				 ? EEH_Template::get_button_or_link( EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'send_payment_reminder', 'TXN_ID'=>$this->_transaction->ID(), 'redirect_to' => 'view_transaction' ), TXN_ADMIN_URL ), __(' Send Payment Reminder'), 'button secondary-button right',  'dashicons dashicons-email-alt' )
537
+				 ? EEH_Template::get_button_or_link(EE_Admin_Page::add_query_args_and_nonce(array('action'=>'send_payment_reminder', 'TXN_ID'=>$this->_transaction->ID(), 'redirect_to' => 'view_transaction'), TXN_ADMIN_URL), __(' Send Payment Reminder'), 'button secondary-button right', 'dashicons dashicons-email-alt')
538 538
 				 : '';
539 539
 		} else {
540 540
 			$this->_template_args['send_payment_reminder_button'] = '';
541 541
 		}
542 542
 
543 543
 		$amount_due = $this->_transaction->get('TXN_total') - $this->_transaction->get('TXN_paid');
544
-		$this->_template_args['amount_due'] = EEH_Template::format_currency( $amount_due, TRUE );
545
-		if ( EE_Registry::instance()->CFG->currency->sign_b4 ) {
546
-			$this->_template_args['amount_due'] = EE_Registry::instance()->CFG->currency->sign . $this->_template_args['amount_due'];
544
+		$this->_template_args['amount_due'] = EEH_Template::format_currency($amount_due, TRUE);
545
+		if (EE_Registry::instance()->CFG->currency->sign_b4) {
546
+			$this->_template_args['amount_due'] = EE_Registry::instance()->CFG->currency->sign.$this->_template_args['amount_due'];
547 547
 		} else {
548
-			$this->_template_args['amount_due'] = $this->_template_args['amount_due'] . EE_Registry::instance()->CFG->currency->sign;
548
+			$this->_template_args['amount_due'] = $this->_template_args['amount_due'].EE_Registry::instance()->CFG->currency->sign;
549 549
 		}
550
-		$this->_template_args['amount_due_class'] =  '';
550
+		$this->_template_args['amount_due_class'] = '';
551 551
 
552
-		if ( $this->_transaction->get('TXN_paid') == $this->_transaction->get('TXN_total') ) {
552
+		if ($this->_transaction->get('TXN_paid') == $this->_transaction->get('TXN_total')) {
553 553
 			// paid in full
554
-			$this->_template_args['amount_due'] =  FALSE;
555
-		} elseif ( $this->_transaction->get('TXN_paid') > $this->_transaction->get('TXN_total') ) {
554
+			$this->_template_args['amount_due'] = FALSE;
555
+		} elseif ($this->_transaction->get('TXN_paid') > $this->_transaction->get('TXN_total')) {
556 556
 			// overpaid
557
-			$this->_template_args['amount_due_class'] =  'txn-overview-no-payment-spn';
558
-		} elseif (( $this->_transaction->get('TXN_total') > 0 ) && ( $this->_transaction->get('TXN_paid') > 0 )) {
557
+			$this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn';
558
+		} elseif (($this->_transaction->get('TXN_total') > 0) && ($this->_transaction->get('TXN_paid') > 0)) {
559 559
 			// monies owing
560
-			$this->_template_args['amount_due_class'] =  'txn-overview-part-payment-spn';
561
-		} elseif (( $this->_transaction->get('TXN_total') > 0 ) && ( $this->_transaction->get('TXN_paid') == 0 )) {
560
+			$this->_template_args['amount_due_class'] = 'txn-overview-part-payment-spn';
561
+		} elseif (($this->_transaction->get('TXN_total') > 0) && ($this->_transaction->get('TXN_paid') == 0)) {
562 562
 			// no payments made yet
563
-			$this->_template_args['amount_due_class'] =  'txn-overview-no-payment-spn';
564
-		} elseif ( $this->_transaction->get('TXN_total') == 0 ) {
563
+			$this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn';
564
+		} elseif ($this->_transaction->get('TXN_total') == 0) {
565 565
 			// free event
566
-			$this->_template_args['amount_due'] =  FALSE;
566
+			$this->_template_args['amount_due'] = FALSE;
567 567
 		}
568 568
 
569 569
 		$payment_method = $this->_transaction->payment_method();
570 570
 
571
-		$this->_template_args['method_of_payment_name'] = $payment_method instanceof EE_Payment_Method ? $payment_method->admin_name() : __( 'Unknown', 'event_espresso' );
571
+		$this->_template_args['method_of_payment_name'] = $payment_method instanceof EE_Payment_Method ? $payment_method->admin_name() : __('Unknown', 'event_espresso');
572 572
 		$this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
573 573
 		// link back to overview
574
-		$this->_template_args['txn_overview_url'] = ! empty ( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] : TXN_ADMIN_URL;
574
+		$this->_template_args['txn_overview_url'] = ! empty ($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : TXN_ADMIN_URL;
575 575
 
576 576
 
577 577
 		//next and previous links
578
-		$next_txn = $this->_transaction->next(null, array( array( 'STS_ID' => array( '!=', EEM_Transaction::failed_status_code ) ) ), 'TXN_ID' );
579
-		$this->_template_args['next_transaction'] = $next_txn ? $this->_next_link( EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'view_transaction', 'TXN_ID' => $next_txn['TXN_ID'] ), TXN_ADMIN_URL ), 'dashicons dashicons-arrow-right ee-icon-size-22' ) : '';
580
-		$previous_txn = $this->_transaction->previous( null, array( array( 'STS_ID' => array( '!=', EEM_Transaction::failed_status_code ) ) ), 'TXN_ID' );
581
-		$this->_template_args['previous_transaction'] = $previous_txn ? $this->_previous_link( EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'view_transaction', 'TXN_ID' => $previous_txn['TXN_ID'] ), TXN_ADMIN_URL ), 'dashicons dashicons-arrow-left ee-icon-size-22' ) : '';
578
+		$next_txn = $this->_transaction->next(null, array(array('STS_ID' => array('!=', EEM_Transaction::failed_status_code))), 'TXN_ID');
579
+		$this->_template_args['next_transaction'] = $next_txn ? $this->_next_link(EE_Admin_Page::add_query_args_and_nonce(array('action' => 'view_transaction', 'TXN_ID' => $next_txn['TXN_ID']), TXN_ADMIN_URL), 'dashicons dashicons-arrow-right ee-icon-size-22') : '';
580
+		$previous_txn = $this->_transaction->previous(null, array(array('STS_ID' => array('!=', EEM_Transaction::failed_status_code))), 'TXN_ID');
581
+		$this->_template_args['previous_transaction'] = $previous_txn ? $this->_previous_link(EE_Admin_Page::add_query_args_and_nonce(array('action' => 'view_transaction', 'TXN_ID' => $previous_txn['TXN_ID']), TXN_ADMIN_URL), 'dashicons dashicons-arrow-left ee-icon-size-22') : '';
582 582
 
583 583
 
584 584
 		// grab messages at the last second
585 585
 		$this->_template_args['notices'] = EE_Error::get_notices();
586 586
 		// path to template
587
-		$template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_header.template.php';
588
-		$this->_template_args['admin_page_header'] = EEH_Template::display_template( $template_path, $this->_template_args, TRUE );
587
+		$template_path = TXN_TEMPLATE_PATH.'txn_admin_details_header.template.php';
588
+		$this->_template_args['admin_page_header'] = EEH_Template::display_template($template_path, $this->_template_args, TRUE);
589 589
 
590 590
 		// the details template wrapper
591 591
 		$this->display_admin_page_with_sidebar();
@@ -604,18 +604,18 @@  discard block
 block discarded – undo
604 604
 
605 605
 		$this->_set_transaction_object();
606 606
 
607
-		add_meta_box( 'edit-txn-details-mbox', __( 'Transaction Details', 'event_espresso' ), array( $this, 'txn_details_meta_box' ), $this->_wp_page_slug, 'normal', 'high' );
607
+		add_meta_box('edit-txn-details-mbox', __('Transaction Details', 'event_espresso'), array($this, 'txn_details_meta_box'), $this->_wp_page_slug, 'normal', 'high');
608 608
 		add_meta_box(
609 609
 			'edit-txn-attendees-mbox',
610
-			__( 'Attendees Registered in this Transaction', 'event_espresso' ),
611
-			array( $this, 'txn_attendees_meta_box' ),
610
+			__('Attendees Registered in this Transaction', 'event_espresso'),
611
+			array($this, 'txn_attendees_meta_box'),
612 612
 			$this->_wp_page_slug,
613 613
 			'normal',
614 614
 			'high',
615
-			array( 'TXN_ID' => $this->_transaction->ID() )
615
+			array('TXN_ID' => $this->_transaction->ID())
616 616
 		);
617
-		add_meta_box( 'edit-txn-registrant-mbox', __( 'Primary Contact', 'event_espresso' ), array( $this, 'txn_registrant_side_meta_box' ), $this->_wp_page_slug, 'side', 'high' );
618
-		add_meta_box( 'edit-txn-billing-info-mbox', __( 'Billing Information', 'event_espresso' ), array( $this, 'txn_billing_info_side_meta_box' ), $this->_wp_page_slug, 'side', 'high' );
617
+		add_meta_box('edit-txn-registrant-mbox', __('Primary Contact', 'event_espresso'), array($this, 'txn_registrant_side_meta_box'), $this->_wp_page_slug, 'side', 'high');
618
+		add_meta_box('edit-txn-billing-info-mbox', __('Billing Information', 'event_espresso'), array($this, 'txn_billing_info_side_meta_box'), $this->_wp_page_slug, 'side', 'high');
619 619
 
620 620
 	}
621 621
 
@@ -636,15 +636,15 @@  discard block
 block discarded – undo
636 636
 
637 637
 		//get line table
638 638
 		EEH_Autoloader::register_line_item_display_autoloaders();
639
-		$Line_Item_Display = new EE_Line_Item_Display( 'admin_table', 'EE_Admin_Table_Line_Item_Display_Strategy' );
640
-		$this->_template_args['line_item_table'] = $Line_Item_Display->display_line_item( $this->_transaction->total_line_item() );
639
+		$Line_Item_Display = new EE_Line_Item_Display('admin_table', 'EE_Admin_Table_Line_Item_Display_Strategy');
640
+		$this->_template_args['line_item_table'] = $Line_Item_Display->display_line_item($this->_transaction->total_line_item());
641 641
 		$this->_template_args['REG_code'] = $this->_transaction->get_first_related('Registration')->get('REG_code');
642 642
 
643 643
 		// process taxes
644
-		$taxes = $this->_transaction->get_many_related( 'Line_Item', array( array( 'LIN_type' => EEM_Line_Item::type_tax )));
645
-		$this->_template_args['taxes'] = ! empty( $taxes ) ? $taxes : FALSE;
644
+		$taxes = $this->_transaction->get_many_related('Line_Item', array(array('LIN_type' => EEM_Line_Item::type_tax)));
645
+		$this->_template_args['taxes'] = ! empty($taxes) ? $taxes : FALSE;
646 646
 
647
-		$this->_template_args['grand_total'] = EEH_Template::format_currency($this->_transaction->get('TXN_total'), FALSE, FALSE );
647
+		$this->_template_args['grand_total'] = EEH_Template::format_currency($this->_transaction->get('TXN_total'), FALSE, FALSE);
648 648
 		$this->_template_args['grand_raw_total'] = $this->_transaction->get('TXN_total');
649 649
 		$this->_template_args['TXN_status'] = $this->_transaction->get('STS_ID');
650 650
 
@@ -652,63 +652,63 @@  discard block
 block discarded – undo
652 652
 
653 653
 		// process payment details
654 654
 		$payments = $this->_transaction->get_many_related('Payment');
655
-		if( ! empty(  $payments ) ) {
656
-			$this->_template_args[ 'payments' ] = $payments;
657
-			$this->_template_args[ 'existing_reg_payments' ] = $this->_get_registration_payment_IDs( $payments );
655
+		if ( ! empty($payments)) {
656
+			$this->_template_args['payments'] = $payments;
657
+			$this->_template_args['existing_reg_payments'] = $this->_get_registration_payment_IDs($payments);
658 658
 		} else {
659
-			$this->_template_args[ 'payments' ] = false;
660
-			$this->_template_args[ 'existing_reg_payments' ] = array();
659
+			$this->_template_args['payments'] = false;
660
+			$this->_template_args['existing_reg_payments'] = array();
661 661
 		}
662 662
 
663
-		$this->_template_args['edit_payment_url'] = add_query_arg( array( 'action' => 'edit_payment'  ), TXN_ADMIN_URL );
664
-		$this->_template_args['delete_payment_url'] = add_query_arg( array( 'action' => 'espresso_delete_payment' ), TXN_ADMIN_URL );
663
+		$this->_template_args['edit_payment_url'] = add_query_arg(array('action' => 'edit_payment'), TXN_ADMIN_URL);
664
+		$this->_template_args['delete_payment_url'] = add_query_arg(array('action' => 'espresso_delete_payment'), TXN_ADMIN_URL);
665 665
 
666
-		if ( isset( $txn_details['invoice_number'] )) {
666
+		if (isset($txn_details['invoice_number'])) {
667 667
 			$this->_template_args['txn_details']['invoice_number']['value'] = $this->_template_args['REG_code'];
668
-			$this->_template_args['txn_details']['invoice_number']['label'] = __( 'Invoice Number', 'event_espresso' );
668
+			$this->_template_args['txn_details']['invoice_number']['label'] = __('Invoice Number', 'event_espresso');
669 669
 		}
670 670
 
671 671
 		$this->_template_args['txn_details']['registration_session']['value'] = $this->_transaction->get_first_related('Registration')->get('REG_session');
672
-		$this->_template_args['txn_details']['registration_session']['label'] = __( 'Registration Session', 'event_espresso' );
672
+		$this->_template_args['txn_details']['registration_session']['label'] = __('Registration Session', 'event_espresso');
673 673
 
674
-		$this->_template_args['txn_details']['ip_address']['value'] = isset( $this->_session['ip_address'] ) ? $this->_session['ip_address'] : '';
675
-		$this->_template_args['txn_details']['ip_address']['label'] = __( 'Transaction placed from IP', 'event_espresso' );
674
+		$this->_template_args['txn_details']['ip_address']['value'] = isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '';
675
+		$this->_template_args['txn_details']['ip_address']['label'] = __('Transaction placed from IP', 'event_espresso');
676 676
 
677
-		$this->_template_args['txn_details']['user_agent']['value'] = isset( $this->_session['user_agent'] ) ? $this->_session['user_agent'] : '';
678
-		$this->_template_args['txn_details']['user_agent']['label'] = __( 'Registrant User Agent', 'event_espresso' );
677
+		$this->_template_args['txn_details']['user_agent']['value'] = isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '';
678
+		$this->_template_args['txn_details']['user_agent']['label'] = __('Registrant User Agent', 'event_espresso');
679 679
 
680 680
 		$reg_steps = '<ul>';
681
-		foreach ( $this->_transaction->reg_steps() as $reg_step => $reg_step_status ) {
682
-			if ( $reg_step_status === true ) {
683
-				$reg_steps .= '<li style="color:#70cc50">' . sprintf( __( '%1$s : Completed', 'event_espresso' ), ucwords( str_replace( '_', ' ', $reg_step ) ) ) . '</li>';
684
-			} else if ( is_numeric( $reg_step_status ) && $reg_step_status !== false ) {
685
-					$reg_steps .= '<li style="color:#2EA2CC">' . sprintf(
686
-							__( '%1$s : Initiated %2$s', 'event_espresso' ),
687
-							ucwords( str_replace( '_', ' ', $reg_step ) ),
688
-							gmdate( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), ( $reg_step_status + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) ) )
689
-						) . '</li>';
681
+		foreach ($this->_transaction->reg_steps() as $reg_step => $reg_step_status) {
682
+			if ($reg_step_status === true) {
683
+				$reg_steps .= '<li style="color:#70cc50">'.sprintf(__('%1$s : Completed', 'event_espresso'), ucwords(str_replace('_', ' ', $reg_step))).'</li>';
684
+			} else if (is_numeric($reg_step_status) && $reg_step_status !== false) {
685
+					$reg_steps .= '<li style="color:#2EA2CC">'.sprintf(
686
+							__('%1$s : Initiated %2$s', 'event_espresso'),
687
+							ucwords(str_replace('_', ' ', $reg_step)),
688
+							gmdate(get_option('date_format').' '.get_option('time_format'), ($reg_step_status + (get_option('gmt_offset') * HOUR_IN_SECONDS)))
689
+						).'</li>';
690 690
 				} else {
691
-				$reg_steps .= '<li style="color:#E76700">' . sprintf( __( '%1$s : Never Initiated', 'event_espresso' ), ucwords( str_replace( '_', ' ', $reg_step ) ) ) . '</li>';
691
+				$reg_steps .= '<li style="color:#E76700">'.sprintf(__('%1$s : Never Initiated', 'event_espresso'), ucwords(str_replace('_', ' ', $reg_step))).'</li>';
692 692
 			}
693 693
 		}
694 694
 		$reg_steps .= '</ul>';
695 695
 		$this->_template_args['txn_details']['reg_steps']['value'] = $reg_steps;
696
-		$this->_template_args['txn_details']['reg_steps']['label'] = __( 'Registration Step Progress', 'event_espresso' );
696
+		$this->_template_args['txn_details']['reg_steps']['label'] = __('Registration Step Progress', 'event_espresso');
697 697
 
698 698
 
699 699
 		$this->_get_registrations_to_apply_payment_to();
700
-		$this->_get_payment_methods( $payments );
700
+		$this->_get_payment_methods($payments);
701 701
 		$this->_get_payment_status_array();
702 702
 		$this->_get_reg_status_selection(); //sets up the template args for the reg status array for the transaction.
703 703
 
704
-		$this->_template_args['transaction_form_url'] = add_query_arg( array( 'action' => 'edit_transaction', 'process' => 'transaction'  ), TXN_ADMIN_URL );
705
-		$this->_template_args['apply_payment_form_url'] = add_query_arg( array( 'page' => 'espresso_transactions', 'action' => 'espresso_apply_payment' ), WP_AJAX_URL );
706
-		$this->_template_args['delete_payment_form_url'] = add_query_arg( array( 'page' => 'espresso_transactions', 'action' => 'espresso_delete_payment' ), WP_AJAX_URL );
704
+		$this->_template_args['transaction_form_url'] = add_query_arg(array('action' => 'edit_transaction', 'process' => 'transaction'), TXN_ADMIN_URL);
705
+		$this->_template_args['apply_payment_form_url'] = add_query_arg(array('page' => 'espresso_transactions', 'action' => 'espresso_apply_payment'), WP_AJAX_URL);
706
+		$this->_template_args['delete_payment_form_url'] = add_query_arg(array('page' => 'espresso_transactions', 'action' => 'espresso_delete_payment'), WP_AJAX_URL);
707 707
 
708 708
 		// 'espresso_delete_payment_nonce'
709 709
 
710
-		$template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_txn_details.template.php';
711
-		echo EEH_Template::display_template( $template_path, $this->_template_args, TRUE );
710
+		$template_path = TXN_TEMPLATE_PATH.'txn_admin_details_main_meta_box_txn_details.template.php';
711
+		echo EEH_Template::display_template($template_path, $this->_template_args, TRUE);
712 712
 
713 713
 	}
714 714
 
@@ -723,27 +723,27 @@  discard block
 block discarded – undo
723 723
 	 * @param EE_Payment[] $payments
724 724
 	 * @return array
725 725
 	 */
726
-	protected function _get_registration_payment_IDs( $payments = array() ) {
726
+	protected function _get_registration_payment_IDs($payments = array()) {
727 727
 		$existing_reg_payments = array();
728 728
 		// get all reg payments for these payments
729
-		$reg_payments = EEM_Registration_Payment::instance()->get_all( array(
729
+		$reg_payments = EEM_Registration_Payment::instance()->get_all(array(
730 730
 			array(
731 731
 				'PAY_ID' => array(
732 732
 					'IN',
733
-					array_keys( $payments )
733
+					array_keys($payments)
734 734
 				)
735 735
 			)
736
-		) );
737
-		if ( ! empty( $reg_payments ) ) {
738
-			foreach ( $payments as $payment ) {
739
-				if ( ! $payment instanceof EE_Payment ) {
736
+		));
737
+		if ( ! empty($reg_payments)) {
738
+			foreach ($payments as $payment) {
739
+				if ( ! $payment instanceof EE_Payment) {
740 740
 					continue;
741
-				} else if ( ! isset( $existing_reg_payments[ $payment->ID() ] ) ) {
742
-					$existing_reg_payments[ $payment->ID() ] = array();
741
+				} else if ( ! isset($existing_reg_payments[$payment->ID()])) {
742
+					$existing_reg_payments[$payment->ID()] = array();
743 743
 				}
744
-				foreach ( $reg_payments as $reg_payment ) {
745
-					if ( $reg_payment instanceof EE_Registration_Payment && $reg_payment->payment_ID() === $payment->ID() ) {
746
-						$existing_reg_payments[ $payment->ID() ][ ] = $reg_payment->registration_ID();
744
+				foreach ($reg_payments as $reg_payment) {
745
+					if ($reg_payment instanceof EE_Registration_Payment && $reg_payment->payment_ID() === $payment->ID()) {
746
+						$existing_reg_payments[$payment->ID()][] = $reg_payment->registration_ID();
747 747
 					}
748 748
 				}
749 749
 			}
@@ -780,39 +780,39 @@  discard block
 block discarded – undo
780 780
 		$registrations_to_apply_payment_to .= '<br /><div class="admin-primary-mbox-tbl-wrap">';
781 781
 		$registrations_to_apply_payment_to .= '<table class="admin-primary-mbox-tbl">';
782 782
 		$registrations_to_apply_payment_to .= '<thead><tr>';
783
-		$registrations_to_apply_payment_to .= '<td>' . __( 'ID', 'event_espresso' ) . '</td>';
784
-		$registrations_to_apply_payment_to .= '<td>' . __( 'Registrant', 'event_espresso' ) . '</td>';
785
-		$registrations_to_apply_payment_to .= '<td>' . __( 'Ticket', 'event_espresso' ) . '</td>';
786
-		$registrations_to_apply_payment_to .= '<td>' . __( 'Event', 'event_espresso' ) . '</td>';
787
-		$registrations_to_apply_payment_to .= '<td class="txn-admin-payment-paid-td jst-cntr">' . __( 'Paid', 'event_espresso' ) . '</td>';
788
-		$registrations_to_apply_payment_to .= '<td class="txn-admin-payment-owing-td jst-cntr">' . __( 'Owing', 'event_espresso' ) . '</td>';
789
-		$registrations_to_apply_payment_to .= '<td class="jst-cntr">' . __( 'Apply', 'event_espresso' ) . '</td>';
783
+		$registrations_to_apply_payment_to .= '<td>'.__('ID', 'event_espresso').'</td>';
784
+		$registrations_to_apply_payment_to .= '<td>'.__('Registrant', 'event_espresso').'</td>';
785
+		$registrations_to_apply_payment_to .= '<td>'.__('Ticket', 'event_espresso').'</td>';
786
+		$registrations_to_apply_payment_to .= '<td>'.__('Event', 'event_espresso').'</td>';
787
+		$registrations_to_apply_payment_to .= '<td class="txn-admin-payment-paid-td jst-cntr">'.__('Paid', 'event_espresso').'</td>';
788
+		$registrations_to_apply_payment_to .= '<td class="txn-admin-payment-owing-td jst-cntr">'.__('Owing', 'event_espresso').'</td>';
789
+		$registrations_to_apply_payment_to .= '<td class="jst-cntr">'.__('Apply', 'event_espresso').'</td>';
790 790
 		$registrations_to_apply_payment_to .= '</tr></thead><tbody>';
791 791
 		// get registrations for TXN
792
-		$registrations = $this->_transaction->registrations( $query_params );
793
-		foreach ( $registrations as $registration ) {
794
-			if ( $registration instanceof EE_Registration ) {
792
+		$registrations = $this->_transaction->registrations($query_params);
793
+		foreach ($registrations as $registration) {
794
+			if ($registration instanceof EE_Registration) {
795 795
 				$owing = $registration->final_price() - $registration->paid();
796
-				$taxable = $registration->ticket()->taxable() ? ' <span class="smaller-text lt-grey-text"> ' . __( '+ tax', 'event_espresso' ) . '</span>' : '';
797
-				$checked = empty( $existing_reg_payments ) || in_array( $registration->ID(), $existing_reg_payments ) ? ' checked="checked"' : '';
798
-				$registrations_to_apply_payment_to .= '<tr id="apply-payment-registration-row-' . $registration->ID() . '">';
796
+				$taxable = $registration->ticket()->taxable() ? ' <span class="smaller-text lt-grey-text"> '.__('+ tax', 'event_espresso').'</span>' : '';
797
+				$checked = empty($existing_reg_payments) || in_array($registration->ID(), $existing_reg_payments) ? ' checked="checked"' : '';
798
+				$registrations_to_apply_payment_to .= '<tr id="apply-payment-registration-row-'.$registration->ID().'">';
799 799
 				// add html for checkbox input and label
800
-				$registrations_to_apply_payment_to .= '<td>' . $registration->ID() . '</td>';
801
-				$registrations_to_apply_payment_to .= '<td>' . $registration->attendee() instanceof EE_Attendee ? $registration->attendee()->full_name() : __( 'Unknown Attendee', 'event_espresso' ) . '</td>';
802
-				$registrations_to_apply_payment_to .= '<td>' . $registration->ticket()->name() . ' : ' . $registration->ticket()->pretty_price() . $taxable . '</td>';
803
-				$registrations_to_apply_payment_to .= '<td>' . $registration->event_name() . '</td>';
804
-				$registrations_to_apply_payment_to .= '<td class="txn-admin-payment-paid-td jst-rght">' . $registration->pretty_paid() . '</td>';
805
-				$registrations_to_apply_payment_to .= '<td class="txn-admin-payment-owing-td jst-rght">' . EEH_Template::format_currency( $owing ) . '</td>';
800
+				$registrations_to_apply_payment_to .= '<td>'.$registration->ID().'</td>';
801
+				$registrations_to_apply_payment_to .= '<td>'.$registration->attendee() instanceof EE_Attendee ? $registration->attendee()->full_name() : __('Unknown Attendee', 'event_espresso').'</td>';
802
+				$registrations_to_apply_payment_to .= '<td>'.$registration->ticket()->name().' : '.$registration->ticket()->pretty_price().$taxable.'</td>';
803
+				$registrations_to_apply_payment_to .= '<td>'.$registration->event_name().'</td>';
804
+				$registrations_to_apply_payment_to .= '<td class="txn-admin-payment-paid-td jst-rght">'.$registration->pretty_paid().'</td>';
805
+				$registrations_to_apply_payment_to .= '<td class="txn-admin-payment-owing-td jst-rght">'.EEH_Template::format_currency($owing).'</td>';
806 806
 				$registrations_to_apply_payment_to .= '<td class="jst-cntr">';
807 807
 				$disabled = $registration->final_price() > 0 ? '' : ' disabled';
808
-				$registrations_to_apply_payment_to .= '<input type="checkbox" value="' . $registration->ID() . '" name="txn_admin_payment[registrations]"' . $checked . $disabled . '>';
808
+				$registrations_to_apply_payment_to .= '<input type="checkbox" value="'.$registration->ID().'" name="txn_admin_payment[registrations]"'.$checked.$disabled.'>';
809 809
 				$registrations_to_apply_payment_to .= '</td>';
810 810
 				$registrations_to_apply_payment_to .= '</tr>';
811 811
 			}
812 812
 		}
813 813
 		$registrations_to_apply_payment_to .= '</tbody></table></div>';
814
-		$registrations_to_apply_payment_to .= '<p class="clear description">' . __( 'The payment will only be applied to the registrations that have a check mark in their corresponding check box. Checkboxes for free registrations have been disabled.', 'event_espresso' ) . '</p></div>';
815
-		$this->_template_args[ 'registrations_to_apply_payment_to' ] = $registrations_to_apply_payment_to;
814
+		$registrations_to_apply_payment_to .= '<p class="clear description">'.__('The payment will only be applied to the registrations that have a check mark in their corresponding check box. Checkboxes for free registrations have been disabled.', 'event_espresso').'</p></div>';
815
+		$this->_template_args['registrations_to_apply_payment_to'] = $registrations_to_apply_payment_to;
816 816
 	}
817 817
 
818 818
 
@@ -829,9 +829,9 @@  discard block
 block discarded – undo
829 829
 		$statuses = EEM_Registration::reg_status_array(array(), TRUE);
830 830
 		//let's add a "don't change" option.
831 831
 		$status_array['NAN'] = __('Leave the Same', 'event_espresso');
832
-		$status_array = array_merge( $status_array, $statuses );
833
-		$this->_template_args['status_change_select'] = EEH_Form_Fields::select_input( 'txn_reg_status_change[reg_status]', $status_array, 'NAN', 'id="txn-admin-payment-reg-status-inp"', 'txn-reg-status-change-reg-status' );
834
-		$this->_template_args['delete_status_change_select'] = EEH_Form_Fields::select_input( 'delete_txn_reg_status_change[reg_status]', $status_array, 'NAN', 'delete-txn-admin-payment-reg-status-inp', 'delete-txn-reg-status-change-reg-status' );
832
+		$status_array = array_merge($status_array, $statuses);
833
+		$this->_template_args['status_change_select'] = EEH_Form_Fields::select_input('txn_reg_status_change[reg_status]', $status_array, 'NAN', 'id="txn-admin-payment-reg-status-inp"', 'txn-reg-status-change-reg-status');
834
+		$this->_template_args['delete_status_change_select'] = EEH_Form_Fields::select_input('delete_txn_reg_status_change[reg_status]', $status_array, 'NAN', 'delete-txn-admin-payment-reg-status-inp', 'delete-txn-reg-status-change-reg-status');
835 835
 
836 836
 	}
837 837
 
@@ -846,21 +846,21 @@  discard block
 block discarded – undo
846 846
 	 * @param EE_Payment[] to show on this page
847 847
 	 *	@return void
848 848
 	 */
849
-	private function _get_payment_methods( $payments = array() ) {
849
+	private function _get_payment_methods($payments = array()) {
850 850
 		$payment_methods_of_payments = array();
851
-		foreach( $payments as $payment ){
852
-			if( $payment instanceof EE_Payment ){
853
-				$payment_methods_of_payments[] = $payment->get( 'PMD_ID' );
851
+		foreach ($payments as $payment) {
852
+			if ($payment instanceof EE_Payment) {
853
+				$payment_methods_of_payments[] = $payment->get('PMD_ID');
854 854
 			}
855 855
 		}
856
-		if( $payment_methods_of_payments ){
857
-			$query_args = array( array( 'OR*payment_method_for_payment' => array(
858
-					'PMD_ID' => array( 'IN', $payment_methods_of_payments ),
859
-					'PMD_scope' => array( 'LIKE', '%' . EEM_Payment_Method::scope_admin . '%' ) ) ) );
860
-		}else{
861
-			$query_args = array( array( 'PMD_scope' => array( 'LIKE', '%' . EEM_Payment_Method::scope_admin . '%' ) ) );
856
+		if ($payment_methods_of_payments) {
857
+			$query_args = array(array('OR*payment_method_for_payment' => array(
858
+					'PMD_ID' => array('IN', $payment_methods_of_payments),
859
+					'PMD_scope' => array('LIKE', '%'.EEM_Payment_Method::scope_admin.'%') )));
860
+		} else {
861
+			$query_args = array(array('PMD_scope' => array('LIKE', '%'.EEM_Payment_Method::scope_admin.'%')));
862 862
 		}
863
-		$this->_template_args['payment_methods'] = EEM_Payment_Method::instance()->get_all( $query_args );
863
+		$this->_template_args['payment_methods'] = EEM_Payment_Method::instance()->get_all($query_args);
864 864
 	}
865 865
 
866 866
 
@@ -874,46 +874,46 @@  discard block
 block discarded – undo
874 874
 	 * @param array $metabox
875 875
 	 * @return void
876 876
 	 */
877
-	public function txn_attendees_meta_box( $post, $metabox = array( 'args' => array() )) {
877
+	public function txn_attendees_meta_box($post, $metabox = array('args' => array())) {
878 878
 
879
-		extract( $metabox['args'] );
879
+		extract($metabox['args']);
880 880
 		$this->_template_args['post'] = $post;
881 881
 		$this->_template_args['event_attendees'] = array();
882 882
 		// process items in cart
883
-		$line_items = $this->_transaction->get_many_related('Line_Item', array( array( 'LIN_type' => 'line-item' ) ) );
884
-		if ( ! empty( $line_items )) {
885
-			foreach ( $line_items as $item ) {
886
-				if ( $item instanceof EE_Line_Item ) {
887
-					switch( $item->OBJ_type() ) {
883
+		$line_items = $this->_transaction->get_many_related('Line_Item', array(array('LIN_type' => 'line-item')));
884
+		if ( ! empty($line_items)) {
885
+			foreach ($line_items as $item) {
886
+				if ($item instanceof EE_Line_Item) {
887
+					switch ($item->OBJ_type()) {
888 888
 
889 889
 						case 'Event' :
890 890
 							break;
891 891
 
892 892
 						case 'Ticket' :
893 893
 							$ticket = $item->ticket();
894
-							if ( empty( $ticket )) {
894
+							if (empty($ticket)) {
895 895
 								continue; //right now we're only handling tickets here.  Cause its expected that only tickets will have attendees right?
896 896
 							}
897
-							$ticket_price = EEH_Template::format_currency( $item->get( 'LIN_unit_price' ));
897
+							$ticket_price = EEH_Template::format_currency($item->get('LIN_unit_price'));
898 898
 							$event = $ticket->get_first_related('Registration')->get_first_related('Event');
899
-							$event_name = $event instanceof EE_Event ? $event->get('EVT_name') . ' - ' . $item->get('LIN_name') : '';
899
+							$event_name = $event instanceof EE_Event ? $event->get('EVT_name').' - '.$item->get('LIN_name') : '';
900 900
 
901
-							$registrations = $ticket->get_many_related('Registration', array( array('TXN_ID' => $this->_transaction->ID() )));
902
-							foreach( $registrations as $registration ) {
903
-								$this->_template_args['event_attendees'][$registration->ID()]['att_num'] 						= $registration->get('REG_count');
904
-								$this->_template_args['event_attendees'][$registration->ID()]['event_ticket_name'] 	= $event_name;
905
-								$this->_template_args['event_attendees'][$registration->ID()]['ticket_price'] 				= $ticket_price;
901
+							$registrations = $ticket->get_many_related('Registration', array(array('TXN_ID' => $this->_transaction->ID())));
902
+							foreach ($registrations as $registration) {
903
+								$this->_template_args['event_attendees'][$registration->ID()]['att_num'] = $registration->get('REG_count');
904
+								$this->_template_args['event_attendees'][$registration->ID()]['event_ticket_name'] = $event_name;
905
+								$this->_template_args['event_attendees'][$registration->ID()]['ticket_price'] = $ticket_price;
906 906
 								// attendee info
907 907
 								$attendee = $registration->get_first_related('Attendee');
908
-								if ( $attendee instanceof EE_Attendee ) {
908
+								if ($attendee instanceof EE_Attendee) {
909 909
 									$this->_template_args['event_attendees'][$registration->ID()]['att_id'] 			= $attendee->ID();
910 910
 									$this->_template_args['event_attendees'][$registration->ID()]['attendee'] 	= $attendee->full_name();
911
-									$this->_template_args['event_attendees'][$registration->ID()]['email'] 			= '<a href="mailto:' . $attendee->email() . '?subject=' . $event->get('EVT_name') . __(' Event', 'event_espresso') . '">' . $attendee->email() . '</a>';
912
-									$this->_template_args['event_attendees'][$registration->ID()]['address'] 		=  implode(',<br>', $attendee->full_address_as_array() );
911
+									$this->_template_args['event_attendees'][$registration->ID()]['email'] = '<a href="mailto:'.$attendee->email().'?subject='.$event->get('EVT_name').__(' Event', 'event_espresso').'">'.$attendee->email().'</a>';
912
+									$this->_template_args['event_attendees'][$registration->ID()]['address'] 		= implode(',<br>', $attendee->full_address_as_array());
913 913
 								} else {
914 914
 									$this->_template_args['event_attendees'][$registration->ID()]['att_id'] 			= '';
915 915
 									$this->_template_args['event_attendees'][$registration->ID()]['attendee'] 	= '';
916
-									$this->_template_args['event_attendees'][$registration->ID()]['email'] 			= '';
916
+									$this->_template_args['event_attendees'][$registration->ID()]['email'] = '';
917 917
 									$this->_template_args['event_attendees'][$registration->ID()]['address'] 		= '';
918 918
 								}
919 919
 							}
@@ -923,12 +923,12 @@  discard block
 block discarded – undo
923 923
 				}
924 924
 			}
925 925
 
926
-			$this->_template_args['transaction_form_url'] = add_query_arg( array( 'action' => 'edit_transaction', 'process' => 'attendees'  ), TXN_ADMIN_URL );
927
-			echo EEH_Template::display_template( TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_attendees.template.php', $this->_template_args, TRUE );
926
+			$this->_template_args['transaction_form_url'] = add_query_arg(array('action' => 'edit_transaction', 'process' => 'attendees'), TXN_ADMIN_URL);
927
+			echo EEH_Template::display_template(TXN_TEMPLATE_PATH.'txn_admin_details_main_meta_box_attendees.template.php', $this->_template_args, TRUE);
928 928
 
929 929
 		} else {
930 930
 			echo sprintf(
931
-				__( '%1$sFor some reason, there are no attendees registered for this transaction. Likely the registration was abandoned in process.%2$s', 'event_espresso' ),
931
+				__('%1$sFor some reason, there are no attendees registered for this transaction. Likely the registration was abandoned in process.%2$s', 'event_espresso'),
932 932
 				'<p class="important-notice">',
933 933
 				'</p>'
934 934
 			);
@@ -947,20 +947,20 @@  discard block
 block discarded – undo
947 947
 	 */
948 948
 	public function txn_registrant_side_meta_box() {
949 949
 		$primary_att = $this->_transaction->primary_registration() instanceof EE_Registration ? $this->_transaction->primary_registration()->get_first_related('Attendee') : null;
950
-		if ( ! $primary_att instanceof EE_Attendee ) {
950
+		if ( ! $primary_att instanceof EE_Attendee) {
951 951
 			$this->_template_args['no_attendee_message'] = __('There is no attached contact for this transaction.  The transaction either failed due to an error or was abandoned.', 'event_espresso');
952 952
 			$primary_att = EEM_Attendee::instance()->create_default_object();
953 953
 		}
954
-		$this->_template_args['ATT_ID'] 						= $primary_att->ID();
954
+		$this->_template_args['ATT_ID'] = $primary_att->ID();
955 955
 		$this->_template_args['prime_reg_fname']		= $primary_att->fname();
956 956
 		$this->_template_args['prime_reg_lname']		= $primary_att->lname();
957
-		$this->_template_args['prime_reg_email'] 		= $primary_att->email();
957
+		$this->_template_args['prime_reg_email'] = $primary_att->email();
958 958
 		$this->_template_args['prime_reg_phone'] 	= $primary_att->phone();
959
-		$this->_template_args['edit_attendee_url'] 	= EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'edit_attendee', 'post' => $primary_att->ID()  ), REG_ADMIN_URL );
959
+		$this->_template_args['edit_attendee_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit_attendee', 'post' => $primary_att->ID()), REG_ADMIN_URL);
960 960
 		// get formatted address for registrant
961
-		EE_Registry::instance()->load_helper( 'Formatter' );
962
-		$this->_template_args[ 'formatted_address' ] = EEH_Address::format( $primary_att );
963
-		echo EEH_Template::display_template( TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_registrant.template.php', $this->_template_args, TRUE );
961
+		EE_Registry::instance()->load_helper('Formatter');
962
+		$this->_template_args['formatted_address'] = EEH_Address::format($primary_att);
963
+		echo EEH_Template::display_template(TXN_TEMPLATE_PATH.'txn_admin_details_side_meta_box_registrant.template.php', $this->_template_args, TRUE);
964 964
 	}
965 965
 
966 966
 
@@ -976,12 +976,12 @@  discard block
 block discarded – undo
976 976
 
977 977
 		$this->_template_args['billing_form'] = $this->_transaction->billing_info();
978 978
 		$this->_template_args['billing_form_url'] = add_query_arg(
979
-			array( 'action' => 'edit_transaction', 'process' => 'billing'  ),
979
+			array('action' => 'edit_transaction', 'process' => 'billing'),
980 980
 			TXN_ADMIN_URL
981 981
 		);
982 982
 
983
-		$template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_billing_info.template.php';
984
-		echo EEH_Template::display_template( $template_path, $this->_template_args, TRUE );/**/
983
+		$template_path = TXN_TEMPLATE_PATH.'txn_admin_details_side_meta_box_billing_info.template.php';
984
+		echo EEH_Template::display_template($template_path, $this->_template_args, TRUE); /**/
985 985
 	}
986 986
 
987 987
 
@@ -994,43 +994,43 @@  discard block
 block discarded – undo
994 994
 	*	@return void
995 995
 	*/
996 996
 	public function apply_payments_or_refunds() {
997
-		$json_response_data = array( 'return_data' => FALSE );
997
+		$json_response_data = array('return_data' => FALSE);
998 998
 		$valid_data = $this->_validate_payment_request_data();
999
-		if ( ! empty( $valid_data ) ) {
1000
-			$PAY_ID = $valid_data[ 'PAY_ID' ];
999
+		if ( ! empty($valid_data)) {
1000
+			$PAY_ID = $valid_data['PAY_ID'];
1001 1001
 			//save  the new payment
1002
-			$payment = $this->_create_payment_from_request_data( $valid_data );
1002
+			$payment = $this->_create_payment_from_request_data($valid_data);
1003 1003
 			// get the TXN for this payment
1004 1004
 			$transaction = $payment->transaction();
1005 1005
 			// verify transaction
1006
-			if ( $transaction instanceof EE_Transaction ) {
1006
+			if ($transaction instanceof EE_Transaction) {
1007 1007
 				// calculate_total_payments_and_update_status
1008
-				$this->_process_transaction_payments( $transaction );
1009
-				$REG_IDs = $this->_get_REG_IDs_to_apply_payment_to( $payment );
1010
-				$this->_remove_existing_registration_payments( $payment, $PAY_ID );
1008
+				$this->_process_transaction_payments($transaction);
1009
+				$REG_IDs = $this->_get_REG_IDs_to_apply_payment_to($payment);
1010
+				$this->_remove_existing_registration_payments($payment, $PAY_ID);
1011 1011
 				// apply payment to registrations (if applicable)
1012
-				if ( ! empty( $REG_IDs ) ) {
1013
-					$this->_update_registration_payments( $transaction, $payment, $REG_IDs );
1012
+				if ( ! empty($REG_IDs)) {
1013
+					$this->_update_registration_payments($transaction, $payment, $REG_IDs);
1014 1014
 					$this->_maybe_send_notifications();
1015 1015
 					// now process status changes for the same registrations
1016
-					$this->_process_registration_status_change( $transaction, $REG_IDs );
1016
+					$this->_process_registration_status_change($transaction, $REG_IDs);
1017 1017
 				}
1018
-				$this->_maybe_send_notifications( $payment );
1018
+				$this->_maybe_send_notifications($payment);
1019 1019
 				//prepare to render page
1020
-				$json_response_data[ 'return_data' ] = $this->_build_payment_json_response( $payment, $REG_IDs );
1021
-				do_action( 'AHEE__Transactions_Admin_Page__apply_payments_or_refund__after_recording', $transaction, $payment );
1020
+				$json_response_data['return_data'] = $this->_build_payment_json_response($payment, $REG_IDs);
1021
+				do_action('AHEE__Transactions_Admin_Page__apply_payments_or_refund__after_recording', $transaction, $payment);
1022 1022
 			} else {
1023 1023
 				EE_Error::add_error(
1024
-					__( 'A valid Transaction for this payment could not be retrieved.', 'event_espresso' ),
1024
+					__('A valid Transaction for this payment could not be retrieved.', 'event_espresso'),
1025 1025
 					__FILE__, __FUNCTION__, __LINE__
1026 1026
 				);
1027 1027
 			}
1028 1028
 		} else {
1029
-			EE_Error::add_error( __( 'The payment form data could not be processed. Please try again.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
1029
+			EE_Error::add_error(__('The payment form data could not be processed. Please try again.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1030 1030
 		}
1031 1031
 
1032
-		$notices = EE_Error::get_notices( FALSE, FALSE, FALSE );
1033
-		echo json_encode( array_merge( $json_response_data, $notices ));
1032
+		$notices = EE_Error::get_notices(FALSE, FALSE, FALSE);
1033
+		echo json_encode(array_merge($json_response_data, $notices));
1034 1034
 		die();
1035 1035
 	}
1036 1036
 
@@ -1042,30 +1042,30 @@  discard block
 block discarded – undo
1042 1042
 	 * @return array
1043 1043
 	 */
1044 1044
 	protected function _validate_payment_request_data() {
1045
-		if ( ! isset( $this->_req_data[ 'txn_admin_payment' ] ) ) {
1045
+		if ( ! isset($this->_req_data['txn_admin_payment'])) {
1046 1046
 			return false;
1047 1047
 		}
1048 1048
 		$payment_form = $this->_generate_payment_form_section();
1049 1049
 		try {
1050
-			if ( $payment_form->was_submitted() ) {
1050
+			if ($payment_form->was_submitted()) {
1051 1051
 				$payment_form->receive_form_submission();
1052
-				if ( ! $payment_form->is_valid() ) {
1052
+				if ( ! $payment_form->is_valid()) {
1053 1053
 					$submission_error_messages = array();
1054
-					foreach ( $payment_form->get_validation_errors_accumulated() as $validation_error ) {
1055
-						if ( $validation_error instanceof EE_Validation_Error ) {
1054
+					foreach ($payment_form->get_validation_errors_accumulated() as $validation_error) {
1055
+						if ($validation_error instanceof EE_Validation_Error) {
1056 1056
 							$submission_error_messages[] = sprintf(
1057
-								_x( '%s : %s', 'Form Section Name : Form Validation Error', 'event_espresso' ),
1057
+								_x('%s : %s', 'Form Section Name : Form Validation Error', 'event_espresso'),
1058 1058
 								$validation_error->get_form_section()->html_label_text(),
1059 1059
 								$validation_error->getMessage()
1060 1060
 							);
1061 1061
 						}
1062 1062
 					}
1063
-					EE_Error::add_error( join( '<br />', $submission_error_messages ), __FILE__, __FUNCTION__, __LINE__ );
1063
+					EE_Error::add_error(join('<br />', $submission_error_messages), __FILE__, __FUNCTION__, __LINE__);
1064 1064
 					return array();
1065 1065
 				}
1066 1066
 			}
1067
-		} catch ( EE_Error $e ) {
1068
-			EE_Error::add_error( $e->getMessage(), __FILE__, __FUNCTION__, __LINE__ );
1067
+		} catch (EE_Error $e) {
1068
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
1069 1069
 			return array();
1070 1070
 		}
1071 1071
 		return $payment_form->valid_data();
@@ -1087,63 +1087,63 @@  discard block
 block discarded – undo
1087 1087
 						array(
1088 1088
 							'default' => 0,
1089 1089
 							'required' => false,
1090
-							'html_label_text' => __( 'Payment ID', 'event_espresso' ),
1091
-							'validation_strategies' => array( new EE_Int_Normalization() )
1090
+							'html_label_text' => __('Payment ID', 'event_espresso'),
1091
+							'validation_strategies' => array(new EE_Int_Normalization())
1092 1092
 						)
1093 1093
 					),
1094 1094
 					'TXN_ID' => new EE_Text_Input(
1095 1095
 						array(
1096 1096
 							'default' => 0,
1097 1097
 							'required' => true,
1098
-							'html_label_text' => __( 'Transaction ID', 'event_espresso' ),
1099
-							'validation_strategies' => array( new EE_Int_Normalization() )
1098
+							'html_label_text' => __('Transaction ID', 'event_espresso'),
1099
+							'validation_strategies' => array(new EE_Int_Normalization())
1100 1100
 						)
1101 1101
 					),
1102 1102
 					'type' => new EE_Text_Input(
1103 1103
 						array(
1104 1104
 							'default' => 1,
1105 1105
 							'required' => true,
1106
-							'html_label_text' => __( 'Payment or Refund', 'event_espresso' ),
1107
-							'validation_strategies' => array( new EE_Int_Normalization() )
1106
+							'html_label_text' => __('Payment or Refund', 'event_espresso'),
1107
+							'validation_strategies' => array(new EE_Int_Normalization())
1108 1108
 						)
1109 1109
 					),
1110 1110
 					'amount' => new EE_Text_Input(
1111 1111
 						array(
1112 1112
 							'default' => 0,
1113 1113
 							'required' => true,
1114
-							'html_label_text' => __( 'Payment amount', 'event_espresso' ),
1115
-							'validation_strategies' => array( new EE_Float_Normalization() )
1114
+							'html_label_text' => __('Payment amount', 'event_espresso'),
1115
+							'validation_strategies' => array(new EE_Float_Normalization())
1116 1116
 						)
1117 1117
 					),
1118 1118
 					'status' => new EE_Text_Input(
1119 1119
 						array(
1120 1120
 							'default' => EEM_Payment::status_id_approved,
1121 1121
 							'required' => true,
1122
-							'html_label_text' => __( 'Payment status', 'event_espresso' ),
1122
+							'html_label_text' => __('Payment status', 'event_espresso'),
1123 1123
 						)
1124 1124
 					),
1125 1125
 					'PMD_ID' => new EE_Text_Input(
1126 1126
 						array(
1127 1127
 							'default' => 2,
1128 1128
 							'required' => true,
1129
-							'html_label_text' => __( 'Payment Method', 'event_espresso' ),
1130
-							'validation_strategies' => array( new EE_Int_Normalization() )
1129
+							'html_label_text' => __('Payment Method', 'event_espresso'),
1130
+							'validation_strategies' => array(new EE_Int_Normalization())
1131 1131
 						)
1132 1132
 					),
1133 1133
 					'date' => new EE_Text_Input(
1134 1134
 						array(
1135 1135
 							'default' => time(),
1136 1136
 							'required' => true,
1137
-							'html_label_text' => __( 'Payment date', 'event_espresso' ),
1137
+							'html_label_text' => __('Payment date', 'event_espresso'),
1138 1138
 						)
1139 1139
 					),
1140 1140
 					'txn_id_chq_nmbr' => new EE_Text_Input(
1141 1141
 						array(
1142 1142
 							'default' => '',
1143 1143
 							'required' => false,
1144
-							'html_label_text' => __( 'Transaction or Cheque Number', 'event_espresso' ),
1144
+							'html_label_text' => __('Transaction or Cheque Number', 'event_espresso'),
1145 1145
                                                         'validation_strategies' => array(
1146
-                                                            new EE_Max_Length_Validation_Strategy( __('Input too long', 'event_espresso'), 100 ),
1146
+                                                            new EE_Max_Length_Validation_Strategy(__('Input too long', 'event_espresso'), 100),
1147 1147
                                                         )
1148 1148
 						)
1149 1149
 					),
@@ -1151,9 +1151,9 @@  discard block
 block discarded – undo
1151 1151
 						array(
1152 1152
 							'default' => '',
1153 1153
 							'required' => false,
1154
-							'html_label_text' => __( 'Purchase Order Number', 'event_espresso' ),
1154
+							'html_label_text' => __('Purchase Order Number', 'event_espresso'),
1155 1155
                                                         'validation_strategies' => array(
1156
-                                                            new EE_Max_Length_Validation_Strategy( __('Input too long', 'event_espresso'), 100 ),
1156
+                                                            new EE_Max_Length_Validation_Strategy(__('Input too long', 'event_espresso'), 100),
1157 1157
                                                         )
1158 1158
 						)
1159 1159
 					),
@@ -1161,9 +1161,9 @@  discard block
 block discarded – undo
1161 1161
 						array(
1162 1162
 							'default' => '',
1163 1163
 							'required' => false,
1164
-							'html_label_text' => __( 'Extra Field for Accounting', 'event_espresso' ),
1164
+							'html_label_text' => __('Extra Field for Accounting', 'event_espresso'),
1165 1165
                                                         'validation_strategies' => array(
1166
-                                                            new EE_Max_Length_Validation_Strategy( __('Input too long', 'event_espresso'), 100 ),
1166
+                                                            new EE_Max_Length_Validation_Strategy(__('Input too long', 'event_espresso'), 100),
1167 1167
                                                         )
1168 1168
 						)
1169 1169
 					),
@@ -1180,34 +1180,34 @@  discard block
 block discarded – undo
1180 1180
 	 * @param array $valid_data
1181 1181
 	 * @return EE_Payment
1182 1182
 	 */
1183
-	protected function _create_payment_from_request_data( $valid_data ) {
1184
-		$PAY_ID = $valid_data[ 'PAY_ID' ];
1183
+	protected function _create_payment_from_request_data($valid_data) {
1184
+		$PAY_ID = $valid_data['PAY_ID'];
1185 1185
 		// get payment amount
1186
-		$amount = $valid_data[ 'amount' ] ? abs( $valid_data[ 'amount' ] ) : 0;
1186
+		$amount = $valid_data['amount'] ? abs($valid_data['amount']) : 0;
1187 1187
 		// payments have a type value of 1 and refunds have a type value of -1
1188 1188
 		// so multiplying amount by type will give a positive value for payments, and negative values for refunds
1189
-		$amount = $valid_data[ 'type' ] < 0 ? $amount * -1 : $amount;
1189
+		$amount = $valid_data['type'] < 0 ? $amount * -1 : $amount;
1190 1190
 		$payment = EE_Payment::new_instance(
1191 1191
 			array(
1192
-				'TXN_ID' 								=> $valid_data[ 'TXN_ID' ],
1193
-				'STS_ID' 								=> $valid_data[ 'status' ],
1194
-				'PAY_timestamp' 				=> $valid_data[ 'date' ],
1192
+				'TXN_ID' 								=> $valid_data['TXN_ID'],
1193
+				'STS_ID' 								=> $valid_data['status'],
1194
+				'PAY_timestamp' 				=> $valid_data['date'],
1195 1195
 				'PAY_source'           			=> EEM_Payment_Method::scope_admin,
1196
-				'PMD_ID'               				=> $valid_data[ 'PMD_ID' ],
1196
+				'PMD_ID'               				=> $valid_data['PMD_ID'],
1197 1197
 				'PAY_amount'           			=> $amount,
1198
-				'PAY_txn_id_chq_nmbr'  	=> $valid_data[ 'txn_id_chq_nmbr' ],
1199
-				'PAY_po_number'        		=> $valid_data[ 'po_number' ],
1200
-				'PAY_extra_accntng'    		=> $valid_data[ 'accounting' ],
1198
+				'PAY_txn_id_chq_nmbr'  	=> $valid_data['txn_id_chq_nmbr'],
1199
+				'PAY_po_number'        		=> $valid_data['po_number'],
1200
+				'PAY_extra_accntng'    		=> $valid_data['accounting'],
1201 1201
 				'PAY_details'          				=> $valid_data,
1202 1202
 				'PAY_ID'               				=> $PAY_ID
1203 1203
 			),
1204 1204
 			'',
1205
-			array( 'Y-m-d', 'H:i a' )
1205
+			array('Y-m-d', 'H:i a')
1206 1206
 		);
1207
-		if ( ! $payment->save() ) {
1207
+		if ( ! $payment->save()) {
1208 1208
 			EE_Error::add_error(
1209 1209
 				sprintf(
1210
-					__( 'Payment %1$d has not been successfully saved to the database.', 'event_espresso' ),
1210
+					__('Payment %1$d has not been successfully saved to the database.', 'event_espresso'),
1211 1211
 					$payment->ID()
1212 1212
 				),
1213 1213
 				__FILE__, __FUNCTION__, __LINE__
@@ -1224,15 +1224,15 @@  discard block
 block discarded – undo
1224 1224
 	 * @param \EE_Transaction $transaction
1225 1225
 	 * @return array
1226 1226
 	 */
1227
-	protected function _process_transaction_payments( EE_Transaction $transaction ) {
1227
+	protected function _process_transaction_payments(EE_Transaction $transaction) {
1228 1228
 		/** @type EE_Transaction_Payments $transaction_payments */
1229
-		$transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' );
1229
+		$transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
1230 1230
 		//update the transaction with this payment
1231
-		if ( $transaction_payments->calculate_total_payments_and_update_status( $transaction ) ) {
1232
-			EE_Error::add_success( __( 'The payment has been processed successfully.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
1231
+		if ($transaction_payments->calculate_total_payments_and_update_status($transaction)) {
1232
+			EE_Error::add_success(__('The payment has been processed successfully.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1233 1233
 		} else {
1234 1234
 			EE_Error::add_error(
1235
-				__( 'The payment was processed successfully but the amount paid for the transaction was not updated.', 'event_espresso' )
1235
+				__('The payment was processed successfully but the amount paid for the transaction was not updated.', 'event_espresso')
1236 1236
 				, __FILE__, __FUNCTION__, __LINE__
1237 1237
 			);
1238 1238
 		}
@@ -1248,19 +1248,19 @@  discard block
 block discarded – undo
1248 1248
 	 * @param \EE_Payment $payment
1249 1249
 	 * @return array
1250 1250
 	 */
1251
-	protected function _get_REG_IDs_to_apply_payment_to( EE_Payment $payment ) {
1251
+	protected function _get_REG_IDs_to_apply_payment_to(EE_Payment $payment) {
1252 1252
 		$REG_IDs = array();
1253 1253
 		// grab array of IDs for specific registrations to apply changes to
1254
-		if ( isset( $this->_req_data[ 'txn_admin_payment' ][ 'registrations' ] ) ) {
1255
-			$REG_IDs = (array)$this->_req_data[ 'txn_admin_payment' ][ 'registrations' ];
1254
+		if (isset($this->_req_data['txn_admin_payment']['registrations'])) {
1255
+			$REG_IDs = (array) $this->_req_data['txn_admin_payment']['registrations'];
1256 1256
 		}
1257 1257
 		//nothing specified ? then get all reg IDs
1258
-		if ( empty( $REG_IDs ) ) {
1258
+		if (empty($REG_IDs)) {
1259 1259
 			$registrations = $payment->transaction()->registrations();
1260
-			$REG_IDs = ! empty( $registrations ) ? array_keys( $registrations ) : $this->_get_existing_reg_payment_REG_IDs( $payment );
1260
+			$REG_IDs = ! empty($registrations) ? array_keys($registrations) : $this->_get_existing_reg_payment_REG_IDs($payment);
1261 1261
 		}
1262 1262
 		// ensure that REG_IDs are integers and NOT strings
1263
-		return array_map( 'intval', $REG_IDs );
1263
+		return array_map('intval', $REG_IDs);
1264 1264
 	}
1265 1265
 
1266 1266
 
@@ -1277,7 +1277,7 @@  discard block
 block discarded – undo
1277 1277
 	/**
1278 1278
 	 * @param array $existing_reg_payment_REG_IDs
1279 1279
 	 */
1280
-	public function set_existing_reg_payment_REG_IDs( $existing_reg_payment_REG_IDs = null ) {
1280
+	public function set_existing_reg_payment_REG_IDs($existing_reg_payment_REG_IDs = null) {
1281 1281
 		$this->_existing_reg_payment_REG_IDs = $existing_reg_payment_REG_IDs;
1282 1282
 	}
1283 1283
 
@@ -1292,13 +1292,13 @@  discard block
 block discarded – undo
1292 1292
 	 * @param \EE_Payment $payment
1293 1293
 	 * @return array
1294 1294
 	 */
1295
-	protected function _get_existing_reg_payment_REG_IDs( EE_Payment $payment ) {
1296
-		if ( $this->existing_reg_payment_REG_IDs() === null ) {
1295
+	protected function _get_existing_reg_payment_REG_IDs(EE_Payment $payment) {
1296
+		if ($this->existing_reg_payment_REG_IDs() === null) {
1297 1297
 			// let's get any existing reg payment records for this payment
1298
-			$existing_reg_payment_REG_IDs = $payment->get_many_related( 'Registration' );
1298
+			$existing_reg_payment_REG_IDs = $payment->get_many_related('Registration');
1299 1299
 			// but we only want the REG IDs, so grab the array keys
1300
-			$existing_reg_payment_REG_IDs = ! empty( $existing_reg_payment_REG_IDs ) ? array_keys( $existing_reg_payment_REG_IDs ) : array();
1301
-			$this->set_existing_reg_payment_REG_IDs( $existing_reg_payment_REG_IDs );
1300
+			$existing_reg_payment_REG_IDs = ! empty($existing_reg_payment_REG_IDs) ? array_keys($existing_reg_payment_REG_IDs) : array();
1301
+			$this->set_existing_reg_payment_REG_IDs($existing_reg_payment_REG_IDs);
1302 1302
 		}
1303 1303
 		return $this->existing_reg_payment_REG_IDs();
1304 1304
 	}
@@ -1317,23 +1317,23 @@  discard block
 block discarded – undo
1317 1317
 	 * @param int         $PAY_ID
1318 1318
 	 * @return bool;
1319 1319
 	 */
1320
-	protected function _remove_existing_registration_payments( EE_Payment $payment, $PAY_ID = 0 ) {
1320
+	protected function _remove_existing_registration_payments(EE_Payment $payment, $PAY_ID = 0) {
1321 1321
 		// newly created payments will have nothing recorded for $PAY_ID
1322
-		if ( $PAY_ID == 0 ) {
1322
+		if ($PAY_ID == 0) {
1323 1323
 			return false;
1324 1324
 		}
1325
-		$existing_reg_payment_REG_IDs = $this->_get_existing_reg_payment_REG_IDs( $payment );
1326
-		if ( empty( $existing_reg_payment_REG_IDs )) {
1325
+		$existing_reg_payment_REG_IDs = $this->_get_existing_reg_payment_REG_IDs($payment);
1326
+		if (empty($existing_reg_payment_REG_IDs)) {
1327 1327
 			return false;
1328 1328
 		}
1329 1329
 		/** @type EE_Transaction_Payments $transaction_payments */
1330
-		$transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' );
1330
+		$transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
1331 1331
 		return $transaction_payments->delete_registration_payments_and_update_registrations(
1332 1332
 			$payment,
1333 1333
 			array(
1334 1334
 				array(
1335 1335
 					'PAY_ID' => $payment->ID(),
1336
-					'REG_ID' => array( 'IN', $existing_reg_payment_REG_IDs ),
1336
+					'REG_ID' => array('IN', $existing_reg_payment_REG_IDs),
1337 1337
 				)
1338 1338
 			)
1339 1339
 		);
@@ -1352,25 +1352,25 @@  discard block
 block discarded – undo
1352 1352
 	 * @param array $REG_IDs
1353 1353
 	 * @return bool
1354 1354
 	 */
1355
-	protected function _update_registration_payments( EE_Transaction $transaction, EE_Payment $payment, $REG_IDs = array() ) {
1355
+	protected function _update_registration_payments(EE_Transaction $transaction, EE_Payment $payment, $REG_IDs = array()) {
1356 1356
 		// we can pass our own custom set of registrations to EE_Payment_Processor::process_registration_payments()
1357 1357
 		// so let's do that using our set of REG_IDs from the form
1358 1358
 		$registration_query_where_params = array(
1359
-			'REG_ID' => array( 'IN', $REG_IDs )
1359
+			'REG_ID' => array('IN', $REG_IDs)
1360 1360
 		);
1361 1361
 		// but add in some conditions regarding payment,
1362 1362
 		// so that we don't apply payments to registrations that are free or have already been paid for
1363 1363
 		// but ONLY if the payment is NOT a refund ( ie: the payment amount is not negative )
1364
-		if ( ! $payment->is_a_refund() ) {
1365
-			$registration_query_where_params[ 'REG_final_price' ]  = array( '!=', 0 );
1366
-			$registration_query_where_params[ 'REG_final_price*' ]  = array( '!=', 'REG_paid', true );
1364
+		if ( ! $payment->is_a_refund()) {
1365
+			$registration_query_where_params['REG_final_price'] = array('!=', 0);
1366
+			$registration_query_where_params['REG_final_price*'] = array('!=', 'REG_paid', true);
1367 1367
 		}
1368 1368
 		//EEH_Debug_Tools::printr( $registration_query_where_params, '$registration_query_where_params', __FILE__, __LINE__ );
1369
-		$registrations = $transaction->registrations( array( $registration_query_where_params ) );
1370
-		if ( ! empty( $registrations ) ) {
1369
+		$registrations = $transaction->registrations(array($registration_query_where_params));
1370
+		if ( ! empty($registrations)) {
1371 1371
 			/** @type EE_Payment_Processor $payment_processor */
1372
-			$payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' );
1373
-			$payment_processor->process_registration_payments( $transaction, $payment, $registrations );
1372
+			$payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
1373
+			$payment_processor->process_registration_payments($transaction, $payment, $registrations);
1374 1374
 		}
1375 1375
 	}
1376 1376
 
@@ -1386,22 +1386,22 @@  discard block
 block discarded – undo
1386 1386
 	 * @param array $REG_IDs
1387 1387
 	 * @return bool
1388 1388
 	 */
1389
-	protected function _process_registration_status_change( EE_Transaction $transaction, $REG_IDs = array() ) {
1389
+	protected function _process_registration_status_change(EE_Transaction $transaction, $REG_IDs = array()) {
1390 1390
 		// first if there is no change in status then we get out.
1391 1391
 		if (
1392
-			! isset( $this->_req_data['txn_reg_status_change'], $this->_req_data[ 'txn_reg_status_change' ][ 'reg_status' ] )
1392
+			! isset($this->_req_data['txn_reg_status_change'], $this->_req_data['txn_reg_status_change']['reg_status'])
1393 1393
 			|| $this->_req_data['txn_reg_status_change']['reg_status'] == 'NAN'
1394 1394
 		) {
1395 1395
 			//no error message, no change requested, just nothing to do man.
1396 1396
 			return FALSE;
1397 1397
 		}
1398 1398
 		/** @type EE_Transaction_Processor $transaction_processor */
1399
-		$transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' );
1399
+		$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
1400 1400
 		// made it here dude?  Oh WOW.  K, let's take care of changing the statuses
1401 1401
 		return $transaction_processor->manually_update_registration_statuses(
1402 1402
 			$transaction,
1403
-			sanitize_text_field( $this->_req_data[ 'txn_reg_status_change' ][ 'reg_status' ] ),
1404
-			array( array( 'REG_ID' => array( 'IN', $REG_IDs ) ) )
1403
+			sanitize_text_field($this->_req_data['txn_reg_status_change']['reg_status']),
1404
+			array(array('REG_ID' => array('IN', $REG_IDs)))
1405 1405
 		);
1406 1406
 	}
1407 1407
 
@@ -1416,16 +1416,16 @@  discard block
 block discarded – undo
1416 1416
 	 * @param bool | null        $delete_txn_reg_status_change
1417 1417
 	 * @return array
1418 1418
 	 */
1419
-	protected function _build_payment_json_response( EE_Payment $payment, $REG_IDs = array(), $delete_txn_reg_status_change = null ) {
1419
+	protected function _build_payment_json_response(EE_Payment $payment, $REG_IDs = array(), $delete_txn_reg_status_change = null) {
1420 1420
 		// was the payment deleted ?
1421
-		if ( is_bool( $delete_txn_reg_status_change )) {
1421
+		if (is_bool($delete_txn_reg_status_change)) {
1422 1422
 			return array(
1423 1423
 				'PAY_ID' 				=> $payment->ID(),
1424 1424
 				'amount' 			=> $payment->amount(),
1425 1425
 				'total_paid' 			=> $payment->transaction()->paid(),
1426 1426
 				'txn_status' 			=> $payment->transaction()->status_ID(),
1427 1427
 				'pay_status' 		=> $payment->STS_ID(),
1428
-				'registrations' 	=> $this->_registration_payment_data_array( $REG_IDs ),
1428
+				'registrations' 	=> $this->_registration_payment_data_array($REG_IDs),
1429 1429
 				'delete_txn_reg_status_change' => $delete_txn_reg_status_change,
1430 1430
 			);
1431 1431
 		} else {
@@ -1437,16 +1437,16 @@  discard block
 block discarded – undo
1437 1437
 				'pay_status' 	=> $payment->STS_ID(),
1438 1438
 				'PAY_ID'           => $payment->ID(),
1439 1439
 				'STS_ID' 			=> $payment->STS_ID(),
1440
-				'status' 			=> self::$_pay_status[ $payment->STS_ID() ],
1441
-				'date' 				=> $payment->timestamp( 'Y-m-d', 'h:i a' ),
1442
-				'method' 		=> strtoupper( $payment->source() ),
1440
+				'status' 			=> self::$_pay_status[$payment->STS_ID()],
1441
+				'date' 				=> $payment->timestamp('Y-m-d', 'h:i a'),
1442
+				'method' 		=> strtoupper($payment->source()),
1443 1443
 				'PM_ID' 			=> $payment->payment_method() ? $payment->payment_method()->ID() : 1,
1444
-				'gateway' 		=> $payment->payment_method() ? $payment->payment_method()->admin_name() : __( "Unknown", 'event_espresso' ),
1444
+				'gateway' 		=> $payment->payment_method() ? $payment->payment_method()->admin_name() : __("Unknown", 'event_espresso'),
1445 1445
 				'gateway_response' 	=> $payment->gateway_response(),
1446 1446
 				'txn_id_chq_nmbr'  	=> $payment->txn_id_chq_nmbr(),
1447 1447
 				'po_number'        		=> $payment->po_number(),
1448 1448
 				'extra_accntng'    		=> $payment->extra_accntng(),
1449
-				'registrations'    			=> $this->_registration_payment_data_array( $REG_IDs ),
1449
+				'registrations'    			=> $this->_registration_payment_data_array($REG_IDs),
1450 1450
 			);
1451 1451
 		}
1452 1452
 	}
@@ -1461,42 +1461,42 @@  discard block
 block discarded – undo
1461 1461
 	*	@return void
1462 1462
 	*/
1463 1463
 	public function delete_payment() {
1464
-		$json_response_data = array( 'return_data' => FALSE );
1465
-		$PAY_ID = isset( $this->_req_data['delete_txn_admin_payment'], $this->_req_data['delete_txn_admin_payment']['PAY_ID'] ) ? absint( $this->_req_data['delete_txn_admin_payment']['PAY_ID'] ) : 0;
1466
-		if ( $PAY_ID ) {
1467
-			$delete_txn_reg_status_change = isset( $this->_req_data[ 'delete_txn_reg_status_change' ] ) ? $this->_req_data[ 'delete_txn_reg_status_change' ] : false;
1468
-			$payment = EEM_Payment::instance()->get_one_by_ID( $PAY_ID );
1469
-			if ( $payment instanceof EE_Payment ) {
1470
-				$REG_IDs = $this->_get_existing_reg_payment_REG_IDs( $payment );
1464
+		$json_response_data = array('return_data' => FALSE);
1465
+		$PAY_ID = isset($this->_req_data['delete_txn_admin_payment'], $this->_req_data['delete_txn_admin_payment']['PAY_ID']) ? absint($this->_req_data['delete_txn_admin_payment']['PAY_ID']) : 0;
1466
+		if ($PAY_ID) {
1467
+			$delete_txn_reg_status_change = isset($this->_req_data['delete_txn_reg_status_change']) ? $this->_req_data['delete_txn_reg_status_change'] : false;
1468
+			$payment = EEM_Payment::instance()->get_one_by_ID($PAY_ID);
1469
+			if ($payment instanceof EE_Payment) {
1470
+				$REG_IDs = $this->_get_existing_reg_payment_REG_IDs($payment);
1471 1471
 				/** @type EE_Transaction_Payments $transaction_payments */
1472
-				$transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' );
1473
-				if ( $transaction_payments->delete_payment_and_update_transaction( $payment )) {
1474
-					EE_Error::add_success( __( 'The Payment was successfully deleted.', 'event_espresso' ) );
1475
-					$json_response_data['return_data'] = $this->_build_payment_json_response( $payment, $REG_IDs, $delete_txn_reg_status_change );
1476
-					if ( $delete_txn_reg_status_change ) {
1472
+				$transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
1473
+				if ($transaction_payments->delete_payment_and_update_transaction($payment)) {
1474
+					EE_Error::add_success(__('The Payment was successfully deleted.', 'event_espresso'));
1475
+					$json_response_data['return_data'] = $this->_build_payment_json_response($payment, $REG_IDs, $delete_txn_reg_status_change);
1476
+					if ($delete_txn_reg_status_change) {
1477 1477
 						$this->_req_data['txn_reg_status_change'] = $delete_txn_reg_status_change;
1478 1478
 						//MAKE sure we also add the delete_txn_req_status_change to the
1479 1479
 						//$_REQUEST global because that's how messages will be looking for it.
1480 1480
 						$_REQUEST['txn_reg_status_change'] = $delete_txn_reg_status_change;
1481 1481
 						$this->_maybe_send_notifications();
1482
-						$this->_process_registration_status_change( $payment->transaction(), $REG_IDs );
1482
+						$this->_process_registration_status_change($payment->transaction(), $REG_IDs);
1483 1483
 						//$this->_maybe_send_notifications( $payment );
1484 1484
 					}
1485 1485
 				}
1486 1486
 			} else {
1487 1487
 				EE_Error::add_error(
1488
-					__( 'Valid Payment data could not be retrieved from the database.', 'event_espresso' ),
1488
+					__('Valid Payment data could not be retrieved from the database.', 'event_espresso'),
1489 1489
 					__FILE__, __FUNCTION__, __LINE__
1490 1490
 				);
1491 1491
 			}
1492 1492
 		} else {
1493 1493
 			EE_Error::add_error(
1494
-				__( 'A valid Payment ID was not received, therefore payment form data could not be loaded.', 'event_espresso' ),
1494
+				__('A valid Payment ID was not received, therefore payment form data could not be loaded.', 'event_espresso'),
1495 1495
 				__FILE__, __FUNCTION__, __LINE__
1496 1496
 			);
1497 1497
 		}
1498
-		$notices = EE_Error::get_notices( FALSE, FALSE, FALSE );
1499
-		echo json_encode( array_merge( $json_response_data, $notices ));
1498
+		$notices = EE_Error::get_notices(FALSE, FALSE, FALSE);
1499
+		echo json_encode(array_merge($json_response_data, $notices));
1500 1500
 		die();
1501 1501
 	}
1502 1502
 
@@ -1510,17 +1510,17 @@  discard block
 block discarded – undo
1510 1510
 	 * @param array $REG_IDs
1511 1511
 	 * @return array
1512 1512
 	 */
1513
-	protected function _registration_payment_data_array( $REG_IDs ) {
1513
+	protected function _registration_payment_data_array($REG_IDs) {
1514 1514
 		$registration_payment_data = array();
1515 1515
 		//if non empty reg_ids lets get an array of registrations and update the values for the apply_payment/refund rows.
1516
-		if ( ! empty( $REG_IDs ) ) {
1517
-			EE_Registry::instance()->load_helper( 'Template' );
1518
-			$registrations = EEM_Registration::instance()->get_all( array( array( 'REG_ID' => array( 'IN', $REG_IDs ) ) ) );
1519
-			foreach ( $registrations as $registration ) {
1520
-				if ( $registration instanceof EE_Registration ) {
1521
-					$registration_payment_data[ $registration->ID() ] = array(
1516
+		if ( ! empty($REG_IDs)) {
1517
+			EE_Registry::instance()->load_helper('Template');
1518
+			$registrations = EEM_Registration::instance()->get_all(array(array('REG_ID' => array('IN', $REG_IDs))));
1519
+			foreach ($registrations as $registration) {
1520
+				if ($registration instanceof EE_Registration) {
1521
+					$registration_payment_data[$registration->ID()] = array(
1522 1522
 						'paid' => $registration->pretty_paid(),
1523
-						'owing' => EEH_Template::format_currency( $registration->final_price() - $registration->paid() ),
1523
+						'owing' => EEH_Template::format_currency($registration->final_price() - $registration->paid()),
1524 1524
 					);
1525 1525
 				}
1526 1526
 			}
@@ -1540,30 +1540,30 @@  discard block
 block discarded – undo
1540 1540
 	 * @access protected
1541 1541
 	 * @param \EE_Payment | null $payment
1542 1542
 	 */
1543
-	protected function _maybe_send_notifications( $payment = null ) {
1544
-		switch ( $payment instanceof EE_Payment ) {
1543
+	protected function _maybe_send_notifications($payment = null) {
1544
+		switch ($payment instanceof EE_Payment) {
1545 1545
 			// payment notifications
1546 1546
 			case true :
1547 1547
 				if (
1548 1548
 					isset(
1549
-						$this->_req_data[ 'txn_payments' ],
1550
-						$this->_req_data[ 'txn_payments' ][ 'send_notifications' ]
1549
+						$this->_req_data['txn_payments'],
1550
+						$this->_req_data['txn_payments']['send_notifications']
1551 1551
 					) &&
1552
-					filter_var( $this->_req_data[ 'txn_payments' ][ 'send_notifications' ], FILTER_VALIDATE_BOOLEAN )
1552
+					filter_var($this->_req_data['txn_payments']['send_notifications'], FILTER_VALIDATE_BOOLEAN)
1553 1553
 				) {
1554
-					$this->_process_payment_notification( $payment );
1554
+					$this->_process_payment_notification($payment);
1555 1555
 				}
1556 1556
 				break;
1557 1557
 			// registration notifications
1558 1558
 			case false :
1559 1559
 				if (
1560 1560
 					isset(
1561
-						$this->_req_data[ 'txn_reg_status_change' ],
1562
-						$this->_req_data[ 'txn_reg_status_change' ][ 'send_notifications' ]
1561
+						$this->_req_data['txn_reg_status_change'],
1562
+						$this->_req_data['txn_reg_status_change']['send_notifications']
1563 1563
 					) &&
1564
-					filter_var( $this->_req_data[ 'txn_reg_status_change' ][ 'send_notifications' ], FILTER_VALIDATE_BOOLEAN )
1564
+					filter_var($this->_req_data['txn_reg_status_change']['send_notifications'], FILTER_VALIDATE_BOOLEAN)
1565 1565
 				) {
1566
-					add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true' );
1566
+					add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true');
1567 1567
 				}
1568 1568
 				break;
1569 1569
 		}
@@ -1579,11 +1579,11 @@  discard block
 block discarded – undo
1579 1579
 	*	@return void
1580 1580
 	*/
1581 1581
 	protected function _send_payment_reminder() {
1582
-	    $TXN_ID = ( ! empty( $this->_req_data['TXN_ID'] )) ? absint( $this->_req_data['TXN_ID'] ) : FALSE;
1583
-		$transaction = EEM_Transaction::instance()->get_one_by_ID( $TXN_ID );
1584
-		$query_args = isset($this->_req_data['redirect_to'] ) ? array('action' => $this->_req_data['redirect_to'], 'TXN_ID' => $this->_req_data['TXN_ID'] ) : array();
1585
-		do_action( 'AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder', $transaction );
1586
-		$this->_redirect_after_action( FALSE, __('payment reminder', 'event_espresso'), __('sent', 'event_espresso'), $query_args, TRUE );
1582
+	    $TXN_ID = ( ! empty($this->_req_data['TXN_ID'])) ? absint($this->_req_data['TXN_ID']) : FALSE;
1583
+		$transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
1584
+		$query_args = isset($this->_req_data['redirect_to']) ? array('action' => $this->_req_data['redirect_to'], 'TXN_ID' => $this->_req_data['TXN_ID']) : array();
1585
+		do_action('AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder', $transaction);
1586
+		$this->_redirect_after_action(FALSE, __('payment reminder', 'event_espresso'), __('sent', 'event_espresso'), $query_args, TRUE);
1587 1587
 	}
1588 1588
 
1589 1589
 
@@ -1597,36 +1597,36 @@  discard block
 block discarded – undo
1597 1597
 	 * @param string   $view
1598 1598
 	 * @return mixed int = count || array of transaction objects
1599 1599
 	 */
1600
-	public function get_transactions( $perpage, $count = FALSE, $view = '' ) {
1600
+	public function get_transactions($perpage, $count = FALSE, $view = '') {
1601 1601
 
1602 1602
 		$TXN = EEM_Transaction::instance();
1603 1603
 
1604
-	    $start_date = isset( $this->_req_data['txn-filter-start-date'] ) ? wp_strip_all_tags( $this->_req_data['txn-filter-start-date'] ) : date( 'm/d/Y', strtotime( '-10 year' ));
1605
-	    $end_date = isset( $this->_req_data['txn-filter-end-date'] ) ? wp_strip_all_tags( $this->_req_data['txn-filter-end-date'] ) : date( 'm/d/Y' );
1604
+	    $start_date = isset($this->_req_data['txn-filter-start-date']) ? wp_strip_all_tags($this->_req_data['txn-filter-start-date']) : date('m/d/Y', strtotime('-10 year'));
1605
+	    $end_date = isset($this->_req_data['txn-filter-end-date']) ? wp_strip_all_tags($this->_req_data['txn-filter-end-date']) : date('m/d/Y');
1606 1606
 
1607 1607
 	    //make sure our timestamps start and end right at the boundaries for each day
1608
-	    $start_date = date( 'Y-m-d', strtotime( $start_date ) ) . ' 00:00:00';
1609
-	    $end_date = date( 'Y-m-d', strtotime( $end_date ) ) . ' 23:59:59';
1608
+	    $start_date = date('Y-m-d', strtotime($start_date)).' 00:00:00';
1609
+	    $end_date = date('Y-m-d', strtotime($end_date)).' 23:59:59';
1610 1610
 
1611 1611
 
1612 1612
 	    //convert to timestamps
1613
-	    $start_date = strtotime( $start_date );
1614
-	    $end_date = strtotime( $end_date );
1613
+	    $start_date = strtotime($start_date);
1614
+	    $end_date = strtotime($end_date);
1615 1615
 
1616 1616
 	    //makes sure start date is the lowest value and vice versa
1617
-	    $start_date = min( $start_date, $end_date );
1618
-	    $end_date = max( $start_date, $end_date );
1617
+	    $start_date = min($start_date, $end_date);
1618
+	    $end_date = max($start_date, $end_date);
1619 1619
 
1620 1620
 	    //convert to correct format for query
1621
-	$start_date = EEM_Transaction::instance()->convert_datetime_for_query( 'TXN_timestamp', date( 'Y-m-d H:i:s', $start_date ), 'Y-m-d H:i:s' );
1622
-	$end_date = EEM_Transaction::instance()->convert_datetime_for_query( 'TXN_timestamp', date( 'Y-m-d H:i:s', $end_date ), 'Y-m-d H:i:s' );
1621
+	$start_date = EEM_Transaction::instance()->convert_datetime_for_query('TXN_timestamp', date('Y-m-d H:i:s', $start_date), 'Y-m-d H:i:s');
1622
+	$end_date = EEM_Transaction::instance()->convert_datetime_for_query('TXN_timestamp', date('Y-m-d H:i:s', $end_date), 'Y-m-d H:i:s');
1623 1623
 
1624 1624
 
1625 1625
 
1626 1626
 	    //set orderby
1627 1627
 		$this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : '';
1628 1628
 
1629
-		switch ( $this->_req_data['orderby'] ) {
1629
+		switch ($this->_req_data['orderby']) {
1630 1630
 			case 'TXN_ID':
1631 1631
 				$orderby = 'TXN_ID';
1632 1632
 				break;
@@ -1640,66 +1640,66 @@  discard block
 block discarded – undo
1640 1640
 				$orderby = 'TXN_timestamp';
1641 1641
 		}
1642 1642
 
1643
-		$sort = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] )) ? $this->_req_data['order'] : 'DESC';
1644
-		$current_page = isset( $this->_req_data['paged'] ) && !empty( $this->_req_data['paged'] ) ? $this->_req_data['paged'] : 1;
1645
-		$per_page = isset( $perpage ) && !empty( $perpage ) ? $perpage : 10;
1646
-		$per_page = isset( $this->_req_data['perpage'] ) && !empty( $this->_req_data['perpage'] ) ? $this->_req_data['perpage'] : $per_page;
1643
+		$sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'DESC';
1644
+		$current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1;
1645
+		$per_page = isset($perpage) && ! empty($perpage) ? $perpage : 10;
1646
+		$per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $per_page;
1647 1647
 
1648
-		$offset = ($current_page-1)*$per_page;
1649
-		$limit = array( $offset, $per_page );
1648
+		$offset = ($current_page - 1) * $per_page;
1649
+		$limit = array($offset, $per_page);
1650 1650
 
1651 1651
 		$_where = array(
1652
-			'TXN_timestamp' => array('BETWEEN', array($start_date, $end_date) ),
1652
+			'TXN_timestamp' => array('BETWEEN', array($start_date, $end_date)),
1653 1653
 			'Registration.REG_count' => 1
1654 1654
 		);
1655 1655
 
1656
-		if ( isset( $this->_req_data['EVT_ID'] ) ) {
1656
+		if (isset($this->_req_data['EVT_ID'])) {
1657 1657
 			$_where['Registration.EVT_ID'] = $this->_req_data['EVT_ID'];
1658 1658
 		}
1659 1659
 
1660
-		if ( isset( $this->_req_data['s'] ) ) {
1661
-			$search_string = '%' . $this->_req_data['s'] . '%';
1660
+		if (isset($this->_req_data['s'])) {
1661
+			$search_string = '%'.$this->_req_data['s'].'%';
1662 1662
 			$_where['OR'] = array(
1663
-				'Registration.Event.EVT_name' => array( 'LIKE', $search_string ),
1664
-				'Registration.Event.EVT_desc' => array( 'LIKE', $search_string ),
1665
-				'Registration.Event.EVT_short_desc' => array( 'LIKE' , $search_string ),
1666
-				'Registration.Attendee.ATT_full_name' => array( 'LIKE', $search_string ),
1667
-				'Registration.Attendee.ATT_fname' => array( 'LIKE', $search_string ),
1668
-				'Registration.Attendee.ATT_lname' => array( 'LIKE', $search_string ),
1669
-				'Registration.Attendee.ATT_short_bio' => array( 'LIKE', $search_string ),
1670
-				'Registration.Attendee.ATT_email' => array('LIKE', $search_string ),
1671
-				'Registration.Attendee.ATT_address' => array( 'LIKE', $search_string ),
1672
-				'Registration.Attendee.ATT_address2' => array( 'LIKE', $search_string ),
1673
-				'Registration.Attendee.ATT_city' => array( 'LIKE', $search_string ),
1674
-				'Registration.REG_final_price' => array( 'LIKE', $search_string ),
1675
-				'Registration.REG_code' => array( 'LIKE', $search_string ),
1676
-				'Registration.REG_count' => array( 'LIKE' , $search_string ),
1677
-				'Registration.REG_group_size' => array( 'LIKE' , $search_string ),
1678
-				'Registration.Ticket.TKT_name' => array( 'LIKE', $search_string ),
1679
-				'Registration.Ticket.TKT_description' => array( 'LIKE', $search_string ),
1680
-				'Payment.PAY_source' => array('LIKE', $search_string ),
1681
-				'Payment.Payment_Method.PMD_name' => array('LIKE', $search_string ),
1682
-				'TXN_session_data' => array( 'LIKE', $search_string ),
1683
-				'Payment.PAY_txn_id_chq_nmbr' => array( 'LIKE', $search_string )
1663
+				'Registration.Event.EVT_name' => array('LIKE', $search_string),
1664
+				'Registration.Event.EVT_desc' => array('LIKE', $search_string),
1665
+				'Registration.Event.EVT_short_desc' => array('LIKE', $search_string),
1666
+				'Registration.Attendee.ATT_full_name' => array('LIKE', $search_string),
1667
+				'Registration.Attendee.ATT_fname' => array('LIKE', $search_string),
1668
+				'Registration.Attendee.ATT_lname' => array('LIKE', $search_string),
1669
+				'Registration.Attendee.ATT_short_bio' => array('LIKE', $search_string),
1670
+				'Registration.Attendee.ATT_email' => array('LIKE', $search_string),
1671
+				'Registration.Attendee.ATT_address' => array('LIKE', $search_string),
1672
+				'Registration.Attendee.ATT_address2' => array('LIKE', $search_string),
1673
+				'Registration.Attendee.ATT_city' => array('LIKE', $search_string),
1674
+				'Registration.REG_final_price' => array('LIKE', $search_string),
1675
+				'Registration.REG_code' => array('LIKE', $search_string),
1676
+				'Registration.REG_count' => array('LIKE', $search_string),
1677
+				'Registration.REG_group_size' => array('LIKE', $search_string),
1678
+				'Registration.Ticket.TKT_name' => array('LIKE', $search_string),
1679
+				'Registration.Ticket.TKT_description' => array('LIKE', $search_string),
1680
+				'Payment.PAY_source' => array('LIKE', $search_string),
1681
+				'Payment.Payment_Method.PMD_name' => array('LIKE', $search_string),
1682
+				'TXN_session_data' => array('LIKE', $search_string),
1683
+				'Payment.PAY_txn_id_chq_nmbr' => array('LIKE', $search_string)
1684 1684
 				);
1685 1685
 		}
1686 1686
 
1687 1687
 		//failed transactions
1688
-		$failed = ( ! empty( $this->_req_data['status'] ) && $this->_req_data['status'] == 'failed' && ! $count ) || ( $count && $view == 'failed' ) ? TRUE: FALSE;
1689
-		$abandoned = ( ! empty( $this->_req_data['status'] ) && $this->_req_data['status'] == 'abandoned' && ! $count ) || ( $count && $view == 'abandoned' ) ? TRUE: FALSE;
1688
+		$failed = ( ! empty($this->_req_data['status']) && $this->_req_data['status'] == 'failed' && ! $count) || ($count && $view == 'failed') ? TRUE : FALSE;
1689
+		$abandoned = ( ! empty($this->_req_data['status']) && $this->_req_data['status'] == 'abandoned' && ! $count) || ($count && $view == 'abandoned') ? TRUE : FALSE;
1690 1690
 
1691
-		if ( $failed ) {
1692
-			$_where[ 'STS_ID' ] = EEM_Transaction::failed_status_code;
1693
-		} else if ( $abandoned ) {
1691
+		if ($failed) {
1692
+			$_where['STS_ID'] = EEM_Transaction::failed_status_code;
1693
+		} else if ($abandoned) {
1694 1694
 				$_where['STS_ID'] = EEM_Transaction::abandoned_status_code;
1695 1695
 		} else {
1696
-				$_where['STS_ID'] = array( '!=', EEM_Transaction::failed_status_code );
1697
-				$_where['STS_ID*'] = array( '!=', EEM_Transaction::abandoned_status_code );
1696
+				$_where['STS_ID'] = array('!=', EEM_Transaction::failed_status_code);
1697
+				$_where['STS_ID*'] = array('!=', EEM_Transaction::abandoned_status_code);
1698 1698
 		}
1699 1699
 
1700
-		$query_params = array( $_where, 'order_by' => array( $orderby => $sort ), 'limit' => $limit );
1700
+		$query_params = array($_where, 'order_by' => array($orderby => $sort), 'limit' => $limit);
1701 1701
 
1702
-		$transactions = $count ? $TXN->count( array($_where), 'TXN_ID', TRUE ) : $TXN->get_all($query_params);
1702
+		$transactions = $count ? $TXN->count(array($_where), 'TXN_ID', TRUE) : $TXN->get_all($query_params);
1703 1703
 
1704 1704
 
1705 1705
 		return $transactions;
Please login to merge, or discard this patch.
caffeinated/payment_methods/Paypal_Pro/EEG_Paypal_Pro.gateway.php 1 patch
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!defined('EVENT_ESPRESSO_VERSION'))
3
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
4 4
 	exit('No direct script access allowed');
5 5
 
6 6
 /**
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  *
26 26
  * ------------------------------------------------------------------------
27 27
  */
28
-class EEG_Paypal_Pro extends EE_Onsite_Gateway{
28
+class EEG_Paypal_Pro extends EE_Onsite_Gateway {
29 29
 	/**
30 30
 	 *
31 31
 	 * @var $_paypal_api_username string
@@ -88,25 +88,25 @@  discard block
 block discarded – undo
88 88
 	 * } @see parent::do_direct_payment for more info
89 89
 	 * @return \EE_Payment|\EEI_Payment
90 90
 	 */
91
-	public function do_direct_payment($payment,$billing_info = null){
91
+	public function do_direct_payment($payment, $billing_info = null) {
92 92
 		$transaction = $payment->transaction();
93 93
 		$primary_registrant = $transaction->primary_registration();
94
-		$order_description  = sprintf(__("Event Registrations from %s", "event_espresso"),get_bloginfo('name'));
94
+		$order_description  = sprintf(__("Event Registrations from %s", "event_espresso"), get_bloginfo('name'));
95 95
 		//charge for the full amount. Show itemized list
96
-		if( $this->_can_easily_itemize_transaction_for( $payment ) ){
96
+		if ($this->_can_easily_itemize_transaction_for($payment)) {
97 97
 			$item_num = 1;
98 98
 			$total_line_item = $transaction->total_line_item();
99 99
 			$order_items = array();
100 100
 			foreach ($total_line_item->get_items() as $line_item) {
101 101
 				//ignore line items with a quantity of 0
102
-				if( $line_item->quantity() == 0 ) {
102
+				if ($line_item->quantity() == 0) {
103 103
 					continue;
104 104
 				}
105 105
 				$item = array(
106 106
 						// Item Name.  127 char max.
107
-						'l_name' => substr($line_item->name(),0,127),
107
+						'l_name' => substr($line_item->name(), 0, 127),
108 108
 						// Item description.  127 char max.
109
-						'l_desc' => substr($line_item->desc(),0,127),
109
+						'l_desc' => substr($line_item->desc(), 0, 127),
110 110
 						// Cost of individual item.
111 111
 						'l_amt' => $line_item->unit_price(),
112 112
 						// Item Number.  127 char max.
@@ -127,14 +127,14 @@  discard block
 block discarded – undo
127 127
 			}
128 128
 			$item_amount = $total_line_item->get_items_total();
129 129
 			$tax_amount = $total_line_item->get_total_tax();
130
-		}else{
130
+		} else {
131 131
 			$order_items = array();
132 132
 			$item_amount = $payment->amount();
133
-			$single_item_desc = sprintf(__("Partial payment of %s for %s", "event_espresso"),$payment->amount(),$primary_registrant->reg_code());
133
+			$single_item_desc = sprintf(__("Partial payment of %s for %s", "event_espresso"), $payment->amount(), $primary_registrant->reg_code());
134 134
 			$tax_amount = 0;
135
-			array_push($order_items,array(
135
+			array_push($order_items, array(
136 136
 				// Item Name.  127 char max.
137
-				'l_name' => sprintf(__("Partial payment for registration: %s", 'event_espresso'),$primary_registrant->reg_code()),
137
+				'l_name' => sprintf(__("Partial payment for registration: %s", 'event_espresso'), $primary_registrant->reg_code()),
138 138
 				// Item description.  127 char max.
139 139
 				'l_desc' => $single_item_desc,
140 140
 				// Cost of individual item.
@@ -181,11 +181,11 @@  discard block
 block discarded – undo
181 181
 			// Payer's salutation.  20 char max.
182 182
 			'salutation' => '',
183 183
 			// Payer's first name.  25 char max.
184
-			'firstname' => substr($billing_info['first_name'],0,25),
184
+			'firstname' => substr($billing_info['first_name'], 0, 25),
185 185
 			// Payer's middle name.  25 char max.
186 186
 			'middlename' => '',
187 187
 			// Payer's last name.  25 char max.
188
-			'lastname' => substr($billing_info['last_name'],0,25),
188
+			'lastname' => substr($billing_info['last_name'], 0, 25),
189 189
 			// Payer's suffix.  12 char max.
190 190
 			'suffix' => ''
191 191
 		);
@@ -198,13 +198,13 @@  discard block
 block discarded – undo
198 198
 			// Required.  Name of City.
199 199
 			'city' => $billing_info['city'],
200 200
 			// Required. Name of State or Province.
201
-			'state' => substr( $billing_info['state'], 0, 40 ),
201
+			'state' => substr($billing_info['state'], 0, 40),
202 202
 			// Required.  Country code.
203 203
 			'countrycode' => $billing_info['country'],
204 204
 			// Required.  Postal code of payer.
205 205
 			'zip' => $billing_info['zip'],
206 206
 			// Phone Number of payer.  20 char max.
207
-			'shiptophonenum' => substr($billing_info['phone'],0,20)
207
+			'shiptophonenum' => substr($billing_info['phone'], 0, 20)
208 208
 		);
209 209
 
210 210
 
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 			// Required.  Three-letter currency code.  Default is USD.
215 215
 			'currencycode' => $payment->currency_code(),
216 216
 			// Required if you include itemized cart details. (L_AMTn, etc.)  Subtotal of items not including S&H, or tax.
217
-			'itemamt' => $this->format_currency($item_amount),//
217
+			'itemamt' => $this->format_currency($item_amount), //
218 218
 			// Total shipping costs for the order.  If you specify shippingamt, you must also specify itemamt.
219 219
 			'shippingamt' => '',
220 220
 			// Total handling costs for the order.  If you specify handlingamt, you must also specify itemamt.
@@ -226,10 +226,10 @@  discard block
 block discarded – undo
226 226
 			// Free-form field for your own use.  256 char max.
227 227
 			'custom' => $primary_registrant ? $primary_registrant->ID() : '',
228 228
 			// Your own invoice or tracking number
229
-			'invnum' => wp_generate_password(12,false),//$transaction->ID(),
229
+			'invnum' => wp_generate_password(12, false), //$transaction->ID(),
230 230
 			// URL for receiving Instant Payment Notifications.  This overrides what your profile is set to use.
231 231
 			'notifyurl' => '',
232
-			'buttonsource' => 'EventEspresso_SP',//EE will blow up if you change this
232
+			'buttonsource' => 'EventEspresso_SP', //EE will blow up if you change this
233 233
 		);
234 234
 		// Wrap all data arrays into a single, "master" array which will be passed into the class function.
235 235
 		$PayPalRequestData = array(
@@ -242,32 +242,32 @@  discard block
 block discarded – undo
242 242
 				'OrderItems' => $order_items,
243 243
 		);
244 244
 		$this->_log_clean_request($PayPalRequestData, $payment);
245
-		try{
245
+		try {
246 246
 			$PayPalResult = $this->prep_and_curl_request($PayPalRequestData);
247 247
 			//remove PCI-sensitive data so it doesn't get stored
248
-			$PayPalResult = $this->_log_clean_response($PayPalResult,$payment);
248
+			$PayPalResult = $this->_log_clean_response($PayPalResult, $payment);
249 249
 
250 250
 			$message = isset($PayPalResult['L_LONGMESSAGE0']) ? $PayPalResult['L_LONGMESSAGE0'] : $PayPalResult['ACK'];
251
-			if( empty($PayPalResult[ 'RAWRESPONSE' ] ) ) {
252
-				$payment->set_status( $this->_pay_model->failed_status() ) ;
253
-				$payment->set_gateway_response( __( 'No response received from Paypal Pro', 'event_espresso' ) );
251
+			if (empty($PayPalResult['RAWRESPONSE'])) {
252
+				$payment->set_status($this->_pay_model->failed_status());
253
+				$payment->set_gateway_response(__('No response received from Paypal Pro', 'event_espresso'));
254 254
 				$payment->set_details($PayPalResult);
255
-			}else{
256
-				if($this->_APICallSuccessful($PayPalResult)){
255
+			} else {
256
+				if ($this->_APICallSuccessful($PayPalResult)) {
257 257
 					$payment->set_status($this->_pay_model->approved_status());
258
-				}else{
258
+				} else {
259 259
 					$payment->set_status($this->_pay_model->declined_status());
260 260
 				}
261 261
 				//make sure we interpret the AMT as a float, not an international string (where periods are thousand separators)
262
-				$payment->set_amount(isset($PayPalResult['AMT']) ? floatval( $PayPalResult['AMT'] ) : 0);
262
+				$payment->set_amount(isset($PayPalResult['AMT']) ? floatval($PayPalResult['AMT']) : 0);
263 263
 				$payment->set_gateway_response($message);
264
-				$payment->set_txn_id_chq_nmbr(isset( $PayPalResult['TRANSACTIONID'] )? $PayPalResult['TRANSACTIONID'] : null);
264
+				$payment->set_txn_id_chq_nmbr(isset($PayPalResult['TRANSACTIONID']) ? $PayPalResult['TRANSACTIONID'] : null);
265 265
 
266 266
 				$primary_registration_code = $primary_registrant instanceof EE_Registration ? $primary_registrant->reg_code() : '';
267 267
 				$payment->set_extra_accntng($primary_registration_code);
268 268
 				$payment->set_details($PayPalResult);
269 269
 			}
270
-		}catch(Exception $e){
270
+		} catch (Exception $e) {
271 271
 			$payment->set_status($this->_pay_model->failed_status());
272 272
 			$payment->set_gateway_response($e->getMessage());
273 273
 		}
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 	 * @param EEI_Payment $payment
285 285
 	 * @return array
286 286
 	 */
287
-	private function _log_clean_request($request,$payment){
287
+	private function _log_clean_request($request, $payment) {
288 288
 		$cleaned_request_data = $request;
289 289
 		unset($cleaned_request_data['CCDetails']['acct']);
290 290
 		unset($cleaned_request_data['CCDetails']['cvv2']);
@@ -300,13 +300,13 @@  discard block
 block discarded – undo
300 300
 	 * @param EEI_Payment $payment
301 301
 	 * @return array cleaned
302 302
 	 */
303
-	private function _log_clean_response($response,$payment){
303
+	private function _log_clean_response($response, $payment) {
304 304
 		unset($response['REQUESTDATA']['CREDITCARDTYPE']);
305 305
 		unset($response['REQUESTDATA']['ACCT']);
306 306
 		unset($response['REQUESTDATA']['EXPDATE']);
307 307
 		unset($response['REQUESTDATA']['CVV2']);
308 308
 		unset($response['RAWREQUEST']);
309
-		$this->log(array('Paypal Response'=>$response),$payment);
309
+		$this->log(array('Paypal Response'=>$response), $payment);
310 310
 		return $response;
311 311
 	}
312 312
 
@@ -331,32 +331,32 @@  discard block
 block discarded – undo
331 331
 		// DP Fields
332 332
 		$DPFields = isset($DataArray['DPFields']) ? $DataArray['DPFields'] : array();
333 333
 		foreach ($DPFields as $DPFieldsVar => $DPFieldsVal)
334
-			$DPFieldsNVP .= '&' . strtoupper($DPFieldsVar) . '=' . urlencode($DPFieldsVal);
334
+			$DPFieldsNVP .= '&'.strtoupper($DPFieldsVar).'='.urlencode($DPFieldsVal);
335 335
 
336 336
 		// CC Details Fields
337 337
 		$CCDetails = isset($DataArray['CCDetails']) ? $DataArray['CCDetails'] : array();
338 338
 		foreach ($CCDetails as $CCDetailsVar => $CCDetailsVal)
339
-			$CCDetailsNVP .= '&' . strtoupper($CCDetailsVar) . '=' . urlencode($CCDetailsVal);
339
+			$CCDetailsNVP .= '&'.strtoupper($CCDetailsVar).'='.urlencode($CCDetailsVal);
340 340
 
341 341
 		// PayerInfo Type Fields
342 342
 		$PayerInfo = isset($DataArray['PayerInfo']) ? $DataArray['PayerInfo'] : array();
343 343
 		foreach ($PayerInfo as $PayerInfoVar => $PayerInfoVal)
344
-			$PayerInfoNVP .= '&' . strtoupper($PayerInfoVar) . '=' . urlencode($PayerInfoVal);
344
+			$PayerInfoNVP .= '&'.strtoupper($PayerInfoVar).'='.urlencode($PayerInfoVal);
345 345
 
346 346
 		// Payer Name Fields
347 347
 		$PayerName = isset($DataArray['PayerName']) ? $DataArray['PayerName'] : array();
348 348
 		foreach ($PayerName as $PayerNameVar => $PayerNameVal)
349
-			$PayerNameNVP .= '&' . strtoupper($PayerNameVar) . '=' . urlencode($PayerNameVal);
349
+			$PayerNameNVP .= '&'.strtoupper($PayerNameVar).'='.urlencode($PayerNameVal);
350 350
 
351 351
 		// Address Fields (Billing)
352 352
 		$BillingAddress = isset($DataArray['BillingAddress']) ? $DataArray['BillingAddress'] : array();
353 353
 		foreach ($BillingAddress as $BillingAddressVar => $BillingAddressVal)
354
-			$BillingAddressNVP .= '&' . strtoupper($BillingAddressVar) . '=' . urlencode($BillingAddressVal);
354
+			$BillingAddressNVP .= '&'.strtoupper($BillingAddressVar).'='.urlencode($BillingAddressVal);
355 355
 
356 356
 		// Payment Details Type Fields
357 357
 		$PaymentDetails = isset($DataArray['PaymentDetails']) ? $DataArray['PaymentDetails'] : array();
358 358
 		foreach ($PaymentDetails as $PaymentDetailsVar => $PaymentDetailsVal)
359
-			$PaymentDetailsNVP .= '&' . strtoupper($PaymentDetailsVar) . '=' . urlencode($PaymentDetailsVal);
359
+			$PaymentDetailsNVP .= '&'.strtoupper($PaymentDetailsVar).'='.urlencode($PaymentDetailsVal);
360 360
 
361 361
 		// Payment Details Item Type Fields
362 362
 		$OrderItems = isset($DataArray['OrderItems']) ? $DataArray['OrderItems'] : array();
@@ -364,22 +364,22 @@  discard block
 block discarded – undo
364 364
 		foreach ($OrderItems as $OrderItemsVar => $OrderItemsVal) {
365 365
 			$CurrentItem = $OrderItems[$OrderItemsVar];
366 366
 			foreach ($CurrentItem as $CurrentItemVar => $CurrentItemVal)
367
-				$OrderItemsNVP .= '&' . strtoupper($CurrentItemVar) . $n . '=' . urlencode($CurrentItemVal);
367
+				$OrderItemsNVP .= '&'.strtoupper($CurrentItemVar).$n.'='.urlencode($CurrentItemVal);
368 368
 			$n++;
369 369
 		}
370 370
 
371 371
 		// Ship To Address Fields
372 372
 		$ShippingAddress = isset($DataArray['ShippingAddress']) ? $DataArray['ShippingAddress'] : array();
373 373
 		foreach ($ShippingAddress as $ShippingAddressVar => $ShippingAddressVal)
374
-			$ShippingAddressNVP .= '&' . strtoupper($ShippingAddressVar) . '=' . urlencode($ShippingAddressVal);
374
+			$ShippingAddressNVP .= '&'.strtoupper($ShippingAddressVar).'='.urlencode($ShippingAddressVal);
375 375
 
376 376
 		// 3D Secure Fields
377 377
 		$Secure3D = isset($DataArray['Secure3D']) ? $DataArray['Secure3D'] : array();
378 378
 		foreach ($Secure3D as $Secure3DVar => $Secure3DVal)
379
-			$Secure3DNVP .= '&' . strtoupper($Secure3DVar) . '=' . urlencode($Secure3DVal);
379
+			$Secure3DNVP .= '&'.strtoupper($Secure3DVar).'='.urlencode($Secure3DVal);
380 380
 
381 381
 		// Now that we have each chunk we need to go ahead and append them all together for our entire NVP string
382
-		$NVPRequest = 'USER=' . $this->_username . '&PWD=' . $this->_password . '&VERSION=64.0' . '&SIGNATURE=' . $this->_signature . $DPFieldsNVP . $CCDetailsNVP . $PayerInfoNVP . $PayerNameNVP . $BillingAddressNVP . $PaymentDetailsNVP . $OrderItemsNVP . $ShippingAddressNVP . $Secure3DNVP;
382
+		$NVPRequest = 'USER='.$this->_username.'&PWD='.$this->_password.'&VERSION=64.0'.'&SIGNATURE='.$this->_signature.$DPFieldsNVP.$CCDetailsNVP.$PayerInfoNVP.$PayerNameNVP.$BillingAddressNVP.$PaymentDetailsNVP.$OrderItemsNVP.$ShippingAddressNVP.$Secure3DNVP;
383 383
 		$NVPResponse = $this->_CURLRequest($NVPRequest);
384 384
 		$NVPRequestArray = $this->_NVPToArray($NVPRequest);
385 385
 		$NVPResponseArray = $this->_NVPToArray($NVPResponse);
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
 	private function _CURLRequest($Request) {
404 404
 		$EndPointURL = $this->_debug_mode ? 'https://api-3t.sandbox.paypal.com/nvp' : 'https://api-3t.paypal.com/nvp';
405 405
 		$curl = curl_init();
406
-		curl_setopt($curl, CURLOPT_VERBOSE, apply_filters('FHEE__EEG_Paypal_Pro__CurlRequest__CURLOPT_VERBOSE', TRUE ) );
406
+		curl_setopt($curl, CURLOPT_VERBOSE, apply_filters('FHEE__EEG_Paypal_Pro__CurlRequest__CURLOPT_VERBOSE', TRUE));
407 407
 		curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
408 408
 		curl_setopt($curl, CURLOPT_TIMEOUT, 60);
409 409
 		curl_setopt($curl, CURLOPT_URL, $EndPointURL);
@@ -453,9 +453,9 @@  discard block
 block discarded – undo
453 453
 	private function _APICallSuccessful($PayPalResult) {
454 454
 		$approved = false;
455 455
 		// check main response message from PayPal
456
-		if (isset($PayPalResult['ACK']) && !empty($PayPalResult['ACK'])) {
456
+		if (isset($PayPalResult['ACK']) && ! empty($PayPalResult['ACK'])) {
457 457
 			$ack = strtoupper($PayPalResult['ACK']);
458
-			$approved = ( $ack == 'SUCCESS' || $ack == 'SUCCESSWITHWARNING' || $ack == 'PARTIALSUCCESS' ) ? true : false;
458
+			$approved = ($ack == 'SUCCESS' || $ack == 'SUCCESSWITHWARNING' || $ack == 'PARTIALSUCCESS') ? true : false;
459 459
 		}
460 460
 
461 461
 		return $approved;
@@ -471,11 +471,11 @@  discard block
 block discarded – undo
471 471
 
472 472
 		$Errors = array();
473 473
 		$n = 0;
474
-		while (isset($DataArray['L_ERRORCODE' . $n . ''])) {
475
-			$LErrorCode = isset($DataArray['L_ERRORCODE' . $n . '']) ? $DataArray['L_ERRORCODE' . $n . ''] : '';
476
-			$LShortMessage = isset($DataArray['L_SHORTMESSAGE' . $n . '']) ? $DataArray['L_SHORTMESSAGE' . $n . ''] : '';
477
-			$LLongMessage = isset($DataArray['L_LONGMESSAGE' . $n . '']) ? $DataArray['L_LONGMESSAGE' . $n . ''] : '';
478
-			$LSeverityCode = isset($DataArray['L_SEVERITYCODE' . $n . '']) ? $DataArray['L_SEVERITYCODE' . $n . ''] : '';
474
+		while (isset($DataArray['L_ERRORCODE'.$n.''])) {
475
+			$LErrorCode = isset($DataArray['L_ERRORCODE'.$n.'']) ? $DataArray['L_ERRORCODE'.$n.''] : '';
476
+			$LShortMessage = isset($DataArray['L_SHORTMESSAGE'.$n.'']) ? $DataArray['L_SHORTMESSAGE'.$n.''] : '';
477
+			$LLongMessage = isset($DataArray['L_LONGMESSAGE'.$n.'']) ? $DataArray['L_LONGMESSAGE'.$n.''] : '';
478
+			$LSeverityCode = isset($DataArray['L_SEVERITYCODE'.$n.'']) ? $DataArray['L_SEVERITYCODE'.$n.''] : '';
479 479
 
480 480
 			$CurrentItem = array(
481 481
 					'L_ERRORCODE' => $LErrorCode,
@@ -515,7 +515,7 @@  discard block
 block discarded – undo
515 515
 				elseif ($CurrentErrorVar == 'L_SEVERITYCODE')
516 516
 					$CurrentVarName = 'Severity Code';
517 517
 
518
-				$error .= '<br />' . $CurrentVarName . ': ' . $CurrentErrorVal;
518
+				$error .= '<br />'.$CurrentVarName.': '.$CurrentErrorVal;
519 519
 			}
520 520
 		}
521 521
 		return $error;
Please login to merge, or discard this patch.
core/EE_Session.core.php 1 patch
Spacing   +151 added lines, -151 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if (!defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
2 2
 /**
3 3
  *
4 4
  * Event Espresso
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 	  * array for defining default session vars
111 111
 	  * @var array
112 112
 	  */
113
-	 private $_default_session_vars = array (
113
+	 private $_default_session_vars = array(
114 114
 		'id' 							=> null,
115 115
 		'user_id' 					=> null,
116 116
 		'ip_address' 			=> null,
@@ -132,9 +132,9 @@  discard block
 block discarded – undo
132 132
 	 *		@access public
133 133
 	 *		@return EE_Session
134 134
 	 */
135
-	public static function instance ( ) {
135
+	public static function instance( ) {
136 136
 		// check if class object is instantiated
137
-		if ( ! self::$_instance instanceof EE_Session ) {
137
+		if ( ! self::$_instance instanceof EE_Session) {
138 138
 			self::$_instance = new self();
139 139
 		}
140 140
 		return self::$_instance;
@@ -151,11 +151,11 @@  discard block
 block discarded – undo
151 151
 	private function __construct() {
152 152
 
153 153
 		// session loading is turned ON by default, but prior to the init hook, can be turned back OFF via: add_filter( 'FHEE_load_EE_Session', '__return_false' );
154
-		if ( ! apply_filters( 'FHEE_load_EE_Session', TRUE ) ) {
154
+		if ( ! apply_filters('FHEE_load_EE_Session', TRUE)) {
155 155
 			return null;
156 156
 		}
157
-		do_action( 'AHEE_log', __CLASS__, __FUNCTION__, '' );
158
-		define( 'ESPRESSO_SESSION', TRUE );
157
+		do_action('AHEE_log', __CLASS__, __FUNCTION__, '');
158
+		define('ESPRESSO_SESSION', TRUE);
159 159
 		// default session lifespan in seconds
160 160
 		$this->_lifespan = apply_filters(
161 161
 			'FHEE__EE_Session__construct___lifespan',
@@ -168,35 +168,35 @@  discard block
 block discarded – undo
168 168
 		 * 		}
169 169
 		 */
170 170
 		// retrieve session options from db
171
-		$session_settings = get_option( 'ee_session_settings' );
172
-		if ( $session_settings !== FALSE ) {
171
+		$session_settings = get_option('ee_session_settings');
172
+		if ($session_settings !== FALSE) {
173 173
 			// cycle though existing session options
174
-			foreach ( $session_settings as $var_name => $session_setting ) {
174
+			foreach ($session_settings as $var_name => $session_setting) {
175 175
 				// set values for class properties
176
-				$var_name = '_' . $var_name;
176
+				$var_name = '_'.$var_name;
177 177
 				$this->{$var_name} = $session_setting;
178 178
 			}
179 179
 		}
180 180
 		// are we using encryption?
181
-		if ( $this->_use_encryption ) {
181
+		if ($this->_use_encryption) {
182 182
 			// instantiate the class object making all properties and methods accessible via $this->encryption ex: $this->encryption->encrypt();
183
-			$this->encryption = EE_Registry::instance()->load_core( 'Encryption' );
183
+			$this->encryption = EE_Registry::instance()->load_core('Encryption');
184 184
 		}
185 185
 		// filter hook allows outside functions/classes/plugins to change default empty cart
186
-		$extra_default_session_vars = apply_filters( 'FHEE__EE_Session__construct__extra_default_session_vars', array() );
187
-		array_merge( $this->_default_session_vars, $extra_default_session_vars );
186
+		$extra_default_session_vars = apply_filters('FHEE__EE_Session__construct__extra_default_session_vars', array());
187
+		array_merge($this->_default_session_vars, $extra_default_session_vars);
188 188
 		// apply default session vars
189 189
 		$this->_set_defaults();
190 190
 		// check for existing session and retrieve it from db
191
-		if ( ! $this->_espresso_session() ) {
191
+		if ( ! $this->_espresso_session()) {
192 192
 			// or just start a new one
193 193
 			$this->_create_espresso_session();
194 194
 		}
195 195
 		// check request for 'clear_session' param
196
-		add_action( 'AHEE__EE_Request_Handler__construct__complete', array( $this, 'wp_loaded' ));
196
+		add_action('AHEE__EE_Request_Handler__construct__complete', array($this, 'wp_loaded'));
197 197
 		// once everything is all said and done,
198
-		add_action( 'shutdown', array( $this, 'update' ), 100 );
199
-		add_action( 'shutdown', array( $this, 'garbage_collection' ), 999 );
198
+		add_action('shutdown', array($this, 'update'), 100);
199
+		add_action('shutdown', array($this, 'garbage_collection'), 999);
200 200
 
201 201
 	}
202 202
 
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 	  * @return int
234 234
 	  */
235 235
 	 public function extension() {
236
-		 return apply_filters( 'FHEE__EE_Session__extend_expiration__seconds_added', ( 10 * MINUTE_IN_SECONDS ) );
236
+		 return apply_filters('FHEE__EE_Session__extend_expiration__seconds_added', (10 * MINUTE_IN_SECONDS));
237 237
 	 }
238 238
 
239 239
 
@@ -242,9 +242,9 @@  discard block
 block discarded – undo
242 242
 	  * @param int $time number of seconds to add to session expiration
243 243
 	  * @return int
244 244
 	  */
245
-	 public function extend_expiration( $time = 0 ) {
245
+	 public function extend_expiration($time = 0) {
246 246
 		 $time = $time ? $time : $this->extension();
247
-		 $this->_expiration += absint( $time );
247
+		 $this->_expiration += absint($time);
248 248
 	 }
249 249
 
250 250
 
@@ -266,8 +266,8 @@  discard block
 block discarded – undo
266 266
 	 */
267 267
 	private function _set_defaults() {
268 268
 		// set some defaults
269
-		foreach ( $this->_default_session_vars as $key => $default_var ) {
270
-			$this->_session_data[ $key ] = $default_var;
269
+		foreach ($this->_default_session_vars as $key => $default_var) {
270
+			$this->_session_data[$key] = $default_var;
271 271
 		}
272 272
 	}
273 273
 
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
 	  * @param \EE_Cart $cart
289 289
 	  * @return bool
290 290
 	  */
291
-	 public function set_cart( EE_Cart $cart ) {
291
+	 public function set_cart(EE_Cart $cart) {
292 292
 		 $this->_session_data['cart'] = $cart;
293 293
 		 return TRUE;
294 294
 	 }
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 	  * reset_cart
300 300
 	  */
301 301
 	 public function reset_cart() {
302
-		 do_action( 'AHEE__EE_Session__reset_cart__before_reset', $this );
302
+		 do_action('AHEE__EE_Session__reset_cart__before_reset', $this);
303 303
 		 $this->_session_data['cart'] = NULL;
304 304
 	 }
305 305
 
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 	  * @return \EE_Cart
310 310
 	  */
311 311
 	 public function cart() {
312
-		 return isset( $this->_session_data['cart'] ) && $this->_session_data[ 'cart' ] instanceof EE_Cart ? $this->_session_data['cart'] : NULL;
312
+		 return isset($this->_session_data['cart']) && $this->_session_data['cart'] instanceof EE_Cart ? $this->_session_data['cart'] : NULL;
313 313
 	 }
314 314
 
315 315
 
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
 	  * @param \EE_Checkout $checkout
319 319
 	  * @return bool
320 320
 	  */
321
-	 public function set_checkout( EE_Checkout $checkout ) {
321
+	 public function set_checkout(EE_Checkout $checkout) {
322 322
 		 $this->_session_data['checkout'] = $checkout;
323 323
 		 return TRUE;
324 324
 	 }
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
 	  * reset_checkout
330 330
 	  */
331 331
 	 public function reset_checkout() {
332
-		 do_action( 'AHEE__EE_Session__reset_checkout__before_reset', $this );
332
+		 do_action('AHEE__EE_Session__reset_checkout__before_reset', $this);
333 333
 		 $this->_session_data['checkout'] = NULL;
334 334
 	 }
335 335
 
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
 	  * @return \EE_Checkout
340 340
 	  */
341 341
 	 public function checkout() {
342
-		 return isset( $this->_session_data['checkout'] ) && $this->_session_data[ 'checkout' ] instanceof EE_Checkout ? $this->_session_data['checkout'] : NULL;
342
+		 return isset($this->_session_data['checkout']) && $this->_session_data['checkout'] instanceof EE_Checkout ? $this->_session_data['checkout'] : NULL;
343 343
 	 }
344 344
 
345 345
 
@@ -348,9 +348,9 @@  discard block
 block discarded – undo
348 348
 	  * @param \EE_Transaction $transaction
349 349
 	  * @return bool
350 350
 	  */
351
-	 public function set_transaction( EE_Transaction $transaction ) {
351
+	 public function set_transaction(EE_Transaction $transaction) {
352 352
 		 // first remove the session from the transaction before we save the transaction in the session
353
-		 $transaction->set_txn_session_data( NULL );
353
+		 $transaction->set_txn_session_data(NULL);
354 354
 		 $this->_session_data['transaction'] = $transaction;
355 355
 		 return TRUE;
356 356
 	 }
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
 	  * reset_transaction
362 362
 	  */
363 363
 	 public function reset_transaction() {
364
-		 do_action( 'AHEE__EE_Session__reset_transaction__before_reset', $this );
364
+		 do_action('AHEE__EE_Session__reset_transaction__before_reset', $this);
365 365
 		 $this->_session_data['transaction'] = NULL;
366 366
 	 }
367 367
 
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
 	  * @return \EE_Transaction
372 372
 	  */
373 373
 	 public function transaction() {
374
-		 return isset( $this->_session_data['transaction'] ) && $this->_session_data[ 'transaction' ] instanceof EE_Transaction ? $this->_session_data['transaction'] : NULL;
374
+		 return isset($this->_session_data['transaction']) && $this->_session_data['transaction'] instanceof EE_Transaction ? $this->_session_data['transaction'] : NULL;
375 375
 	 }
376 376
 
377 377
 
@@ -383,15 +383,15 @@  discard block
 block discarded – undo
383 383
 	  * @param bool $reset_cache
384 384
 	  * @return    array
385 385
 	  */
386
-	public function get_session_data( $key = NULL, $reset_cache = FALSE ) {
387
-		if ( $reset_cache ) {
386
+	public function get_session_data($key = NULL, $reset_cache = FALSE) {
387
+		if ($reset_cache) {
388 388
 			$this->reset_cart();
389 389
 			$this->reset_checkout();
390 390
 			$this->reset_transaction();
391 391
 		}
392
-		 if ( ! empty( $key ))  {
393
-			return  isset( $this->_session_data[ $key ] ) ? $this->_session_data[ $key ] : NULL;
394
-		}  else  {
392
+		 if ( ! empty($key)) {
393
+			return  isset($this->_session_data[$key]) ? $this->_session_data[$key] : NULL;
394
+		} else {
395 395
 			return $this->_session_data;
396 396
 		}
397 397
 	}
@@ -404,23 +404,23 @@  discard block
 block discarded – undo
404 404
 	  * @param 	array $data
405 405
 	  * @return 	TRUE on success, FALSE on fail
406 406
 	  */
407
-	public function set_session_data( $data ) {
407
+	public function set_session_data($data) {
408 408
 
409 409
 		// nothing ??? bad data ??? go home!
410
-		if ( empty( $data ) || ! is_array( $data )) {
411
-			EE_Error::add_error( __( 'No session data or invalid session data was provided.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
410
+		if (empty($data) || ! is_array($data)) {
411
+			EE_Error::add_error(__('No session data or invalid session data was provided.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
412 412
 			return FALSE;
413 413
 		}
414 414
 
415
-		foreach ( $data as $key =>$value ) {
416
-			if ( isset( $this->_default_session_vars[ $key ] )) {
415
+		foreach ($data as $key =>$value) {
416
+			if (isset($this->_default_session_vars[$key])) {
417 417
 				EE_Error::add_error(
418
-					sprintf( __( 'Sorry! %s is a default session datum and can not be reset.', 'event_espresso' ), $key ),
418
+					sprintf(__('Sorry! %s is a default session datum and can not be reset.', 'event_espresso'), $key),
419 419
 					__FILE__, __FUNCTION__, __LINE__
420 420
 				);
421 421
 				return FALSE;
422 422
 			} else {
423
-				$this->_session_data[ $key ] = $value;
423
+				$this->_session_data[$key] = $value;
424 424
 			}
425 425
 		}
426 426
 
@@ -437,9 +437,9 @@  discard block
 block discarded – undo
437 437
 	  * @throws \EE_Error
438 438
 	  */
439 439
 	private function _espresso_session() {
440
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
440
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
441 441
 		// check that session has started
442
-		if ( session_id() === '' ) {
442
+		if (session_id() === '') {
443 443
 			//starts a new session if one doesn't already exist, or re-initiates an existing one
444 444
 			session_start();
445 445
 		}
@@ -448,57 +448,57 @@  discard block
 block discarded – undo
448 448
 		// and the visitors IP
449 449
 		$this->_ip_address = $this->_visitor_ip();
450 450
 		// set the "user agent"
451
-		$this->_user_agent = ( isset($_SERVER['HTTP_USER_AGENT'])) ? esc_attr( $_SERVER['HTTP_USER_AGENT'] ) : FALSE;
451
+		$this->_user_agent = (isset($_SERVER['HTTP_USER_AGENT'])) ? esc_attr($_SERVER['HTTP_USER_AGENT']) : FALSE;
452 452
 		// now let's retrieve what's in the db
453 453
 		// we're using WP's Transient API to store session data using the PHP session ID as the option name
454
-		$session_data = get_transient( EE_Session::session_id_prefix . $this->_sid );
455
-		if ( $session_data ) {
456
-			if ( apply_filters( 'FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG ) ) {
457
-				$hash_check = get_transient( EE_Session::hash_check_prefix . $this->_sid );
458
-				if ( $hash_check && $hash_check !== md5( $session_data ) ) {
454
+		$session_data = get_transient(EE_Session::session_id_prefix.$this->_sid);
455
+		if ($session_data) {
456
+			if (apply_filters('FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG)) {
457
+				$hash_check = get_transient(EE_Session::hash_check_prefix.$this->_sid);
458
+				if ($hash_check && $hash_check !== md5($session_data)) {
459 459
 					EE_Error::add_error(
460 460
 						sprintf(
461
-							__( 'The stored data for session %1$s failed to pass a hash check and therefore appears to be invalid.', 'event_espresso' ),
462
-							EE_Session::session_id_prefix . $this->_sid
461
+							__('The stored data for session %1$s failed to pass a hash check and therefore appears to be invalid.', 'event_espresso'),
462
+							EE_Session::session_id_prefix.$this->_sid
463 463
 						),
464 464
 						__FILE__, __FUNCTION__, __LINE__
465 465
 					);
466 466
 				}
467 467
 			}
468 468
 			// un-encrypt the data
469
-			$session_data = $this->_use_encryption ? $this->encryption->decrypt( $session_data ) : $session_data;
469
+			$session_data = $this->_use_encryption ? $this->encryption->decrypt($session_data) : $session_data;
470 470
 			// unserialize
471
-			$session_data = maybe_unserialize( $session_data );
471
+			$session_data = maybe_unserialize($session_data);
472 472
 			// just a check to make sure the session array is indeed an array
473
-			if ( ! is_array( $session_data ) ) {
473
+			if ( ! is_array($session_data)) {
474 474
 				// no?!?! then something is wrong
475 475
 				return FALSE;
476 476
 			}
477 477
 			// get the current time in UTC
478
-			$this->_time = isset( $this->_time ) ? $this->_time : time();
478
+			$this->_time = isset($this->_time) ? $this->_time : time();
479 479
 			// and reset the session expiration
480
-			$this->_expiration = isset( $session_data['expiration'] ) ? $session_data['expiration'] : $this->_time + $this->_lifespan;
480
+			$this->_expiration = isset($session_data['expiration']) ? $session_data['expiration'] : $this->_time + $this->_lifespan;
481 481
 
482 482
 		} else {
483 483
 			// set initial site access time and the session expiration
484 484
 			$this->_set_init_access_and_expiration();
485 485
 			// set referer
486
-			$this->_session_data[ 'pages_visited' ][ $this->_session_data['init_access'] ] = isset( $_SERVER['HTTP_REFERER'] ) ? esc_attr( $_SERVER['HTTP_REFERER'] ) : '';
486
+			$this->_session_data['pages_visited'][$this->_session_data['init_access']] = isset($_SERVER['HTTP_REFERER']) ? esc_attr($_SERVER['HTTP_REFERER']) : '';
487 487
 			// no previous session = go back and create one (on top of the data above)
488 488
 			return FALSE;
489 489
 		}
490 490
 		// now the user agent
491
-		if ( $session_data['user_agent'] != $this->_user_agent ) {
491
+		if ($session_data['user_agent'] != $this->_user_agent) {
492 492
 			return FALSE;
493 493
 		}
494 494
 		// make event espresso session data available to plugin
495
-		$this->_session_data = array_merge( $this->_session_data, $session_data );
495
+		$this->_session_data = array_merge($this->_session_data, $session_data);
496 496
 		// wait a minute... how old are you?
497
-		if ( $this->_time > $this->_expiration ) {
497
+		if ($this->_time > $this->_expiration) {
498 498
 			// yer too old fer me!
499 499
 			$this->_expired = true;
500 500
 			// wipe out everything that isn't a default session datum, and set expired flag to true
501
-			$this->clear_session( __CLASS__, __FUNCTION__ );
501
+			$this->clear_session(__CLASS__, __FUNCTION__);
502 502
 		}
503 503
 		return TRUE;
504 504
 
@@ -517,12 +517,12 @@  discard block
 block discarded – undo
517 517
 	  */
518 518
 	protected function _generate_session_id() {
519 519
 		// check if the SID was passed explicitly, otherwise get from session, then add salt and hash it to reduce length
520
-		if ( isset( $_REQUEST[ 'EESID' ] ) ) {
521
-			$session_id = sanitize_text_field( $_REQUEST[ 'EESID' ] );
520
+		if (isset($_REQUEST['EESID'])) {
521
+			$session_id = sanitize_text_field($_REQUEST['EESID']);
522 522
 		} else {
523
-			$session_id = md5( session_id() . get_current_blog_id() . $this->_get_sid_salt() );
523
+			$session_id = md5(session_id().get_current_blog_id().$this->_get_sid_salt());
524 524
 		}
525
-		return apply_filters( 'FHEE__EE_Session___generate_session_id__session_id', $session_id );
525
+		return apply_filters('FHEE__EE_Session___generate_session_id__session_id', $session_id);
526 526
 	}
527 527
 
528 528
 
@@ -534,20 +534,20 @@  discard block
 block discarded – undo
534 534
 	  */
535 535
 	protected function _get_sid_salt() {
536 536
 		// was session id salt already saved to db ?
537
-		if ( empty( $this->_sid_salt ) ) {
537
+		if (empty($this->_sid_salt)) {
538 538
 			// no?  then maybe use WP defined constant
539
-			if ( defined( 'AUTH_SALT' ) ) {
539
+			if (defined('AUTH_SALT')) {
540 540
 				$this->_sid_salt = AUTH_SALT;
541 541
 			}
542 542
 			// if salt doesn't exist or is too short
543
-			if ( empty( $this->_sid_salt ) || strlen( $this->_sid_salt ) < 32 ) {
543
+			if (empty($this->_sid_salt) || strlen($this->_sid_salt) < 32) {
544 544
 				// create a new one
545
-				$this->_sid_salt = wp_generate_password( 64 );
545
+				$this->_sid_salt = wp_generate_password(64);
546 546
 			}
547 547
 			// and save it as a permanent session setting
548
-			$session_settings = get_option( 'ee_session_settings' );
549
-			$session_settings[ 'sid_salt' ] = $this->_sid_salt;
550
-			update_option( 'ee_session_settings', $session_settings );
548
+			$session_settings = get_option('ee_session_settings');
549
+			$session_settings['sid_salt'] = $this->_sid_salt;
550
+			update_option('ee_session_settings', $session_settings);
551 551
 		}
552 552
 		return $this->_sid_salt;
553 553
 	}
@@ -575,18 +575,18 @@  discard block
 block discarded – undo
575 575
 	  * @param bool $new_session
576 576
 	  * @return TRUE on success, FALSE on fail
577 577
 	  */
578
-	public function update( $new_session = FALSE ) {
579
-		$this->_session_data = isset( $this->_session_data )
580
-			&& is_array( $this->_session_data )
581
-			&& isset( $this->_session_data['id'])
578
+	public function update($new_session = FALSE) {
579
+		$this->_session_data = isset($this->_session_data)
580
+			&& is_array($this->_session_data)
581
+			&& isset($this->_session_data['id'])
582 582
 			? $this->_session_data
583 583
 			: NULL;
584
-		if ( empty( $this->_session_data )) {
584
+		if (empty($this->_session_data)) {
585 585
 			$this->_set_defaults();
586 586
 		}
587
-		foreach ( $this->_session_data as $key => $value ) {
587
+		foreach ($this->_session_data as $key => $value) {
588 588
 
589
-			switch( $key ) {
589
+			switch ($key) {
590 590
 
591 591
 				case 'id' :
592 592
 					// session ID
@@ -604,7 +604,7 @@  discard block
 block discarded – undo
604 604
 				break;
605 605
 
606 606
 				case 'init_access' :
607
-					$this->_session_data['init_access'] = absint( $value );
607
+					$this->_session_data['init_access'] = absint($value);
608 608
 				break;
609 609
 
610 610
 				case 'last_access' :
@@ -614,7 +614,7 @@  discard block
 block discarded – undo
614 614
 
615 615
 				case 'expiration' :
616 616
 					// when the session expires
617
-					$this->_session_data['expiration'] = ! empty( $this->_expiration )
617
+					$this->_session_data['expiration'] = ! empty($this->_expiration)
618 618
 						? $this->_expiration
619 619
 						: $this->_session_data['init_access'] + $this->_lifespan;
620 620
 				break;
@@ -626,11 +626,11 @@  discard block
 block discarded – undo
626 626
 
627 627
 				case 'pages_visited' :
628 628
 					$page_visit = $this->_get_page_visit();
629
-					if ( $page_visit ) {
629
+					if ($page_visit) {
630 630
 						// set pages visited where the first will be the http referrer
631
-						$this->_session_data[ 'pages_visited' ][ $this->_time ] = $page_visit;
631
+						$this->_session_data['pages_visited'][$this->_time] = $page_visit;
632 632
 						// we'll only save the last 10 page visits.
633
-						$this->_session_data[ 'pages_visited' ] = array_slice( $this->_session_data['pages_visited'], -10 );
633
+						$this->_session_data['pages_visited'] = array_slice($this->_session_data['pages_visited'], -10);
634 634
 					}
635 635
 				break;
636 636
 
@@ -638,9 +638,9 @@  discard block
 block discarded – undo
638 638
 
639 639
 		}
640 640
 		// creating a new session does not require saving to the db just yet
641
-		if ( ! $new_session ) {
641
+		if ( ! $new_session) {
642 642
 			// ready? let's save
643
-			if ( $this->_save_session_to_db() ) {
643
+			if ($this->_save_session_to_db()) {
644 644
 				return TRUE;
645 645
 			} else {
646 646
 				return FALSE;
@@ -661,9 +661,9 @@  discard block
 block discarded – undo
661 661
 	 * 	@return bool
662 662
 	 */
663 663
 	private function _create_espresso_session( ) {
664
-		do_action( 'AHEE_log', __CLASS__, __FUNCTION__, '' );
664
+		do_action('AHEE_log', __CLASS__, __FUNCTION__, '');
665 665
 		// use the update function for now with $new_session arg set to TRUE
666
-		return  $this->update( TRUE ) ? TRUE : FALSE;
666
+		return  $this->update(TRUE) ? TRUE : FALSE;
667 667
 	}
668 668
 
669 669
 
@@ -688,19 +688,19 @@  discard block
 block discarded – undo
688 688
 		}
689 689
 		EE_Registry::instance()->SSN = $this;
690 690
 		// first serialize all of our session data
691
-		$session_data = serialize( $this->_session_data );
691
+		$session_data = serialize($this->_session_data);
692 692
 		// encrypt it if we are using encryption
693
-		$session_data = $this->_use_encryption ? $this->encryption->encrypt( $session_data ) : $session_data;
693
+		$session_data = $this->_use_encryption ? $this->encryption->encrypt($session_data) : $session_data;
694 694
 		// add an hour to the session transient expiration (NOT the session expiration itself),
695 695
 		// which allows us to still retrieve expired sessions instead of having the transients deleted on us immediately,
696 696
 		// which looks no different than the session having never existed at all
697 697
 		$expiry = $this->_lifespan + HOUR_IN_SECONDS;
698 698
 		// maybe save hash check
699
-		if ( apply_filters( 'FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG ) ) {
700
-			set_transient( EE_Session::hash_check_prefix . $this->_sid, md5( $session_data ), $expiry );
699
+		if (apply_filters('FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG)) {
700
+			set_transient(EE_Session::hash_check_prefix.$this->_sid, md5($session_data), $expiry);
701 701
 		}
702 702
 		// we're using the Transient API for storing session data, cuz it's so damn simple -> set_transient(  transient ID, data, expiry )
703
-		return set_transient( EE_Session::session_id_prefix . $this->_sid, $session_data, $expiry );
703
+		return set_transient(EE_Session::session_id_prefix.$this->_sid, $session_data, $expiry);
704 704
 	}
705 705
 
706 706
 
@@ -726,10 +726,10 @@  discard block
 block discarded – undo
726 726
 			'HTTP_FORWARDED',
727 727
 			'REMOTE_ADDR'
728 728
 		);
729
-		foreach ( $server_keys as $key ){
730
-			if ( isset( $_SERVER[ $key ] )) {
731
-				foreach ( array_map( 'trim', explode( ',', $_SERVER[ $key ] )) as $ip ) {
732
-					if ( $ip === '127.0.0.1' || filter_var( $ip, FILTER_VALIDATE_IP ) !== FALSE ) {
729
+		foreach ($server_keys as $key) {
730
+			if (isset($_SERVER[$key])) {
731
+				foreach (array_map('trim', explode(',', $_SERVER[$key])) as $ip) {
732
+					if ($ip === '127.0.0.1' || filter_var($ip, FILTER_VALIDATE_IP) !== FALSE) {
733 733
 						$visitor_ip = $ip;
734 734
 					}
735 735
 				}
@@ -749,41 +749,41 @@  discard block
 block discarded – undo
749 749
 	 */
750 750
 	public function _get_page_visit() {
751 751
 
752
-				$page_visit = home_url('/') . 'wp-admin/admin-ajax.php';
752
+				$page_visit = home_url('/').'wp-admin/admin-ajax.php';
753 753
 
754 754
 		// check for request url
755
-		if ( isset( $_SERVER['REQUEST_URI'] )) {
755
+		if (isset($_SERVER['REQUEST_URI'])) {
756 756
 
757
-			$request_uri = esc_url( $_SERVER['REQUEST_URI'] );
757
+			$request_uri = esc_url($_SERVER['REQUEST_URI']);
758 758
 
759
-			$ru_bits = explode( '?', $request_uri );
759
+			$ru_bits = explode('?', $request_uri);
760 760
 			$request_uri = $ru_bits[0];
761 761
 			// check for and grab host as well
762
-			if ( isset( $_SERVER['HTTP_HOST'] )) {
763
-				$http_host = esc_url( $_SERVER['HTTP_HOST'] );
762
+			if (isset($_SERVER['HTTP_HOST'])) {
763
+				$http_host = esc_url($_SERVER['HTTP_HOST']);
764 764
 			} else {
765 765
 				$http_host = '';
766 766
 			}
767 767
 			// check for page_id in SERVER REQUEST
768
-			if ( isset( $_REQUEST['page_id'] )) {
768
+			if (isset($_REQUEST['page_id'])) {
769 769
 				// rebuild $e_reg without any of the extra parameters
770
-				$page_id = '?page_id=' . esc_attr( $_REQUEST['page_id'] ) . '&amp;';
770
+				$page_id = '?page_id='.esc_attr($_REQUEST['page_id']).'&amp;';
771 771
 			} else {
772 772
 				$page_id = '?';
773 773
 			}
774 774
 			// check for $e_reg in SERVER REQUEST
775
-			if ( isset( $_REQUEST['ee'] )) {
775
+			if (isset($_REQUEST['ee'])) {
776 776
 				// rebuild $e_reg without any of the extra parameters
777
-				$e_reg = 'ee=' . esc_attr( $_REQUEST['ee'] );
777
+				$e_reg = 'ee='.esc_attr($_REQUEST['ee']);
778 778
 			} else {
779 779
 				$e_reg = '';
780 780
 			}
781 781
 
782
-			$page_visit = rtrim( $http_host . $request_uri . $page_id . $e_reg, '?' );
782
+			$page_visit = rtrim($http_host.$request_uri.$page_id.$e_reg, '?');
783 783
 
784 784
 		}
785 785
 
786
-		return $page_visit != home_url( '/wp-admin/admin-ajax.php' ) ? $page_visit : '';
786
+		return $page_visit != home_url('/wp-admin/admin-ajax.php') ? $page_visit : '';
787 787
 
788 788
 	}
789 789
 
@@ -811,13 +811,13 @@  discard block
 block discarded – undo
811 811
 	  * @param string $class
812 812
 	  * @param string $function
813 813
 	  */
814
-	public function clear_session( $class = '', $function = '' ) {
815
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, 'session cleared by : ' . $class . '::' .  $function . '()' );
814
+	public function clear_session($class = '', $function = '') {
815
+		do_action('AHEE_log', __FILE__, __FUNCTION__, 'session cleared by : '.$class.'::'.$function.'()');
816 816
 		$this->reset_cart();
817 817
 		$this->reset_checkout();
818 818
 		$this->reset_transaction();
819 819
 		// wipe out everything that isn't a default session datum
820
-		$this->reset_data( array_keys( $this->_session_data ));
820
+		$this->reset_data(array_keys($this->_session_data));
821 821
 		// reset initial site access time and the session expiration
822 822
 		$this->_set_init_access_and_expiration();
823 823
 		$this->_save_session_to_db();
@@ -832,41 +832,41 @@  discard block
 block discarded – undo
832 832
 	  * @param bool  $show_all_notices
833 833
 	  * @return TRUE on success, FALSE on fail
834 834
 	  */
835
-	public function reset_data( $data_to_reset = array(), $show_all_notices = FALSE ) {
835
+	public function reset_data($data_to_reset = array(), $show_all_notices = FALSE) {
836 836
 		// if $data_to_reset is not in an array, then put it in one
837
-		if ( ! is_array( $data_to_reset ) ) {
838
-			$data_to_reset = array ( $data_to_reset );
837
+		if ( ! is_array($data_to_reset)) {
838
+			$data_to_reset = array($data_to_reset);
839 839
 		}
840 840
 		// nothing ??? go home!
841
-		if ( empty( $data_to_reset )) {
842
-			EE_Error::add_error( __( 'No session data could be reset, because no session var name was provided.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
841
+		if (empty($data_to_reset)) {
842
+			EE_Error::add_error(__('No session data could be reset, because no session var name was provided.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
843 843
 			return FALSE;
844 844
 		}
845 845
 		$return_value = TRUE;
846 846
 		// since $data_to_reset is an array, cycle through the values
847
-		foreach ( $data_to_reset as $reset ) {
847
+		foreach ($data_to_reset as $reset) {
848 848
 
849 849
 			// first check to make sure it is a valid session var
850
-			if ( isset( $this->_session_data[ $reset ] )) {
850
+			if (isset($this->_session_data[$reset])) {
851 851
 				// then check to make sure it is not a default var
852
-				if ( ! array_key_exists( $reset, $this->_default_session_vars )) {
852
+				if ( ! array_key_exists($reset, $this->_default_session_vars)) {
853 853
 					// remove session var
854
-					unset( $this->_session_data[ $reset ] );
855
-					if ( $show_all_notices ) {
856
-						EE_Error::add_success( sprintf( __( 'The session variable %s was removed.', 'event_espresso' ), $reset ), __FILE__, __FUNCTION__, __LINE__ );
854
+					unset($this->_session_data[$reset]);
855
+					if ($show_all_notices) {
856
+						EE_Error::add_success(sprintf(__('The session variable %s was removed.', 'event_espresso'), $reset), __FILE__, __FUNCTION__, __LINE__);
857 857
 					}
858 858
 
859 859
 				} else {
860 860
 					// yeeeeeeeeerrrrrrrrrrr OUT !!!!
861
-					if ( $show_all_notices ) {
862
-						EE_Error::add_error( sprintf( __( 'Sorry! %s is a default session datum and can not be reset.', 'event_espresso' ), $reset ), __FILE__, __FUNCTION__, __LINE__ );
861
+					if ($show_all_notices) {
862
+						EE_Error::add_error(sprintf(__('Sorry! %s is a default session datum and can not be reset.', 'event_espresso'), $reset), __FILE__, __FUNCTION__, __LINE__);
863 863
 					}
864 864
 					$return_value = FALSE;
865 865
 				}
866 866
 
867
-			} else if ( $show_all_notices ) {
867
+			} else if ($show_all_notices) {
868 868
 				// oops! that session var does not exist!
869
-				EE_Error::add_error( sprintf( __( 'The session item provided, %s, is invalid or does not exist.', 'event_espresso' ), $reset ), __FILE__, __FUNCTION__, __LINE__ );
869
+				EE_Error::add_error(sprintf(__('The session item provided, %s, is invalid or does not exist.', 'event_espresso'), $reset), __FILE__, __FUNCTION__, __LINE__);
870 870
 				$return_value = FALSE;
871 871
 			}
872 872
 
@@ -887,8 +887,8 @@  discard block
 block discarded – undo
887 887
 	 *   @return	 string
888 888
 	 */
889 889
 	public function wp_loaded() {
890
-		if ( isset(  EE_Registry::instance()->REQ ) && EE_Registry::instance()->REQ->is_set( 'clear_session' )) {
891
-			$this->clear_session( __CLASS__, __FUNCTION__ );
890
+		if (isset(EE_Registry::instance()->REQ) && EE_Registry::instance()->REQ->is_set('clear_session')) {
891
+			$this->clear_session(__CLASS__, __FUNCTION__);
892 892
 		}
893 893
 	}
894 894
 
@@ -913,24 +913,24 @@  discard block
 block discarded – undo
913 913
 	  */
914 914
 	 public function garbage_collection() {
915 915
 		 // only perform during regular requests
916
-		 if ( ! defined( 'DOING_AJAX') || ! DOING_AJAX ) {
916
+		 if ( ! defined('DOING_AJAX') || ! DOING_AJAX) {
917 917
 			 /** @type WPDB $wpdb */
918 918
 			 global $wpdb;
919 919
 			 // since transient expiration timestamps are set in the future, we can compare against NOW
920 920
 			 $expiration = time();
921
-			 $too_far_in_the_the_future = $expiration + ( $this->_lifespan * 2 ) + HOUR_IN_SECONDS;
921
+			 $too_far_in_the_the_future = $expiration + ($this->_lifespan * 2) + HOUR_IN_SECONDS;
922 922
 			 // filter the query limit. Set to 0 to turn off garbage collection
923
-			 $expired_session_transient_delete_query_limit = absint( apply_filters( 'FHEE__EE_Session__garbage_collection___expired_session_transient_delete_query_limit', 50 ));
923
+			 $expired_session_transient_delete_query_limit = absint(apply_filters('FHEE__EE_Session__garbage_collection___expired_session_transient_delete_query_limit', 50));
924 924
 			 // non-zero LIMIT means take out the trash
925
-			 if ( $expired_session_transient_delete_query_limit ) {
925
+			 if ($expired_session_transient_delete_query_limit) {
926 926
 				 //array of transient keys that require garbage collection
927 927
 				 $session_keys = array(
928 928
 					 EE_Session::session_id_prefix,
929 929
 					 EE_Session::hash_check_prefix,
930 930
 				 );
931
-				 foreach ( $session_keys as $session_key ) {
932
-					 $session_key = str_replace( '_', '\_', $session_key );
933
-					 $session_key = '\_transient\_timeout\_' . $session_key . '%';
931
+				 foreach ($session_keys as $session_key) {
932
+					 $session_key = str_replace('_', '\_', $session_key);
933
+					 $session_key = '\_transient\_timeout\_'.$session_key.'%';
934 934
 					 $SQL = "
935 935
 					SELECT option_name
936 936
 					FROM {$wpdb->options}
@@ -940,28 +940,28 @@  discard block
 block discarded – undo
940 940
 					OR option_value > {$too_far_in_the_the_future} )
941 941
 					LIMIT {$expired_session_transient_delete_query_limit}
942 942
 				";
943
-					 $expired_sessions = $wpdb->get_col( $SQL );
943
+					 $expired_sessions = $wpdb->get_col($SQL);
944 944
 					 // valid results?
945
-					 if ( ! $expired_sessions instanceof WP_Error && ! empty( $expired_sessions ) ) {
945
+					 if ( ! $expired_sessions instanceof WP_Error && ! empty($expired_sessions)) {
946 946
 						 // format array of results into something usable within the actual DELETE query's IN clause
947 947
 						 $expired = array();
948
-						 foreach ( $expired_sessions as $expired_session ) {
949
-							 $expired[ ] = "'" . $expired_session . "'";
950
-							 $expired[ ] = "'" . str_replace( 'timeout_', '', $expired_session ) . "'";
948
+						 foreach ($expired_sessions as $expired_session) {
949
+							 $expired[] = "'".$expired_session."'";
950
+							 $expired[] = "'".str_replace('timeout_', '', $expired_session)."'";
951 951
 						 }
952
-						 $expired = implode( ', ', $expired );
952
+						 $expired = implode(', ', $expired);
953 953
 						 $SQL = "
954 954
 						DELETE FROM {$wpdb->options}
955 955
 						WHERE option_name
956 956
 						IN ( $expired );
957 957
 					 ";
958
-						 $results = $wpdb->query( $SQL );
958
+						 $results = $wpdb->query($SQL);
959 959
 						 // if something went wrong, then notify the admin
960
-						 if ( $results instanceof WP_Error && is_admin() ) {
961
-							 EE_Error::add_error( $results->get_error_message(), __FILE__, __FUNCTION__, __LINE__ );
960
+						 if ($results instanceof WP_Error && is_admin()) {
961
+							 EE_Error::add_error($results->get_error_message(), __FILE__, __FUNCTION__, __LINE__);
962 962
 						 }
963 963
 					 }
964
-					 do_action( 'FHEE__EE_Session__garbage_collection___end', $expired_session_transient_delete_query_limit );
964
+					 do_action('FHEE__EE_Session__garbage_collection___end', $expired_session_transient_delete_query_limit);
965 965
 				 }
966 966
 			 }
967 967
 		 }
Please login to merge, or discard this patch.