Completed
Branch BUG-7537 (60d82a)
by
unknown
73:15 queued 56:23
created
reg_steps/payment_options/EE_SPCO_Reg_Step_Payment_Options.class.php 1 patch
Spacing   +369 added lines, -369 removed lines patch added patch discarded remove patch
@@ -28,15 +28,15 @@  discard block
 block discarded – undo
28 28
 	 *  @return 	void
29 29
 	 */
30 30
 	public static function set_hooks() {
31
-		add_filter( 'FHEE__SPCO__EE_Line_Item_Filter_Collection', array( 'EE_SPCO_Reg_Step_Payment_Options', 'add_spco_line_item_filters' ) );
32
-		add_action( 'wp_ajax_switch_spco_billing_form', array( 'EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form' ));
33
-		add_action( 'wp_ajax_nopriv_switch_spco_billing_form', array( 'EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form' ));
34
-		add_action( 'wp_ajax_save_payer_details', array( 'EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details' ));
35
-		add_action( 'wp_ajax_nopriv_save_payer_details', array( 'EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details' ));
36
-		add_action( 'wp_ajax_get_transaction_details_for_gateways', array( 'EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details' ) );
37
-		add_action( 'wp_ajax_nopriv_get_transaction_details_for_gateways', array( 'EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details' )
31
+		add_filter('FHEE__SPCO__EE_Line_Item_Filter_Collection', array('EE_SPCO_Reg_Step_Payment_Options', 'add_spco_line_item_filters'));
32
+		add_action('wp_ajax_switch_spco_billing_form', array('EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form'));
33
+		add_action('wp_ajax_nopriv_switch_spco_billing_form', array('EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form'));
34
+		add_action('wp_ajax_save_payer_details', array('EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details'));
35
+		add_action('wp_ajax_nopriv_save_payer_details', array('EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details'));
36
+		add_action('wp_ajax_get_transaction_details_for_gateways', array('EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details'));
37
+		add_action('wp_ajax_nopriv_get_transaction_details_for_gateways', array('EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details')
38 38
 		);
39
-		add_filter( 'FHEE__EED_Recaptcha___bypass_recaptcha__bypass_request_params_array', array( 'EE_SPCO_Reg_Step_Payment_Options', 'bypass_recaptcha_for_load_payment_method' ), 10, 1 );
39
+		add_filter('FHEE__EED_Recaptcha___bypass_recaptcha__bypass_request_params_array', array('EE_SPCO_Reg_Step_Payment_Options', 'bypass_recaptcha_for_load_payment_method'), 10, 1);
40 40
 	}
41 41
 
42 42
 
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 	 * 	ajax switch_spco_billing_form
46 46
 	 */
47 47
 	public static function switch_spco_billing_form() {
48
-		EED_Single_Page_Checkout::process_ajax_request( 'switch_payment_method' );
48
+		EED_Single_Page_Checkout::process_ajax_request('switch_payment_method');
49 49
 	}
50 50
 
51 51
 
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	 * 	ajax save_payer_details
55 55
 	 */
56 56
 	public static function save_payer_details() {
57
-		EED_Single_Page_Checkout::process_ajax_request( 'save_payer_details_via_ajax' );
57
+		EED_Single_Page_Checkout::process_ajax_request('save_payer_details_via_ajax');
58 58
 	}
59 59
 
60 60
 
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 	 * 	ajax get_transaction_details
64 64
 	 */
65 65
 	public static function get_transaction_details() {
66
-		EED_Single_Page_Checkout::process_ajax_request( 'get_transaction_details_for_gateways' );
66
+		EED_Single_Page_Checkout::process_ajax_request('get_transaction_details_for_gateways');
67 67
 	}
68 68
 
69 69
 
@@ -91,13 +91,13 @@  discard block
 block discarded – undo
91 91
 	 * @param    EE_Checkout $checkout
92 92
 	 * @return    \EE_SPCO_Reg_Step_Payment_Options
93 93
 	 */
94
-	public function __construct( EE_Checkout $checkout ) {
94
+	public function __construct(EE_Checkout $checkout) {
95 95
 		$this->_slug = 'payment_options';
96 96
 		$this->_name = __('Payment Options', 'event_espresso');
97
-		$this->_template = SPCO_REG_STEPS_PATH . $this->_slug . DS . 'payment_options_main.template.php';
97
+		$this->_template = SPCO_REG_STEPS_PATH.$this->_slug.DS.'payment_options_main.template.php';
98 98
 		$this->checkout = $checkout;
99 99
 		$this->_reset_success_message();
100
-		$this->set_instructions( __('Please select a method of payment and provide any necessary billing information before proceeding.', 'event_espresso'));
100
+		$this->set_instructions(__('Please select a method of payment and provide any necessary billing information before proceeding.', 'event_espresso'));
101 101
 	}
102 102
 
103 103
 
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 	/**
115 115
 	 * @param null $line_item_display
116 116
 	 */
117
-	public function set_line_item_display( $line_item_display ) {
117
+	public function set_line_item_display($line_item_display) {
118 118
 		$this->line_item_display = $line_item_display;
119 119
 	}
120 120
 
@@ -125,9 +125,9 @@  discard block
 block discarded – undo
125 125
 	 * @return void
126 126
 	 */
127 127
 	public function translate_js_strings() {
128
-		EE_Registry::$i18n_js_strings['no_payment_method'] = __( 'Please select a method of payment in order to continue.', 'event_espresso' );
129
-		EE_Registry::$i18n_js_strings['invalid_payment_method'] = __( 'A valid method of payment could not be determined. Please refresh the page and try again.', 'event_espresso' );
130
-		EE_Registry::$i18n_js_strings['forwarding_to_offsite'] = __( 'Forwarding to Secure Payment Provider.', 'event_espresso' );
128
+		EE_Registry::$i18n_js_strings['no_payment_method'] = __('Please select a method of payment in order to continue.', 'event_espresso');
129
+		EE_Registry::$i18n_js_strings['invalid_payment_method'] = __('A valid method of payment could not be determined. Please refresh the page and try again.', 'event_espresso');
130
+		EE_Registry::$i18n_js_strings['forwarding_to_offsite'] = __('Forwarding to Secure Payment Provider.', 'event_espresso');
131 131
 	}
132 132
 
133 133
 
@@ -156,20 +156,20 @@  discard block
 block discarded – undo
156 156
 			// 	$ 0.00 transactions (no payment required)
157 157
 			! $this->checkout->payment_required()
158 158
 			// but do NOT remove if current action being called belongs to this reg step
159
-			&& ! is_callable( array( $this, $this->checkout->action ) )
159
+			&& ! is_callable(array($this, $this->checkout->action))
160 160
 			&& ! $this->completed()
161 161
 		) {
162 162
 			// and if so, then we no longer need the Payment Options step
163
-			if ( $this->is_current_step() ) {
163
+			if ($this->is_current_step()) {
164 164
 				$this->checkout->generate_reg_form = false;
165 165
 			}
166
-			$this->checkout->remove_reg_step( $this->_slug );
166
+			$this->checkout->remove_reg_step($this->_slug);
167 167
 			// DEBUG LOG
168 168
 			//$this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ );
169 169
 			return false;
170 170
 		}
171 171
 		// load EEM_Payment_Method
172
-		EE_Registry::instance()->load_model( 'Payment_Method' );
172
+		EE_Registry::instance()->load_model('Payment_Method');
173 173
 		// get all active payment methods
174 174
 		$this->checkout->available_payment_methods = EEM_Payment_Method::instance()->get_all_for_transaction(
175 175
 			$this->checkout->transaction, EEM_Payment_Method::scope_cart
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 	 * @return bool
184 184
 	 */
185 185
 	public function generate_reg_form() {
186
-		EE_Registry::instance()->load_helper( 'HTML' );
186
+		EE_Registry::instance()->load_helper('HTML');
187 187
 		// reset in case someone changes their mind
188 188
 		$this->_reset_selected_method_of_payment();
189 189
 		// set some defaults
@@ -194,15 +194,15 @@  discard block
 block discarded – undo
194 194
 		$sold_out_events = array();
195 195
 		$reg_count = 0;
196 196
 		// loop thru registrations to gather info
197
-		$registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params );
198
-		foreach ( $registrations as $registration ) {
197
+		$registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
198
+		foreach ($registrations as $registration) {
199 199
 			/** @var $registration EE_Registration */
200 200
 			$reg_count++;
201 201
 			// if returning registrant is Approved then do NOT do this
202
-			if ( ! ( $this->checkout->revisit && $registration->status_ID() == EEM_Registration::status_id_approved )) {
203
-				if ( $registration->event()->is_sold_out() || $registration->event()->is_sold_out( true )) {
202
+			if ( ! ($this->checkout->revisit && $registration->status_ID() == EEM_Registration::status_id_approved)) {
203
+				if ($registration->event()->is_sold_out() || $registration->event()->is_sold_out(true)) {
204 204
 					// add event to list of events that are sold out
205
-					$sold_out_events[ $registration->event()->ID() ] = $registration->event();
205
+					$sold_out_events[$registration->event()->ID()] = $registration->event();
206 206
 					do_action(
207 207
 						'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__sold_out_event',
208 208
 						$registration->event(),
@@ -210,9 +210,9 @@  discard block
 block discarded – undo
210 210
 					);
211 211
 				}
212 212
 				// event requires admin approval
213
-				if ( $registration->status_ID() == EEM_Registration::status_id_not_approved ) {
213
+				if ($registration->status_ID() == EEM_Registration::status_id_not_approved) {
214 214
 					// add event to list of events with pre-approval reg status
215
-					$registrations_requiring_pre_approval[ $registration->ID() ] = $registration;
215
+					$registrations_requiring_pre_approval[$registration->ID()] = $registration;
216 216
 					do_action(
217 217
 						'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_pre_approval',
218 218
 						$registration->event(),
@@ -221,29 +221,29 @@  discard block
 block discarded – undo
221 221
 				}
222 222
 			}
223 223
 			// are they allowed to pay now and is there monies owing?
224
-			if ( $registration->owes_monies_and_can_pay() ) {
225
-				$registrations_requiring_payment[ $registration->ID() ] = $registration;
224
+			if ($registration->owes_monies_and_can_pay()) {
225
+				$registrations_requiring_payment[$registration->ID()] = $registration;
226 226
 				do_action(
227 227
 					'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_payment',
228 228
 					$registration->event(),
229 229
 					$this
230 230
 				);
231
-			} else if ( ! $this->checkout->revisit && $registration->status_ID() != EEM_Registration::status_id_not_approved && $registration->ticket()->is_free()  ) {
232
-				$registrations_for_free_events[ $registration->event()->ID() ] = $registration;
231
+			} else if ( ! $this->checkout->revisit && $registration->status_ID() != EEM_Registration::status_id_not_approved && $registration->ticket()->is_free()) {
232
+				$registrations_for_free_events[$registration->event()->ID()] = $registration;
233 233
 			}
234 234
 		}
235 235
 		$subsections = array();
236 236
 		// now decide which template to load
237
-		if ( ! empty( $sold_out_events )) {
238
-			$subsections['sold_out_events'] = $this->_sold_out_events( $sold_out_events );
237
+		if ( ! empty($sold_out_events)) {
238
+			$subsections['sold_out_events'] = $this->_sold_out_events($sold_out_events);
239 239
 		}
240
-		if ( ! empty( $registrations_requiring_pre_approval )) {
241
-			$subsections['registrations_requiring_pre_approval'] = $this->_registrations_requiring_pre_approval( $registrations_requiring_pre_approval );
240
+		if ( ! empty($registrations_requiring_pre_approval)) {
241
+			$subsections['registrations_requiring_pre_approval'] = $this->_registrations_requiring_pre_approval($registrations_requiring_pre_approval);
242 242
 		}
243
-		if ( ! empty( $registrations_for_free_events ) ) {
244
-			$subsections[ 'no_payment_required' ] = $this->_no_payment_required( $registrations_for_free_events );
243
+		if ( ! empty($registrations_for_free_events)) {
244
+			$subsections['no_payment_required'] = $this->_no_payment_required($registrations_for_free_events);
245 245
 		}
246
-		if ( ! empty( $registrations_requiring_payment ) ) {
246
+		if ( ! empty($registrations_requiring_payment)) {
247 247
 			// autoload Line_Item_Display classes
248 248
 			EEH_Autoloader::register_line_item_filter_autoloaders();
249 249
 			$line_item_filter_processor = new EE_Line_Item_Filter_Processor(
@@ -254,17 +254,17 @@  discard block
 block discarded – undo
254 254
 				$this->checkout->cart->get_grand_total()
255 255
 			);
256 256
 			$filtered_line_item_tree = $line_item_filter_processor->process();
257
-			if ( $this->checkout->amount_owing > 0 ) {
257
+			if ($this->checkout->amount_owing > 0) {
258 258
 				EEH_Autoloader::register_line_item_display_autoloaders();
259
-				$this->set_line_item_display( new EE_Line_Item_Display( 'spco' ) );
260
-				$subsections[ 'payment_options' ] = $this->_display_payment_options(
259
+				$this->set_line_item_display(new EE_Line_Item_Display('spco'));
260
+				$subsections['payment_options'] = $this->_display_payment_options(
261 261
 					$this->line_item_display->display_line_item(
262 262
 						$filtered_line_item_tree,
263
-						array( 'registrations' => $registrations )
263
+						array('registrations' => $registrations)
264 264
 					)
265 265
 				);
266 266
 				$this->checkout->amount_owing = $filtered_line_item_tree->total();
267
-				$this->_apply_registration_payments_to_amount_owing( $registrations );
267
+				$this->_apply_registration_payments_to_amount_owing($registrations);
268 268
 			}
269 269
 		} else {
270 270
 			$this->_hide_reg_step_submit_button_if_revisit();
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
 	 * @param \EE_Line_Item_Filter_Collection $line_item_filter_collection
298 298
 	 * @return \EE_Line_Item_Filter_Collection
299 299
 	 */
300
-	public static function add_spco_line_item_filters( EE_Line_Item_Filter_Collection $line_item_filter_collection ) {
300
+	public static function add_spco_line_item_filters(EE_Line_Item_Filter_Collection $line_item_filter_collection) {
301 301
 		$line_item_filter_collection->add(
302 302
 			new EE_Billable_Line_Item_Filter(
303 303
 				EE_Registry::instance()->SSN->checkout()->transaction->registrations(
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
 				)
306 306
 			)
307 307
 		);
308
-		$line_item_filter_collection->add( new EE_Non_Zero_Line_Item_Filter() );
308
+		$line_item_filter_collection->add(new EE_Non_Zero_Line_Item_Filter());
309 309
 		return $line_item_filter_collection;
310 310
 	}
311 311
 
@@ -319,8 +319,8 @@  discard block
 block discarded – undo
319 319
 	 * @return void
320 320
 	 */
321 321
 	protected function _hide_reg_step_submit_button_if_revisit() {
322
-		if ( $this->checkout->revisit ) {
323
-			add_filter( 'FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', '__return_empty_string' );
322
+		if ($this->checkout->revisit) {
323
+			add_filter('FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', '__return_empty_string');
324 324
 		}
325 325
 	}
326 326
 
@@ -331,12 +331,12 @@  discard block
 block discarded – undo
331 331
 	 * @param \EE_Event[] $sold_out_events_array
332 332
 	 * @return \EE_Form_Section_Proper
333 333
 	 */
334
-	private function _sold_out_events( $sold_out_events_array = array() ) {
334
+	private function _sold_out_events($sold_out_events_array = array()) {
335 335
 		// set some defaults
336 336
 		$this->checkout->selected_method_of_payment = 'events_sold_out';
337 337
 		$sold_out_events = '';
338
-		foreach ( $sold_out_events_array as $sold_out_event ) {
339
-			$sold_out_events .= EEH_HTML::li( EEH_HTML::span( $sold_out_event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text' ));
338
+		foreach ($sold_out_events_array as $sold_out_event) {
339
+			$sold_out_events .= EEH_HTML::li(EEH_HTML::span($sold_out_event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text'));
340 340
 		}
341 341
 		return new EE_Form_Section_Proper(
342 342
 			array(
@@ -348,14 +348,14 @@  discard block
 block discarded – undo
348 348
 				),
349 349
 				'layout_strategy'		=> new EE_Template_Layout(
350 350
 					array(
351
-						'layout_template_file' 	=> SPCO_REG_STEPS_PATH . $this->_slug . DS . 'sold_out_events.template.php', // layout_template
351
+						'layout_template_file' 	=> SPCO_REG_STEPS_PATH.$this->_slug.DS.'sold_out_events.template.php', // layout_template
352 352
 						'template_args'  				=> apply_filters(
353 353
 							'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__template_args',
354 354
 							array(
355 355
 								'sold_out_events' 			=> $sold_out_events,
356 356
 								'sold_out_events_msg' 	=> apply_filters(
357 357
 									'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__sold_out_events_msg',
358
-									__( 'It appears that the event you were about to make a payment for has sold out since you first registered. If you have already made a partial payment towards this event, please contact the event administrator for a refund.', 'event_espresso' )
358
+									__('It appears that the event you were about to make a payment for has sold out since you first registered. If you have already made a partial payment towards this event, please contact the event administrator for a refund.', 'event_espresso')
359 359
 								)
360 360
 							)
361 361
 						)
@@ -372,14 +372,14 @@  discard block
 block discarded – undo
372 372
 	 * @param array $registrations_requiring_pre_approval
373 373
 	 * @return \EE_Form_Section_Proper
374 374
 	 */
375
-	private function _registrations_requiring_pre_approval( $registrations_requiring_pre_approval = array()) {
375
+	private function _registrations_requiring_pre_approval($registrations_requiring_pre_approval = array()) {
376 376
 		$events_requiring_pre_approval = '';
377
-		foreach ( $registrations_requiring_pre_approval as $registration ) {
378
-			if ( $registration instanceof EE_Registration && $registration->event() instanceof EE_Event ) {
379
-				$events_requiring_pre_approval[ $registration->event()->ID() ] = EEH_HTML::li(
380
-					EEH_HTML::span( '', '', 'dashicons dashicons-marker ee-icon-size-16 orange-text'
377
+		foreach ($registrations_requiring_pre_approval as $registration) {
378
+			if ($registration instanceof EE_Registration && $registration->event() instanceof EE_Event) {
379
+				$events_requiring_pre_approval[$registration->event()->ID()] = EEH_HTML::li(
380
+					EEH_HTML::span('', '', 'dashicons dashicons-marker ee-icon-size-16 orange-text'
381 381
 					)
382
-					. EEH_HTML::span( $registration->event()->name(), '', 'orange-text' )
382
+					. EEH_HTML::span($registration->event()->name(), '', 'orange-text')
383 383
 				);
384 384
 			}
385 385
 		}
@@ -391,14 +391,14 @@  discard block
 block discarded – undo
391 391
 				),
392 392
 				'layout_strategy'		=> new EE_Template_Layout(
393 393
 					array(
394
-						'layout_template_file' 	=> SPCO_REG_STEPS_PATH . $this->_slug . DS . 'events_requiring_pre_approval.template.php', // layout_template
394
+						'layout_template_file' 	=> SPCO_REG_STEPS_PATH.$this->_slug.DS.'events_requiring_pre_approval.template.php', // layout_template
395 395
 						'template_args'  				=> apply_filters(
396 396
 							'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__template_args',
397 397
 							array(
398
-								'events_requiring_pre_approval' 			=> implode( '', $events_requiring_pre_approval ),
398
+								'events_requiring_pre_approval' 			=> implode('', $events_requiring_pre_approval),
399 399
 								'events_requiring_pre_approval_msg' 	=> apply_filters(
400 400
 									'FHEE__EE_SPCO_Reg_Step_Payment_Options___events_requiring_pre_approval__events_requiring_pre_approval_msg',
401
-									__( 'The following events do not require payment at this time and will not be billed during this transaction. Billing will only occur after the attendee has been approved by the event organizer. You will be notified when your registration has been processed. If this is a free event, then no billing will occur.', 'event_espresso' )
401
+									__('The following events do not require payment at this time and will not be billed during this transaction. Billing will only occur after the attendee has been approved by the event organizer. You will be notified when your registration has been processed. If this is a free event, then no billing will occur.', 'event_espresso')
402 402
 								)
403 403
 							)
404 404
 						),
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
 	 * @param \EE_Event[] $registrations_for_free_events
417 417
 	 * @return \EE_Form_Section_Proper
418 418
 	 */
419
-	private function _no_payment_required( $registrations_for_free_events = array() ) {
419
+	private function _no_payment_required($registrations_for_free_events = array()) {
420 420
 		// set some defaults
421 421
 		$this->checkout->selected_method_of_payment = 'no_payment_required';
422 422
 		// generate no_payment_required form
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
 				),
429 429
 				'layout_strategy' 	=> new EE_Template_Layout(
430 430
 					array(
431
-						'layout_template_file' 	=> SPCO_REG_STEPS_PATH . $this->_slug . DS . 'no_payment_required.template.php', // layout_template
431
+						'layout_template_file' 	=> SPCO_REG_STEPS_PATH.$this->_slug.DS.'no_payment_required.template.php', // layout_template
432 432
 						'template_args'  				=> apply_filters(
433 433
 							'FHEE__EE_SPCO_Reg_Step_Payment_Options___no_payment_required__template_args',
434 434
 							array(
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
 								'registrations' => array(),
437 437
 								'ticket_count' 	=> array(),
438 438
 								'registrations_for_free_events' 	=> $registrations_for_free_events,
439
-								'no_payment_required_msg' => EEH_HTML::p( __( 'This is a free event, so no billing will occur.', 'event_espresso' ))
439
+								'no_payment_required_msg' => EEH_HTML::p(__('This is a free event, so no billing will occur.', 'event_espresso'))
440 440
 							)
441 441
 						),
442 442
 					)
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
 	 * @param string $transaction_details
454 454
 	 * @return \EE_Form_Section_Proper
455 455
 	 */
456
-	private function _display_payment_options( $transaction_details = '' ) {
456
+	private function _display_payment_options($transaction_details = '') {
457 457
 		// has method_of_payment been set by no-js user?
458 458
 		$this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment();
459 459
 		// build payment options form
@@ -465,20 +465,20 @@  discard block
 block discarded – undo
465 465
 						'before_payment_options' => apply_filters(
466 466
 							'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__before_payment_options',
467 467
 							new EE_Form_Section_Proper(
468
-								array( 'layout_strategy'	=> new EE_Div_Per_Section_Layout() )
468
+								array('layout_strategy'	=> new EE_Div_Per_Section_Layout())
469 469
 							)
470 470
 						),
471 471
 						'payment_options' => $this->_setup_payment_options(),
472 472
 						'after_payment_options' => apply_filters(
473 473
 							'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__after_payment_options',
474 474
 							new EE_Form_Section_Proper(
475
-								array( 'layout_strategy'	=> new EE_Div_Per_Section_Layout() )
475
+								array('layout_strategy'	=> new EE_Div_Per_Section_Layout())
476 476
 							)
477 477
 						),
478 478
 						'default_hidden_inputs' => $this->reg_step_hidden_inputs(),
479
-						'extra_hidden_inputs' 	=> $this->_extra_hidden_inputs( FALSE )
479
+						'extra_hidden_inputs' 	=> $this->_extra_hidden_inputs(FALSE)
480 480
 					),
481
-					'layout_strategy'	=> new EE_Template_Layout( array(
481
+					'layout_strategy'	=> new EE_Template_Layout(array(
482 482
 							'layout_template_file' 	=> $this->_template,
483 483
 							'template_args'  				=> apply_filters(
484 484
 								'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__template_args',
@@ -502,11 +502,11 @@  discard block
 block discarded – undo
502 502
 	 * @param bool $no_payment_required
503 503
 	 * @return \EE_Form_Section_Proper
504 504
 	 */
505
-	private function _extra_hidden_inputs( $no_payment_required = TRUE ) {
505
+	private function _extra_hidden_inputs($no_payment_required = TRUE) {
506 506
 
507 507
 		return new EE_Form_Section_Proper(
508 508
 			array(
509
-				'html_id' 				=> 'ee-' . $this->slug() . '-extra-hidden-inputs',
509
+				'html_id' 				=> 'ee-'.$this->slug().'-extra-hidden-inputs',
510 510
 				'layout_strategy'	=> new EE_Div_Per_Section_Layout(),
511 511
 				'subsections' 		=> array(
512 512
 					'spco_no_payment_required' => new EE_Hidden_Input(
@@ -539,16 +539,16 @@  discard block
 block discarded – undo
539 539
 	 * @access    protected
540 540
 	 * @return    void
541 541
 	 */
542
-	protected function _apply_registration_payments_to_amount_owing( $registrations ) {
542
+	protected function _apply_registration_payments_to_amount_owing($registrations) {
543 543
 		$payments = array();
544
-		foreach ( $registrations as $registration ) {
545
-			if ( $registration instanceof EE_Registration && $registration->owes_monies_and_can_pay() ) {
544
+		foreach ($registrations as $registration) {
545
+			if ($registration instanceof EE_Registration && $registration->owes_monies_and_can_pay()) {
546 546
 				$payments = $payments + $registration->registration_payments();
547 547
 			}
548 548
 		}
549
-		if ( ! empty( $payments ) ) {
550
-			foreach ( $payments as $payment ) {
551
-				if ( $payment instanceof EE_Registration_Payment ) {
549
+		if ( ! empty($payments)) {
550
+			foreach ($payments as $payment) {
551
+				if ($payment instanceof EE_Registration_Payment) {
552 552
 					$this->checkout->amount_owing -= $payment->amount();
553 553
 				}
554 554
 			}
@@ -563,9 +563,9 @@  discard block
 block discarded – undo
563 563
 	 * @param 	bool $force_reset
564 564
 	 * @return 	void
565 565
 	 */
566
-	private function _reset_selected_method_of_payment( $force_reset = FALSE ) {
567
-		$reset_payment_method = $force_reset ? TRUE : sanitize_text_field( EE_Registry::instance()->REQ->get( 'reset_payment_method', FALSE ));
568
-		if ( $reset_payment_method ) {
566
+	private function _reset_selected_method_of_payment($force_reset = FALSE) {
567
+		$reset_payment_method = $force_reset ? TRUE : sanitize_text_field(EE_Registry::instance()->REQ->get('reset_payment_method', FALSE));
568
+		if ($reset_payment_method) {
569 569
 			$this->checkout->selected_method_of_payment = NULL;
570 570
 			$this->checkout->payment_method = NULL;
571 571
 			$this->checkout->billing_form = NULL;
@@ -584,9 +584,9 @@  discard block
 block discarded – undo
584 584
 	 * @param string $selected_method_of_payment
585 585
 	 * 	@return 		EE_Billing_Info_Form
586 586
 	 */
587
-	private function _save_selected_method_of_payment( $selected_method_of_payment = '' ) {
588
-		$selected_method_of_payment = ! empty( $selected_method_of_payment ) ? $selected_method_of_payment : $this->checkout->selected_method_of_payment;
589
-		EE_Registry::instance()->SSN->set_session_data( array( 'selected_method_of_payment' => $selected_method_of_payment ));
587
+	private function _save_selected_method_of_payment($selected_method_of_payment = '') {
588
+		$selected_method_of_payment = ! empty($selected_method_of_payment) ? $selected_method_of_payment : $this->checkout->selected_method_of_payment;
589
+		EE_Registry::instance()->SSN->set_session_data(array('selected_method_of_payment' => $selected_method_of_payment));
590 590
 	}
591 591
 
592 592
 
@@ -599,40 +599,40 @@  discard block
 block discarded – undo
599 599
 		// load payment method classes
600 600
 		$this->checkout->available_payment_methods = $this->_get_available_payment_methods();
601 601
 		// switch up header depending on number of available payment methods
602
-		$payment_method_header = count( $this->checkout->available_payment_methods ) > 1
603
-			? apply_filters( 'FHEE__registration_page_payment_options__method_of_payment_hdr', __( 'Please Select Your Method of Payment', 'event_espresso' ))
604
-			: apply_filters( 'FHEE__registration_page_payment_options__method_of_payment_hdr', __( 'Method of Payment', 'event_espresso' ));
602
+		$payment_method_header = count($this->checkout->available_payment_methods) > 1
603
+			? apply_filters('FHEE__registration_page_payment_options__method_of_payment_hdr', __('Please Select Your Method of Payment', 'event_espresso'))
604
+			: apply_filters('FHEE__registration_page_payment_options__method_of_payment_hdr', __('Method of Payment', 'event_espresso'));
605 605
 		$available_payment_methods = array(
606 606
 			// display the "Payment Method" header
607 607
 			'payment_method_header' => new EE_Form_Section_HTML(
608
-				EEH_HTML::h4 ( $payment_method_header, 'method-of-payment-hdr' )
608
+				EEH_HTML::h4($payment_method_header, 'method-of-payment-hdr')
609 609
 			)
610 610
 		);
611 611
 		// the list of actual payment methods ( invoice, paypal, etc ) in a  ( slug => HTML )  format
612 612
 		$available_payment_method_options = array();
613 613
 		$default_payment_method_option = array();
614 614
 		// additional instructions to be displayed and hidden below payment methods (adding a clearing div to start)
615
-		$payment_methods_billing_info = array( new EE_Form_Section_HTML( EEH_HTML::div ( '<br />', '', '', 'clear:both;' )));
615
+		$payment_methods_billing_info = array(new EE_Form_Section_HTML(EEH_HTML::div('<br />', '', '', 'clear:both;')));
616 616
 		// loop through payment methods
617
-		foreach( $this->checkout->available_payment_methods as $payment_method ) {
618
-			if ( $payment_method instanceof EE_Payment_Method ) {
619
-				$payment_method_button = EEH_HTML::img( $payment_method->button_url(), $payment_method->name(), 'spco-payment-method-' . $payment_method->slug() . '-btn-img', 'spco-payment-method-btn-img' );
617
+		foreach ($this->checkout->available_payment_methods as $payment_method) {
618
+			if ($payment_method instanceof EE_Payment_Method) {
619
+				$payment_method_button = EEH_HTML::img($payment_method->button_url(), $payment_method->name(), 'spco-payment-method-'.$payment_method->slug().'-btn-img', 'spco-payment-method-btn-img');
620 620
 				// check if any payment methods are set as default
621 621
 				// if payment method is already selected OR nothing is selected and this payment method should be open_by_default
622
-				if (( $this->checkout->selected_method_of_payment == $payment_method->slug() ) || ( ! $this->checkout->selected_method_of_payment && $payment_method->open_by_default() )) {
622
+				if (($this->checkout->selected_method_of_payment == $payment_method->slug()) || ( ! $this->checkout->selected_method_of_payment && $payment_method->open_by_default())) {
623 623
 					$this->checkout->selected_method_of_payment = $payment_method->slug();
624 624
 					$this->_save_selected_method_of_payment();
625
-					$default_payment_method_option[ $payment_method->slug() ] =  $payment_method_button;
625
+					$default_payment_method_option[$payment_method->slug()] = $payment_method_button;
626 626
 				} else {
627
-					$available_payment_method_options[ $payment_method->slug() ] =  $payment_method_button;
627
+					$available_payment_method_options[$payment_method->slug()] = $payment_method_button;
628 628
 				}
629
-				$payment_methods_billing_info[ $payment_method->slug() . '-info' ] = $this->_payment_method_billing_info( $payment_method );
629
+				$payment_methods_billing_info[$payment_method->slug().'-info'] = $this->_payment_method_billing_info($payment_method);
630 630
 			}
631 631
 		}
632 632
 		// prepend available_payment_method_options with default_payment_method_option so that it appears first in list of PMs
633 633
 		$available_payment_method_options = $default_payment_method_option + $available_payment_method_options;
634 634
 		// now generate the actual form  inputs
635
-		$available_payment_methods['available_payment_methods'] = $this->_available_payment_method_inputs( $available_payment_method_options );
635
+		$available_payment_methods['available_payment_methods'] = $this->_available_payment_method_inputs($available_payment_method_options);
636 636
 		$available_payment_methods = $available_payment_methods + $payment_methods_billing_info;
637 637
 
638 638
 		// build the available payment methods form
@@ -652,19 +652,19 @@  discard block
 block discarded – undo
652 652
 	 * @return EE_Payment_Method[]
653 653
 	 */
654 654
 	protected function _get_available_payment_methods() {
655
-		if ( ! empty( $this->checkout->available_payment_methods )) {
655
+		if ( ! empty($this->checkout->available_payment_methods)) {
656 656
 			return $this->checkout->available_payment_methods;
657 657
 		}
658 658
 		$available_payment_methods = array();
659 659
 		// load EEM_Payment_Method
660
-		EE_Registry::instance()->load_model( 'Payment_Method' );
660
+		EE_Registry::instance()->load_model('Payment_Method');
661 661
 		/** @type EEM_Payment_Method $EEM_Payment_Method */
662 662
 		$EEM_Payment_Method = EE_Registry::instance()->LIB->EEM_Payment_Method;
663 663
 		// get all active payment methods
664
-		$payment_methods = $EEM_Payment_Method->get_all_for_transaction( $this->checkout->transaction, EEM_Payment_Method::scope_cart );
665
-		foreach ( $payment_methods as $payment_method ) {
666
-			if ( $payment_method instanceof EE_Payment_Method ) {
667
-				$available_payment_methods[ $payment_method->slug() ] = $payment_method;
664
+		$payment_methods = $EEM_Payment_Method->get_all_for_transaction($this->checkout->transaction, EEM_Payment_Method::scope_cart);
665
+		foreach ($payment_methods as $payment_method) {
666
+			if ($payment_method instanceof EE_Payment_Method) {
667
+				$available_payment_methods[$payment_method->slug()] = $payment_method;
668 668
 			}
669 669
 		}
670 670
 		return $available_payment_methods;
@@ -680,14 +680,14 @@  discard block
 block discarded – undo
680 680
 	 * @param 	array $available_payment_method_options
681 681
 	 * @return 	\EE_Form_Section_Proper
682 682
 	 */
683
-	private function _available_payment_method_inputs( $available_payment_method_options = array() ) {
683
+	private function _available_payment_method_inputs($available_payment_method_options = array()) {
684 684
 		// generate inputs
685 685
 		return new EE_Form_Section_Proper(
686 686
 			array(
687 687
 				'html_id' 				=> 'ee-available-payment-method-inputs',
688 688
 				'layout_strategy'	=> new EE_Div_Per_Section_Layout(),
689 689
 				'subsections' 		=> array(
690
-					'' => new EE_Radio_Button_Input (
690
+					'' => new EE_Radio_Button_Input(
691 691
 						$available_payment_method_options,
692 692
 						array(
693 693
 							'html_name' 				=> 'selected_method_of_payment',
@@ -711,36 +711,36 @@  discard block
 block discarded – undo
711 711
 	 * @param 	EE_Payment_Method $payment_method
712 712
 	 * @return 	\EE_Form_Section_Proper
713 713
 	 */
714
-	private function _payment_method_billing_info( EE_Payment_Method $payment_method ) {
714
+	private function _payment_method_billing_info(EE_Payment_Method $payment_method) {
715 715
 		$currently_selected = $this->checkout->selected_method_of_payment == $payment_method->slug() ? TRUE : FALSE;
716 716
 		// generate the billing form for payment method
717
-		$billing_form = $currently_selected ? $this->_get_billing_form_for_payment_method( $payment_method ) : new EE_Form_Section_HTML();
717
+		$billing_form = $currently_selected ? $this->_get_billing_form_for_payment_method($payment_method) : new EE_Form_Section_HTML();
718 718
 		$this->checkout->billing_form = $currently_selected ? $billing_form : $this->checkout->billing_form;
719 719
 		// it's all in the details
720
-		$info_html = EEH_HTML::h3 ( __( 'Important information regarding your payment', 'event_espresso' ), '', 'spco-payment-method-hdr' );
720
+		$info_html = EEH_HTML::h3(__('Important information regarding your payment', 'event_espresso'), '', 'spco-payment-method-hdr');
721 721
 		// add some info regarding the step, either from what's saved in the admin, or a default string depending on whether the PM has a billing form or not
722
-		if ( $payment_method->description() ) {
722
+		if ($payment_method->description()) {
723 723
 			$payment_method_info = $payment_method->description();
724
-		} elseif ( $billing_form instanceof EE_Billing_Info_Form ) {
725
-			$payment_method_info = sprintf( __( 'Please provide the following billing information, then click the "%1$s" button below in order to proceed.', 'event_espresso' ), $this->submit_button_text() );
724
+		} elseif ($billing_form instanceof EE_Billing_Info_Form) {
725
+			$payment_method_info = sprintf(__('Please provide the following billing information, then click the "%1$s" button below in order to proceed.', 'event_espresso'), $this->submit_button_text());
726 726
 		} else {
727
-			$payment_method_info = sprintf( __( 'Please click the "%1$s" button below in order to proceed.', 'event_espresso' ), $this->submit_button_text() );
727
+			$payment_method_info = sprintf(__('Please click the "%1$s" button below in order to proceed.', 'event_espresso'), $this->submit_button_text());
728 728
 		}
729
-		$info_html .= EEH_HTML::p (
730
-			apply_filters( 'FHEE__EE_SPCO_Reg_Step_Payment_Options___payment_method_billing_info__payment_method_info', $payment_method_info ),
729
+		$info_html .= EEH_HTML::p(
730
+			apply_filters('FHEE__EE_SPCO_Reg_Step_Payment_Options___payment_method_billing_info__payment_method_info', $payment_method_info),
731 731
 			'',
732 732
 			'spco-payment-method-desc ee-attention'
733 733
 		);
734 734
 
735 735
 		return new EE_Form_Section_Proper(
736 736
 			array(
737
-				'html_id' 					=> 'spco-payment-method-info-' . $payment_method->slug(),
737
+				'html_id' 					=> 'spco-payment-method-info-'.$payment_method->slug(),
738 738
 				'html_class' 			=> 'spco-payment-method-info-dv',
739 739
 				// only display the selected or default PM
740 740
 				'html_style' 			=> $currently_selected ? '' : 'display:none;',
741 741
 				'layout_strategy'		=> new EE_Div_Per_Section_Layout(),
742 742
 				'subsections' 			=> array(
743
-					'info' 					=> new EE_Form_Section_HTML( $info_html ),
743
+					'info' 					=> new EE_Form_Section_HTML($info_html),
744 744
 					'billing_form' 		=> $currently_selected ? $billing_form : new EE_Form_Section_HTML()
745 745
 				)
746 746
 			)
@@ -758,12 +758,12 @@  discard block
 block discarded – undo
758 758
 	 */
759 759
 	public function get_billing_form_html_for_payment_method() {
760 760
 		// how have they chosen to pay?
761
-		$this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( TRUE );
761
+		$this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(TRUE);
762 762
 		$this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment();
763
-		if ( ! $this->checkout->payment_method instanceof EE_Payment_Method ) {
763
+		if ( ! $this->checkout->payment_method instanceof EE_Payment_Method) {
764 764
 			return FALSE;
765 765
 		}
766
-		if ( apply_filters( 'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', false ) ) {
766
+		if (apply_filters('FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', false)) {
767 767
             EE_Error::add_success(
768 768
                 apply_filters(
769 769
                     'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method',
@@ -772,20 +772,20 @@  discard block
 block discarded – undo
772 772
             );
773 773
         }
774 774
 		// now generate billing form for selected method of payment
775
-		$payment_method_billing_form = $this->_get_billing_form_for_payment_method( $this->checkout->payment_method );
775
+		$payment_method_billing_form = $this->_get_billing_form_for_payment_method($this->checkout->payment_method);
776 776
 		// fill form with attendee info if applicable
777
-		if ( $payment_method_billing_form instanceof EE_Billing_Attendee_Info_Form && $this->checkout->transaction_has_primary_registrant() ) {
778
-			$payment_method_billing_form->populate_from_attendee( $this->checkout->transaction->primary_registration()->attendee() );
777
+		if ($payment_method_billing_form instanceof EE_Billing_Attendee_Info_Form && $this->checkout->transaction_has_primary_registrant()) {
778
+			$payment_method_billing_form->populate_from_attendee($this->checkout->transaction->primary_registration()->attendee());
779 779
 		}
780 780
 		// and debug content
781
-		if ( $payment_method_billing_form instanceof EE_Billing_Info_Form && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base ) {
782
-			$payment_method_billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings( $payment_method_billing_form );
781
+		if ($payment_method_billing_form instanceof EE_Billing_Info_Form && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base) {
782
+			$payment_method_billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings($payment_method_billing_form);
783 783
 		}
784 784
 		$billing_info = $payment_method_billing_form instanceof EE_Form_Section_Proper ? $payment_method_billing_form->get_html() : '';
785
-		$this->checkout->json_response->set_return_data( array( 'payment_method_info' => $billing_info ));
785
+		$this->checkout->json_response->set_return_data(array('payment_method_info' => $billing_info));
786 786
 		// localize validation rules for main form
787 787
 		$this->checkout->current_step->reg_form->localize_validation_rules();
788
-		$this->checkout->json_response->add_validation_rules( EE_Form_Section_Proper::js_localization() );
788
+		$this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization());
789 789
 		return TRUE;
790 790
 	}
791 791
 
@@ -798,15 +798,15 @@  discard block
 block discarded – undo
798 798
 	 * @param EE_Payment_Method $payment_method
799 799
 	 * @return \EE_Billing_Info_Form
800 800
 	 */
801
-	private function _get_billing_form_for_payment_method( EE_Payment_Method $payment_method ) {
802
-		$billing_form = $payment_method->type_obj()->billing_form( $this->checkout->transaction, array( 'amount_owing' => $this->checkout->amount_owing ) );
803
-		if ( $billing_form instanceof EE_Billing_Info_Form ) {
804
-			if ( EE_Registry::instance()->REQ->is_set( 'payment_method' )) {
805
-                if ( apply_filters('FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', false )) {
801
+	private function _get_billing_form_for_payment_method(EE_Payment_Method $payment_method) {
802
+		$billing_form = $payment_method->type_obj()->billing_form($this->checkout->transaction, array('amount_owing' => $this->checkout->amount_owing));
803
+		if ($billing_form instanceof EE_Billing_Info_Form) {
804
+			if (EE_Registry::instance()->REQ->is_set('payment_method')) {
805
+                if (apply_filters('FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', false)) {
806 806
                     EE_Error::add_success(
807 807
                         apply_filters(
808 808
                             'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method',
809
-                            sprintf( __( 'You have selected "%s" as your method of payment. Please note the important payment information below.', 'event_espresso' ), $payment_method->name() )
809
+                            sprintf(__('You have selected "%s" as your method of payment. Please note the important payment information below.', 'event_espresso'), $payment_method->name())
810 810
                         )
811 811
                     );
812 812
                 }
@@ -831,27 +831,27 @@  discard block
 block discarded – undo
831 831
 	 * @param string 		$request_param
832 832
 	 * @return NULL|string
833 833
 	 */
834
-	private function _get_selected_method_of_payment( $required = FALSE, $request_param = 'selected_method_of_payment' ) {
834
+	private function _get_selected_method_of_payment($required = FALSE, $request_param = 'selected_method_of_payment') {
835 835
 		// is selected_method_of_payment set in the request ?
836
-		$selected_method_of_payment = EE_Registry::instance()->REQ->get( $request_param, FALSE );
837
-		if ( $selected_method_of_payment ) {
836
+		$selected_method_of_payment = EE_Registry::instance()->REQ->get($request_param, FALSE);
837
+		if ($selected_method_of_payment) {
838 838
 			// sanitize it
839
-			$selected_method_of_payment = is_array( $selected_method_of_payment ) ? array_shift( $selected_method_of_payment ) : $selected_method_of_payment;
840
-			$selected_method_of_payment = sanitize_text_field( $selected_method_of_payment );
839
+			$selected_method_of_payment = is_array($selected_method_of_payment) ? array_shift($selected_method_of_payment) : $selected_method_of_payment;
840
+			$selected_method_of_payment = sanitize_text_field($selected_method_of_payment);
841 841
 			// store it in the session so that it's available for all subsequent requests including AJAX
842
-			$this->_save_selected_method_of_payment( $selected_method_of_payment );
842
+			$this->_save_selected_method_of_payment($selected_method_of_payment);
843 843
 		} else {
844 844
 			// or is is set in the session ?
845
-			$selected_method_of_payment = EE_Registry::instance()->SSN->get_session_data( 'selected_method_of_payment' );
845
+			$selected_method_of_payment = EE_Registry::instance()->SSN->get_session_data('selected_method_of_payment');
846 846
 		}
847 847
 		// do ya really really gotta have it?
848
-		if ( empty( $selected_method_of_payment ) && $required ) {
848
+		if (empty($selected_method_of_payment) && $required) {
849 849
 			EE_Error::add_error(
850 850
 				sprintf(
851
-					__( 'The selected method of payment could not be determined.%sPlease ensure that you have selected one before proceeding.%sIf you continue to experience difficulties, then refresh your browser and try again, or contact %s for assistance.', 'event_espresso' ),
851
+					__('The selected method of payment could not be determined.%sPlease ensure that you have selected one before proceeding.%sIf you continue to experience difficulties, then refresh your browser and try again, or contact %s for assistance.', 'event_espresso'),
852 852
 					'<br/>',
853 853
 					'<br/>',
854
-					EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
854
+					EE_Registry::instance()->CFG->organization->get_pretty('email')
855 855
 				),
856 856
 				__FILE__, __FUNCTION__, __LINE__
857 857
 			);
@@ -877,37 +877,37 @@  discard block
 block discarded – undo
877 877
 	 * @return string
878 878
 	 */
879 879
 	public function switch_payment_method() {
880
-		if ( ! $this->_verify_payment_method_is_set() ) {
880
+		if ( ! $this->_verify_payment_method_is_set()) {
881 881
 			return FALSE;
882 882
 		}
883
-		if ( apply_filters( 'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', false ) ) {
883
+		if (apply_filters('FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', false)) {
884 884
 			EE_Error::add_success(
885 885
 				apply_filters(
886 886
 					'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method',
887
-					sprintf( __( 'You have selected "%s" as your method of payment. Please note the important payment information below.', 'event_espresso' ), $this->checkout->payment_method->name() )
887
+					sprintf(__('You have selected "%s" as your method of payment. Please note the important payment information below.', 'event_espresso'), $this->checkout->payment_method->name())
888 888
 				)
889 889
 			);
890 890
 		}
891 891
 		// generate billing form for selected method of payment if it hasn't been done already
892
-		if ( $this->checkout->payment_method->type_obj()->has_billing_form() ) {
893
-			$this->checkout->billing_form = $this->_get_billing_form_for_payment_method( $this->checkout->payment_method );
892
+		if ($this->checkout->payment_method->type_obj()->has_billing_form()) {
893
+			$this->checkout->billing_form = $this->_get_billing_form_for_payment_method($this->checkout->payment_method);
894 894
 		}
895 895
 		// fill form with attendee info if applicable
896
-		if ( $this->checkout->billing_form instanceof EE_Billing_Attendee_Info_Form && $this->checkout->transaction_has_primary_registrant() ) {
897
-			$this->checkout->billing_form->populate_from_attendee( $this->checkout->transaction->primary_registration()->attendee() );
896
+		if ($this->checkout->billing_form instanceof EE_Billing_Attendee_Info_Form && $this->checkout->transaction_has_primary_registrant()) {
897
+			$this->checkout->billing_form->populate_from_attendee($this->checkout->transaction->primary_registration()->attendee());
898 898
 		}
899 899
 		// and debug content
900
-		if ( $this->checkout->billing_form instanceof EE_Billing_Info_Form && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base ) {
901
-			$this->checkout->billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings( $this->checkout->billing_form );
900
+		if ($this->checkout->billing_form instanceof EE_Billing_Info_Form && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base) {
901
+			$this->checkout->billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings($this->checkout->billing_form);
902 902
 		}
903 903
 		// get html and validation rules for form
904
-		if ( $this->checkout->billing_form instanceof EE_Form_Section_Proper ) {
905
-			$this->checkout->json_response->set_return_data( array( 'payment_method_info' => $this->checkout->billing_form->get_html() ));
904
+		if ($this->checkout->billing_form instanceof EE_Form_Section_Proper) {
905
+			$this->checkout->json_response->set_return_data(array('payment_method_info' => $this->checkout->billing_form->get_html()));
906 906
 			// localize validation rules for main form
907
-			$this->checkout->billing_form->localize_validation_rules( TRUE );
908
-			$this->checkout->json_response->add_validation_rules( EE_Form_Section_Proper::js_localization() );
907
+			$this->checkout->billing_form->localize_validation_rules(TRUE);
908
+			$this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization());
909 909
 		} else {
910
-			$this->checkout->json_response->set_return_data( array( 'payment_method_info' => '' ));
910
+			$this->checkout->json_response->set_return_data(array('payment_method_info' => ''));
911 911
 		}
912 912
 		//prevents advancement to next step
913 913
 		$this->checkout->continue_reg = FALSE;
@@ -922,12 +922,12 @@  discard block
 block discarded – undo
922 922
 	 */
923 923
 	protected function _verify_payment_method_is_set() {
924 924
 		// generate billing form for selected method of payment if it hasn't been done already
925
-		if ( empty( $this->checkout->selected_method_of_payment )) {
925
+		if (empty($this->checkout->selected_method_of_payment)) {
926 926
 			// how have they chosen to pay?
927
-			$this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( TRUE );
927
+			$this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(TRUE);
928 928
 		}
929 929
 		// verify payment method
930
-		if ( ! $this->checkout->payment_method instanceof EE_Payment_Method ) {
930
+		if ( ! $this->checkout->payment_method instanceof EE_Payment_Method) {
931 931
 			// get payment method for selected method of payment
932 932
 			$this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment();
933 933
 		}
@@ -947,23 +947,23 @@  discard block
 block discarded – undo
947 947
 	 * @return void
948 948
 	 */
949 949
 	public function save_payer_details_via_ajax() {
950
-		if ( ! $this->_verify_payment_method_is_set() ) {
950
+		if ( ! $this->_verify_payment_method_is_set()) {
951 951
 			return;
952 952
 		}
953 953
 		// generate billing form for selected method of payment if it hasn't been done already
954
-		if ( $this->checkout->payment_method->type_obj()->has_billing_form() ) {
955
-			$this->checkout->billing_form = $this->_get_billing_form_for_payment_method( $this->checkout->payment_method );
954
+		if ($this->checkout->payment_method->type_obj()->has_billing_form()) {
955
+			$this->checkout->billing_form = $this->_get_billing_form_for_payment_method($this->checkout->payment_method);
956 956
 		}
957 957
 		// generate primary attendee from payer info if applicable
958 958
 		if ( ! $this->checkout->transaction_has_primary_registrant()) {
959 959
 			$attendee = $this->_create_attendee_from_request_data();
960
-			if ( $attendee instanceof EE_Attendee ) {
961
-				foreach ( $this->checkout->transaction->registrations() as $registration ) {
962
-					if ( $registration->is_primary_registrant() ) {
960
+			if ($attendee instanceof EE_Attendee) {
961
+				foreach ($this->checkout->transaction->registrations() as $registration) {
962
+					if ($registration->is_primary_registrant()) {
963 963
 						$this->checkout->primary_attendee_obj = $attendee;
964
-						$registration->_add_relation_to( $attendee, 'Attendee' );
965
-						$registration->set_attendee_id( $attendee->ID() );
966
-						$registration->update_cache_after_object_save( 'Attendee', $attendee );
964
+						$registration->_add_relation_to($attendee, 'Attendee');
965
+						$registration->set_attendee_id($attendee->ID());
966
+						$registration->update_cache_after_object_save('Attendee', $attendee);
967 967
 					}
968 968
 				}
969 969
 			}
@@ -976,56 +976,56 @@  discard block
 block discarded – undo
976 976
 	 * uses info from alternate GET or POST data (such as AJAX) to create a new attendee
977 977
 	 * @return \EE_Attendee
978 978
 	 */
979
-	protected function _create_attendee_from_request_data(){
979
+	protected function _create_attendee_from_request_data() {
980 980
 		// get State ID
981
-		$STA_ID = ! empty( $_REQUEST['state'] ) ? sanitize_text_field( $_REQUEST['state'] ) : '';
982
-		if ( ! empty( $STA_ID )) {
981
+		$STA_ID = ! empty($_REQUEST['state']) ? sanitize_text_field($_REQUEST['state']) : '';
982
+		if ( ! empty($STA_ID)) {
983 983
 			// can we get state object from name ?
984
-			EE_Registry::instance()->load_model( 'State' );
985
-			$state = EEM_State::instance()->get_col( array( array( 'STA_name' => $STA_ID ), 'limit' => 1), 'STA_ID' );
986
-			$STA_ID = is_array( $state ) && ! empty( $state ) ? reset( $state ) : $STA_ID;
984
+			EE_Registry::instance()->load_model('State');
985
+			$state = EEM_State::instance()->get_col(array(array('STA_name' => $STA_ID), 'limit' => 1), 'STA_ID');
986
+			$STA_ID = is_array($state) && ! empty($state) ? reset($state) : $STA_ID;
987 987
 		}
988 988
 		// get Country ISO
989
-		$CNT_ISO = ! empty( $_REQUEST['country'] ) ? sanitize_text_field( $_REQUEST['country'] ) : '';
990
-		if ( ! empty( $CNT_ISO )) {
989
+		$CNT_ISO = ! empty($_REQUEST['country']) ? sanitize_text_field($_REQUEST['country']) : '';
990
+		if ( ! empty($CNT_ISO)) {
991 991
 			// can we get country object from name ?
992
-			EE_Registry::instance()->load_model( 'Country' );
993
-			$country = EEM_Country::instance()->get_col( array( array( 'CNT_name' => $CNT_ISO ), 'limit' => 1), 'CNT_ISO' );
994
-			$CNT_ISO = is_array( $country ) && ! empty( $country ) ? reset( $country ) : $CNT_ISO;
992
+			EE_Registry::instance()->load_model('Country');
993
+			$country = EEM_Country::instance()->get_col(array(array('CNT_name' => $CNT_ISO), 'limit' => 1), 'CNT_ISO');
994
+			$CNT_ISO = is_array($country) && ! empty($country) ? reset($country) : $CNT_ISO;
995 995
 		}
996 996
 		// grab attendee data
997 997
 		$attendee_data = array(
998
-			'ATT_fname' 		=> ! empty( $_REQUEST['first_name'] ) ? sanitize_text_field( $_REQUEST['first_name'] ) : '',
999
-			'ATT_lname' 		=> ! empty( $_REQUEST['last_name'] ) ? sanitize_text_field( $_REQUEST['last_name'] ) : '',
1000
-			'ATT_email' 		=> ! empty( $_REQUEST['email'] ) ? sanitize_email( $_REQUEST['email'] ) : '',
1001
-			'ATT_address' 		=> ! empty( $_REQUEST['address'] ) ? sanitize_text_field( $_REQUEST['address'] ) : '',
1002
-			'ATT_address2' 	=> ! empty( $_REQUEST['address2'] ) ? sanitize_text_field( $_REQUEST['address2'] ) : '',
1003
-			'ATT_city' 			=> ! empty( $_REQUEST['city'] ) ? sanitize_text_field( $_REQUEST['city'] ) : '',
998
+			'ATT_fname' 		=> ! empty($_REQUEST['first_name']) ? sanitize_text_field($_REQUEST['first_name']) : '',
999
+			'ATT_lname' 		=> ! empty($_REQUEST['last_name']) ? sanitize_text_field($_REQUEST['last_name']) : '',
1000
+			'ATT_email' 		=> ! empty($_REQUEST['email']) ? sanitize_email($_REQUEST['email']) : '',
1001
+			'ATT_address' 		=> ! empty($_REQUEST['address']) ? sanitize_text_field($_REQUEST['address']) : '',
1002
+			'ATT_address2' 	=> ! empty($_REQUEST['address2']) ? sanitize_text_field($_REQUEST['address2']) : '',
1003
+			'ATT_city' 			=> ! empty($_REQUEST['city']) ? sanitize_text_field($_REQUEST['city']) : '',
1004 1004
 			'STA_ID' 				=> $STA_ID,
1005 1005
 			'CNT_ISO' 			=> $CNT_ISO,
1006
-			'ATT_zip' 				=> ! empty( $_REQUEST['zip'] ) ? sanitize_text_field( $_REQUEST['zip'] ) : '',
1007
-			'ATT_phone' 		=> ! empty( $_REQUEST['phone'] ) ? sanitize_text_field( $_REQUEST['phone'] ) : '',
1006
+			'ATT_zip' 				=> ! empty($_REQUEST['zip']) ? sanitize_text_field($_REQUEST['zip']) : '',
1007
+			'ATT_phone' 		=> ! empty($_REQUEST['phone']) ? sanitize_text_field($_REQUEST['phone']) : '',
1008 1008
 		);
1009 1009
 		// validate the email address since it is the most important piece of info
1010
-		if ( empty( $attendee_data['ATT_email'] ) || $attendee_data['ATT_email'] != $_REQUEST['email'] ) {
1011
-			EE_Error::add_error( __( 'An invalid email address was submitted.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
1010
+		if (empty($attendee_data['ATT_email']) || $attendee_data['ATT_email'] != $_REQUEST['email']) {
1011
+			EE_Error::add_error(__('An invalid email address was submitted.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1012 1012
 		}
1013 1013
 		// does this attendee already exist in the db ? we're searching using a combination of first name, last name, AND email address
1014
-		if ( ! empty( $attendee_data['ATT_fname'] ) && ! empty( $attendee_data['ATT_lname'] ) && ! empty( $attendee_data['ATT_email'] ) ) {
1015
-			$existing_attendee = EE_Registry::instance()->LIB->EEM_Attendee->find_existing_attendee( array(
1014
+		if ( ! empty($attendee_data['ATT_fname']) && ! empty($attendee_data['ATT_lname']) && ! empty($attendee_data['ATT_email'])) {
1015
+			$existing_attendee = EE_Registry::instance()->LIB->EEM_Attendee->find_existing_attendee(array(
1016 1016
 				'ATT_fname' => $attendee_data['ATT_fname'],
1017 1017
 				'ATT_lname' => $attendee_data['ATT_lname'],
1018 1018
 				'ATT_email' => $attendee_data['ATT_email']
1019 1019
 			));
1020
-			if ( $existing_attendee instanceof EE_Attendee ) {
1020
+			if ($existing_attendee instanceof EE_Attendee) {
1021 1021
 				return $existing_attendee;
1022 1022
 			}
1023 1023
 		}
1024 1024
 		// no existing attendee? kk let's create a new one
1025 1025
 		// kinda lame, but we need a first and last name to create an attendee, so use the email address if those don't exist
1026
-		$attendee_data['ATT_fname'] = ! empty( $attendee_data['ATT_fname'] ) ? $attendee_data['ATT_fname'] : $attendee_data['ATT_email'];
1027
-		$attendee_data['ATT_lname'] = ! empty( $attendee_data['ATT_lname'] ) ? $attendee_data['ATT_lname'] : $attendee_data['ATT_email'];
1028
-		return EE_Attendee::new_instance( $attendee_data );
1026
+		$attendee_data['ATT_fname'] = ! empty($attendee_data['ATT_fname']) ? $attendee_data['ATT_fname'] : $attendee_data['ATT_email'];
1027
+		$attendee_data['ATT_lname'] = ! empty($attendee_data['ATT_lname']) ? $attendee_data['ATT_lname'] : $attendee_data['ATT_email'];
1028
+		return EE_Attendee::new_instance($attendee_data);
1029 1029
 	}
1030 1030
 
1031 1031
 
@@ -1045,22 +1045,22 @@  discard block
 block discarded – undo
1045 1045
 	 */
1046 1046
 	public function process_reg_step() {
1047 1047
 		// how have they chosen to pay?
1048
-		$this->checkout->selected_method_of_payment = $this->checkout->transaction->is_free() ? 'no_payment_required' : $this->_get_selected_method_of_payment( TRUE );
1048
+		$this->checkout->selected_method_of_payment = $this->checkout->transaction->is_free() ? 'no_payment_required' : $this->_get_selected_method_of_payment(TRUE);
1049 1049
 		// choose your own adventure based on method_of_payment
1050
-		switch(  $this->checkout->selected_method_of_payment ) {
1050
+		switch ($this->checkout->selected_method_of_payment) {
1051 1051
 
1052 1052
 			case 'events_sold_out' :
1053 1053
 				$this->checkout->redirect = TRUE;
1054 1054
 				$this->checkout->redirect_url = $this->checkout->cancel_page_url;
1055
-				$this->checkout->json_response->set_redirect_url( $this->checkout->redirect_url );
1055
+				$this->checkout->json_response->set_redirect_url($this->checkout->redirect_url);
1056 1056
 				// mark this reg step as completed
1057 1057
 				$this->set_completed();
1058 1058
 				return FALSE;
1059 1059
 				break;
1060 1060
 
1061 1061
 			case 'payments_closed' :
1062
-				if ( apply_filters( 'FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__payments_closed__display_success', false ) ) {
1063
-					EE_Error::add_success( __( 'no payment required at this time.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
1062
+				if (apply_filters('FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__payments_closed__display_success', false)) {
1063
+					EE_Error::add_success(__('no payment required at this time.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1064 1064
 				}
1065 1065
 				// mark this reg step as completed
1066 1066
 				$this->set_completed();
@@ -1068,8 +1068,8 @@  discard block
 block discarded – undo
1068 1068
 				break;
1069 1069
 
1070 1070
 			case 'no_payment_required' :
1071
-				if ( apply_filters( 'FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__no_payment_required__display_success', false ) ) {
1072
-					EE_Error::add_success( __( 'no payment required.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
1071
+				if (apply_filters('FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__no_payment_required__display_success', false)) {
1072
+					EE_Error::add_success(__('no payment required.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1073 1073
 				}
1074 1074
 				// mark this reg step as completed
1075 1075
 				$this->set_completed();
@@ -1078,9 +1078,9 @@  discard block
 block discarded – undo
1078 1078
 
1079 1079
 			default:
1080 1080
 				$payment_successful = $this->_process_payment();
1081
-				if ( $payment_successful ) {
1081
+				if ($payment_successful) {
1082 1082
 					$this->checkout->continue_reg = true;
1083
-					$this->_maybe_set_completed( $this->checkout->payment_method );
1083
+					$this->_maybe_set_completed($this->checkout->payment_method);
1084 1084
 				} else {
1085 1085
 					$this->checkout->continue_reg = false;
1086 1086
 				}
@@ -1098,8 +1098,8 @@  discard block
 block discarded – undo
1098 1098
 	 * @param \EE_Payment_Method $payment_method
1099 1099
 	 * @return void
1100 1100
 	 */
1101
-	protected function _maybe_set_completed( EE_Payment_Method $payment_method ) {
1102
-		switch ( $payment_method->type_obj()->payment_occurs() ) {
1101
+	protected function _maybe_set_completed(EE_Payment_Method $payment_method) {
1102
+		switch ($payment_method->type_obj()->payment_occurs()) {
1103 1103
 			case EE_PMT_Base::offsite :
1104 1104
 				break;
1105 1105
 			case EE_PMT_Base::onsite :
@@ -1122,15 +1122,15 @@  discard block
 block discarded – undo
1122 1122
 	public function update_reg_step() {
1123 1123
 		$success = TRUE;
1124 1124
 		// if payment required
1125
-		if ( $this->checkout->transaction->total() > 0 ) {
1126
-			do_action ('AHEE__EE_Single_Page_Checkout__process_finalize_registration__before_gateway', $this->checkout->transaction );
1125
+		if ($this->checkout->transaction->total() > 0) {
1126
+			do_action('AHEE__EE_Single_Page_Checkout__process_finalize_registration__before_gateway', $this->checkout->transaction);
1127 1127
 			// attempt payment via payment method
1128 1128
 			$success = $this->process_reg_step();
1129 1129
 		}
1130
-		if ( $success && ! $this->checkout->redirect ) {
1131
-			$this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn( $this->checkout->transaction->ID() );
1130
+		if ($success && ! $this->checkout->redirect) {
1131
+			$this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn($this->checkout->transaction->ID());
1132 1132
 			 // set return URL
1133
-			$this->checkout->redirect_url = add_query_arg( array( 'e_reg_url_link' => $this->checkout->reg_url_link ), $this->checkout->thank_you_page_url );
1133
+			$this->checkout->redirect_url = add_query_arg(array('e_reg_url_link' => $this->checkout->reg_url_link), $this->checkout->thank_you_page_url);
1134 1134
 		}
1135 1135
 		return $success;
1136 1136
 	}
@@ -1150,24 +1150,24 @@  discard block
 block discarded – undo
1150 1150
 		// clear any previous errors related to not selecting a payment method
1151 1151
 //		EE_Error::overwrite_errors();
1152 1152
 		// ya gotta make a choice man
1153
-		if ( empty( $this->checkout->selected_method_of_payment )) {
1154
-			$this->checkout->json_response->set_plz_select_method_of_payment( __( 'Please select a method of payment before proceeding.', 'event_espresso' ));
1153
+		if (empty($this->checkout->selected_method_of_payment)) {
1154
+			$this->checkout->json_response->set_plz_select_method_of_payment(__('Please select a method of payment before proceeding.', 'event_espresso'));
1155 1155
 			return FALSE;
1156 1156
 		}
1157 1157
 		// get EE_Payment_Method object
1158
-		if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment() ) {
1158
+		if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) {
1159 1159
 			return FALSE;
1160 1160
 		}
1161 1161
 		// setup billing form
1162
-		if ( $this->checkout->payment_method->is_on_site() ) {
1163
-			$this->checkout->billing_form = $this->_get_billing_form_for_payment_method( $this->checkout->payment_method );
1162
+		if ($this->checkout->payment_method->is_on_site()) {
1163
+			$this->checkout->billing_form = $this->_get_billing_form_for_payment_method($this->checkout->payment_method);
1164 1164
 			// bad billing form ?
1165
-			if ( ! $this->_billing_form_is_valid() ) {
1165
+			if ( ! $this->_billing_form_is_valid()) {
1166 1166
 				return FALSE;
1167 1167
 			}
1168 1168
 		}
1169 1169
 		// ensure primary registrant has been fully processed
1170
-		if ( ! $this->_setup_primary_registrant_prior_to_payment() ) {
1170
+		if ( ! $this->_setup_primary_registrant_prior_to_payment()) {
1171 1171
 			return FALSE;
1172 1172
 		}
1173 1173
 		/** @type EE_Transaction_Processor $transaction_processor */
@@ -1175,24 +1175,24 @@  discard block
 block discarded – undo
1175 1175
 		// in case a registrant leaves to an Off-Site Gateway and never returns, we want to approve any registrations for events with a default reg status of Approved
1176 1176
 		//$transaction_processor->toggle_registration_statuses_for_default_approved_events( $this->checkout->transaction, $this->checkout->reg_cache_where_params );
1177 1177
 		// attempt payment
1178
-		$payment = $this->_attempt_payment( $this->checkout->payment_method );
1178
+		$payment = $this->_attempt_payment($this->checkout->payment_method);
1179 1179
 		// process results
1180
-		$payment = $this->_validate_payment( $payment );
1181
-		$payment = $this->_post_payment_processing( $payment );
1180
+		$payment = $this->_validate_payment($payment);
1181
+		$payment = $this->_post_payment_processing($payment);
1182 1182
 		// verify payment
1183
-		if ( $payment instanceof EE_Payment ) {
1183
+		if ($payment instanceof EE_Payment) {
1184 1184
 			// store that for later
1185 1185
 			$this->checkout->payment = $payment;
1186 1186
 			/** @type EE_Transaction_Processor $transaction_processor */
1187
-			$transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' );
1187
+			$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
1188 1188
 			// we can also consider the TXN to not have been failed, so temporarily upgrade it's status to abandoned
1189
-			$transaction_processor->toggle_failed_transaction_status( $this->checkout->transaction );
1190
-			if ( $payment->status() == EEM_Payment::status_id_approved || $payment->status() == EEM_Payment::status_id_pending ) {
1189
+			$transaction_processor->toggle_failed_transaction_status($this->checkout->transaction);
1190
+			if ($payment->status() == EEM_Payment::status_id_approved || $payment->status() == EEM_Payment::status_id_pending) {
1191 1191
 				return true;
1192 1192
 			} else {
1193 1193
 				return false;
1194 1194
 			}
1195
-		} else if ( $payment === true ) {
1195
+		} else if ($payment === true) {
1196 1196
 			// please note that offline payment methods will NOT make a payment,
1197 1197
 			// but instead just mark themselves as the PMD_ID on the transaction, and return true
1198 1198
 			$this->checkout->payment = $payment;
@@ -1211,10 +1211,10 @@  discard block
 block discarded – undo
1211 1211
 	 * @return bool
1212 1212
 	 */
1213 1213
 	public function redirect_form() {
1214
-		$payment_method_billing_info = $this->_payment_method_billing_info( $this->_get_payment_method_for_selected_method_of_payment() );
1214
+		$payment_method_billing_info = $this->_payment_method_billing_info($this->_get_payment_method_for_selected_method_of_payment());
1215 1215
 		$html = $payment_method_billing_info->get_html_and_js();
1216 1216
 		$html .= $this->checkout->redirect_form;
1217
-		EE_Registry::instance()->REQ->add_output( $html );
1217
+		EE_Registry::instance()->REQ->add_output($html);
1218 1218
 		return TRUE;
1219 1219
 	}
1220 1220
 
@@ -1227,36 +1227,36 @@  discard block
 block discarded – undo
1227 1227
 	 * @return bool
1228 1228
 	 */
1229 1229
 	private function _billing_form_is_valid() {
1230
-		if ( ! $this->checkout->payment_method->type_obj()->has_billing_form() ) {
1230
+		if ( ! $this->checkout->payment_method->type_obj()->has_billing_form()) {
1231 1231
 			return TRUE;
1232 1232
 		}
1233
-		if ( $this->checkout->billing_form instanceof EE_Billing_Info_Form ) {
1234
-			if ( $this->checkout->billing_form->was_submitted() ) {
1233
+		if ($this->checkout->billing_form instanceof EE_Billing_Info_Form) {
1234
+			if ($this->checkout->billing_form->was_submitted()) {
1235 1235
 				$this->checkout->billing_form->receive_form_submission();
1236
-				if ( $this->checkout->billing_form->is_valid() ) {
1236
+				if ($this->checkout->billing_form->is_valid()) {
1237 1237
 					return TRUE;
1238 1238
 				}
1239 1239
 				$validation_errors = $this->checkout->billing_form->get_validation_errors_accumulated();
1240 1240
 				$error_strings = array();
1241
-				foreach( $validation_errors as $validation_error ){
1242
-					if( $validation_error instanceof EE_Validation_Error ){
1241
+				foreach ($validation_errors as $validation_error) {
1242
+					if ($validation_error instanceof EE_Validation_Error) {
1243 1243
 						$form_section = $validation_error->get_form_section();
1244
-						if( $form_section instanceof EE_Form_Input_Base ){
1244
+						if ($form_section instanceof EE_Form_Input_Base) {
1245 1245
 							$label = $form_section->html_label_text();
1246
-						}elseif( $form_section instanceof EE_Form_Section_Base ){
1246
+						}elseif ($form_section instanceof EE_Form_Section_Base) {
1247 1247
 							$label = $form_section->name();
1248
-						}else{
1249
-							$label = __( 'Validation Error', 'event_espresso' );
1248
+						} else {
1249
+							$label = __('Validation Error', 'event_espresso');
1250 1250
 						}
1251
-						$error_strings[] = sprintf('%1$s: %2$s', $label, $validation_error->getMessage() );
1251
+						$error_strings[] = sprintf('%1$s: %2$s', $label, $validation_error->getMessage());
1252 1252
 					}
1253 1253
 				}
1254
-				EE_Error::add_error( sprintf( __( 'One or more billing form inputs are invalid and require correction before proceeding. %1$s %2$s', 'event_espresso' ), '<br/>', implode( '<br/>', $error_strings )  ), __FILE__, __FUNCTION__, __LINE__ );
1254
+				EE_Error::add_error(sprintf(__('One or more billing form inputs are invalid and require correction before proceeding. %1$s %2$s', 'event_espresso'), '<br/>', implode('<br/>', $error_strings)), __FILE__, __FUNCTION__, __LINE__);
1255 1255
 			} else {
1256
-				EE_Error::add_error( __( 'The billing form was not submitted or something prevented it\'s submission.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
1256
+				EE_Error::add_error(__('The billing form was not submitted or something prevented it\'s submission.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1257 1257
 			}
1258 1258
 		} else {
1259
-			EE_Error::add_error( __( 'The submitted billing form is invalid possibly due to a technical reason.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
1259
+			EE_Error::add_error(__('The submitted billing form is invalid possibly due to a technical reason.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1260 1260
 		}
1261 1261
 		return FALSE;
1262 1262
 	}
@@ -1274,9 +1274,9 @@  discard block
 block discarded – undo
1274 1274
 	 */
1275 1275
 		private function _setup_primary_registrant_prior_to_payment() {
1276 1276
 			// check if transaction has a primary registrant and that it has a related Attendee object
1277
-			if ( ! $this->checkout->transaction_has_primary_registrant() ) {
1277
+			if ( ! $this->checkout->transaction_has_primary_registrant()) {
1278 1278
 				// need to at least gather some primary registrant data before attempting payment
1279
-				if ( $this->checkout->billing_form instanceof EE_Billing_Attendee_Info_Form && ! $this->_capture_primary_registration_data_from_billing_form() ) {
1279
+				if ($this->checkout->billing_form instanceof EE_Billing_Attendee_Info_Form && ! $this->_capture_primary_registration_data_from_billing_form()) {
1280 1280
 					return FALSE;
1281 1281
 				}
1282 1282
 			}
@@ -1284,13 +1284,13 @@  discard block
 block discarded – undo
1284 1284
 			// grab the primary_registration object
1285 1285
 			$primary_registration = $this->checkout->transaction->primary_registration();
1286 1286
 			/** @type EE_Transaction_Processor $transaction_processor */
1287
-			$transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' );
1287
+			$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
1288 1288
 			// at this point we'll consider a TXN to not have been failed
1289
-			$transaction_processor->toggle_failed_transaction_status( $this->checkout->transaction );
1289
+			$transaction_processor->toggle_failed_transaction_status($this->checkout->transaction);
1290 1290
 			// save the TXN ( which clears cached copy of primary_registration)
1291 1291
 			$this->checkout->transaction->save();
1292 1292
 			// grab TXN ID and save it to the primary_registration
1293
-			$primary_registration->set_transaction_id( $this->checkout->transaction->ID() );
1293
+			$primary_registration->set_transaction_id($this->checkout->transaction->ID());
1294 1294
 			// save what we have so far
1295 1295
 			$primary_registration->save();
1296 1296
 			return TRUE;
@@ -1307,41 +1307,41 @@  discard block
 block discarded – undo
1307 1307
 		private function _capture_primary_registration_data_from_billing_form() {
1308 1308
 			// convert billing form data into an attendee
1309 1309
 			$this->checkout->primary_attendee_obj = $this->checkout->billing_form->create_attendee_from_billing_form_data();
1310
-			if ( ! $this->checkout->primary_attendee_obj instanceof EE_Attendee ) {
1310
+			if ( ! $this->checkout->primary_attendee_obj instanceof EE_Attendee) {
1311 1311
 				EE_Error::add_error(
1312 1312
 					sprintf(
1313
-						__( 'The billing form details could not be used for attendee details due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso' ),
1313
+						__('The billing form details could not be used for attendee details due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso'),
1314 1314
 						'<br/>',
1315
-						EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
1315
+						EE_Registry::instance()->CFG->organization->get_pretty('email')
1316 1316
 					), __FILE__, __FUNCTION__, __LINE__
1317 1317
 				);
1318 1318
 				return FALSE;
1319 1319
 			}
1320 1320
 			$primary_registration = $this->checkout->transaction->primary_registration();
1321
-			if ( ! $primary_registration instanceof EE_Registration ) {
1321
+			if ( ! $primary_registration instanceof EE_Registration) {
1322 1322
 				EE_Error::add_error(
1323 1323
 					sprintf(
1324
-						__( 'The primary registrant for this transaction could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso' ),
1324
+						__('The primary registrant for this transaction could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso'),
1325 1325
 						'<br/>',
1326
-						EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
1326
+						EE_Registry::instance()->CFG->organization->get_pretty('email')
1327 1327
 					), __FILE__, __FUNCTION__, __LINE__
1328 1328
 				);
1329 1329
 				return FALSE;
1330 1330
 			}
1331
-			if ( ! $primary_registration->_add_relation_to( $this->checkout->primary_attendee_obj, 'Attendee' ) instanceof EE_Attendee ) {
1331
+			if ( ! $primary_registration->_add_relation_to($this->checkout->primary_attendee_obj, 'Attendee') instanceof EE_Attendee) {
1332 1332
 				EE_Error::add_error(
1333 1333
 					sprintf(
1334
-						__( 'The primary registrant could not be associated with this transaction due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso' ),
1334
+						__('The primary registrant could not be associated with this transaction due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso'),
1335 1335
 						'<br/>',
1336
-						EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
1336
+						EE_Registry::instance()->CFG->organization->get_pretty('email')
1337 1337
 					), __FILE__, __FUNCTION__, __LINE__
1338 1338
 				);
1339 1339
 				return FALSE;
1340 1340
 			}
1341 1341
 			/** @type EE_Registration_Processor $registration_processor */
1342
-			$registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' );
1342
+			$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
1343 1343
 			// at this point, we should have enough details about the registrant to consider the registration NOT incomplete
1344
-			$registration_processor->toggle_incomplete_registration_status_to_default( $primary_registration );
1344
+			$registration_processor->toggle_incomplete_registration_status_to_default($primary_registration);
1345 1345
 
1346 1346
 			return TRUE;
1347 1347
 		}
@@ -1357,35 +1357,35 @@  discard block
 block discarded – undo
1357 1357
 	 */
1358 1358
 		private function _get_payment_method_for_selected_method_of_payment() {
1359 1359
 			// get EE_Payment_Method object
1360
-			if ( isset( $this->checkout->available_payment_methods[ $this->checkout->selected_method_of_payment ] )) {
1361
-				$payment_method = $this->checkout->available_payment_methods[ $this->checkout->selected_method_of_payment ];
1360
+			if (isset($this->checkout->available_payment_methods[$this->checkout->selected_method_of_payment])) {
1361
+				$payment_method = $this->checkout->available_payment_methods[$this->checkout->selected_method_of_payment];
1362 1362
 			} else {
1363 1363
 				// load EEM_Payment_Method
1364
-				EE_Registry::instance()->load_model( 'Payment_Method' );
1364
+				EE_Registry::instance()->load_model('Payment_Method');
1365 1365
 				/** @type EEM_Payment_Method $EEM_Payment_Method */
1366 1366
 				$EEM_Payment_Method = EE_Registry::instance()->LIB->EEM_Payment_Method;
1367
-				$payment_method = $EEM_Payment_Method->get_one_by_slug( $this->checkout->selected_method_of_payment );
1367
+				$payment_method = $EEM_Payment_Method->get_one_by_slug($this->checkout->selected_method_of_payment);
1368 1368
 			}
1369 1369
 			// verify $payment_method
1370
-			if ( ! $payment_method instanceof EE_Payment_Method ) {
1370
+			if ( ! $payment_method instanceof EE_Payment_Method) {
1371 1371
 				// not a payment
1372 1372
 				EE_Error::add_error(
1373 1373
 					sprintf(
1374
-						__( 'The selected method of payment could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso' ),
1374
+						__('The selected method of payment could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso'),
1375 1375
 						'<br/>',
1376
-						EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
1376
+						EE_Registry::instance()->CFG->organization->get_pretty('email')
1377 1377
 					), __FILE__, __FUNCTION__, __LINE__
1378 1378
 				);
1379 1379
 				return NULL;
1380 1380
 			}
1381 1381
 			// and verify it has a valid Payment_Method Type object
1382
-			if ( ! $payment_method->type_obj() instanceof EE_PMT_Base ) {
1382
+			if ( ! $payment_method->type_obj() instanceof EE_PMT_Base) {
1383 1383
 				// not a payment
1384 1384
 				EE_Error::add_error(
1385 1385
 					sprintf(
1386
-						__( 'A valid payment method could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso' ),
1386
+						__('A valid payment method could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso'),
1387 1387
 						'<br/>',
1388
-						EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
1388
+						EE_Registry::instance()->CFG->organization->get_pretty('email')
1389 1389
 					), __FILE__, __FUNCTION__, __LINE__
1390 1390
 				);
1391 1391
 				return NULL;
@@ -1404,30 +1404,30 @@  discard block
 block discarded – undo
1404 1404
 	 * 	@type 	EE_Payment_Method $payment_method
1405 1405
 	 * 	@return 	mixed	EE_Payment | boolean
1406 1406
 	 */
1407
-	private function _attempt_payment( EE_Payment_Method $payment_method ) {
1408
-		$payment =NULL;
1407
+	private function _attempt_payment(EE_Payment_Method $payment_method) {
1408
+		$payment = NULL;
1409 1409
 		$this->checkout->transaction->save();
1410
-		$payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' );
1411
-		if ( ! $payment_processor instanceof EE_Payment_Processor ) {
1410
+		$payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
1411
+		if ( ! $payment_processor instanceof EE_Payment_Processor) {
1412 1412
 			return FALSE;
1413 1413
 		}
1414 1414
 		try {
1415
-			$payment_processor->set_revisit( $this->checkout->revisit );
1415
+			$payment_processor->set_revisit($this->checkout->revisit);
1416 1416
 			// generate payment object
1417 1417
 			$payment = $payment_processor->process_payment(
1418 1418
 				$payment_method,
1419 1419
 				$this->checkout->transaction,
1420 1420
 				$this->checkout->amount_owing,
1421 1421
 				$this->checkout->billing_form,
1422
-				$this->_get_return_url( $payment_method ),
1422
+				$this->_get_return_url($payment_method),
1423 1423
 				'CART',
1424 1424
 				$this->checkout->admin_request,
1425 1425
 				TRUE,
1426 1426
 				$this->reg_step_url()
1427 1427
 			);
1428 1428
 
1429
-		} catch( Exception $e ) {
1430
-			$this->_handle_payment_processor_exception( $e );
1429
+		} catch (Exception $e) {
1430
+			$this->_handle_payment_processor_exception($e);
1431 1431
 		}
1432 1432
 		return $payment;
1433 1433
 	}
@@ -1441,12 +1441,12 @@  discard block
 block discarded – undo
1441 1441
 	 * @param \Exception $e
1442 1442
 	 * @return void
1443 1443
 	 */
1444
-	protected function _handle_payment_processor_exception( Exception $e ) {
1444
+	protected function _handle_payment_processor_exception(Exception $e) {
1445 1445
 		EE_Error::add_error(
1446 1446
 			sprintf(
1447
-				__( 'The payment could not br processed due to a technical issue.%1$sPlease try again or contact %2$s for assistance.||The following Exception was thrown in %4$s on line %5$s:%1$s%3$s', 'event_espresso' ),
1447
+				__('The payment could not br processed due to a technical issue.%1$sPlease try again or contact %2$s for assistance.||The following Exception was thrown in %4$s on line %5$s:%1$s%3$s', 'event_espresso'),
1448 1448
 				'<br/>',
1449
-				EE_Registry::instance()->CFG->organization->get_pretty( 'email' ),
1449
+				EE_Registry::instance()->CFG->organization->get_pretty('email'),
1450 1450
 				$e->getMessage(),
1451 1451
 				$e->getFile(),
1452 1452
 				$e->getLine()
@@ -1463,9 +1463,9 @@  discard block
 block discarded – undo
1463 1463
 	 * @param \EE_Payment_Method $payment_method
1464 1464
 	 * @return string
1465 1465
 	 */
1466
-	protected function _get_return_url( EE_Payment_Method $payment_method ) {
1466
+	protected function _get_return_url(EE_Payment_Method $payment_method) {
1467 1467
 		$return_url = '';
1468
-		switch ( $payment_method->type_obj()->payment_occurs() ) {
1468
+		switch ($payment_method->type_obj()->payment_occurs()) {
1469 1469
 
1470 1470
 			case EE_PMT_Base::offsite :
1471 1471
 				$return_url = add_query_arg(
@@ -1496,18 +1496,18 @@  discard block
 block discarded – undo
1496 1496
 	 * @param EE_Payment $payment
1497 1497
 	 * @return EE_Payment | FALSE
1498 1498
 	 */
1499
-	private function _validate_payment( $payment = NULL ) {
1500
-		if (  $this->checkout->payment_method->is_off_line() ) {
1499
+	private function _validate_payment($payment = NULL) {
1500
+		if ($this->checkout->payment_method->is_off_line()) {
1501 1501
 			return TRUE;
1502 1502
 		}
1503 1503
 		// verify payment object
1504
-		if ( ! $payment instanceof EE_Payment ) {
1504
+		if ( ! $payment instanceof EE_Payment) {
1505 1505
 			// not a payment
1506 1506
 			EE_Error::add_error(
1507 1507
 				sprintf(
1508
-					__( 'A valid payment was not generated due to a technical issue.%1$sPlease try again or contact %2$s for assistance.', 'event_espresso' ),
1508
+					__('A valid payment was not generated due to a technical issue.%1$sPlease try again or contact %2$s for assistance.', 'event_espresso'),
1509 1509
 					'<br/>',
1510
-					EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
1510
+					EE_Registry::instance()->CFG->organization->get_pretty('email')
1511 1511
 				), __FILE__, __FUNCTION__, __LINE__
1512 1512
 			);
1513 1513
 			return FALSE;
@@ -1524,23 +1524,23 @@  discard block
 block discarded – undo
1524 1524
 	 * @param EE_Payment $payment
1525 1525
 	 * @return bool
1526 1526
 	 */
1527
-	private function _post_payment_processing( $payment = NULL ) {
1527
+	private function _post_payment_processing($payment = NULL) {
1528 1528
 		// On-Site payment?
1529
-		if ( $this->checkout->payment_method->is_on_site() ) {
1530
-			if ( ! $this->_process_payment_status( $payment, EE_PMT_Base::onsite )) {
1529
+		if ($this->checkout->payment_method->is_on_site()) {
1530
+			if ( ! $this->_process_payment_status($payment, EE_PMT_Base::onsite)) {
1531 1531
 				//$this->_setup_redirect_for_next_step();
1532 1532
 				$this->checkout->continue_reg = false;
1533 1533
 			}
1534 1534
 			// Off-Site payment?
1535
-		} else if ( $this->checkout->payment_method->is_off_site() ) {
1535
+		} else if ($this->checkout->payment_method->is_off_site()) {
1536 1536
 			// if a payment object was made and it specifies a redirect url, then we'll setup that redirect info
1537
-			if ( $payment instanceof EE_Payment && $payment->redirect_url() ){
1538
-				do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $payment->redirect_url(), '$payment->redirect_url()' );
1537
+			if ($payment instanceof EE_Payment && $payment->redirect_url()) {
1538
+				do_action('AHEE_log', __CLASS__, __FUNCTION__, $payment->redirect_url(), '$payment->redirect_url()');
1539 1539
 				$this->checkout->redirect = TRUE;
1540 1540
 				$this->checkout->redirect_form = $payment->redirect_form();
1541
-				$this->checkout->redirect_url = $this->reg_step_url( 'redirect_form' );
1541
+				$this->checkout->redirect_url = $this->reg_step_url('redirect_form');
1542 1542
 				// set JSON response
1543
-				$this->checkout->json_response->set_redirect_form( $this->checkout->redirect_form );
1543
+				$this->checkout->json_response->set_redirect_form($this->checkout->redirect_form);
1544 1544
 				// set cron job for finalizing the TXN
1545 1545
 				// in case the user does not return from the off-site gateway
1546 1546
 				EE_Cron_Tasks::schedule_finalize_abandoned_transactions_check(
@@ -1548,21 +1548,21 @@  discard block
 block discarded – undo
1548 1548
 					$this->checkout->transaction->ID()
1549 1549
 				);
1550 1550
 				// and lastly, let's bump the payment status to pending
1551
-				$payment->set_status( EEM_Payment::status_id_pending );
1551
+				$payment->set_status(EEM_Payment::status_id_pending);
1552 1552
 				$payment->save();
1553 1553
 			} else {
1554 1554
 				// not a payment
1555 1555
 				$this->checkout->continue_reg = false;
1556 1556
 				EE_Error::add_error(
1557 1557
 					sprintf(
1558
-						__( 'It appears the Off Site Payment Method was not configured properly.%sPlease try again or contact %s for assistance.', 'event_espresso' ),
1558
+						__('It appears the Off Site Payment Method was not configured properly.%sPlease try again or contact %s for assistance.', 'event_espresso'),
1559 1559
 						'<br/>',
1560
-						EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
1560
+						EE_Registry::instance()->CFG->organization->get_pretty('email')
1561 1561
 					), __FILE__, __FUNCTION__, __LINE__
1562 1562
 				);
1563 1563
 			}
1564 1564
 			// Off-Line payment?
1565
-		} else if ( $payment === TRUE ) {
1565
+		} else if ($payment === TRUE) {
1566 1566
 			//$this->_setup_redirect_for_next_step();
1567 1567
 			return TRUE;
1568 1568
 		} else {
@@ -1598,65 +1598,65 @@  discard block
 block discarded – undo
1598 1598
 	 * @return bool
1599 1599
 	 * @throws \EE_Error
1600 1600
 	 */
1601
-	private function _process_payment_status( $payment, $payment_occurs = EE_PMT_Base::offline ) {
1601
+	private function _process_payment_status($payment, $payment_occurs = EE_PMT_Base::offline) {
1602 1602
 		// off-line payment? carry on
1603
-		if ( $payment_occurs == EE_PMT_Base::offline ) {
1603
+		if ($payment_occurs == EE_PMT_Base::offline) {
1604 1604
 			return true;
1605 1605
 		}
1606 1606
 		// verify payment validity
1607
-		if ( $payment instanceof EE_Payment ) {
1608
-			do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $payment->status(), '$payment->status()' );
1607
+		if ($payment instanceof EE_Payment) {
1608
+			do_action('AHEE_log', __CLASS__, __FUNCTION__, $payment->status(), '$payment->status()');
1609 1609
 			$msg = $payment->gateway_response();
1610 1610
 			// check results
1611
-			switch ( $payment->status() ) {
1611
+			switch ($payment->status()) {
1612 1612
 
1613 1613
 				// good payment
1614 1614
 				case EEM_Payment::status_id_approved :
1615
-					EE_Error::add_success( __( 'Your payment was processed successfully.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
1615
+					EE_Error::add_success(__('Your payment was processed successfully.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1616 1616
 					return TRUE;
1617 1617
 					break;
1618 1618
 
1619 1619
 				// slow payment
1620 1620
 				case EEM_Payment::status_id_pending :
1621
-					if ( empty( $msg )) {
1622
-						$msg = __( 'Your payment appears to have been processed successfully, but the Instant Payment Notification has not yet been received. It should arrive shortly.', 'event_espresso' );
1621
+					if (empty($msg)) {
1622
+						$msg = __('Your payment appears to have been processed successfully, but the Instant Payment Notification has not yet been received. It should arrive shortly.', 'event_espresso');
1623 1623
 					}
1624
-					EE_Error::add_success( $msg, __FILE__, __FUNCTION__, __LINE__ );
1624
+					EE_Error::add_success($msg, __FILE__, __FUNCTION__, __LINE__);
1625 1625
 					return TRUE;
1626 1626
 					break;
1627 1627
 
1628 1628
 				// don't wanna payment
1629 1629
 				case EEM_Payment::status_id_cancelled :
1630
-					if ( empty( $msg )) {
1630
+					if (empty($msg)) {
1631 1631
 						$msg = _n(
1632 1632
 							'Payment cancelled. Please try again.',
1633 1633
 							'Payment cancelled. Please try again or select another method of payment.',
1634
-							count( $this->checkout->available_payment_methods ),
1634
+							count($this->checkout->available_payment_methods),
1635 1635
 							'event_espresso'
1636 1636
 						);
1637 1637
 					}
1638
-					EE_Error::add_attention( $msg, __FILE__, __FUNCTION__, __LINE__ );
1638
+					EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__);
1639 1639
 					return FALSE;
1640 1640
 					break;
1641 1641
 
1642 1642
 				// not enough payment
1643 1643
 				case EEM_Payment::status_id_declined :
1644
-					if ( empty( $msg )) {
1644
+					if (empty($msg)) {
1645 1645
 						$msg = _n(
1646 1646
 							'We\'re sorry but your payment was declined. Please try again.',
1647 1647
 							'We\'re sorry but your payment was declined. Please try again or select another method of payment.',
1648
-							count( $this->checkout->available_payment_methods ),
1648
+							count($this->checkout->available_payment_methods),
1649 1649
 							'event_espresso'
1650 1650
 						);
1651 1651
 					}
1652
-					EE_Error::add_attention( $msg, __FILE__, __FUNCTION__, __LINE__ );
1652
+					EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__);
1653 1653
 					return FALSE;
1654 1654
 					break;
1655 1655
 
1656 1656
 				// bad payment
1657 1657
 				case EEM_Payment::status_id_failed :
1658
-					if ( ! empty( $msg ) ) {
1659
-						EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
1658
+					if ( ! empty($msg)) {
1659
+						EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1660 1660
 						return false;
1661 1661
 					}
1662 1662
 					// default to error below
@@ -1666,14 +1666,14 @@  discard block
 block discarded – undo
1666 1666
 		}
1667 1667
 		// off-site payment gateway responses are too unreliable, so let's just assume that
1668 1668
 		// the payment processing is just running slower than the registrant's request
1669
-		if ( $payment_occurs == EE_PMT_Base::offsite ) {
1669
+		if ($payment_occurs == EE_PMT_Base::offsite) {
1670 1670
 			return true;
1671 1671
 		}
1672 1672
 		EE_Error::add_error(
1673 1673
 				sprintf(
1674
-					__( 'Your payment could not be processed successfully due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso' ),
1674
+					__('Your payment could not be processed successfully due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso'),
1675 1675
 					'<br/>',
1676
-					EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
1676
+					EE_Registry::instance()->CFG->organization->get_pretty('email')
1677 1677
 				),
1678 1678
 				__FILE__, __FUNCTION__, __LINE__
1679 1679
 			);
@@ -1706,13 +1706,13 @@  discard block
 block discarded – undo
1706 1706
 	public function process_gateway_response() {
1707 1707
 		$payment = null;
1708 1708
 		// how have they chosen to pay?
1709
-		$this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( true );
1709
+		$this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true);
1710 1710
 		// get EE_Payment_Method object
1711
-		if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment() ) {
1711
+		if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) {
1712 1712
 			$this->checkout->continue_reg = false;
1713 1713
 			return false;
1714 1714
 		}
1715
-		if ( ! $this->checkout->payment_method->is_off_site() ) {
1715
+		if ( ! $this->checkout->payment_method->is_off_site()) {
1716 1716
 			return false;
1717 1717
 		}
1718 1718
 		$this->_validate_offsite_return();
@@ -1726,23 +1726,23 @@  discard block
 block discarded – undo
1726 1726
 		//	true
1727 1727
 		//);
1728 1728
 		// verify TXN
1729
-		if ( $this->checkout->transaction instanceof EE_Transaction ) {
1729
+		if ($this->checkout->transaction instanceof EE_Transaction) {
1730 1730
 			$gateway = $this->checkout->payment_method->type_obj()->get_gateway();
1731
-			if ( ! $gateway instanceof EE_Offsite_Gateway ) {
1731
+			if ( ! $gateway instanceof EE_Offsite_Gateway) {
1732 1732
 				$this->checkout->continue_reg = false;
1733 1733
 				return false;
1734 1734
 			}
1735
-			$payment = $this->_process_off_site_payment( $gateway );
1736
-			$payment = $this->_process_cancelled_payments( $payment );
1737
-			$payment = $this->_validate_payment( $payment );
1735
+			$payment = $this->_process_off_site_payment($gateway);
1736
+			$payment = $this->_process_cancelled_payments($payment);
1737
+			$payment = $this->_validate_payment($payment);
1738 1738
 			// if payment was not declined by the payment gateway or cancelled by the registrant
1739
-			if ( $this->_process_payment_status( $payment, EE_PMT_Base::offsite ) ) {
1739
+			if ($this->_process_payment_status($payment, EE_PMT_Base::offsite)) {
1740 1740
 				//$this->_setup_redirect_for_next_step();
1741 1741
 				// store that for later
1742 1742
 				$this->checkout->payment = $payment;
1743 1743
 				// mark this reg step as completed, as long as gateway doesn't use a separate IPN request,
1744 1744
 				// because we will complete this step during the IPN processing then
1745
-				if ( $gateway instanceof EE_Offsite_Gateway && ! $gateway->uses_separate_IPN_request() ) {
1745
+				if ($gateway instanceof EE_Offsite_Gateway && ! $gateway->uses_separate_IPN_request()) {
1746 1746
 					$this->set_completed();
1747 1747
 				}
1748 1748
 				return true;
@@ -1765,19 +1765,19 @@  discard block
 block discarded – undo
1765 1765
 	 * @return bool
1766 1766
 	 */
1767 1767
 	private function _validate_offsite_return() {
1768
-		$TXN_ID = (int)EE_Registry::instance()->REQ->get( 'spco_txn', 0 );
1769
-		if ( $TXN_ID != $this->checkout->transaction->ID() ) {
1768
+		$TXN_ID = (int) EE_Registry::instance()->REQ->get('spco_txn', 0);
1769
+		if ($TXN_ID != $this->checkout->transaction->ID()) {
1770 1770
 			// Houston... we might have a problem
1771 1771
 			$invalid_TXN = false;
1772 1772
 			// first gather some info
1773
-			$valid_TXN = EEM_Transaction::instance()->get_one_by_ID( $TXN_ID );
1773
+			$valid_TXN = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
1774 1774
 			$primary_registrant = $valid_TXN instanceof EE_Transaction ? $valid_TXN->primary_registration() : null;
1775 1775
 			// let's start by retrieving the cart for this TXN
1776
-			$cart = EE_Cart::get_cart_from_txn( $this->checkout->transaction );
1777
-			if ( $cart instanceof EE_Cart ) {
1776
+			$cart = EE_Cart::get_cart_from_txn($this->checkout->transaction);
1777
+			if ($cart instanceof EE_Cart) {
1778 1778
 				// verify that the current cart has tickets
1779 1779
 				$tickets = $cart->get_tickets();
1780
-				if ( empty( $tickets ) ) {
1780
+				if (empty($tickets)) {
1781 1781
 					$invalid_TXN = true;
1782 1782
 				}
1783 1783
 			} else {
@@ -1785,39 +1785,39 @@  discard block
 block discarded – undo
1785 1785
 			}
1786 1786
 			$valid_TXN_SID = $primary_registrant instanceof EE_Registration ? $primary_registrant->session_ID() : null;
1787 1787
 			// validate current Session ID and compare against valid TXN session ID
1788
-			if ( EE_Session::instance()->id() === null ) {
1788
+			if (EE_Session::instance()->id() === null) {
1789 1789
 				$invalid_TXN = true;
1790
-			} else if ( EE_Session::instance()->id() === $valid_TXN_SID ) {
1790
+			} else if (EE_Session::instance()->id() === $valid_TXN_SID) {
1791 1791
 				// WARNING !!!
1792 1792
 				// this could be PayPal sending back duplicate requests (ya they do that)
1793 1793
 				// or it **could** mean someone is simply registering AGAIN after having just done so
1794 1794
 				// so now we need to determine if this current TXN looks valid or not
1795 1795
 				/** @type EE_Transaction_Processor $transaction_processor */
1796
-				$transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' );
1796
+				$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
1797 1797
 				// has this step even been started ?
1798
-				if ( $transaction_processor->reg_step_completed( $this->checkout->transaction, $this->slug() === false )
1798
+				if ($transaction_processor->reg_step_completed($this->checkout->transaction, $this->slug() === false)
1799 1799
 				) {
1800 1800
 					// really? you're half way through this reg step, but you never started it ?
1801 1801
 					$invalid_TXN = true;
1802 1802
 				}
1803 1803
 			}
1804
-			if ( $invalid_TXN ) {
1804
+			if ($invalid_TXN) {
1805 1805
 				// is the valid TXN completed ?
1806
-				if ( $valid_TXN instanceof EE_Transaction ) {
1806
+				if ($valid_TXN instanceof EE_Transaction) {
1807 1807
 					/** @type EE_Transaction_Processor $transaction_processor */
1808
-					$transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' );
1808
+					$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
1809 1809
 					// has this step even been started ?
1810
-					$reg_step_completed = $transaction_processor->reg_step_completed( $valid_TXN, $this->slug() );
1811
-					if ( $reg_step_completed !== false && $reg_step_completed !== true ) {
1810
+					$reg_step_completed = $transaction_processor->reg_step_completed($valid_TXN, $this->slug());
1811
+					if ($reg_step_completed !== false && $reg_step_completed !== true) {
1812 1812
 						// so it **looks** like this is a double request from PayPal
1813 1813
 						// so let's try to pick up where we left off
1814 1814
 						$this->checkout->transaction = $valid_TXN;
1815
-						$this->checkout->refresh_all_entities( true );
1815
+						$this->checkout->refresh_all_entities(true);
1816 1816
 						return;
1817 1817
 					}
1818 1818
 				}
1819 1819
 				// you appear to be lost?
1820
-				$this->_redirect_wayward_request( $primary_registrant );
1820
+				$this->_redirect_wayward_request($primary_registrant);
1821 1821
 			}
1822 1822
 		}
1823 1823
 	}
@@ -1831,16 +1831,16 @@  discard block
 block discarded – undo
1831 1831
 	 * @param \EE_Registration $primary_registrant
1832 1832
 	 * @return bool
1833 1833
 	 */
1834
-	private function _redirect_wayward_request( EE_Registration $primary_registrant ) {
1835
-		if ( ! $primary_registrant instanceof EE_Registration ) {
1834
+	private function _redirect_wayward_request(EE_Registration $primary_registrant) {
1835
+		if ( ! $primary_registrant instanceof EE_Registration) {
1836 1836
 			// try redirecting based on the current TXN
1837 1837
 			$primary_registrant = $this->checkout->transaction instanceof EE_Transaction ? $this->checkout->transaction->primary_registration() : null;
1838
-			if ( ! $primary_registrant instanceof EE_Registration ) {
1838
+			if ( ! $primary_registrant instanceof EE_Registration) {
1839 1839
 				EE_Error::add_error(
1840 1840
 					sprintf(
1841
-						__( 'Invalid information was received from the Off-Site Payment Processor and your Transaction details could not be retrieved from the database.%1$sPlease try again or contact %2$s for assistance.', 'event_espresso' ),
1841
+						__('Invalid information was received from the Off-Site Payment Processor and your Transaction details could not be retrieved from the database.%1$sPlease try again or contact %2$s for assistance.', 'event_espresso'),
1842 1842
 						'<br/>',
1843
-						EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
1843
+						EE_Registry::instance()->CFG->organization->get_pretty('email')
1844 1844
 					),
1845 1845
 					__FILE__, __FUNCTION__, __LINE__
1846 1846
 				);
@@ -1868,16 +1868,16 @@  discard block
 block discarded – undo
1868 1868
 	 * @param \EE_Offsite_Gateway $gateway
1869 1869
 	 * @return \EE_Payment
1870 1870
 	 */
1871
-	private function _process_off_site_payment( EE_Offsite_Gateway $gateway ) {
1871
+	private function _process_off_site_payment(EE_Offsite_Gateway $gateway) {
1872 1872
 		try {
1873 1873
 			// if gateway uses_separate_IPN_request, then we don't have to process the IPN manually
1874
-			if ( $gateway instanceof EE_Offsite_Gateway && $gateway->uses_separate_IPN_request() ) {
1874
+			if ($gateway instanceof EE_Offsite_Gateway && $gateway->uses_separate_IPN_request()) {
1875 1875
 				$payment = $this->checkout->transaction->last_payment();
1876 1876
 				//$payment_source = 'last_payment';
1877 1877
 			} else {
1878 1878
 				// get payment details and process results
1879 1879
 				/** @type EE_Payment_Processor $payment_processor */
1880
-				$payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' );
1880
+				$payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
1881 1881
 				$payment = $payment_processor->process_ipn(
1882 1882
 					$_REQUEST,
1883 1883
 					$this->checkout->transaction,
@@ -1887,14 +1887,14 @@  discard block
 block discarded – undo
1887 1887
 				);
1888 1888
 				//$payment_source = 'process_ipn';
1889 1889
 			}
1890
-		} catch ( Exception $e ) {
1890
+		} catch (Exception $e) {
1891 1891
 			// let's just eat the exception and try to move on using any previously set payment info
1892 1892
 			$payment = $this->checkout->transaction->last_payment();
1893 1893
 			//$payment_source = 'last_payment after Exception';
1894 1894
 			// but if we STILL don't have a payment object
1895
-			if ( ! $payment instanceof EE_Payment ) {
1895
+			if ( ! $payment instanceof EE_Payment) {
1896 1896
 				// then we'll object ! ( not object like a thing... but object like what a lawyer says ! )
1897
-				$this->_handle_payment_processor_exception( $e );
1897
+				$this->_handle_payment_processor_exception($e);
1898 1898
 			}
1899 1899
 		}
1900 1900
 		// DEBUG LOG
@@ -1918,13 +1918,13 @@  discard block
 block discarded – undo
1918 1918
 	 * @param EE_Payment $payment
1919 1919
 	 * @return EE_Payment | FALSE
1920 1920
 	 */
1921
-	private function _process_cancelled_payments( $payment = NULL ) {
1921
+	private function _process_cancelled_payments($payment = NULL) {
1922 1922
 		if (
1923
-			isset( $_REQUEST[ 'ee_cancel_payment' ] )
1923
+			isset($_REQUEST['ee_cancel_payment'])
1924 1924
 			&& $payment instanceof EE_Payment
1925 1925
 			&& $payment->status() == EEM_Payment::status_id_failed
1926 1926
 		) {
1927
-			$payment->set_status( EEM_Payment::status_id_cancelled );
1927
+			$payment->set_status(EEM_Payment::status_id_cancelled);
1928 1928
 		}
1929 1929
 		return $payment;
1930 1930
 	}
@@ -1941,23 +1941,23 @@  discard block
 block discarded – undo
1941 1941
 	public function get_transaction_details_for_gateways() {
1942 1942
 		$txn_details = array();
1943 1943
 		// ya gotta make a choice man
1944
-		if ( empty( $this->checkout->selected_method_of_payment ) ) {
1944
+		if (empty($this->checkout->selected_method_of_payment)) {
1945 1945
 			$txn_details = array(
1946
-				'error' => __( 'Please select a method of payment before proceeding.', 'event_espresso' )
1946
+				'error' => __('Please select a method of payment before proceeding.', 'event_espresso')
1947 1947
 			);
1948 1948
 		}
1949 1949
 		// get EE_Payment_Method object
1950 1950
 		if (
1951
-			empty( $txn_details ) &&
1951
+			empty($txn_details) &&
1952 1952
 			! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()
1953 1953
 		) {
1954 1954
 			$txn_details = array(
1955 1955
 				'selected_method_of_payment' => $this->checkout->selected_method_of_payment,
1956
-				'error' => __( 'A valid Payment Method could not be determined.', 'event_espresso' )
1956
+				'error' => __('A valid Payment Method could not be determined.', 'event_espresso')
1957 1957
 			);
1958 1958
 		}
1959
-		if ( empty( $txn_details ) && $this->checkout->transaction instanceof EE_Transaction ) {
1960
-			$return_url = $this->_get_return_url( $this->checkout->payment_method );
1959
+		if (empty($txn_details) && $this->checkout->transaction instanceof EE_Transaction) {
1960
+			$return_url = $this->_get_return_url($this->checkout->payment_method);
1961 1961
 			$txn_details = array(
1962 1962
 				'TXN_ID'        			=> $this->checkout->transaction->ID(),
1963 1963
 				'TXN_timestamp' 	=> $this->checkout->transaction->datetime(),
@@ -1968,7 +1968,7 @@  discard block
 block discarded – undo
1968 1968
 				'PMD_ID'        			=> $this->checkout->transaction->payment_method_ID(),
1969 1969
 				'payment_amount' => $this->checkout->amount_owing,
1970 1970
 				'return_url' 				=> $return_url,
1971
-				'cancel_url' 				=> add_query_arg( array( 'ee_cancel_payment' => true ), $return_url ),
1971
+				'cancel_url' 				=> add_query_arg(array('ee_cancel_payment' => true), $return_url),
1972 1972
 				'notify_url' 				=> EE_Config::instance()->core->txn_page_url(
1973 1973
 					array(
1974 1974
 						'e_reg_url_link'    			=> $this->checkout->transaction->primary_registration()->reg_url_link(),
@@ -1977,7 +1977,7 @@  discard block
 block discarded – undo
1977 1977
 				)
1978 1978
 			);
1979 1979
 		}
1980
-		echo json_encode( $txn_details );
1980
+		echo json_encode($txn_details);
1981 1981
 		exit();
1982 1982
 	}
1983 1983
 
Please login to merge, or discard this patch.
payment_methods/Paypal_Standard/EEG_Paypal_Standard.gateway.php 1 patch
Spacing   +122 added lines, -122 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	 * @return EEG_Paypal_Standard
69 69
 	 */
70 70
 	public function __construct() {
71
-		$this->set_uses_separate_IPN_request( true ) ;
71
+		$this->set_uses_separate_IPN_request(true);
72 72
 		parent::__construct();
73 73
 	}
74 74
 
@@ -78,11 +78,11 @@  discard block
 block discarded – undo
78 78
 	 * Also sets the gateway url class variable based on whether debug mode is enabled or not
79 79
 	 * @param array $settings_array
80 80
 	 */
81
-	public function set_settings($settings_array){
81
+	public function set_settings($settings_array) {
82 82
 		parent::set_settings($settings_array);
83
-		if($this->_debug_mode){
83
+		if ($this->_debug_mode) {
84 84
 			$this->_gateway_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
85
-		}else{
85
+		} else {
86 86
 			$this->_gateway_url = 'https://www.paypal.com/cgi-bin/webscr';
87 87
 		}
88 88
 	}
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 	 * @param string      $cancel_url   URL to send the user to after a cancelled payment attempt on teh payment provider's website
98 98
 	 * @return EEI_Payment
99 99
 	 */
100
-	public function set_redirection_info( $payment, $billing_info = array(), $return_url = NULL, $notify_url = NULL, $cancel_url = NULL ){
100
+	public function set_redirection_info($payment, $billing_info = array(), $return_url = NULL, $notify_url = NULL, $cancel_url = NULL) {
101 101
 		$redirect_args = array();
102 102
 		$transaction = $payment->transaction();
103 103
 		$primary_registrant = $transaction->primary_registration();
@@ -107,42 +107,42 @@  discard block
 block discarded – undo
107 107
 
108 108
 		$total_discounts_to_cart_total = $transaction->paid();
109 109
 		//only itemize the order if we're paying for the rest of the order's amount
110
-		if( $payment->amount() == $transaction->total() ) {
111
-			$payment->update_extra_meta( EEG_Paypal_Standard::itemized_payment_option_name, true );
110
+		if ($payment->amount() == $transaction->total()) {
111
+			$payment->update_extra_meta(EEG_Paypal_Standard::itemized_payment_option_name, true);
112 112
 			//this payment is for the remaining transaction amount,
113 113
 			//keep track of exactly how much the itemized order amount equals
114 114
 			$itemized_sum = 0;
115 115
 			$shipping_previously_added = 0;
116 116
 			//so let's show all the line items
117
-			foreach($total_line_item->get_items() as $line_item){
118
-				if ( $line_item instanceof EE_Line_Item ) {
117
+			foreach ($total_line_item->get_items() as $line_item) {
118
+				if ($line_item instanceof EE_Line_Item) {
119 119
 					//it's some kind of discount
120
-					if( $line_item->total() < 0 ) {
121
-						$total_discounts_to_cart_total += abs( $line_item->total() );
120
+					if ($line_item->total() < 0) {
121
+						$total_discounts_to_cart_total += abs($line_item->total());
122 122
 						$itemized_sum += $line_item->total();
123 123
 						continue;
124 124
 					}
125 125
 					//dont include shipping again.
126
-					if( strpos( $line_item->code(), 'paypal_shipping_') === 0 ) {
126
+					if (strpos($line_item->code(), 'paypal_shipping_') === 0) {
127 127
 						$shipping_previously_added = $line_item->total();
128 128
 						continue;
129 129
 					}
130
-					$redirect_args[ 'item_name_' . $item_num ] = substr(
131
-						sprintf( _x( '%1$s for %2$s', 'Ticket for Event', 'event_espresso' ), $line_item->name(), $line_item->ticket_event_name() ),
130
+					$redirect_args['item_name_'.$item_num] = substr(
131
+						sprintf(_x('%1$s for %2$s', 'Ticket for Event', 'event_espresso'), $line_item->name(), $line_item->ticket_event_name()),
132 132
 						0, 127
133 133
 					);
134
-					$redirect_args[ 'amount_' . $item_num ] = $line_item->unit_price();
135
-					$redirect_args[ 'quantity_' . $item_num ] = $line_item->quantity();
134
+					$redirect_args['amount_'.$item_num] = $line_item->unit_price();
135
+					$redirect_args['quantity_'.$item_num] = $line_item->quantity();
136 136
 					//if we're not letting PayPal calculate shipping, tell them its 0
137
-					if ( ! $this->_paypal_shipping ) {
138
-						$redirect_args[ 'shipping_' . $item_num ] = '0';
139
-						$redirect_args[ 'shipping2_' . $item_num ] = '0';
137
+					if ( ! $this->_paypal_shipping) {
138
+						$redirect_args['shipping_'.$item_num] = '0';
139
+						$redirect_args['shipping2_'.$item_num] = '0';
140 140
 					}
141 141
 					$item_num++;
142 142
 					$itemized_sum += $line_item->total();
143 143
 				}
144 144
 			}
145
-			$taxes_li = $this->_line_item->get_taxes_subtotal( $total_line_item );
145
+			$taxes_li = $this->_line_item->get_taxes_subtotal($total_line_item);
146 146
 			//ideally itemized sum equals the transaction total. but if not (which is weird)
147 147
 			//and the itemized sum is LESS than the transaction total
148 148
 			//add another line item
@@ -152,47 +152,47 @@  discard block
 block discarded – undo
152 152
 					$transaction->total() - $itemized_sum - $taxes_li->total() - $shipping_previously_added,
153 153
 					2 
154 154
 				);
155
-			if( $itemized_sum_diff_from_txn_total < 0 ) {
155
+			if ($itemized_sum_diff_from_txn_total < 0) {
156 156
 				//itemized sum is too big
157
-				$total_discounts_to_cart_total += abs( $itemized_sum_diff_from_txn_total );
158
-			} elseif( $itemized_sum_diff_from_txn_total > 0 ) {
159
-				$redirect_args[ 'item_name_' . $item_num ] = substr(
160
-						__( 'Other charges', 'event_espresso' ), 0, 127 );
161
-				$redirect_args[ 'amount_' . $item_num ] = $this->format_currency( $itemized_sum_diff_from_txn_total );
162
-				$redirect_args[ 'quantity_' . $item_num ] = 1;
157
+				$total_discounts_to_cart_total += abs($itemized_sum_diff_from_txn_total);
158
+			} elseif ($itemized_sum_diff_from_txn_total > 0) {
159
+				$redirect_args['item_name_'.$item_num] = substr(
160
+						__('Other charges', 'event_espresso'), 0, 127 );
161
+				$redirect_args['amount_'.$item_num] = $this->format_currency($itemized_sum_diff_from_txn_total);
162
+				$redirect_args['quantity_'.$item_num] = 1;
163 163
 				$item_num++;
164 164
 			}
165
-			if( $total_discounts_to_cart_total > 0 ) {
166
-				$redirect_args[ 'discount_amount_cart' ] = $this->format_currency( $total_discounts_to_cart_total );
165
+			if ($total_discounts_to_cart_total > 0) {
166
+				$redirect_args['discount_amount_cart'] = $this->format_currency($total_discounts_to_cart_total);
167 167
 			}
168 168
 			//add our taxes to the order if we're NOT using PayPal's
169
-			if( ! $this->_paypal_taxes ){
169
+			if ( ! $this->_paypal_taxes) {
170 170
 				$redirect_args['tax_cart'] = $total_line_item->get_total_tax();
171 171
 			}
172 172
 		} else {
173
-			$payment->update_extra_meta( EEG_Paypal_Standard::itemized_payment_option_name, false );
173
+			$payment->update_extra_meta(EEG_Paypal_Standard::itemized_payment_option_name, false);
174 174
 			//partial payment that's not for the remaining amount, so we can't send an itemized list
175
-			$redirect_args['item_name_' . $item_num] = substr(
176
-				sprintf( __('Payment of %1$s for %2$s', "event_espresso"), $payment->amount(), $primary_registrant->reg_code() ),
175
+			$redirect_args['item_name_'.$item_num] = substr(
176
+				sprintf(__('Payment of %1$s for %2$s', "event_espresso"), $payment->amount(), $primary_registrant->reg_code()),
177 177
 				0, 127
178 178
 			);
179
-			$redirect_args['amount_' . $item_num] = $payment->amount();
180
-			$redirect_args['shipping_' . $item_num ] = '0';
181
-			$redirect_args['shipping2_' . $item_num ] = '0';
179
+			$redirect_args['amount_'.$item_num] = $payment->amount();
180
+			$redirect_args['shipping_'.$item_num] = '0';
181
+			$redirect_args['shipping2_'.$item_num] = '0';
182 182
 			$redirect_args['tax_cart'] = '0';
183 183
 			$item_num++;
184 184
 		}
185 185
 
186
-		if($this->_debug_mode){
187
-			$redirect_args['item_name_' . $item_num] = 'DEBUG INFO (this item only added in sandbox mode';
188
-			$redirect_args['amount_' . $item_num] = 0;
186
+		if ($this->_debug_mode) {
187
+			$redirect_args['item_name_'.$item_num] = 'DEBUG INFO (this item only added in sandbox mode';
188
+			$redirect_args['amount_'.$item_num] = 0;
189 189
 			$redirect_args['on0_'.$item_num] = 'NOTIFY URL';
190
-			$redirect_args['os0_' . $item_num] = $notify_url;
190
+			$redirect_args['os0_'.$item_num] = $notify_url;
191 191
 			$redirect_args['on1_'.$item_num] = 'RETURN URL';
192
-			$redirect_args['os1_' . $item_num] = $return_url;
192
+			$redirect_args['os1_'.$item_num] = $return_url;
193 193
 //			$redirect_args['option_index_' . $item_num] = 1; // <-- dunno if this is needed ?
194
-			$redirect_args['shipping_' . $item_num ] = '0';
195
-			$redirect_args['shipping2_' . $item_num ] = '0';
194
+			$redirect_args['shipping_'.$item_num] = '0';
195
+			$redirect_args['shipping2_'.$item_num] = '0';
196 196
 		}
197 197
 
198 198
 		$redirect_args['business'] = $this->_paypal_id;
@@ -202,14 +202,14 @@  discard block
 block discarded – undo
202 202
 		$redirect_args['cmd'] = '_cart';
203 203
 		$redirect_args['upload'] = 1;
204 204
 		$redirect_args['currency_code'] = $payment->currency_code();
205
-		$redirect_args['rm'] = 2;//makes the user return with method=POST
206
-		if($this->_image_url){
205
+		$redirect_args['rm'] = 2; //makes the user return with method=POST
206
+		if ($this->_image_url) {
207 207
 			$redirect_args['image_url'] = $this->_image_url;
208 208
 		}
209 209
 		$redirect_args['no_shipping'] = $this->_shipping_details;
210
-		$redirect_args['bn'] = 'EventEspresso_SP';//EE will blow up if you change this
210
+		$redirect_args['bn'] = 'EventEspresso_SP'; //EE will blow up if you change this
211 211
 
212
-		$redirect_args = apply_filters( "FHEE__EEG_Paypal_Standard__set_redirection_info__arguments", $redirect_args, $this );
212
+		$redirect_args = apply_filters("FHEE__EEG_Paypal_Standard__set_redirection_info__arguments", $redirect_args, $this);
213 213
 
214 214
 		$payment->set_redirect_url($this->_gateway_url);
215 215
 		$payment->set_redirect_args($redirect_args);
@@ -230,55 +230,55 @@  discard block
 block discarded – undo
230 230
 	 * @return \EEI_Payment updated
231 231
 	 * @throws \EE_Error
232 232
 	 */
233
-	public function handle_payment_update( $update_info, $transaction ){
233
+	public function handle_payment_update($update_info, $transaction) {
234 234
 		//verify there's payment data that's been sent
235
-		if ( empty( $update_info[ 'payment_status' ] ) || empty( $update_info[ 'txn_id' ] ) ) {
235
+		if (empty($update_info['payment_status']) || empty($update_info['txn_id'])) {
236 236
 			// waaaait... is this a PDT request? (see https://developer.paypal.com/docs/classic/products/payment-data-transfer/)
237 237
 			// indicated by the "tx" argument? If so, we don't need it. We'll just use the IPN data when it comes
238
-			if ( isset( $update_info[ 'tx' ] ) ) {
238
+			if (isset($update_info['tx'])) {
239 239
 				return $transaction->last_payment();
240 240
 			} else {
241 241
 				return null;
242 242
 			}
243 243
 		}
244
-		$payment = $this->_pay_model->get_payment_by_txn_id_chq_nmbr( $update_info[ 'txn_id' ] );
245
-		if ( ! $payment instanceof EEI_Payment ) {
244
+		$payment = $this->_pay_model->get_payment_by_txn_id_chq_nmbr($update_info['txn_id']);
245
+		if ( ! $payment instanceof EEI_Payment) {
246 246
 			$payment = $transaction->last_payment();
247 247
 		}
248 248
 		// ok, then validate the IPN. Even if we've already processed this payment,
249 249
 		// let PayPal know we don't want to hear from them anymore!
250
-		if ( ! $this->validate_ipn( $update_info, $payment ) ) {
250
+		if ( ! $this->validate_ipn($update_info, $payment)) {
251 251
 			return $payment;
252 252
 		}
253 253
 		//ok, well let's process this payment then!
254
-		switch ( $update_info[ 'payment_status' ] ) {
254
+		switch ($update_info['payment_status']) {
255 255
 
256 256
 			case 'Completed' :
257 257
 				$status = $this->_pay_model->approved_status();
258
-				$gateway_response = __( 'The payment is approved.', 'event_espresso' );
258
+				$gateway_response = __('The payment is approved.', 'event_espresso');
259 259
 				break;
260 260
 
261 261
 			case 'Pending' :
262 262
 				$status = $this->_pay_model->pending_status();
263
-				$gateway_response = __( 'The payment is in progress. Another message will be sent when payment is approved.', 'event_espresso' );
263
+				$gateway_response = __('The payment is in progress. Another message will be sent when payment is approved.', 'event_espresso');
264 264
 				break;
265 265
 
266 266
 			case 'Denied' :
267 267
 				$status = $this->_pay_model->declined_status();
268
-				$gateway_response = __( 'The payment has been declined.', 'event_espresso' );
268
+				$gateway_response = __('The payment has been declined.', 'event_espresso');
269 269
 				break;
270 270
 
271 271
 			case 'Expired' :
272 272
 			case 'Failed' :
273 273
 				$status = $this->_pay_model->failed_status();
274
-				$gateway_response = __( 'The payment failed for technical reasons or expired.', 'event_espresso' );
274
+				$gateway_response = __('The payment failed for technical reasons or expired.', 'event_espresso');
275 275
 				break;
276 276
 
277 277
 			case 'Refunded' :
278 278
 			case 'Partially_Refunded' :
279 279
 				// even though it's a refund, we consider the payment as approved, it just has a negative value
280 280
 				$status = $this->_pay_model->approved_status();
281
-				$gateway_response = __( 'The payment has been refunded. Please update registrations accordingly.', 'event_espresso' );
281
+				$gateway_response = __('The payment has been refunded. Please update registrations accordingly.', 'event_espresso');
282 282
 				break;
283 283
 
284 284
 			case 'Voided' :
@@ -286,25 +286,25 @@  discard block
 block discarded – undo
286 286
 			case 'Canceled_Reversal' :
287 287
 			default :
288 288
 				$status = $this->_pay_model->cancelled_status();
289
-				$gateway_response = __( 'The payment was cancelled, reversed, or voided. Please update registrations accordingly.', 'event_espresso' );
289
+				$gateway_response = __('The payment was cancelled, reversed, or voided. Please update registrations accordingly.', 'event_espresso');
290 290
 				break;
291 291
 
292 292
 		}
293 293
 
294 294
 		//check if we've already processed this payment
295
-		if ( $payment instanceof EEI_Payment ) {
295
+		if ($payment instanceof EEI_Payment) {
296 296
 			//payment exists. if this has the exact same status and amount, don't bother updating. just return
297
-			if ( $payment->status() == $status && $payment->amount() == $update_info[ 'mc_gross' ] ) {
297
+			if ($payment->status() == $status && $payment->amount() == $update_info['mc_gross']) {
298 298
 				// DUPLICATED IPN! dont bother updating transaction foo!;
299
-				$message_log = sprintf( __( 'It appears we have received a duplicate IPN from PayPal for payment %d', 'event_espresso' ), $payment->ID() );
299
+				$message_log = sprintf(__('It appears we have received a duplicate IPN from PayPal for payment %d', 'event_espresso'), $payment->ID());
300 300
 			} else {
301 301
 				// new payment yippee !!!
302
-				$payment->set_status( $status );
303
-				$payment->set_amount( floatval( $update_info[ 'mc_gross' ] ) );
304
-				$payment->set_gateway_response( $gateway_response );
305
-				$payment->set_details( $update_info );
306
-				$payment->set_txn_id_chq_nmbr( $update_info[ 'txn_id' ] );
307
-				$message_log = sprintf( __( 'Updated payment either from IPN or as part of POST from PayPal', 'event_espresso' ) );
302
+				$payment->set_status($status);
303
+				$payment->set_amount(floatval($update_info['mc_gross']));
304
+				$payment->set_gateway_response($gateway_response);
305
+				$payment->set_details($update_info);
306
+				$payment->set_txn_id_chq_nmbr($update_info['txn_id']);
307
+				$message_log = sprintf(__('Updated payment either from IPN or as part of POST from PayPal', 'event_espresso'));
308 308
 			}
309 309
 			$this->log(
310 310
 				array(
@@ -316,11 +316,11 @@  discard block
 block discarded – undo
316 316
 				$payment
317 317
 			);
318 318
 		}
319
-		do_action( 'FHEE__EEG_Paypal_Standard__handle_payment_update__payment_processed', $payment, $this );
319
+		do_action('FHEE__EEG_Paypal_Standard__handle_payment_update__payment_processed', $payment, $this);
320 320
 		// kill request here if this is a refund
321
-		if ( $update_info[ 'payment_status' ] == 'Refunded' || $update_info[ 'payment_status' ] == 'Partially_Refunded'   ) {
322
-			if ( apply_filters( 'FHEE__EEG_Paypal_Standard__handle_payment_update__kill_refund_request', true ) ) {
323
-				status_header( 200 );
321
+		if ($update_info['payment_status'] == 'Refunded' || $update_info['payment_status'] == 'Partially_Refunded') {
322
+			if (apply_filters('FHEE__EEG_Paypal_Standard__handle_payment_update__kill_refund_request', true)) {
323
+				status_header(200);
324 324
 				exit();
325 325
 			}
326 326
 		}
@@ -336,9 +336,9 @@  discard block
 block discarded – undo
336 336
 	 * @param EE_Payment|EEI_Payment $payment
337 337
 	 * @return boolean
338 338
 	 */
339
-	public function validate_ipn( $update_info, $payment ) {
339
+	public function validate_ipn($update_info, $payment) {
340 340
 		//allow us to skip validating IPNs with PayPal (useful for testing)
341
-		if ( apply_filters( 'FHEE__EEG_Paypal_Standard__validate_ipn__skip', false ) ) {
341
+		if (apply_filters('FHEE__EEG_Paypal_Standard__validate_ipn__skip', false)) {
342 342
 			return true;
343 343
 		}
344 344
 		//...otherwise, we actually don't care what the $update_info is, we need to look
@@ -346,22 +346,22 @@  discard block
 block discarded – undo
346 346
 		// Reading POSTed data directly from $_POST causes serialization issues with array data in the POST.
347 347
 		// Instead, read raw POST data from the input stream.
348 348
 		// @see https://gist.github.com/xcommerce-gists/3440401
349
-		$raw_post_data = file_get_contents( 'php://input' );
350
-		$raw_post_array = explode( '&', $raw_post_data );
349
+		$raw_post_data = file_get_contents('php://input');
350
+		$raw_post_array = explode('&', $raw_post_data);
351 351
 		$update_info = array();
352
-		foreach ( $raw_post_array as $keyval ) {
353
-			$keyval = explode( '=', $keyval );
354
-			if ( count( $keyval ) == 2 )
355
-				$update_info[ $keyval[ 0 ] ] = urldecode( $keyval[ 1 ] );
352
+		foreach ($raw_post_array as $keyval) {
353
+			$keyval = explode('=', $keyval);
354
+			if (count($keyval) == 2)
355
+				$update_info[$keyval[0]] = urldecode($keyval[1]);
356 356
 		}
357 357
 		// read the IPN message sent from PayPal and prepend 'cmd=_notify-validate'
358 358
 		$req = 'cmd=_notify-validate';
359
-		$get_magic_quotes_exists = function_exists( 'get_magic_quotes_gpc' ) ? true : false;
360
-		foreach ( $update_info as $key => $value ) {
361
-			if ( $get_magic_quotes_exists && get_magic_quotes_gpc() == 1 ) {
362
-				$value = urlencode( stripslashes( $value ) );
359
+		$get_magic_quotes_exists = function_exists('get_magic_quotes_gpc') ? true : false;
360
+		foreach ($update_info as $key => $value) {
361
+			if ($get_magic_quotes_exists && get_magic_quotes_gpc() == 1) {
362
+				$value = urlencode(stripslashes($value));
363 363
 			} else {
364
-				$value = urlencode( $value );
364
+				$value = urlencode($value);
365 365
 			}
366 366
 			$req .= "&$key=$value";
367 367
 		}
@@ -371,34 +371,34 @@  discard block
 block discarded – undo
371 371
 			array(
372 372
 				'body' 				=> $req,
373 373
 				'sslverify' 		=> false,
374
-				'timeout' 		=> 60 ,
374
+				'timeout' 		=> 60,
375 375
 				// make sure to set a site specific unique "user-agent" string since the WordPres default gets declined by PayPal
376 376
 				// plz see: https://github.com/websharks/s2member/issues/610
377
-				'user-agent' 	=> 'Event Espresso v' . EVENT_ESPRESSO_VERSION . '; ' . home_url(),
377
+				'user-agent' 	=> 'Event Espresso v'.EVENT_ESPRESSO_VERSION.'; '.home_url(),
378 378
 				'httpversion' => '1.1'
379 379
 			)
380 380
 		);
381 381
 		// then check the response
382
-		if ( ! is_wp_error( $response ) && array_key_exists( 'body', $response ) && strcmp( $response[ 'body' ], "VERIFIED" ) == 0 ) {
382
+		if ( ! is_wp_error($response) && array_key_exists('body', $response) && strcmp($response['body'], "VERIFIED") == 0) {
383 383
 			return true;
384 384
 		} else {
385 385
 			// huh, something's wack... the IPN didn't validate. We must have replied to the IPN incorrectly,
386 386
 			// or their API must have changed: http://www.paypalobjects.com/en_US/ebook/PP_OrderManagement_IntegrationGuide/ipn.html
387
-			if( is_wp_error(  $response ) ) {
387
+			if (is_wp_error($response)) {
388 388
 				$error_msg = sprintf( 
389
-					__( 'WP Error. Code: "%1$s", Message: "%2$s", Data: "%3$s"', 'event_espresso' ),
389
+					__('WP Error. Code: "%1$s", Message: "%2$s", Data: "%3$s"', 'event_espresso'),
390 390
 					$response->get_error_code(),
391 391
 					$response->get_error_message(),
392
-					print_r( $response->get_error_data, true )
392
+					print_r($response->get_error_data, true)
393 393
 				);
394
-			} elseif( is_array( $response ) && isset( $response[ 'body' ] ) ) {
395
-				$error_msg = $response[ 'body' ];
394
+			} elseif (is_array($response) && isset($response['body'])) {
395
+				$error_msg = $response['body'];
396 396
 			} else {
397
-				$error_msg = print_r( $response, true );
397
+				$error_msg = print_r($response, true);
398 398
 			}
399
-			$payment->set_gateway_response( sprintf( __( "IPN Validation failed! Paypal responded with '%s'", "event_espresso" ), $error_msg ) );
400
-			$payment->set_details( array( 'REQUEST' => $update_info, 'VALIDATION_RESPONSE' => $response ) );
401
-			$payment->set_status( EEM_Payment::status_id_failed );
399
+			$payment->set_gateway_response(sprintf(__("IPN Validation failed! Paypal responded with '%s'", "event_espresso"), $error_msg));
400
+			$payment->set_details(array('REQUEST' => $update_info, 'VALIDATION_RESPONSE' => $response));
401
+			$payment->set_status(EEM_Payment::status_id_failed);
402 402
 			// log the results
403 403
 			$this->log(
404 404
 				array(
@@ -420,9 +420,9 @@  discard block
 block discarded – undo
420 420
 	 */
421 421
 	protected function _process_response_url() {
422 422
 		EE_Registry::instance()->load_helper('URL');
423
-		if ( isset( $_SERVER[ 'HTTP_HOST' ], $_SERVER[ 'REQUEST_URI' ] ) ) {
423
+		if (isset($_SERVER['HTTP_HOST'], $_SERVER['REQUEST_URI'])) {
424 424
 			$url = is_ssl() ? 'https://' : 'http://';
425
-			$url .= EEH_URL::filter_input_server_url( 'HTTP_HOST' );
425
+			$url .= EEH_URL::filter_input_server_url('HTTP_HOST');
426 426
 			$url .= EEH_URL::filter_input_server_url();
427 427
 		} else {
428 428
 			$url = 'unknown';
@@ -438,30 +438,30 @@  discard block
 block discarded – undo
438 438
 	 * like the taxes or shipping
439 439
 	 * @param EEI_Payment $payment
440 440
 	 */
441
-	public function update_txn_based_on_payment( $payment ) {
441
+	public function update_txn_based_on_payment($payment) {
442 442
 		$update_info = $payment->details();
443 443
 		$transaction = $payment->transaction();
444
-		$payment_was_itemized = $payment->get_extra_meta( EEG_Paypal_Standard::itemized_payment_option_name, true, false );
445
-		if( ! $transaction ){
446
-			$this->log( __( 'Payment with ID %d has no related transaction, and so update_txn_based_on_payment couldn\'t be executed properly', 'event_espresso' ), $payment );
444
+		$payment_was_itemized = $payment->get_extra_meta(EEG_Paypal_Standard::itemized_payment_option_name, true, false);
445
+		if ( ! $transaction) {
446
+			$this->log(__('Payment with ID %d has no related transaction, and so update_txn_based_on_payment couldn\'t be executed properly', 'event_espresso'), $payment);
447 447
 			return;
448 448
 		}
449
-		if( ! is_array( $update_info ) || ! isset( $update_info[ 'mc_shipping' ] ) || ! isset( $update_info[ 'tax' ] ) ) {
449
+		if ( ! is_array($update_info) || ! isset($update_info['mc_shipping']) || ! isset($update_info['tax'])) {
450 450
 			$this->log(
451 451
 				array(
452 452
 					'url' 				=> $this->_process_response_url(),
453
-					'message' 	=> __( 'Could not update transaction based on payment because the payment details have not yet been put on the payment. This normally happens during the IPN or returning from PayPal', 'event_espresso' ),
453
+					'message' 	=> __('Could not update transaction based on payment because the payment details have not yet been put on the payment. This normally happens during the IPN or returning from PayPal', 'event_espresso'),
454 454
 					'payment' 	=> $payment->model_field_array()
455 455
 				),
456 456
 				$payment
457 457
 			);
458 458
 			return;
459 459
 		}
460
-		if( $payment->status() !== $this->_pay_model->approved_status() ) {
460
+		if ($payment->status() !== $this->_pay_model->approved_status()) {
461 461
 			$this->log(
462 462
 				array(
463 463
 					'url' 				=> $this->_process_response_url(),
464
-					'message' 	=> __( 'We shouldn\'t update transactions taxes or shipping data from non-approved payments', 'event_espresso' ),
464
+					'message' 	=> __('We shouldn\'t update transactions taxes or shipping data from non-approved payments', 'event_espresso'),
465 465
 					'payment' 	=> $payment->model_field_array()
466 466
 				),
467 467
 				$payment
@@ -471,43 +471,43 @@  discard block
 block discarded – undo
471 471
 		$grand_total_needs_resaving = false;
472 472
 
473 473
 		//might paypal have changed the taxes?
474
-		if( $this->_paypal_taxes && $payment_was_itemized ){
474
+		if ($this->_paypal_taxes && $payment_was_itemized) {
475 475
                     //note that we're doing this BEFORE adding shipping; we actually want PayPal's shipping to remain non-taxable
476
-                    $this->_line_item->set_line_items_taxable( $transaction->total_line_item(), true, 'paypal_shipping' );
476
+                    $this->_line_item->set_line_items_taxable($transaction->total_line_item(), true, 'paypal_shipping');
477 477
                     $this->_line_item->set_total_tax_to(
478 478
                             $transaction->total_line_item(),
479
-                            floatval( $update_info['tax'] ),
480
-                            __( 'Taxes', 'event_espresso' ),
481
-                            __( 'Calculated by Paypal', 'event_espresso' ),
479
+                            floatval($update_info['tax']),
480
+                            __('Taxes', 'event_espresso'),
481
+                            __('Calculated by Paypal', 'event_espresso'),
482 482
                             'paypal_tax'
483 483
                     );
484 484
                     $grand_total_needs_resaving = TRUE;
485 485
 		}
486 486
 
487
-		$shipping_amount = floatval( $update_info[ 'mc_shipping' ] );
487
+		$shipping_amount = floatval($update_info['mc_shipping']);
488 488
 		//might paypal have added shipping?
489
-		if( $this->_paypal_shipping && $shipping_amount && $payment_was_itemized ){
489
+		if ($this->_paypal_shipping && $shipping_amount && $payment_was_itemized) {
490 490
 			$this->_line_item->add_unrelated_item(
491 491
 				$transaction->total_line_item(),
492
-				sprintf( __('Shipping for transaction %1$s', 'event_espresso'), $transaction->ID() ),
492
+				sprintf(__('Shipping for transaction %1$s', 'event_espresso'), $transaction->ID()),
493 493
 				$shipping_amount,
494 494
 				__('Shipping charges calculated by Paypal', 'event_espresso'),
495 495
 				1,
496 496
 				false,
497
-				'paypal_shipping_' . $transaction->ID()
497
+				'paypal_shipping_'.$transaction->ID()
498 498
 			);
499 499
 			$grand_total_needs_resaving = true;
500 500
 		}
501 501
 
502
-		if( $grand_total_needs_resaving ){
503
-			$transaction->total_line_item()->save_this_and_descendants_to_txn( $transaction->ID() );
504
-			$registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' );
505
-			$registration_processor->update_registration_final_prices( $transaction );
502
+		if ($grand_total_needs_resaving) {
503
+			$transaction->total_line_item()->save_this_and_descendants_to_txn($transaction->ID());
504
+			$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
505
+			$registration_processor->update_registration_final_prices($transaction);
506 506
 		}
507 507
 		$this->log(
508 508
 			array(
509 509
 				'url' 													=> $this->_process_response_url(),
510
-				'message' 										=> __( 'Updated transaction related to payment', 'event_espresso' ),
510
+				'message' 										=> __('Updated transaction related to payment', 'event_espresso'),
511 511
 				'transaction (updated)' 					=> $transaction->model_field_array(),
512 512
 				'payment (updated)' 						=> $payment->model_field_array(),
513 513
 				'use_paypal_shipping' 					=> $this->_paypal_shipping,
Please login to merge, or discard this patch.
core/db_models/EEM_Base.model.php 4 patches
Doc Comments   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -809,7 +809,7 @@  discard block
 block discarded – undo
809 809
 	 * Returns the name of the field's name that points to the WP_User table
810 810
 	 *  on this model (or follows the _model_chain_to_wp_user and uses that model's
811 811
 	 * foreign key to the WP_User table)
812
-	 * @return string|boolean string on success, boolean false when there is no
812
+	 * @return string|false string on success, boolean false when there is no
813 813
 	 * foreign key to the WP_User table
814 814
 	 */
815 815
 	function wp_user_field_name() {
@@ -906,6 +906,7 @@  discard block
 block discarded – undo
906 906
 	 * If you would like to use these custom selections in WHERE, GROUP_BY, or HAVING clauses, you must instead provide an array.
907 907
 	 * Array keys are the aliases used to refer to this selection, and values are to be numerically-indexed arrays, where 0 is the selection
908 908
 	 * and 1 is the data type. Eg, array('count'=>array('COUNT(REG_ID)','%d'))
909
+	 * @param string $columns_to_select
909 910
 	 * @return array|stdClass[] like results of $wpdb->get_results($sql,OBJECT), (ie, output type is OBJECT)
910 911
 	 */
911 912
 	public function  get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null){
@@ -1248,7 +1249,7 @@  discard block
 block discarded – undo
1248 1249
 	 * @param bool   $pretty          Whether to return the pretty formats (true) or not (false).
1249 1250
 	 * @throws EE_Error   If the given field_name is not of the EE_Datetime_Field type.
1250 1251
 	 *
1251
-	 * @return array formats in an array with the date format first, and the time format last.
1252
+	 * @return string[] formats in an array with the date format first, and the time format last.
1252 1253
 	 */
1253 1254
 	public function get_formats_for( $field_name, $pretty = false ) {
1254 1255
 		$field_settings = $this->field_settings_for( $field_name );
@@ -1283,7 +1284,7 @@  discard block
 block discarded – undo
1283 1284
 	 *
1284 1285
 	 * @throws EE_Error   	If the given field_name is not of the EE_Datetime_Field type.
1285 1286
 	 *
1286
-	 * @return int|string  If the given field_name is not of the EE_Datetime_Field type, then an EE_Error
1287
+	 * @return string|null  If the given field_name is not of the EE_Datetime_Field type, then an EE_Error
1287 1288
 	 *                    	     exception is triggered.
1288 1289
 	 */
1289 1290
 	public function current_time_for_query( $field_name, $timestamp = false, $what = 'both' ) {
@@ -1982,7 +1983,7 @@  discard block
 block discarded – undo
1982 1983
 	/**
1983 1984
 	 * Verifies the EE addons' database is up-to-date and records that we've done it on
1984 1985
 	 * EEM_Base::$_db_verification_level
1985
-	 * @param $wpdb_method
1986
+	 * @param string $wpdb_method
1986 1987
 	 * @param $arguments_to_provide
1987 1988
 	 * @return string
1988 1989
 	 */
@@ -2050,7 +2051,6 @@  discard block
 block discarded – undo
2050 2051
 	 * 'hasAndBelongsToMany' relationships: checks that there isn't already an entry in the join table, and adds one.
2051 2052
 	 * If one of the model Objects has not yet been saved to the database, it is saved before adding the entry in the join table
2052 2053
 	 *
2053
-	 * @param EE_Base_Class/int $thisModelObject
2054 2054
 	 * @param EE_Base_Class/int $id_or_obj EE_base_Class or ID of other Model Object
2055 2055
 	 * @param string $relationName, key in EEM_Base::_relations
2056 2056
 	 * an attendee to a group, you also want to specify which role they will have in that group. So you would use this parameter to specify array('role-column-name'=>'role-id')
@@ -2072,8 +2072,8 @@  discard block
 block discarded – undo
2072 2072
 	 *
2073 2073
 	 * 'hasAndBelongsToMany' relationships:removes any existing entry in the join table between the two models.
2074 2074
 	 *
2075
-	 * @param EE_Base_Class/int $id_or_obj
2076
-	 * @param EE_Base_Class/int $other_model_id_or_obj EE_Base_Class or ID of other Model Object
2075
+	 * @param EE_CPT_Base $id_or_obj
2076
+	 * @param EE_Term_Taxonomy $other_model_id_or_obj EE_Base_Class or ID of other Model Object
2077 2077
 	 * @param string $relationName key in EEM_Base::_relations
2078 2078
 	 * @return boolean of success
2079 2079
 	 * @param array   $where_query This allows you to enter further query params for the relation to for relation to methods that allow you to further specify extra columns to join by (such as HABTM).  Keep in mind that the only acceptable query_params is strict "col" => "value" pairs because these will be inserted in any new rows created as well.
@@ -2149,7 +2149,7 @@  discard block
 block discarded – undo
2149 2149
 	/**
2150 2150
 	 * Instead of getting the related model objects, simply counts them. Ignores default_where_conditions by default,
2151 2151
 	 * unless otherwise specified in the $query_params
2152
-	 * @param int/EE_Base_Class $id_or_obj
2152
+	 * @param EE_Event $id_or_obj
2153 2153
 	 * @param string $model_name like 'Event', or 'Registration'
2154 2154
 	 * @param array $query_params like EEM_Base::get_all's
2155 2155
 	 * @param string $field_to_count name of field to count by. By default, uses primary key
@@ -2538,7 +2538,7 @@  discard block
 block discarded – undo
2538 2538
 	/**
2539 2539
 	 * Finds all the fields that correspond to the given table
2540 2540
 	 * @param string $table_alias, array key in EEM_Base::_tables
2541
-	 * @return EE_Model_Field_Base[]
2541
+	 * @return EE_Model_Field_Base
2542 2542
 	 */
2543 2543
 	function _get_fields_for_table($table_alias){
2544 2544
 		return $this->_fields[$table_alias];
@@ -3630,8 +3630,8 @@  discard block
 block discarded – undo
3630 3630
 	/**
3631 3631
 	 * gets the field object of type 'primary_key' from the fieldsSettings attribute.
3632 3632
 	 * Eg, on EE_Answer that would be ANS_ID field object
3633
-	 * @param $field_obj
3634
-	 * @return EE_Model_Field_Base
3633
+	 * @param EE_Model_Field_Base $field_obj
3634
+	 * @return boolean
3635 3635
 	 */
3636 3636
 	public function is_primary_key_field( $field_obj ){
3637 3637
 		return $field_obj instanceof EE_Primary_Key_Field_Base ? TRUE : FALSE;
@@ -3725,7 +3725,7 @@  discard block
 block discarded – undo
3725 3725
 	 * Gets the actual table for the table alias
3726 3726
 	 * @param string $table_alias eg Event, Event_Meta, Registration, Transaction, but maybe
3727 3727
 	 * a table alias with a model chain prefix, like 'Venue__Event_Venue___Event_Meta'. Either one works
3728
-	 * @return EE_Table_Base
3728
+	 * @return string
3729 3729
 	 */
3730 3730
 	function get_table_for_alias($table_alias){
3731 3731
 		$table_alias_sans_model_relation_chain_prefix = EE_Model_Parser::remove_table_alias_model_relation_chain_prefix($table_alias);
@@ -3852,7 +3852,7 @@  discard block
 block discarded – undo
3852 3852
 	 * The purpose of this method is to allow us to create a model object that is not in the db that holds default values.
3853 3853
 	 * A typical example of where this is used is when creating a new item and the initial load of a form.  We dont' necessarily want to test for if the object is present but just assume it is BUT load the defaults from the object (as set in the model_field!).
3854 3854
 	 *
3855
-	 * @return EE_Base_Class single EE_Base_Class object with default values for the properties.
3855
+	 * @return boolean single EE_Base_Class object with default values for the properties.
3856 3856
 	 */
3857 3857
 	public function create_default_object() {
3858 3858
 
@@ -4242,7 +4242,7 @@  discard block
 block discarded – undo
4242 4242
 	}
4243 4243
 	/**
4244 4244
 	 * Read comments for assume_values_already_prepared_by_model_object()
4245
-	 * @return int
4245
+	 * @return boolean
4246 4246
 	 */
4247 4247
 	public function get_assumption_concerning_values_already_prepared_by_model_object(){
4248 4248
 		return $this->_values_already_prepared_by_model_object;
Please login to merge, or discard this patch.
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -604,10 +604,10 @@  discard block
 block discarded – undo
604 604
 	 	$stati = EEM_Status::instance()->get_all(array(array('STS_type' => $status_type) ) );
605 605
 	 	$status_array = array();
606 606
 	 	foreach ( $stati as $status ) {
607
-            $status_array[ $status->ID() ] = $status->get('STS_code');
608
-        }
609
-        return $translated ? EEM_Status::instance()->localized_status($status_array, FALSE, 'sentence') : $status_array;
610
-    }
607
+			$status_array[ $status->ID() ] = $status->get('STS_code');
608
+		}
609
+		return $translated ? EEM_Status::instance()->localized_status($status_array, FALSE, 'sentence') : $status_array;
610
+	}
611 611
 
612 612
 
613 613
 
@@ -617,7 +617,7 @@  discard block
 block discarded – undo
617 617
 	 *
618 618
 	 *	@var array $0 (where) array {
619 619
 	 *		eg: array('QST_display_text'=>'Are you bob?','QST_admin_text'=>'Determine if user is bob')
620
-			* becomes
620
+	 * becomes
621 621
 	 *		SQL >> "...WHERE QST_display_text = 'Are you bob?' AND QST_admin_text = 'Determine if user is bob'...")
622 622
 	 *
623 623
 	 *		To add WHERE conditions based on related models (and even models-related-to-related-models) prepend the model's name
@@ -1605,7 +1605,7 @@  discard block
 block discarded – undo
1605 1605
 	 * Deletes a single row from the DB given the model object's primary key value. (eg, EE_Attendee->ID()'s value).
1606 1606
 	 * Wrapper for EEM_Base::delete()
1607 1607
 	 * @param mixed $id
1608
-     * @param boolean $allow_blocking if TRUE, matched objects will only be deleted if there is no related model info
1608
+	 * @param boolean $allow_blocking if TRUE, matched objects will only be deleted if there is no related model info
1609 1609
 	 * that blocks it (ie, there' sno other data that depends on this data); if false, deletes regardless of other objects
1610 1610
 	 * which may depend on it. Its generally advisable to always leave this as TRUE, otherwise you could easily corrupt your DB
1611 1611
 	 * @return boolean whether the row got deleted or not
Please login to merge, or discard this patch.
Spacing   +960 added lines, -960 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  * @since 				EE4
24 24
  *
25 25
  */
26
-abstract class EEM_Base extends EE_Base{
26
+abstract class EEM_Base extends EE_Base {
27 27
 
28 28
 	//admin posty
29 29
 	//basic -> grants access to mine -> if they don't have it, select none
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
 	 * Flag indicating whether this model has a primary key or not
236 236
 	 * @var boolean
237 237
 	 */
238
-	protected $_has_primary_key_field=null;
238
+	protected $_has_primary_key_field = null;
239 239
 
240 240
 	/**
241 241
 	 * Whether or not this model is based off a table in WP core only (CPTs should set
@@ -297,19 +297,19 @@  discard block
 block discarded – undo
297 297
 	 * operators that work like 'BETWEEN'.  Typically used for datetime calculations, i.e. "BETWEEN '12-1-2011' AND '12-31-2012'"
298 298
 	 * @var array
299 299
 	 */
300
-	protected $_between_style_operators = array( 'BETWEEN' );
300
+	protected $_between_style_operators = array('BETWEEN');
301 301
 
302 302
 	/**
303 303
 	 * operators that are used for handling NUll and !NULL queries.  Typically used for when checking if a row exists on a join table.
304 304
 	 * @var array
305 305
 	 */
306
-	protected $_null_style_operators = array( 'IS NOT NULL', 'IS NULL');
306
+	protected $_null_style_operators = array('IS NOT NULL', 'IS NULL');
307 307
 
308 308
 	/**
309 309
 	 * Allowed values for $query_params['order'] for ordering in queries
310 310
 	 * @var array
311 311
 	 */
312
-	protected $_allowed_order_values = array('asc','desc','ASC','DESC');
312
+	protected $_allowed_order_values = array('asc', 'desc', 'ASC', 'DESC');
313 313
 
314 314
 	/**
315 315
 	 * When these are keys in a WHERE or HAVING clause, they are handled much differently
@@ -323,13 +323,13 @@  discard block
 block discarded – undo
323 323
 	 * 'where', but 'where' clauses are so common that we thought we'd omit it
324 324
 	 * @var array
325 325
 	 */
326
-	private $_allowed_query_params = array(0, 'limit','order_by','group_by','having','force_join','order','on_join_limit','default_where_conditions', 'caps');
326
+	private $_allowed_query_params = array(0, 'limit', 'order_by', 'group_by', 'having', 'force_join', 'order', 'on_join_limit', 'default_where_conditions', 'caps');
327 327
 
328 328
 	/**
329 329
 	 * All the data types that can be used in $wpdb->prepare statements.
330 330
 	 * @var array
331 331
 	 */
332
-	private $_valid_wpdb_data_types = array('%d','%s','%f');
332
+	private $_valid_wpdb_data_types = array('%d', '%s', '%f');
333 333
 
334 334
 	/**
335 335
 	 * 	EE_Registry Object
@@ -362,17 +362,17 @@  discard block
 block discarded – undo
362 362
 	/**
363 363
 	 * constant used to show EEM_Base has not yet verified the db on this http request
364 364
 	 */
365
-	const db_verified_none 		= 0;
365
+	const db_verified_none = 0;
366 366
 	/**
367 367
 	 * constant used to show EEM_Base has verified the EE core db on this http request,
368 368
 	 * but not the addons' dbs
369 369
 	 */
370
-	const db_verified_core 		= 1;
370
+	const db_verified_core = 1;
371 371
 	/**
372 372
 	 * constant used to show EEM_Base has verified the addons' dbs (and implicitly
373 373
 	 * the EE core db too)
374 374
 	 */
375
-	const db_verified_addons 	= 2;
375
+	const db_verified_addons = 2;
376 376
 
377 377
 	/**
378 378
 	 * indicates whether an EEM_Base child has already re-verified the DB
@@ -409,13 +409,13 @@  discard block
 block discarded – undo
409 409
 	 * @param null $timezone
410 410
 	 * @throws \EE_Error
411 411
 	 */
412
-	protected function __construct( $timezone = NULL ){
412
+	protected function __construct($timezone = NULL) {
413 413
 		// check that the model has not been loaded too soon
414
-		if ( ! did_action( 'AHEE__EE_System__load_espresso_addons' )) {
415
-			throw new EE_Error (
414
+		if ( ! did_action('AHEE__EE_System__load_espresso_addons')) {
415
+			throw new EE_Error(
416 416
 				sprintf(
417
-					__( 'The %1$s model can not be loaded before the "AHEE__EE_System__load_espresso_addons" hook has been called. This gives other addons a chance to extend this model.', 'event_espresso' ),
418
-					get_class( $this )
417
+					__('The %1$s model can not be loaded before the "AHEE__EE_System__load_espresso_addons" hook has been called. This gives other addons a chance to extend this model.', 'event_espresso'),
418
+					get_class($this)
419 419
 				)
420 420
 			);
421 421
 		}
@@ -425,11 +425,11 @@  discard block
 block discarded – undo
425 425
 		 * just use EE_Register_Model_Extension
426 426
 		 * @var EE_Table_Base[] $_tables
427 427
 		 */
428
-		$this->_tables = apply_filters( 'FHEE__'.get_class($this).'__construct__tables', $this->_tables );
429
-		foreach($this->_tables as $table_alias => $table_obj){
428
+		$this->_tables = apply_filters('FHEE__'.get_class($this).'__construct__tables', $this->_tables);
429
+		foreach ($this->_tables as $table_alias => $table_obj) {
430 430
 			/** @var $table_obj EE_Table_Base */
431 431
 			$table_obj->_construct_finalize_with_alias($table_alias);
432
-			if( $table_obj instanceof EE_Secondary_Table ){
432
+			if ($table_obj instanceof EE_Secondary_Table) {
433 433
 				/** @var $table_obj EE_Secondary_Table */
434 434
 				$table_obj->_construct_finalize_set_table_to_join_with($this->_get_main_table());
435 435
 			}
@@ -439,54 +439,54 @@  discard block
 block discarded – undo
439 439
 		 * EE_Register_Model_Extension
440 440
 		 * @param EE_Model_Field_Base[] $_fields
441 441
 		 */
442
-		$this->_fields = apply_filters('FHEE__'.get_class($this).'__construct__fields',$this->_fields);
442
+		$this->_fields = apply_filters('FHEE__'.get_class($this).'__construct__fields', $this->_fields);
443 443
 		$this->_invalidate_field_caches();
444
-		foreach($this->_fields as $table_alias => $fields_for_table){
445
-			if ( ! array_key_exists( $table_alias, $this->_tables )){
446
-				throw new EE_Error(sprintf(__("Table alias %s does not exist in EEM_Base child's _tables array. Only tables defined are %s",'event_espresso'),$table_alias,implode(",",$this->_fields)));
444
+		foreach ($this->_fields as $table_alias => $fields_for_table) {
445
+			if ( ! array_key_exists($table_alias, $this->_tables)) {
446
+				throw new EE_Error(sprintf(__("Table alias %s does not exist in EEM_Base child's _tables array. Only tables defined are %s", 'event_espresso'), $table_alias, implode(",", $this->_fields)));
447 447
 			}
448
-			foreach($fields_for_table as $field_name => $field_obj){
448
+			foreach ($fields_for_table as $field_name => $field_obj) {
449 449
 				/** @var $field_obj EE_Model_Field_Base | EE_Primary_Key_Field_Base */
450 450
 				//primary key field base has a slightly different _construct_finalize
451 451
 				/** @var $field_obj EE_Model_Field_Base */
452
-				$field_obj->_construct_finalize( $table_alias, $field_name, $this->get_this_model_name() );
452
+				$field_obj->_construct_finalize($table_alias, $field_name, $this->get_this_model_name());
453 453
 			}
454 454
 		}
455 455
 
456 456
 		// everything is related to Extra_Meta
457
-		if( get_class($this) != 'EEM_Extra_Meta'){
457
+		if (get_class($this) != 'EEM_Extra_Meta') {
458 458
 			//make extra meta related to everything, but don't block deleting things just
459 459
 			//because they have related extra meta info. For now just orphan those extra meta
460 460
 			//in the future we should automatically delete them
461
-			$this->_model_relations['Extra_Meta'] = new EE_Has_Many_Any_Relation( FALSE );
461
+			$this->_model_relations['Extra_Meta'] = new EE_Has_Many_Any_Relation(FALSE);
462 462
 		}
463 463
 		//and change logs
464
-		if( get_class( $this) !=  'EEM_Change_Log' ) {
465
-			$this->_model_relations[ 'Change_Log' ] = new EE_Has_Many_Any_Relation( FALSE );
464
+		if (get_class($this) != 'EEM_Change_Log') {
465
+			$this->_model_relations['Change_Log'] = new EE_Has_Many_Any_Relation(FALSE);
466 466
 		}
467 467
 		/**
468 468
 		 * Filters the list of relations on a model. It is best to NOT use this directly and instead just use
469 469
 		 * EE_Register_Model_Extension
470 470
 		 * @param EE_Model_Relation_Base[] $_model_relations
471 471
 		 */
472
-		$this->_model_relations = apply_filters('FHEE__'.get_class($this).'__construct__model_relations',$this->_model_relations);
473
-		foreach($this->_model_relations as $model_name => $relation_obj){
472
+		$this->_model_relations = apply_filters('FHEE__'.get_class($this).'__construct__model_relations', $this->_model_relations);
473
+		foreach ($this->_model_relations as $model_name => $relation_obj) {
474 474
 			/** @var $relation_obj EE_Model_Relation_Base */
475 475
 			$relation_obj->_construct_finalize_set_models($this->get_this_model_name(), $model_name);
476 476
 		}
477
-		foreach($this->_indexes as $index_name => $index_obj){
477
+		foreach ($this->_indexes as $index_name => $index_obj) {
478 478
 			/** @var $index_obj EE_Index */
479 479
 			$index_obj->_construct_finalize($index_name, $this->get_this_model_name());
480 480
 		}
481 481
 
482 482
 		$this->set_timezone($timezone);
483 483
 		//finalize default where condition strategy, or set default
484
-		if( ! $this->_default_where_conditions_strategy){
484
+		if ( ! $this->_default_where_conditions_strategy) {
485 485
 			//nothing was set during child constructor, so set default
486 486
 			$this->_default_where_conditions_strategy = new EE_Default_Where_Conditions();
487 487
 		}
488 488
 		$this->_default_where_conditions_strategy->_finalize_construct($this);
489
-		if( ! $this->_minimum_where_conditions_strategy){
489
+		if ( ! $this->_minimum_where_conditions_strategy) {
490 490
 			//nothing was set during child constructor, so set default
491 491
 			$this->_minimum_where_conditions_strategy = new EE_Default_Where_Conditions();
492 492
 		}
@@ -494,15 +494,15 @@  discard block
 block discarded – undo
494 494
 
495 495
 		//if the cap slug hasn't been set, and we haven't set it to false on purpose
496 496
 		//to indicate to NOT set it, set it to the logical default
497
-		if( $this->_caps_slug === null ) {
498
-			EE_Registry::instance()->load_helper( 'Inflector' );
499
-			$this->_caps_slug = EEH_Inflector::pluralize_and_lower( $this->get_this_model_name() );
497
+		if ($this->_caps_slug === null) {
498
+			EE_Registry::instance()->load_helper('Inflector');
499
+			$this->_caps_slug = EEH_Inflector::pluralize_and_lower($this->get_this_model_name());
500 500
 		}
501 501
 		//initialize the standard cap restriction generators if none were specified by the child constructor
502
-		if( $this->_cap_restriction_generators !== false ){
503
-			foreach( $this->cap_contexts_to_cap_action_map() as $cap_context => $action ){
504
-				if( ! isset( $this->_cap_restriction_generators[ $cap_context ] ) ) {
505
-					$this->_cap_restriction_generators[ $cap_context ] = apply_filters(
502
+		if ($this->_cap_restriction_generators !== false) {
503
+			foreach ($this->cap_contexts_to_cap_action_map() as $cap_context => $action) {
504
+				if ( ! isset($this->_cap_restriction_generators[$cap_context])) {
505
+					$this->_cap_restriction_generators[$cap_context] = apply_filters(
506 506
 						'FHEE__EEM_Base___construct__standard_cap_restriction_generator',
507 507
 						new EE_Restriction_Generator_Protected(),
508 508
 						$cap_context,
@@ -512,23 +512,23 @@  discard block
 block discarded – undo
512 512
 			}
513 513
 		}
514 514
 		//if there are cap restriction generators, use them to make the default cap restrictions
515
-		if( $this->_cap_restriction_generators !== false ){
516
-			foreach( $this->_cap_restriction_generators as $context => $generator_object ) {
517
-				if( ! $generator_object ){
515
+		if ($this->_cap_restriction_generators !== false) {
516
+			foreach ($this->_cap_restriction_generators as $context => $generator_object) {
517
+				if ( ! $generator_object) {
518 518
 					continue;
519 519
 				}
520
-				if( ! $generator_object instanceof EE_Restriction_Generator_Base ){
520
+				if ( ! $generator_object instanceof EE_Restriction_Generator_Base) {
521 521
 					throw new EE_Error(
522 522
 						sprintf(
523
-							__( 'Index "%1$s" in the model %2$s\'s _cap_restriction_generators is not a child of EE_Restriction_Generator_Base. It should be that or NULL.', 'event_espresso' ),
523
+							__('Index "%1$s" in the model %2$s\'s _cap_restriction_generators is not a child of EE_Restriction_Generator_Base. It should be that or NULL.', 'event_espresso'),
524 524
 							$context,
525 525
 							$this->get_this_model_name()
526 526
 						)
527 527
 					);
528 528
 				}
529
-				$action = $this->cap_action_for_context( $context );
530
-				if( ! $generator_object->construction_finalized() ){
531
-					$generator_object->_construct_finalize( $this, $action );
529
+				$action = $this->cap_action_for_context($context);
530
+				if ( ! $generator_object->construction_finalized()) {
531
+					$generator_object->_construct_finalize($this, $action);
532 532
 				}
533 533
 
534 534
 			}
@@ -542,11 +542,11 @@  discard block
 block discarded – undo
542 542
 	 * @param string $context one of EEM_Base::valid_cap_contexts()
543 543
 	 * @return EE_Default_Where_Conditions[]
544 544
 	 */
545
-	protected function _generate_cap_restrictions( $context ){
546
-		if( isset( $this->_cap_restriction_generators[ $context ] ) &&
547
-				$this->_cap_restriction_generators[ $context ] instanceof EE_Restriction_Generator_Base ) {
548
-			return $this->_cap_restriction_generators[ $context ]->generate_restrictions();
549
-		}else{
545
+	protected function _generate_cap_restrictions($context) {
546
+		if (isset($this->_cap_restriction_generators[$context]) &&
547
+				$this->_cap_restriction_generators[$context] instanceof EE_Restriction_Generator_Base) {
548
+			return $this->_cap_restriction_generators[$context]->generate_restrictions();
549
+		} else {
550 550
 			return array();
551 551
 		}
552 552
 }
@@ -559,16 +559,16 @@  discard block
 block discarded – undo
559 559
 	 *		@param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved).  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)
560 560
 	 *		@return static (as in the concrete child class)
561 561
 	 */
562
-	public static function instance( $timezone = NULL ){
562
+	public static function instance($timezone = NULL) {
563 563
 
564 564
 		// check if instance of Espresso_model already exists
565 565
 		if ( ! static::$_instance instanceof static) {
566 566
 			// instantiate Espresso_model
567
-			static::$_instance = new static( $timezone );
567
+			static::$_instance = new static($timezone);
568 568
 		}
569 569
 
570 570
 		//we might have a timezone set, let set_timezone decide what to do with it
571
-		static::$_instance->set_timezone( $timezone );
571
+		static::$_instance->set_timezone($timezone);
572 572
 
573 573
 		// Espresso_model object
574 574
 		return static::$_instance;
@@ -581,11 +581,11 @@  discard block
 block discarded – undo
581 581
 	 * @param null | string $timezone
582 582
 	 * @return static
583 583
 	 */
584
-	public static function reset(  $timezone = NULL ){
585
-		if ( ! is_null( static::$_instance ) ) {
584
+	public static function reset($timezone = NULL) {
585
+		if ( ! is_null(static::$_instance)) {
586 586
 			static::$_instance = null;
587 587
 
588
-			return self::instance( $timezone );
588
+			return self::instance($timezone);
589 589
 		}
590 590
 		return null;
591 591
 	}
@@ -596,15 +596,15 @@  discard block
 block discarded – undo
596 596
 	 * @param  boolean $translated return localized strings or JUST the array.
597 597
 	 * @return array
598 598
 	 */
599
-	 public function status_array( $translated = FALSE ) {
600
-	 	if ( !array_key_exists('Status', $this->_model_relations ) )
599
+	 public function status_array($translated = FALSE) {
600
+	 	if ( ! array_key_exists('Status', $this->_model_relations))
601 601
 	 		return array();
602 602
 	 	$model_name = $this->get_this_model_name();
603
-	 	$status_type = str_replace(' ', '_', strtolower( str_replace('_', ' ', $model_name) ) );
604
-	 	$stati = EEM_Status::instance()->get_all(array(array('STS_type' => $status_type) ) );
603
+	 	$status_type = str_replace(' ', '_', strtolower(str_replace('_', ' ', $model_name)));
604
+	 	$stati = EEM_Status::instance()->get_all(array(array('STS_type' => $status_type)));
605 605
 	 	$status_array = array();
606
-	 	foreach ( $stati as $status ) {
607
-            $status_array[ $status->ID() ] = $status->get('STS_code');
606
+	 	foreach ($stati as $status) {
607
+            $status_array[$status->ID()] = $status->get('STS_code');
608 608
         }
609 609
         return $translated ? EEM_Status::instance()->localized_status($status_array, FALSE, 'sentence') : $status_array;
610 610
     }
@@ -787,7 +787,7 @@  discard block
 block discarded – undo
787 787
 	 *			'order_by'=>array('ANS_value'=>'ASC')
788 788
 	 *		));
789 789
 	 */
790
-	function get_all($query_params = array()){
790
+	function get_all($query_params = array()) {
791 791
 		return $this->_create_objects($this->_get_all_wpdb_results($query_params, ARRAY_A, NULL));
792 792
 	}
793 793
 
@@ -797,10 +797,10 @@  discard block
 block discarded – undo
797 797
 	 * @param array $query_params @see EEM_Base::get_all()
798 798
 	 * @return array like EEM_Base::get_all
799 799
 	 */
800
-	function alter_query_params_to_only_include_mine( $query_params = array() ) {
800
+	function alter_query_params_to_only_include_mine($query_params = array()) {
801 801
 		$wp_user_field_name = $this->wp_user_field_name();
802
-		if( $wp_user_field_name ){
803
-			$query_params[0][ $wp_user_field_name ] = get_current_user_id();
802
+		if ($wp_user_field_name) {
803
+			$query_params[0][$wp_user_field_name] = get_current_user_id();
804 804
 		}
805 805
 		return $query_params;
806 806
 	}
@@ -813,19 +813,19 @@  discard block
 block discarded – undo
813 813
 	 * foreign key to the WP_User table
814 814
 	 */
815 815
 	function wp_user_field_name() {
816
-		try{
817
-			if( ! empty( $this->_model_chain_to_wp_user ) ) {
818
-				$models_to_follow_to_wp_users = explode( '.', $this->_model_chain_to_wp_user );
819
-				$last_model_name = end( $models_to_follow_to_wp_users );
820
-				$model_with_fk_to_wp_users = EE_Registry::instance()->load_model( $last_model_name );
821
-				$model_chain_to_wp_user = $this->_model_chain_to_wp_user . '.';
822
-			}else{
816
+		try {
817
+			if ( ! empty($this->_model_chain_to_wp_user)) {
818
+				$models_to_follow_to_wp_users = explode('.', $this->_model_chain_to_wp_user);
819
+				$last_model_name = end($models_to_follow_to_wp_users);
820
+				$model_with_fk_to_wp_users = EE_Registry::instance()->load_model($last_model_name);
821
+				$model_chain_to_wp_user = $this->_model_chain_to_wp_user.'.';
822
+			} else {
823 823
 				$model_with_fk_to_wp_users = $this;
824 824
 				$model_chain_to_wp_user = '';
825 825
 			}
826
-			$wp_user_field = $model_with_fk_to_wp_users->get_foreign_key_to( 'WP_User' );
827
-			return $model_chain_to_wp_user . $wp_user_field->get_name();
828
-		}catch( EE_Error $e ) {
826
+			$wp_user_field = $model_with_fk_to_wp_users->get_foreign_key_to('WP_User');
827
+			return $model_chain_to_wp_user.$wp_user_field->get_name();
828
+		} catch (EE_Error $e) {
829 829
 			return false;
830 830
 		}
831 831
 	}
@@ -839,7 +839,7 @@  discard block
 block discarded – undo
839 839
 	 * (or transiently-related model)
840 840
 	 * @return string
841 841
 	 */
842
-	public function model_chain_to_wp_user(){
842
+	public function model_chain_to_wp_user() {
843 843
 		return $this->_model_chain_to_wp_user;
844 844
 	}
845 845
 
@@ -851,13 +851,13 @@  discard block
 block discarded – undo
851 851
 	 * @return boolean
852 852
 	 */
853 853
 	public function is_owned() {
854
-		if( $this->model_chain_to_wp_user() ){
854
+		if ($this->model_chain_to_wp_user()) {
855 855
 			return true;
856
-		}else{
857
-			try{
858
-				$this->get_foreign_key_to( 'WP_User' );
856
+		} else {
857
+			try {
858
+				$this->get_foreign_key_to('WP_User');
859 859
 				return true;
860
-			}catch( EE_Error $e ){
860
+			} catch (EE_Error $e) {
861 861
 				return false;
862 862
 			}
863 863
 		}
@@ -876,21 +876,21 @@  discard block
 block discarded – undo
876 876
 	 * and 1 is the data type. Eg, array('count'=>array('COUNT(REG_ID)','%d'))
877 877
 	 * @return array | stdClass[] like results of $wpdb->get_results($sql,OBJECT), (ie, output type is OBJECT)
878 878
 	 */
879
-	protected function  _get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null){
879
+	protected function  _get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null) {
880 880
 		//remember the custom selections, if any
881
-		if(is_array($columns_to_select)){
881
+		if (is_array($columns_to_select)) {
882 882
 			$this->_custom_selections = $columns_to_select;
883
-		}elseif(is_string($columns_to_select)){
883
+		}elseif (is_string($columns_to_select)) {
884 884
 			$this->_custom_selections = array($this->_custom_selections);
885
-		}else{
885
+		} else {
886 886
 			$this->_custom_selections = array();
887 887
 		}
888 888
 
889 889
 		$model_query_info = $this->_create_model_query_info_carrier($query_params);
890 890
 		$select_expressions = $columns_to_select ? $this->_construct_select_from_input($columns_to_select) : $this->_construct_default_select_sql($model_query_info);
891
-		$SQL ="SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info);
891
+		$SQL = "SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info);
892 892
 //		echo "sql:$SQL";
893
-		$results =  $this->_do_wpdb_query( 'get_results', array($SQL, $output ) );// $wpdb->get_results($SQL, $output);
893
+		$results = $this->_do_wpdb_query('get_results', array($SQL, $output)); // $wpdb->get_results($SQL, $output);
894 894
 		return $results;
895 895
 	}
896 896
 
@@ -908,7 +908,7 @@  discard block
 block discarded – undo
908 908
 	 * and 1 is the data type. Eg, array('count'=>array('COUNT(REG_ID)','%d'))
909 909
 	 * @return array|stdClass[] like results of $wpdb->get_results($sql,OBJECT), (ie, output type is OBJECT)
910 910
 	 */
911
-	public function  get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null){
911
+	public function  get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null) {
912 912
 		return $this->_get_all_wpdb_results($query_params, $output, $columns_to_select);
913 913
 	}
914 914
 
@@ -920,12 +920,12 @@  discard block
 block discarded – undo
920 920
 	 * @throws EE_Error
921 921
 	 * @return string
922 922
 	 */
923
-	private function _construct_select_from_input($columns_to_select){
924
-		if(is_array($columns_to_select)){
923
+	private function _construct_select_from_input($columns_to_select) {
924
+		if (is_array($columns_to_select)) {
925 925
 			$select_sql_array = array();
926 926
 
927
-			foreach($columns_to_select as $alias => $selection_and_datatype){
928
-				if( ! is_array($selection_and_datatype) || ! isset($selection_and_datatype[1])){
927
+			foreach ($columns_to_select as $alias => $selection_and_datatype) {
928
+				if ( ! is_array($selection_and_datatype) || ! isset($selection_and_datatype[1])) {
929 929
 					throw new EE_Error(
930 930
 						sprintf(
931 931
 							__(
@@ -937,24 +937,24 @@  discard block
 block discarded – undo
937 937
 						)
938 938
 					);
939 939
 				}
940
-				if( ! in_array( $selection_and_datatype[1],$this->_valid_wpdb_data_types)){
940
+				if ( ! in_array($selection_and_datatype[1], $this->_valid_wpdb_data_types)) {
941 941
 					throw new EE_Error(
942 942
 						sprintf(
943 943
 							__(
944 944
 								"Datatype %s (for selection '%s' and alias '%s') is not a valid wpdb datatype (eg %%s)",
945 945
 								"event_espresso"
946 946
 							),
947
-							$selection_and_datatype[ 1 ],
948
-							$selection_and_datatype[ 0 ],
947
+							$selection_and_datatype[1],
948
+							$selection_and_datatype[0],
949 949
 							$alias,
950
-							implode( ",", $this->_valid_wpdb_data_types )
950
+							implode(",", $this->_valid_wpdb_data_types)
951 951
 						)
952 952
 					);
953 953
 				}
954 954
 				$select_sql_array[] = "{$selection_and_datatype[0]} AS $alias";
955 955
 			}
956
-			$columns_to_select_string = implode(", ",$select_sql_array);
957
-		}else{
956
+			$columns_to_select_string = implode(", ", $select_sql_array);
957
+		} else {
958 958
 			$columns_to_select_string = $columns_to_select;
959 959
 		}
960 960
 		return $columns_to_select_string;
@@ -967,7 +967,7 @@  discard block
 block discarded – undo
967 967
 	 * Convenient wrapper for getting the primary key field's name. Eg, on Registration, this would be 'REG_ID'
968 968
 	 * @return string
969 969
 	 */
970
-	function primary_key_name(){
970
+	function primary_key_name() {
971 971
 		return $this->get_primary_key_field()->get_name();
972 972
 	}
973 973
 
@@ -979,14 +979,14 @@  discard block
 block discarded – undo
979 979
 	 * @param mixed $id int or string, depending on the type of the model's primary key
980 980
 	 * @return EE_Base_Class
981 981
 	 */
982
-	function get_one_by_ID($id){
983
-		if( $this->get_from_entity_map( $id ) ){
984
-			return $this->get_from_entity_map( $id );
982
+	function get_one_by_ID($id) {
983
+		if ($this->get_from_entity_map($id)) {
984
+			return $this->get_from_entity_map($id);
985 985
 		}
986 986
 		return $this->get_one( 
987 987
 			$this->alter_query_params_to_restrict_by_ID( 
988 988
 				$id,
989
-				array( 'default_where_conditions' => 'minimum' )
989
+				array('default_where_conditions' => 'minimum')
990 990
 			) 
991 991
 		);
992 992
 	}
@@ -998,15 +998,15 @@  discard block
 block discarded – undo
998 998
 	 * @param array $query_params
999 999
 	 * @return array of normal query params, @see EEM_Base::get_all
1000 1000
 	 */
1001
-	public function alter_query_params_to_restrict_by_ID( $id, $query_params = array() ) {
1002
-		if( ! isset( $query_params[ 0 ] ) ) {
1003
-			$query_params[ 0 ] = array();
1001
+	public function alter_query_params_to_restrict_by_ID($id, $query_params = array()) {
1002
+		if ( ! isset($query_params[0])) {
1003
+			$query_params[0] = array();
1004 1004
 		}
1005
-		if( $this->has_primary_key_field ( ) ) {
1006
-			$query_params[ 0 ][ $this->primary_key_name() ] = $id ;
1007
-		}else{
1005
+		if ($this->has_primary_key_field( )) {
1006
+			$query_params[0][$this->primary_key_name()] = $id;
1007
+		} else {
1008 1008
 			//no primary key, so the $id must be from the get_index_primary_key_string()
1009
-			$query_params[0] = array_replace_recursive( $query_params[ 0 ], $this->parse_index_primary_key_string( $id ) );
1009
+			$query_params[0] = array_replace_recursive($query_params[0], $this->parse_index_primary_key_string($id));
1010 1010
 		}
1011 1011
 		return $query_params;
1012 1012
 	}
@@ -1018,16 +1018,16 @@  discard block
 block discarded – undo
1018 1018
 	 * @param array $query_params like EEM_Base's $query_params variable.
1019 1019
 	 * @return EE_Base_Class | NULL
1020 1020
 	 */
1021
-	function get_one($query_params = array()){
1022
-		if( ! is_array( $query_params ) ){
1023
-			EE_Error::doing_it_wrong('EEM_Base::get_one', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' );
1021
+	function get_one($query_params = array()) {
1022
+		if ( ! is_array($query_params)) {
1023
+			EE_Error::doing_it_wrong('EEM_Base::get_one', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0');
1024 1024
 			$query_params = array();
1025 1025
 		}
1026 1026
 		$query_params['limit'] = 1;
1027 1027
 		$items = $this->get_all($query_params);
1028
-		if(empty($items)){
1028
+		if (empty($items)) {
1029 1029
 			return null;
1030
-		}else{
1030
+		} else {
1031 1031
 			return array_shift($items);
1032 1032
 		}
1033 1033
 	}
@@ -1051,8 +1051,8 @@  discard block
 block discarded – undo
1051 1051
 	 *
1052 1052
 	 * @return EE_Base_Class[]|array
1053 1053
 	 */
1054
-	public function next_x( $current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) {
1055
-		return $this->_get_consecutive( $current_field_value, '>', $field_to_order_by, $limit, $query_params, $columns_to_select );
1054
+	public function next_x($current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) {
1055
+		return $this->_get_consecutive($current_field_value, '>', $field_to_order_by, $limit, $query_params, $columns_to_select);
1056 1056
 	}
1057 1057
 
1058 1058
 
@@ -1075,8 +1075,8 @@  discard block
 block discarded – undo
1075 1075
 	 *
1076 1076
 	 * @return EE_Base_Class[]|array
1077 1077
 	 */
1078
-	public function previous_x( $current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) {
1079
-		return $this->_get_consecutive( $current_field_value, '<', $field_to_order_by, $limit, $query_params, $columns_to_select );
1078
+	public function previous_x($current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) {
1079
+		return $this->_get_consecutive($current_field_value, '<', $field_to_order_by, $limit, $query_params, $columns_to_select);
1080 1080
 	}
1081 1081
 
1082 1082
 
@@ -1098,9 +1098,9 @@  discard block
 block discarded – undo
1098 1098
 	 *
1099 1099
 	 * @return EE_Base_Class|null|array()
1100 1100
 	 */
1101
-	public function next( $current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) {
1102
-		$results = $this->_get_consecutive( $current_field_value, '>', $field_to_order_by, 1, $query_params, $columns_to_select );
1103
-		return empty( $results ) ? null : reset( $results );
1101
+	public function next($current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null) {
1102
+		$results = $this->_get_consecutive($current_field_value, '>', $field_to_order_by, 1, $query_params, $columns_to_select);
1103
+		return empty($results) ? null : reset($results);
1104 1104
 	}
1105 1105
 
1106 1106
 
@@ -1122,9 +1122,9 @@  discard block
 block discarded – undo
1122 1122
 	 *
1123 1123
 	 * @return EE_Base_Class|null|array()
1124 1124
 	 */
1125
-	public function previous( $current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) {
1126
-		$results = $this->_get_consecutive( $current_field_value, '<', $field_to_order_by, 1, $query_params, $columns_to_select );
1127
-		return empty( $results ) ? null : reset( $results );
1125
+	public function previous($current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null) {
1126
+		$results = $this->_get_consecutive($current_field_value, '<', $field_to_order_by, 1, $query_params, $columns_to_select);
1127
+		return empty($results) ? null : reset($results);
1128 1128
 	}
1129 1129
 
1130 1130
 
@@ -1150,40 +1150,40 @@  discard block
 block discarded – undo
1150 1150
 	 * @return EE_Base_Class[]|array
1151 1151
 	 * @throws EE_Error
1152 1152
 	 */
1153
-	protected function _get_consecutive( $current_field_value, $operand = '>', $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) {
1153
+	protected function _get_consecutive($current_field_value, $operand = '>', $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) {
1154 1154
 		//if $field_to_order_by is empty then let's assume we're ordering by the primary key.
1155
-		if ( empty( $field_to_order_by ) ) {
1156
-			if ( $this->has_primary_key_field() ) {
1155
+		if (empty($field_to_order_by)) {
1156
+			if ($this->has_primary_key_field()) {
1157 1157
 				$field_to_order_by = $this->get_primary_key_field()->get_name();
1158 1158
 			} else {
1159 1159
 
1160
-				if ( WP_DEBUG ) {
1161
-					throw new EE_Error( __( 'EEM_Base::_get_consecutive() has been called with no $field_to_order_by argument and there is no primary key on the field.  Please provide the field you would like to use as the base for retrieving the next item(s).', 'event_espresso' ) );
1160
+				if (WP_DEBUG) {
1161
+					throw new EE_Error(__('EEM_Base::_get_consecutive() has been called with no $field_to_order_by argument and there is no primary key on the field.  Please provide the field you would like to use as the base for retrieving the next item(s).', 'event_espresso'));
1162 1162
 				}
1163
-				EE_Error::add_error( __('There was an error with the query.', 'event_espresso') );
1163
+				EE_Error::add_error(__('There was an error with the query.', 'event_espresso'));
1164 1164
 				return array();
1165 1165
 			}
1166 1166
 		}
1167 1167
 
1168
-		if( ! is_array( $query_params ) ){
1169
-			EE_Error::doing_it_wrong('EEM_Base::_get_consecutive', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' );
1168
+		if ( ! is_array($query_params)) {
1169
+			EE_Error::doing_it_wrong('EEM_Base::_get_consecutive', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0');
1170 1170
 			$query_params = array();
1171 1171
 		}
1172 1172
 
1173 1173
 		//let's add the where query param for consecutive look up.
1174
-		$query_params[0][ $field_to_order_by ] = array( $operand, $current_field_value );
1174
+		$query_params[0][$field_to_order_by] = array($operand, $current_field_value);
1175 1175
 		$query_params['limit'] = $limit;
1176 1176
 
1177 1177
 		//set direction
1178
-		$incoming_orderby = isset( $query_params['order_by'] ) ? $query_params['order_by'] : array();
1179
-		$query_params['order_by'] = $operand == '>' ? array( $field_to_order_by => 'ASC' ) + $incoming_orderby : array( $field_to_order_by => 'DESC') + $incoming_orderby;
1178
+		$incoming_orderby = isset($query_params['order_by']) ? $query_params['order_by'] : array();
1179
+		$query_params['order_by'] = $operand == '>' ? array($field_to_order_by => 'ASC') + $incoming_orderby : array($field_to_order_by => 'DESC') + $incoming_orderby;
1180 1180
 
1181 1181
 		//if $columns_to_select is empty then that means we're returning EE_Base_Class objects
1182
-		if ( empty( $columns_to_select ) ) {
1183
-			return $this->get_all( $query_params );
1182
+		if (empty($columns_to_select)) {
1183
+			return $this->get_all($query_params);
1184 1184
 		} else {
1185 1185
 			//getting just the fields
1186
-			return $this->_get_all_wpdb_results( $query_params, ARRAY_A, $columns_to_select );
1186
+			return $this->_get_all_wpdb_results($query_params, ARRAY_A, $columns_to_select);
1187 1187
 		}
1188 1188
 	}
1189 1189
 
@@ -1194,18 +1194,18 @@  discard block
 block discarded – undo
1194 1194
 	 * This sets the _timezone property after model object has been instantiated.
1195 1195
 	 * @param null | string $timezone valid PHP DateTimeZone timezone string
1196 1196
 	 */
1197
-	public function set_timezone( $timezone ) {
1198
-		if ( $timezone !== null ) {
1197
+	public function set_timezone($timezone) {
1198
+		if ($timezone !== null) {
1199 1199
 			$this->_timezone = $timezone;
1200 1200
 		}
1201 1201
 		//note we need to loop through relations and set the timezone on those objects as well.
1202
-		foreach ( $this->_model_relations as $relation ) {
1203
-			$relation->set_timezone( $timezone );
1202
+		foreach ($this->_model_relations as $relation) {
1203
+			$relation->set_timezone($timezone);
1204 1204
 		}
1205 1205
 		//and finally we do the same for any datetime fields
1206
-		foreach ( $this->_fields as $field ) {
1207
-			if ( $field instanceof EE_Datetime_Field ) {
1208
-				$field->set_timezone( $timezone );
1206
+		foreach ($this->_fields as $field) {
1207
+			if ($field instanceof EE_Datetime_Field) {
1208
+				$field->set_timezone($timezone);
1209 1209
 			}
1210 1210
 		}
1211 1211
 	}
@@ -1220,9 +1220,9 @@  discard block
 block discarded – undo
1220 1220
 	 */
1221 1221
 	public function get_timezone() {
1222 1222
 		//first validate if timezone is set.  If not, then let's set it be whatever is set on the model fields.
1223
-		if ( empty( $this->_timezone ) ) {
1224
-			foreach( $this->_fields as $field ) {
1225
-				if ( $field instanceof EE_Datetime_Field ) {
1223
+		if (empty($this->_timezone)) {
1224
+			foreach ($this->_fields as $field) {
1225
+				if ($field instanceof EE_Datetime_Field) {
1226 1226
 					$this->set_timezone($field->get_timezone());
1227 1227
 					break;
1228 1228
 				}
@@ -1230,9 +1230,9 @@  discard block
 block discarded – undo
1230 1230
 		}
1231 1231
 
1232 1232
 		//if timezone STILL empty then return the default timezone for the site.
1233
-		if ( empty( $this->_timezone ) ) {
1234
-			EE_Registry::instance()->load_helper( 'DTT_Helper' );
1235
-			$this->set_timezone( EEH_DTT_Helper::get_timezone() );
1233
+		if (empty($this->_timezone)) {
1234
+			EE_Registry::instance()->load_helper('DTT_Helper');
1235
+			$this->set_timezone(EEH_DTT_Helper::get_timezone());
1236 1236
 		}
1237 1237
 		return $this->_timezone;
1238 1238
 	}
@@ -1250,19 +1250,19 @@  discard block
 block discarded – undo
1250 1250
 	 *
1251 1251
 	 * @return array formats in an array with the date format first, and the time format last.
1252 1252
 	 */
1253
-	public function get_formats_for( $field_name, $pretty = false ) {
1254
-		$field_settings = $this->field_settings_for( $field_name );
1253
+	public function get_formats_for($field_name, $pretty = false) {
1254
+		$field_settings = $this->field_settings_for($field_name);
1255 1255
 
1256 1256
 		//if not a valid EE_Datetime_Field then throw error
1257
-		if ( ! $field_settings instanceof EE_Datetime_Field ) {
1258
-			throw new EE_Error( sprintf( __('The field sent into EEM_Base::get_formats_for (%s) is not registered as a EE_Datetime_Field. Please check the spelling and make sure you are submitting the right field name to retrieve date_formats for.', 'event_espresso' ), $field_name ) );
1257
+		if ( ! $field_settings instanceof EE_Datetime_Field) {
1258
+			throw new EE_Error(sprintf(__('The field sent into EEM_Base::get_formats_for (%s) is not registered as a EE_Datetime_Field. Please check the spelling and make sure you are submitting the right field name to retrieve date_formats for.', 'event_espresso'), $field_name));
1259 1259
 		}
1260 1260
 
1261 1261
 		//while we are here, let's make sure the timezone internally in EEM_Base matches what is stored on
1262 1262
 		//the field.
1263 1263
 		$this->_timezone = $field_settings->get_timezone();
1264 1264
 
1265
-		return array( $field_settings->get_date_format( $pretty ), $field_settings->get_time_format( $pretty ) );
1265
+		return array($field_settings->get_date_format($pretty), $field_settings->get_time_format($pretty));
1266 1266
 	}
1267 1267
 
1268 1268
 
@@ -1286,25 +1286,25 @@  discard block
 block discarded – undo
1286 1286
 	 * @return int|string  If the given field_name is not of the EE_Datetime_Field type, then an EE_Error
1287 1287
 	 *                    	     exception is triggered.
1288 1288
 	 */
1289
-	public function current_time_for_query( $field_name, $timestamp = false, $what = 'both' ) {
1290
-		$formats = $this->get_formats_for( $field_name );
1289
+	public function current_time_for_query($field_name, $timestamp = false, $what = 'both') {
1290
+		$formats = $this->get_formats_for($field_name);
1291 1291
 
1292
-		$DateTime = new DateTime( "now", new DateTimeZone( $this->_timezone ) );
1292
+		$DateTime = new DateTime("now", new DateTimeZone($this->_timezone));
1293 1293
 
1294
-		if ( $timestamp ) {
1295
-			return $DateTime->format( 'U' );
1294
+		if ($timestamp) {
1295
+			return $DateTime->format('U');
1296 1296
 		}
1297 1297
 
1298 1298
 		//not returning timestamp, so return formatted string in timezone.
1299
-		switch( $what ) {
1299
+		switch ($what) {
1300 1300
 			case 'time' :
1301
-				return $DateTime->format( $formats[1] );
1301
+				return $DateTime->format($formats[1]);
1302 1302
 				break;
1303 1303
 			case 'date' :
1304
-				return $DateTime->format( $formats[0] );
1304
+				return $DateTime->format($formats[0]);
1305 1305
 				break;
1306 1306
 			default :
1307
-				return $DateTime->format( implode( ' ', $formats ) );
1307
+				return $DateTime->format(implode(' ', $formats));
1308 1308
 				break;
1309 1309
 		}
1310 1310
 	}
@@ -1328,20 +1328,20 @@  discard block
 block discarded – undo
1328 1328
 	 *                           		'U', this is ignored.
1329 1329
 	 * @return DateTime
1330 1330
 	 */
1331
-	public function convert_datetime_for_query( $field_name, $timestring, $incoming_format, $timezone = '' ) {
1331
+	public function convert_datetime_for_query($field_name, $timestring, $incoming_format, $timezone = '') {
1332 1332
 
1333 1333
 		//just using this to ensure the timezone is set correctly internally
1334
-		$this->get_formats_for( $field_name );
1334
+		$this->get_formats_for($field_name);
1335 1335
 
1336 1336
 		//load EEH_DTT_Helper
1337
-		EE_Registry::instance()->load_helper( 'DTT_Helper' );
1338
-		$set_timezone = empty( $timezone ) ? EEH_DTT_Helper::get_timezone() : $timezone;
1337
+		EE_Registry::instance()->load_helper('DTT_Helper');
1338
+		$set_timezone = empty($timezone) ? EEH_DTT_Helper::get_timezone() : $timezone;
1339 1339
 
1340
-		$incomingDateTime = date_create_from_format( $incoming_format, $timestring, new DateTimeZone( $set_timezone ) );
1341
-		if( $incomingDateTime ) {
1342
-			return $incomingDateTime->setTimeZone( new DateTimeZone( $this->_timezone ) );
1340
+		$incomingDateTime = date_create_from_format($incoming_format, $timestring, new DateTimeZone($set_timezone));
1341
+		if ($incomingDateTime) {
1342
+			return $incomingDateTime->setTimeZone(new DateTimeZone($this->_timezone));
1343 1343
 		} else {
1344
-			return new DateTime( null, new DateTimeZone( $set_timezone ) );
1344
+			return new DateTime(null, new DateTimeZone($set_timezone));
1345 1345
 		}
1346 1346
 	}
1347 1347
 
@@ -1352,7 +1352,7 @@  discard block
 block discarded – undo
1352 1352
 	 * Gets all the tables comprising this model. Array keys are the table aliases, and values are EE_Table objects
1353 1353
 	 * @return EE_Table_Base[]
1354 1354
 	 */
1355
-	function get_tables(){
1355
+	function get_tables() {
1356 1356
 		return $this->_tables;
1357 1357
 	}
1358 1358
 
@@ -1386,9 +1386,9 @@  discard block
 block discarded – undo
1386 1386
 	 * be aware that model objects being used could get out-of-sync with the database
1387 1387
 	 * @return int how many rows got updated or FALSE if something went wrong with the query (wp returns FALSE or num rows affected which *could* include 0 which DOES NOT mean the query was bad)
1388 1388
 	 */
1389
-	function update($fields_n_values, $query_params, $keep_model_objs_in_sync = TRUE){
1390
-		if( ! is_array( $query_params ) ){
1391
-			EE_Error::doing_it_wrong('EEM_Base::update', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' );
1389
+	function update($fields_n_values, $query_params, $keep_model_objs_in_sync = TRUE) {
1390
+		if ( ! is_array($query_params)) {
1391
+			EE_Error::doing_it_wrong('EEM_Base::update', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0');
1392 1392
 			$query_params = array();
1393 1393
 		}
1394 1394
 		/**
@@ -1398,7 +1398,7 @@  discard block
 block discarded – undo
1398 1398
 		 * @param array $fields_n_values the updated fields and their new values
1399 1399
 		 * @param array $query_params @see EEM_Base::get_all()
1400 1400
 		 */
1401
-		do_action( 'AHEE__EEM_Base__update__begin',$this, $fields_n_values, $query_params );
1401
+		do_action('AHEE__EEM_Base__update__begin', $this, $fields_n_values, $query_params);
1402 1402
 		/**
1403 1403
 		 * Filters the fields about to be updated given the query parameters. You can provide the
1404 1404
 		 * $query_params to $this->get_all() to find exactly which records will be updated
@@ -1406,10 +1406,10 @@  discard block
 block discarded – undo
1406 1406
 		 * @param EEM_Base $model the model being queried
1407 1407
 		 * @param array $query_params see EEM_Base::get_all()
1408 1408
 		 */
1409
-		$fields_n_values = apply_filters( 'FHEE__EEM_Base__update__fields_n_values', $fields_n_values, $this, $query_params );
1409
+		$fields_n_values = apply_filters('FHEE__EEM_Base__update__fields_n_values', $fields_n_values, $this, $query_params);
1410 1410
 		//need to verify that, for any entry we want to update, there are entries in each secondary table.
1411 1411
 		//to do that, for each table, verify that it's PK isn't null.
1412
-		$tables= $this->get_tables();
1412
+		$tables = $this->get_tables();
1413 1413
 
1414 1414
 		//and if the other tables don't have a row for each table-to-be-updated, we'll insert one with whatever values available in the current update query
1415 1415
 		//NOTE: we should make this code more efficient by NOT querying twice
@@ -1419,29 +1419,29 @@  discard block
 block discarded – undo
1419 1419
 			//we want to make sure the default_where strategy is ignored
1420 1420
 			$this->_ignore_where_strategy = TRUE;
1421 1421
 			$wpdb_select_results = $this->_get_all_wpdb_results($query_params);
1422
-			foreach( $wpdb_select_results as $wpdb_result ){
1422
+			foreach ($wpdb_select_results as $wpdb_result) {
1423 1423
 				// type cast stdClass as array
1424
-				$wpdb_result = (array)$wpdb_result;
1424
+				$wpdb_result = (array) $wpdb_result;
1425 1425
 				//get the model object's PK, as we'll want this if we need to insert a row into secondary tables
1426
-				if( $this->has_primary_key_field() ){
1427
-					$main_table_pk_value = $wpdb_result[ $this->get_primary_key_field()->get_qualified_column() ];
1428
-				}else{
1426
+				if ($this->has_primary_key_field()) {
1427
+					$main_table_pk_value = $wpdb_result[$this->get_primary_key_field()->get_qualified_column()];
1428
+				} else {
1429 1429
 					//if there's no primary key, we basically can't support having a 2nd table on the model (we could but it would be lots of work)
1430 1430
 					$main_table_pk_value = null;
1431 1431
 				}
1432 1432
 				//if there are more than 1 tables, we'll want to verify that each table for this model has an entry in the other tables
1433 1433
 				//and if the other tables don't have a row for each table-to-be-updated, we'll insert one with whatever values available in the current update query
1434
-				if(count($tables) > 1){
1434
+				if (count($tables) > 1) {
1435 1435
 					//foreach matching row in the DB, ensure that each table's PK isn't null. If so, there must not be an entry
1436 1436
 					//in that table, and so we'll want to insert one
1437
-					foreach($tables as $table_obj){
1437
+					foreach ($tables as $table_obj) {
1438 1438
 						$this_table_pk_column = $table_obj->get_fully_qualified_pk_column();
1439 1439
 						//if there is no private key for this table on the results, it means there's no entry
1440 1440
 						//in this table, right? so insert a row in the current table, using any fields available
1441
-						if( ! ( array_key_exists( $this_table_pk_column, $wpdb_result) && $wpdb_result[ $this_table_pk_column ] )){
1441
+						if ( ! (array_key_exists($this_table_pk_column, $wpdb_result) && $wpdb_result[$this_table_pk_column])) {
1442 1442
 							$success = $this->_insert_into_specific_table($table_obj, $fields_n_values, $main_table_pk_value);
1443 1443
 							//if we died here, report the error
1444
-							if( ! $success ) {
1444
+							if ( ! $success) {
1445 1445
 								return false;
1446 1446
 							}
1447 1447
 						}
@@ -1461,44 +1461,44 @@  discard block
 block discarded – undo
1461 1461
 		//if this wasn't called from a model object (to update itself)
1462 1462
 		//then we want to make sure we keep all the existing
1463 1463
 		//model objects in sync with the db
1464
-		if( $keep_model_objs_in_sync && ! $this->_values_already_prepared_by_model_object ){
1465
-			if( $this->has_primary_key_field() ){
1466
-				$model_objs_affected_ids = $this->get_col( $query_params );
1467
-			}else{
1464
+		if ($keep_model_objs_in_sync && ! $this->_values_already_prepared_by_model_object) {
1465
+			if ($this->has_primary_key_field()) {
1466
+				$model_objs_affected_ids = $this->get_col($query_params);
1467
+			} else {
1468 1468
 				//we need to select a bunch of columns and then combine them into the the "index primary key string"s
1469
-				$models_affected_key_columns = $this->_get_all_wpdb_results($query_params, ARRAY_A );
1469
+				$models_affected_key_columns = $this->_get_all_wpdb_results($query_params, ARRAY_A);
1470 1470
 				$model_objs_affected_ids = array();
1471
-				foreach( $models_affected_key_columns as $row ){
1472
-					$combined_index_key = $this->get_index_primary_key_string( $row );
1473
-					$model_objs_affected_ids[ $combined_index_key ] = $combined_index_key;
1471
+				foreach ($models_affected_key_columns as $row) {
1472
+					$combined_index_key = $this->get_index_primary_key_string($row);
1473
+					$model_objs_affected_ids[$combined_index_key] = $combined_index_key;
1474 1474
 				}
1475 1475
 
1476 1476
 			}
1477 1477
 
1478
-			if( ! $model_objs_affected_ids ){
1478
+			if ( ! $model_objs_affected_ids) {
1479 1479
 				//wait wait wait- if nothing was affected let's stop here
1480 1480
 				return 0;
1481 1481
 			}
1482
-			foreach( $model_objs_affected_ids as $id ){
1483
-				$model_obj_in_entity_map = $this->get_from_entity_map( $id );
1484
-				if( $model_obj_in_entity_map ){
1485
-					foreach( $fields_n_values as $field => $new_value ){
1486
-						$model_obj_in_entity_map->set( $field, $new_value );
1482
+			foreach ($model_objs_affected_ids as $id) {
1483
+				$model_obj_in_entity_map = $this->get_from_entity_map($id);
1484
+				if ($model_obj_in_entity_map) {
1485
+					foreach ($fields_n_values as $field => $new_value) {
1486
+						$model_obj_in_entity_map->set($field, $new_value);
1487 1487
 					}
1488 1488
 				}
1489 1489
 			}
1490 1490
 			//if there is a primary key on this model, we can now do a slight optimization
1491
-			if( $this->has_primary_key_field() ){
1491
+			if ($this->has_primary_key_field()) {
1492 1492
 				//we already know what we want to update. So let's make the query simpler so it's a little more efficient
1493 1493
 				$query_params = array(
1494
-					array( $this->primary_key_name() => array( 'IN', $model_objs_affected_ids ) ),
1495
-					'limit' => count( $model_objs_affected_ids ), 'default_where_conditions' => 'none' );
1494
+					array($this->primary_key_name() => array('IN', $model_objs_affected_ids)),
1495
+					'limit' => count($model_objs_affected_ids), 'default_where_conditions' => 'none' );
1496 1496
 			}
1497 1497
 		}
1498 1498
 
1499
-		$model_query_info = $this->_create_model_query_info_carrier( $query_params );
1500
-		$SQL = "UPDATE ".$model_query_info->get_full_join_sql()." SET ".$this->_construct_update_sql($fields_n_values).$model_query_info->get_where_sql();//note: doesn't use _construct_2nd_half_of_select_query() because doesn't accept LIMIT, ORDER BY, etc.
1501
-		$rows_affected = $this->_do_wpdb_query('query', array( $SQL ) );
1499
+		$model_query_info = $this->_create_model_query_info_carrier($query_params);
1500
+		$SQL = "UPDATE ".$model_query_info->get_full_join_sql()." SET ".$this->_construct_update_sql($fields_n_values).$model_query_info->get_where_sql(); //note: doesn't use _construct_2nd_half_of_select_query() because doesn't accept LIMIT, ORDER BY, etc.
1501
+		$rows_affected = $this->_do_wpdb_query('query', array($SQL));
1502 1502
 		/**
1503 1503
 		 * Action called after a model update call has been made.
1504 1504
 		 *
@@ -1507,8 +1507,8 @@  discard block
 block discarded – undo
1507 1507
 		 * @param array $query_params @see EEM_Base::get_all()
1508 1508
 		 * @param int $rows_affected
1509 1509
 		 */
1510
-		do_action( 'AHEE__EEM_Base__update__end',$this, $fields_n_values, $query_params, $rows_affected );
1511
-		return $rows_affected;//how many supposedly got updated
1510
+		do_action('AHEE__EEM_Base__update__end', $this, $fields_n_values, $query_params, $rows_affected);
1511
+		return $rows_affected; //how many supposedly got updated
1512 1512
 	}
1513 1513
 
1514 1514
 	/**
@@ -1520,22 +1520,22 @@  discard block
 block discarded – undo
1520 1520
 	 * @param string $field_to_select
1521 1521
 	 * @return array just like $wpdb->get_col()
1522 1522
 	 */
1523
-	public function get_col( $query_params  = array(), $field_to_select = NULL ){
1523
+	public function get_col($query_params = array(), $field_to_select = NULL) {
1524 1524
 
1525
-		if( $field_to_select ){
1526
-			$field = $this->field_settings_for( $field_to_select );
1527
-		}elseif( $this->has_primary_key_field ( ) ){
1525
+		if ($field_to_select) {
1526
+			$field = $this->field_settings_for($field_to_select);
1527
+		}elseif ($this->has_primary_key_field( )) {
1528 1528
 			$field = $this->get_primary_key_field();
1529
-		}else{
1529
+		} else {
1530 1530
 			//no primary key, just grab the first column
1531
-			$field = reset( $this->field_settings());
1531
+			$field = reset($this->field_settings());
1532 1532
 		}
1533 1533
 
1534 1534
 
1535 1535
 		$model_query_info = $this->_create_model_query_info_carrier($query_params);
1536 1536
 		$select_expressions = $field->get_qualified_column();
1537
-		$SQL ="SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info);
1538
-		$results =  $this->_do_wpdb_query('get_col', array( $SQL ) );
1537
+		$SQL = "SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info);
1538
+		$results = $this->_do_wpdb_query('get_col', array($SQL));
1539 1539
 		return $results;
1540 1540
 	}
1541 1541
 
@@ -1545,12 +1545,12 @@  discard block
 block discarded – undo
1545 1545
 	 * @param string $field_to_select @see EEM_Base::get_col()
1546 1546
 	 * @return string
1547 1547
 	 */
1548
-	public function get_var( $query_params = array(), $field_to_select = NULL ) {
1549
-		$query_params[ 'limit' ] = 1;
1550
-		$col = $this->get_col( $query_params, $field_to_select );
1551
-		if( ! empty( $col ) ) {
1552
-			return reset( $col );
1553
-		}else{
1548
+	public function get_var($query_params = array(), $field_to_select = NULL) {
1549
+		$query_params['limit'] = 1;
1550
+		$col = $this->get_col($query_params, $field_to_select);
1551
+		if ( ! empty($col)) {
1552
+			return reset($col);
1553
+		} else {
1554 1554
 			return NULL;
1555 1555
 		}
1556 1556
 	}
@@ -1564,19 +1564,19 @@  discard block
 block discarded – undo
1564 1564
 	 * @param array $fields_n_values array keys are field names on this model, and values are what those fields should be updated to in the DB
1565 1565
 	 * @return string of SQL
1566 1566
 	 */
1567
-	function _construct_update_sql($fields_n_values){
1567
+	function _construct_update_sql($fields_n_values) {
1568 1568
 		/** @type WPDB $wpdb */
1569 1569
 		global $wpdb;
1570 1570
 		$cols_n_values = array();
1571
-		foreach($fields_n_values as $field_name => $value){
1571
+		foreach ($fields_n_values as $field_name => $value) {
1572 1572
 			$field_obj = $this->field_settings_for($field_name);
1573 1573
 			//if the value is NULL, we want to assign the value to that.
1574 1574
 			//wpdb->prepare doesn't really handle that properly
1575
-			$prepared_value = $this->_prepare_value_or_use_default( $field_obj, $fields_n_values );
1576
-			$value_sql = $prepared_value===NULL ? 'NULL' : $wpdb->prepare( $field_obj->get_wpdb_data_type(), $prepared_value );
1575
+			$prepared_value = $this->_prepare_value_or_use_default($field_obj, $fields_n_values);
1576
+			$value_sql = $prepared_value === NULL ? 'NULL' : $wpdb->prepare($field_obj->get_wpdb_data_type(), $prepared_value);
1577 1577
 			$cols_n_values[] = $field_obj->get_qualified_column()."=".$value_sql;
1578 1578
 		}
1579
-		return implode(",",$cols_n_values);
1579
+		return implode(",", $cols_n_values);
1580 1580
 
1581 1581
 	}
1582 1582
 	
@@ -1589,10 +1589,10 @@  discard block
 block discarded – undo
1589 1589
 	 * @param boolean $allow_blocking whether to block deletion if related things exist, or not
1590 1590
 	 * @return boolean whether the row got deleted or not
1591 1591
 	 */
1592
-	public function delete_permanently_by_ID( $id, $allow_blocking = true ) {
1592
+	public function delete_permanently_by_ID($id, $allow_blocking = true) {
1593 1593
 		return $this->delete_permanently( 
1594 1594
 			array(
1595
-				array( $this->get_primary_key_field()->get_name() => $id ),
1595
+				array($this->get_primary_key_field()->get_name() => $id),
1596 1596
 				'limit' 	=> 1
1597 1597
 			),
1598 1598
 			$allow_blocking
@@ -1610,10 +1610,10 @@  discard block
 block discarded – undo
1610 1610
 	 * which may depend on it. Its generally advisable to always leave this as TRUE, otherwise you could easily corrupt your DB
1611 1611
 	 * @return boolean whether the row got deleted or not
1612 1612
 	 */
1613
-	public function delete_by_ID( $id, $allow_blocking = true ){
1613
+	public function delete_by_ID($id, $allow_blocking = true) {
1614 1614
 		return $this->delete( 
1615 1615
 			array(
1616
-				array( $this->get_primary_key_field()->get_name() => $id ),
1616
+				array($this->get_primary_key_field()->get_name() => $id),
1617 1617
 				'limit' 	=> 1
1618 1618
 			), 
1619 1619
 			$allow_blocking 
@@ -1627,7 +1627,7 @@  discard block
 block discarded – undo
1627 1627
 	 * @param boolean $allow_blocking
1628 1628
 	 * @return @see EEM_Base::delete_permanently
1629 1629
 	 */
1630
-	function delete($query_params,$allow_blocking = true){
1630
+	function delete($query_params, $allow_blocking = true) {
1631 1631
 		return $this->delete_permanently($query_params, $allow_blocking);
1632 1632
 	}
1633 1633
 
@@ -1643,7 +1643,7 @@  discard block
 block discarded – undo
1643 1643
 	 * which may depend on it. Its generally advisable to always leave this as TRUE, otherwise you could easily corrupt your DB
1644 1644
 	 * @return int how many rows got deleted
1645 1645
 	 */
1646
-	function delete_permanently($query_params,$allow_blocking = true){
1646
+	function delete_permanently($query_params, $allow_blocking = true) {
1647 1647
 		/**
1648 1648
 		 * Action called just before performing a real deletion query. You can use the
1649 1649
 		 * model and its $query_params to find exactly which items will be deleted
@@ -1652,34 +1652,34 @@  discard block
 block discarded – undo
1652 1652
 		 * @param boolean $allow_blocking whether or not to allow related model objects
1653 1653
 		 * to block (prevent) this deletion
1654 1654
 		 */
1655
-		do_action( 'AHEE__EEM_Base__delete__begin', $this, $query_params, $allow_blocking );
1655
+		do_action('AHEE__EEM_Base__delete__begin', $this, $query_params, $allow_blocking);
1656 1656
 		//some MySQL databases may be running safe mode, which may restrict
1657 1657
 		//deletion if there is no KEY column used in the WHERE statement of a deletion.
1658 1658
 		//to get around this, we first do a SELECT, get all the IDs, and then run another query
1659 1659
 		//to delete them
1660 1660
 		$items_for_deletion = $this->_get_all_wpdb_results($query_params);
1661
-		$deletion_where = $this->_setup_ids_for_delete( $items_for_deletion, $allow_blocking);
1662
-		if($deletion_where){
1661
+		$deletion_where = $this->_setup_ids_for_delete($items_for_deletion, $allow_blocking);
1662
+		if ($deletion_where) {
1663 1663
 			//echo "objects for deletion:";var_dump($objects_for_deletion);
1664 1664
 			$model_query_info = $this->_create_model_query_info_carrier($query_params);
1665 1665
 			$table_aliases = array();
1666
-			foreach(array_keys($this->_tables) as $table_alias){
1666
+			foreach (array_keys($this->_tables) as $table_alias) {
1667 1667
 				$table_aliases[] = $table_alias;
1668 1668
 			}
1669
-			$SQL = "DELETE ".implode(", ",$table_aliases)." FROM ".$model_query_info->get_full_join_sql()." WHERE ".$deletion_where;
1669
+			$SQL = "DELETE ".implode(", ", $table_aliases)." FROM ".$model_query_info->get_full_join_sql()." WHERE ".$deletion_where;
1670 1670
 
1671 1671
 			//		/echo "delete sql:$SQL";
1672
-			$rows_deleted = $this->_do_wpdb_query( 'query', array( $SQL ) );
1673
-		}else{
1672
+			$rows_deleted = $this->_do_wpdb_query('query', array($SQL));
1673
+		} else {
1674 1674
 			$rows_deleted = 0;
1675 1675
 		}
1676 1676
 
1677 1677
 		//and lastly make sure those items are removed from the entity map; if they could be put into it at all
1678
-		if( $this->has_primary_key_field() ){
1679
-			foreach($items_for_deletion as $item_for_deletion_row ){
1680
-				$pk_value = $item_for_deletion_row[ $this->get_primary_key_field()->get_qualified_column() ];
1681
-				if( isset( $this->_entity_map[ $pk_value ] ) ){
1682
-					unset( $this->_entity_map[ $pk_value ] );
1678
+		if ($this->has_primary_key_field()) {
1679
+			foreach ($items_for_deletion as $item_for_deletion_row) {
1680
+				$pk_value = $item_for_deletion_row[$this->get_primary_key_field()->get_qualified_column()];
1681
+				if (isset($this->_entity_map[$pk_value])) {
1682
+					unset($this->_entity_map[$pk_value]);
1683 1683
 				}
1684 1684
 			}
1685 1685
 		}
@@ -1691,8 +1691,8 @@  discard block
 block discarded – undo
1691 1691
 		 * @param array $query_params @see EEM_Base::get_all()
1692 1692
 		 * @param int $rows_deleted
1693 1693
 		 */
1694
-		do_action( 'AHEE__EEM_Base__delete__end', $this, $query_params, $rows_deleted );
1695
-		return $rows_deleted;//how many supposedly got deleted
1694
+		do_action('AHEE__EEM_Base__delete__end', $this, $query_params, $rows_deleted);
1695
+		return $rows_deleted; //how many supposedly got deleted
1696 1696
 	}
1697 1697
 
1698 1698
 
@@ -1708,28 +1708,28 @@  discard block
 block discarded – undo
1708 1708
 	 * blocking its deletion before removing the relation between A and B
1709 1709
 	 * @return boolean
1710 1710
 	 */
1711
-	public function delete_is_blocked_by_related_models($this_model_obj_or_id, $ignore_this_model_obj = null){
1711
+	public function delete_is_blocked_by_related_models($this_model_obj_or_id, $ignore_this_model_obj = null) {
1712 1712
 		//first, if $ignore_this_model_obj was supplied, get its model
1713
-		if($ignore_this_model_obj && $ignore_this_model_obj instanceof EE_Base_Class){
1713
+		if ($ignore_this_model_obj && $ignore_this_model_obj instanceof EE_Base_Class) {
1714 1714
 			$ignored_model = $ignore_this_model_obj->get_model();
1715
-		}else{
1715
+		} else {
1716 1716
 			$ignored_model = null;
1717 1717
 		}
1718 1718
 		//now check all the relations of $this_model_obj_or_id and see if there
1719 1719
 		//are any related model objects blocking it?
1720 1720
 		$is_blocked = false;
1721
-		foreach($this->_model_relations as $relation_name => $relation_obj){
1722
-			if( $relation_obj->block_delete_if_related_models_exist()){
1721
+		foreach ($this->_model_relations as $relation_name => $relation_obj) {
1722
+			if ($relation_obj->block_delete_if_related_models_exist()) {
1723 1723
 				//if $ignore_this_model_obj was supplied, then for the query
1724 1724
 				//on that model needs to be told to ignore $ignore_this_model_obj
1725
-				if($ignored_model && $relation_name == $ignored_model->get_this_model_name()){
1726
-					$related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id,array(
1727
-					array($ignored_model->get_primary_key_field()->get_name() => array('!=',$ignore_this_model_obj->ID()))));
1728
-				}else{
1725
+				if ($ignored_model && $relation_name == $ignored_model->get_this_model_name()) {
1726
+					$related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id, array(
1727
+					array($ignored_model->get_primary_key_field()->get_name() => array('!=', $ignore_this_model_obj->ID()))));
1728
+				} else {
1729 1729
 					$related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id);
1730 1730
 				}
1731 1731
 
1732
-				if($related_model_objects){
1732
+				if ($related_model_objects) {
1733 1733
 					EE_Error::add_error($relation_obj->get_deletion_error_message(), __FILE__, __FUNCTION__, __LINE__);
1734 1734
 					$is_blocked = true;
1735 1735
 				}
@@ -1749,65 +1749,65 @@  discard block
 block discarded – undo
1749 1749
 	 * @throws EE_Error
1750 1750
 	 * @return string    everything that comes after the WHERE statement.
1751 1751
 	 */
1752
-	protected function _setup_ids_for_delete( $objects_for_deletion, $allow_blocking = true) {
1753
-		if($this->has_primary_key_field()){
1752
+	protected function _setup_ids_for_delete($objects_for_deletion, $allow_blocking = true) {
1753
+		if ($this->has_primary_key_field()) {
1754 1754
 			$primary_table = $this->_get_main_table();
1755 1755
 			$other_tables = $this->_get_other_tables();
1756 1756
 			$deletes = $query = array();
1757
-			foreach ( $objects_for_deletion as $delete_object ) {
1757
+			foreach ($objects_for_deletion as $delete_object) {
1758 1758
 				//before we mark this object for deletion,
1759 1759
 				//make sure there's no related objects blocking its deletion (if we're checking)
1760
-				if( $allow_blocking && $this->delete_is_blocked_by_related_models($delete_object[$primary_table->get_fully_qualified_pk_column()]) ){
1760
+				if ($allow_blocking && $this->delete_is_blocked_by_related_models($delete_object[$primary_table->get_fully_qualified_pk_column()])) {
1761 1761
 					continue;
1762 1762
 				}
1763 1763
 
1764 1764
 				//primary table deletes
1765
-				if ( isset( $delete_object[$primary_table->get_fully_qualified_pk_column()] ) )
1765
+				if (isset($delete_object[$primary_table->get_fully_qualified_pk_column()]))
1766 1766
 					$deletes[$primary_table->get_fully_qualified_pk_column()][] = $delete_object[$primary_table->get_fully_qualified_pk_column()];
1767 1767
 
1768 1768
 				//other tables
1769
-				if ( !empty( $other_tables ) ) {
1770
-					foreach ( $other_tables as $ot ) {
1769
+				if ( ! empty($other_tables)) {
1770
+					foreach ($other_tables as $ot) {
1771 1771
 
1772 1772
 						//first check if we've got the foreign key column here.
1773
-						if ( isset( $delete_object[$ot->get_fully_qualified_fk_column()] ) )
1773
+						if (isset($delete_object[$ot->get_fully_qualified_fk_column()]))
1774 1774
 							$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_fk_column()];
1775 1775
 
1776 1776
 						//wait! it's entirely possible that we'll have a the primary key for this table in here if it's a foreign key for one of the other secondary tables
1777
-						if ( isset( $delete_object[$ot->get_fully_qualified_pk_column()] ) )
1777
+						if (isset($delete_object[$ot->get_fully_qualified_pk_column()]))
1778 1778
 							$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()];
1779 1779
 
1780 1780
 						//finally, it is possible that the fk for this table is found in the fully qualified pk column for the fk table, so let's see if that's there!
1781
-						if ( isset( $delete_object[$ot->get_fully_qualified_pk_on_fk_table()]) )
1781
+						if (isset($delete_object[$ot->get_fully_qualified_pk_on_fk_table()]))
1782 1782
 							$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()];
1783 1783
 					}
1784 1784
 				}
1785 1785
 			}
1786 1786
 
1787 1787
 			//we should have deletes now, so let's just go through and setup the where statement
1788
-			foreach ( $deletes as $column => $values ) {
1788
+			foreach ($deletes as $column => $values) {
1789 1789
 				//make sure we have unique $values;
1790 1790
 				$values = array_unique($values);
1791
-				$query[] = $column . ' IN(' . implode(",",$values) . ')';
1791
+				$query[] = $column.' IN('.implode(",", $values).')';
1792 1792
 			}
1793 1793
 
1794
-			return !empty($query) ? implode(' AND ', $query ) : '';
1795
-		}elseif(count($this->get_combined_primary_key_fields()) > 1){
1794
+			return ! empty($query) ? implode(' AND ', $query) : '';
1795
+		}elseif (count($this->get_combined_primary_key_fields()) > 1) {
1796 1796
 			$ways_to_identify_a_row = array();
1797 1797
 			$fields = $this->get_combined_primary_key_fields();
1798 1798
 			//note: because there' sno primary key, that means nothing else  can be pointing to this model, right?
1799
-			foreach($objects_for_deletion as  $delete_object){
1799
+			foreach ($objects_for_deletion as  $delete_object) {
1800 1800
 				$values_for_each_cpk_for_a_row = array();
1801
-				foreach($fields as $cpk_field){
1801
+				foreach ($fields as $cpk_field) {
1802 1802
 					$values_for_each_cpk_for_a_row[] = $cpk_field->get_qualified_column()."=".$delete_object[$cpk_field->get_qualified_column()];
1803 1803
 				}
1804
-				$ways_to_identify_a_row[] = "(".implode(" AND ",$values_for_each_cpk_for_a_row).")";
1804
+				$ways_to_identify_a_row[] = "(".implode(" AND ", $values_for_each_cpk_for_a_row).")";
1805 1805
 			}
1806
-			return implode(" OR ",$ways_to_identify_a_row);
1807
-		}else{
1806
+			return implode(" OR ", $ways_to_identify_a_row);
1807
+		} else {
1808 1808
 			//so there's no primary key and no combined key...
1809 1809
 			//sorry, can't help you
1810
-			throw new EE_Error(sprintf(__("Cannot delete objects of type %s because there is no primary key NOR combined key", "event_espresso"),get_class($this)));
1810
+			throw new EE_Error(sprintf(__("Cannot delete objects of type %s because there is no primary key NOR combined key", "event_espresso"), get_class($this)));
1811 1811
 		}
1812 1812
 	}
1813 1813
 
@@ -1821,21 +1821,21 @@  discard block
 block discarded – undo
1821 1821
 	 * @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;
1822 1822
 	 * @return int
1823 1823
 	 */
1824
-	function count($query_params =array(),$field_to_count = NULL, $distinct = FALSE){
1824
+	function count($query_params = array(), $field_to_count = NULL, $distinct = FALSE) {
1825 1825
 		$model_query_info = $this->_create_model_query_info_carrier($query_params);
1826
-		if($field_to_count){
1826
+		if ($field_to_count) {
1827 1827
 			$field_obj = $this->field_settings_for($field_to_count);
1828 1828
 			$column_to_count = $field_obj->get_qualified_column();
1829
-		}elseif($this->has_primary_key_field ()){
1829
+		}elseif ($this->has_primary_key_field()) {
1830 1830
 			$pk_field_obj = $this->get_primary_key_field();
1831 1831
 			$column_to_count = $pk_field_obj->get_qualified_column();
1832
-		}else{//there's no primary key
1832
+		} else {//there's no primary key
1833 1833
 			$column_to_count = '*';
1834 1834
 		}
1835 1835
 
1836
-		$column_to_count = $distinct ? "DISTINCT (" . $column_to_count . " )" : $column_to_count;
1837
-		$SQL ="SELECT COUNT(".$column_to_count.")" . $this->_construct_2nd_half_of_select_query($model_query_info);
1838
-		return (int)$this->_do_wpdb_query( 'get_var', array( $SQL) );
1836
+		$column_to_count = $distinct ? "DISTINCT (".$column_to_count." )" : $column_to_count;
1837
+		$SQL = "SELECT COUNT(".$column_to_count.")".$this->_construct_2nd_half_of_select_query($model_query_info);
1838
+		return (int) $this->_do_wpdb_query('get_var', array($SQL));
1839 1839
 	}
1840 1840
 
1841 1841
 	/**
@@ -1845,23 +1845,23 @@  discard block
 block discarded – undo
1845 1845
 	 * @param string $field_to_sum name of field (array key in $_fields array)
1846 1846
 	 * @return float
1847 1847
 	 */
1848
-	function sum($query_params, $field_to_sum = NULL){
1848
+	function sum($query_params, $field_to_sum = NULL) {
1849 1849
 		$model_query_info = $this->_create_model_query_info_carrier($query_params);
1850 1850
 
1851
-		if($field_to_sum){
1851
+		if ($field_to_sum) {
1852 1852
 			$field_obj = $this->field_settings_for($field_to_sum);
1853 1853
 
1854
-		}else{
1854
+		} else {
1855 1855
 			$field_obj = $this->get_primary_key_field();
1856 1856
 		}
1857 1857
 		$column_to_count = $field_obj->get_qualified_column();
1858 1858
 
1859
-		$SQL ="SELECT SUM(".$column_to_count.")" . $this->_construct_2nd_half_of_select_query($model_query_info);
1860
-		$return_value = $this->_do_wpdb_query('get_var',array( $SQL ) );
1861
-		if($field_obj->get_wpdb_data_type() == '%d' || $field_obj->get_wpdb_data_type() == '%s' ){
1862
-			return (float)$return_value;
1863
-		}else{//must be %f
1864
-			return (float)$return_value;
1859
+		$SQL = "SELECT SUM(".$column_to_count.")".$this->_construct_2nd_half_of_select_query($model_query_info);
1860
+		$return_value = $this->_do_wpdb_query('get_var', array($SQL));
1861
+		if ($field_obj->get_wpdb_data_type() == '%d' || $field_obj->get_wpdb_data_type() == '%s') {
1862
+			return (float) $return_value;
1863
+		} else {//must be %f
1864
+			return (float) $return_value;
1865 1865
 		}
1866 1866
 	}
1867 1867
 
@@ -1876,33 +1876,33 @@  discard block
 block discarded – undo
1876 1876
 	 * @global wpdb $wpdb
1877 1877
 	 * @return mixed
1878 1878
 	 */
1879
-	protected function _do_wpdb_query( $wpdb_method, $arguments_to_provide ){
1879
+	protected function _do_wpdb_query($wpdb_method, $arguments_to_provide) {
1880 1880
 		//if we're in maintenance mode level 2, DON'T run any queries
1881 1881
 		//because level 2 indicates the database needs updating and
1882 1882
 		//is probably out of sync with the code
1883
-		if( ! EE_Maintenance_Mode::instance()->models_can_query()){
1883
+		if ( ! EE_Maintenance_Mode::instance()->models_can_query()) {
1884 1884
 			throw new EE_Error(sprintf(__("Event Espresso Level 2 Maintenance mode is active. That means EE can not run ANY database queries until the necessary migration scripts have run which will take EE out of maintenance mode level 2. Please inform support of this error.", "event_espresso")));
1885 1885
 		}
1886 1886
 		/** @type WPDB $wpdb */
1887 1887
 		global $wpdb;
1888
-		if( ! method_exists( $wpdb, $wpdb_method ) ){
1889
-			throw new EE_Error( sprintf( __( 'There is no method named "%s" on Wordpress\' $wpdb object','event_espresso' ), $wpdb_method ) );
1888
+		if ( ! method_exists($wpdb, $wpdb_method)) {
1889
+			throw new EE_Error(sprintf(__('There is no method named "%s" on Wordpress\' $wpdb object', 'event_espresso'), $wpdb_method));
1890 1890
 		}
1891
-		if( WP_DEBUG ){
1891
+		if (WP_DEBUG) {
1892 1892
 			$old_show_errors_value = $wpdb->show_errors;
1893
-			$wpdb->show_errors( FALSE );
1894
-		}
1895
-		$result = $this->_process_wpdb_query( $wpdb_method, $arguments_to_provide );
1896
-		$this->show_db_query_if_previously_requested( $wpdb->last_query );
1897
-		if( WP_DEBUG ){
1898
-			$wpdb->show_errors( $old_show_errors_value );
1899
-			if( ! empty( $wpdb->last_error ) ){
1900
-				throw new EE_Error( sprintf( __( 'WPDB Error: "%s"', 'event_espresso' ), $wpdb->last_error ) );
1901
-			}elseif( $result === false ){
1902
-				throw new EE_Error( sprintf( __( 'WPDB Error occurred, but no error message was logged by wpdb! The wpdb method called was "%1$s" and the arguments were "%2$s"', 'event_espresso' ), $wpdb_method, var_export( $arguments_to_provide, true ) ) );
1893
+			$wpdb->show_errors(FALSE);
1894
+		}
1895
+		$result = $this->_process_wpdb_query($wpdb_method, $arguments_to_provide);
1896
+		$this->show_db_query_if_previously_requested($wpdb->last_query);
1897
+		if (WP_DEBUG) {
1898
+			$wpdb->show_errors($old_show_errors_value);
1899
+			if ( ! empty($wpdb->last_error)) {
1900
+				throw new EE_Error(sprintf(__('WPDB Error: "%s"', 'event_espresso'), $wpdb->last_error));
1901
+			}elseif ($result === false) {
1902
+				throw new EE_Error(sprintf(__('WPDB Error occurred, but no error message was logged by wpdb! The wpdb method called was "%1$s" and the arguments were "%2$s"', 'event_espresso'), $wpdb_method, var_export($arguments_to_provide, true)));
1903 1903
 			}
1904
-		}elseif( $result === false ) {
1905
-			EE_Error::add_error( sprintf( __( 'A database error has occurred. Turn on WP_DEBUG for more information.', 'event_espresso' )), __FILE__, __FUNCTION__, __LINE__);
1904
+		}elseif ($result === false) {
1905
+			EE_Error::add_error(sprintf(__('A database error has occurred. Turn on WP_DEBUG for more information.', 'event_espresso')), __FILE__, __FUNCTION__, __LINE__);
1906 1906
 		}
1907 1907
 		return $result;
1908 1908
 	}
@@ -1918,23 +1918,23 @@  discard block
 block discarded – undo
1918 1918
 	 * @param array $arguments_to_provide
1919 1919
 	 * @return mixed
1920 1920
 	 */
1921
-	private function _process_wpdb_query( $wpdb_method, $arguments_to_provide ) {
1921
+	private function _process_wpdb_query($wpdb_method, $arguments_to_provide) {
1922 1922
 		/** @type WPDB $wpdb */
1923 1923
 		global $wpdb;
1924 1924
 		$wpdb->last_error = null;
1925
-		$result = call_user_func_array( array( $wpdb, $wpdb_method ), $arguments_to_provide );
1925
+		$result = call_user_func_array(array($wpdb, $wpdb_method), $arguments_to_provide);
1926 1926
 		// was there an error running the query?
1927
-		if ( ( $result === false || ! empty( $wpdb->last_error ) ) ) {
1928
-			switch ( EEM_Base::$_db_verification_level ) {
1927
+		if (($result === false || ! empty($wpdb->last_error))) {
1928
+			switch (EEM_Base::$_db_verification_level) {
1929 1929
 
1930 1930
 				case EEM_Base::db_verified_none :
1931 1931
 					// let's double-check core's DB
1932
-					$error_message = $this->_verify_core_db( $wpdb_method, $arguments_to_provide );
1932
+					$error_message = $this->_verify_core_db($wpdb_method, $arguments_to_provide);
1933 1933
 					break;
1934 1934
 
1935 1935
 				case EEM_Base::db_verified_core :
1936 1936
 					// STILL NO LOVE?? verify all the addons too. Maybe they need to be fixed
1937
-					$error_message = $this->_verify_addons_db( $wpdb_method, $arguments_to_provide );
1937
+					$error_message = $this->_verify_addons_db($wpdb_method, $arguments_to_provide);
1938 1938
 					break;
1939 1939
 
1940 1940
 				case EEM_Base::db_verified_addons :
@@ -1942,11 +1942,11 @@  discard block
 block discarded – undo
1942 1942
 					return $result;
1943 1943
 					break;
1944 1944
 			}
1945
-			if ( ! empty( $error_message ) ) {
1946
-				EE_Log::instance()->log( __FILE__, __FUNCTION__, $error_message, 'error' );
1947
-				trigger_error( $error_message );
1945
+			if ( ! empty($error_message)) {
1946
+				EE_Log::instance()->log(__FILE__, __FUNCTION__, $error_message, 'error');
1947
+				trigger_error($error_message);
1948 1948
 			}
1949
-			return $this->_process_wpdb_query( $wpdb_method, $arguments_to_provide );
1949
+			return $this->_process_wpdb_query($wpdb_method, $arguments_to_provide);
1950 1950
 
1951 1951
 		}
1952 1952
 
@@ -1962,18 +1962,18 @@  discard block
 block discarded – undo
1962 1962
 	 * @param array $arguments_to_provide
1963 1963
 	 * @return string
1964 1964
 	 */
1965
-	private function _verify_core_db( $wpdb_method, $arguments_to_provide ){
1965
+	private function _verify_core_db($wpdb_method, $arguments_to_provide) {
1966 1966
 		/** @type WPDB $wpdb */
1967 1967
 		global $wpdb;
1968 1968
 		//ok remember that we've already attempted fixing the core db, in case the problem persists
1969 1969
 		EEM_Base::$_db_verification_level = EEM_Base::db_verified_core;
1970 1970
 		$error_message = sprintf(
1971
-			__( 'WPDB Error "%1$s" while running wpdb method "%2$s" with arguments %3$s. Automatically attempting to fix EE Core DB', 'event_espresso' ),
1971
+			__('WPDB Error "%1$s" while running wpdb method "%2$s" with arguments %3$s. Automatically attempting to fix EE Core DB', 'event_espresso'),
1972 1972
 			$wpdb->last_error,
1973 1973
 			$wpdb_method,
1974
-			json_encode( $arguments_to_provide )
1974
+			json_encode($arguments_to_provide)
1975 1975
 		);
1976
-		EE_System::instance()->initialize_db_if_no_migrations_required( false, true );
1976
+		EE_System::instance()->initialize_db_if_no_migrations_required(false, true);
1977 1977
 		return $error_message;
1978 1978
 	}
1979 1979
 
@@ -1986,16 +1986,16 @@  discard block
 block discarded – undo
1986 1986
 	 * @param $arguments_to_provide
1987 1987
 	 * @return string
1988 1988
 	 */
1989
-	private function _verify_addons_db( $wpdb_method, $arguments_to_provide ) {
1989
+	private function _verify_addons_db($wpdb_method, $arguments_to_provide) {
1990 1990
 		/** @type WPDB $wpdb */
1991 1991
 		global $wpdb;
1992 1992
 		//ok remember that we've already attempted fixing the addons dbs, in case the problem persists
1993 1993
 		EEM_Base::$_db_verification_level = EEM_Base::db_verified_addons;
1994 1994
 		$error_message = sprintf(
1995
-			__( 'WPDB AGAIN: Error "%1$s" while running the same method and arguments as before. Automatically attempting to fix EE Addons DB', 'event_espresso' ),
1995
+			__('WPDB AGAIN: Error "%1$s" while running the same method and arguments as before. Automatically attempting to fix EE Addons DB', 'event_espresso'),
1996 1996
 			$wpdb->last_error,
1997 1997
 			$wpdb_method,
1998
-			json_encode( $arguments_to_provide )
1998
+			json_encode($arguments_to_provide)
1999 1999
 		);
2000 2000
 		EE_System::instance()->initialize_addons();
2001 2001
 		return $error_message;
@@ -2010,7 +2010,7 @@  discard block
 block discarded – undo
2010 2010
 	 * @param EE_Model_Query_Info_Carrier $model_query_info
2011 2011
 	 * @return string
2012 2012
 	 */
2013
-	private function _construct_2nd_half_of_select_query(EE_Model_Query_Info_Carrier $model_query_info){
2013
+	private function _construct_2nd_half_of_select_query(EE_Model_Query_Info_Carrier $model_query_info) {
2014 2014
 		return " FROM ".$model_query_info->get_full_join_sql().
2015 2015
 				$model_query_info->get_where_sql().
2016 2016
 				$model_query_info->get_group_by_sql().
@@ -2023,7 +2023,7 @@  discard block
 block discarded – undo
2023 2023
 	 * Set to easily debug the next X queries ran from this model.
2024 2024
 	 * @param int $count
2025 2025
 	 */
2026
-	function show_next_x_db_queries($count = 1){
2026
+	function show_next_x_db_queries($count = 1) {
2027 2027
 		$this->_show_next_x_db_queries = $count;
2028 2028
 	}
2029 2029
 
@@ -2032,8 +2032,8 @@  discard block
 block discarded – undo
2032 2032
 	/**
2033 2033
 	 * @param $sql_query
2034 2034
 	 */
2035
-	function show_db_query_if_previously_requested($sql_query){
2036
-		if($this->_show_next_x_db_queries > 0){
2035
+	function show_db_query_if_previously_requested($sql_query) {
2036
+		if ($this->_show_next_x_db_queries > 0) {
2037 2037
 			echo $sql_query;
2038 2038
 			$this->_show_next_x_db_queries--;
2039 2039
 		}
@@ -2057,9 +2057,9 @@  discard block
 block discarded – undo
2057 2057
 	 * @param array   $extra_join_model_fields_n_values This allows you to enter further query params for the relation to for relation to methods that allow you to further specify extra columns to join by (such as HABTM).  Keep in mind that the only acceptable query_params is strict "col" => "value" pairs because these will be inserted in any new rows created as well.
2058 2058
 	 * @return EE_Base_Class which was added as a relation. Object referred to by $other_model_id_or_obj
2059 2059
 	 */
2060
-	public function add_relationship_to($id_or_obj,$other_model_id_or_obj, $relationName, $extra_join_model_fields_n_values = array()){
2060
+	public function add_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $extra_join_model_fields_n_values = array()) {
2061 2061
 		$relation_obj = $this->related_settings_for($relationName);
2062
-		return $relation_obj->add_relation_to( $id_or_obj, $other_model_id_or_obj, $extra_join_model_fields_n_values);
2062
+		return $relation_obj->add_relation_to($id_or_obj, $other_model_id_or_obj, $extra_join_model_fields_n_values);
2063 2063
 	}
2064 2064
 
2065 2065
 	/**
@@ -2078,9 +2078,9 @@  discard block
 block discarded – undo
2078 2078
 	 * @return boolean of success
2079 2079
 	 * @param array   $where_query This allows you to enter further query params for the relation to for relation to methods that allow you to further specify extra columns to join by (such as HABTM).  Keep in mind that the only acceptable query_params is strict "col" => "value" pairs because these will be inserted in any new rows created as well.
2080 2080
 	 */
2081
-	public function remove_relationship_to($id_or_obj,  $other_model_id_or_obj, $relationName, $where_query= array() ){
2081
+	public function remove_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query = array()) {
2082 2082
 		$relation_obj = $this->related_settings_for($relationName);
2083
-		return $relation_obj->remove_relation_to($id_or_obj, $other_model_id_or_obj, $where_query );
2083
+		return $relation_obj->remove_relation_to($id_or_obj, $other_model_id_or_obj, $where_query);
2084 2084
 	}
2085 2085
 
2086 2086
 
@@ -2093,9 +2093,9 @@  discard block
 block discarded – undo
2093 2093
 	 * @param EE_Base_Class[] objects to which relations were removed
2094 2094
 	 * @return \EE_Base_Class[]
2095 2095
 	 */
2096
-	public function remove_relations($id_or_obj,$relationName,$where_query_params = array()){
2096
+	public function remove_relations($id_or_obj, $relationName, $where_query_params = array()) {
2097 2097
 		$relation_obj = $this->related_settings_for($relationName);
2098
-		return $relation_obj->remove_relations($id_or_obj, $where_query_params );
2098
+		return $relation_obj->remove_relations($id_or_obj, $where_query_params);
2099 2099
 	}
2100 2100
 
2101 2101
 
@@ -2108,10 +2108,10 @@  discard block
 block discarded – undo
2108 2108
 	 * @param array $query_params like EEM_Base::get_all
2109 2109
 	 * @return EE_Base_Class[]
2110 2110
 	 */
2111
-	function get_all_related($id_or_obj, $model_name, $query_params = null){
2111
+	function get_all_related($id_or_obj, $model_name, $query_params = null) {
2112 2112
 		$model_obj = $this->ensure_is_obj($id_or_obj);
2113 2113
 		$relation_settings = $this->related_settings_for($model_name);
2114
-		return $relation_settings->get_all_related($model_obj,$query_params);
2114
+		return $relation_settings->get_all_related($model_obj, $query_params);
2115 2115
 	}
2116 2116
 
2117 2117
 	/**
@@ -2124,10 +2124,10 @@  discard block
 block discarded – undo
2124 2124
 	 * @param array $query_params
2125 2125
 	 * @return int how many deleted
2126 2126
 	 */
2127
-	public function delete_related($id_or_obj,$model_name, $query_params = array()){
2127
+	public function delete_related($id_or_obj, $model_name, $query_params = array()) {
2128 2128
 		$model_obj = $this->ensure_is_obj($id_or_obj);
2129 2129
 		$relation_settings = $this->related_settings_for($model_name);
2130
-		return $relation_settings->delete_all_related($model_obj,$query_params);
2130
+		return $relation_settings->delete_all_related($model_obj, $query_params);
2131 2131
 	}
2132 2132
 
2133 2133
 	/**
@@ -2140,10 +2140,10 @@  discard block
 block discarded – undo
2140 2140
 	 * @param array $query_params
2141 2141
 	 * @return int how many deleted
2142 2142
 	 */
2143
-	public function delete_related_permanently($id_or_obj,$model_name, $query_params = array()){
2143
+	public function delete_related_permanently($id_or_obj, $model_name, $query_params = array()) {
2144 2144
 		$model_obj = $this->ensure_is_obj($id_or_obj);
2145 2145
 		$relation_settings = $this->related_settings_for($model_name);
2146
-		return $relation_settings->delete_related_permanently($model_obj,$query_params);
2146
+		return $relation_settings->delete_related_permanently($model_obj, $query_params);
2147 2147
 	}
2148 2148
 
2149 2149
 	/**
@@ -2156,17 +2156,17 @@  discard block
 block discarded – undo
2156 2156
 	 * @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;
2157 2157
 	 * @return int
2158 2158
 	 */
2159
-	function count_related($id_or_obj,$model_name,$query_params = array(),$field_to_count = null, $distinct = FALSE){
2159
+	function count_related($id_or_obj, $model_name, $query_params = array(), $field_to_count = null, $distinct = FALSE) {
2160 2160
 		$related_model = $this->get_related_model_obj($model_name);
2161 2161
 		//we're just going to use the query params on the related model's normal get_all query,
2162 2162
 		//except add a condition to say to match the current mod
2163
-		if( ! isset($query_params['default_where_conditions'])){
2164
-			$query_params['default_where_conditions']='none';
2163
+		if ( ! isset($query_params['default_where_conditions'])) {
2164
+			$query_params['default_where_conditions'] = 'none';
2165 2165
 		}
2166 2166
 		$this_model_name = $this->get_this_model_name();
2167 2167
 		$this_pk_field_name = $this->get_primary_key_field()->get_name();
2168
-		$query_params[0][$this_model_name.".".$this_pk_field_name]=$id_or_obj;
2169
-		return $related_model->count($query_params,$field_to_count,$distinct);
2168
+		$query_params[0][$this_model_name.".".$this_pk_field_name] = $id_or_obj;
2169
+		return $related_model->count($query_params, $field_to_count, $distinct);
2170 2170
 	}
2171 2171
 
2172 2172
 
@@ -2180,21 +2180,21 @@  discard block
 block discarded – undo
2180 2180
 	 * @param string $field_to_sum name of field to count by. By default, uses primary key
2181 2181
 	 * @return float
2182 2182
 	 */
2183
-	function sum_related($id_or_obj,$model_name,$query_params,$field_to_sum = null){
2183
+	function sum_related($id_or_obj, $model_name, $query_params, $field_to_sum = null) {
2184 2184
 		$related_model = $this->get_related_model_obj($model_name);
2185
-		if( ! is_array( $query_params ) ){
2186
-			EE_Error::doing_it_wrong('EEM_Base::sum_related', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' );
2185
+		if ( ! is_array($query_params)) {
2186
+			EE_Error::doing_it_wrong('EEM_Base::sum_related', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0');
2187 2187
 			$query_params = array();
2188 2188
 		}
2189 2189
 		//we're just going to use the query params on the related model's normal get_all query,
2190 2190
 		//except add a condition to say to match the current mod
2191
-		if( ! isset($query_params['default_where_conditions'])){
2192
-			$query_params['default_where_conditions']='none';
2191
+		if ( ! isset($query_params['default_where_conditions'])) {
2192
+			$query_params['default_where_conditions'] = 'none';
2193 2193
 		}
2194 2194
 		$this_model_name = $this->get_this_model_name();
2195 2195
 		$this_pk_field_name = $this->get_primary_key_field()->get_name();
2196
-		$query_params[0][$this_model_name.".".$this_pk_field_name]=$id_or_obj;
2197
-		return $related_model->sum($query_params,$field_to_sum);
2196
+		$query_params[0][$this_model_name.".".$this_pk_field_name] = $id_or_obj;
2197
+		return $related_model->sum($query_params, $field_to_sum);
2198 2198
 	}
2199 2199
 
2200 2200
 
@@ -2206,12 +2206,12 @@  discard block
 block discarded – undo
2206 2206
 	 * @param array $query_params like EEM_Base::get_all's
2207 2207
 	 * @return EE_Base_Class
2208 2208
 	 */
2209
-	public function get_first_related( EE_Base_Class $id_or_obj, $other_model_name, $query_params ){
2210
-		$query_params['limit']=1;
2211
-		$results = $this->get_all_related($id_or_obj,$other_model_name,$query_params);
2212
-		if( $results ){
2209
+	public function get_first_related(EE_Base_Class $id_or_obj, $other_model_name, $query_params) {
2210
+		$query_params['limit'] = 1;
2211
+		$results = $this->get_all_related($id_or_obj, $other_model_name, $query_params);
2212
+		if ($results) {
2213 2213
 			return array_shift($results);
2214
-		}else{
2214
+		} else {
2215 2215
 			return null;
2216 2216
 		}
2217 2217
 
@@ -2221,8 +2221,8 @@  discard block
 block discarded – undo
2221 2221
 	 * Gets the model's name as it's expected in queries. For example, if this is EEM_Event model, that would be Event
2222 2222
 	 * @return string
2223 2223
 	 */
2224
-	function get_this_model_name(){
2225
-		return str_replace("EEM_","",get_class($this));
2224
+	function get_this_model_name() {
2225
+		return str_replace("EEM_", "", get_class($this));
2226 2226
 	}
2227 2227
 
2228 2228
 	/**
@@ -2230,14 +2230,14 @@  discard block
 block discarded – undo
2230 2230
 	 * @return EE_Any_Foreign_Model_Name_Field
2231 2231
 	 * @throws EE_Error
2232 2232
 	 */
2233
-	public function get_field_containing_related_model_name(){
2234
-		foreach($this->field_settings(true) as $field){
2235
-			if($field instanceof EE_Any_Foreign_Model_Name_Field){
2233
+	public function get_field_containing_related_model_name() {
2234
+		foreach ($this->field_settings(true) as $field) {
2235
+			if ($field instanceof EE_Any_Foreign_Model_Name_Field) {
2236 2236
 				$field_with_model_name = $field;
2237 2237
 			}
2238 2238
 		}
2239
-		if( !isset($field_with_model_name) || !$field_with_model_name ){
2240
-			throw new EE_Error(sprintf(__("There is no EE_Any_Foreign_Model_Name field on model %s", "event_espresso"), $this->get_this_model_name() ));
2239
+		if ( ! isset($field_with_model_name) || ! $field_with_model_name) {
2240
+			throw new EE_Error(sprintf(__("There is no EE_Any_Foreign_Model_Name field on model %s", "event_espresso"), $this->get_this_model_name()));
2241 2241
 		}
2242 2242
 		return $field_with_model_name;
2243 2243
 	}
@@ -2258,19 +2258,19 @@  discard block
 block discarded – undo
2258 2258
 	 * @return int new primary key on main table that got inserted
2259 2259
 	 * @throws EE_Error
2260 2260
 	 */
2261
-	function insert($field_n_values){
2261
+	function insert($field_n_values) {
2262 2262
 		/**
2263 2263
 		 * Filters the fields and their values before inserting an item using the models
2264 2264
 		 * @param array $fields_n_values keys are the fields and values are their new values
2265 2265
 		 * @param EEM_Base $model the model used
2266 2266
 		 */
2267
-		$field_n_values = apply_filters( 'FHEE__EEM_Base__insert__fields_n_values', $field_n_values, $this );
2268
-		if($this->_satisfies_unique_indexes($field_n_values)){
2267
+		$field_n_values = apply_filters('FHEE__EEM_Base__insert__fields_n_values', $field_n_values, $this);
2268
+		if ($this->_satisfies_unique_indexes($field_n_values)) {
2269 2269
 			$main_table = $this->_get_main_table();
2270 2270
 			$new_id = $this->_insert_into_specific_table($main_table, $field_n_values, false);
2271
-			if( $new_id !== false ) {
2272
-				foreach($this->_get_other_tables() as $other_table){
2273
-					$this->_insert_into_specific_table($other_table, $field_n_values,$new_id);
2271
+			if ($new_id !== false) {
2272
+				foreach ($this->_get_other_tables() as $other_table) {
2273
+					$this->_insert_into_specific_table($other_table, $field_n_values, $new_id);
2274 2274
 				}
2275 2275
 			}
2276 2276
 			/**
@@ -2280,9 +2280,9 @@  discard block
 block discarded – undo
2280 2280
 			 * @param array $fields_n_values fields and their values
2281 2281
 			 * @param int|string the ID of the newly-inserted model object
2282 2282
 			 */
2283
-			do_action( 'AHEE__EEM_Base__insert__end', $this, $field_n_values, $new_id );
2283
+			do_action('AHEE__EEM_Base__insert__end', $this, $field_n_values, $new_id);
2284 2284
 			return $new_id;
2285
-		}else{
2285
+		} else {
2286 2286
 			return FALSE;
2287 2287
 		}
2288 2288
 	}
@@ -2295,11 +2295,11 @@  discard block
 block discarded – undo
2295 2295
 	 * @param string $action
2296 2296
 	 * @return boolean
2297 2297
 	 */
2298
-	protected function _satisfies_unique_indexes($field_n_values,$action = 'insert'){
2299
-		foreach($this->unique_indexes() as $index_name => $index){
2298
+	protected function _satisfies_unique_indexes($field_n_values, $action = 'insert') {
2299
+		foreach ($this->unique_indexes() as $index_name => $index) {
2300 2300
 			$uniqueness_where_params = array_intersect_key($field_n_values, $index->fields());
2301
-			if($this->exists(array($uniqueness_where_params))){
2302
-				EE_Error::add_error(sprintf(__("Could not %s %s. %s uniqueness index failed. Fields %s must form a unique set, but an entry already exists with values %s.", "event_espresso"),$action,$this->_get_class_name(),$index_name,implode(",",$index->field_names()),http_build_query($uniqueness_where_params)), __FILE__, __FUNCTION__, __LINE__ );
2301
+			if ($this->exists(array($uniqueness_where_params))) {
2302
+				EE_Error::add_error(sprintf(__("Could not %s %s. %s uniqueness index failed. Fields %s must form a unique set, but an entry already exists with values %s.", "event_espresso"), $action, $this->_get_class_name(), $index_name, implode(",", $index->field_names()), http_build_query($uniqueness_where_params)), __FILE__, __FUNCTION__, __LINE__);
2303 2303
 				return false;
2304 2304
 			}
2305 2305
 		}
@@ -2320,28 +2320,28 @@  discard block
 block discarded – undo
2320 2320
 	 * @throws EE_Error
2321 2321
 	 * @return EE_Base_Class
2322 2322
 	 */
2323
-	public function get_one_conflicting($obj_or_fields_array, $include_primary_key = true ){
2324
-		if($obj_or_fields_array instanceof EE_Base_Class){
2323
+	public function get_one_conflicting($obj_or_fields_array, $include_primary_key = true) {
2324
+		if ($obj_or_fields_array instanceof EE_Base_Class) {
2325 2325
 			$fields_n_values = $obj_or_fields_array->model_field_array();
2326
-		}elseif( is_array($obj_or_fields_array)){
2326
+		}elseif (is_array($obj_or_fields_array)) {
2327 2327
 			$fields_n_values = $obj_or_fields_array;
2328
-		}else{
2329
-			throw new EE_Error(sprintf(__("%s get_all_conflicting should be called with a model object or an array of field names and values, you provided %d", "event_espresso"),get_class($this),$obj_or_fields_array));
2328
+		} else {
2329
+			throw new EE_Error(sprintf(__("%s get_all_conflicting should be called with a model object or an array of field names and values, you provided %d", "event_espresso"), get_class($this), $obj_or_fields_array));
2330 2330
 		}
2331
-		$query_params = array( 'default_where_conditions' => 'minimum' );
2332
-		if( $this->has_primary_key_field() &&
2333
-				( $include_primary_key || $this->get_primary_key_field() instanceof EE_Primary_Key_String_Field) &&
2334
-				isset($fields_n_values[$this->primary_key_name()])){
2331
+		$query_params = array('default_where_conditions' => 'minimum');
2332
+		if ($this->has_primary_key_field() &&
2333
+				($include_primary_key || $this->get_primary_key_field() instanceof EE_Primary_Key_String_Field) &&
2334
+				isset($fields_n_values[$this->primary_key_name()])) {
2335 2335
 			$query_params[0]['OR'][$this->primary_key_name()] = $fields_n_values[$this->primary_key_name()];
2336 2336
 		}
2337
-		foreach($this->unique_indexes() as $unique_index_name=>$unique_index){
2337
+		foreach ($this->unique_indexes() as $unique_index_name=>$unique_index) {
2338 2338
 			$uniqueness_where_params = array_intersect_key($fields_n_values, $unique_index->fields());
2339 2339
 			$query_params[0]['OR']['AND*'.$unique_index_name] = $uniqueness_where_params;
2340 2340
 		}
2341 2341
 		//if there is nothing to base this search on, then we shouldn't find anything
2342
-		if( ! isset( $query_params[0] ) || ( isset( $query_params[0] ) && empty( $query_params[0] ) ) ) {
2342
+		if ( ! isset($query_params[0]) || (isset($query_params[0]) && empty($query_params[0]))) {
2343 2343
 			return array();
2344
-		}else{
2344
+		} else {
2345 2345
 			return $this->get_one($query_params);
2346 2346
 		}
2347 2347
 	}
@@ -2351,7 +2351,7 @@  discard block
 block discarded – undo
2351 2351
 	 * @param array $query_params
2352 2352
 	 * @return boolean
2353 2353
 	 */
2354
-	function exists($query_params){
2354
+	function exists($query_params) {
2355 2355
 		$query_params['limit'] = 1;
2356 2356
 		return $this->count($query_params) > 0;
2357 2357
 	}
@@ -2361,7 +2361,7 @@  discard block
 block discarded – undo
2361 2361
 	 * @param int|string $id
2362 2362
 	 * @return boolean
2363 2363
 	 */
2364
-	function exists_by_ID($id){
2364
+	function exists_by_ID($id) {
2365 2365
 		return $this->exists(array('default_where_conditions'=>'none', array($this->primary_key_name() => $id)));
2366 2366
 	}
2367 2367
 
@@ -2381,45 +2381,45 @@  discard block
 block discarded – undo
2381 2381
 	 * @global WPDB $wpdb only used to get the $wpdb->insert_id after performing an insert
2382 2382
 	 * @return int ID of new row inserted, or FALSE on failure
2383 2383
 	 */
2384
-	protected function _insert_into_specific_table(EE_Table_Base $table, $fields_n_values, $new_id = 0 ){
2384
+	protected function _insert_into_specific_table(EE_Table_Base $table, $fields_n_values, $new_id = 0) {
2385 2385
 		global $wpdb;
2386 2386
 		$insertion_col_n_values = array();
2387 2387
 		$format_for_insertion = array();
2388 2388
 		$fields_on_table = $this->_get_fields_for_table($table->get_table_alias());
2389
-		foreach($fields_on_table as $field_name => $field_obj){
2389
+		foreach ($fields_on_table as $field_name => $field_obj) {
2390 2390
 			//check if its an auto-incrementing column, in which case we should just leave it to do its autoincrement thing
2391
-			if($field_obj->is_auto_increment()){
2391
+			if ($field_obj->is_auto_increment()) {
2392 2392
 				continue;
2393 2393
 			}
2394 2394
 			$prepared_value = $this->_prepare_value_or_use_default($field_obj, $fields_n_values);
2395 2395
 			//if the value we want to assign it to is NULL, just don't mention it for the insertion
2396
-			if( $prepared_value !== NULL ){
2397
-				$insertion_col_n_values[ $field_obj->get_table_column() ] = $prepared_value;
2396
+			if ($prepared_value !== NULL) {
2397
+				$insertion_col_n_values[$field_obj->get_table_column()] = $prepared_value;
2398 2398
 				$format_for_insertion[] = $field_obj->get_wpdb_data_type();
2399 2399
 			}
2400 2400
 		}
2401 2401
 
2402
-		if($table instanceof EE_Secondary_Table && $new_id){
2402
+		if ($table instanceof EE_Secondary_Table && $new_id) {
2403 2403
 			//its not the main table, so we should have already saved the main table's PK which we just inserted
2404 2404
 			//so add the fk to the main table as a column
2405 2405
 			$insertion_col_n_values[$table->get_fk_on_table()] = $new_id;
2406
-			$format_for_insertion[]='%d';//yes right now we're only allowing these foreign keys to be INTs
2406
+			$format_for_insertion[] = '%d'; //yes right now we're only allowing these foreign keys to be INTs
2407 2407
 		}
2408 2408
 		//insert the new entry
2409
-		$result = $this->_do_wpdb_query( 'insert', array( $table->get_table_name(), $insertion_col_n_values, $format_for_insertion ) );
2410
-		if( $result === false ) {
2409
+		$result = $this->_do_wpdb_query('insert', array($table->get_table_name(), $insertion_col_n_values, $format_for_insertion));
2410
+		if ($result === false) {
2411 2411
 			return false;
2412 2412
 		}
2413 2413
 		//ok, now what do we return for the ID of the newly-inserted thing?
2414
-		if($this->has_primary_key_field()){
2415
-			if($this->get_primary_key_field()->is_auto_increment()){
2414
+		if ($this->has_primary_key_field()) {
2415
+			if ($this->get_primary_key_field()->is_auto_increment()) {
2416 2416
 				return $wpdb->insert_id;
2417
-			}else{
2417
+			} else {
2418 2418
 				//it's not an auto-increment primary key, so
2419 2419
 				//it must have been supplied
2420 2420
 				return $fields_n_values[$this->get_primary_key_field()->get_name()];
2421 2421
 			}
2422
-		}else{
2422
+		} else {
2423 2423
 			//we can't return a  primary key because there is none. instead return
2424 2424
 			//a unique string indicating this model
2425 2425
 			return $this->get_index_primary_key_string($fields_n_values);
@@ -2434,15 +2434,15 @@  discard block
 block discarded – undo
2434 2434
 	 * @param array $fields_n_values
2435 2435
 	 * @return mixed string|int|float depending on what the table column will be expecting
2436 2436
 	 */
2437
-	protected function _prepare_value_or_use_default( $field_obj, $fields_n_values ){
2437
+	protected function _prepare_value_or_use_default($field_obj, $fields_n_values) {
2438 2438
 		//if this field doesn't allow nullable, don't allow it
2439
-		if( ! $field_obj->is_nullable() && (
2440
-				! isset( $fields_n_values[ $field_obj->get_name() ] ) ||
2441
-				$fields_n_values[ $field_obj->get_name() ] === NULL ) ){
2442
-			$fields_n_values[ $field_obj->get_name() ] = $field_obj->get_default_value();
2439
+		if ( ! $field_obj->is_nullable() && (
2440
+				! isset($fields_n_values[$field_obj->get_name()]) ||
2441
+				$fields_n_values[$field_obj->get_name()] === NULL )) {
2442
+			$fields_n_values[$field_obj->get_name()] = $field_obj->get_default_value();
2443 2443
 		}
2444
-		$unprepared_value = isset( $fields_n_values[ $field_obj->get_name() ] ) ? $fields_n_values[ $field_obj->get_name() ] : NULL;
2445
-		return $this->_prepare_value_for_use_in_db( $unprepared_value, $field_obj);
2444
+		$unprepared_value = isset($fields_n_values[$field_obj->get_name()]) ? $fields_n_values[$field_obj->get_name()] : NULL;
2445
+		return $this->_prepare_value_for_use_in_db($unprepared_value, $field_obj);
2446 2446
 	}
2447 2447
 
2448 2448
 
@@ -2454,9 +2454,9 @@  discard block
 block discarded – undo
2454 2454
 	 * @param EE_Model_Field_Base $field field which will be doing the preparing of the value. If null, we assume $value is a custom selection
2455 2455
 	 * @return mixed a value ready for use in the database for insertions, updating, or in a where clause
2456 2456
 	 */
2457
-	private function _prepare_value_for_use_in_db($value, $field){
2458
-		if($field && $field instanceof EE_Model_Field_Base){
2459
-			switch( $this->_values_already_prepared_by_model_object ){
2457
+	private function _prepare_value_for_use_in_db($value, $field) {
2458
+		if ($field && $field instanceof EE_Model_Field_Base) {
2459
+			switch ($this->_values_already_prepared_by_model_object) {
2460 2460
 				/** @noinspection PhpMissingBreakStatementInspection */
2461 2461
 				case self::not_prepared_by_model_object:
2462 2462
 					$value = $field->prepare_for_set($value);
@@ -2467,7 +2467,7 @@  discard block
 block discarded – undo
2467 2467
 					//leave the value alone
2468 2468
 			}
2469 2469
 			return $value;
2470
-		}else{
2470
+		} else {
2471 2471
 			return $value;
2472 2472
 		}
2473 2473
 	}
@@ -2477,13 +2477,13 @@  discard block
 block discarded – undo
2477 2477
 	 * @return EE_Primary_Table
2478 2478
 	 * @throws EE_Error
2479 2479
 	 */
2480
-	protected function _get_main_table(){
2481
-		foreach($this->_tables as $table){
2482
-			if($table instanceof EE_Primary_Table){
2480
+	protected function _get_main_table() {
2481
+		foreach ($this->_tables as $table) {
2482
+			if ($table instanceof EE_Primary_Table) {
2483 2483
 				return $table;
2484 2484
 			}
2485 2485
 		}
2486
-		throw new EE_Error(sprintf(__('There are no main tables on %s. They should be added to _tables array in the constructor','event_espresso'),get_class($this)));
2486
+		throw new EE_Error(sprintf(__('There are no main tables on %s. They should be added to _tables array in the constructor', 'event_espresso'), get_class($this)));
2487 2487
 	}
2488 2488
 
2489 2489
 	/**
@@ -2502,7 +2502,7 @@  discard block
 block discarded – undo
2502 2502
 	 */
2503 2503
 	public function second_table() {
2504 2504
 		// grab second table from tables array
2505
-		$second_table = end( $this->_tables );
2505
+		$second_table = end($this->_tables);
2506 2506
 		return $second_table instanceof EE_Secondary_Table ? $second_table->get_table_name() : NULL;
2507 2507
 	}
2508 2508
 
@@ -2515,8 +2515,8 @@  discard block
 block discarded – undo
2515 2515
 	 * @param string $table_alias
2516 2516
 	 * @return EE_Primary_Table | EE_Secondary_Table
2517 2517
 	 */
2518
-	public function get_table_obj_by_alias( $table_alias = '' ) {
2519
-		return isset( $this->_tables[ $table_alias ] ) ? $this->_tables[ $table_alias ] : NULL;
2518
+	public function get_table_obj_by_alias($table_alias = '') {
2519
+		return isset($this->_tables[$table_alias]) ? $this->_tables[$table_alias] : NULL;
2520 2520
 	}
2521 2521
 
2522 2522
 
@@ -2525,10 +2525,10 @@  discard block
 block discarded – undo
2525 2525
 	 * Gets all the tables of type EE_Other_Table from EEM_CPT_Basel_Model::_tables
2526 2526
 	 * @return EE_Secondary_Table[]
2527 2527
 	 */
2528
-	protected function _get_other_tables(){
2529
-		$other_tables =array();
2530
-		foreach($this->_tables as $table_alias => $table){
2531
-			if($table instanceof EE_Secondary_Table){
2528
+	protected function _get_other_tables() {
2529
+		$other_tables = array();
2530
+		foreach ($this->_tables as $table_alias => $table) {
2531
+			if ($table instanceof EE_Secondary_Table) {
2532 2532
 				$other_tables[$table_alias] = $table;
2533 2533
 			}
2534 2534
 		}
@@ -2540,7 +2540,7 @@  discard block
 block discarded – undo
2540 2540
 	 * @param string $table_alias, array key in EEM_Base::_tables
2541 2541
 	 * @return EE_Model_Field_Base[]
2542 2542
 	 */
2543
-	function _get_fields_for_table($table_alias){
2543
+	function _get_fields_for_table($table_alias) {
2544 2544
 		return $this->_fields[$table_alias];
2545 2545
 	}
2546 2546
 
@@ -2552,29 +2552,29 @@  discard block
 block discarded – undo
2552 2552
 	 * @param array $query_params like EEM_Base::get_all's $query_parameters['where']
2553 2553
 	 * @return EE_Model_Query_Info_Carrier
2554 2554
 	 */
2555
-	function _extract_related_models_from_query($query_params){
2555
+	function _extract_related_models_from_query($query_params) {
2556 2556
 		$query_info_carrier = new EE_Model_Query_Info_Carrier();
2557
-		if(array_key_exists(0,$query_params)){
2558
-			$this->_extract_related_models_from_sub_params_array_keys($query_params[0], $query_info_carrier,0);
2559
-		}
2560
-		if(array_key_exists('group_by', $query_params)){
2561
-			if(is_array($query_params['group_by'])){
2562
-				$this->_extract_related_models_from_sub_params_array_values($query_params['group_by'],$query_info_carrier,'group_by');
2563
-			}elseif( ! empty ( $query_params['group_by'] )){
2564
-				$this->_extract_related_model_info_from_query_param( $query_params['group_by'],$query_info_carrier,'group_by');
2557
+		if (array_key_exists(0, $query_params)) {
2558
+			$this->_extract_related_models_from_sub_params_array_keys($query_params[0], $query_info_carrier, 0);
2559
+		}
2560
+		if (array_key_exists('group_by', $query_params)) {
2561
+			if (is_array($query_params['group_by'])) {
2562
+				$this->_extract_related_models_from_sub_params_array_values($query_params['group_by'], $query_info_carrier, 'group_by');
2563
+			}elseif ( ! empty ($query_params['group_by'])) {
2564
+				$this->_extract_related_model_info_from_query_param($query_params['group_by'], $query_info_carrier, 'group_by');
2565 2565
 			}
2566 2566
 		}
2567
-		if(array_key_exists('having',$query_params)){
2568
-			$this->_extract_related_models_from_sub_params_array_keys($query_params[0], $query_info_carrier,'having');
2567
+		if (array_key_exists('having', $query_params)) {
2568
+			$this->_extract_related_models_from_sub_params_array_keys($query_params[0], $query_info_carrier, 'having');
2569 2569
 		}
2570
-		if(array_key_exists('order_by', $query_params)){
2571
-			if ( is_array( $query_params['order_by'] ) )
2572
-				$this->_extract_related_models_from_sub_params_array_keys($query_params['order_by'],$query_info_carrier,'order_by');
2573
-			elseif( ! empty( $query_params['order_by'] ))
2574
-				$this->_extract_related_model_info_from_query_param( $query_params['order_by'], $query_info_carrier,'order_by');
2570
+		if (array_key_exists('order_by', $query_params)) {
2571
+			if (is_array($query_params['order_by']))
2572
+				$this->_extract_related_models_from_sub_params_array_keys($query_params['order_by'], $query_info_carrier, 'order_by');
2573
+			elseif ( ! empty($query_params['order_by']))
2574
+				$this->_extract_related_model_info_from_query_param($query_params['order_by'], $query_info_carrier, 'order_by');
2575 2575
 		}
2576
-		if(array_key_exists('force_join', $query_params)){
2577
-			$this->_extract_related_models_from_sub_params_array_values($query_params['force_join'],$query_info_carrier,'force_join');
2576
+		if (array_key_exists('force_join', $query_params)) {
2577
+			$this->_extract_related_models_from_sub_params_array_values($query_params['force_join'], $query_info_carrier, 'force_join');
2578 2578
 		}
2579 2579
 		return $query_info_carrier;
2580 2580
 	}
@@ -2587,34 +2587,34 @@  discard block
 block discarded – undo
2587 2587
 	 * @throws EE_Error
2588 2588
 	 * @return \EE_Model_Query_Info_Carrier
2589 2589
 	 */
2590
-	private function _extract_related_models_from_sub_params_array_keys($sub_query_params, EE_Model_Query_Info_Carrier $model_query_info_carrier,$query_param_type){
2591
-		if (!empty($sub_query_params)){
2590
+	private function _extract_related_models_from_sub_params_array_keys($sub_query_params, EE_Model_Query_Info_Carrier $model_query_info_carrier, $query_param_type) {
2591
+		if ( ! empty($sub_query_params)) {
2592 2592
 			$sub_query_params = (array) $sub_query_params;
2593
-			foreach($sub_query_params as $param => $possibly_array_of_params){
2593
+			foreach ($sub_query_params as $param => $possibly_array_of_params) {
2594 2594
 				//$param could be simply 'EVT_ID', or it could be 'Registrations.REG_ID', or even 'Registrations.Transactions.Payments.PAY_amount'
2595
-				$this->_extract_related_model_info_from_query_param( $param, $model_query_info_carrier,$query_param_type);
2595
+				$this->_extract_related_model_info_from_query_param($param, $model_query_info_carrier, $query_param_type);
2596 2596
 
2597 2597
 				//if $possibly_array_of_params is an array, try recursing into it, searching for keys which
2598 2598
 				//indicate needed joins. Eg, array('NOT'=>array('Registration.TXN_ID'=>23)). In this case, we tried
2599 2599
 				//extracting models out of the 'NOT', which obviously wasn't successful, and then we recurse into the value
2600 2600
 				//of array('Registration.TXN_ID'=>23)
2601 2601
 				$query_param_sans_stars = $this->_remove_stars_and_anything_after_from_condition_query_param_key($param);
2602
-				if(in_array($query_param_sans_stars, $this->_logic_query_param_keys,true)){
2603
-					if (! is_array($possibly_array_of_params)){
2602
+				if (in_array($query_param_sans_stars, $this->_logic_query_param_keys, true)) {
2603
+					if ( ! is_array($possibly_array_of_params)) {
2604 2604
 						throw new EE_Error(sprintf(__("You used a special where query param %s, but the value isn't an array of where query params, it's just %s'. It should be an array, eg array('EVT_ID'=>23,'OR'=>array('Venue.VNU_ID'=>32,'Venue.VNU_name'=>'monkey_land'))", "event_espresso"),
2605
-							$param,$possibly_array_of_params));
2606
-					}else{
2607
-						$this->_extract_related_models_from_sub_params_array_keys($possibly_array_of_params, $model_query_info_carrier,$query_param_type);
2605
+							$param, $possibly_array_of_params));
2606
+					} else {
2607
+						$this->_extract_related_models_from_sub_params_array_keys($possibly_array_of_params, $model_query_info_carrier, $query_param_type);
2608 2608
 					}
2609
-				}elseif($query_param_type === 0 //ie WHERE
2609
+				}elseif ($query_param_type === 0 //ie WHERE
2610 2610
 						&& is_array($possibly_array_of_params)
2611 2611
 						&& isset($possibly_array_of_params[2])
2612
-						&& $possibly_array_of_params[2] == true){
2612
+						&& $possibly_array_of_params[2] == true) {
2613 2613
 					//then $possible_array_of_params looks something like array('<','DTT_sold',true)
2614 2614
 					//indicating that $possible_array_of_params[1] is actually a field name,
2615 2615
 					//from which we should extract query parameters!
2616
-					if(! isset($possibly_array_of_params[0]) || ! isset($possibly_array_of_params[1])){
2617
-						throw new EE_Error(sprintf(__("Improperly formed query parameter %s. It should be numerically indexed like array('<','DTT_sold',true); but you provided %s", "event_espresso"),$query_param_type,implode(",",$possibly_array_of_params)));
2616
+					if ( ! isset($possibly_array_of_params[0]) || ! isset($possibly_array_of_params[1])) {
2617
+						throw new EE_Error(sprintf(__("Improperly formed query parameter %s. It should be numerically indexed like array('<','DTT_sold',true); but you provided %s", "event_espresso"), $query_param_type, implode(",", $possibly_array_of_params)));
2618 2618
 					}
2619 2619
 					$this->_extract_related_model_info_from_query_param($possibly_array_of_params[1], $model_query_info_carrier, $query_param_type);
2620 2620
 				}
@@ -2633,14 +2633,14 @@  discard block
 block discarded – undo
2633 2633
 	 * @throws EE_Error
2634 2634
 	 * @return \EE_Model_Query_Info_Carrier
2635 2635
 	 */
2636
-	private function _extract_related_models_from_sub_params_array_values($sub_query_params, EE_Model_Query_Info_Carrier $model_query_info_carrier,$query_param_type){
2637
-		if (!empty($sub_query_params)){
2638
-			if(!is_array($sub_query_params)){
2639
-				throw new EE_Error(sprintf(__("Query parameter %s should be an array, but it isn't.", "event_espresso"),$sub_query_params));
2636
+	private function _extract_related_models_from_sub_params_array_values($sub_query_params, EE_Model_Query_Info_Carrier $model_query_info_carrier, $query_param_type) {
2637
+		if ( ! empty($sub_query_params)) {
2638
+			if ( ! is_array($sub_query_params)) {
2639
+				throw new EE_Error(sprintf(__("Query parameter %s should be an array, but it isn't.", "event_espresso"), $sub_query_params));
2640 2640
 			}
2641
-			foreach($sub_query_params as $param){
2641
+			foreach ($sub_query_params as $param) {
2642 2642
 				//$param could be simply 'EVT_ID', or it could be 'Registrations.REG_ID', or even 'Registrations.Transactions.Payments.PAY_amount'
2643
-				$this->_extract_related_model_info_from_query_param( $param, $model_query_info_carrier, $query_param_type);
2643
+				$this->_extract_related_model_info_from_query_param($param, $model_query_info_carrier, $query_param_type);
2644 2644
 			}
2645 2645
 		}
2646 2646
 		return $model_query_info_carrier;
@@ -2659,81 +2659,81 @@  discard block
 block discarded – undo
2659 2659
 	 * @throws EE_Error
2660 2660
 	 * @return EE_Model_Query_Info_Carrier
2661 2661
 	 */
2662
-	function _create_model_query_info_carrier($query_params){
2663
-		if( ! is_array( $query_params ) ){
2664
-			EE_Error::doing_it_wrong('EEM_Base::_create_model_query_info_carrier', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' );
2662
+	function _create_model_query_info_carrier($query_params) {
2663
+		if ( ! is_array($query_params)) {
2664
+			EE_Error::doing_it_wrong('EEM_Base::_create_model_query_info_carrier', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0');
2665 2665
 			$query_params = array();
2666 2666
 		}
2667
-		if( isset( $query_params[0] ) ) {
2667
+		if (isset($query_params[0])) {
2668 2668
 			$where_query_params = $query_params[0];
2669
-		}else{
2669
+		} else {
2670 2670
 			$where_query_params = array();
2671 2671
 		}
2672 2672
 		//first check if we should alter the query to account for caps or not
2673 2673
 		//because the caps might require us to do extra joins
2674
-		if( isset( $query_params[ 'caps' ] ) && $query_params[ 'caps' ] != 'none' ) {
2675
-			$query_params[0] = $where_query_params = array_replace_recursive( $where_query_params, $this->caps_where_conditions( $query_params[ 'caps' ] ) );
2674
+		if (isset($query_params['caps']) && $query_params['caps'] != 'none') {
2675
+			$query_params[0] = $where_query_params = array_replace_recursive($where_query_params, $this->caps_where_conditions($query_params['caps']));
2676 2676
 		}
2677 2677
 		$query_object = $this->_extract_related_models_from_query($query_params);
2678 2678
 
2679 2679
 		//verify where_query_params has NO numeric indexes.... that's simply not how you use it!
2680
-		foreach($where_query_params as $key => $value){
2681
-			if(is_int($key)){
2682
-				throw new EE_Error(sprintf(__("WHERE query params must NOT be numerically-indexed. You provided the array key '%s' for value '%s' while querying model %s. All the query params provided were '%s' Please read documentation on EEM_Base::get_all.", "event_espresso"),$key, var_export( $value, true ), var_export( $query_params, true ), get_class($this)));
2680
+		foreach ($where_query_params as $key => $value) {
2681
+			if (is_int($key)) {
2682
+				throw new EE_Error(sprintf(__("WHERE query params must NOT be numerically-indexed. You provided the array key '%s' for value '%s' while querying model %s. All the query params provided were '%s' Please read documentation on EEM_Base::get_all.", "event_espresso"), $key, var_export($value, true), var_export($query_params, true), get_class($this)));
2683 2683
 			}
2684 2684
 		}
2685
-		if( array_key_exists( 'default_where_conditions',$query_params) && ! empty( $query_params['default_where_conditions'] )){
2685
+		if (array_key_exists('default_where_conditions', $query_params) && ! empty($query_params['default_where_conditions'])) {
2686 2686
 			$use_default_where_conditions = $query_params['default_where_conditions'];
2687
-		}else{
2687
+		} else {
2688 2688
 			$use_default_where_conditions = 'all';
2689 2689
 		}
2690
-		$where_query_params = array_merge($this->_get_default_where_conditions_for_models_in_query($query_object,$use_default_where_conditions,$where_query_params), $where_query_params );
2691
-		$query_object->set_where_sql( $this->_construct_where_clause($where_query_params));
2690
+		$where_query_params = array_merge($this->_get_default_where_conditions_for_models_in_query($query_object, $use_default_where_conditions, $where_query_params), $where_query_params);
2691
+		$query_object->set_where_sql($this->_construct_where_clause($where_query_params));
2692 2692
 
2693 2693
 
2694 2694
 		//if this is a "on_join_limit" then we are limiting on on a specific table in a multi_table join.  So we need to setup a subquery and use that for the main join.  Note for now this only works on the primary table for the model.  So for instance, you could set the limit array like this:
2695 2695
 		//array( 'on_join_limit' => array('Primary_Table_Alias', array(1,10) ) )
2696
-		if ( array_key_exists('on_join_limit', $query_params ) && ! empty( $query_params['on_join_limit'] )) {
2697
-			$query_object->set_main_model_join_sql( $this->_construct_limit_join_select( $query_params['on_join_limit'][0], $query_params['on_join_limit'][1] ) );
2696
+		if (array_key_exists('on_join_limit', $query_params) && ! empty($query_params['on_join_limit'])) {
2697
+			$query_object->set_main_model_join_sql($this->_construct_limit_join_select($query_params['on_join_limit'][0], $query_params['on_join_limit'][1]));
2698 2698
 		}
2699 2699
 
2700 2700
 
2701 2701
 		//set limit
2702
-		if(array_key_exists('limit',$query_params)){
2703
-			if(is_array($query_params['limit'])){
2704
-				if( ! isset($query_params['limit'][0]) || ! isset($query_params['limit'][1])){
2705
-					$e = sprintf(__("Invalid DB query. You passed '%s' for the LIMIT, but only the following are valid: an integer, string representing an integer, a string like 'int,int', or an array like array(int,int)", "event_espresso"),  http_build_query($query_params['limit']));
2702
+		if (array_key_exists('limit', $query_params)) {
2703
+			if (is_array($query_params['limit'])) {
2704
+				if ( ! isset($query_params['limit'][0]) || ! isset($query_params['limit'][1])) {
2705
+					$e = sprintf(__("Invalid DB query. You passed '%s' for the LIMIT, but only the following are valid: an integer, string representing an integer, a string like 'int,int', or an array like array(int,int)", "event_espresso"), http_build_query($query_params['limit']));
2706 2706
 					throw new EE_Error($e."|".$e);
2707 2707
 				}
2708 2708
 				//they passed us an array for the limit. Assume it's like array(50,25), meaning offset by 50, and get 25
2709 2709
 				$query_object->set_limit_sql(" LIMIT ".$query_params['limit'][0].",".$query_params['limit'][1]);
2710
-			}elseif( ! empty ( $query_params['limit'] )){
2710
+			}elseif ( ! empty ($query_params['limit'])) {
2711 2711
 				$query_object->set_limit_sql((" LIMIT ".$query_params['limit']));
2712 2712
 			}
2713 2713
 		}
2714 2714
 		//set order by
2715
-		if(array_key_exists('order_by',$query_params)){
2716
-			if(is_array($query_params['order_by'])){
2715
+		if (array_key_exists('order_by', $query_params)) {
2716
+			if (is_array($query_params['order_by'])) {
2717 2717
 				//if they're using 'order_by' as an array, they can't use 'order' (because 'order_by' must
2718 2718
 				//specify whether to ascend or descend on each field. Eg 'order_by'=>array('EVT_ID'=>'ASC'). So
2719 2719
 				//including 'order' wouldn't make any sense if 'order_by' has already specified which way to order!
2720
-				if(array_key_exists('order', $query_params)){
2720
+				if (array_key_exists('order', $query_params)) {
2721 2721
 					throw new EE_Error(sprintf(__("In querying %s, we are using query parameter 'order_by' as an array (keys:%s,values:%s), and so we can't use query parameter 'order' (value %s). You should just use the 'order_by' parameter ", "event_espresso"),
2722
-							get_class($this),implode(", ",array_keys($query_params['order_by'])),implode(", ",$query_params['order_by']),$query_params['order']));
2722
+							get_class($this), implode(", ", array_keys($query_params['order_by'])), implode(", ", $query_params['order_by']), $query_params['order']));
2723 2723
 				}
2724
-				 $this->_extract_related_models_from_sub_params_array_keys($query_params['order_by'],$query_object,'order_by');
2724
+				 $this->_extract_related_models_from_sub_params_array_keys($query_params['order_by'], $query_object, 'order_by');
2725 2725
 				//assume it's an array of fields to order by
2726 2726
 				$order_array = array();
2727
-				foreach($query_params['order_by'] as $field_name_to_order_by => $order){
2727
+				foreach ($query_params['order_by'] as $field_name_to_order_by => $order) {
2728 2728
 					$order = $this->_extract_order($order);
2729 2729
 					$order_array[] = $this->_deduce_column_name_from_query_param($field_name_to_order_by).SP.$order;
2730 2730
 				}
2731
-				$query_object->set_order_by_sql(" ORDER BY ".implode(",",$order_array));
2732
-			}elseif( ! empty ( $query_params['order_by'] )){
2733
-				$this->_extract_related_model_info_from_query_param($query_params['order_by'],$query_object,'order',$query_params['order_by']);
2734
-				if(isset($query_params['order'])){
2731
+				$query_object->set_order_by_sql(" ORDER BY ".implode(",", $order_array));
2732
+			}elseif ( ! empty ($query_params['order_by'])) {
2733
+				$this->_extract_related_model_info_from_query_param($query_params['order_by'], $query_object, 'order', $query_params['order_by']);
2734
+				if (isset($query_params['order'])) {
2735 2735
 					$order = $this->_extract_order($query_params['order']);
2736
-				}else{
2736
+				} else {
2737 2737
 					$order = 'DESC';
2738 2738
 				}
2739 2739
 				$query_object->set_order_by_sql(" ORDER BY ".$this->_deduce_column_name_from_query_param($query_params['order_by']).SP.$order);
@@ -2741,46 +2741,46 @@  discard block
 block discarded – undo
2741 2741
 		}
2742 2742
 
2743 2743
 		//if 'order_by' wasn't set, maybe they are just using 'order' on its own?
2744
-		if( ! array_key_exists('order_by',$query_params) && array_key_exists('order',$query_params) && ! empty( $query_params['order'] )){
2744
+		if ( ! array_key_exists('order_by', $query_params) && array_key_exists('order', $query_params) && ! empty($query_params['order'])) {
2745 2745
 			$pk_field = $this->get_primary_key_field();
2746 2746
 			$order = $this->_extract_order($query_params['order']);
2747 2747
 			$query_object->set_order_by_sql(" ORDER BY ".$pk_field->get_qualified_column().SP.$order);
2748 2748
 		}
2749 2749
 
2750 2750
 		//set group by
2751
-		if(array_key_exists('group_by',$query_params)){
2752
-			if(is_array($query_params['group_by'])){
2751
+		if (array_key_exists('group_by', $query_params)) {
2752
+			if (is_array($query_params['group_by'])) {
2753 2753
 				//it's an array, so assume we'll be grouping by a bunch of stuff
2754 2754
 				$group_by_array = array();
2755
-				foreach($query_params['group_by'] as $field_name_to_group_by){
2755
+				foreach ($query_params['group_by'] as $field_name_to_group_by) {
2756 2756
 					$group_by_array[] = $this->_deduce_column_name_from_query_param($field_name_to_group_by);
2757 2757
 				}
2758
-				$query_object->set_group_by_sql(" GROUP BY ".implode(", ",$group_by_array));
2759
-			}elseif( ! empty ( $query_params['group_by'] )){
2758
+				$query_object->set_group_by_sql(" GROUP BY ".implode(", ", $group_by_array));
2759
+			}elseif ( ! empty ($query_params['group_by'])) {
2760 2760
 				$query_object->set_group_by_sql(" GROUP BY ".$this->_deduce_column_name_from_query_param($query_params['group_by']));
2761 2761
 			}
2762 2762
 		}
2763 2763
 		//set having
2764
-		if(array_key_exists('having',$query_params) && $query_params['having']){
2765
-			$query_object->set_having_sql( $this->_construct_having_clause($query_params['having']));
2764
+		if (array_key_exists('having', $query_params) && $query_params['having']) {
2765
+			$query_object->set_having_sql($this->_construct_having_clause($query_params['having']));
2766 2766
 		}
2767 2767
 
2768 2768
 		//now, just verify they didn't pass anything wack
2769
-		foreach($query_params as $query_key => $query_value){
2770
-			if( ! in_array($query_key,$this->_allowed_query_params,true)){
2769
+		foreach ($query_params as $query_key => $query_value) {
2770
+			if ( ! in_array($query_key, $this->_allowed_query_params, true)) {
2771 2771
 				throw new EE_Error(
2772 2772
 					sprintf(
2773
-						__("You passed %s as a query parameter to %s, which is illegal! The allowed query parameters are %s",'event_espresso'),
2773
+						__("You passed %s as a query parameter to %s, which is illegal! The allowed query parameters are %s", 'event_espresso'),
2774 2774
 						$query_key,
2775 2775
 						get_class($this),
2776 2776
 //						print_r( $this->_allowed_query_params, TRUE )
2777
-						implode( ',', $this->_allowed_query_params )
2777
+						implode(',', $this->_allowed_query_params)
2778 2778
 					)
2779 2779
 				);
2780 2780
 			}
2781 2781
 		}
2782 2782
 		$main_model_join_sql = $query_object->get_main_model_join_sql();
2783
-		if ( empty( $main_model_join_sql ) )
2783
+		if (empty($main_model_join_sql))
2784 2784
 			$query_object->set_main_model_join_sql($this->_construct_internal_join());
2785 2785
 		return $query_object;
2786 2786
 	}
@@ -2791,17 +2791,17 @@  discard block
 block discarded – undo
2791 2791
 	 * @param string $context one of EEM_Base::valid_cap_contexts()
2792 2792
 	 * @return array like EEM_Base::get_all() 's $query_params[0]
2793 2793
 	 */
2794
-	public function caps_where_conditions( $context = self::caps_read ) {
2795
-		EEM_Base::verify_is_valid_cap_context( $context );
2794
+	public function caps_where_conditions($context = self::caps_read) {
2795
+		EEM_Base::verify_is_valid_cap_context($context);
2796 2796
 		$cap_where_conditions = array();
2797
-		$cap_restrictions = $this->caps_missing( $context );
2797
+		$cap_restrictions = $this->caps_missing($context);
2798 2798
 		/**
2799 2799
 		 * @var $cap_restrictions EE_Default_Where_Conditions[]
2800 2800
 		 */
2801
-		foreach( $cap_restrictions as $cap => $restriction_if_no_cap ) {
2802
-				$cap_where_conditions = array_replace_recursive( $cap_where_conditions, $restriction_if_no_cap->get_default_where_conditions() );
2801
+		foreach ($cap_restrictions as $cap => $restriction_if_no_cap) {
2802
+				$cap_where_conditions = array_replace_recursive($cap_where_conditions, $restriction_if_no_cap->get_default_where_conditions());
2803 2803
 		}
2804
-		return apply_filters( 'FHEE__EEM_Base__caps_where_conditions__return', $cap_where_conditions, $this, $context, $cap_restrictions );
2804
+		return apply_filters('FHEE__EEM_Base__caps_where_conditions__return', $cap_where_conditions, $this, $context, $cap_restrictions);
2805 2805
 	}
2806 2806
 
2807 2807
 	/**
@@ -2811,11 +2811,11 @@  discard block
 block discarded – undo
2811 2811
 	 * @return string either ASC, asc, DESC or desc
2812 2812
 	 * @throws EE_Error
2813 2813
 	 */
2814
-	private function _extract_order($should_be_order_string){
2815
-		if(in_array($should_be_order_string, $this->_allowed_order_values)){
2814
+	private function _extract_order($should_be_order_string) {
2815
+		if (in_array($should_be_order_string, $this->_allowed_order_values)) {
2816 2816
 			return $should_be_order_string;
2817
-		}else{
2818
-			throw new EE_Error(sprintf(__("While performing a query on '%s', tried to use '%s' as an order parameter. ", "event_espresso"),get_class($this),$should_be_order_string));
2817
+		} else {
2818
+			throw new EE_Error(sprintf(__("While performing a query on '%s', tried to use '%s' as an order parameter. ", "event_espresso"), get_class($this), $should_be_order_string));
2819 2819
 		}
2820 2820
 	}
2821 2821
 
@@ -2833,7 +2833,7 @@  discard block
 block discarded – undo
2833 2833
 	 * @throws EE_Error
2834 2834
 	 * @return array like $query_params[0], see EEM_Base::get_all for documentation
2835 2835
 	 */
2836
-	private function _get_default_where_conditions_for_models_in_query(EE_Model_Query_Info_Carrier $query_info_carrier,$use_default_where_conditions = 'all',$where_query_params = array()){
2836
+	private function _get_default_where_conditions_for_models_in_query(EE_Model_Query_Info_Carrier $query_info_carrier, $use_default_where_conditions = 'all', $where_query_params = array()) {
2837 2837
 		$allowed_used_default_where_conditions_values = array(
2838 2838
 				'all',
2839 2839
 				'this_model_only', 
@@ -2841,23 +2841,23 @@  discard block
 block discarded – undo
2841 2841
 				'minimum',
2842 2842
 				'none'
2843 2843
 			);
2844
-		if( ! in_array($use_default_where_conditions,$allowed_used_default_where_conditions_values)){
2845
-			throw new EE_Error(sprintf(__("You passed an invalid value to the query parameter 'default_where_conditions' of '%s'. Allowed values are %s", "event_espresso"),$use_default_where_conditions,implode(", ",$allowed_used_default_where_conditions_values)));
2844
+		if ( ! in_array($use_default_where_conditions, $allowed_used_default_where_conditions_values)) {
2845
+			throw new EE_Error(sprintf(__("You passed an invalid value to the query parameter 'default_where_conditions' of '%s'. Allowed values are %s", "event_espresso"), $use_default_where_conditions, implode(", ", $allowed_used_default_where_conditions_values)));
2846 2846
 		}
2847
-		if( in_array($use_default_where_conditions, array('all','this_model_only')) ){
2847
+		if (in_array($use_default_where_conditions, array('all', 'this_model_only'))) {
2848 2848
 			$universal_query_params = $this->_get_default_where_conditions();
2849
-		}elseif( $use_default_where_conditions == 'minimum' ) {
2849
+		}elseif ($use_default_where_conditions == 'minimum') {
2850 2850
 			$universal_query_params = $this->_get_minimum_where_conditions();
2851
-		}else{
2851
+		} else {
2852 2852
 			$universal_query_params = array();
2853 2853
 		}
2854 2854
 
2855
-		if(in_array($use_default_where_conditions,array('all', 'minimum',  'other_models_only'))){
2856
-			foreach($query_info_carrier->get_model_names_included() as $model_relation_path => $model_name){
2855
+		if (in_array($use_default_where_conditions, array('all', 'minimum', 'other_models_only'))) {
2856
+			foreach ($query_info_carrier->get_model_names_included() as $model_relation_path => $model_name) {
2857 2857
 				$related_model = $this->get_related_model_obj($model_name);
2858
-				if( $use_default_where_conditions == 'minimum' ) {
2858
+				if ($use_default_where_conditions == 'minimum') {
2859 2859
 					$related_model_universal_where_params = $related_model->_get_minimum_where_conditions($model_relation_path);
2860
-				}else{
2860
+				} else {
2861 2861
 					$related_model_universal_where_params = $related_model->_get_default_where_conditions($model_relation_path);
2862 2862
 				}
2863 2863
 
@@ -2884,22 +2884,22 @@  discard block
 block discarded – undo
2884 2884
 	 * @param string $model_relation_path like 'Transaction.Payment.'
2885 2885
 	 * @return array like EEM_Base::get_all's $query_params[0]
2886 2886
 	 */
2887
-	private function _override_defaults_or_make_null_friendly($default_where_conditions,$provided_where_conditions,$model,$model_relation_path){
2887
+	private function _override_defaults_or_make_null_friendly($default_where_conditions, $provided_where_conditions, $model, $model_relation_path) {
2888 2888
 		$null_friendly_where_conditions = array();
2889 2889
 		$none_overridden = true;
2890 2890
 		$or_condition_key_for_defaults = 'OR*'.get_class($model);
2891 2891
 
2892
-		foreach($default_where_conditions as $key => $val){
2893
-			if( isset($provided_where_conditions[$key])){
2892
+		foreach ($default_where_conditions as $key => $val) {
2893
+			if (isset($provided_where_conditions[$key])) {
2894 2894
 				$none_overridden = false;
2895
-			}else{
2895
+			} else {
2896 2896
 				$null_friendly_where_conditions[$or_condition_key_for_defaults]['AND'][$key] = $val;
2897 2897
 			}
2898 2898
 		}
2899
-		if( $none_overridden && $default_where_conditions){
2900
-			if($model->has_primary_key_field()){
2899
+		if ($none_overridden && $default_where_conditions) {
2900
+			if ($model->has_primary_key_field()) {
2901 2901
 				$null_friendly_where_conditions[$or_condition_key_for_defaults][$model_relation_path.".".$model->primary_key_name()] = array('IS NULL');
2902
-			}else{
2902
+			} else {
2903 2903
 				//@todo NO PK, use other defaults
2904 2904
 			}
2905 2905
 		}
@@ -2914,8 +2914,8 @@  discard block
 block discarded – undo
2914 2914
 	 * @param string $model_relation_path eg, path from Event to Payment is "Registration.Transaction.Payment."
2915 2915
 	 * @return array like EEM_Base::get_all's $query_params[0] (where conditions)
2916 2916
 	 */
2917
-	protected function _get_default_where_conditions($model_relation_path = null){
2918
-		if ( $this->_ignore_where_strategy )
2917
+	protected function _get_default_where_conditions($model_relation_path = null) {
2918
+		if ($this->_ignore_where_strategy)
2919 2919
 			return array();
2920 2920
 
2921 2921
 		return $this->_default_where_conditions_strategy->get_default_where_conditions($model_relation_path);
@@ -2930,8 +2930,8 @@  discard block
 block discarded – undo
2930 2930
 	 * @param string $model_relation_path eg, path from Event to Payment is "Registration.Transaction.Payment."
2931 2931
 	 * @return array like EEM_Base::get_all's $query_params[0] (where conditions)
2932 2932
 	 */
2933
-	protected function _get_minimum_where_conditions($model_relation_path = null){
2934
-		if ( $this->_ignore_where_strategy )
2933
+	protected function _get_minimum_where_conditions($model_relation_path = null) {
2934
+		if ($this->_ignore_where_strategy)
2935 2935
 			return array();
2936 2936
 
2937 2937
 		return $this->_minimum_where_conditions_strategy->get_default_where_conditions($model_relation_path);
@@ -2942,13 +2942,13 @@  discard block
 block discarded – undo
2942 2942
 	 * @param EE_Model_Query_Info_Carrier $model_query_info
2943 2943
 	 * @return string
2944 2944
 	 */
2945
-	private function _construct_default_select_sql(EE_Model_Query_Info_Carrier $model_query_info){
2945
+	private function _construct_default_select_sql(EE_Model_Query_Info_Carrier $model_query_info) {
2946 2946
 		$selects = $this->_get_columns_to_select_for_this_model();
2947
-		foreach($model_query_info->get_model_names_included() as $model_relation_chain => $name_of_other_model_included){
2947
+		foreach ($model_query_info->get_model_names_included() as $model_relation_chain => $name_of_other_model_included) {
2948 2948
 			$other_model_included = $this->get_related_model_obj($name_of_other_model_included);
2949 2949
 			$selects = array_merge($selects, $other_model_included->_get_columns_to_select_for_this_model($model_relation_chain));
2950 2950
 		}
2951
-		return implode(", ",$selects);
2951
+		return implode(", ", $selects);
2952 2952
 	}
2953 2953
 
2954 2954
 	/**
@@ -2957,19 +2957,19 @@  discard block
 block discarded – undo
2957 2957
 	 * @param string $model_relation_chain like 'Question.Question_Group.Event'
2958 2958
 	 * @return array numerically indexed, values are columns to select and rename, eg "Event.ID AS 'Event.ID'"
2959 2959
 	 */
2960
-	public function _get_columns_to_select_for_this_model($model_relation_chain = ''){
2960
+	public function _get_columns_to_select_for_this_model($model_relation_chain = '') {
2961 2961
 		$fields = $this->field_settings();
2962 2962
 		$selects = array();
2963 2963
 		$table_alias_with_model_relation_chain_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_this_model_name());
2964
-		foreach($fields as $field_obj){
2965
-			$selects[] = $table_alias_with_model_relation_chain_prefix . $field_obj->get_table_alias().".".$field_obj->get_table_column()." AS '".$table_alias_with_model_relation_chain_prefix.$field_obj->get_table_alias().".".$field_obj->get_table_column()."'";
2964
+		foreach ($fields as $field_obj) {
2965
+			$selects[] = $table_alias_with_model_relation_chain_prefix.$field_obj->get_table_alias().".".$field_obj->get_table_column()." AS '".$table_alias_with_model_relation_chain_prefix.$field_obj->get_table_alias().".".$field_obj->get_table_column()."'";
2966 2966
 		}
2967 2967
 		//make sure we are also getting the PKs of each table
2968 2968
 		$tables = $this->get_tables();
2969
-		if(count($tables) > 1){
2970
-			foreach($tables as $table_obj){
2971
-				$qualified_pk_column = $table_alias_with_model_relation_chain_prefix . $table_obj->get_fully_qualified_pk_column();
2972
-				if( ! in_array($qualified_pk_column,$selects)){
2969
+		if (count($tables) > 1) {
2970
+			foreach ($tables as $table_obj) {
2971
+				$qualified_pk_column = $table_alias_with_model_relation_chain_prefix.$table_obj->get_fully_qualified_pk_column();
2972
+				if ( ! in_array($qualified_pk_column, $selects)) {
2973 2973
 					$selects[] = "$qualified_pk_column AS '$qualified_pk_column'";
2974 2974
 				}
2975 2975
 			}
@@ -2993,66 +2993,66 @@  discard block
 block discarded – undo
2993 2993
 	 * @throws EE_Error
2994 2994
 	 * @return void only modifies the EEM_Related_Model_Info_Carrier passed into it
2995 2995
 	 */
2996
-	private function _extract_related_model_info_from_query_param( $query_param, EE_Model_Query_Info_Carrier $passed_in_query_info, $query_param_type, $original_query_param = NULL ){
2997
-		if($original_query_param == NULL){
2996
+	private function _extract_related_model_info_from_query_param($query_param, EE_Model_Query_Info_Carrier $passed_in_query_info, $query_param_type, $original_query_param = NULL) {
2997
+		if ($original_query_param == NULL) {
2998 2998
 			$original_query_param = $query_param;
2999 2999
 		}
3000 3000
 		$query_param = $this->_remove_stars_and_anything_after_from_condition_query_param_key($query_param);
3001 3001
 		/** @var $allow_logic_query_params bool whether or not to allow logic_query_params like 'NOT','OR', or 'AND' */
3002
-		$allow_logic_query_params = in_array($query_param_type,array('where','having'));
3003
-		$allow_fields = in_array($query_param_type,array('where','having','order_by','group_by','order'));
3002
+		$allow_logic_query_params = in_array($query_param_type, array('where', 'having'));
3003
+		$allow_fields = in_array($query_param_type, array('where', 'having', 'order_by', 'group_by', 'order'));
3004 3004
 		//check to see if we have a field on this model
3005 3005
 		$this_model_fields = $this->field_settings(true);
3006
-		if(array_key_exists($query_param,$this_model_fields)){
3007
-			if($allow_fields){
3006
+		if (array_key_exists($query_param, $this_model_fields)) {
3007
+			if ($allow_fields) {
3008 3008
 				return;
3009
-			}else{
3009
+			} else {
3010 3010
 				throw new EE_Error(sprintf(__("Using a field name (%s) on model %s is not allowed on this query param type '%s'. Original query param was %s", "event_espresso"),
3011
-						$query_param,get_class($this),$query_param_type,$original_query_param));
3011
+						$query_param, get_class($this), $query_param_type, $original_query_param));
3012 3012
 			}
3013 3013
 		}
3014 3014
 		//check if this is a special logic query param
3015
-		elseif(in_array($query_param, $this->_logic_query_param_keys, TRUE)){
3016
-			if($allow_logic_query_params){
3015
+		elseif (in_array($query_param, $this->_logic_query_param_keys, TRUE)) {
3016
+			if ($allow_logic_query_params) {
3017 3017
 				return;
3018
-			}else{
3018
+			} else {
3019 3019
 				throw new EE_Error(
3020 3020
 					sprintf(
3021
-						__( 'Logic query params ("%1$s") are being used incorrectly with the following query param ("%2$s") on model %3$s. %4$sAdditional Info:%4$s%5$s', 'event_espresso' ),
3022
-						implode( '", "', $this->_logic_query_param_keys ),
3023
-						$query_param ,
3024
-						get_class( $this ),
3021
+						__('Logic query params ("%1$s") are being used incorrectly with the following query param ("%2$s") on model %3$s. %4$sAdditional Info:%4$s%5$s', 'event_espresso'),
3022
+						implode('", "', $this->_logic_query_param_keys),
3023
+						$query_param,
3024
+						get_class($this),
3025 3025
 						'<br />',
3026
-						"\t" . ' $passed_in_query_info = <pre>' . print_r( $passed_in_query_info, TRUE ) . '</pre>' . "\n\t" . ' $query_param_type = ' . $query_param_type . "\n\t" . ' $original_query_param = ' . $original_query_param
3026
+						"\t".' $passed_in_query_info = <pre>'.print_r($passed_in_query_info, TRUE).'</pre>'."\n\t".' $query_param_type = '.$query_param_type."\n\t".' $original_query_param = '.$original_query_param
3027 3027
 					)
3028 3028
 				);
3029 3029
 			}
3030 3030
 		}
3031 3031
 
3032 3032
 		//check if it's a custom selection
3033
-		elseif(array_key_exists($query_param,$this->_custom_selections)){
3033
+		elseif (array_key_exists($query_param, $this->_custom_selections)) {
3034 3034
 			return;
3035 3035
 		}
3036 3036
 
3037 3037
 		//check if has a model name at the beginning
3038 3038
 		//and
3039 3039
 		//check if it's a field on a related model
3040
-		foreach($this->_model_relations as $valid_related_model_name=>$relation_obj){
3041
-			if(strpos($query_param, $valid_related_model_name.".") === 0){
3042
-				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info,$original_query_param);
3040
+		foreach ($this->_model_relations as $valid_related_model_name=>$relation_obj) {
3041
+			if (strpos($query_param, $valid_related_model_name.".") === 0) {
3042
+				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info, $original_query_param);
3043 3043
 				$query_param = substr($query_param, strlen($valid_related_model_name."."));
3044
-				if($query_param == ''){
3044
+				if ($query_param == '') {
3045 3045
 					//nothing left to $query_param
3046 3046
 					//we should actually end in a field name, not a model like this!
3047 3047
 					throw new EE_Error(sprintf(__("Query param '%s' (of type %s on model %s) shouldn't end on a period (.) ", "event_espresso"),
3048
-					$query_param,$query_param_type,get_class($this),$valid_related_model_name));
3049
-				}else{
3048
+					$query_param, $query_param_type, get_class($this), $valid_related_model_name));
3049
+				} else {
3050 3050
 					$related_model_obj = $this->get_related_model_obj($valid_related_model_name);
3051 3051
 					$related_model_obj->_extract_related_model_info_from_query_param($query_param, $passed_in_query_info, $query_param_type, $original_query_param);
3052 3052
 					return;
3053 3053
 				}
3054
-			}elseif($query_param == $valid_related_model_name){
3055
-				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info,$original_query_param);
3054
+			}elseif ($query_param == $valid_related_model_name) {
3055
+				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info, $original_query_param);
3056 3056
 				return;
3057 3057
 			}
3058 3058
 		}
@@ -3062,7 +3062,7 @@  discard block
 block discarded – undo
3062 3062
 		//and we previously confirmed it wasn't a logic query param or field on the current model
3063 3063
 		//it's wack, that's what it is
3064 3064
 		throw new EE_Error(sprintf(__("There is no model named '%s' related to %s. Query param type is %s and original query param is %s", "event_espresso"),
3065
-				$query_param,get_class($this),$query_param_type,$original_query_param));
3065
+				$query_param, get_class($this), $query_param_type, $original_query_param));
3066 3066
 
3067 3067
 	}
3068 3068
 
@@ -3079,26 +3079,26 @@  discard block
 block discarded – undo
3079 3079
 	 * what models to prepend onto its default query params or in case it wants to rename tables (in case there are multiple joins to the same table)
3080 3080
 	 * @return void
3081 3081
 	 */
3082
-	private function _add_join_to_model($model_name, EE_Model_Query_Info_Carrier $passed_in_query_info,$original_query_param){
3082
+	private function _add_join_to_model($model_name, EE_Model_Query_Info_Carrier $passed_in_query_info, $original_query_param) {
3083 3083
 		$relation_obj = $this->related_settings_for($model_name);
3084 3084
 
3085 3085
 		$model_relation_chain = EE_Model_Parser::extract_model_relation_chain($model_name, $original_query_param);
3086 3086
 		//check if the relation is HABTM, because then we're essentially doing two joins
3087 3087
 		//If so, join first to the JOIN table, and add its data types, and then continue as normal
3088
-		if($relation_obj instanceof EE_HABTM_Relation){
3088
+		if ($relation_obj instanceof EE_HABTM_Relation) {
3089 3089
 			$join_model_obj = $relation_obj->get_join_model();
3090 3090
 			//replace the model specified with the join model for this relation chain, whi
3091 3091
 			$relation_chain_to_join_model = EE_Model_Parser::replace_model_name_with_join_model_name_in_model_relation_chain($model_name, $join_model_obj->get_this_model_name(), $model_relation_chain);
3092 3092
 			$new_query_info = new EE_Model_Query_Info_Carrier(
3093 3093
 					array($relation_chain_to_join_model => $join_model_obj->get_this_model_name()),
3094 3094
 					$relation_obj->get_join_to_intermediate_model_statement($relation_chain_to_join_model));
3095
-			$passed_in_query_info->merge( $new_query_info  );
3095
+			$passed_in_query_info->merge($new_query_info);
3096 3096
 		}
3097 3097
 		//now just join to the other table pointed to by the relation object, and add its data types
3098 3098
 		$new_query_info = new EE_Model_Query_Info_Carrier(
3099 3099
 				array($model_relation_chain=>$model_name),
3100 3100
 				$relation_obj->get_join_statement($model_relation_chain));
3101
-		$passed_in_query_info->merge( $new_query_info  );
3101
+		$passed_in_query_info->merge($new_query_info);
3102 3102
 	}
3103 3103
 
3104 3104
 
@@ -3107,11 +3107,11 @@  discard block
 block discarded – undo
3107 3107
 	 * @param array $where_params like EEM_Base::get_all
3108 3108
 	 * @return string of SQL
3109 3109
 	 */
3110
-	private function _construct_where_clause($where_params){
3110
+	private function _construct_where_clause($where_params) {
3111 3111
 		$SQL = $this->_construct_condition_clause_recursive($where_params, ' AND ');
3112
-		if($SQL){
3113
-			return " WHERE ". $SQL;
3114
-		}else{
3112
+		if ($SQL) {
3113
+			return " WHERE ".$SQL;
3114
+		} else {
3115 3115
 			return '';
3116 3116
 		}
3117 3117
 	}
@@ -3122,11 +3122,11 @@  discard block
 block discarded – undo
3122 3122
 	 * @param array $having_params
3123 3123
 	 * @return string
3124 3124
 	 */
3125
-	private function _construct_having_clause($having_params){
3125
+	private function _construct_having_clause($having_params) {
3126 3126
 		$SQL = $this->_construct_condition_clause_recursive($having_params, ' AND ');
3127
-		if($SQL){
3128
-			return " HAVING ". $SQL;
3129
-		}else{
3127
+		if ($SQL) {
3128
+			return " HAVING ".$SQL;
3129
+		} else {
3130 3130
 			return '';
3131 3131
 		}
3132 3132
 
@@ -3140,17 +3140,17 @@  discard block
 block discarded – undo
3140 3140
 	 * @return EE_Model_Field_Base
3141 3141
 	 * @throws EE_Error
3142 3142
 	 */
3143
-	protected function _get_field_on_model($field_name,$model_name){
3143
+	protected function _get_field_on_model($field_name, $model_name) {
3144 3144
 		$model_class = 'EEM_'.$model_name;
3145 3145
 		$model_filepath = $model_class.".model.php";
3146
-		EE_Registry::instance()->load_helper( 'File' );
3147
-		if ( is_readable($model_filepath)){
3146
+		EE_Registry::instance()->load_helper('File');
3147
+		if (is_readable($model_filepath)) {
3148 3148
 			require_once($model_filepath);
3149
-			$model_instance=call_user_func($model_name."::instance");
3149
+			$model_instance = call_user_func($model_name."::instance");
3150 3150
 			/* @var $model_instance EEM_Base */
3151 3151
 			return $model_instance->field_settings_for($field_name);
3152
-		}else{
3153
-			throw new EE_Error(sprintf(__('No model named %s exists, with classname %s and filepath %s','event_espresso'),$model_name,$model_class,$model_filepath));
3152
+		} else {
3153
+			throw new EE_Error(sprintf(__('No model named %s exists, with classname %s and filepath %s', 'event_espresso'), $model_name, $model_class, $model_filepath));
3154 3154
 		}
3155 3155
 	}
3156 3156
 
@@ -3163,43 +3163,43 @@  discard block
 block discarded – undo
3163 3163
 	 * @throws EE_Error
3164 3164
 	 * @return string of SQL
3165 3165
 	 */
3166
-	private function _construct_condition_clause_recursive($where_params, $glue = ' AND'){
3167
-		$where_clauses=array();
3168
-		foreach($where_params as $query_param => $op_and_value_or_sub_condition){
3169
-			$query_param = $this->_remove_stars_and_anything_after_from_condition_query_param_key($query_param);//str_replace("*",'',$query_param);
3170
-			if(in_array($query_param,$this->_logic_query_param_keys)){
3171
-				switch($query_param){
3166
+	private function _construct_condition_clause_recursive($where_params, $glue = ' AND') {
3167
+		$where_clauses = array();
3168
+		foreach ($where_params as $query_param => $op_and_value_or_sub_condition) {
3169
+			$query_param = $this->_remove_stars_and_anything_after_from_condition_query_param_key($query_param); //str_replace("*",'',$query_param);
3170
+			if (in_array($query_param, $this->_logic_query_param_keys)) {
3171
+				switch ($query_param) {
3172 3172
 					case 'not':
3173 3173
 					case 'NOT':
3174
-						$where_clauses[] = "! (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, $glue).")";
3174
+						$where_clauses[] = "! (".$this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, $glue).")";
3175 3175
 						break;
3176 3176
 					case 'and':
3177 3177
 					case 'AND':
3178
-						$where_clauses[] = " (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' AND ') .")";
3178
+						$where_clauses[] = " (".$this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' AND ').")";
3179 3179
 						break;
3180 3180
 					case 'or':
3181 3181
 					case 'OR':
3182
-						$where_clauses[] = " (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' OR ') .")";
3182
+						$where_clauses[] = " (".$this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' OR ').")";
3183 3183
 						break;
3184 3184
 				}
3185
-			}else{
3185
+			} else {
3186 3186
 				$field_obj = $this->_deduce_field_from_query_param($query_param);
3187 3187
 
3188 3188
 				//if it's not a normal field, maybe it's a custom selection?
3189
-				if( ! $field_obj){
3190
-					if(isset( $this->_custom_selections[$query_param][1])){
3189
+				if ( ! $field_obj) {
3190
+					if (isset($this->_custom_selections[$query_param][1])) {
3191 3191
 						$field_obj = $this->_custom_selections[$query_param][1];
3192
-					}else{
3193
-						throw new EE_Error(sprintf(__("%s is neither a valid model field name, nor a custom selection", "event_espresso"),$query_param));
3192
+					} else {
3193
+						throw new EE_Error(sprintf(__("%s is neither a valid model field name, nor a custom selection", "event_espresso"), $query_param));
3194 3194
 					}
3195 3195
 				}
3196 3196
 				$op_and_value_sql = $this->_construct_op_and_value($op_and_value_or_sub_condition, $field_obj);
3197
-				$where_clauses[]=$this->_deduce_column_name_from_query_param($query_param).SP.$op_and_value_sql;
3197
+				$where_clauses[] = $this->_deduce_column_name_from_query_param($query_param).SP.$op_and_value_sql;
3198 3198
 			}
3199 3199
 		}
3200
-		if($where_clauses){
3201
-			$SQL = implode($glue,$where_clauses);
3202
-		}else{
3200
+		if ($where_clauses) {
3201
+			$SQL = implode($glue, $where_clauses);
3202
+		} else {
3203 3203
 			$SQL = '';
3204 3204
 		}
3205 3205
 		return $SQL;
@@ -3213,18 +3213,18 @@  discard block
 block discarded – undo
3213 3213
 	 * @throws EE_Error
3214 3214
 	 * @return string table alias and column name for SQL, eg "Transaction.TXN_ID"
3215 3215
 	 */
3216
-	private function _deduce_column_name_from_query_param($query_param){
3216
+	private function _deduce_column_name_from_query_param($query_param) {
3217 3217
 		$field = $this->_deduce_field_from_query_param($query_param);
3218 3218
 
3219
-		if( $field ){
3220
-			$table_alias_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_from_query_param( $field->get_model_name(), $query_param );
3221
-			return $table_alias_prefix . $field->get_qualified_column();
3222
-		}elseif(array_key_exists($query_param,$this->_custom_selections)){
3219
+		if ($field) {
3220
+			$table_alias_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_from_query_param($field->get_model_name(), $query_param);
3221
+			return $table_alias_prefix.$field->get_qualified_column();
3222
+		}elseif (array_key_exists($query_param, $this->_custom_selections)) {
3223 3223
 			//maybe it's custom selection item?
3224 3224
 			//if so, just use it as the "column name"
3225 3225
 			return $query_param;
3226
-		}else{
3227
-			throw new EE_Error(sprintf(__("%s is not a valid field on this model, nor a custom selection (%s)", "event_espresso"),$query_param,implode(",",$this->_custom_selections)));
3226
+		} else {
3227
+			throw new EE_Error(sprintf(__("%s is not a valid field on this model, nor a custom selection (%s)", "event_espresso"), $query_param, implode(",", $this->_custom_selections)));
3228 3228
 		}
3229 3229
 	}
3230 3230
 
@@ -3236,11 +3236,11 @@  discard block
 block discarded – undo
3236 3236
 	 * @param string $condition_query_param_key
3237 3237
 	 * @return string
3238 3238
 	 */
3239
-	private function _remove_stars_and_anything_after_from_condition_query_param_key($condition_query_param_key){
3239
+	private function _remove_stars_and_anything_after_from_condition_query_param_key($condition_query_param_key) {
3240 3240
 		$pos_of_star = strpos($condition_query_param_key, '*');
3241
-		if($pos_of_star === FALSE){
3241
+		if ($pos_of_star === FALSE) {
3242 3242
 			return $condition_query_param_key;
3243
-		}else{
3243
+		} else {
3244 3244
 			$condition_query_param_sans_star = substr($condition_query_param_key, 0, $pos_of_star);
3245 3245
 			return $condition_query_param_sans_star;
3246 3246
 		}
@@ -3255,54 +3255,54 @@  discard block
 block discarded – undo
3255 3255
 	 * @throws EE_Error
3256 3256
 	 * @return string
3257 3257
 	 */
3258
-	private function _construct_op_and_value($op_and_value, $field_obj){
3259
-		if(is_array( $op_and_value )){
3258
+	private function _construct_op_and_value($op_and_value, $field_obj) {
3259
+		if (is_array($op_and_value)) {
3260 3260
 			$operator = isset($op_and_value[0]) ? $this->_prepare_operator_for_sql($op_and_value[0]) : null;
3261
-			if( ! $operator){
3261
+			if ( ! $operator) {
3262 3262
 				$php_array_like_string = array();
3263
-				foreach($op_and_value as $key => $value){
3263
+				foreach ($op_and_value as $key => $value) {
3264 3264
 					$php_array_like_string[] = "$key=>$value";
3265 3265
 				}
3266
-				throw new EE_Error(sprintf(__("You setup a query parameter like you were going to specify an operator, but didn't. You provided '(%s)', but the operator should be at array key index 0 (eg array('>',32))", "event_espresso"), implode(",",$php_array_like_string)));
3266
+				throw new EE_Error(sprintf(__("You setup a query parameter like you were going to specify an operator, but didn't. You provided '(%s)', but the operator should be at array key index 0 (eg array('>',32))", "event_espresso"), implode(",", $php_array_like_string)));
3267 3267
 			}
3268 3268
 			$value = isset($op_and_value[1]) ? $op_and_value[1] : null;
3269
-		}else{
3269
+		} else {
3270 3270
 			$operator = '=';
3271 3271
 			$value = $op_and_value;
3272 3272
 		}
3273 3273
 
3274 3274
 		//check to see if the value is actually another field
3275
-		if(is_array($op_and_value) && isset($op_and_value[2]) && $op_and_value[2] == true){
3275
+		if (is_array($op_and_value) && isset($op_and_value[2]) && $op_and_value[2] == true) {
3276 3276
 			return $operator.SP.$this->_deduce_column_name_from_query_param($value);
3277
-		}elseif(in_array($operator, $this->_in_style_operators) && is_array($value)){
3277
+		}elseif (in_array($operator, $this->_in_style_operators) && is_array($value)) {
3278 3278
 			//in this case, the value should be an array, or at least a comma-separated list
3279 3279
 			//it will need to handle a little differently
3280 3280
 			$cleaned_value = $this->_construct_in_value($value, $field_obj);
3281 3281
 			//note: $cleaned_value has already been run through $wpdb->prepare()
3282 3282
 			return $operator.SP.$cleaned_value;
3283
-		} elseif( in_array( $operator, $this->_between_style_operators ) && is_array( $value ) ) {
3283
+		} elseif (in_array($operator, $this->_between_style_operators) && is_array($value)) {
3284 3284
 			//the value should be an array with count of two.
3285
-			if ( count($value) !== 2 )
3286
-				throw new EE_Error( sprintf( __("The '%s' operator must be used with an array of values and there must be exactly TWO values in that array.", 'event_espresso'), "BETWEEN" ) );
3287
-			$cleaned_value = $this->_construct_between_value( $value, $field_obj );
3285
+			if (count($value) !== 2)
3286
+				throw new EE_Error(sprintf(__("The '%s' operator must be used with an array of values and there must be exactly TWO values in that array.", 'event_espresso'), "BETWEEN"));
3287
+			$cleaned_value = $this->_construct_between_value($value, $field_obj);
3288 3288
 			return $operator.SP.$cleaned_value;
3289
-		} elseif( in_array( $operator, $this->_null_style_operators ) ) {
3290
-			if($value != NULL){
3291
-				throw new EE_Error(sprintf(__("You attempted to give a value  (%s) while using a NULL-style operator (%s). That isn't valid", "event_espresso"),$value,$operator));
3289
+		} elseif (in_array($operator, $this->_null_style_operators)) {
3290
+			if ($value != NULL) {
3291
+				throw new EE_Error(sprintf(__("You attempted to give a value  (%s) while using a NULL-style operator (%s). That isn't valid", "event_espresso"), $value, $operator));
3292 3292
 			}
3293 3293
 			return $operator;
3294
-		}elseif( $operator == 'LIKE' && ! is_array($value)){
3294
+		}elseif ($operator == 'LIKE' && ! is_array($value)) {
3295 3295
 			//if the operator is 'LIKE', we want to allow percent signs (%) and not
3296 3296
 			//remove other junk. So just treat it as a string.
3297 3297
 			return $operator.SP.$this->_wpdb_prepare_using_field($value, '%s');
3298
-		}elseif( ! in_array($operator, $this->_in_style_operators) && ! is_array($value)){
3299
-			return $operator.SP.$this->_wpdb_prepare_using_field($value,$field_obj);
3300
-		}elseif(in_array($operator, $this->_in_style_operators) && ! is_array($value)){
3301
-			throw new EE_Error(sprintf(__("Operator '%s' must be used with an array of values, eg 'Registration.REG_ID' => array('%s',array(1,2,3))",'event_espresso'),$operator, $operator));
3302
-		}elseif( ! in_array($operator, $this->_in_style_operators) && is_array($value)){
3303
-			throw new EE_Error(sprintf(__("Operator '%s' must be used with a single value, not an array. Eg 'Registration.REG_ID => array('%s',23))",'event_espresso'),$operator,$operator));
3304
-		}else{
3305
-			throw new EE_Error(sprintf(__("It appears you've provided some totally invalid query parameters. Operator and value were:'%s', which isn't right at all", "event_espresso"),  http_build_query($op_and_value)));
3298
+		}elseif ( ! in_array($operator, $this->_in_style_operators) && ! is_array($value)) {
3299
+			return $operator.SP.$this->_wpdb_prepare_using_field($value, $field_obj);
3300
+		}elseif (in_array($operator, $this->_in_style_operators) && ! is_array($value)) {
3301
+			throw new EE_Error(sprintf(__("Operator '%s' must be used with an array of values, eg 'Registration.REG_ID' => array('%s',array(1,2,3))", 'event_espresso'), $operator, $operator));
3302
+		}elseif ( ! in_array($operator, $this->_in_style_operators) && is_array($value)) {
3303
+			throw new EE_Error(sprintf(__("Operator '%s' must be used with a single value, not an array. Eg 'Registration.REG_ID => array('%s',23))", 'event_espresso'), $operator, $operator));
3304
+		} else {
3305
+			throw new EE_Error(sprintf(__("It appears you've provided some totally invalid query parameters. Operator and value were:'%s', which isn't right at all", "event_espresso"), http_build_query($op_and_value)));
3306 3306
 		}
3307 3307
 	}
3308 3308
 
@@ -3314,12 +3314,12 @@  discard block
 block discarded – undo
3314 3314
 	 * @param EE_Model_Field_Base|string $field_obj if string, it should be the datatype to be used when querying, eg '%s'
3315 3315
 	 * @return string
3316 3316
 	 */
3317
-	function _construct_between_value( $values, $field_obj ) {
3317
+	function _construct_between_value($values, $field_obj) {
3318 3318
 		$cleaned_values = array();
3319
-		foreach ( $values as $value ) {
3320
-			$cleaned_values[] = $this->_wpdb_prepare_using_field($value,$field_obj);
3319
+		foreach ($values as $value) {
3320
+			$cleaned_values[] = $this->_wpdb_prepare_using_field($value, $field_obj);
3321 3321
 		}
3322
-		return  $cleaned_values[0] . " AND " . $cleaned_values[1];
3322
+		return  $cleaned_values[0]." AND ".$cleaned_values[1];
3323 3323
 	}
3324 3324
 
3325 3325
 
@@ -3335,26 +3335,26 @@  discard block
 block discarded – undo
3335 3335
 	 * @param EE_Model_Field_Base|string $field_obj if string, it should be a wpdb data type like '%s', or '%d'
3336 3336
 	 * @return string of SQL to follow an 'IN' or 'NOT IN' operator
3337 3337
 	 */
3338
-	function _construct_in_value($values,  $field_obj){
3338
+	function _construct_in_value($values, $field_obj) {
3339 3339
 		//check if the value is a CSV list
3340
-		if(is_string($values)){
3340
+		if (is_string($values)) {
3341 3341
 			//in which case, turn it into an array
3342
-			$values = explode(",",$values);
3342
+			$values = explode(",", $values);
3343 3343
 		}
3344 3344
 		$cleaned_values = array();
3345
-		foreach($values as $value){
3346
-			$cleaned_values[] = $this->_wpdb_prepare_using_field($value,$field_obj);
3345
+		foreach ($values as $value) {
3346
+			$cleaned_values[] = $this->_wpdb_prepare_using_field($value, $field_obj);
3347 3347
 		}
3348 3348
 		//we would just LOVE to leave $cleaned_values as an empty array, and return the value as "()",
3349 3349
 		//but unfortunately that's invalid SQL. So instead we return a string which we KNOW will evaluate to be the empty set
3350 3350
 		//which is effectively equivalent to returning "()". We don't return "(0)" because that only works for auto-incrementing columns
3351
-		if(empty($cleaned_values)){
3351
+		if (empty($cleaned_values)) {
3352 3352
 			$all_fields = $this->field_settings();
3353 3353
 			$a_field = array_shift($all_fields);
3354 3354
 			$main_table = $this->_get_main_table();
3355 3355
 			$cleaned_values[] = "SELECT ".$a_field->get_table_column()." FROM ".$main_table->get_table_name()." WHERE FALSE";
3356 3356
 		}
3357
-		return "(".implode(",",$cleaned_values).")";
3357
+		return "(".implode(",", $cleaned_values).")";
3358 3358
 	}
3359 3359
 
3360 3360
 
@@ -3366,16 +3366,16 @@  discard block
 block discarded – undo
3366 3366
 	 * @throws EE_Error
3367 3367
 	 * @return false|null|string
3368 3368
 	 */
3369
-	private function _wpdb_prepare_using_field($value,$field_obj){
3369
+	private function _wpdb_prepare_using_field($value, $field_obj) {
3370 3370
 		/** @type WPDB $wpdb */
3371 3371
 		global $wpdb;
3372
-		if($field_obj instanceof EE_Model_Field_Base){
3373
-			return $wpdb->prepare($field_obj->get_wpdb_data_type(),$this->_prepare_value_for_use_in_db($value, $field_obj));
3374
-		}else{//$field_obj should really just be a data type
3375
-			if( ! in_array($field_obj,$this->_valid_wpdb_data_types)){
3376
-				throw new EE_Error(sprintf(__("%s is not a valid wpdb datatype. Valid ones are %s", "event_espresso"),$field_obj,implode(",",$this->_valid_wpdb_data_types)));
3372
+		if ($field_obj instanceof EE_Model_Field_Base) {
3373
+			return $wpdb->prepare($field_obj->get_wpdb_data_type(), $this->_prepare_value_for_use_in_db($value, $field_obj));
3374
+		} else {//$field_obj should really just be a data type
3375
+			if ( ! in_array($field_obj, $this->_valid_wpdb_data_types)) {
3376
+				throw new EE_Error(sprintf(__("%s is not a valid wpdb datatype. Valid ones are %s", "event_espresso"), $field_obj, implode(",", $this->_valid_wpdb_data_types)));
3377 3377
 			}
3378
-			return $wpdb->prepare($field_obj,$value);
3378
+			return $wpdb->prepare($field_obj, $value);
3379 3379
 		}
3380 3380
 	}
3381 3381
 
@@ -3387,27 +3387,27 @@  discard block
 block discarded – undo
3387 3387
 	 * @throws EE_Error
3388 3388
 	 * @return EE_Model_Field_Base
3389 3389
 	 */
3390
-	protected function _deduce_field_from_query_param($query_param_name){
3390
+	protected function _deduce_field_from_query_param($query_param_name) {
3391 3391
 		//ok, now proceed with deducing which part is the model's name, and which is the field's name
3392 3392
 		//which will help us find the database table and column
3393 3393
 
3394
-		$query_param_parts = explode(".",$query_param_name);
3395
-		if(empty($query_param_parts)){
3396
-			throw new EE_Error(sprintf(__("_extract_column_name is empty when trying to extract column and table name from %s",'event_espresso'),$query_param_name));
3394
+		$query_param_parts = explode(".", $query_param_name);
3395
+		if (empty($query_param_parts)) {
3396
+			throw new EE_Error(sprintf(__("_extract_column_name is empty when trying to extract column and table name from %s", 'event_espresso'), $query_param_name));
3397 3397
 		}
3398 3398
 		$number_of_parts = count($query_param_parts);
3399
-		$last_query_param_part = $query_param_parts[ count($query_param_parts) - 1 ];
3400
-		if($number_of_parts == 1){
3399
+		$last_query_param_part = $query_param_parts[count($query_param_parts) - 1];
3400
+		if ($number_of_parts == 1) {
3401 3401
 			$field_name = $last_query_param_part;
3402 3402
 			$model_obj = $this;
3403
-		}else{// $number_of_parts >= 2
3403
+		} else {// $number_of_parts >= 2
3404 3404
 			//the last part is the column name, and there are only 2parts. therefore...
3405 3405
 			$field_name = $last_query_param_part;
3406
-			$model_obj = $this->get_related_model_obj( $query_param_parts[ $number_of_parts - 2 ]);
3406
+			$model_obj = $this->get_related_model_obj($query_param_parts[$number_of_parts - 2]);
3407 3407
 		}
3408
-		try{
3408
+		try {
3409 3409
 			return $model_obj->field_settings_for($field_name);
3410
-		}catch(EE_Error $e){
3410
+		} catch (EE_Error $e) {
3411 3411
 			return null;
3412 3412
 		}
3413 3413
 	}
@@ -3421,13 +3421,13 @@  discard block
 block discarded – undo
3421 3421
 	 * @throws EE_Error
3422 3422
 	 * @return string
3423 3423
 	 */
3424
-	function _get_qualified_column_for_field($field_name){
3424
+	function _get_qualified_column_for_field($field_name) {
3425 3425
 		$all_fields = $this->field_settings();
3426 3426
 		$field = isset($all_fields[$field_name]) ? $all_fields[$field_name] : FALSE;
3427
-		if($field){
3427
+		if ($field) {
3428 3428
 			return $field->get_qualified_column();
3429
-		}else{
3430
-			throw new EE_Error(sprintf(__("There is no field titled %s on model %s. Either the query trying to use it is bad, or you need to add it to the list of fields on the model.",'event_espresso'),$field_name,get_class($this)));
3429
+		} else {
3430
+			throw new EE_Error(sprintf(__("There is no field titled %s on model %s. Either the query trying to use it is bad, or you need to add it to the list of fields on the model.", 'event_espresso'), $field_name, get_class($this)));
3431 3431
 		}
3432 3432
 	}
3433 3433
 
@@ -3441,14 +3441,14 @@  discard block
 block discarded – undo
3441 3441
 	 * @param  mixed|string $limit The limit for this select
3442 3442
 	 * @return string 				The final select join element for the query.
3443 3443
 	 */
3444
-	function _construct_limit_join_select( $table_alias, $limit ) {
3444
+	function _construct_limit_join_select($table_alias, $limit) {
3445 3445
 		$SQL = '';
3446 3446
 
3447
-		foreach ( $this->_tables as $table_obj ) {
3448
-			if ( $table_obj instanceof EE_Primary_Table ) {
3449
-				$SQL .= $table_alias == $table_obj->get_table_alias() ? $table_obj->get_select_join_limit( $limit ) : SP.$table_obj->get_table_name()." AS ".$table_obj->get_table_alias().SP;
3450
-			} elseif ( $table_obj instanceof EE_Secondary_Table ) {
3451
-				$SQL .= $table_alias == $table_obj->get_table_alias() ? $table_obj->get_select_join_limit_join($limit) : SP . $table_obj->get_join_sql( $table_alias ).SP;
3447
+		foreach ($this->_tables as $table_obj) {
3448
+			if ($table_obj instanceof EE_Primary_Table) {
3449
+				$SQL .= $table_alias == $table_obj->get_table_alias() ? $table_obj->get_select_join_limit($limit) : SP.$table_obj->get_table_name()." AS ".$table_obj->get_table_alias().SP;
3450
+			} elseif ($table_obj instanceof EE_Secondary_Table) {
3451
+				$SQL .= $table_alias == $table_obj->get_table_alias() ? $table_obj->get_select_join_limit_join($limit) : SP.$table_obj->get_join_sql($table_alias).SP;
3452 3452
 			}
3453 3453
 		}
3454 3454
 		return $SQL;
@@ -3461,7 +3461,7 @@  discard block
 block discarded – undo
3461 3461
 	 * Eg "wp_post AS Event" or "wp_post AS Event INNER JOIN wp_postmeta Event_Meta ON Event.ID = Event_Meta.post_id"
3462 3462
 	 * @return string SQL
3463 3463
 	 */
3464
-	function _construct_internal_join(){
3464
+	function _construct_internal_join() {
3465 3465
 		$SQL = $this->_get_main_table()->get_table_sql();
3466 3466
 		$SQL .= $this->_construct_internal_join_to_table_with_alias($this->_get_main_table()->get_table_alias());
3467 3467
 		return $SQL;
@@ -3482,17 +3482,17 @@  discard block
 block discarded – undo
3482 3482
 	 * @param string $alias_prefixed table alias to join to (this table should already be in the FROM SQL clause)
3483 3483
 	 * @return string
3484 3484
 	 */
3485
-	function _construct_internal_join_to_table_with_alias($alias_prefixed){
3485
+	function _construct_internal_join_to_table_with_alias($alias_prefixed) {
3486 3486
 		$SQL = '';
3487 3487
 		$alias_sans_prefix = EE_Model_Parser::remove_table_alias_model_relation_chain_prefix($alias_prefixed);
3488
-		foreach($this->_tables as $table_obj){
3489
-			if($table_obj instanceof EE_Secondary_Table){//table is secondary table
3490
-				if($alias_sans_prefix == $table_obj->get_table_alias()){
3488
+		foreach ($this->_tables as $table_obj) {
3489
+			if ($table_obj instanceof EE_Secondary_Table) {//table is secondary table
3490
+				if ($alias_sans_prefix == $table_obj->get_table_alias()) {
3491 3491
 					//so we're joining to this table, meaning the table is already in
3492 3492
 					//the FROM statement, BUT the primary table isn't. So we want
3493 3493
 					//to add the inverse join sql
3494 3494
 					$SQL .= $table_obj->get_inverse_join_sql($alias_prefixed);
3495
-				}else{
3495
+				} else {
3496 3496
 					//just add a regular JOIN to this table from the primary table
3497 3497
 					$SQL .= $table_obj->get_join_sql($alias_prefixed);
3498 3498
 				}
@@ -3506,9 +3506,9 @@  discard block
 block discarded – undo
3506 3506
 	 * This should be a growing array of keys being table-columns (eg 'EVT_ID' and 'Event.EVT_ID'), and values being their data type (eg, '%s', '%d', etc)
3507 3507
 	 * @return array
3508 3508
 	 */
3509
-	function _get_data_types(){
3509
+	function _get_data_types() {
3510 3510
 		$data_types = array();
3511
-		foreach(array_values($this->field_settings()) as $field_obj){
3511
+		foreach (array_values($this->field_settings()) as $field_obj) {
3512 3512
 			//$data_types[$field_obj->get_table_column()] = $field_obj->get_wpdb_data_type();
3513 3513
 			/** @var $field_obj EE_Model_Field_Base */
3514 3514
 			$data_types[$field_obj->get_qualified_column()] = $field_obj->get_wpdb_data_type();
@@ -3524,11 +3524,11 @@  discard block
 block discarded – undo
3524 3524
 	 * @throws EE_Error
3525 3525
 	 * @return EEM_Base
3526 3526
 	 */
3527
-	function get_related_model_obj($model_name){
3527
+	function get_related_model_obj($model_name) {
3528 3528
 
3529 3529
 		$model_classname = "EEM_".$model_name;
3530
-		if(!class_exists($model_classname)){
3531
-			throw new EE_Error(sprintf(__("You specified a related model named %s in your query. No such model exists, if it did, it would have the classname %s",'event_espresso'),$model_name,$model_classname));
3530
+		if ( ! class_exists($model_classname)) {
3531
+			throw new EE_Error(sprintf(__("You specified a related model named %s in your query. No such model exists, if it did, it would have the classname %s", 'event_espresso'), $model_name, $model_classname));
3532 3532
 		}
3533 3533
 		$model_obj = call_user_func($model_classname."::instance");
3534 3534
 		return $model_obj;
@@ -3539,7 +3539,7 @@  discard block
 block discarded – undo
3539 3539
 	 * Returns the array of EE_ModelRelations for this model.
3540 3540
 	 * @return EE_Model_Relation_Base[]
3541 3541
 	 */
3542
-	public function relation_settings(){
3542
+	public function relation_settings() {
3543 3543
 		return $this->_model_relations;
3544 3544
 	}
3545 3545
 
@@ -3549,10 +3549,10 @@  discard block
 block discarded – undo
3549 3549
 	 * (Eg, without an event, datetimes have little purpose.)
3550 3550
 	 * @return EE_Belongs_To_Relation[]
3551 3551
 	 */
3552
-	public function belongs_to_relations(){
3552
+	public function belongs_to_relations() {
3553 3553
 		$belongs_to_relations = array();
3554
-		foreach($this->relation_settings() as $model_name => $relation_obj){
3555
-			if($relation_obj instanceof EE_Belongs_To_Relation){
3554
+		foreach ($this->relation_settings() as $model_name => $relation_obj) {
3555
+			if ($relation_obj instanceof EE_Belongs_To_Relation) {
3556 3556
 				$belongs_to_relations[$model_name] = $relation_obj;
3557 3557
 			}
3558 3558
 		}
@@ -3567,15 +3567,15 @@  discard block
 block discarded – undo
3567 3567
 	 * @throws EE_Error
3568 3568
 	 * @return EE_Model_Relation_Base
3569 3569
 	 */
3570
-	public function related_settings_for($relation_name){
3571
-		$relatedModels=$this->relation_settings();
3572
-		if(!array_key_exists($relation_name,$relatedModels)){
3570
+	public function related_settings_for($relation_name) {
3571
+		$relatedModels = $this->relation_settings();
3572
+		if ( ! array_key_exists($relation_name, $relatedModels)) {
3573 3573
 			throw new EE_Error(
3574 3574
 				sprintf(
3575
-					__('Cannot get %s related to %s. There is no model relation of that type. There is, however, %s...','event_espresso'),
3575
+					__('Cannot get %s related to %s. There is no model relation of that type. There is, however, %s...', 'event_espresso'),
3576 3576
 					$relation_name,
3577 3577
 					$this->_get_class_name(),
3578
-					implode( ', ', array_keys( $relatedModels ))
3578
+					implode(', ', array_keys($relatedModels))
3579 3579
 				)
3580 3580
 			);
3581 3581
 		}
@@ -3590,10 +3590,10 @@  discard block
 block discarded – undo
3590 3590
 	 * @throws EE_Error
3591 3591
 	 * @return EE_Model_Field_Base
3592 3592
 	 */
3593
-	public function field_settings_for($fieldName){
3594
-		$fieldSettings=$this->field_settings(true);
3595
-		if( ! array_key_exists($fieldName,$fieldSettings)){
3596
-			throw new EE_Error(sprintf(__("There is no field/column '%s' on '%s'",'event_espresso'),$fieldName,get_class($this)));
3593
+	public function field_settings_for($fieldName) {
3594
+		$fieldSettings = $this->field_settings(true);
3595
+		if ( ! array_key_exists($fieldName, $fieldSettings)) {
3596
+			throw new EE_Error(sprintf(__("There is no field/column '%s' on '%s'", 'event_espresso'), $fieldName, get_class($this)));
3597 3597
 		}
3598 3598
 		return $fieldSettings[$fieldName];
3599 3599
 	}
@@ -3603,11 +3603,11 @@  discard block
 block discarded – undo
3603 3603
 	 * @param string $fieldName a key in the model's _field_settings array
3604 3604
 	 * @return boolean
3605 3605
 	 */
3606
-	public function has_field($fieldName){
3606
+	public function has_field($fieldName) {
3607 3607
 		$fieldSettings = $this->field_settings(true);
3608
-		if( isset($fieldSettings[$fieldName])){
3608
+		if (isset($fieldSettings[$fieldName])) {
3609 3609
 			return true;
3610
-		}else{
3610
+		} else {
3611 3611
 			return false;
3612 3612
 		}
3613 3613
 	}
@@ -3617,11 +3617,11 @@  discard block
 block discarded – undo
3617 3617
 	 * @param string $relation_name possibly one of the keys in the relation_settings array
3618 3618
 	 * @return boolean
3619 3619
 	 */
3620
-	public function has_relation($relation_name){
3620
+	public function has_relation($relation_name) {
3621 3621
 		$relations = $this->relation_settings();
3622
-		if(isset($relations[$relation_name])){
3622
+		if (isset($relations[$relation_name])) {
3623 3623
 			return true;
3624
-		}else{
3624
+		} else {
3625 3625
 			return false;
3626 3626
 		}
3627 3627
 	}
@@ -3633,7 +3633,7 @@  discard block
 block discarded – undo
3633 3633
 	 * @param $field_obj
3634 3634
 	 * @return EE_Model_Field_Base
3635 3635
 	 */
3636
-	public function is_primary_key_field( $field_obj ){
3636
+	public function is_primary_key_field($field_obj) {
3637 3637
 		return $field_obj instanceof EE_Primary_Key_Field_Base ? TRUE : FALSE;
3638 3638
 	}
3639 3639
 
@@ -3645,16 +3645,16 @@  discard block
 block discarded – undo
3645 3645
 	 * @return EE_Model_Field_Base
3646 3646
 	 * @throws EE_Error
3647 3647
 	 */
3648
-	public function get_primary_key_field(){
3649
-		if( $this->_primary_key_field === NULL ){
3650
-			foreach( $this->field_settings( TRUE ) as $field_obj ){
3651
-				if( $this->is_primary_key_field( $field_obj )){
3648
+	public function get_primary_key_field() {
3649
+		if ($this->_primary_key_field === NULL) {
3650
+			foreach ($this->field_settings(TRUE) as $field_obj) {
3651
+				if ($this->is_primary_key_field($field_obj)) {
3652 3652
 					$this->_primary_key_field = $field_obj;
3653 3653
 					break;
3654 3654
 				}
3655 3655
 			}
3656
-			if( ! $this->_primary_key_field instanceof EE_Primary_Key_Field_Base ){
3657
-				throw new EE_Error(sprintf(__("There is no Primary Key defined on model %s",'event_espresso'),get_class($this)));
3656
+			if ( ! $this->_primary_key_field instanceof EE_Primary_Key_Field_Base) {
3657
+				throw new EE_Error(sprintf(__("There is no Primary Key defined on model %s", 'event_espresso'), get_class($this)));
3658 3658
 			}
3659 3659
 		}
3660 3660
 		return $this->_primary_key_field;
@@ -3667,12 +3667,12 @@  discard block
 block discarded – undo
3667 3667
 	 * Internally does some caching.
3668 3668
 	 * @return boolean
3669 3669
 	 */
3670
-	public function has_primary_key_field(){
3671
-		if($this->_has_primary_key_field === null){
3672
-			try{
3670
+	public function has_primary_key_field() {
3671
+		if ($this->_has_primary_key_field === null) {
3672
+			try {
3673 3673
 				$this->get_primary_key_field();
3674 3674
 				$this->_has_primary_key_field = true;
3675
-			}catch(EE_Error $e){
3675
+			} catch (EE_Error $e) {
3676 3676
 				$this->_has_primary_key_field = false;
3677 3677
 			}
3678 3678
 		}
@@ -3686,9 +3686,9 @@  discard block
 block discarded – undo
3686 3686
 	 * @param string $field_class_name class name of field that you want to find. Eg, EE_Datetime_Field, EE_Foreign_Key_Field, etc
3687 3687
 	 * @return EE_Model_Field_Base or null if none is found
3688 3688
 	 */
3689
-	public function get_a_field_of_type($field_class_name){
3690
-		foreach($this->field_settings() as $field){
3691
-			if( $field instanceof $field_class_name ){
3689
+	public function get_a_field_of_type($field_class_name) {
3690
+		foreach ($this->field_settings() as $field) {
3691
+			if ($field instanceof $field_class_name) {
3692 3692
 				return $field;
3693 3693
 			}
3694 3694
 		}
@@ -3702,21 +3702,21 @@  discard block
 block discarded – undo
3702 3702
 	 * @return EE_Foreign_Key_Field_Base
3703 3703
 	 * @throws EE_Error
3704 3704
 	 */
3705
-	public function get_foreign_key_to($model_name){
3706
-		if( ! isset( $this->_cache_foreign_key_to_fields[ $model_name ] ) ){
3707
-			foreach($this->field_settings() as $field){
3705
+	public function get_foreign_key_to($model_name) {
3706
+		if ( ! isset($this->_cache_foreign_key_to_fields[$model_name])) {
3707
+			foreach ($this->field_settings() as $field) {
3708 3708
 //				if(is_subclass_of($field, 'EE_Foreign_Key_Field_Base')){
3709
-				if( $field instanceof EE_Foreign_Key_Field_Base ){
3710
-					if (in_array($model_name,$field->get_model_names_pointed_to() ) ) {
3711
-						$this->_cache_foreign_key_to_fields[ $model_name ] = $field;
3709
+				if ($field instanceof EE_Foreign_Key_Field_Base) {
3710
+					if (in_array($model_name, $field->get_model_names_pointed_to())) {
3711
+						$this->_cache_foreign_key_to_fields[$model_name] = $field;
3712 3712
 					}
3713 3713
 				}
3714 3714
 			}
3715
-			if( ! isset( $this->_cache_foreign_key_to_fields[ $model_name ] ) ){
3716
-				throw new EE_Error(sprintf(__("There is no foreign key field pointing to model %s on model %s",'event_espresso'),$model_name,get_class($this)));
3715
+			if ( ! isset($this->_cache_foreign_key_to_fields[$model_name])) {
3716
+				throw new EE_Error(sprintf(__("There is no foreign key field pointing to model %s on model %s", 'event_espresso'), $model_name, get_class($this)));
3717 3717
 			}
3718 3718
 		}
3719
-		return $this->_cache_foreign_key_to_fields[ $model_name ];
3719
+		return $this->_cache_foreign_key_to_fields[$model_name];
3720 3720
 	}
3721 3721
 
3722 3722
 
@@ -3727,7 +3727,7 @@  discard block
 block discarded – undo
3727 3727
 	 * a table alias with a model chain prefix, like 'Venue__Event_Venue___Event_Meta'. Either one works
3728 3728
 	 * @return EE_Table_Base
3729 3729
 	 */
3730
-	function get_table_for_alias($table_alias){
3730
+	function get_table_for_alias($table_alias) {
3731 3731
 		$table_alias_sans_model_relation_chain_prefix = EE_Model_Parser::remove_table_alias_model_relation_chain_prefix($table_alias);
3732 3732
 		return $this->_tables[$table_alias_sans_model_relation_chain_prefix]->get_table_name();
3733 3733
 	}
@@ -3740,25 +3740,25 @@  discard block
 block discarded – undo
3740 3740
 	 * @param bool $include_db_only_fields flag indicating whether or not to include the db-only fields
3741 3741
 	 * @return EE_Model_Field_Base[] where the keys are the field's name
3742 3742
 	 */
3743
-	public function field_settings($include_db_only_fields = false){
3744
-		if( $include_db_only_fields ){
3745
-			if( $this->_cached_fields === NULL ){
3743
+	public function field_settings($include_db_only_fields = false) {
3744
+		if ($include_db_only_fields) {
3745
+			if ($this->_cached_fields === NULL) {
3746 3746
 				$this->_cached_fields = array();
3747
-				foreach($this->_fields as $fields_corresponding_to_table){
3748
-					foreach($fields_corresponding_to_table as $field_name => $field_obj){
3749
-						$this->_cached_fields[$field_name]=$field_obj;
3747
+				foreach ($this->_fields as $fields_corresponding_to_table) {
3748
+					foreach ($fields_corresponding_to_table as $field_name => $field_obj) {
3749
+						$this->_cached_fields[$field_name] = $field_obj;
3750 3750
 					}
3751 3751
 				}
3752 3752
 			}
3753 3753
 			return $this->_cached_fields;
3754
-		}else{
3755
-			if( $this->_cached_fields_non_db_only === NULL ){
3754
+		} else {
3755
+			if ($this->_cached_fields_non_db_only === NULL) {
3756 3756
 				$this->_cached_fields_non_db_only = array();
3757
-				foreach($this->_fields as $fields_corresponding_to_table){
3758
-					foreach($fields_corresponding_to_table as $field_name => $field_obj){
3757
+				foreach ($this->_fields as $fields_corresponding_to_table) {
3758
+					foreach ($fields_corresponding_to_table as $field_name => $field_obj) {
3759 3759
 						/** @var $field_obj EE_Model_Field_Base */
3760
-						if( ! $field_obj->is_db_only_field() ){
3761
-							$this->_cached_fields_non_db_only[$field_name]=$field_obj;
3760
+						if ( ! $field_obj->is_db_only_field()) {
3761
+							$this->_cached_fields_non_db_only[$field_name] = $field_obj;
3762 3762
 						}
3763 3763
 					}
3764 3764
 				}
@@ -3777,67 +3777,67 @@  discard block
 block discarded – undo
3777 3777
 	 * @return \EE_Base_Class[] array keys are primary keys (if there is a primary key on the model. if not, numerically indexed)
3778 3778
 	 * @throws \EE_Error
3779 3779
 	 */
3780
-	protected function _create_objects( $rows = array() ) {
3781
-		$array_of_objects=array();
3782
-		if(empty($rows)){
3780
+	protected function _create_objects($rows = array()) {
3781
+		$array_of_objects = array();
3782
+		if (empty($rows)) {
3783 3783
 			return array();
3784 3784
 		}
3785 3785
 		$count_if_model_has_no_primary_key = 0;
3786 3786
 		$has_primary_key = $this->has_primary_key_field();
3787
-		if( $has_primary_key ) {
3787
+		if ($has_primary_key) {
3788 3788
 			$primary_key_field = $this->get_primary_key_field();
3789 3789
 		} else {
3790 3790
 			$primary_key_field = null;
3791 3791
 		}
3792
-		foreach ( $rows as $row ) {
3793
-			if(empty($row)){
3792
+		foreach ($rows as $row) {
3793
+			if (empty($row)) {
3794 3794
 				//wp did its weird thing where it returns an array like array(0=>null), which is totally not helpful...
3795 3795
 				return array();
3796 3796
 			}
3797 3797
 			//check if we've already set this object in the results array,
3798 3798
 			//in which case there's no need to process it further (again)
3799
-			if( $has_primary_key ) {
3799
+			if ($has_primary_key) {
3800 3800
 				$table_pk_value = $this->_get_column_value_with_table_alias_or_not(
3801 3801
 					$row,
3802 3802
 					$primary_key_field->get_qualified_column(),
3803 3803
 					$primary_key_field->get_table_column()
3804 3804
 				);
3805
-				if( $table_pk_value &&
3806
-					isset( $array_of_objects[ $table_pk_value ] ) ) {
3805
+				if ($table_pk_value &&
3806
+					isset($array_of_objects[$table_pk_value])) {
3807 3807
 					continue;
3808 3808
 				}
3809 3809
 			}
3810
-			$classInstance=$this->instantiate_class_from_array_or_object($row);
3811
-			if( ! $classInstance ) {
3810
+			$classInstance = $this->instantiate_class_from_array_or_object($row);
3811
+			if ( ! $classInstance) {
3812 3812
 				throw new EE_Error(
3813 3813
 					sprintf(
3814
-						__( 'Could not create instance of class %s from row %s', 'event_espresso' ),
3814
+						__('Could not create instance of class %s from row %s', 'event_espresso'),
3815 3815
 						$this->get_this_model_name(),
3816
-						http_build_query( $row )
3816
+						http_build_query($row)
3817 3817
 					)
3818 3818
 				);
3819 3819
 			}
3820 3820
 			//set the timezone on the instantiated objects
3821
-			$classInstance->set_timezone( $this->_timezone );
3821
+			$classInstance->set_timezone($this->_timezone);
3822 3822
 			//make sure if there is any timezone setting present that we set the timezone for the object
3823 3823
 			$key = $has_primary_key ? $classInstance->ID() : $count_if_model_has_no_primary_key++;
3824
-			$array_of_objects[ $key ] = $classInstance;
3824
+			$array_of_objects[$key] = $classInstance;
3825 3825
 			//also, for all the relations of type BelongsTo, see if we can cache
3826 3826
 			//those related models
3827 3827
 			//(we could do this for other relations too, but if there are conditions
3828 3828
 			//that filtered out some fo the results, then we'd be caching an incomplete set
3829 3829
 			//so it requires a little more thought than just caching them immediately...)
3830
-			foreach($this->_model_relations as $modelName => $relation_obj){
3831
-				if( $relation_obj instanceof EE_Belongs_To_Relation){
3830
+			foreach ($this->_model_relations as $modelName => $relation_obj) {
3831
+				if ($relation_obj instanceof EE_Belongs_To_Relation) {
3832 3832
 					//check if this model's INFO is present. If so, cache it on the model
3833 3833
 					$other_model = $relation_obj->get_other_model();
3834 3834
 
3835 3835
 					$other_model_obj_maybe = $other_model->instantiate_class_from_array_or_object($row);
3836 3836
 
3837 3837
 					//if we managed to make a model object from the results, cache it on the main model object
3838
-					if( $other_model_obj_maybe ){
3838
+					if ($other_model_obj_maybe) {
3839 3839
 						//set timezone on these other model objects if they are present
3840
-						$other_model_obj_maybe->set_timezone( $this->_timezone );
3840
+						$other_model_obj_maybe->set_timezone($this->_timezone);
3841 3841
 						$classInstance->cache($modelName, $other_model_obj_maybe);
3842 3842
 					}
3843 3843
 				}
@@ -3858,12 +3858,12 @@  discard block
 block discarded – undo
3858 3858
 
3859 3859
 		$this_model_fields_and_values = array();
3860 3860
 		//setup the row using default values;
3861
-		foreach ( $this->field_settings() as $field_name => $field_obj ) {
3861
+		foreach ($this->field_settings() as $field_name => $field_obj) {
3862 3862
 			$this_model_fields_and_values[$field_name] = $field_obj->get_default_value();
3863 3863
 		}
3864 3864
 
3865 3865
 		$className = $this->_get_class_name();
3866
-		$classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_and_values ), FALSE, FALSE );
3866
+		$classInstance = EE_Registry::instance()->load_class($className, array($this_model_fields_and_values), FALSE, FALSE);
3867 3867
 
3868 3868
 		return $classInstance;
3869 3869
 	}
@@ -3876,45 +3876,45 @@  discard block
 block discarded – undo
3876 3876
 	 * or an stdClass where each property is the name of a column,
3877 3877
 	 * @return EE_Base_Class
3878 3878
 	 */
3879
-	public function instantiate_class_from_array_or_object($cols_n_values){
3880
-		if( ! is_array( $cols_n_values ) && is_object( $cols_n_values )) {
3881
-			$cols_n_values = get_object_vars( $cols_n_values );
3879
+	public function instantiate_class_from_array_or_object($cols_n_values) {
3880
+		if ( ! is_array($cols_n_values) && is_object($cols_n_values)) {
3881
+			$cols_n_values = get_object_vars($cols_n_values);
3882 3882
 		}
3883 3883
 		$primary_key = NULL;
3884 3884
 		//make sure the array only has keys that are fields/columns on this model
3885
-		$this_model_fields_n_values = $this->_deduce_fields_n_values_from_cols_n_values( $cols_n_values );
3886
-		if( $this->has_primary_key_field() && isset( $this_model_fields_n_values[ $this->primary_key_name() ] ) ){
3887
-			$primary_key = $this_model_fields_n_values[ $this->primary_key_name() ];
3885
+		$this_model_fields_n_values = $this->_deduce_fields_n_values_from_cols_n_values($cols_n_values);
3886
+		if ($this->has_primary_key_field() && isset($this_model_fields_n_values[$this->primary_key_name()])) {
3887
+			$primary_key = $this_model_fields_n_values[$this->primary_key_name()];
3888 3888
 		}
3889
-		$className=$this->_get_class_name();
3889
+		$className = $this->_get_class_name();
3890 3890
 
3891 3891
 		//check we actually found results that we can use to build our model object
3892 3892
 		//if not, return null
3893
-		if( $this->has_primary_key_field()){
3894
-			if(empty( $this_model_fields_n_values[$this->primary_key_name()] )){
3893
+		if ($this->has_primary_key_field()) {
3894
+			if (empty($this_model_fields_n_values[$this->primary_key_name()])) {
3895 3895
 				return NULL;
3896 3896
 			}
3897
-		}else if($this->unique_indexes()){
3897
+		} else if ($this->unique_indexes()) {
3898 3898
 			$first_column = reset($this_model_fields_n_values);
3899
-			if(empty($first_column)){
3899
+			if (empty($first_column)) {
3900 3900
 				return NULL;
3901 3901
 			}
3902 3902
 		}
3903 3903
 
3904 3904
 		// if there is no primary key or the object doesn't already exist in the entity map, then create a new instance
3905
-		if ( $primary_key){
3906
-			$classInstance = $this->get_from_entity_map( $primary_key );
3907
-			if( ! $classInstance) {
3908
-				$classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_n_values, $this->_timezone ), TRUE, FALSE );
3905
+		if ($primary_key) {
3906
+			$classInstance = $this->get_from_entity_map($primary_key);
3907
+			if ( ! $classInstance) {
3908
+				$classInstance = EE_Registry::instance()->load_class($className, array($this_model_fields_n_values, $this->_timezone), TRUE, FALSE);
3909 3909
 				// add this new object to the entity map
3910
-				$classInstance = $this->add_to_entity_map( $classInstance );
3910
+				$classInstance = $this->add_to_entity_map($classInstance);
3911 3911
 			}
3912
-		}else{
3913
-			$classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_n_values, $this->_timezone ), TRUE, FALSE );
3912
+		} else {
3913
+			$classInstance = EE_Registry::instance()->load_class($className, array($this_model_fields_n_values, $this->_timezone), TRUE, FALSE);
3914 3914
 		}
3915 3915
 
3916 3916
 			//it is entirely possible that the instantiated class object has a set timezone_string db field and has set it's internal _timezone property accordingly (see new_instance_from_db in model objects particularly EE_Event for example).  In this case, we want to make sure the model object doesn't have its timezone string overwritten by any timezone property currently set here on the model so, we intentionally override the model _timezone property with the model_object timezone property.
3917
-		$this->set_timezone( $classInstance->get_timezone() );
3917
+		$this->set_timezone($classInstance->get_timezone());
3918 3918
 		return $classInstance;
3919 3919
 	}
3920 3920
 	/**
@@ -3922,8 +3922,8 @@  discard block
 block discarded – undo
3922 3922
 	 * @param int|string $id the ID of the model object
3923 3923
 	 * @return EE_Base_Class
3924 3924
 	 */
3925
-	public function get_from_entity_map( $id ){
3926
-		return isset( $this->_entity_map[ $id ] ) ? $this->_entity_map[ $id ] : NULL;
3925
+	public function get_from_entity_map($id) {
3926
+		return isset($this->_entity_map[$id]) ? $this->_entity_map[$id] : NULL;
3927 3927
 	}
3928 3928
 
3929 3929
 
@@ -3942,21 +3942,21 @@  discard block
 block discarded – undo
3942 3942
 	 * @throws EE_Error
3943 3943
 	 * @return \EE_Base_Class
3944 3944
 	 */
3945
-	public function add_to_entity_map( EE_Base_Class $object) {
3945
+	public function add_to_entity_map(EE_Base_Class $object) {
3946 3946
 		$className = $this->_get_class_name();
3947
-		if( ! $object instanceof $className ){
3948
-			throw new EE_Error(sprintf(__("You tried adding a %s to a mapping of %ss", "event_espresso"),is_object( $object ) ? get_class( $object ) : $object, $className ) );
3947
+		if ( ! $object instanceof $className) {
3948
+			throw new EE_Error(sprintf(__("You tried adding a %s to a mapping of %ss", "event_espresso"), is_object($object) ? get_class($object) : $object, $className));
3949 3949
 		}
3950 3950
 		/** @var $object EE_Base_Class */
3951
-		if ( ! $object->ID() ){
3952
-			throw new EE_Error(sprintf(__("You tried storing a model object with NO ID in the %s entity mapper.", "event_espresso"),get_class($this)));
3951
+		if ( ! $object->ID()) {
3952
+			throw new EE_Error(sprintf(__("You tried storing a model object with NO ID in the %s entity mapper.", "event_espresso"), get_class($this)));
3953 3953
 		}
3954 3954
 		// double check it's not already there
3955
-		$classInstance = $this->get_from_entity_map( $object->ID() );
3956
-		if ( $classInstance ) {
3955
+		$classInstance = $this->get_from_entity_map($object->ID());
3956
+		if ($classInstance) {
3957 3957
 			return $classInstance;
3958 3958
 		} else {
3959
-			$this->_entity_map[ $object->ID() ] = $object;
3959
+			$this->_entity_map[$object->ID()] = $object;
3960 3960
 			return $object;
3961 3961
 		}
3962 3962
 	}
@@ -3969,8 +3969,8 @@  discard block
 block discarded – undo
3969 3969
 	 * @param array $cols_n_values
3970 3970
 	 * @return array
3971 3971
 	 */
3972
-	public function deduce_fields_n_values_from_cols_n_values( $cols_n_values ) {
3973
-		return $this->_deduce_fields_n_values_from_cols_n_values( $cols_n_values );
3972
+	public function deduce_fields_n_values_from_cols_n_values($cols_n_values) {
3973
+		return $this->_deduce_fields_n_values_from_cols_n_values($cols_n_values);
3974 3974
 	}
3975 3975
 
3976 3976
 
@@ -3983,40 +3983,40 @@  discard block
 block discarded – undo
3983 3983
 	 * @param string $cols_n_values
3984 3984
 	 * @return array
3985 3985
 	 */
3986
-	protected function _deduce_fields_n_values_from_cols_n_values( $cols_n_values ){
3986
+	protected function _deduce_fields_n_values_from_cols_n_values($cols_n_values) {
3987 3987
 		$this_model_fields_n_values = array();
3988
-		foreach( $this->get_tables() as $table_alias => $table_obj ) {
3989
-			$table_pk_value = $this->_get_column_value_with_table_alias_or_not($cols_n_values, $table_obj->get_fully_qualified_pk_column(), $table_obj->get_pk_column() );
3988
+		foreach ($this->get_tables() as $table_alias => $table_obj) {
3989
+			$table_pk_value = $this->_get_column_value_with_table_alias_or_not($cols_n_values, $table_obj->get_fully_qualified_pk_column(), $table_obj->get_pk_column());
3990 3990
 			//there is a primary key on this table and its not set. Use defaults for all its columns
3991
-			if( $table_obj->get_pk_column() && $table_pk_value === NULL ){
3992
-				foreach( $this->_get_fields_for_table( $table_alias ) as $field_name => $field_obj ) {
3993
-					if( ! $field_obj->is_db_only_field() ){
3991
+			if ($table_obj->get_pk_column() && $table_pk_value === NULL) {
3992
+				foreach ($this->_get_fields_for_table($table_alias) as $field_name => $field_obj) {
3993
+					if ( ! $field_obj->is_db_only_field()) {
3994 3994
 						//prepare field as if its coming from db
3995
-						$prepared_value = $field_obj->prepare_for_set( $field_obj->get_default_value() );
3996
-						$this_model_fields_n_values[$field_name] = $field_obj->prepare_for_use_in_db( $prepared_value );
3995
+						$prepared_value = $field_obj->prepare_for_set($field_obj->get_default_value());
3996
+						$this_model_fields_n_values[$field_name] = $field_obj->prepare_for_use_in_db($prepared_value);
3997 3997
 					}
3998 3998
 				}
3999
-			}else{
3999
+			} else {
4000 4000
 				//the table's rows existed. Use their values
4001
-				foreach( $this->_get_fields_for_table( $table_alias ) as $field_name => $field_obj ) {
4002
-					if( ! $field_obj->is_db_only_field() )
4003
-					$this_model_fields_n_values[$field_name] = $this->_get_column_value_with_table_alias_or_not($cols_n_values, $field_obj->get_qualified_column(), $field_obj->get_table_column() );
4001
+				foreach ($this->_get_fields_for_table($table_alias) as $field_name => $field_obj) {
4002
+					if ( ! $field_obj->is_db_only_field())
4003
+					$this_model_fields_n_values[$field_name] = $this->_get_column_value_with_table_alias_or_not($cols_n_values, $field_obj->get_qualified_column(), $field_obj->get_table_column());
4004 4004
 				}
4005 4005
 			}
4006 4006
 		}
4007 4007
 		return $this_model_fields_n_values;
4008 4008
 	}
4009 4009
 
4010
-	protected function _get_column_value_with_table_alias_or_not( $cols_n_values, $qualified_column, $regular_column ){
4010
+	protected function _get_column_value_with_table_alias_or_not($cols_n_values, $qualified_column, $regular_column) {
4011 4011
 		//ask the field what it think it's table_name.column_name should be, and call it the "qualified column"
4012 4012
 		//does the field on the model relate to this column retrieved from the db?
4013 4013
 		//or is it a db-only field? (not relating to the model)
4014
-		if( isset( $cols_n_values[ $qualified_column ] ) ){
4015
-			$value = $cols_n_values[ $qualified_column ];
4014
+		if (isset($cols_n_values[$qualified_column])) {
4015
+			$value = $cols_n_values[$qualified_column];
4016 4016
 
4017
-		}elseif( isset( $cols_n_values[ $regular_column ] ) ){
4018
-			$value = $cols_n_values[ $regular_column ];
4019
-		}else{
4017
+		}elseif (isset($cols_n_values[$regular_column])) {
4018
+			$value = $cols_n_values[$regular_column];
4019
+		} else {
4020 4020
 			$value = NULL;
4021 4021
 		}
4022 4022
 
@@ -4034,23 +4034,23 @@  discard block
 block discarded – undo
4034 4034
 	 * @param int|string $id
4035 4035
 	 * @return EE_Base_Class
4036 4036
 	 */
4037
-	public function refresh_entity_map_from_db( $id ){
4038
-		$obj_in_map = $this->get_from_entity_map( $id );
4039
-		if( $obj_in_map ){
4040
-			$wpdb_results = $this->_get_all_wpdb_results( array( array ( $this->get_primary_key_field()->get_name() => $id ), 'limit' => 1 ) );
4041
-			if( $wpdb_results && is_array( $wpdb_results ) ){
4042
-				$one_row = reset( $wpdb_results );
4043
-				foreach( $this->_deduce_fields_n_values_from_cols_n_values($one_row ) as $field_name => $db_value ) {
4044
-					$obj_in_map->set_from_db( $field_name, $db_value );
4037
+	public function refresh_entity_map_from_db($id) {
4038
+		$obj_in_map = $this->get_from_entity_map($id);
4039
+		if ($obj_in_map) {
4040
+			$wpdb_results = $this->_get_all_wpdb_results(array(array($this->get_primary_key_field()->get_name() => $id), 'limit' => 1));
4041
+			if ($wpdb_results && is_array($wpdb_results)) {
4042
+				$one_row = reset($wpdb_results);
4043
+				foreach ($this->_deduce_fields_n_values_from_cols_n_values($one_row) as $field_name => $db_value) {
4044
+					$obj_in_map->set_from_db($field_name, $db_value);
4045 4045
 				}
4046 4046
 				//clear the cache of related model objects
4047
-				foreach ( $this->relation_settings() as $relation_name => $relation_obj ){
4048
-					$obj_in_map->clear_cache($relation_name, NULL, TRUE );
4047
+				foreach ($this->relation_settings() as $relation_name => $relation_obj) {
4048
+					$obj_in_map->clear_cache($relation_name, NULL, TRUE);
4049 4049
 				}
4050 4050
 			}
4051 4051
 			return $obj_in_map;
4052
-		}else{
4053
-			return $this->get_one_by_ID( $id );
4052
+		} else {
4053
+			return $this->get_one_by_ID($id);
4054 4054
 		}
4055 4055
 	}
4056 4056
 
@@ -4068,24 +4068,24 @@  discard block
 block discarded – undo
4068 4068
 	 * @param EE_Base_Class $replacing_model_obj
4069 4069
 	 * @return \EE_Base_Class
4070 4070
 	 */
4071
-	public function refresh_entity_map_with( $id, $replacing_model_obj ) {
4072
-		$obj_in_map = $this->get_from_entity_map( $id );
4073
-		if( $obj_in_map ){
4074
-			if( $replacing_model_obj instanceof EE_Base_Class ){
4075
-				foreach( $replacing_model_obj->model_field_array() as $field_name => $value ) {
4076
-					$obj_in_map->set( $field_name, $value );
4071
+	public function refresh_entity_map_with($id, $replacing_model_obj) {
4072
+		$obj_in_map = $this->get_from_entity_map($id);
4073
+		if ($obj_in_map) {
4074
+			if ($replacing_model_obj instanceof EE_Base_Class) {
4075
+				foreach ($replacing_model_obj->model_field_array() as $field_name => $value) {
4076
+					$obj_in_map->set($field_name, $value);
4077 4077
 				}
4078 4078
 				//make the model object in the entity map's cache match the $replacing_model_obj
4079
-				foreach ( $this->relation_settings() as $relation_name => $relation_obj ){
4080
-					$obj_in_map->clear_cache($relation_name, NULL, TRUE );
4081
-					foreach( $replacing_model_obj->get_all_from_cache( $relation_name ) as $cache_id => $cached_obj ) {
4082
-						$obj_in_map->cache( $relation_name, $cached_obj, $cache_id );
4079
+				foreach ($this->relation_settings() as $relation_name => $relation_obj) {
4080
+					$obj_in_map->clear_cache($relation_name, NULL, TRUE);
4081
+					foreach ($replacing_model_obj->get_all_from_cache($relation_name) as $cache_id => $cached_obj) {
4082
+						$obj_in_map->cache($relation_name, $cached_obj, $cache_id);
4083 4083
 					}
4084 4084
 				}
4085 4085
 			}
4086 4086
 			return $obj_in_map;
4087
-		}else{
4088
-			$this->add_to_entity_map( $replacing_model_obj );
4087
+		} else {
4088
+			$this->add_to_entity_map($replacing_model_obj);
4089 4089
 			return $replacing_model_obj;
4090 4090
 		}
4091 4091
 	}
@@ -4098,7 +4098,7 @@  discard block
 block discarded – undo
4098 4098
 	 * require_once($this->_getClassName().".class.php");
4099 4099
 	 * @return string
4100 4100
 	 */
4101
-	private function _get_class_name(){
4101
+	private function _get_class_name() {
4102 4102
 		return "EE_".$this->get_this_model_name();
4103 4103
 	}
4104 4104
 
@@ -4111,10 +4111,10 @@  discard block
 block discarded – undo
4111 4111
 	 * @param int $quantity
4112 4112
 	 * @return string
4113 4113
 	 */
4114
-	public function item_name($quantity = 1){
4115
-		if($quantity == 1){
4114
+	public function item_name($quantity = 1) {
4115
+		if ($quantity == 1) {
4116 4116
 			return $this->singular_item;
4117
-		}else{
4117
+		} else {
4118 4118
 			return $this->plural_item;
4119 4119
 		}
4120 4120
 	}
@@ -4143,13 +4143,13 @@  discard block
 block discarded – undo
4143 4143
 	 * @throws EE_Error
4144 4144
 	 * @return mixed whatever the plugin which calls add_filter decides
4145 4145
 	 */
4146
-	public function __call($methodName,$args){
4147
-		$className=get_class($this);
4148
-		$tagName="FHEE__{$className}__{$methodName}";
4149
-		if(!has_filter($tagName)){
4146
+	public function __call($methodName, $args) {
4147
+		$className = get_class($this);
4148
+		$tagName = "FHEE__{$className}__{$methodName}";
4149
+		if ( ! has_filter($tagName)) {
4150 4150
 			throw new EE_Error(
4151 4151
 				sprintf(
4152
-					__( 'Method %1$s on model %2$s does not exist! You can create one with the following code in functions.php or in a plugin: %4$s function my_callback(%4$s \$previousReturnValue, EEM_Base \$object\ $argsArray=NULL ){%4$s     /*function body*/%4$s      return \$whatever;%4$s }%4$s add_filter( \'%3$s\', \'my_callback\', 10, 3 );', 'event_espresso' ),
4152
+					__('Method %1$s on model %2$s does not exist! You can create one with the following code in functions.php or in a plugin: %4$s function my_callback(%4$s \$previousReturnValue, EEM_Base \$object\ $argsArray=NULL ){%4$s     /*function body*/%4$s      return \$whatever;%4$s }%4$s add_filter( \'%3$s\', \'my_callback\', 10, 3 );', 'event_espresso'),
4153 4153
 					$methodName,
4154 4154
 					$className,
4155 4155
 					$tagName,
@@ -4158,7 +4158,7 @@  discard block
 block discarded – undo
4158 4158
 			);
4159 4159
 		}
4160 4160
 
4161
-		return apply_filters($tagName,null,$this,$args);
4161
+		return apply_filters($tagName, null, $this, $args);
4162 4162
 	}
4163 4163
 
4164 4164
 
@@ -4171,22 +4171,22 @@  discard block
 block discarded – undo
4171 4171
 	 * @throws EE_Error
4172 4172
 	 * @return EE_Base_Class
4173 4173
 	 */
4174
-	public function ensure_is_obj( $base_class_obj_or_id, $ensure_is_in_db = FALSE ){
4174
+	public function ensure_is_obj($base_class_obj_or_id, $ensure_is_in_db = FALSE) {
4175 4175
 		$className = $this->_get_class_name();
4176 4176
 		$primary_key_field = $this->get_primary_key_field();
4177
-		if( $base_class_obj_or_id instanceof $className ){
4177
+		if ($base_class_obj_or_id instanceof $className) {
4178 4178
 			$model_object = $base_class_obj_or_id;
4179
-		}elseif( $primary_key_field instanceof EE_Primary_Key_Int_Field && (
4180
-				is_int( $base_class_obj_or_id ) ||
4181
-				is_string( $base_class_obj_or_id ) )){//assume it's an ID. either a proper integer or a string representing an integer (eg "101" instead of 101)
4179
+		}elseif ($primary_key_field instanceof EE_Primary_Key_Int_Field && (
4180
+				is_int($base_class_obj_or_id) ||
4181
+				is_string($base_class_obj_or_id) )) {//assume it's an ID. either a proper integer or a string representing an integer (eg "101" instead of 101)
4182 4182
 			$model_object = $this->get_one_by_ID($base_class_obj_or_id);
4183
-		}elseif( $primary_key_field instanceof EE_Primary_Key_String_Field && is_string($base_class_obj_or_id) ){
4183
+		}elseif ($primary_key_field instanceof EE_Primary_Key_String_Field && is_string($base_class_obj_or_id)) {
4184 4184
 			//assume its a string representation of the object
4185 4185
 			$model_object = $this->get_one_by_ID($base_class_obj_or_id);
4186
-		}else{
4187
-			throw new EE_Error(sprintf(__("'%s' is neither an object of type %s, nor an ID! Its full value is '%s'",'event_espresso'),$base_class_obj_or_id,$this->_get_class_name(),print_r($base_class_obj_or_id,true)));
4186
+		} else {
4187
+			throw new EE_Error(sprintf(__("'%s' is neither an object of type %s, nor an ID! Its full value is '%s'", 'event_espresso'), $base_class_obj_or_id, $this->_get_class_name(), print_r($base_class_obj_or_id, true)));
4188 4188
 		}
4189
-		if( $model_object->ID() == NULL && $ensure_is_in_db){
4189
+		if ($model_object->ID() == NULL && $ensure_is_in_db) {
4190 4190
 			$model_object->save();
4191 4191
 		}
4192 4192
 		return $model_object;
@@ -4202,19 +4202,19 @@  discard block
 block discarded – undo
4202 4202
 	 * @return int|string depending on the type of this model object's ID
4203 4203
 	 * @throws EE_Error
4204 4204
 	 */
4205
-	public function ensure_is_ID($base_class_obj_or_id){
4205
+	public function ensure_is_ID($base_class_obj_or_id) {
4206 4206
 		$className = $this->_get_class_name();
4207
-		if( $base_class_obj_or_id instanceof $className ){
4207
+		if ($base_class_obj_or_id instanceof $className) {
4208 4208
 			/** @var $base_class_obj_or_id EE_Base_Class */
4209 4209
 			$id = $base_class_obj_or_id->ID();
4210
-		}elseif(is_int($base_class_obj_or_id)){
4210
+		}elseif (is_int($base_class_obj_or_id)) {
4211 4211
 			//assume it's an ID
4212 4212
 			$id = $base_class_obj_or_id;
4213
-		}elseif(is_string($base_class_obj_or_id)){
4213
+		}elseif (is_string($base_class_obj_or_id)) {
4214 4214
 			//assume its a string representation of the object
4215 4215
 			$id = $base_class_obj_or_id;
4216
-		}else{
4217
-			throw new EE_Error(sprintf(__("'%s' is neither an object of type %s, nor an ID! Its full value is '%s'",'event_espresso'),$base_class_obj_or_id,$this->_get_class_name(),print_r($base_class_obj_or_id,true)));
4216
+		} else {
4217
+			throw new EE_Error(sprintf(__("'%s' is neither an object of type %s, nor an ID! Its full value is '%s'", 'event_espresso'), $base_class_obj_or_id, $this->_get_class_name(), print_r($base_class_obj_or_id, true)));
4218 4218
 		}
4219 4219
 		return $id;
4220 4220
 	}
@@ -4237,14 +4237,14 @@  discard block
 block discarded – undo
4237 4237
 	 * @param int $values_already_prepared like one of the constants on EEM_Base
4238 4238
 	 * @return void
4239 4239
 	 */
4240
-	public function assume_values_already_prepared_by_model_object($values_already_prepared = self::not_prepared_by_model_object){
4240
+	public function assume_values_already_prepared_by_model_object($values_already_prepared = self::not_prepared_by_model_object) {
4241 4241
 		$this->_values_already_prepared_by_model_object = $values_already_prepared;
4242 4242
 	}
4243 4243
 	/**
4244 4244
 	 * Read comments for assume_values_already_prepared_by_model_object()
4245 4245
 	 * @return int
4246 4246
 	 */
4247
-	public function get_assumption_concerning_values_already_prepared_by_model_object(){
4247
+	public function get_assumption_concerning_values_already_prepared_by_model_object() {
4248 4248
 		return $this->_values_already_prepared_by_model_object;
4249 4249
 	}
4250 4250
 
@@ -4252,17 +4252,17 @@  discard block
 block discarded – undo
4252 4252
 	 * Gets all the indexes on this model
4253 4253
 	 * @return EE_Index[]
4254 4254
 	 */
4255
-	public function indexes(){
4255
+	public function indexes() {
4256 4256
 		return $this->_indexes;
4257 4257
 	}
4258 4258
 	/**
4259 4259
 	 * Gets all the Unique Indexes on this model
4260 4260
 	 * @return EE_Unique_Index[]
4261 4261
 	 */
4262
-	public function unique_indexes(){
4262
+	public function unique_indexes() {
4263 4263
 		$unique_indexes = array();
4264
-		foreach($this->_indexes as $name => $index){
4265
-			if($index instanceof EE_Unique_Index){
4264
+		foreach ($this->_indexes as $name => $index) {
4265
+			if ($index instanceof EE_Unique_Index) {
4266 4266
 				$unique_indexes [$name] = $index;
4267 4267
 			}
4268 4268
 		}
@@ -4275,9 +4275,9 @@  discard block
 block discarded – undo
4275 4275
 	 * on a primary index
4276 4276
 	 * @return EE_Model_Field_Base[]
4277 4277
 	 */
4278
-	public function get_combined_primary_key_fields(){
4279
-		foreach($this->indexes() as $index){
4280
-			if($index instanceof EE_Primary_Key_Index){
4278
+	public function get_combined_primary_key_fields() {
4279
+		foreach ($this->indexes() as $index) {
4280
+			if ($index instanceof EE_Primary_Key_Index) {
4281 4281
 				return $index->fields();
4282 4282
 			}
4283 4283
 		}
@@ -4290,7 +4290,7 @@  discard block
 block discarded – undo
4290 4290
 	 * @param array $cols_n_values keys are field names, values are their values
4291 4291
 	 * @return string
4292 4292
 	 */
4293
-	public function get_index_primary_key_string($cols_n_values){
4293
+	public function get_index_primary_key_string($cols_n_values) {
4294 4294
 		$cols_n_values_for_primary_key_index = array_intersect_key($cols_n_values, $this->get_combined_primary_key_fields());
4295 4295
 		return http_build_query($cols_n_values_for_primary_key_index);
4296 4296
 	}
@@ -4302,13 +4302,13 @@  discard block
 block discarded – undo
4302 4302
 	 * @param string $index_primary_key_string
4303 4303
 	 * @return null|array
4304 4304
 	 */
4305
-	function parse_index_primary_key_string( $index_primary_key_string) {
4305
+	function parse_index_primary_key_string($index_primary_key_string) {
4306 4306
 		$key_fields = $this->get_combined_primary_key_fields();
4307 4307
 		//check all of them are in the $id
4308 4308
 		$key_vals_in_combined_pk = array();
4309
-		parse_str( $index_primary_key_string, $key_vals_in_combined_pk );
4310
-		foreach( $key_fields as $key_field_name => $field_obj ) {
4311
-			if( ! isset( $key_vals_in_combined_pk[ $key_field_name ] ) ){
4309
+		parse_str($index_primary_key_string, $key_vals_in_combined_pk);
4310
+		foreach ($key_fields as $key_field_name => $field_obj) {
4311
+			if ( ! isset($key_vals_in_combined_pk[$key_field_name])) {
4312 4312
 				return NULL;
4313 4313
 			}
4314 4314
 		}
@@ -4321,10 +4321,10 @@  discard block
 block discarded – undo
4321 4321
 	 * @param array $key_vals
4322 4322
 	 * @return boolean
4323 4323
 	 */
4324
-	function has_all_combined_primary_key_fields( $key_vals ) {
4325
-		$keys_it_should_have = array_keys( $this->get_combined_primary_key_fields() );
4326
-		foreach( $keys_it_should_have as $key ){
4327
-			if( ! isset( $key_vals[ $key ] ) ){
4324
+	function has_all_combined_primary_key_fields($key_vals) {
4325
+		$keys_it_should_have = array_keys($this->get_combined_primary_key_fields());
4326
+		foreach ($keys_it_should_have as $key) {
4327
+			if ( ! isset($key_vals[$key])) {
4328 4328
 				return false;
4329 4329
 			}
4330 4330
 		}
@@ -4340,23 +4340,23 @@  discard block
 block discarded – undo
4340 4340
 	 * @throws EE_Error
4341 4341
 	 * @return \EE_Base_Class[] Array keys are object IDs (if there is a primary key on the model. if not, numerically indexed)
4342 4342
 	 */
4343
-	public function get_all_copies($model_object_or_attributes_array, $query_params = array()){
4343
+	public function get_all_copies($model_object_or_attributes_array, $query_params = array()) {
4344 4344
 
4345
-		if($model_object_or_attributes_array instanceof EE_Base_Class){
4345
+		if ($model_object_or_attributes_array instanceof EE_Base_Class) {
4346 4346
 			$attributes_array = $model_object_or_attributes_array->model_field_array();
4347
-		}elseif(is_array($model_object_or_attributes_array)){
4347
+		}elseif (is_array($model_object_or_attributes_array)) {
4348 4348
 			$attributes_array = $model_object_or_attributes_array;
4349
-		}else{
4350
-			throw new EE_Error(sprintf(__("get_all_copies should be provided with either a model object or an array of field-value-pairs, but was given %s", "event_espresso"),$model_object_or_attributes_array));
4349
+		} else {
4350
+			throw new EE_Error(sprintf(__("get_all_copies should be provided with either a model object or an array of field-value-pairs, but was given %s", "event_espresso"), $model_object_or_attributes_array));
4351 4351
 		}
4352 4352
 		//even copies obviously won't have the same ID, so remove the primary key
4353 4353
 		//from the WHERE conditions for finding copies (if there is a primary key, of course)
4354
-		if($this->has_primary_key_field() && isset($attributes_array[$this->primary_key_name()])){
4354
+		if ($this->has_primary_key_field() && isset($attributes_array[$this->primary_key_name()])) {
4355 4355
 			unset($attributes_array[$this->primary_key_name()]);
4356 4356
 		}
4357
-		if(isset($query_params[0])){
4358
-			$query_params[0] = array_merge($attributes_array,$query_params);
4359
-		}else{
4357
+		if (isset($query_params[0])) {
4358
+			$query_params[0] = array_merge($attributes_array, $query_params);
4359
+		} else {
4360 4360
 			$query_params[0] = $attributes_array;
4361 4361
 		}
4362 4362
 		return $this->get_all($query_params);
@@ -4370,16 +4370,16 @@  discard block
 block discarded – undo
4370 4370
 	 * @param array $query_params
4371 4371
 	 * @return EE_Base_Class
4372 4372
 	 */
4373
-	function get_one_copy($model_object_or_attributes_array,$query_params = array()){
4374
-		if( ! is_array( $query_params ) ){
4375
-			EE_Error::doing_it_wrong('EEM_Base::get_one_copy', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' );
4373
+	function get_one_copy($model_object_or_attributes_array, $query_params = array()) {
4374
+		if ( ! is_array($query_params)) {
4375
+			EE_Error::doing_it_wrong('EEM_Base::get_one_copy', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0');
4376 4376
 			$query_params = array();
4377 4377
 		}
4378 4378
 		$query_params['limit'] = 1;
4379
-		$copies = $this->get_all_copies($model_object_or_attributes_array,$query_params);
4380
-		if(is_array($copies)){
4379
+		$copies = $this->get_all_copies($model_object_or_attributes_array, $query_params);
4380
+		if (is_array($copies)) {
4381 4381
 			return array_shift($copies);
4382
-		}else{
4382
+		} else {
4383 4383
 			return null;
4384 4384
 		}
4385 4385
 	}
@@ -4393,10 +4393,10 @@  discard block
 block discarded – undo
4393 4393
 	 * @param int|string $id the value of the primary key to update
4394 4394
 	 * @return int number of rows updated
4395 4395
 	 */
4396
-	public function update_by_ID($fields_n_values,$id){
4396
+	public function update_by_ID($fields_n_values, $id) {
4397 4397
 		$query_params = array(0=>array($this->get_primary_key_field()->get_name() => $id),
4398 4398
 			'default_where_conditions'=>'other_models_only',);
4399
-		return $this->update($fields_n_values,$query_params);
4399
+		return $this->update($fields_n_values, $query_params);
4400 4400
 	}
4401 4401
 
4402 4402
 
@@ -4407,12 +4407,12 @@  discard block
 block discarded – undo
4407 4407
 	 * @return string an operator which can be used in SQL
4408 4408
 	 * @throws EE_Error
4409 4409
 	 */
4410
-	private function _prepare_operator_for_sql($operator_supplied){
4410
+	private function _prepare_operator_for_sql($operator_supplied) {
4411 4411
 		$sql_operator = isset($this->_valid_operators[$operator_supplied]) ? $this->_valid_operators[$operator_supplied] : null;
4412
-		if($sql_operator){
4412
+		if ($sql_operator) {
4413 4413
 			return $sql_operator;
4414
-		}else{
4415
-			throw new EE_Error(sprintf(__("The operator '%s' is not in the list of valid operators: %s", "event_espresso"),$operator_supplied,implode(",",array_keys($this->_valid_operators))));
4414
+		} else {
4415
+			throw new EE_Error(sprintf(__("The operator '%s' is not in the list of valid operators: %s", "event_espresso"), $operator_supplied, implode(",", array_keys($this->_valid_operators))));
4416 4416
 		}
4417 4417
 	}
4418 4418
 
@@ -4422,10 +4422,10 @@  discard block
 block discarded – undo
4422 4422
 	 * @param array $query_params like get_all's
4423 4423
 	 * @return string[]
4424 4424
 	 */
4425
-	public function get_all_names($query_params = array()){
4425
+	public function get_all_names($query_params = array()) {
4426 4426
 		$objs = $this->get_all($query_params);
4427 4427
 		$names = array();
4428
-		foreach($objs as $obj){
4428
+		foreach ($objs as $obj) {
4429 4429
 			$names[$obj->ID()] = $obj->name();
4430 4430
 		}
4431 4431
 		return $names;
@@ -4440,22 +4440,22 @@  discard block
 block discarded – undo
4440 4440
 	 * @param boolean $filter_out_empty_ids if a model object has an ID of '' or 0, don't bother including it in the returned array
4441 4441
 	 * @return array
4442 4442
 	 */
4443
-	public function get_IDs( $model_objects, $filter_out_empty_ids = false) {
4444
-		if( ! $this->has_primary_key_field() ) {
4445
-			if( WP_DEBUG ) {
4446
-				EE_Error::add_error( __( 'Trying to get IDs from a model than has no primary key', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
4443
+	public function get_IDs($model_objects, $filter_out_empty_ids = false) {
4444
+		if ( ! $this->has_primary_key_field()) {
4445
+			if (WP_DEBUG) {
4446
+				EE_Error::add_error(__('Trying to get IDs from a model than has no primary key', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
4447 4447
 				return array();
4448 4448
 			}
4449 4449
 		}
4450 4450
 		$IDs = array();
4451
-		foreach( $model_objects as $model_object ) {
4451
+		foreach ($model_objects as $model_object) {
4452 4452
 			$id = $model_object->ID();
4453
-			if( ! $id ) {
4454
-				if( $filter_out_empty_ids ) {
4453
+			if ( ! $id) {
4454
+				if ($filter_out_empty_ids) {
4455 4455
 					continue;
4456 4456
 				}
4457
-				if( WP_DEBUG ) {
4458
-					EE_Error::add_error(__( 'Called %1$s on a model object that has no ID and so probably hasn\'t been saved to the database', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
4457
+				if (WP_DEBUG) {
4458
+					EE_Error::add_error(__('Called %1$s on a model object that has no ID and so probably hasn\'t been saved to the database', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
4459 4459
 				}
4460 4460
 			}
4461 4461
 			$IDs[] = $id;
@@ -4468,8 +4468,8 @@  discard block
 block discarded – undo
4468 4468
 	 * are no capabilities that relate to this model returns false
4469 4469
 	 * @return string|false
4470 4470
 	 */
4471
-	public function cap_slug(){
4472
-		return apply_filters( 'FHEE__EEM_Base__cap_slug', $this->_caps_slug, $this);
4471
+	public function cap_slug() {
4472
+		return apply_filters('FHEE__EEM_Base__cap_slug', $this->_caps_slug, $this);
4473 4473
 	}
4474 4474
 
4475 4475
 	/**
@@ -4481,27 +4481,27 @@  discard block
 block discarded – undo
4481 4481
 	 * @param string $context
4482 4482
 	 * @return EE_Default_Where_Conditions[] indexed by associated capability
4483 4483
 	 */
4484
-	public function cap_restrictions( $context = EEM_Base::caps_read ) {
4485
-		EEM_Base::verify_is_valid_cap_context( $context );
4484
+	public function cap_restrictions($context = EEM_Base::caps_read) {
4485
+		EEM_Base::verify_is_valid_cap_context($context);
4486 4486
 		//check if we ought to run the restriction generator first
4487
-		if( isset( $this->_cap_restriction_generators[ $context ] ) &&
4488
-				$this->_cap_restriction_generators[ $context ] instanceof EE_Restriction_Generator_Base &&
4489
-				! $this->_cap_restriction_generators[ $context ]->has_generated_cap_restrictions() ) {
4490
-			$this->_cap_restrictions[ $context ] = array_merge( $this->_cap_restrictions[ $context ],  $this->_cap_restriction_generators[ $context ]->generate_restrictions() );
4487
+		if (isset($this->_cap_restriction_generators[$context]) &&
4488
+				$this->_cap_restriction_generators[$context] instanceof EE_Restriction_Generator_Base &&
4489
+				! $this->_cap_restriction_generators[$context]->has_generated_cap_restrictions()) {
4490
+			$this->_cap_restrictions[$context] = array_merge($this->_cap_restrictions[$context], $this->_cap_restriction_generators[$context]->generate_restrictions());
4491 4491
 		}
4492 4492
 		//and make sure we've finalized the construction of each restriction
4493
-		foreach( $this->_cap_restrictions[ $context ] as $where_conditions_obj ) {
4494
-			$where_conditions_obj->_finalize_construct( $this );
4493
+		foreach ($this->_cap_restrictions[$context] as $where_conditions_obj) {
4494
+			$where_conditions_obj->_finalize_construct($this);
4495 4495
 		}
4496 4496
 
4497
-		return $this->_cap_restrictions[ $context ];
4497
+		return $this->_cap_restrictions[$context];
4498 4498
 	}
4499 4499
 
4500 4500
 	/**
4501 4501
 	 * Indicating whether or not this model thinks its a wp core model
4502 4502
 	 * @return boolean
4503 4503
 	 */
4504
-	public function is_wp_core_model(){
4504
+	public function is_wp_core_model() {
4505 4505
 		return $this->_wp_core_model;
4506 4506
 	}
4507 4507
 
@@ -4511,12 +4511,12 @@  discard block
 block discarded – undo
4511 4511
 	 * @param string $context one of EEM_Base::caps_ constants
4512 4512
 	 * @return EE_Default_Where_Conditions[] indexed by capability name
4513 4513
 	 */
4514
-	public function caps_missing( $context = EEM_Base::caps_read ) {
4514
+	public function caps_missing($context = EEM_Base::caps_read) {
4515 4515
 		$missing_caps = array();
4516
-		$cap_restrictions = $this->cap_restrictions( $context );
4517
-		foreach( $cap_restrictions as $cap => $restriction_if_no_cap ) {
4518
-			if( ! EE_Capabilities::instance()->current_user_can( $cap, $this->get_this_model_name() . '_model_applying_caps') ) {
4519
-				$missing_caps[ $cap ] = $restriction_if_no_cap;
4516
+		$cap_restrictions = $this->cap_restrictions($context);
4517
+		foreach ($cap_restrictions as $cap => $restriction_if_no_cap) {
4518
+			if ( ! EE_Capabilities::instance()->current_user_can($cap, $this->get_this_model_name().'_model_applying_caps')) {
4519
+				$missing_caps[$cap] = $restriction_if_no_cap;
4520 4520
 			}
4521 4521
 		}
4522 4522
 		return $missing_caps;
@@ -4528,7 +4528,7 @@  discard block
 block discarded – undo
4528 4528
 	 * one of 'read', 'edit', or 'delete'
4529 4529
 	 */
4530 4530
 	public function cap_contexts_to_cap_action_map() {
4531
-		return apply_filters( 'FHEE__EEM_Base__cap_contexts_to_cap_action_map', $this->_cap_contexts_to_cap_action_map, $this );
4531
+		return apply_filters('FHEE__EEM_Base__cap_contexts_to_cap_action_map', $this->_cap_contexts_to_cap_action_map, $this);
4532 4532
 	}
4533 4533
 
4534 4534
 
@@ -4539,19 +4539,19 @@  discard block
 block discarded – undo
4539 4539
 	 * @return string one of EEM_Base::cap_contexts_to_cap_action_map() values
4540 4540
 	 * @throws \EE_Error
4541 4541
 	 */
4542
-	public function cap_action_for_context( $context ) {
4542
+	public function cap_action_for_context($context) {
4543 4543
 		$mapping = $this->cap_contexts_to_cap_action_map();
4544
-		if( isset( $mapping[ $context ] ) ) {
4545
-			return $mapping[ $context ];
4544
+		if (isset($mapping[$context])) {
4545
+			return $mapping[$context];
4546 4546
 		}
4547
-		if( $action = apply_filters( 'FHEE__EEM_Base__cap_action_for_context', null, $this, $mapping, $context ) ) {
4547
+		if ($action = apply_filters('FHEE__EEM_Base__cap_action_for_context', null, $this, $mapping, $context)) {
4548 4548
 			return $action;
4549 4549
 		}
4550 4550
 		throw new EE_Error(
4551 4551
 			sprintf(
4552
-				__( 'Cannot find capability restrictions for context "%1$s", allowed values are:%2$s', 'event_espresso' ),
4552
+				__('Cannot find capability restrictions for context "%1$s", allowed values are:%2$s', 'event_espresso'),
4553 4553
 				$context,
4554
-				implode(',', array_keys( $this->cap_contexts_to_cap_action_map() ) )
4554
+				implode(',', array_keys($this->cap_contexts_to_cap_action_map()))
4555 4555
 			)
4556 4556
 		);
4557 4557
 
@@ -4562,7 +4562,7 @@  discard block
 block discarded – undo
4562 4562
 	 * @return array
4563 4563
 	 */
4564 4564
 	static public function valid_cap_contexts() {
4565
-		return apply_filters( 'FHEE__EEM_Base__valid_cap_contexts', array(
4565
+		return apply_filters('FHEE__EEM_Base__valid_cap_contexts', array(
4566 4566
 			self::caps_read,
4567 4567
 			self::caps_read_admin,
4568 4568
 			self::caps_edit,
@@ -4578,17 +4578,17 @@  discard block
 block discarded – undo
4578 4578
 	 * @return bool
4579 4579
 	 * @throws \EE_Error
4580 4580
 	 */
4581
-	static public function verify_is_valid_cap_context( $context ) {
4581
+	static public function verify_is_valid_cap_context($context) {
4582 4582
 		$valid_cap_contexts = EEM_Base::valid_cap_contexts();
4583
-		if( in_array( $context, $valid_cap_contexts ) ) {
4583
+		if (in_array($context, $valid_cap_contexts)) {
4584 4584
 			return true;
4585
-		}else{
4585
+		} else {
4586 4586
 			throw new EE_Error(
4587 4587
 				sprintf(
4588
-					__( 'Context "%1$s" passed into model "%2$s" is not a valid context. They are: %3$s', 'event_espresso' ),
4588
+					__('Context "%1$s" passed into model "%2$s" is not a valid context. They are: %3$s', 'event_espresso'),
4589 4589
 					$context,
4590
-					'EEM_Base' ,
4591
-					implode(',', $valid_cap_contexts )
4590
+					'EEM_Base',
4591
+					implode(',', $valid_cap_contexts)
4592 4592
 				)
4593 4593
 			);
4594 4594
 		}
Please login to merge, or discard this patch.
Braces   +133 added lines, -122 removed lines patch added patch discarded remove patch
@@ -546,7 +546,7 @@  discard block
 block discarded – undo
546 546
 		if( isset( $this->_cap_restriction_generators[ $context ] ) &&
547 547
 				$this->_cap_restriction_generators[ $context ] instanceof EE_Restriction_Generator_Base ) {
548 548
 			return $this->_cap_restriction_generators[ $context ]->generate_restrictions();
549
-		}else{
549
+		} else{
550 550
 			return array();
551 551
 		}
552 552
 }
@@ -597,8 +597,9 @@  discard block
 block discarded – undo
597 597
 	 * @return array
598 598
 	 */
599 599
 	 public function status_array( $translated = FALSE ) {
600
-	 	if ( !array_key_exists('Status', $this->_model_relations ) )
601
-	 		return array();
600
+	 	if ( !array_key_exists('Status', $this->_model_relations ) ) {
601
+	 		 		return array();
602
+	 	}
602 603
 	 	$model_name = $this->get_this_model_name();
603 604
 	 	$status_type = str_replace(' ', '_', strtolower( str_replace('_', ' ', $model_name) ) );
604 605
 	 	$stati = EEM_Status::instance()->get_all(array(array('STS_type' => $status_type) ) );
@@ -819,13 +820,13 @@  discard block
 block discarded – undo
819 820
 				$last_model_name = end( $models_to_follow_to_wp_users );
820 821
 				$model_with_fk_to_wp_users = EE_Registry::instance()->load_model( $last_model_name );
821 822
 				$model_chain_to_wp_user = $this->_model_chain_to_wp_user . '.';
822
-			}else{
823
+			} else{
823 824
 				$model_with_fk_to_wp_users = $this;
824 825
 				$model_chain_to_wp_user = '';
825 826
 			}
826 827
 			$wp_user_field = $model_with_fk_to_wp_users->get_foreign_key_to( 'WP_User' );
827 828
 			return $model_chain_to_wp_user . $wp_user_field->get_name();
828
-		}catch( EE_Error $e ) {
829
+		} catch( EE_Error $e ) {
829 830
 			return false;
830 831
 		}
831 832
 	}
@@ -853,11 +854,11 @@  discard block
 block discarded – undo
853 854
 	public function is_owned() {
854 855
 		if( $this->model_chain_to_wp_user() ){
855 856
 			return true;
856
-		}else{
857
+		} else{
857 858
 			try{
858 859
 				$this->get_foreign_key_to( 'WP_User' );
859 860
 				return true;
860
-			}catch( EE_Error $e ){
861
+			} catch( EE_Error $e ){
861 862
 				return false;
862 863
 			}
863 864
 		}
@@ -880,9 +881,9 @@  discard block
 block discarded – undo
880 881
 		//remember the custom selections, if any
881 882
 		if(is_array($columns_to_select)){
882 883
 			$this->_custom_selections = $columns_to_select;
883
-		}elseif(is_string($columns_to_select)){
884
+		} elseif(is_string($columns_to_select)){
884 885
 			$this->_custom_selections = array($this->_custom_selections);
885
-		}else{
886
+		} else{
886 887
 			$this->_custom_selections = array();
887 888
 		}
888 889
 
@@ -954,7 +955,7 @@  discard block
 block discarded – undo
954 955
 				$select_sql_array[] = "{$selection_and_datatype[0]} AS $alias";
955 956
 			}
956 957
 			$columns_to_select_string = implode(", ",$select_sql_array);
957
-		}else{
958
+		} else{
958 959
 			$columns_to_select_string = $columns_to_select;
959 960
 		}
960 961
 		return $columns_to_select_string;
@@ -1004,7 +1005,7 @@  discard block
 block discarded – undo
1004 1005
 		}
1005 1006
 		if( $this->has_primary_key_field ( ) ) {
1006 1007
 			$query_params[ 0 ][ $this->primary_key_name() ] = $id ;
1007
-		}else{
1008
+		} else{
1008 1009
 			//no primary key, so the $id must be from the get_index_primary_key_string()
1009 1010
 			$query_params[0] = array_replace_recursive( $query_params[ 0 ], $this->parse_index_primary_key_string( $id ) );
1010 1011
 		}
@@ -1027,7 +1028,7 @@  discard block
 block discarded – undo
1027 1028
 		$items = $this->get_all($query_params);
1028 1029
 		if(empty($items)){
1029 1030
 			return null;
1030
-		}else{
1031
+		} else{
1031 1032
 			return array_shift($items);
1032 1033
 		}
1033 1034
 	}
@@ -1425,7 +1426,7 @@  discard block
 block discarded – undo
1425 1426
 				//get the model object's PK, as we'll want this if we need to insert a row into secondary tables
1426 1427
 				if( $this->has_primary_key_field() ){
1427 1428
 					$main_table_pk_value = $wpdb_result[ $this->get_primary_key_field()->get_qualified_column() ];
1428
-				}else{
1429
+				} else{
1429 1430
 					//if there's no primary key, we basically can't support having a 2nd table on the model (we could but it would be lots of work)
1430 1431
 					$main_table_pk_value = null;
1431 1432
 				}
@@ -1464,7 +1465,7 @@  discard block
 block discarded – undo
1464 1465
 		if( $keep_model_objs_in_sync && ! $this->_values_already_prepared_by_model_object ){
1465 1466
 			if( $this->has_primary_key_field() ){
1466 1467
 				$model_objs_affected_ids = $this->get_col( $query_params );
1467
-			}else{
1468
+			} else{
1468 1469
 				//we need to select a bunch of columns and then combine them into the the "index primary key string"s
1469 1470
 				$models_affected_key_columns = $this->_get_all_wpdb_results($query_params, ARRAY_A );
1470 1471
 				$model_objs_affected_ids = array();
@@ -1524,9 +1525,9 @@  discard block
 block discarded – undo
1524 1525
 
1525 1526
 		if( $field_to_select ){
1526 1527
 			$field = $this->field_settings_for( $field_to_select );
1527
-		}elseif( $this->has_primary_key_field ( ) ){
1528
+		} elseif( $this->has_primary_key_field ( ) ){
1528 1529
 			$field = $this->get_primary_key_field();
1529
-		}else{
1530
+		} else{
1530 1531
 			//no primary key, just grab the first column
1531 1532
 			$field = reset( $this->field_settings());
1532 1533
 		}
@@ -1550,7 +1551,7 @@  discard block
 block discarded – undo
1550 1551
 		$col = $this->get_col( $query_params, $field_to_select );
1551 1552
 		if( ! empty( $col ) ) {
1552 1553
 			return reset( $col );
1553
-		}else{
1554
+		} else{
1554 1555
 			return NULL;
1555 1556
 		}
1556 1557
 	}
@@ -1670,7 +1671,7 @@  discard block
 block discarded – undo
1670 1671
 
1671 1672
 			//		/echo "delete sql:$SQL";
1672 1673
 			$rows_deleted = $this->_do_wpdb_query( 'query', array( $SQL ) );
1673
-		}else{
1674
+		} else{
1674 1675
 			$rows_deleted = 0;
1675 1676
 		}
1676 1677
 
@@ -1712,7 +1713,7 @@  discard block
 block discarded – undo
1712 1713
 		//first, if $ignore_this_model_obj was supplied, get its model
1713 1714
 		if($ignore_this_model_obj && $ignore_this_model_obj instanceof EE_Base_Class){
1714 1715
 			$ignored_model = $ignore_this_model_obj->get_model();
1715
-		}else{
1716
+		} else{
1716 1717
 			$ignored_model = null;
1717 1718
 		}
1718 1719
 		//now check all the relations of $this_model_obj_or_id and see if there
@@ -1725,7 +1726,7 @@  discard block
 block discarded – undo
1725 1726
 				if($ignored_model && $relation_name == $ignored_model->get_this_model_name()){
1726 1727
 					$related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id,array(
1727 1728
 					array($ignored_model->get_primary_key_field()->get_name() => array('!=',$ignore_this_model_obj->ID()))));
1728
-				}else{
1729
+				} else{
1729 1730
 					$related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id);
1730 1731
 				}
1731 1732
 
@@ -1762,24 +1763,28 @@  discard block
 block discarded – undo
1762 1763
 				}
1763 1764
 
1764 1765
 				//primary table deletes
1765
-				if ( isset( $delete_object[$primary_table->get_fully_qualified_pk_column()] ) )
1766
-					$deletes[$primary_table->get_fully_qualified_pk_column()][] = $delete_object[$primary_table->get_fully_qualified_pk_column()];
1766
+				if ( isset( $delete_object[$primary_table->get_fully_qualified_pk_column()] ) ) {
1767
+									$deletes[$primary_table->get_fully_qualified_pk_column()][] = $delete_object[$primary_table->get_fully_qualified_pk_column()];
1768
+				}
1767 1769
 
1768 1770
 				//other tables
1769 1771
 				if ( !empty( $other_tables ) ) {
1770 1772
 					foreach ( $other_tables as $ot ) {
1771 1773
 
1772 1774
 						//first check if we've got the foreign key column here.
1773
-						if ( isset( $delete_object[$ot->get_fully_qualified_fk_column()] ) )
1774
-							$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_fk_column()];
1775
+						if ( isset( $delete_object[$ot->get_fully_qualified_fk_column()] ) ) {
1776
+													$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_fk_column()];
1777
+						}
1775 1778
 
1776 1779
 						//wait! it's entirely possible that we'll have a the primary key for this table in here if it's a foreign key for one of the other secondary tables
1777
-						if ( isset( $delete_object[$ot->get_fully_qualified_pk_column()] ) )
1778
-							$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()];
1780
+						if ( isset( $delete_object[$ot->get_fully_qualified_pk_column()] ) ) {
1781
+													$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()];
1782
+						}
1779 1783
 
1780 1784
 						//finally, it is possible that the fk for this table is found in the fully qualified pk column for the fk table, so let's see if that's there!
1781
-						if ( isset( $delete_object[$ot->get_fully_qualified_pk_on_fk_table()]) )
1782
-							$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()];
1785
+						if ( isset( $delete_object[$ot->get_fully_qualified_pk_on_fk_table()]) ) {
1786
+													$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()];
1787
+						}
1783 1788
 					}
1784 1789
 				}
1785 1790
 			}
@@ -1792,7 +1797,7 @@  discard block
 block discarded – undo
1792 1797
 			}
1793 1798
 
1794 1799
 			return !empty($query) ? implode(' AND ', $query ) : '';
1795
-		}elseif(count($this->get_combined_primary_key_fields()) > 1){
1800
+		} elseif(count($this->get_combined_primary_key_fields()) > 1){
1796 1801
 			$ways_to_identify_a_row = array();
1797 1802
 			$fields = $this->get_combined_primary_key_fields();
1798 1803
 			//note: because there' sno primary key, that means nothing else  can be pointing to this model, right?
@@ -1804,7 +1809,7 @@  discard block
 block discarded – undo
1804 1809
 				$ways_to_identify_a_row[] = "(".implode(" AND ",$values_for_each_cpk_for_a_row).")";
1805 1810
 			}
1806 1811
 			return implode(" OR ",$ways_to_identify_a_row);
1807
-		}else{
1812
+		} else{
1808 1813
 			//so there's no primary key and no combined key...
1809 1814
 			//sorry, can't help you
1810 1815
 			throw new EE_Error(sprintf(__("Cannot delete objects of type %s because there is no primary key NOR combined key", "event_espresso"),get_class($this)));
@@ -1826,10 +1831,10 @@  discard block
 block discarded – undo
1826 1831
 		if($field_to_count){
1827 1832
 			$field_obj = $this->field_settings_for($field_to_count);
1828 1833
 			$column_to_count = $field_obj->get_qualified_column();
1829
-		}elseif($this->has_primary_key_field ()){
1834
+		} elseif($this->has_primary_key_field ()){
1830 1835
 			$pk_field_obj = $this->get_primary_key_field();
1831 1836
 			$column_to_count = $pk_field_obj->get_qualified_column();
1832
-		}else{//there's no primary key
1837
+		} else{//there's no primary key
1833 1838
 			$column_to_count = '*';
1834 1839
 		}
1835 1840
 
@@ -1851,7 +1856,7 @@  discard block
 block discarded – undo
1851 1856
 		if($field_to_sum){
1852 1857
 			$field_obj = $this->field_settings_for($field_to_sum);
1853 1858
 
1854
-		}else{
1859
+		} else{
1855 1860
 			$field_obj = $this->get_primary_key_field();
1856 1861
 		}
1857 1862
 		$column_to_count = $field_obj->get_qualified_column();
@@ -1860,7 +1865,7 @@  discard block
 block discarded – undo
1860 1865
 		$return_value = $this->_do_wpdb_query('get_var',array( $SQL ) );
1861 1866
 		if($field_obj->get_wpdb_data_type() == '%d' || $field_obj->get_wpdb_data_type() == '%s' ){
1862 1867
 			return (float)$return_value;
1863
-		}else{//must be %f
1868
+		} else{//must be %f
1864 1869
 			return (float)$return_value;
1865 1870
 		}
1866 1871
 	}
@@ -1898,10 +1903,10 @@  discard block
 block discarded – undo
1898 1903
 			$wpdb->show_errors( $old_show_errors_value );
1899 1904
 			if( ! empty( $wpdb->last_error ) ){
1900 1905
 				throw new EE_Error( sprintf( __( 'WPDB Error: "%s"', 'event_espresso' ), $wpdb->last_error ) );
1901
-			}elseif( $result === false ){
1906
+			} elseif( $result === false ){
1902 1907
 				throw new EE_Error( sprintf( __( 'WPDB Error occurred, but no error message was logged by wpdb! The wpdb method called was "%1$s" and the arguments were "%2$s"', 'event_espresso' ), $wpdb_method, var_export( $arguments_to_provide, true ) ) );
1903 1908
 			}
1904
-		}elseif( $result === false ) {
1909
+		} elseif( $result === false ) {
1905 1910
 			EE_Error::add_error( sprintf( __( 'A database error has occurred. Turn on WP_DEBUG for more information.', 'event_espresso' )), __FILE__, __FUNCTION__, __LINE__);
1906 1911
 		}
1907 1912
 		return $result;
@@ -2211,7 +2216,7 @@  discard block
 block discarded – undo
2211 2216
 		$results = $this->get_all_related($id_or_obj,$other_model_name,$query_params);
2212 2217
 		if( $results ){
2213 2218
 			return array_shift($results);
2214
-		}else{
2219
+		} else{
2215 2220
 			return null;
2216 2221
 		}
2217 2222
 
@@ -2282,7 +2287,7 @@  discard block
 block discarded – undo
2282 2287
 			 */
2283 2288
 			do_action( 'AHEE__EEM_Base__insert__end', $this, $field_n_values, $new_id );
2284 2289
 			return $new_id;
2285
-		}else{
2290
+		} else{
2286 2291
 			return FALSE;
2287 2292
 		}
2288 2293
 	}
@@ -2323,9 +2328,9 @@  discard block
 block discarded – undo
2323 2328
 	public function get_one_conflicting($obj_or_fields_array, $include_primary_key = true ){
2324 2329
 		if($obj_or_fields_array instanceof EE_Base_Class){
2325 2330
 			$fields_n_values = $obj_or_fields_array->model_field_array();
2326
-		}elseif( is_array($obj_or_fields_array)){
2331
+		} elseif( is_array($obj_or_fields_array)){
2327 2332
 			$fields_n_values = $obj_or_fields_array;
2328
-		}else{
2333
+		} else{
2329 2334
 			throw new EE_Error(sprintf(__("%s get_all_conflicting should be called with a model object or an array of field names and values, you provided %d", "event_espresso"),get_class($this),$obj_or_fields_array));
2330 2335
 		}
2331 2336
 		$query_params = array( 'default_where_conditions' => 'minimum' );
@@ -2341,7 +2346,7 @@  discard block
 block discarded – undo
2341 2346
 		//if there is nothing to base this search on, then we shouldn't find anything
2342 2347
 		if( ! isset( $query_params[0] ) || ( isset( $query_params[0] ) && empty( $query_params[0] ) ) ) {
2343 2348
 			return array();
2344
-		}else{
2349
+		} else{
2345 2350
 			return $this->get_one($query_params);
2346 2351
 		}
2347 2352
 	}
@@ -2414,12 +2419,12 @@  discard block
 block discarded – undo
2414 2419
 		if($this->has_primary_key_field()){
2415 2420
 			if($this->get_primary_key_field()->is_auto_increment()){
2416 2421
 				return $wpdb->insert_id;
2417
-			}else{
2422
+			} else{
2418 2423
 				//it's not an auto-increment primary key, so
2419 2424
 				//it must have been supplied
2420 2425
 				return $fields_n_values[$this->get_primary_key_field()->get_name()];
2421 2426
 			}
2422
-		}else{
2427
+		} else{
2423 2428
 			//we can't return a  primary key because there is none. instead return
2424 2429
 			//a unique string indicating this model
2425 2430
 			return $this->get_index_primary_key_string($fields_n_values);
@@ -2467,7 +2472,7 @@  discard block
 block discarded – undo
2467 2472
 					//leave the value alone
2468 2473
 			}
2469 2474
 			return $value;
2470
-		}else{
2475
+		} else{
2471 2476
 			return $value;
2472 2477
 		}
2473 2478
 	}
@@ -2560,7 +2565,7 @@  discard block
 block discarded – undo
2560 2565
 		if(array_key_exists('group_by', $query_params)){
2561 2566
 			if(is_array($query_params['group_by'])){
2562 2567
 				$this->_extract_related_models_from_sub_params_array_values($query_params['group_by'],$query_info_carrier,'group_by');
2563
-			}elseif( ! empty ( $query_params['group_by'] )){
2568
+			} elseif( ! empty ( $query_params['group_by'] )){
2564 2569
 				$this->_extract_related_model_info_from_query_param( $query_params['group_by'],$query_info_carrier,'group_by');
2565 2570
 			}
2566 2571
 		}
@@ -2568,10 +2573,11 @@  discard block
 block discarded – undo
2568 2573
 			$this->_extract_related_models_from_sub_params_array_keys($query_params[0], $query_info_carrier,'having');
2569 2574
 		}
2570 2575
 		if(array_key_exists('order_by', $query_params)){
2571
-			if ( is_array( $query_params['order_by'] ) )
2572
-				$this->_extract_related_models_from_sub_params_array_keys($query_params['order_by'],$query_info_carrier,'order_by');
2573
-			elseif( ! empty( $query_params['order_by'] ))
2574
-				$this->_extract_related_model_info_from_query_param( $query_params['order_by'], $query_info_carrier,'order_by');
2576
+			if ( is_array( $query_params['order_by'] ) ) {
2577
+							$this->_extract_related_models_from_sub_params_array_keys($query_params['order_by'],$query_info_carrier,'order_by');
2578
+			} elseif( ! empty( $query_params['order_by'] )) {
2579
+							$this->_extract_related_model_info_from_query_param( $query_params['order_by'], $query_info_carrier,'order_by');
2580
+			}
2575 2581
 		}
2576 2582
 		if(array_key_exists('force_join', $query_params)){
2577 2583
 			$this->_extract_related_models_from_sub_params_array_values($query_params['force_join'],$query_info_carrier,'force_join');
@@ -2603,10 +2609,10 @@  discard block
 block discarded – undo
2603 2609
 					if (! is_array($possibly_array_of_params)){
2604 2610
 						throw new EE_Error(sprintf(__("You used a special where query param %s, but the value isn't an array of where query params, it's just %s'. It should be an array, eg array('EVT_ID'=>23,'OR'=>array('Venue.VNU_ID'=>32,'Venue.VNU_name'=>'monkey_land'))", "event_espresso"),
2605 2611
 							$param,$possibly_array_of_params));
2606
-					}else{
2612
+					} else{
2607 2613
 						$this->_extract_related_models_from_sub_params_array_keys($possibly_array_of_params, $model_query_info_carrier,$query_param_type);
2608 2614
 					}
2609
-				}elseif($query_param_type === 0 //ie WHERE
2615
+				} elseif($query_param_type === 0 //ie WHERE
2610 2616
 						&& is_array($possibly_array_of_params)
2611 2617
 						&& isset($possibly_array_of_params[2])
2612 2618
 						&& $possibly_array_of_params[2] == true){
@@ -2666,7 +2672,7 @@  discard block
 block discarded – undo
2666 2672
 		}
2667 2673
 		if( isset( $query_params[0] ) ) {
2668 2674
 			$where_query_params = $query_params[0];
2669
-		}else{
2675
+		} else{
2670 2676
 			$where_query_params = array();
2671 2677
 		}
2672 2678
 		//first check if we should alter the query to account for caps or not
@@ -2684,7 +2690,7 @@  discard block
 block discarded – undo
2684 2690
 		}
2685 2691
 		if( array_key_exists( 'default_where_conditions',$query_params) && ! empty( $query_params['default_where_conditions'] )){
2686 2692
 			$use_default_where_conditions = $query_params['default_where_conditions'];
2687
-		}else{
2693
+		} else{
2688 2694
 			$use_default_where_conditions = 'all';
2689 2695
 		}
2690 2696
 		$where_query_params = array_merge($this->_get_default_where_conditions_for_models_in_query($query_object,$use_default_where_conditions,$where_query_params), $where_query_params );
@@ -2707,7 +2713,7 @@  discard block
 block discarded – undo
2707 2713
 				}
2708 2714
 				//they passed us an array for the limit. Assume it's like array(50,25), meaning offset by 50, and get 25
2709 2715
 				$query_object->set_limit_sql(" LIMIT ".$query_params['limit'][0].",".$query_params['limit'][1]);
2710
-			}elseif( ! empty ( $query_params['limit'] )){
2716
+			} elseif( ! empty ( $query_params['limit'] )){
2711 2717
 				$query_object->set_limit_sql((" LIMIT ".$query_params['limit']));
2712 2718
 			}
2713 2719
 		}
@@ -2729,11 +2735,11 @@  discard block
 block discarded – undo
2729 2735
 					$order_array[] = $this->_deduce_column_name_from_query_param($field_name_to_order_by).SP.$order;
2730 2736
 				}
2731 2737
 				$query_object->set_order_by_sql(" ORDER BY ".implode(",",$order_array));
2732
-			}elseif( ! empty ( $query_params['order_by'] )){
2738
+			} elseif( ! empty ( $query_params['order_by'] )){
2733 2739
 				$this->_extract_related_model_info_from_query_param($query_params['order_by'],$query_object,'order',$query_params['order_by']);
2734 2740
 				if(isset($query_params['order'])){
2735 2741
 					$order = $this->_extract_order($query_params['order']);
2736
-				}else{
2742
+				} else{
2737 2743
 					$order = 'DESC';
2738 2744
 				}
2739 2745
 				$query_object->set_order_by_sql(" ORDER BY ".$this->_deduce_column_name_from_query_param($query_params['order_by']).SP.$order);
@@ -2756,7 +2762,7 @@  discard block
 block discarded – undo
2756 2762
 					$group_by_array[] = $this->_deduce_column_name_from_query_param($field_name_to_group_by);
2757 2763
 				}
2758 2764
 				$query_object->set_group_by_sql(" GROUP BY ".implode(", ",$group_by_array));
2759
-			}elseif( ! empty ( $query_params['group_by'] )){
2765
+			} elseif( ! empty ( $query_params['group_by'] )){
2760 2766
 				$query_object->set_group_by_sql(" GROUP BY ".$this->_deduce_column_name_from_query_param($query_params['group_by']));
2761 2767
 			}
2762 2768
 		}
@@ -2780,8 +2786,9 @@  discard block
 block discarded – undo
2780 2786
 			}
2781 2787
 		}
2782 2788
 		$main_model_join_sql = $query_object->get_main_model_join_sql();
2783
-		if ( empty( $main_model_join_sql ) )
2784
-			$query_object->set_main_model_join_sql($this->_construct_internal_join());
2789
+		if ( empty( $main_model_join_sql ) ) {
2790
+					$query_object->set_main_model_join_sql($this->_construct_internal_join());
2791
+		}
2785 2792
 		return $query_object;
2786 2793
 	}
2787 2794
 
@@ -2814,7 +2821,7 @@  discard block
 block discarded – undo
2814 2821
 	private function _extract_order($should_be_order_string){
2815 2822
 		if(in_array($should_be_order_string, $this->_allowed_order_values)){
2816 2823
 			return $should_be_order_string;
2817
-		}else{
2824
+		} else{
2818 2825
 			throw new EE_Error(sprintf(__("While performing a query on '%s', tried to use '%s' as an order parameter. ", "event_espresso"),get_class($this),$should_be_order_string));
2819 2826
 		}
2820 2827
 	}
@@ -2846,9 +2853,9 @@  discard block
 block discarded – undo
2846 2853
 		}
2847 2854
 		if( in_array($use_default_where_conditions, array('all','this_model_only')) ){
2848 2855
 			$universal_query_params = $this->_get_default_where_conditions();
2849
-		}elseif( $use_default_where_conditions == 'minimum' ) {
2856
+		} elseif( $use_default_where_conditions == 'minimum' ) {
2850 2857
 			$universal_query_params = $this->_get_minimum_where_conditions();
2851
-		}else{
2858
+		} else{
2852 2859
 			$universal_query_params = array();
2853 2860
 		}
2854 2861
 
@@ -2857,7 +2864,7 @@  discard block
 block discarded – undo
2857 2864
 				$related_model = $this->get_related_model_obj($model_name);
2858 2865
 				if( $use_default_where_conditions == 'minimum' ) {
2859 2866
 					$related_model_universal_where_params = $related_model->_get_minimum_where_conditions($model_relation_path);
2860
-				}else{
2867
+				} else{
2861 2868
 					$related_model_universal_where_params = $related_model->_get_default_where_conditions($model_relation_path);
2862 2869
 				}
2863 2870
 
@@ -2892,14 +2899,14 @@  discard block
 block discarded – undo
2892 2899
 		foreach($default_where_conditions as $key => $val){
2893 2900
 			if( isset($provided_where_conditions[$key])){
2894 2901
 				$none_overridden = false;
2895
-			}else{
2902
+			} else{
2896 2903
 				$null_friendly_where_conditions[$or_condition_key_for_defaults]['AND'][$key] = $val;
2897 2904
 			}
2898 2905
 		}
2899 2906
 		if( $none_overridden && $default_where_conditions){
2900 2907
 			if($model->has_primary_key_field()){
2901 2908
 				$null_friendly_where_conditions[$or_condition_key_for_defaults][$model_relation_path.".".$model->primary_key_name()] = array('IS NULL');
2902
-			}else{
2909
+			} else{
2903 2910
 				//@todo NO PK, use other defaults
2904 2911
 			}
2905 2912
 		}
@@ -2915,8 +2922,9 @@  discard block
 block discarded – undo
2915 2922
 	 * @return array like EEM_Base::get_all's $query_params[0] (where conditions)
2916 2923
 	 */
2917 2924
 	protected function _get_default_where_conditions($model_relation_path = null){
2918
-		if ( $this->_ignore_where_strategy )
2919
-			return array();
2925
+		if ( $this->_ignore_where_strategy ) {
2926
+					return array();
2927
+		}
2920 2928
 
2921 2929
 		return $this->_default_where_conditions_strategy->get_default_where_conditions($model_relation_path);
2922 2930
 	}
@@ -2931,8 +2939,9 @@  discard block
 block discarded – undo
2931 2939
 	 * @return array like EEM_Base::get_all's $query_params[0] (where conditions)
2932 2940
 	 */
2933 2941
 	protected function _get_minimum_where_conditions($model_relation_path = null){
2934
-		if ( $this->_ignore_where_strategy )
2935
-			return array();
2942
+		if ( $this->_ignore_where_strategy ) {
2943
+					return array();
2944
+		}
2936 2945
 
2937 2946
 		return $this->_minimum_where_conditions_strategy->get_default_where_conditions($model_relation_path);
2938 2947
 	}
@@ -3006,7 +3015,7 @@  discard block
 block discarded – undo
3006 3015
 		if(array_key_exists($query_param,$this_model_fields)){
3007 3016
 			if($allow_fields){
3008 3017
 				return;
3009
-			}else{
3018
+			} else{
3010 3019
 				throw new EE_Error(sprintf(__("Using a field name (%s) on model %s is not allowed on this query param type '%s'. Original query param was %s", "event_espresso"),
3011 3020
 						$query_param,get_class($this),$query_param_type,$original_query_param));
3012 3021
 			}
@@ -3015,7 +3024,7 @@  discard block
 block discarded – undo
3015 3024
 		elseif(in_array($query_param, $this->_logic_query_param_keys, TRUE)){
3016 3025
 			if($allow_logic_query_params){
3017 3026
 				return;
3018
-			}else{
3027
+			} else{
3019 3028
 				throw new EE_Error(
3020 3029
 					sprintf(
3021 3030
 						__( 'Logic query params ("%1$s") are being used incorrectly with the following query param ("%2$s") on model %3$s. %4$sAdditional Info:%4$s%5$s', 'event_espresso' ),
@@ -3046,12 +3055,12 @@  discard block
 block discarded – undo
3046 3055
 					//we should actually end in a field name, not a model like this!
3047 3056
 					throw new EE_Error(sprintf(__("Query param '%s' (of type %s on model %s) shouldn't end on a period (.) ", "event_espresso"),
3048 3057
 					$query_param,$query_param_type,get_class($this),$valid_related_model_name));
3049
-				}else{
3058
+				} else{
3050 3059
 					$related_model_obj = $this->get_related_model_obj($valid_related_model_name);
3051 3060
 					$related_model_obj->_extract_related_model_info_from_query_param($query_param, $passed_in_query_info, $query_param_type, $original_query_param);
3052 3061
 					return;
3053 3062
 				}
3054
-			}elseif($query_param == $valid_related_model_name){
3063
+			} elseif($query_param == $valid_related_model_name){
3055 3064
 				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info,$original_query_param);
3056 3065
 				return;
3057 3066
 			}
@@ -3111,7 +3120,7 @@  discard block
 block discarded – undo
3111 3120
 		$SQL = $this->_construct_condition_clause_recursive($where_params, ' AND ');
3112 3121
 		if($SQL){
3113 3122
 			return " WHERE ". $SQL;
3114
-		}else{
3123
+		} else{
3115 3124
 			return '';
3116 3125
 		}
3117 3126
 	}
@@ -3126,7 +3135,7 @@  discard block
 block discarded – undo
3126 3135
 		$SQL = $this->_construct_condition_clause_recursive($having_params, ' AND ');
3127 3136
 		if($SQL){
3128 3137
 			return " HAVING ". $SQL;
3129
-		}else{
3138
+		} else{
3130 3139
 			return '';
3131 3140
 		}
3132 3141
 
@@ -3149,7 +3158,7 @@  discard block
 block discarded – undo
3149 3158
 			$model_instance=call_user_func($model_name."::instance");
3150 3159
 			/* @var $model_instance EEM_Base */
3151 3160
 			return $model_instance->field_settings_for($field_name);
3152
-		}else{
3161
+		} else{
3153 3162
 			throw new EE_Error(sprintf(__('No model named %s exists, with classname %s and filepath %s','event_espresso'),$model_name,$model_class,$model_filepath));
3154 3163
 		}
3155 3164
 	}
@@ -3182,14 +3191,14 @@  discard block
 block discarded – undo
3182 3191
 						$where_clauses[] = " (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' OR ') .")";
3183 3192
 						break;
3184 3193
 				}
3185
-			}else{
3194
+			} else{
3186 3195
 				$field_obj = $this->_deduce_field_from_query_param($query_param);
3187 3196
 
3188 3197
 				//if it's not a normal field, maybe it's a custom selection?
3189 3198
 				if( ! $field_obj){
3190 3199
 					if(isset( $this->_custom_selections[$query_param][1])){
3191 3200
 						$field_obj = $this->_custom_selections[$query_param][1];
3192
-					}else{
3201
+					} else{
3193 3202
 						throw new EE_Error(sprintf(__("%s is neither a valid model field name, nor a custom selection", "event_espresso"),$query_param));
3194 3203
 					}
3195 3204
 				}
@@ -3199,7 +3208,7 @@  discard block
 block discarded – undo
3199 3208
 		}
3200 3209
 		if($where_clauses){
3201 3210
 			$SQL = implode($glue,$where_clauses);
3202
-		}else{
3211
+		} else{
3203 3212
 			$SQL = '';
3204 3213
 		}
3205 3214
 		return $SQL;
@@ -3219,11 +3228,11 @@  discard block
 block discarded – undo
3219 3228
 		if( $field ){
3220 3229
 			$table_alias_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_from_query_param( $field->get_model_name(), $query_param );
3221 3230
 			return $table_alias_prefix . $field->get_qualified_column();
3222
-		}elseif(array_key_exists($query_param,$this->_custom_selections)){
3231
+		} elseif(array_key_exists($query_param,$this->_custom_selections)){
3223 3232
 			//maybe it's custom selection item?
3224 3233
 			//if so, just use it as the "column name"
3225 3234
 			return $query_param;
3226
-		}else{
3235
+		} else{
3227 3236
 			throw new EE_Error(sprintf(__("%s is not a valid field on this model, nor a custom selection (%s)", "event_espresso"),$query_param,implode(",",$this->_custom_selections)));
3228 3237
 		}
3229 3238
 	}
@@ -3240,7 +3249,7 @@  discard block
 block discarded – undo
3240 3249
 		$pos_of_star = strpos($condition_query_param_key, '*');
3241 3250
 		if($pos_of_star === FALSE){
3242 3251
 			return $condition_query_param_key;
3243
-		}else{
3252
+		} else{
3244 3253
 			$condition_query_param_sans_star = substr($condition_query_param_key, 0, $pos_of_star);
3245 3254
 			return $condition_query_param_sans_star;
3246 3255
 		}
@@ -3266,7 +3275,7 @@  discard block
 block discarded – undo
3266 3275
 				throw new EE_Error(sprintf(__("You setup a query parameter like you were going to specify an operator, but didn't. You provided '(%s)', but the operator should be at array key index 0 (eg array('>',32))", "event_espresso"), implode(",",$php_array_like_string)));
3267 3276
 			}
3268 3277
 			$value = isset($op_and_value[1]) ? $op_and_value[1] : null;
3269
-		}else{
3278
+		} else{
3270 3279
 			$operator = '=';
3271 3280
 			$value = $op_and_value;
3272 3281
 		}
@@ -3274,7 +3283,7 @@  discard block
 block discarded – undo
3274 3283
 		//check to see if the value is actually another field
3275 3284
 		if(is_array($op_and_value) && isset($op_and_value[2]) && $op_and_value[2] == true){
3276 3285
 			return $operator.SP.$this->_deduce_column_name_from_query_param($value);
3277
-		}elseif(in_array($operator, $this->_in_style_operators) && is_array($value)){
3286
+		} elseif(in_array($operator, $this->_in_style_operators) && is_array($value)){
3278 3287
 			//in this case, the value should be an array, or at least a comma-separated list
3279 3288
 			//it will need to handle a little differently
3280 3289
 			$cleaned_value = $this->_construct_in_value($value, $field_obj);
@@ -3282,8 +3291,9 @@  discard block
 block discarded – undo
3282 3291
 			return $operator.SP.$cleaned_value;
3283 3292
 		} elseif( in_array( $operator, $this->_between_style_operators ) && is_array( $value ) ) {
3284 3293
 			//the value should be an array with count of two.
3285
-			if ( count($value) !== 2 )
3286
-				throw new EE_Error( sprintf( __("The '%s' operator must be used with an array of values and there must be exactly TWO values in that array.", 'event_espresso'), "BETWEEN" ) );
3294
+			if ( count($value) !== 2 ) {
3295
+							throw new EE_Error( sprintf( __("The '%s' operator must be used with an array of values and there must be exactly TWO values in that array.", 'event_espresso'), "BETWEEN" ) );
3296
+			}
3287 3297
 			$cleaned_value = $this->_construct_between_value( $value, $field_obj );
3288 3298
 			return $operator.SP.$cleaned_value;
3289 3299
 		} elseif( in_array( $operator, $this->_null_style_operators ) ) {
@@ -3291,17 +3301,17 @@  discard block
 block discarded – undo
3291 3301
 				throw new EE_Error(sprintf(__("You attempted to give a value  (%s) while using a NULL-style operator (%s). That isn't valid", "event_espresso"),$value,$operator));
3292 3302
 			}
3293 3303
 			return $operator;
3294
-		}elseif( $operator == 'LIKE' && ! is_array($value)){
3304
+		} elseif( $operator == 'LIKE' && ! is_array($value)){
3295 3305
 			//if the operator is 'LIKE', we want to allow percent signs (%) and not
3296 3306
 			//remove other junk. So just treat it as a string.
3297 3307
 			return $operator.SP.$this->_wpdb_prepare_using_field($value, '%s');
3298
-		}elseif( ! in_array($operator, $this->_in_style_operators) && ! is_array($value)){
3308
+		} elseif( ! in_array($operator, $this->_in_style_operators) && ! is_array($value)){
3299 3309
 			return $operator.SP.$this->_wpdb_prepare_using_field($value,$field_obj);
3300
-		}elseif(in_array($operator, $this->_in_style_operators) && ! is_array($value)){
3310
+		} elseif(in_array($operator, $this->_in_style_operators) && ! is_array($value)){
3301 3311
 			throw new EE_Error(sprintf(__("Operator '%s' must be used with an array of values, eg 'Registration.REG_ID' => array('%s',array(1,2,3))",'event_espresso'),$operator, $operator));
3302
-		}elseif( ! in_array($operator, $this->_in_style_operators) && is_array($value)){
3312
+		} elseif( ! in_array($operator, $this->_in_style_operators) && is_array($value)){
3303 3313
 			throw new EE_Error(sprintf(__("Operator '%s' must be used with a single value, not an array. Eg 'Registration.REG_ID => array('%s',23))",'event_espresso'),$operator,$operator));
3304
-		}else{
3314
+		} else{
3305 3315
 			throw new EE_Error(sprintf(__("It appears you've provided some totally invalid query parameters. Operator and value were:'%s', which isn't right at all", "event_espresso"),  http_build_query($op_and_value)));
3306 3316
 		}
3307 3317
 	}
@@ -3371,7 +3381,7 @@  discard block
 block discarded – undo
3371 3381
 		global $wpdb;
3372 3382
 		if($field_obj instanceof EE_Model_Field_Base){
3373 3383
 			return $wpdb->prepare($field_obj->get_wpdb_data_type(),$this->_prepare_value_for_use_in_db($value, $field_obj));
3374
-		}else{//$field_obj should really just be a data type
3384
+		} else{//$field_obj should really just be a data type
3375 3385
 			if( ! in_array($field_obj,$this->_valid_wpdb_data_types)){
3376 3386
 				throw new EE_Error(sprintf(__("%s is not a valid wpdb datatype. Valid ones are %s", "event_espresso"),$field_obj,implode(",",$this->_valid_wpdb_data_types)));
3377 3387
 			}
@@ -3400,14 +3410,14 @@  discard block
 block discarded – undo
3400 3410
 		if($number_of_parts == 1){
3401 3411
 			$field_name = $last_query_param_part;
3402 3412
 			$model_obj = $this;
3403
-		}else{// $number_of_parts >= 2
3413
+		} else{// $number_of_parts >= 2
3404 3414
 			//the last part is the column name, and there are only 2parts. therefore...
3405 3415
 			$field_name = $last_query_param_part;
3406 3416
 			$model_obj = $this->get_related_model_obj( $query_param_parts[ $number_of_parts - 2 ]);
3407 3417
 		}
3408 3418
 		try{
3409 3419
 			return $model_obj->field_settings_for($field_name);
3410
-		}catch(EE_Error $e){
3420
+		} catch(EE_Error $e){
3411 3421
 			return null;
3412 3422
 		}
3413 3423
 	}
@@ -3426,7 +3436,7 @@  discard block
 block discarded – undo
3426 3436
 		$field = isset($all_fields[$field_name]) ? $all_fields[$field_name] : FALSE;
3427 3437
 		if($field){
3428 3438
 			return $field->get_qualified_column();
3429
-		}else{
3439
+		} else{
3430 3440
 			throw new EE_Error(sprintf(__("There is no field titled %s on model %s. Either the query trying to use it is bad, or you need to add it to the list of fields on the model.",'event_espresso'),$field_name,get_class($this)));
3431 3441
 		}
3432 3442
 	}
@@ -3492,7 +3502,7 @@  discard block
 block discarded – undo
3492 3502
 					//the FROM statement, BUT the primary table isn't. So we want
3493 3503
 					//to add the inverse join sql
3494 3504
 					$SQL .= $table_obj->get_inverse_join_sql($alias_prefixed);
3495
-				}else{
3505
+				} else{
3496 3506
 					//just add a regular JOIN to this table from the primary table
3497 3507
 					$SQL .= $table_obj->get_join_sql($alias_prefixed);
3498 3508
 				}
@@ -3607,7 +3617,7 @@  discard block
 block discarded – undo
3607 3617
 		$fieldSettings = $this->field_settings(true);
3608 3618
 		if( isset($fieldSettings[$fieldName])){
3609 3619
 			return true;
3610
-		}else{
3620
+		} else{
3611 3621
 			return false;
3612 3622
 		}
3613 3623
 	}
@@ -3621,7 +3631,7 @@  discard block
 block discarded – undo
3621 3631
 		$relations = $this->relation_settings();
3622 3632
 		if(isset($relations[$relation_name])){
3623 3633
 			return true;
3624
-		}else{
3634
+		} else{
3625 3635
 			return false;
3626 3636
 		}
3627 3637
 	}
@@ -3672,7 +3682,7 @@  discard block
 block discarded – undo
3672 3682
 			try{
3673 3683
 				$this->get_primary_key_field();
3674 3684
 				$this->_has_primary_key_field = true;
3675
-			}catch(EE_Error $e){
3685
+			} catch(EE_Error $e){
3676 3686
 				$this->_has_primary_key_field = false;
3677 3687
 			}
3678 3688
 		}
@@ -3751,7 +3761,7 @@  discard block
 block discarded – undo
3751 3761
 				}
3752 3762
 			}
3753 3763
 			return $this->_cached_fields;
3754
-		}else{
3764
+		} else{
3755 3765
 			if( $this->_cached_fields_non_db_only === NULL ){
3756 3766
 				$this->_cached_fields_non_db_only = array();
3757 3767
 				foreach($this->_fields as $fields_corresponding_to_table){
@@ -3894,7 +3904,7 @@  discard block
 block discarded – undo
3894 3904
 			if(empty( $this_model_fields_n_values[$this->primary_key_name()] )){
3895 3905
 				return NULL;
3896 3906
 			}
3897
-		}else if($this->unique_indexes()){
3907
+		} else if($this->unique_indexes()){
3898 3908
 			$first_column = reset($this_model_fields_n_values);
3899 3909
 			if(empty($first_column)){
3900 3910
 				return NULL;
@@ -3909,7 +3919,7 @@  discard block
 block discarded – undo
3909 3919
 				// add this new object to the entity map
3910 3920
 				$classInstance = $this->add_to_entity_map( $classInstance );
3911 3921
 			}
3912
-		}else{
3922
+		} else{
3913 3923
 			$classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_n_values, $this->_timezone ), TRUE, FALSE );
3914 3924
 		}
3915 3925
 
@@ -3996,11 +4006,12 @@  discard block
 block discarded – undo
3996 4006
 						$this_model_fields_n_values[$field_name] = $field_obj->prepare_for_use_in_db( $prepared_value );
3997 4007
 					}
3998 4008
 				}
3999
-			}else{
4009
+			} else{
4000 4010
 				//the table's rows existed. Use their values
4001 4011
 				foreach( $this->_get_fields_for_table( $table_alias ) as $field_name => $field_obj ) {
4002
-					if( ! $field_obj->is_db_only_field() )
4003
-					$this_model_fields_n_values[$field_name] = $this->_get_column_value_with_table_alias_or_not($cols_n_values, $field_obj->get_qualified_column(), $field_obj->get_table_column() );
4012
+					if( ! $field_obj->is_db_only_field() ) {
4013
+										$this_model_fields_n_values[$field_name] = $this->_get_column_value_with_table_alias_or_not($cols_n_values, $field_obj->get_qualified_column(), $field_obj->get_table_column() );
4014
+					}
4004 4015
 				}
4005 4016
 			}
4006 4017
 		}
@@ -4014,9 +4025,9 @@  discard block
 block discarded – undo
4014 4025
 		if( isset( $cols_n_values[ $qualified_column ] ) ){
4015 4026
 			$value = $cols_n_values[ $qualified_column ];
4016 4027
 
4017
-		}elseif( isset( $cols_n_values[ $regular_column ] ) ){
4028
+		} elseif( isset( $cols_n_values[ $regular_column ] ) ){
4018 4029
 			$value = $cols_n_values[ $regular_column ];
4019
-		}else{
4030
+		} else{
4020 4031
 			$value = NULL;
4021 4032
 		}
4022 4033
 
@@ -4049,7 +4060,7 @@  discard block
 block discarded – undo
4049 4060
 				}
4050 4061
 			}
4051 4062
 			return $obj_in_map;
4052
-		}else{
4063
+		} else{
4053 4064
 			return $this->get_one_by_ID( $id );
4054 4065
 		}
4055 4066
 	}
@@ -4084,7 +4095,7 @@  discard block
 block discarded – undo
4084 4095
 				}
4085 4096
 			}
4086 4097
 			return $obj_in_map;
4087
-		}else{
4098
+		} else{
4088 4099
 			$this->add_to_entity_map( $replacing_model_obj );
4089 4100
 			return $replacing_model_obj;
4090 4101
 		}
@@ -4114,7 +4125,7 @@  discard block
 block discarded – undo
4114 4125
 	public function item_name($quantity = 1){
4115 4126
 		if($quantity == 1){
4116 4127
 			return $this->singular_item;
4117
-		}else{
4128
+		} else{
4118 4129
 			return $this->plural_item;
4119 4130
 		}
4120 4131
 	}
@@ -4176,14 +4187,14 @@  discard block
 block discarded – undo
4176 4187
 		$primary_key_field = $this->get_primary_key_field();
4177 4188
 		if( $base_class_obj_or_id instanceof $className ){
4178 4189
 			$model_object = $base_class_obj_or_id;
4179
-		}elseif( $primary_key_field instanceof EE_Primary_Key_Int_Field && (
4190
+		} elseif( $primary_key_field instanceof EE_Primary_Key_Int_Field && (
4180 4191
 				is_int( $base_class_obj_or_id ) ||
4181 4192
 				is_string( $base_class_obj_or_id ) )){//assume it's an ID. either a proper integer or a string representing an integer (eg "101" instead of 101)
4182 4193
 			$model_object = $this->get_one_by_ID($base_class_obj_or_id);
4183
-		}elseif( $primary_key_field instanceof EE_Primary_Key_String_Field && is_string($base_class_obj_or_id) ){
4194
+		} elseif( $primary_key_field instanceof EE_Primary_Key_String_Field && is_string($base_class_obj_or_id) ){
4184 4195
 			//assume its a string representation of the object
4185 4196
 			$model_object = $this->get_one_by_ID($base_class_obj_or_id);
4186
-		}else{
4197
+		} else{
4187 4198
 			throw new EE_Error(sprintf(__("'%s' is neither an object of type %s, nor an ID! Its full value is '%s'",'event_espresso'),$base_class_obj_or_id,$this->_get_class_name(),print_r($base_class_obj_or_id,true)));
4188 4199
 		}
4189 4200
 		if( $model_object->ID() == NULL && $ensure_is_in_db){
@@ -4207,13 +4218,13 @@  discard block
 block discarded – undo
4207 4218
 		if( $base_class_obj_or_id instanceof $className ){
4208 4219
 			/** @var $base_class_obj_or_id EE_Base_Class */
4209 4220
 			$id = $base_class_obj_or_id->ID();
4210
-		}elseif(is_int($base_class_obj_or_id)){
4221
+		} elseif(is_int($base_class_obj_or_id)){
4211 4222
 			//assume it's an ID
4212 4223
 			$id = $base_class_obj_or_id;
4213
-		}elseif(is_string($base_class_obj_or_id)){
4224
+		} elseif(is_string($base_class_obj_or_id)){
4214 4225
 			//assume its a string representation of the object
4215 4226
 			$id = $base_class_obj_or_id;
4216
-		}else{
4227
+		} else{
4217 4228
 			throw new EE_Error(sprintf(__("'%s' is neither an object of type %s, nor an ID! Its full value is '%s'",'event_espresso'),$base_class_obj_or_id,$this->_get_class_name(),print_r($base_class_obj_or_id,true)));
4218 4229
 		}
4219 4230
 		return $id;
@@ -4344,9 +4355,9 @@  discard block
 block discarded – undo
4344 4355
 
4345 4356
 		if($model_object_or_attributes_array instanceof EE_Base_Class){
4346 4357
 			$attributes_array = $model_object_or_attributes_array->model_field_array();
4347
-		}elseif(is_array($model_object_or_attributes_array)){
4358
+		} elseif(is_array($model_object_or_attributes_array)){
4348 4359
 			$attributes_array = $model_object_or_attributes_array;
4349
-		}else{
4360
+		} else{
4350 4361
 			throw new EE_Error(sprintf(__("get_all_copies should be provided with either a model object or an array of field-value-pairs, but was given %s", "event_espresso"),$model_object_or_attributes_array));
4351 4362
 		}
4352 4363
 		//even copies obviously won't have the same ID, so remove the primary key
@@ -4356,7 +4367,7 @@  discard block
 block discarded – undo
4356 4367
 		}
4357 4368
 		if(isset($query_params[0])){
4358 4369
 			$query_params[0] = array_merge($attributes_array,$query_params);
4359
-		}else{
4370
+		} else{
4360 4371
 			$query_params[0] = $attributes_array;
4361 4372
 		}
4362 4373
 		return $this->get_all($query_params);
@@ -4379,7 +4390,7 @@  discard block
 block discarded – undo
4379 4390
 		$copies = $this->get_all_copies($model_object_or_attributes_array,$query_params);
4380 4391
 		if(is_array($copies)){
4381 4392
 			return array_shift($copies);
4382
-		}else{
4393
+		} else{
4383 4394
 			return null;
4384 4395
 		}
4385 4396
 	}
@@ -4411,7 +4422,7 @@  discard block
 block discarded – undo
4411 4422
 		$sql_operator = isset($this->_valid_operators[$operator_supplied]) ? $this->_valid_operators[$operator_supplied] : null;
4412 4423
 		if($sql_operator){
4413 4424
 			return $sql_operator;
4414
-		}else{
4425
+		} else{
4415 4426
 			throw new EE_Error(sprintf(__("The operator '%s' is not in the list of valid operators: %s", "event_espresso"),$operator_supplied,implode(",",array_keys($this->_valid_operators))));
4416 4427
 		}
4417 4428
 	}
@@ -4582,7 +4593,7 @@  discard block
 block discarded – undo
4582 4593
 		$valid_cap_contexts = EEM_Base::valid_cap_contexts();
4583 4594
 		if( in_array( $context, $valid_cap_contexts ) ) {
4584 4595
 			return true;
4585
-		}else{
4596
+		} else{
4586 4597
 			throw new EE_Error(
4587 4598
 				sprintf(
4588 4599
 					__( 'Context "%1$s" passed into model "%2$s" is not a valid context. They are: %3$s', 'event_espresso' ),
Please login to merge, or discard this patch.
admin_pages/registrations/Registrations_Admin_Page.core.php 2 patches
Spacing   +528 added lines, -528 removed lines patch added patch discarded remove patch
@@ -49,8 +49,8 @@  discard block
 block discarded – undo
49 49
 	 * @param bool $routing
50 50
 	 * @return Registrations_Admin_Page
51 51
 	 */
52
-	public function __construct( $routing = TRUE ) {
53
-		parent::__construct( $routing );
52
+	public function __construct($routing = TRUE) {
53
+		parent::__construct($routing);
54 54
 	}
55 55
 
56 56
 
@@ -82,16 +82,16 @@  discard block
 block discarded – undo
82 82
 				'trash' => 'post.php'
83 83
 			);
84 84
 
85
-		add_action('edit_form_after_title', array($this, 'after_title_form_fields'), 10 );
85
+		add_action('edit_form_after_title', array($this, 'after_title_form_fields'), 10);
86 86
 		//add filters so that the comment urls don't take users to a confusing 404 page
87
-		add_filter('get_comment_link', array( $this, 'clear_comment_link' ), 10, 3 );
87
+		add_filter('get_comment_link', array($this, 'clear_comment_link'), 10, 3);
88 88
 	}
89 89
 
90 90
 
91
-	public function clear_comment_link( $link, $comment, $args ) {
91
+	public function clear_comment_link($link, $comment, $args) {
92 92
 		//gotta make sure this only happens on this route
93
-		$post_type = get_post_type( $comment->comment_post_ID);
94
-		if ( $post_type == 'espresso_attendees' )
93
+		$post_type = get_post_type($comment->comment_post_ID);
94
+		if ($post_type == 'espresso_attendees')
95 95
 			return '#commentsdiv';
96 96
 		return $link;
97 97
 	}
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 
100 100
 	protected function _ajax_hooks() {
101 101
 		//todo: all hooks for registrations ajax goes in here
102
-		add_action( 'wp_ajax_toggle_checkin_status', array( $this, 'toggle_checkin_status' ));
102
+		add_action('wp_ajax_toggle_checkin_status', array($this, 'toggle_checkin_status'));
103 103
 	}
104 104
 
105 105
 
@@ -114,8 +114,8 @@  discard block
 block discarded – undo
114 114
 					'add-attendee' => __('Add Contact', 'event_espresso'),
115 115
 					'edit' => __('Edit Contact', 'event_espresso'),
116 116
 					'report'=>  __("Event Registrations CSV Report", "event_espresso"),
117
-					'report_all' => __( 'All Registrations CSV Report', 'event_espresso' ),
118
-					'contact_list_report' => __( 'Contact List Report', 'event_espresso' ),
117
+					'report_all' => __('All Registrations CSV Report', 'event_espresso'),
118
+					'contact_list_report' => __('Contact List Report', 'event_espresso'),
119 119
 					'contact_list_export'=>  __("Export Data", "event_espresso"),
120 120
 				),
121 121
 			'publishbox' => array(
@@ -143,9 +143,9 @@  discard block
 block discarded – undo
143 143
 
144 144
 		$this->_get_registration_status_array();
145 145
 
146
-		$reg_id = ! empty( $this->_req_data['_REG_ID'] ) && ! is_array( $this->_req_data['_REG_ID'] ) ? $this->_req_data['_REG_ID'] : 0;
147
-		$att_id = ! empty( $this->_req_data[ 'ATT_ID' ] ) && ! is_array( $this->_req_data['ATT_ID'] ) ? $this->_req_data['ATT_ID'] : 0;
148
-		$att_id = ! empty( $this->_req_data['post'] ) && ! is_array( $this->_req_data['post'] ) ? $this->_req_data['post'] : $att_id;
146
+		$reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0;
147
+		$att_id = ! empty($this->_req_data['ATT_ID']) && ! is_array($this->_req_data['ATT_ID']) ? $this->_req_data['ATT_ID'] : 0;
148
+		$att_id = ! empty($this->_req_data['post']) && ! is_array($this->_req_data['post']) ? $this->_req_data['post'] : $att_id;
149 149
 
150 150
 		$this->_page_routes = array(
151 151
 
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 
179 179
 				'restore_registrations' => array(
180 180
 					'func' => '_trash_or_restore_registrations',
181
-					'args' => array( 'trash' => FALSE ),
181
+					'args' => array('trash' => FALSE),
182 182
 					'noheader' => TRUE,
183 183
 					'capability' => 'ee_delete_registrations'
184 184
 					),
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
 						'filename' => 'registrations_overview_other'
406 406
 					)
407 407
                 ),
408
-				'help_tour' => array( 'Registration_Overview_Help_Tour' ),
408
+				'help_tour' => array('Registration_Overview_Help_Tour'),
409 409
 				'qtips' => array('Registration_List_Table_Tips'),
410 410
 				'list_table' => 'EE_Registrations_List_Table',
411 411
 				'require_nonce' => FALSE
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
 				'nav' => array(
416 416
 					'label' => __('REG Details', 'event_espresso'),
417 417
 					'order' => 15,
418
-					'url' => isset($this->_req_data['_REG_ID']) ? add_query_arg(array('_REG_ID' => $this->_req_data['_REG_ID'] ), $this->_current_page_view_url )  : $this->_admin_base_url,
418
+					'url' => isset($this->_req_data['_REG_ID']) ? add_query_arg(array('_REG_ID' => $this->_req_data['_REG_ID']), $this->_current_page_view_url) : $this->_admin_base_url,
419 419
 					'persistent' => FALSE
420 420
 					),
421 421
                 'help_tabs' => array(
@@ -436,8 +436,8 @@  discard block
 block discarded – undo
436 436
 						'filename' => 'registrations_details_registrant_details'
437 437
 						)
438 438
 					),
439
-				'help_tour' => array( 'Registration_Details_Help_Tour' ),
440
-				'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array( '_registration_details_metaboxes' ) ),
439
+				'help_tour' => array('Registration_Details_Help_Tour'),
440
+				'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_registration_details_metaboxes')),
441 441
 				'require_nonce' => FALSE
442 442
 				),
443 443
 
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
 					'order' => 15,
462 462
 					'persistent' => FALSE
463 463
 					),
464
-				'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array('_publish_post_box', 'attendee_editor_metaboxes' ) ),
464
+				'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box', 'attendee_editor_metaboxes')),
465 465
 				'require_nonce' => FALSE
466 466
 				),
467 467
 
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
 					'label' => __('Edit Contact', 'event_espresso'),
471 471
 					'order' => 15,
472 472
 					'persistent' => FALSE,
473
-					'url' => isset($this->_req_data['ATT_ID']) ? add_query_arg(array('ATT_ID' => $this->_req_data['ATT_ID'] ), $this->_current_page_view_url )  : $this->_admin_base_url
473
+					'url' => isset($this->_req_data['ATT_ID']) ? add_query_arg(array('ATT_ID' => $this->_req_data['ATT_ID']), $this->_current_page_view_url) : $this->_admin_base_url
474 474
 					),
475 475
 				'metaboxes' => array('attendee_editor_metaboxes'),
476 476
 				'require_nonce' => FALSE
@@ -500,7 +500,7 @@  discard block
 block discarded – undo
500 500
 						'filename' => 'registrations_contact_list_other'
501 501
 					)
502 502
                 ),
503
-				'help_tour' => array( 'Contact_List_Help_Tour' ),
503
+				'help_tour' => array('Contact_List_Help_Tour'),
504 504
 				'metaboxes' => array(),
505 505
 				'require_nonce' => FALSE
506 506
 				),
@@ -519,7 +519,7 @@  discard block
 block discarded – undo
519 519
 	protected function _add_screen_options() {}
520 520
 	protected function _add_feature_pointers() {}
521 521
 	public function admin_init() {
522
-		EE_Registry::$i18n_js_strings[ 'update_att_qstns' ] = __( 'click "Update Registration Questions" to save your changes', 'event_espresso' );
522
+		EE_Registry::$i18n_js_strings['update_att_qstns'] = __('click "Update Registration Questions" to save your changes', 'event_espresso');
523 523
 	}
524 524
 	public function admin_notices() {}
525 525
 	public function admin_footer_scripts() {}
@@ -537,7 +537,7 @@  discard block
 block discarded – undo
537 537
 	*		@return void
538 538
 	*/
539 539
 	private function _get_registration_status_array() {
540
-		self::$_reg_status = EEM_Registration::reg_status_array( array(), TRUE);
540
+		self::$_reg_status = EEM_Registration::reg_status_array(array(), TRUE);
541 541
 	}
542 542
 
543 543
 
@@ -560,11 +560,11 @@  discard block
 block discarded – undo
560 560
 	public function load_scripts_styles() {
561 561
 		//style
562 562
 		//wp_register_style('espresso_attendees', ATT_ASSETS_URL . 'espresso_attendees_admin.css', array(), EVENT_ESPRESSO_VERSION );
563
-		wp_register_style('espresso_reg', REG_ASSETS_URL . 'espresso_registrations_admin.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION );
563
+		wp_register_style('espresso_reg', REG_ASSETS_URL.'espresso_registrations_admin.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION);
564 564
 		wp_enqueue_style('espresso_reg');
565 565
 
566 566
 		//script
567
-		wp_register_script('espresso_reg', REG_ASSETS_URL . 'espresso_registrations_admin.js', array('jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'), EVENT_ESPRESSO_VERSION, TRUE);
567
+		wp_register_script('espresso_reg', REG_ASSETS_URL.'espresso_registrations_admin.js', array('jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'), EVENT_ESPRESSO_VERSION, TRUE);
568 568
 		wp_enqueue_script('espresso_reg');
569 569
 	}
570 570
 
@@ -573,9 +573,9 @@  discard block
 block discarded – undo
573 573
 	public function load_scripts_styles_edit_attendee() {
574 574
 		//stuff to only show up on our attendee edit details page.
575 575
 		$attendee_details_translations = array(
576
-			'att_publish_text' => sprintf( __('Created on: <b>%1$s</b>', 'event_espresso'), $this->_cpt_model_obj->get_datetime('ATT_created') )
576
+			'att_publish_text' => sprintf(__('Created on: <b>%1$s</b>', 'event_espresso'), $this->_cpt_model_obj->get_datetime('ATT_created'))
577 577
 			);
578
-		wp_localize_script( 'espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations );
578
+		wp_localize_script('espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations);
579 579
 		wp_enqueue_script('jquery-validate');
580 580
 	}
581 581
 
@@ -584,8 +584,8 @@  discard block
 block discarded – undo
584 584
 		//styles
585 585
 		wp_enqueue_style('espresso-ui-theme');
586 586
 		//scripts
587
-		$this->_get_reg_custom_questions_form( $this->_registration->ID() );
588
-		$this->_reg_custom_questions_form->wp_enqueue_scripts( true );
587
+		$this->_get_reg_custom_questions_form($this->_registration->ID());
588
+		$this->_reg_custom_questions_form->wp_enqueue_scripts(true);
589 589
 	}
590 590
 
591 591
 
@@ -595,7 +595,7 @@  discard block
 block discarded – undo
595 595
 
596 596
 	public function load_scripts_styles_contact_list() {
597 597
 		wp_deregister_style('espresso_reg');
598
-		wp_register_style('espresso_att', REG_ASSETS_URL . 'espresso_attendees_admin.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION );
598
+		wp_register_style('espresso_att', REG_ASSETS_URL.'espresso_attendees_admin.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION);
599 599
 		wp_enqueue_style('espresso_att');
600 600
 	}
601 601
 
@@ -604,9 +604,9 @@  discard block
 block discarded – undo
604 604
 
605 605
 
606 606
 	public function load_scripts_styles_new_registration() {
607
-		wp_register_script( 'ee-spco-for-admin', REG_ASSETS_URL . 'spco_for_admin.js', array('underscore', 'jquery'), EVENT_ESPRESSO_VERSION, TRUE );
607
+		wp_register_script('ee-spco-for-admin', REG_ASSETS_URL.'spco_for_admin.js', array('underscore', 'jquery'), EVENT_ESPRESSO_VERSION, TRUE);
608 608
 		wp_enqueue_script('ee-spco-for-admin');
609
-		add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true' );
609
+		add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
610 610
 		EE_Form_Section_Proper::wp_enqueue_scripts();
611 611
 		EED_Ticket_Selector::load_tckt_slctr_assets();
612 612
 		EE_Datepicker_Input::enqueue_styles_and_scripts();
@@ -645,23 +645,23 @@  discard block
 block discarded – undo
645 645
 
646 646
 		/** setup reg status bulk actions **/
647 647
 		$def_reg_status_actions['approve_registration'] = __('Approve Registrations', 'event_espresso');
648
-		if ( in_array( $match_array['approve_registration'], $active_mts ) && EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'batch_send_messages' ) ) {
648
+		if (in_array($match_array['approve_registration'], $active_mts) && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')) {
649 649
 			$def_reg_status_actions['approve_and_notify_registration'] = __('Approve and Notify Registrations', 'event_espresso');
650 650
 		}
651 651
 		$def_reg_status_actions['decline_registration'] = __('Decline Registrations', 'event_espresso');
652
-		if ( in_array( $match_array['decline_registration'], $active_mts ) && EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'batch_send_messages' ) ) {
652
+		if (in_array($match_array['decline_registration'], $active_mts) && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')) {
653 653
 			$def_reg_status_actions['decline_and_notify_registration'] = __('Decline and Notify Registrations', 'event_espresso');
654 654
 		}
655 655
 		$def_reg_status_actions['pending_registration'] = __('Set Registrations to Pending Payment', 'event_espresso');
656
-		if ( in_array( $match_array['pending_registration'], $active_mts ) && EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'batch_send_messages' ) ) {
656
+		if (in_array($match_array['pending_registration'], $active_mts) && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')) {
657 657
 			$def_reg_status_actions['pending_and_notify_registration'] = __('Set Registrations to Pending Payment and Notify', 'event_espresso');
658 658
 		}
659 659
 		$def_reg_status_actions['no_approve_registration'] = __('Set Registrations to Not Approved', 'event_espresso');
660
-		if ( in_array( $match_array['no_approve_registration'], $active_mts ) && EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'batch_send_messages' ) ) {
660
+		if (in_array($match_array['no_approve_registration'], $active_mts) && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')) {
661 661
 			$def_reg_status_actions['no_approve_and_notify_registration'] = __('Set Registrations to Not Approved and Notify', 'event_espresso');
662 662
 		}
663 663
 		$def_reg_status_actions['cancel_registration'] = __('Cancel Registrations', 'event_espresso');
664
-		if ( in_array( $match_array['cancel_registration'], $active_mts ) && EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'batch_send_messages' ) ) {
664
+		if (in_array($match_array['cancel_registration'], $active_mts) && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')) {
665 665
 			$def_reg_status_actions['cancel_and_notify_registration'] = __('Cancel Registrations and Notify', 'event_espresso');
666 666
 		}
667 667
 
@@ -670,29 +670,29 @@  discard block
 block discarded – undo
670 670
 				'slug' => 'all',
671 671
 				'label' => __('View All Registrations', 'event_espresso'),
672 672
 				'count' => 0,
673
-				'bulk_action' => array_merge( $def_reg_status_actions, array(
673
+				'bulk_action' => array_merge($def_reg_status_actions, array(
674 674
 					'trash_registrations' => __('Trash Registrations', 'event_espresso')
675
-					) )
675
+					))
676 676
 				),
677 677
 			'month' => array(
678 678
 				'slug' => 'month',
679 679
 				'label' => __('This Month', 'event_espresso'),
680 680
 				'count' => 0,
681
-				'bulk_action' => array_merge( $def_reg_status_actions, array(
681
+				'bulk_action' => array_merge($def_reg_status_actions, array(
682 682
 					'trash_registrations' => __('Trash Registrations', 'event_espresso')
683 683
 					))
684 684
 				),
685 685
 			'today' => array(
686 686
 				'slug' => 'today',
687
-				'label' => sprintf( __('Today - %s', 'event_espresso'), date('M d, Y', current_time('timestamp' ) ) ),
687
+				'label' => sprintf(__('Today - %s', 'event_espresso'), date('M d, Y', current_time('timestamp'))),
688 688
 				'count' => 0,
689
-				'bulk_action' => array_merge( $def_reg_status_actions,  array(
689
+				'bulk_action' => array_merge($def_reg_status_actions, array(
690 690
 					'trash_registrations' => __('Trash Registrations', 'event_espresso')
691 691
 					))
692 692
 				)
693 693
 			);
694 694
 
695
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_registrations', 'espresso_registrations_delete_registration' ) ) {
695
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registrations', 'espresso_registrations_delete_registration')) {
696 696
 			$this->_views['incomplete'] = array(
697 697
 				'slug' => 'incomplete',
698 698
 				'label' => __('Incomplete', 'event_espresso'),
@@ -728,7 +728,7 @@  discard block
 block discarded – undo
728 728
 				)
729 729
 			);
730 730
 
731
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_contacts', 'espresso_registrations_trash_attendees' ) ) {
731
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_contacts', 'espresso_registrations_trash_attendees')) {
732 732
 			$this->_views['trash'] = array(
733 733
 				'slug' => 'trash',
734 734
 				'label' => __('Trash', 'event_espresso'),
@@ -767,42 +767,42 @@  discard block
 block discarded – undo
767 767
 				'desc' => __('View Transaction Invoice', 'event_espresso')
768 768
 				),
769 769
  			);
770
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'espresso_registrations_resend_registration' ) ) {
770
+		if (EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'espresso_registrations_resend_registration')) {
771 771
 			$fc_items['resend_registration'] = array(
772 772
 				'class' => 'dashicons dashicons-email-alt',
773 773
 				'desc' => __('Resend Registration Details', 'event_espresso')
774 774
 				);
775 775
 		} else {
776
-			$fc_items['blank'] = array( 'class' => 'blank', 'desc' => '' );
776
+			$fc_items['blank'] = array('class' => 'blank', 'desc' => '');
777 777
 		}
778 778
 
779 779
 		$sc_items = array(
780 780
 			'approved_status' => array(
781
-				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved,
782
-				'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_approved, FALSE, 'sentence' )
781
+				'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_approved,
782
+				'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_approved, FALSE, 'sentence')
783 783
 				),
784 784
 			'pending_status' => array(
785
-				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment,
786
-				'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_pending_payment, FALSE, 'sentence' )
785
+				'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_pending_payment,
786
+				'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, FALSE, 'sentence')
787 787
 				),
788 788
 			'incomplete_status' => array(
789
-				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete,
790
-				'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_incomplete, FALSE, 'sentence' )
789
+				'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_incomplete,
790
+				'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_incomplete, FALSE, 'sentence')
791 791
 			),
792 792
 			'not_approved' => array(
793
-				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved,
794
-				'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_not_approved, FALSE, 'sentence' )
793
+				'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_not_approved,
794
+				'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, FALSE, 'sentence')
795 795
 				),
796 796
 			'declined_status' => array(
797
-				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined,
798
-				'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_declined, FALSE, 'sentence' )
797
+				'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_declined,
798
+				'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_declined, FALSE, 'sentence')
799 799
 				),
800 800
 			'cancelled_status' => array(
801
-				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled,
802
-				'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_cancelled, FALSE, 'sentence' )
801
+				'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_cancelled,
802
+				'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, FALSE, 'sentence')
803 803
 				)
804 804
 			);
805
-		return array_merge( $fc_items, $sc_items );
805
+		return array_merge($fc_items, $sc_items);
806 806
 	}
807 807
 
808 808
 
@@ -815,15 +815,15 @@  discard block
 block discarded – undo
815 815
 
816 816
 
817 817
 	protected function _registrations_overview_list_table() {
818
-		$EVT_ID = ( ! empty( $this->_req_data['event_id'] )) ? absint( $this->_req_data['event_id'] ) : FALSE;
819
-		if ( $EVT_ID ) {
820
-			if ( EE_Registry::instance()->CAP->current_user_can( 'ee_edit_registrations', 'espresso_registrations_new_registration', $EVT_ID ) ) {
821
-				$this->_admin_page_title .= $this->get_action_link_or_button( 'new_registration', 'add-registrant', array( 'event_id' => $EVT_ID ), 'add-new-h2' );
818
+		$EVT_ID = ( ! empty($this->_req_data['event_id'])) ? absint($this->_req_data['event_id']) : FALSE;
819
+		if ($EVT_ID) {
820
+			if (EE_Registry::instance()->CAP->current_user_can('ee_edit_registrations', 'espresso_registrations_new_registration', $EVT_ID)) {
821
+				$this->_admin_page_title .= $this->get_action_link_or_button('new_registration', 'add-registrant', array('event_id' => $EVT_ID), 'add-new-h2');
822 822
 			}
823
-			$event = EEM_Event::instance()->get_one_by_ID( $EVT_ID );
824
-			$this->_template_args['admin_page_header'] = $event instanceof EE_Event ? sprintf( __('%s Viewing registrations for the event: %s%s', 'event_espresso'), '<h2>', '<a href="' . EE_Admin_Page::add_query_args_and_nonce( array('action' => 'edit', 'post' => $event->ID() ), EVENTS_ADMIN_URL ) . '">' . $event->get('EVT_name') . '</a>', '</h2>' ) : '';
823
+			$event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
824
+			$this->_template_args['admin_page_header'] = $event instanceof EE_Event ? sprintf(__('%s Viewing registrations for the event: %s%s', 'event_espresso'), '<h2>', '<a href="'.EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit', 'post' => $event->ID()), EVENTS_ADMIN_URL).'">'.$event->get('EVT_name').'</a>', '</h2>') : '';
825 825
 		}
826
-		$this->_template_args['after_list_table'] = $this->_display_legend( $this->_registration_legend_items() );
826
+		$this->_template_args['after_list_table'] = $this->_display_legend($this->_registration_legend_items());
827 827
 		$this->display_admin_list_table_page_with_no_sidebar();
828 828
 	}
829 829
 
@@ -838,19 +838,19 @@  discard block
 block discarded – undo
838 838
 	 */
839 839
 	private function _set_registration_object() {
840 840
 		//get out if we've already set the object
841
-		if ( is_object( $this->_registration )) {
841
+		if (is_object($this->_registration)) {
842 842
 			return TRUE;
843 843
 		}
844 844
 
845 845
 	    $REG = EEM_Registration::instance();
846 846
 
847
-		$REG_ID = ( ! empty( $this->_req_data['_REG_ID'] )) ? absint( $this->_req_data['_REG_ID'] ) : FALSE;
847
+		$REG_ID = ( ! empty($this->_req_data['_REG_ID'])) ? absint($this->_req_data['_REG_ID']) : FALSE;
848 848
 
849
-		if ( $this->_registration = $REG->get_one_by_ID( $REG_ID ))
849
+		if ($this->_registration = $REG->get_one_by_ID($REG_ID))
850 850
 			return TRUE;
851 851
 		else {
852
-			$error_msg = sprintf( __('An error occurred and the details for Registration ID #%s could not be retrieved.', 'event_espresso'), $REG_ID );
853
-			EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ );
852
+			$error_msg = sprintf(__('An error occurred and the details for Registration ID #%s could not be retrieved.', 'event_espresso'), $REG_ID);
853
+			EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
854 854
 			$this->_registration = NULL;
855 855
 			return FALSE;
856 856
 		}
@@ -869,25 +869,25 @@  discard block
 block discarded – undo
869 869
 	 * @internal param bool $all whether to ignore all query params and just return ALL registrations (or count if count is set)
870 870
 	 * @return mixed (int|array)  int = count || array of registration objects
871 871
 	 */
872
-	public function get_registrations( $per_page = 10, $count = FALSE, $this_month = FALSE, $today = FALSE ) {
873
-
874
-		$EVT_ID = ! empty( $this->_req_data['event_id'] ) && $this->_req_data['event_id'] > 0 ? absint( $this->_req_data['event_id'] ) : FALSE;
875
-		$CAT_ID = ! empty( $this->_req_data['EVT_CAT'] ) && (int) $this->_req_data['EVT_CAT'] > 0? absint( $this->_req_data['EVT_CAT'] ) : FALSE;
876
-		$reg_status = ! empty( $this->_req_data['_reg_status'] ) ? sanitize_text_field( $this->_req_data['_reg_status'] ) : FALSE;
877
-		$month_range = ! empty( $this->_req_data['month_range'] ) ? sanitize_text_field( $this->_req_data['month_range'] ) : FALSE;//should be like 2013-april
878
-		$today_a = ! empty( $this->_req_data['status'] ) && $this->_req_data['status'] == 'today' ? TRUE : FALSE;
879
-		$this_month_a = ! empty( $this->_req_data['status'] ) && $this->_req_data['status'] == 'month' ? TRUE  : FALSE;
872
+	public function get_registrations($per_page = 10, $count = FALSE, $this_month = FALSE, $today = FALSE) {
873
+
874
+		$EVT_ID = ! empty($this->_req_data['event_id']) && $this->_req_data['event_id'] > 0 ? absint($this->_req_data['event_id']) : FALSE;
875
+		$CAT_ID = ! empty($this->_req_data['EVT_CAT']) && (int) $this->_req_data['EVT_CAT'] > 0 ? absint($this->_req_data['EVT_CAT']) : FALSE;
876
+		$reg_status = ! empty($this->_req_data['_reg_status']) ? sanitize_text_field($this->_req_data['_reg_status']) : FALSE;
877
+		$month_range = ! empty($this->_req_data['month_range']) ? sanitize_text_field($this->_req_data['month_range']) : FALSE; //should be like 2013-april
878
+		$today_a = ! empty($this->_req_data['status']) && $this->_req_data['status'] == 'today' ? TRUE : FALSE;
879
+		$this_month_a = ! empty($this->_req_data['status']) && $this->_req_data['status'] == 'month' ? TRUE : FALSE;
880 880
 		$start_date = FALSE;
881 881
 		$end_date = FALSE;
882 882
 		$_where = array();
883
-		$trash = ! empty( $this->_req_data['status'] ) && $this->_req_data['status'] == 'trash' ? TRUE : FALSE;
884
-		$incomplete = ! empty( $this->_req_data['status'] ) && $this->_req_data['status'] == 'incomplete' ? TRUE : FALSE;
883
+		$trash = ! empty($this->_req_data['status']) && $this->_req_data['status'] == 'trash' ? TRUE : FALSE;
884
+		$incomplete = ! empty($this->_req_data['status']) && $this->_req_data['status'] == 'incomplete' ? TRUE : FALSE;
885 885
 
886 886
 		//set orderby
887 887
 		$this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : '';
888 888
 
889 889
 
890
-		switch ( $this->_req_data['orderby'] ) {
890
+		switch ($this->_req_data['orderby']) {
891 891
 			case '_REG_ID':
892 892
 				$orderby = 'REG_ID';
893 893
 				break;
@@ -907,26 +907,26 @@  discard block
 block discarded – undo
907 907
 				$orderby = 'REG_date';
908 908
 		}
909 909
 
910
-		$sort = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] )) ? $this->_req_data['order'] : 'DESC';
911
-		$current_page = isset( $this->_req_data['paged'] ) && !empty( $this->_req_data['paged'] ) ? $this->_req_data['paged'] : 1;
912
-		$per_page = isset( $this->_req_data['perpage'] ) && !empty( $this->_req_data['perpage'] ) ? $this->_req_data['perpage'] : $per_page;
910
+		$sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'DESC';
911
+		$current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1;
912
+		$per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $per_page;
913 913
 
914 914
 
915
-		$offset = ($current_page-1)*$per_page;
916
-		$limit = $count  ? NULL : array( $offset, $per_page );
915
+		$offset = ($current_page - 1) * $per_page;
916
+		$limit = $count ? NULL : array($offset, $per_page);
917 917
 
918
-		if($EVT_ID){
919
-			$_where['EVT_ID']=$EVT_ID;
918
+		if ($EVT_ID) {
919
+			$_where['EVT_ID'] = $EVT_ID;
920 920
 		}
921
-		if($CAT_ID){
921
+		if ($CAT_ID) {
922 922
 			$_where['Event.Term_Taxonomy.term_id'] = $CAT_ID;
923 923
 		}
924
-		if ( $incomplete ) {
924
+		if ($incomplete) {
925 925
 			$_where['STS_ID'] = EEM_Registration::status_id_incomplete;
926 926
 		} else if ( ! $trash) {
927
-			$_where['STS_ID'] = array( '!=', EEM_Registration::status_id_incomplete );
927
+			$_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete);
928 928
 		}
929
-		if($reg_status){
929
+		if ($reg_status) {
930 930
 			$_where['STS_ID'] = $reg_status;
931 931
 		}
932 932
 
@@ -938,105 +938,105 @@  discard block
 block discarded – undo
938 938
 		$time_start = ' 00:00:00';
939 939
 		$time_end = ' 23:59:59';
940 940
 
941
-		if($today_a || $today ){
941
+		if ($today_a || $today) {
942 942
 			$curdate = date('Y-m-d', current_time('timestamp'));
943
-			$_where['REG_date']= array('BETWEEN',
943
+			$_where['REG_date'] = array('BETWEEN',
944 944
 				array(
945
-					EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $curdate . $time_start, 'Y-m-d H:i:s' ),
946
-					EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $curdate . $time_end, 'Y-m-d H:i:s' ),
945
+					EEM_Registration::instance()->convert_datetime_for_query('REG_date', $curdate.$time_start, 'Y-m-d H:i:s'),
946
+					EEM_Registration::instance()->convert_datetime_for_query('REG_date', $curdate.$time_end, 'Y-m-d H:i:s'),
947 947
 			));
948
-		}elseif($this_month_a || $this_month){
948
+		}elseif ($this_month_a || $this_month) {
949 949
 			$this_month_r = date('m', current_time('timestamp'));
950
-			$days_this_month = date( 't', current_time('timestamp') );
951
-			$_where['REG_date']= array('BETWEEN',
950
+			$days_this_month = date('t', current_time('timestamp'));
951
+			$_where['REG_date'] = array('BETWEEN',
952 952
 				array(
953
-					EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start, 'Y-m-d H:i:s' ),
954
-					EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end, 'Y-m-d H:i:s' )
953
+					EEM_Registration::instance()->convert_datetime_for_query('REG_date', $this_year_r.'-'.$this_month_r.'-01'.' '.$time_start, 'Y-m-d H:i:s'),
954
+					EEM_Registration::instance()->convert_datetime_for_query('REG_date', $this_year_r.'-'.$this_month_r.'-'.$days_this_month.' '.$time_end, 'Y-m-d H:i:s')
955 955
 			));
956
-		}elseif($month_range){
956
+		}elseif ($month_range) {
957 957
 			$pieces = explode(' ', $this->_req_data['month_range'], 3);
958
-			$month_r = !empty($pieces[0]) ? date('m', strtotime($pieces[0])) : '';
959
-			$year_r = !empty($pieces[1]) ? $pieces[1] : '';
960
-			$days_in_month = date('t', strtotime($year_r .  '-' . $month_r . '-' . '01') );
961
-			$_where['REG_date']= array('BETWEEN',
962
-				array(  EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $year_r . '-' . $month_r . '-01 00:00:00', 'Y-m-d H:i:s'), EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $year_r . '-' . $month_r . '-' . $days_in_month .  ' 23:59:59', 'Y-m-d H:i:s' ) ) );
963
-		}elseif($start_date && $end_date){
958
+			$month_r = ! empty($pieces[0]) ? date('m', strtotime($pieces[0])) : '';
959
+			$year_r = ! empty($pieces[1]) ? $pieces[1] : '';
960
+			$days_in_month = date('t', strtotime($year_r.'-'.$month_r.'-'.'01'));
961
+			$_where['REG_date'] = array('BETWEEN',
962
+				array(EEM_Registration::instance()->convert_datetime_for_query('REG_date', $year_r.'-'.$month_r.'-01 00:00:00', 'Y-m-d H:i:s'), EEM_Registration::instance()->convert_datetime_for_query('REG_date', $year_r.'-'.$month_r.'-'.$days_in_month.' 23:59:59', 'Y-m-d H:i:s')));
963
+		}elseif ($start_date && $end_date) {
964 964
 			throw new EE_Error("not yet supported");
965
-		}elseif($start_date){
965
+		}elseif ($start_date) {
966 966
 			throw new EE_Error("not yet supported");
967
-		}elseif($end_date){
967
+		}elseif ($end_date) {
968 968
 			throw new EE_Error("not yet supported");
969 969
 		}
970 970
 
971
-		if ( ! empty( $this->_req_data['s'] ) ) {
972
-			$sstr = '%' . $this->_req_data['s'] . '%';
971
+		if ( ! empty($this->_req_data['s'])) {
972
+			$sstr = '%'.$this->_req_data['s'].'%';
973 973
 			$_where['OR'] = array(
974
-				'Event.EVT_name' => array( 'LIKE', $sstr),
975
-				'Event.EVT_desc' => array( 'LIKE', $sstr ),
976
-				'Event.EVT_short_desc' => array( 'LIKE' , $sstr ),
977
-				'Attendee.ATT_full_name' => array( 'LIKE', $sstr ),
978
-				'Attendee.ATT_fname' => array( 'LIKE', $sstr ),
979
-				'Attendee.ATT_lname' => array( 'LIKE', $sstr ),
980
-				'Attendee.ATT_short_bio' => array( 'LIKE', $sstr ),
981
-				'Attendee.ATT_email' => array('LIKE', $sstr ),
982
-				'Attendee.ATT_address' => array( 'LIKE', $sstr ),
983
-				'Attendee.ATT_address2' => array( 'LIKE', $sstr ),
984
-				'Attendee.ATT_city' => array( 'LIKE', $sstr ),
985
-				'REG_final_price' => array( 'LIKE', $sstr ),
986
-				'REG_code' => array( 'LIKE', $sstr ),
987
-				'REG_count' => array( 'LIKE' , $sstr ),
988
-				'REG_group_size' => array( 'LIKE' , $sstr ),
989
-				'Ticket.TKT_name' => array( 'LIKE', $sstr ),
990
-				'Ticket.TKT_description' => array( 'LIKE', $sstr ),
991
-				'Transaction.Payment.PAY_txn_id_chq_nmbr' => array( 'LIKE', $sstr )
974
+				'Event.EVT_name' => array('LIKE', $sstr),
975
+				'Event.EVT_desc' => array('LIKE', $sstr),
976
+				'Event.EVT_short_desc' => array('LIKE', $sstr),
977
+				'Attendee.ATT_full_name' => array('LIKE', $sstr),
978
+				'Attendee.ATT_fname' => array('LIKE', $sstr),
979
+				'Attendee.ATT_lname' => array('LIKE', $sstr),
980
+				'Attendee.ATT_short_bio' => array('LIKE', $sstr),
981
+				'Attendee.ATT_email' => array('LIKE', $sstr),
982
+				'Attendee.ATT_address' => array('LIKE', $sstr),
983
+				'Attendee.ATT_address2' => array('LIKE', $sstr),
984
+				'Attendee.ATT_city' => array('LIKE', $sstr),
985
+				'REG_final_price' => array('LIKE', $sstr),
986
+				'REG_code' => array('LIKE', $sstr),
987
+				'REG_count' => array('LIKE', $sstr),
988
+				'REG_group_size' => array('LIKE', $sstr),
989
+				'Ticket.TKT_name' => array('LIKE', $sstr),
990
+				'Ticket.TKT_description' => array('LIKE', $sstr),
991
+				'Transaction.Payment.PAY_txn_id_chq_nmbr' => array('LIKE', $sstr)
992 992
 				);
993 993
 		}
994 994
 
995 995
 		//capability checks
996
-		if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'get_registrations' ) ) {
996
+		if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'get_registrations')) {
997 997
 			$_where['AND'] = array(
998 998
 				'Event.EVT_wp_user' => get_current_user_id()
999 999
 				);
1000 1000
 		}
1001 1001
 
1002 1002
 
1003
-		if( $count ){
1004
-			if ( $trash ) {
1005
-				return EEM_Registration::instance()->count_deleted( array( $_where ));
1006
-			} else if ( $incomplete ) {
1007
-				return EEM_Registration::instance()->count( array( $_where ));
1003
+		if ($count) {
1004
+			if ($trash) {
1005
+				return EEM_Registration::instance()->count_deleted(array($_where));
1006
+			} else if ($incomplete) {
1007
+				return EEM_Registration::instance()->count(array($_where));
1008 1008
 			} else {
1009
-				return EEM_Registration::instance()->count( array( $_where, 'default_where_conditions' => 'this_model_only' ));
1009
+				return EEM_Registration::instance()->count(array($_where, 'default_where_conditions' => 'this_model_only'));
1010 1010
 			}
1011 1011
 		} else {
1012 1012
 			//make sure we remove default where conditions cause all registrations matching query are returned
1013
-			$query_params = array( $_where, 'order_by' => array( $orderby => $sort ), 'default_where_conditions' => 'this_model_only' );
1014
-			if ( $per_page !== -1 ) {
1013
+			$query_params = array($_where, 'order_by' => array($orderby => $sort), 'default_where_conditions' => 'this_model_only');
1014
+			if ($per_page !== -1) {
1015 1015
 				$query_params['limit'] = $limit;
1016 1016
 			}
1017
-			$registrations =  $trash ? EEM_Registration::instance()->get_all_deleted($query_params) : EEM_Registration::instance()->get_all($query_params);
1017
+			$registrations = $trash ? EEM_Registration::instance()->get_all_deleted($query_params) : EEM_Registration::instance()->get_all($query_params);
1018 1018
 
1019 1019
 
1020
-			if ( $EVT_ID && isset( $registrations[0] ) && $registrations[0] instanceof EE_Registration &&  $registrations[0]->event_obj()) {
1020
+			if ($EVT_ID && isset($registrations[0]) && $registrations[0] instanceof EE_Registration && $registrations[0]->event_obj()) {
1021 1021
 				$first_registration = $registrations[0];
1022 1022
 				//EEH_Debug_Tools::printr( $registrations[0], '$registrations  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
1023 1023
 				$event_name = $first_registration->event_obj()->name();
1024
-				$event_date = $first_registration->date_obj()->start_date_and_time('l F j, Y,', 'g:i:s a');// isset( $registrations[0]->DTT_EVT_start ) ? date( 'l F j, Y,    g:i:s a', $registrations[0]->DTT_EVT_start ) : '';
1024
+				$event_date = $first_registration->date_obj()->start_date_and_time('l F j, Y,', 'g:i:s a'); // isset( $registrations[0]->DTT_EVT_start ) ? date( 'l F j, Y,    g:i:s a', $registrations[0]->DTT_EVT_start ) : '';
1025 1025
 				// edit event link
1026
-				if ( $event_name != '' ) {
1027
-					$edit_event_url = self::add_query_args_and_nonce( array( 'action'=>'edit_event', 'EVT_ID'=>$EVT_ID ), EVENTS_ADMIN_URL );
1028
-					$edit_event_lnk = '<a href="'.$edit_event_url.'" title="' . esc_attr__( 'Edit ', 'event_espresso' ) . $event_name . '">' . __( 'Edit Event', 'event_espresso' ) . '</a>';
1029
-					$event_name .= ' <span class="admin-page-header-edit-lnk not-bold">' . $edit_event_lnk . '</span>' ;
1026
+				if ($event_name != '') {
1027
+					$edit_event_url = self::add_query_args_and_nonce(array('action'=>'edit_event', 'EVT_ID'=>$EVT_ID), EVENTS_ADMIN_URL);
1028
+					$edit_event_lnk = '<a href="'.$edit_event_url.'" title="'.esc_attr__('Edit ', 'event_espresso').$event_name.'">'.__('Edit Event', 'event_espresso').'</a>';
1029
+					$event_name .= ' <span class="admin-page-header-edit-lnk not-bold">'.$edit_event_lnk.'</span>';
1030 1030
 				}
1031 1031
 
1032
-				$back_2_reg_url = self::add_query_args_and_nonce( array( 'action'=>'default' ), REG_ADMIN_URL );
1033
-				$back_2_reg_lnk = '<a href="'.$back_2_reg_url.'" title="' . esc_attr__( 'click to return to viewing all registrations ', 'event_espresso' ) . '">&laquo; ' . __( 'Back to All Registrations', 'event_espresso' ) . '</a>';
1032
+				$back_2_reg_url = self::add_query_args_and_nonce(array('action'=>'default'), REG_ADMIN_URL);
1033
+				$back_2_reg_lnk = '<a href="'.$back_2_reg_url.'" title="'.esc_attr__('click to return to viewing all registrations ', 'event_espresso').'">&laquo; '.__('Back to All Registrations', 'event_espresso').'</a>';
1034 1034
 
1035 1035
 				$this->_template_args['before_admin_page_content'] = '
1036 1036
 			<div id="admin-page-header">
1037
-				<h1><span class="small-text not-bold">'.__( 'Event: ', 'event_espresso' ).'</span>'. $event_name .'</h1>
1038
-				<h3><span class="small-text not-bold">'.__( 'Date: ', 'event_espresso' ). '</span>'. $event_date .'</h3>
1039
-				<span class="admin-page-header-go-back-lnk not-bold">' . $back_2_reg_lnk . '</span>
1037
+				<h1><span class="small-text not-bold">'.__('Event: ', 'event_espresso').'</span>'.$event_name.'</h1>
1038
+				<h3><span class="small-text not-bold">'.__('Date: ', 'event_espresso').'</span>'.$event_date.'</h3>
1039
+				<span class="admin-page-header-go-back-lnk not-bold">' . $back_2_reg_lnk.'</span>
1040 1040
 			</div>
1041 1041
 			';
1042 1042
 
@@ -1074,7 +1074,7 @@  discard block
 block discarded – undo
1074 1074
 
1075 1075
 		$this->_set_registration_object();
1076 1076
 
1077
-		if ( is_object( $this->_registration )) {
1077
+		if (is_object($this->_registration)) {
1078 1078
 			$transaction = $this->_registration->transaction() ? $this->_registration->transaction() : EE_Transaction::new_instance();
1079 1079
 			$this->_session = $transaction->session_data();
1080 1080
 
@@ -1082,10 +1082,10 @@  discard block
 block discarded – undo
1082 1082
 
1083 1083
 
1084 1084
 			$this->_template_args['reg_nmbr']['value'] = $this->_registration->ID();
1085
-			$this->_template_args['reg_nmbr']['label'] = __( 'Registration Number', 'event_espresso' );
1085
+			$this->_template_args['reg_nmbr']['label'] = __('Registration Number', 'event_espresso');
1086 1086
 
1087
-			$this->_template_args['reg_datetime']['value'] =  $this->_registration->pretty_date('l F j, Y','g:i:s a') ;
1088
-			$this->_template_args['reg_datetime']['label'] = __( 'Date', 'event_espresso' );
1087
+			$this->_template_args['reg_datetime']['value'] = $this->_registration->pretty_date('l F j, Y', 'g:i:s a');
1088
+			$this->_template_args['reg_datetime']['label'] = __('Date', 'event_espresso');
1089 1089
 
1090 1090
 			$this->_template_args['grand_total'] = $transaction->total();
1091 1091
 
@@ -1093,19 +1093,19 @@  discard block
 block discarded – undo
1093 1093
 			// link back to overview
1094 1094
 			$this->_template_args['reg_overview_url'] = REG_ADMIN_URL;
1095 1095
 			$this->_template_args['registration'] = $this->_registration;
1096
-			$this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'default', 'event_id' => $event_id ), REG_ADMIN_URL );
1097
-			$this->_template_args['filtered_transactions_link'] = EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'default', 'EVT_ID' => $event_id, 'page' => 'espresso_transactions' ), admin_url( 'admin.php' ) );
1098
-			$this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce( array( 'page' => 'espresso_events', 'action' => 'edit', 'post' => $event_id ), admin_url( 'admin.php' ) );
1096
+			$this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'default', 'event_id' => $event_id), REG_ADMIN_URL);
1097
+			$this->_template_args['filtered_transactions_link'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'default', 'EVT_ID' => $event_id, 'page' => 'espresso_transactions'), admin_url('admin.php'));
1098
+			$this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(array('page' => 'espresso_events', 'action' => 'edit', 'post' => $event_id), admin_url('admin.php'));
1099 1099
 
1100 1100
 			//next and previous links
1101
-			$next_reg = $this->_registration->next(null, array(), 'REG_ID' );
1102
-			$this->_template_args['next_registration'] = $next_reg ? $this->_next_link( EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'view_registration', '_REG_ID' => $next_reg['REG_ID'] ), REG_ADMIN_URL ), 'dashicons dashicons-arrow-right ee-icon-size-22' ) : '';
1103
-			$previous_reg = $this->_registration->previous( null, array(), 'REG_ID' );
1104
-			$this->_template_args['previous_registration'] = $previous_reg ? $this->_previous_link( EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'view_registration', '_REG_ID' => $previous_reg['REG_ID'] ), REG_ADMIN_URL ), 'dashicons dashicons-arrow-left ee-icon-size-22' ) : '';
1101
+			$next_reg = $this->_registration->next(null, array(), 'REG_ID');
1102
+			$this->_template_args['next_registration'] = $next_reg ? $this->_next_link(EE_Admin_Page::add_query_args_and_nonce(array('action' => 'view_registration', '_REG_ID' => $next_reg['REG_ID']), REG_ADMIN_URL), 'dashicons dashicons-arrow-right ee-icon-size-22') : '';
1103
+			$previous_reg = $this->_registration->previous(null, array(), 'REG_ID');
1104
+			$this->_template_args['previous_registration'] = $previous_reg ? $this->_previous_link(EE_Admin_Page::add_query_args_and_nonce(array('action' => 'view_registration', '_REG_ID' => $previous_reg['REG_ID']), REG_ADMIN_URL), 'dashicons dashicons-arrow-left ee-icon-size-22') : '';
1105 1105
 
1106 1106
 			// grab header
1107
-			$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php';
1108
-			$this->_template_args['admin_page_header'] = EEH_Template::display_template( $template_path, $this->_template_args, TRUE );
1107
+			$template_path = REG_TEMPLATE_PATH.'reg_admin_details_header.template.php';
1108
+			$this->_template_args['admin_page_header'] = EEH_Template::display_template($template_path, $this->_template_args, TRUE);
1109 1109
 
1110 1110
 		} else {
1111 1111
 
@@ -1124,17 +1124,17 @@  discard block
 block discarded – undo
1124 1124
 
1125 1125
 
1126 1126
 	protected function _registration_details_metaboxes() {
1127
-		do_action( 'AHEE__Registrations_Admin_Page___registration_details_metabox__start', $this );
1127
+		do_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', $this);
1128 1128
 		$this->_set_registration_object();
1129 1129
 		$attendee = $this->_registration instanceof EE_Registration ? $this->_registration->attendee() : null;
1130
-		add_meta_box( 'edit-reg-status-mbox', __( 'Registration Status', 'event_espresso' ), array( $this, 'set_reg_status_buttons_metabox' ), $this->wp_page_slug, 'normal', 'high' );
1131
-		add_meta_box( 'edit-reg-details-mbox', __( 'Registration Details', 'event_espresso' ), array( $this, '_reg_details_meta_box' ), $this->wp_page_slug, 'normal', 'high' );
1132
-		if ( $attendee instanceof EE_Attendee && EE_Registry::instance()->CAP->current_user_can('ee_edit_registration', 'edit-reg-questions-mbox' ) ) {
1133
-			add_meta_box( 'edit-reg-questions-mbox', __( 'Registration Form Answers', 'event_espresso' ), array( $this, '_reg_questions_meta_box' ), $this->wp_page_slug, 'normal', 'high' );
1130
+		add_meta_box('edit-reg-status-mbox', __('Registration Status', 'event_espresso'), array($this, 'set_reg_status_buttons_metabox'), $this->wp_page_slug, 'normal', 'high');
1131
+		add_meta_box('edit-reg-details-mbox', __('Registration Details', 'event_espresso'), array($this, '_reg_details_meta_box'), $this->wp_page_slug, 'normal', 'high');
1132
+		if ($attendee instanceof EE_Attendee && EE_Registry::instance()->CAP->current_user_can('ee_edit_registration', 'edit-reg-questions-mbox')) {
1133
+			add_meta_box('edit-reg-questions-mbox', __('Registration Form Answers', 'event_espresso'), array($this, '_reg_questions_meta_box'), $this->wp_page_slug, 'normal', 'high');
1134 1134
 		}
1135
-		add_meta_box( 'edit-reg-registrant-mbox', __( 'Contact Details', 'event_espresso' ), array( $this, '_reg_registrant_side_meta_box' ), $this->wp_page_slug, 'side', 'high' );
1136
-		if ( $this->_registration->group_size() > 1 ) {
1137
-			add_meta_box( 'edit-reg-attendees-mbox', __( 'Other Registrations in this Transaction', 'event_espresso' ), array( $this, '_reg_attendees_meta_box' ), $this->wp_page_slug, 'normal', 'high' );
1135
+		add_meta_box('edit-reg-registrant-mbox', __('Contact Details', 'event_espresso'), array($this, '_reg_registrant_side_meta_box'), $this->wp_page_slug, 'side', 'high');
1136
+		if ($this->_registration->group_size() > 1) {
1137
+			add_meta_box('edit-reg-attendees-mbox', __('Other Registrations in this Transaction', 'event_espresso'), array($this, '_reg_attendees_meta_box'), $this->wp_page_slug, 'normal', 'high');
1138 1138
 		}
1139 1139
 	}
1140 1140
 
@@ -1155,23 +1155,23 @@  discard block
 block discarded – undo
1155 1155
 
1156 1156
 		//let's get an array of all possible buttons that we can just reference
1157 1157
 		$status_buttons = $this->_get_reg_status_buttons();
1158
-		$template_args[ 'reg_status_value' ] = $this->_registration->pretty_status();
1159
-		$template_args[ 'reg_status_class' ] = 'status-' . $this->_registration->status_ID();
1158
+		$template_args['reg_status_value'] = $this->_registration->pretty_status();
1159
+		$template_args['reg_status_class'] = 'status-'.$this->_registration->status_ID();
1160 1160
 		$template_args['attendee'] = $this->_registration->attendee();
1161
-		$template = REG_TEMPLATE_PATH . 'reg_status_change_buttons.template.php';
1162
-		if ( $this->_set_registration_object() ) {
1161
+		$template = REG_TEMPLATE_PATH.'reg_status_change_buttons.template.php';
1162
+		if ($this->_set_registration_object()) {
1163 1163
 			$current_status = $this->_registration->status_ID();
1164
-			unset( $status_buttons[$current_status] );
1165
-			if ( $current_status != EEM_Registration::status_id_pending_payment && $is_complete ) {
1166
-				unset( $status_buttons[EEM_Registration::status_id_pending_payment] );
1164
+			unset($status_buttons[$current_status]);
1165
+			if ($current_status != EEM_Registration::status_id_pending_payment && $is_complete) {
1166
+				unset($status_buttons[EEM_Registration::status_id_pending_payment]);
1167 1167
 			}
1168
-			$template_args['status_buttons'] = implode( "\n", $status_buttons );
1168
+			$template_args['status_buttons'] = implode("\n", $status_buttons);
1169 1169
 		}
1170 1170
 		$template_args['form_url'] = REG_ADMIN_URL;
1171 1171
 		$template_args['REG_ID'] = $this->_registration->ID();
1172
-		$template_args['nonce'] = wp_nonce_field( 'change_reg_status_nonce',  'change_reg_status_nonce', FALSE, FALSE );
1172
+		$template_args['nonce'] = wp_nonce_field('change_reg_status_nonce', 'change_reg_status_nonce', FALSE, FALSE);
1173 1173
 
1174
-		EEH_Template::display_template( $template, $template_args );
1174
+		EEH_Template::display_template($template, $template_args);
1175 1175
 
1176 1176
 	}
1177 1177
 
@@ -1185,11 +1185,11 @@  discard block
 block discarded – undo
1185 1185
 	private function _get_reg_status_buttons() {
1186 1186
 
1187 1187
 		$buttons = array(
1188
-			EEM_Registration::status_id_approved => '<input type="submit" name="_reg_status_id" class="button-secondary ee-status-strip reg-status-' . EEM_Registration::status_id_approved . '" value="' . EEH_Template::pretty_status( EEM_Registration::status_id_approved, FALSE, 'sentence' ) . '">',
1189
-			EEM_Registration::status_id_pending_payment => '<input type="submit" name="_reg_status_id" class="button-secondary ee-status-strip reg-status-' . EEM_Registration::status_id_pending_payment . '" value="' . EEH_Template::pretty_status( EEM_Registration::status_id_pending_payment, FALSE, 'sentence' ) . '">',
1190
-			EEM_Registration::status_id_not_approved => '<input type="submit" name="_reg_status_id" class="button-secondary ee-status-strip reg-status-' . EEM_Registration::status_id_not_approved . '" value="' . EEH_Template::pretty_status( EEM_Registration::status_id_not_approved, FALSE, 'sentence' ) . '">',
1191
-			EEM_Registration::status_id_declined => '<input type="submit" name="_reg_status_id" class="button-secondary ee-status-strip reg-status-' . EEM_Registration::status_id_declined . '" value="' . EEH_Template::pretty_status( EEM_Registration::status_id_declined, FALSE, 'sentence' ) . '">',
1192
-			EEM_Registration::status_id_cancelled =>'<input type="submit" name="_reg_status_id" class="button-secondary ee-status-strip reg-status-' . EEM_Registration::status_id_cancelled . '" value="' . EEH_Template::pretty_status( EEM_Registration::status_id_cancelled, FALSE, 'sentence' ) . '">',
1188
+			EEM_Registration::status_id_approved => '<input type="submit" name="_reg_status_id" class="button-secondary ee-status-strip reg-status-'.EEM_Registration::status_id_approved.'" value="'.EEH_Template::pretty_status(EEM_Registration::status_id_approved, FALSE, 'sentence').'">',
1189
+			EEM_Registration::status_id_pending_payment => '<input type="submit" name="_reg_status_id" class="button-secondary ee-status-strip reg-status-'.EEM_Registration::status_id_pending_payment.'" value="'.EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, FALSE, 'sentence').'">',
1190
+			EEM_Registration::status_id_not_approved => '<input type="submit" name="_reg_status_id" class="button-secondary ee-status-strip reg-status-'.EEM_Registration::status_id_not_approved.'" value="'.EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, FALSE, 'sentence').'">',
1191
+			EEM_Registration::status_id_declined => '<input type="submit" name="_reg_status_id" class="button-secondary ee-status-strip reg-status-'.EEM_Registration::status_id_declined.'" value="'.EEH_Template::pretty_status(EEM_Registration::status_id_declined, FALSE, 'sentence').'">',
1192
+			EEM_Registration::status_id_cancelled =>'<input type="submit" name="_reg_status_id" class="button-secondary ee-status-strip reg-status-'.EEM_Registration::status_id_cancelled.'" value="'.EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, FALSE, 'sentence').'">',
1193 1193
 			);
1194 1194
 		return $buttons;
1195 1195
 	}
@@ -1203,13 +1203,13 @@  discard block
 block discarded – undo
1203 1203
 	 *
1204 1204
 	 * @return array  (array with reg_id(s) updated and whether update was successful.
1205 1205
 	 */
1206
-	protected function _set_registration_status_from_request( $status = false, $notify = false ) {
1207
-		$REG_ID = isset( $this->_req_data['_REG_ID'] ) ? (array) $this->_req_data['_REG_ID'] : array();
1206
+	protected function _set_registration_status_from_request($status = false, $notify = false) {
1207
+		$REG_ID = isset($this->_req_data['_REG_ID']) ? (array) $this->_req_data['_REG_ID'] : array();
1208 1208
 
1209
-		$success = $this->_set_registration_status( $REG_ID, $status );
1209
+		$success = $this->_set_registration_status($REG_ID, $status);
1210 1210
 
1211 1211
 		//notify?
1212
-		if ( $success && $notify && EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'espresso_registrations_resend_registration' ) ) {
1212
+		if ($success && $notify && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'espresso_registrations_resend_registration')) {
1213 1213
 			$this->_process_resend_registration();
1214 1214
 		}
1215 1215
 
@@ -1227,19 +1227,19 @@  discard block
 block discarded – undo
1227 1227
 	 * @param bool $status
1228 1228
 	 * @return array (an array with 'success' key representing whether status change was successful, and 'REG_ID' as the array of updated registrations).
1229 1229
 	 */
1230
-	protected function _set_registration_status( $REG_ID, $status = false ) {
1230
+	protected function _set_registration_status($REG_ID, $status = false) {
1231 1231
 		$success = true;
1232 1232
 		// set default status if none is passed
1233 1233
 		$status = $status ? $status : EEM_Registration::status_id_pending_payment;
1234 1234
 
1235 1235
 		//typecast and sanitize reg_id
1236
-		$reg_ids = array_filter( (array) $REG_ID, 'absint' );
1236
+		$reg_ids = array_filter((array) $REG_ID, 'absint');
1237 1237
 
1238 1238
 		//loop through REG_ID's and change status
1239
-		foreach ( $reg_ids as $r_id ) {
1240
-			$registration = EEM_Registration::instance()->get_one_by_ID( $r_id );
1241
-			if ( $registration instanceof EE_Registration ) {
1242
-				$registration->set_status( $status );
1239
+		foreach ($reg_ids as $r_id) {
1240
+			$registration = EEM_Registration::instance()->get_one_by_ID($r_id);
1241
+			if ($registration instanceof EE_Registration) {
1242
+				$registration->set_status($status);
1243 1243
 				$result = $registration->save();
1244 1244
 
1245 1245
 				//verifying explicit fails because update *may* just return 0 for 0 rows affected
@@ -1251,7 +1251,7 @@  discard block
 block discarded – undo
1251 1251
 		$this->_req_data['_REG_ID'] = $reg_ids;
1252 1252
 
1253 1253
 		//return $success and processed registrations
1254
-		return array( 'REG_ID' => $reg_ids, 'success' => $success );
1254
+		return array('REG_ID' => $reg_ids, 'success' => $success);
1255 1255
 	}
1256 1256
 
1257 1257
 
@@ -1263,37 +1263,37 @@  discard block
 block discarded – undo
1263 1263
 	 * @param   bool    $notify indicates whether the _set_registration_status_from_request does notifications or not.
1264 1264
 	 * @return void
1265 1265
 	 */
1266
-	protected function _reg_status_change_return( $STS_ID, $notify = false ) {
1266
+	protected function _reg_status_change_return($STS_ID, $notify = false) {
1267 1267
 
1268
-		$result = ! empty( $STS_ID ) ? $this->_set_registration_status_from_request( $STS_ID, $notify ) : array( 'success' => false );
1268
+		$result = ! empty($STS_ID) ? $this->_set_registration_status_from_request($STS_ID, $notify) : array('success' => false);
1269 1269
 
1270 1270
 
1271
-		$success = isset( $result['success'] ) && $result['success'];
1271
+		$success = isset($result['success']) && $result['success'];
1272 1272
 
1273 1273
 		//setup success message
1274
-		if ( $success ) {
1275
-			$msg = is_array( $result['REG_ID'] ) && count( $result['REG_ID'] ) > 1  ? sprintf( __('Registration status has been set to %s', 'event_espresso'), EEH_Template::pretty_status($STS_ID, false, 'lower' ) ) :  sprintf( __('Registrations have been set to %s.', 'event_espresso'), EEH_Template::pretty_status($STS_ID, false, 'lower' ) ) ;
1276
-			EE_Error::add_success( $msg );
1274
+		if ($success) {
1275
+			$msg = is_array($result['REG_ID']) && count($result['REG_ID']) > 1 ? sprintf(__('Registration status has been set to %s', 'event_espresso'), EEH_Template::pretty_status($STS_ID, false, 'lower')) : sprintf(__('Registrations have been set to %s.', 'event_espresso'), EEH_Template::pretty_status($STS_ID, false, 'lower'));
1276
+			EE_Error::add_success($msg);
1277 1277
 		} else {
1278
-			EE_Error::add_error( __('Something went wrong, and the status was not changed', 'event_espresso' ), __FILE__, __LINE__, __FUNCTION__ );
1278
+			EE_Error::add_error(__('Something went wrong, and the status was not changed', 'event_espresso'), __FILE__, __LINE__, __FUNCTION__);
1279 1279
 		}
1280 1280
 
1281
-		$route = isset( $this->_req_data['return'] ) && $this->_req_data['return'] == 'view_registration' ? array( 'action' => 'view_registration', '_REG_ID' => $result['REG_ID'][0] ) : array( 'action' => 'default' );
1281
+		$route = isset($this->_req_data['return']) && $this->_req_data['return'] == 'view_registration' ? array('action' => 'view_registration', '_REG_ID' => $result['REG_ID'][0]) : array('action' => 'default');
1282 1282
 		//unset nonces
1283
-		foreach ( $this->_req_data as $ref => $value ) {
1284
-			if ( strpos( $ref, 'nonce' ) !== false ) {
1285
-				unset( $this->_req_data[$ref] );
1283
+		foreach ($this->_req_data as $ref => $value) {
1284
+			if (strpos($ref, 'nonce') !== false) {
1285
+				unset($this->_req_data[$ref]);
1286 1286
 				continue;
1287 1287
 			}
1288 1288
 
1289
-			$value = is_array( $value ) ? array_map( 'urlencode', $value ) : urlencode( $value );
1289
+			$value = is_array($value) ? array_map('urlencode', $value) : urlencode($value);
1290 1290
 			$this->_req_data[$ref] = $value;
1291 1291
 		}
1292 1292
 
1293 1293
 		//merge request vars so that the reloaded list table contains any existing filter query params
1294
-		$route = array_merge( $this->_req_data, $route );
1294
+		$route = array_merge($this->_req_data, $route);
1295 1295
 
1296
-		$this->_redirect_after_action( false, '', '', $route, true );
1296
+		$this->_redirect_after_action(false, '', '', $route, true);
1297 1297
 	}
1298 1298
 
1299 1299
 
@@ -1305,29 +1305,29 @@  discard block
 block discarded – undo
1305 1305
 	protected function _change_reg_status() {
1306 1306
 		$this->_req_data['return'] = 'view_registration';
1307 1307
 		//set notify based on whether the send notifications toggle is set or not
1308
-		$notify = ! empty( $this->_req_data['txn_reg_status_change']['send_notifications'] );
1309
-		$this->_req_data[ '_reg_status_id' ] = isset( $this->_req_data[ '_reg_status_id' ] ) ? $this->_req_data[ '_reg_status_id' ] : '';
1308
+		$notify = ! empty($this->_req_data['txn_reg_status_change']['send_notifications']);
1309
+		$this->_req_data['_reg_status_id'] = isset($this->_req_data['_reg_status_id']) ? $this->_req_data['_reg_status_id'] : '';
1310 1310
 
1311
-		switch ( $this->_req_data['_reg_status_id'] ) {
1312
-			case EEH_Template::pretty_status( EEM_Registration::status_id_approved, false, 'sentence' ) :
1313
-				$this->approve_registration( $notify );
1311
+		switch ($this->_req_data['_reg_status_id']) {
1312
+			case EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence') :
1313
+				$this->approve_registration($notify);
1314 1314
 				break;
1315
-			case EEH_Template::pretty_status( EEM_Registration::status_id_pending_payment, false, 'sentence' ) :
1316
-				$this->pending_registration( $notify );
1315
+			case EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence') :
1316
+				$this->pending_registration($notify);
1317 1317
 				break;
1318
-			case EEH_Template::pretty_status( EEM_Registration::status_id_not_approved, false, 'sentence' ) :
1319
-				$this->not_approve_registration( $notify );
1318
+			case EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence') :
1319
+				$this->not_approve_registration($notify);
1320 1320
 				break;
1321
-			case EEH_Template::pretty_status( EEM_Registration::status_id_declined, false, 'sentence' ) :
1322
-				$this->decline_registration( $notify );
1321
+			case EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence') :
1322
+				$this->decline_registration($notify);
1323 1323
 				break;
1324
-			case EEH_Template::pretty_status( EEM_Registration::status_id_cancelled, false, 'sentence' ) :
1325
-				$this->cancel_registration( $notify );
1324
+			case EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence') :
1325
+				$this->cancel_registration($notify);
1326 1326
 				break;
1327 1327
 			default :
1328 1328
 				$result['success'] = false;
1329
-				unset( $this->_req_data['return'] );
1330
-				$this->_reg_status_change_return( '', false );
1329
+				unset($this->_req_data['return']);
1330
+				$this->_reg_status_change_return('', false);
1331 1331
 				break;
1332 1332
 		}
1333 1333
 	}
@@ -1340,8 +1340,8 @@  discard block
 block discarded – undo
1340 1340
 	*		@param bool $notify whether or not to notify the registrant about their approval.
1341 1341
 	*		@return void
1342 1342
 	*/
1343
-	protected function approve_registration( $notify = false ) {
1344
-		$this->_reg_status_change_return( EEM_Registration::status_id_approved, $notify );
1343
+	protected function approve_registration($notify = false) {
1344
+		$this->_reg_status_change_return(EEM_Registration::status_id_approved, $notify);
1345 1345
 	}
1346 1346
 
1347 1347
 
@@ -1353,8 +1353,8 @@  discard block
 block discarded – undo
1353 1353
 	*		@param bool $notify whether or not to notify the registrant about their approval.
1354 1354
 	*		@return void
1355 1355
 	*/
1356
-	protected function decline_registration( $notify = false ) {
1357
-		$this->_reg_status_change_return( EEM_Registration::status_id_declined, $notify );
1356
+	protected function decline_registration($notify = false) {
1357
+		$this->_reg_status_change_return(EEM_Registration::status_id_declined, $notify);
1358 1358
 	}
1359 1359
 
1360 1360
 
@@ -1366,8 +1366,8 @@  discard block
 block discarded – undo
1366 1366
 	*		@param bool $notify whether or not to notify the registrant about their approval.
1367 1367
 	*		@return void
1368 1368
 	*/
1369
-	protected function cancel_registration( $notify = false ) {
1370
-		$this->_reg_status_change_return( EEM_Registration::status_id_cancelled, $notify );
1369
+	protected function cancel_registration($notify = false) {
1370
+		$this->_reg_status_change_return(EEM_Registration::status_id_cancelled, $notify);
1371 1371
 	}
1372 1372
 
1373 1373
 
@@ -1380,8 +1380,8 @@  discard block
 block discarded – undo
1380 1380
 	*		@param bool $notify whether or not to notify the registrant about their approval.
1381 1381
 	*		@return void
1382 1382
 	*/
1383
-	protected function not_approve_registration( $notify = false ) {
1384
-		$this->_reg_status_change_return( EEM_Registration::status_id_not_approved, $notify );
1383
+	protected function not_approve_registration($notify = false) {
1384
+		$this->_reg_status_change_return(EEM_Registration::status_id_not_approved, $notify);
1385 1385
 	}
1386 1386
 
1387 1387
 
@@ -1392,8 +1392,8 @@  discard block
 block discarded – undo
1392 1392
 	*		@param bool $notify whether or not to notify the registrant about their approval.
1393 1393
 	*		@return void
1394 1394
 	*/
1395
-	protected function pending_registration( $notify = false ) {
1396
-		$this->_reg_status_change_return( EEM_Registration::status_id_pending_payment, $notify );
1395
+	protected function pending_registration($notify = false) {
1396
+		$this->_reg_status_change_return(EEM_Registration::status_id_pending_payment, $notify);
1397 1397
 	}
1398 1398
 
1399 1399
 
@@ -1407,75 +1407,75 @@  discard block
 block discarded – undo
1407 1407
 	public function _reg_details_meta_box() {
1408 1408
 		EEH_Autoloader::register_line_item_display_autoloaders();
1409 1409
 		EEH_Autoloader::register_line_item_filter_autoloaders();
1410
-		EE_Registry::instance()->load_Helper( 'Line_Item' );
1410
+		EE_Registry::instance()->load_Helper('Line_Item');
1411 1411
 		$transaction = $this->_registration->transaction() ? $this->_registration->transaction() : EE_Transaction::new_instance();
1412 1412
 		$this->_session = $transaction->session_data();
1413 1413
 
1414 1414
 		$filters = new EE_Line_Item_Filter_Collection();
1415
-		$filters->add( new EE_Single_Registration_Line_Item_Filter( $this->_registration ) );
1416
-		$filters->add( new EE_Non_Zero_Line_Item_Filter() );
1417
-		$line_item_filter_processor = new EE_Line_Item_Filter_Processor( $filters, $transaction->total_line_item() );
1415
+		$filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration));
1416
+		$filters->add(new EE_Non_Zero_Line_Item_Filter());
1417
+		$line_item_filter_processor = new EE_Line_Item_Filter_Processor($filters, $transaction->total_line_item());
1418 1418
 		$filtered_line_item_tree = $line_item_filter_processor->process();
1419 1419
 
1420 1420
 		$this->_template_args['REG_ID'] = $this->_registration->ID();
1421
-		$line_item_display = new EE_Line_Item_Display( 'reg_admin_table', 'EE_Admin_Table_Registration_Line_Item_Display_Strategy' );
1422
-		$this->_template_args['line_item_table'] = $line_item_display->display_line_item( $filtered_line_item_tree, array( 'EE_Registration' => $this->_registration ) );
1421
+		$line_item_display = new EE_Line_Item_Display('reg_admin_table', 'EE_Admin_Table_Registration_Line_Item_Display_Strategy');
1422
+		$this->_template_args['line_item_table'] = $line_item_display->display_line_item($filtered_line_item_tree, array('EE_Registration' => $this->_registration));
1423 1423
 
1424 1424
 
1425 1425
 		$attendee = $this->_registration->attendee();
1426 1426
 
1427 1427
 
1428
-		$this->_template_args['view_transaction_button'] = EE_Registry::instance()->CAP->current_user_can( 'ee_read_transaction', 'espresso_transactions_view_transaction' ) ?EEH_Template::get_button_or_link( EE_Admin_Page::add_query_args_and_nonce( array('action'=> 'view_transaction', 'TXN_ID' => $transaction->ID() ), TXN_ADMIN_URL ), __(' View Transaction'), 'button secondary-button right', 'dashicons dashicons-cart' ) : '';
1429
-		$this->_template_args['resend_registration_button'] = $attendee instanceof EE_Attendee && EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'espresso_registrations_resend_registration' ) ?EEH_Template::get_button_or_link( EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'resend_registration', '_REG_ID'=>$this->_registration->ID(), 'redirect_to' => 'view_registration' ), REG_ADMIN_URL ), __(' Resend Registration'), 'button secondary-button right', 'dashicons dashicons-email-alt' ) : '';
1428
+		$this->_template_args['view_transaction_button'] = EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', 'espresso_transactions_view_transaction') ? EEH_Template::get_button_or_link(EE_Admin_Page::add_query_args_and_nonce(array('action'=> 'view_transaction', 'TXN_ID' => $transaction->ID()), TXN_ADMIN_URL), __(' View Transaction'), 'button secondary-button right', 'dashicons dashicons-cart') : '';
1429
+		$this->_template_args['resend_registration_button'] = $attendee instanceof EE_Attendee && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'espresso_registrations_resend_registration') ? EEH_Template::get_button_or_link(EE_Admin_Page::add_query_args_and_nonce(array('action'=>'resend_registration', '_REG_ID'=>$this->_registration->ID(), 'redirect_to' => 'view_registration'), REG_ADMIN_URL), __(' Resend Registration'), 'button secondary-button right', 'dashicons dashicons-email-alt') : '';
1430 1430
 
1431 1431
 
1432 1432
 		$this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
1433
-		$payment = $transaction->get_first_related( 'Payment' );
1433
+		$payment = $transaction->get_first_related('Payment');
1434 1434
 		$payment = ! $payment instanceof EE_Payment ? EE_Payment::new_instance() : $payment;
1435
-		$payment_method = $payment->get_first_related( 'Payment_Method' );
1435
+		$payment_method = $payment->get_first_related('Payment_Method');
1436 1436
 		$payment_method = ! $payment_method instanceof EE_Payment_Method ? EE_Payment_Method::new_instance() : $payment_method;
1437
-		$reg_status_class = 'status-' . $this->_registration->status_ID();
1437
+		$reg_status_class = 'status-'.$this->_registration->status_ID();
1438 1438
 		$reg_details = array(
1439 1439
 			'payment_method' => $payment_method->name(),
1440 1440
 			'response_msg' => $payment->gateway_response(),
1441
-			'registration_id' => $this->_registration->get( 'REG_code' ),
1441
+			'registration_id' => $this->_registration->get('REG_code'),
1442 1442
 			'registration_session' => $this->_registration->session_ID(),
1443
-			'ip_address' => isset( $this->_session['ip_address'] ) ? $this->_session['ip_address'] : '',
1444
-			'user_agent' => isset( $this->_session['user_agent'] ) ? $this->_session['user_agent'] : '',
1443
+			'ip_address' => isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '',
1444
+			'user_agent' => isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '',
1445 1445
 			);
1446 1446
 
1447 1447
 
1448
-		if ( isset( $reg_details['registration_id'] )) {
1448
+		if (isset($reg_details['registration_id'])) {
1449 1449
 			$this->_template_args['reg_details']['registration_id']['value'] = $reg_details['registration_id'];
1450
-			$this->_template_args['reg_details']['registration_id']['label'] = __( 'Registration ID', 'event_espresso' );
1450
+			$this->_template_args['reg_details']['registration_id']['label'] = __('Registration ID', 'event_espresso');
1451 1451
 			$this->_template_args['reg_details']['registration_id']['class'] = 'regular-text';
1452 1452
 		}
1453 1453
 
1454
-		if ( isset( $reg_details['payment_method'] ) ) {
1454
+		if (isset($reg_details['payment_method'])) {
1455 1455
 			$this->_template_args['reg_details']['payment_method']['value'] = $reg_details['payment_method'];
1456
-			$this->_template_args['reg_details']['payment_method']['label'] = __( 'Most Recent Payment Method', 'event_espresso' );
1456
+			$this->_template_args['reg_details']['payment_method']['label'] = __('Most Recent Payment Method', 'event_espresso');
1457 1457
 			$this->_template_args['reg_details']['payment_method']['class'] = 'regular-text';
1458 1458
 			$this->_template_args['reg_details']['response_msg']['value'] = $reg_details['response_msg'];
1459
-			$this->_template_args['reg_details']['response_msg']['label'] = __( 'Payment method response', 'event_espresso' );
1459
+			$this->_template_args['reg_details']['response_msg']['label'] = __('Payment method response', 'event_espresso');
1460 1460
 			$this->_template_args['reg_details']['response_msg']['class'] = 'regular-text';
1461 1461
 		}
1462 1462
 
1463 1463
 		$this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session'];
1464
-		$this->_template_args['reg_details']['registration_session']['label'] = __( 'Registration Session', 'event_espresso' );
1464
+		$this->_template_args['reg_details']['registration_session']['label'] = __('Registration Session', 'event_espresso');
1465 1465
 		$this->_template_args['reg_details']['registration_session']['class'] = 'regular-text';
1466 1466
 
1467 1467
 		$this->_template_args['reg_details']['ip_address']['value'] = $reg_details['ip_address'];
1468
-		$this->_template_args['reg_details']['ip_address']['label'] = __( 'Registration placed from IP', 'event_espresso' );
1468
+		$this->_template_args['reg_details']['ip_address']['label'] = __('Registration placed from IP', 'event_espresso');
1469 1469
 		$this->_template_args['reg_details']['ip_address']['class'] = 'regular-text';
1470 1470
 
1471 1471
 		$this->_template_args['reg_details']['user_agent']['value'] = $reg_details['user_agent'];
1472
-		$this->_template_args['reg_details']['user_agent']['label'] = __( 'Registrant User Agent', 'event_espresso' );
1472
+		$this->_template_args['reg_details']['user_agent']['label'] = __('Registrant User Agent', 'event_espresso');
1473 1473
 		$this->_template_args['reg_details']['user_agent']['class'] = 'large-text';
1474 1474
 
1475
-		$this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'default', 'event_id' => $this->_registration->event_ID()), REG_ADMIN_URL );
1475
+		$this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'default', 'event_id' => $this->_registration->event_ID()), REG_ADMIN_URL);
1476 1476
 
1477
-		$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php';
1478
-		echo EEH_Template::display_template( $template_path, $this->_template_args, TRUE );
1477
+		$template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_details.template.php';
1478
+		echo EEH_Template::display_template($template_path, $this->_template_args, TRUE);
1479 1479
 
1480 1480
 	}
1481 1481
 
@@ -1489,14 +1489,14 @@  discard block
 block discarded – undo
1489 1489
 	*/
1490 1490
 	public function _reg_questions_meta_box() {
1491 1491
 		//allow someone to override this method entirely
1492
-		if( apply_filters( 'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', true, $this, $this->_registration ) ) {
1493
-			$form = $this->_get_reg_custom_questions_form( $this->_registration->ID() );
1494
-			$this->_template_args[ 'att_questions' ] = count( $form->subforms() ) > 0 ? $form->get_html_and_js() : '';
1492
+		if (apply_filters('FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', true, $this, $this->_registration)) {
1493
+			$form = $this->_get_reg_custom_questions_form($this->_registration->ID());
1494
+			$this->_template_args['att_questions'] = count($form->subforms()) > 0 ? $form->get_html_and_js() : '';
1495 1495
 			$this->_template_args['reg_questions_form_action'] = 'edit_registration';
1496 1496
 			$this->_template_args['REG_ID'] = $this->_registration->ID();
1497 1497
 
1498
-			$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
1499
-			echo EEH_Template::display_template( $template_path, $this->_template_args, TRUE );
1498
+			$template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_questions.template.php';
1499
+			echo EEH_Template::display_template($template_path, $this->_template_args, TRUE);
1500 1500
 		}
1501 1501
 	}
1502 1502
 
@@ -1510,12 +1510,12 @@  discard block
 block discarded – undo
1510 1510
 	 * @param        string $output
1511 1511
 	 * @return        string
1512 1512
 	 */
1513
-	public function form_before_question_group( $output ) {
1513
+	public function form_before_question_group($output) {
1514 1514
 		EE_Error::doing_it_wrong(
1515
-			__CLASS__ . '::' . __FUNCTION__,
1516
-			__( 'This method would have been protected but was used on a filter callback'
1515
+			__CLASS__.'::'.__FUNCTION__,
1516
+			__('This method would have been protected but was used on a filter callback'
1517 1517
 				. 'so needed to be public. Please discontinue usage as it will be removed soon.',
1518
-				'event_espresso' ),
1518
+				'event_espresso'),
1519 1519
 			'4.8.32.rc.000'
1520 1520
 		);
1521 1521
 		return '
@@ -1534,20 +1534,20 @@  discard block
 block discarded – undo
1534 1534
 	 * @param        string $output
1535 1535
 	 * @return        string
1536 1536
 	 */
1537
-	public function form_after_question_group( $output ) {
1537
+	public function form_after_question_group($output) {
1538 1538
 		EE_Error::doing_it_wrong(
1539
-			__CLASS__ . '::' . __FUNCTION__,
1540
-			__( 'This method would have been protected but was used on a filter callback'
1539
+			__CLASS__.'::'.__FUNCTION__,
1540
+			__('This method would have been protected but was used on a filter callback'
1541 1541
 				. 'so needed to be public. Please discontinue usage as it will be removed soon.',
1542
-				'event_espresso' ),
1542
+				'event_espresso'),
1543 1543
 			'4.8.32.rc.000'
1544 1544
 		);
1545 1545
 		return  '
1546 1546
 			<tr class="hide-if-no-js">
1547 1547
 				<th> </th>
1548 1548
 				<td class="reg-admin-edit-attendee-question-td">
1549
-					<a class="reg-admin-edit-attendee-question-lnk" href="#" title="' . esc_attr__( 'click to edit question', 'event_espresso' ) . '">
1550
-						<span class="reg-admin-edit-question-group-spn lt-grey-txt">' . __( 'edit the above question group', 'event_espresso' ) . '</span>
1549
+					<a class="reg-admin-edit-attendee-question-lnk" href="#" title="' . esc_attr__('click to edit question', 'event_espresso').'">
1550
+						<span class="reg-admin-edit-question-group-spn lt-grey-txt">' . __('edit the above question group', 'event_espresso').'</span>
1551 1551
 						<div class="dashicons dashicons-edit"></div>
1552 1552
 					</a>
1553 1553
 				</td>
@@ -1567,18 +1567,18 @@  discard block
 block discarded – undo
1567 1567
 	 * @param        string $label
1568 1568
 	 * @return        string
1569 1569
 	 */
1570
-	public function form_form_field_label_wrap( $label ) {
1570
+	public function form_form_field_label_wrap($label) {
1571 1571
 		EE_Error::doing_it_wrong(
1572
-			__CLASS__ . '::' . __FUNCTION__,
1573
-			__( 'This method would have been protected but was used on a filter callback'
1572
+			__CLASS__.'::'.__FUNCTION__,
1573
+			__('This method would have been protected but was used on a filter callback'
1574 1574
 				. 'so needed to be public. Please discontinue usage as it will be removed soon.',
1575
-				'event_espresso' ),
1575
+				'event_espresso'),
1576 1576
 			'4.8.32.rc.000'
1577 1577
 		);
1578 1578
 		return '
1579 1579
 			<tr>
1580 1580
 				<th>
1581
-					' . $label  . '
1581
+					' . $label.'
1582 1582
 				</th>';
1583 1583
 	}
1584 1584
 
@@ -1592,17 +1592,17 @@  discard block
 block discarded – undo
1592 1592
 	 * @param        string $input
1593 1593
 	 * @return        string
1594 1594
 	 */
1595
-	public function form_form_field_input__wrap( $input ) {
1595
+	public function form_form_field_input__wrap($input) {
1596 1596
 		EE_Error::doing_it_wrong(
1597
-			__CLASS__ . '::' . __FUNCTION__,
1598
-			__( 'This method would have been protected but was used on a filter callback'
1597
+			__CLASS__.'::'.__FUNCTION__,
1598
+			__('This method would have been protected but was used on a filter callback'
1599 1599
 				. 'so needed to be public. Please discontinue usage as it will be removed soon.',
1600
-				'event_espresso' ),
1600
+				'event_espresso'),
1601 1601
 			'4.8.32.rc.000'
1602 1602
 		);
1603 1603
 		return '
1604 1604
 				<td class="reg-admin-attendee-questions-input-td disabled-input">
1605
-					' . $input . '
1605
+					' . $input.'
1606 1606
 				</td>
1607 1607
 			</tr>';
1608 1608
 	}
@@ -1616,14 +1616,14 @@  discard block
 block discarded – undo
1616 1616
 	 * @return void
1617 1617
 	 */
1618 1618
 	protected function _update_attendee_registration_form() {
1619
-		do_action( 'AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', $this );
1620
-		if( $_SERVER['REQUEST_METHOD'] == 'POST'){
1621
-			$REG_ID = isset( $this->_req_data['_REG_ID'] ) ? absint( $this->_req_data['_REG_ID'] ) : FALSE;
1622
-			$success = $this->_save_reg_custom_questions_form( $REG_ID );
1623
-			if( $success ) {
1619
+		do_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', $this);
1620
+		if ($_SERVER['REQUEST_METHOD'] == 'POST') {
1621
+			$REG_ID = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : FALSE;
1622
+			$success = $this->_save_reg_custom_questions_form($REG_ID);
1623
+			if ($success) {
1624 1624
 				$what = __('Registration Form', 'event_espresso');
1625
-				$route = $REG_ID ? array( 'action' => 'view_registration', '_REG_ID' => $REG_ID ) : array( 'action' => 'default' );
1626
-				$this->_redirect_after_action( $success, $what, __('updated', 'event_espresso'), $route );
1625
+				$route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID) : array('action' => 'default');
1626
+				$this->_redirect_after_action($success, $what, __('updated', 'event_espresso'), $route);
1627 1627
 			}
1628 1628
 		}
1629 1629
 	}
@@ -1634,11 +1634,11 @@  discard block
 block discarded – undo
1634 1634
 	 * @param int $REG_ID
1635 1635
 	 * @return EE_Registration_Custom_Questions_Form
1636 1636
 	 */
1637
-	protected function _get_reg_custom_questions_form( $REG_ID ) {
1638
-		if( ! $this->_reg_custom_questions_form ) {
1639
-			require_once( REG_ADMIN . 'form_sections' . DS . 'EE_Registration_Custom_Questions_Form.form.php' );
1640
-			$this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form( EEM_Registration::instance()->get_one_by_ID( $REG_ID ) );
1641
-			$this->_reg_custom_questions_form->_construct_finalize( null, null );
1637
+	protected function _get_reg_custom_questions_form($REG_ID) {
1638
+		if ( ! $this->_reg_custom_questions_form) {
1639
+			require_once(REG_ADMIN.'form_sections'.DS.'EE_Registration_Custom_Questions_Form.form.php');
1640
+			$this->_reg_custom_questions_form = new EE_Registration_Custom_Questions_Form(EEM_Registration::instance()->get_one_by_ID($REG_ID));
1641
+			$this->_reg_custom_questions_form->_construct_finalize(null, null);
1642 1642
 		}
1643 1643
 		return $this->_reg_custom_questions_form;
1644 1644
 	}
@@ -1651,17 +1651,17 @@  discard block
 block discarded – undo
1651 1651
 	 * @param bool $REG_ID
1652 1652
 	 * @return bool
1653 1653
 	 */
1654
-	private function _save_reg_custom_questions_form( $REG_ID = FALSE ) {
1654
+	private function _save_reg_custom_questions_form($REG_ID = FALSE) {
1655 1655
 
1656 1656
 		if ( ! $REG_ID) {
1657
-			EE_Error::add_error( __('An error occurred. No registration ID was received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
1657
+			EE_Error::add_error(__('An error occurred. No registration ID was received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1658 1658
 		}
1659
-		$form = $this->_get_reg_custom_questions_form( $REG_ID );
1660
-		$form->receive_form_submission( $this->_req_data );
1659
+		$form = $this->_get_reg_custom_questions_form($REG_ID);
1660
+		$form->receive_form_submission($this->_req_data);
1661 1661
 		$success = false;
1662
-		if( $form->is_valid() ) {
1663
-			foreach( $form->subforms() as $question_group_id => $question_group_form ) {
1664
-				foreach( $question_group_form->inputs() as $question_id => $input ) {
1662
+		if ($form->is_valid()) {
1663
+			foreach ($form->subforms() as $question_group_id => $question_group_form) {
1664
+				foreach ($question_group_form->inputs() as $question_id => $input) {
1665 1665
 					$where_conditions = array(
1666 1666
 							'QST_ID' => $question_id,
1667 1667
 							'REG_ID' => $REG_ID
@@ -1669,19 +1669,19 @@  discard block
 block discarded – undo
1669 1669
 					$possibly_new_values = array(
1670 1670
 							'ANS_value' => $input->normalized_value()
1671 1671
 						);
1672
-					$answer = EEM_Answer::instance()->get_one( array( $where_conditions ) );
1673
-					if( $answer instanceof EE_Answer ) {
1674
-						$success = $answer->save( $possibly_new_values );
1672
+					$answer = EEM_Answer::instance()->get_one(array($where_conditions));
1673
+					if ($answer instanceof EE_Answer) {
1674
+						$success = $answer->save($possibly_new_values);
1675 1675
 					} else {
1676 1676
 						//insert it then
1677
-						$cols_n_vals = array_merge( $where_conditions, $possibly_new_values );
1678
-						$answer = EE_Answer::new_instance( $cols_n_vals );
1677
+						$cols_n_vals = array_merge($where_conditions, $possibly_new_values);
1678
+						$answer = EE_Answer::new_instance($cols_n_vals);
1679 1679
 						$success = $answer->save();
1680 1680
 					}
1681 1681
 				}
1682 1682
 			}
1683 1683
 		} else {
1684
-			EE_Error::add_error( $form->get_validation_error_string(), __FILE__, __FUNCTION__, __LINE__ );
1684
+			EE_Error::add_error($form->get_validation_error_string(), __FILE__, __FUNCTION__, __LINE__);
1685 1685
 		}
1686 1686
 		return $success;
1687 1687
 	}
@@ -1699,30 +1699,30 @@  discard block
 block discarded – undo
1699 1699
 		$registrations = $REG->get_all(array(
1700 1700
 			array(
1701 1701
 				'TXN_ID'=>$this->_registration->transaction_ID(),
1702
-				'REG_ID'=>array('!=',$this->_registration->ID())
1702
+				'REG_ID'=>array('!=', $this->_registration->ID())
1703 1703
 			),
1704 1704
 			'force_join'=>array('Attendee')));
1705 1705
 
1706 1706
 		$this->_template_args['attendees'] = array();
1707 1707
 		$this->_template_args['attendee_notice'] = '';
1708 1708
 		EE_Registry::instance()->load_helper('Array');
1709
-		if ( empty( $registrations)  || ( is_array($registrations) &&  ! EEH_Array::get_one_item_from_array($registrations) ) ) {
1710
-			EE_Error::add_error( __('There are no records attached to this registration. Something may have gone wrong with the registration', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
1709
+		if (empty($registrations) || (is_array($registrations) && ! EEH_Array::get_one_item_from_array($registrations))) {
1710
+			EE_Error::add_error(__('There are no records attached to this registration. Something may have gone wrong with the registration', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1711 1711
 			$this->_template_args['attendee_notice'] = EE_Error::get_notices();
1712 1712
 		} else {
1713 1713
 
1714 1714
 			$att_nmbr = 1;
1715
-			foreach ( $registrations as $registration ) {
1715
+			foreach ($registrations as $registration) {
1716 1716
 				/* @var $registration EE_Registration */
1717 1717
 				$attendee = $registration->attendee() ? $registration->attendee() : EEM_Attendee::instance()->create_default_object();
1718
-				$this->_template_args['attendees'][ $att_nmbr ]['fname'] = $attendee->fname();//( isset( $registration->ATT_fname ) & ! empty( $registration->ATT_fname ) ) ? $registration->ATT_fname : '';
1719
-				$this->_template_args['attendees'][ $att_nmbr ]['lname'] = $attendee->lname();//( isset( $registration->ATT_lname ) & ! empty( $registration->ATT_lname ) ) ? $registration->ATT_lname : '';
1720
-				$this->_template_args['attendees'][ $att_nmbr ]['email'] = $attendee->email();//( isset( $registration->ATT_email ) & ! empty( $registration->ATT_email ) ) ? $registration->ATT_email : '';
1721
-				$this->_template_args['attendees'][ $att_nmbr ]['final_price'] = $registration->final_price();//( isset( $registration->REG_final_price ) & ! empty( $registration->REG_final_price ) ) ? $registration->REG_final_price : '';
1718
+				$this->_template_args['attendees'][$att_nmbr]['fname'] = $attendee->fname(); //( isset( $registration->ATT_fname ) & ! empty( $registration->ATT_fname ) ) ? $registration->ATT_fname : '';
1719
+				$this->_template_args['attendees'][$att_nmbr]['lname'] = $attendee->lname(); //( isset( $registration->ATT_lname ) & ! empty( $registration->ATT_lname ) ) ? $registration->ATT_lname : '';
1720
+				$this->_template_args['attendees'][$att_nmbr]['email'] = $attendee->email(); //( isset( $registration->ATT_email ) & ! empty( $registration->ATT_email ) ) ? $registration->ATT_email : '';
1721
+				$this->_template_args['attendees'][$att_nmbr]['final_price'] = $registration->final_price(); //( isset( $registration->REG_final_price ) & ! empty( $registration->REG_final_price ) ) ? $registration->REG_final_price : '';
1722 1722
 
1723
-				$this->_template_args['attendees'][ $att_nmbr ]['address'] = implode( ', ', $attendee->full_address_as_array() );
1723
+				$this->_template_args['attendees'][$att_nmbr]['address'] = implode(', ', $attendee->full_address_as_array());
1724 1724
 
1725
-				$this->_template_args['attendees'][ $att_nmbr ]['att_link'] = self::add_query_args_and_nonce( array( 'action'=>'edit_attendee', 'post'=>$attendee->ID() ), REG_ADMIN_URL );
1725
+				$this->_template_args['attendees'][$att_nmbr]['att_link'] = self::add_query_args_and_nonce(array('action'=>'edit_attendee', 'post'=>$attendee->ID()), REG_ADMIN_URL);
1726 1726
 
1727 1727
 				$att_nmbr++;
1728 1728
 			}
@@ -1734,8 +1734,8 @@  discard block
 block discarded – undo
1734 1734
 
1735 1735
 	//			$this->_template_args['registration_form_url'] = add_query_arg( array( 'action' => 'edit_registration', 'process' => 'attendees'  ), REG_ADMIN_URL );
1736 1736
 		}
1737
-		$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php';
1738
-		echo EEH_Template::display_template( $template_path, $this->_template_args, TRUE );
1737
+		$template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_attendees.template.php';
1738
+		echo EEH_Template::display_template($template_path, $this->_template_args, TRUE);
1739 1739
 
1740 1740
 	}
1741 1741
 
@@ -1756,11 +1756,11 @@  discard block
 block discarded – undo
1756 1756
 		$attendee = $att_check instanceof EE_Attendee ? $att_check : EEM_Attendee::instance()->create_default_object();
1757 1757
 
1758 1758
 		//now let's determine if this is not the primary registration.  If it isn't then we set the primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the primary registration object (that way we know if we need to show cereate button or not)
1759
-		if ( ! $this->_registration->is_primary_registrant() ) {
1759
+		if ( ! $this->_registration->is_primary_registrant()) {
1760 1760
 			$primary_registration = $this->_registration->get_primary_registration();
1761 1761
 			$primary_attendee = $primary_registration->attendee();
1762 1762
 
1763
-			if ( ! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID() ) {
1763
+			if ( ! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) {
1764 1764
 				//in here?  This means the displayed registration is not the primary registrant but ALREADY HAS its own custom attendee object so let's not worry about the primary reg.
1765 1765
 				$primary_registration = NULL;
1766 1766
 			}
@@ -1769,28 +1769,28 @@  discard block
 block discarded – undo
1769 1769
 		}
1770 1770
 
1771 1771
 		$this->_template_args['ATT_ID'] = $attendee->ID();
1772
-		$this->_template_args['fname'] = $attendee->fname();//$this->_registration->ATT_fname;
1773
-		$this->_template_args['lname'] = $attendee->lname();//$this->_registration->ATT_lname;
1774
-		$this->_template_args['email'] = $attendee->email();//$this->_registration->ATT_email;
1772
+		$this->_template_args['fname'] = $attendee->fname(); //$this->_registration->ATT_fname;
1773
+		$this->_template_args['lname'] = $attendee->lname(); //$this->_registration->ATT_lname;
1774
+		$this->_template_args['email'] = $attendee->email(); //$this->_registration->ATT_email;
1775 1775
 		$this->_template_args['phone'] = $attendee->phone();
1776 1776
 
1777
-		EE_Registry::instance()->load_helper( 'Formatter' );
1778
-		$this->_template_args[ 'formatted_address' ] = EEH_Address::format( $attendee );
1777
+		EE_Registry::instance()->load_helper('Formatter');
1778
+		$this->_template_args['formatted_address'] = EEH_Address::format($attendee);
1779 1779
 
1780 1780
 
1781 1781
 		//edit link
1782
-		$this->_template_args['att_edit_link'] = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'edit_attendee', 'post'=>$attendee->ID() ), REG_ADMIN_URL );
1783
-		$this->_template_args['att_edit_label'] = __('View/Edit Contact' );
1782
+		$this->_template_args['att_edit_link'] = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'edit_attendee', 'post'=>$attendee->ID()), REG_ADMIN_URL);
1783
+		$this->_template_args['att_edit_label'] = __('View/Edit Contact');
1784 1784
 
1785 1785
 		//create link
1786
-		$this->_template_args['create_link'] = $primary_registration instanceof EE_Registration ? EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'duplicate_attendee',  '_REG_ID' => $this->_registration->ID() ), REG_ADMIN_URL ): '';
1786
+		$this->_template_args['create_link'] = $primary_registration instanceof EE_Registration ? EE_Admin_Page::add_query_args_and_nonce(array('action' => 'duplicate_attendee', '_REG_ID' => $this->_registration->ID()), REG_ADMIN_URL) : '';
1787 1787
 		$this->_template_args['create_label'] = __('Create Contact', 'event_espresso');
1788 1788
 
1789 1789
 		$this->_template_args['att_check'] = $att_check;
1790 1790
 
1791 1791
 
1792
-		$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php';
1793
-		echo EEH_Template::display_template( $template_path, $this->_template_args, TRUE );
1792
+		$template_path = REG_TEMPLATE_PATH.'reg_admin_details_side_meta_box_registrant.template.php';
1793
+		echo EEH_Template::display_template($template_path, $this->_template_args, TRUE);
1794 1794
 	}
1795 1795
 
1796 1796
 
@@ -1803,7 +1803,7 @@  discard block
 block discarded – undo
1803 1803
 	 * @access protected
1804 1804
 	 * @return void
1805 1805
 	 */
1806
-	protected function _trash_or_restore_registrations( $trash = TRUE ) {
1806
+	protected function _trash_or_restore_registrations($trash = TRUE) {
1807 1807
 		$REGM = EEM_Registration::instance();
1808 1808
 
1809 1809
 		$success = 1;
@@ -1813,26 +1813,26 @@  discard block
 block discarded – undo
1813 1813
 		$dtts = array();
1814 1814
 
1815 1815
 		//if empty _REG_ID then get out because there's nothing to do
1816
-		if ( empty( $this->_req_data['_REG_ID'] ) ) {
1816
+		if (empty($this->_req_data['_REG_ID'])) {
1817 1817
 			$msg = $trash ? __('In order to trash registrations you must select which ones you wish to trash by clicking the checkboxes.', 'event_espresso') : __('In order to restore registrations you must select which ones you wish to restore by clicking the checkboxes.', 'event_espresso');
1818
-			EE_Error::add_error( $msg, __FILE__, __LINE__, __FUNCTION__ );
1819
-			$this->_redirect_after_action(FALSE, '', '', array(), TRUE );
1818
+			EE_Error::add_error($msg, __FILE__, __LINE__, __FUNCTION__);
1819
+			$this->_redirect_after_action(FALSE, '', '', array(), TRUE);
1820 1820
 		}
1821 1821
 
1822 1822
 		//Checkboxes
1823
-		if (!empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) {
1823
+		if ( ! empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) {
1824 1824
 			// if array has more than one element than success message should be plural
1825
-			$success = count( $this->_req_data['_REG_ID'] ) > 1 ? 2 : 1;
1825
+			$success = count($this->_req_data['_REG_ID']) > 1 ? 2 : 1;
1826 1826
 			// cycle thru checkboxes
1827
-			while (list( $ind, $REG_ID ) = each($this->_req_data['_REG_ID'])) {
1827
+			while (list($ind, $REG_ID) = each($this->_req_data['_REG_ID'])) {
1828 1828
 
1829 1829
 				$REG = $REGM->get_one_by_ID($REG_ID);
1830 1830
 				$payment_count = $REG->get_first_related('Transaction')->count_related('Payment');
1831
-				if ( $payment_count > 0 ) {
1832
-					$name = $REG->attendee() instanceof EE_Attendee ? $REG->attendee()->full_name() : __( 'Unknown Attendee', 'event_espresso' );
1831
+				if ($payment_count > 0) {
1832
+					$name = $REG->attendee() instanceof EE_Attendee ? $REG->attendee()->full_name() : __('Unknown Attendee', 'event_espresso');
1833 1833
 					$error = 1;
1834 1834
 					$success = 0;
1835
-					EE_Error::add_error( sprintf( __('The registration for %s could not be trashed because it has payments attached to the related transaction.  If you wish to trash this registration you must first delete the payments on the related transaction.', 'event_espresso'), $name ), __FILE__, __FUNCTION__, __LINE__ );
1835
+					EE_Error::add_error(sprintf(__('The registration for %s could not be trashed because it has payments attached to the related transaction.  If you wish to trash this registration you must first delete the payments on the related transaction.', 'event_espresso'), $name), __FILE__, __FUNCTION__, __LINE__);
1836 1836
 					continue; //can't trash this registration because it has payments.
1837 1837
 				}
1838 1838
 				$ticket = $REG->get_first_related('Ticket');
@@ -1841,7 +1841,7 @@  discard block
 block discarded – undo
1841 1841
 				$dtts = array_merge($dtts, $dtt);
1842 1842
 
1843 1843
 				$updated = $trash ? $REG->delete() : $REG->restore();
1844
-				if ( !$updated ) {
1844
+				if ( ! $updated) {
1845 1845
 					$success = 0;
1846 1846
 				} else {
1847 1847
 					$success = 2;
@@ -1856,7 +1856,7 @@  discard block
 block discarded – undo
1856 1856
 			$tickets[$ticket->ID()] = $ticket;
1857 1857
 			$dtts = $ticket->get_many_related('Datetime');
1858 1858
 			$updated = $trash ? $REG->delete() : $REG->restore();
1859
-			if ( ! $updated ) {
1859
+			if ( ! $updated) {
1860 1860
 				$success = 0;
1861 1861
 			}
1862 1862
 
@@ -1866,10 +1866,10 @@  discard block
 block discarded – undo
1866 1866
 		EEM_Ticket::instance()->update_tickets_sold($tickets);
1867 1867
 		EEM_Datetime::instance()->update_sold($dtts);
1868 1868
 
1869
-		$what = $success > 1 ? __( 'Registrations', 'event_espresso' ) : __( 'Registration', 'event_espresso' );
1870
-		$action_desc = $trash ? __( 'moved to the trash', 'event_espresso' ) : __( 'restored', 'event_espresso' );
1869
+		$what = $success > 1 ? __('Registrations', 'event_espresso') : __('Registration', 'event_espresso');
1870
+		$action_desc = $trash ? __('moved to the trash', 'event_espresso') : __('restored', 'event_espresso');
1871 1871
 		$overwrite_msgs = $error ? TRUE : FALSE;
1872
-		$this->_redirect_after_action( $success, $what, $action_desc, array( 'action' => 'default' ), $overwrite_msgs );
1872
+		$this->_redirect_after_action($success, $what, $action_desc, array('action' => 'default'), $overwrite_msgs);
1873 1873
 	}
1874 1874
 
1875 1875
 
@@ -1893,16 +1893,16 @@  discard block
 block discarded – undo
1893 1893
 		$success = 1;
1894 1894
 
1895 1895
 		//Checkboxes
1896
-		if (!empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) {
1896
+		if ( ! empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) {
1897 1897
 			// if array has more than one element than success message should be plural
1898
-			$success = count( $this->_req_data['_REG_ID'] ) > 1 ? 2 : 1;
1898
+			$success = count($this->_req_data['_REG_ID']) > 1 ? 2 : 1;
1899 1899
 			// cycle thru checkboxes
1900
-			while (list( $ind, $REG_ID ) = each($this->_req_data['_REG_ID'])) {
1900
+			while (list($ind, $REG_ID) = each($this->_req_data['_REG_ID'])) {
1901 1901
 				$REG = $REG_MDL->get_one_by_ID($REG_ID);
1902
-				if ( ! $REG instanceof EE_Registration )
1902
+				if ( ! $REG instanceof EE_Registration)
1903 1903
 					continue;
1904 1904
 				$deleted = $this->_delete_registration($REG);
1905
-				if ( !$deleted ) {
1905
+				if ( ! $deleted) {
1906 1906
 					$success = 0;
1907 1907
 				}
1908 1908
 			}
@@ -1912,15 +1912,15 @@  discard block
 block discarded – undo
1912 1912
 			$REG_ID = $this->_req_data['_REG_ID'];
1913 1913
 			$REG = $REG_MDL->get_one_by_ID($REG_ID);
1914 1914
 			$deleted = $this->_delete_registration($REG);
1915
-			if ( ! $deleted ) {
1915
+			if ( ! $deleted) {
1916 1916
 				$success = 0;
1917 1917
 			}
1918 1918
 
1919 1919
 		}
1920 1920
 
1921
-		$what = $success > 1 ? __( 'Registrations', 'event_espresso' ) : __( 'Registration', 'event_espresso' );
1922
-		$action_desc = __( 'permanently deleted.', 'event_espresso' );
1923
-		$this->_redirect_after_action( $success, $what, $action_desc, array( 'action' => 'default' ), TRUE );
1921
+		$what = $success > 1 ? __('Registrations', 'event_espresso') : __('Registration', 'event_espresso');
1922
+		$action_desc = __('permanently deleted.', 'event_espresso');
1923
+		$this->_redirect_after_action($success, $what, $action_desc, array('action' => 'default'), TRUE);
1924 1924
 	}
1925 1925
 
1926 1926
 
@@ -1932,31 +1932,31 @@  discard block
 block discarded – undo
1932 1932
 	 * @param  EE_Registration $REG registration to be deleted permenantly
1933 1933
 	 * @return boolean              true = successful deletion, false = fail.
1934 1934
 	 */
1935
-	protected function _delete_registration( EE_Registration $REG ) {
1935
+	protected function _delete_registration(EE_Registration $REG) {
1936 1936
 		//first we start with the transaction... ultimately, we WILL not delete permanently if there are any related registrations on the transaction that are NOT trashed.
1937 1937
 		$TXN = $REG->get_first_related('Transaction');
1938 1938
 		$REGS = $TXN->get_many_related('Registration');
1939 1939
 
1940 1940
 		$all_trashed = TRUE;
1941
-		foreach ( $REGS as $registration ) {
1942
-			if ( ! $registration->get('REG_deleted') )
1941
+		foreach ($REGS as $registration) {
1942
+			if ( ! $registration->get('REG_deleted'))
1943 1943
 				$all_trashed = FALSE;
1944 1944
 		}
1945 1945
 
1946
-		if ( ! $all_trashed ) {
1947
-			EE_Error::add_error( __('Unable to permanently delete this registration. Before this registration can be permanently deleted, all registrations made in the same transaction must be trashed as well.  These registrations will be permanently deleted in the same action.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
1946
+		if ( ! $all_trashed) {
1947
+			EE_Error::add_error(__('Unable to permanently delete this registration. Before this registration can be permanently deleted, all registrations made in the same transaction must be trashed as well.  These registrations will be permanently deleted in the same action.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1948 1948
 			return false;
1949 1949
 		}
1950 1950
 
1951 1951
 		//k made it here so that means we can delete all the related transactions and their answers (but let's do them separately from THIS one).
1952
-		foreach ( $REGS as $registration ) {
1952
+		foreach ($REGS as $registration) {
1953 1953
 
1954 1954
 			//delete related answers
1955 1955
 			$registration->delete_related_permanently('Answer');
1956 1956
 
1957 1957
 			//remove relationship to EE_Attendee (but we ALWAYS leave the contact record intact)
1958 1958
 			$attendee = $registration->get_first_related('Attendee');
1959
-			if ( $attendee instanceof EE_Attendee ) {
1959
+			if ($attendee instanceof EE_Attendee) {
1960 1960
 				$registration->_remove_relation_to($attendee, 'Attendee');
1961 1961
 			}
1962 1962
 
@@ -1966,7 +1966,7 @@  discard block
 block discarded – undo
1966 1966
 			//now delete permanently the checkins related to this registration.
1967 1967
 			$registration->delete_related_permanently('Checkin');
1968 1968
 
1969
-			if ( $registration->ID() === $REG->ID() )
1969
+			if ($registration->ID() === $REG->ID())
1970 1970
 				continue; //we don't want to delete permanently the existing registration just yet.
1971 1971
 
1972 1972
 			//remove relation to transaction for these registrations if NOT the existing registrations
@@ -1999,34 +1999,34 @@  discard block
 block discarded – undo
1999 1999
 	 * @return void
2000 2000
 	 */
2001 2001
 	public function new_registration() {
2002
-		if ( ! $this->_set_reg_event() ) {
2003
-			throw new EE_Error(__('Unable to continue with registering because there is no Event ID in the request', 'event_espresso') );
2002
+		if ( ! $this->_set_reg_event()) {
2003
+			throw new EE_Error(__('Unable to continue with registering because there is no Event ID in the request', 'event_espresso'));
2004 2004
 		}
2005
-		EE_Registry::instance()->REQ->set_espresso_page( TRUE );
2005
+		EE_Registry::instance()->REQ->set_espresso_page(TRUE);
2006 2006
 
2007 2007
 		// gotta start with a clean slate if we're not coming here via ajax
2008
-		if ( ! defined('DOING_AJAX' ) && ( ! isset( $this->_req_data['processing_registration'] ) || isset( $this->_req_data['step_error'] ))) {
2009
-			EE_Registry::instance()->SSN->clear_session( __CLASS__, __FUNCTION__ );
2008
+		if ( ! defined('DOING_AJAX') && ( ! isset($this->_req_data['processing_registration']) || isset($this->_req_data['step_error']))) {
2009
+			EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
2010 2010
 		}
2011 2011
 
2012
-		$this->_template_args['event_name'] = '' ;
2012
+		$this->_template_args['event_name'] = '';
2013 2013
 		// event name
2014
-		if ( $this->_reg_event ) {
2014
+		if ($this->_reg_event) {
2015 2015
 			$this->_template_args['event_name'] = $this->_reg_event->name();
2016
-			$edit_event_url = self::add_query_args_and_nonce( array( 'action'=>'edit', 'post'=>$this->_reg_event->ID() ), EVENTS_ADMIN_URL );
2017
-			$edit_event_lnk = '<a href="'.$edit_event_url.'" title="' . esc_attr__( 'Edit ', 'event_espresso' ) . $this->_reg_event->name() . '">' . __( 'Edit Event', 'event_espresso' ) . '</a>';
2018
-			$this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">' . $edit_event_lnk . '</span>' ;
2016
+			$edit_event_url = self::add_query_args_and_nonce(array('action'=>'edit', 'post'=>$this->_reg_event->ID()), EVENTS_ADMIN_URL);
2017
+			$edit_event_lnk = '<a href="'.$edit_event_url.'" title="'.esc_attr__('Edit ', 'event_espresso').$this->_reg_event->name().'">'.__('Edit Event', 'event_espresso').'</a>';
2018
+			$this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">'.$edit_event_lnk.'</span>';
2019 2019
 		}
2020 2020
 
2021 2021
 		$this->_template_args['step_content'] = $this->_get_registration_step_content();
2022 2022
 
2023
-		if ( defined('DOING_AJAX' ) )
2023
+		if (defined('DOING_AJAX'))
2024 2024
 			$this->_return_json();
2025 2025
 
2026 2026
 
2027 2027
 		// grab header
2028
-		$template_path = REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php';
2029
-		$this->_template_args['admin_page_content'] = EEH_Template::display_template( $template_path, $this->_template_args, TRUE );
2028
+		$template_path = REG_TEMPLATE_PATH.'reg_admin_register_new_attendee.template.php';
2029
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, $this->_template_args, TRUE);
2030 2030
 
2031 2031
 		//$this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
2032 2032
 		// the details template wrapper
@@ -2044,7 +2044,7 @@  discard block
 block discarded – undo
2044 2044
 	 */
2045 2045
 	protected function _get_registration_step_content() {
2046 2046
 
2047
-		$template_path = REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee_step_content.template.php';
2047
+		$template_path = REG_TEMPLATE_PATH.'reg_admin_register_new_attendee_step_content.template.php';
2048 2048
 		$template_args = array(
2049 2049
 			'title' => '',
2050 2050
 			'content' => '',
@@ -2065,11 +2065,11 @@  discard block
 block discarded – undo
2065 2065
 
2066 2066
 		//if the cart is empty then we know we're at step one so we'll display ticket selector
2067 2067
 		$cart = EE_Registry::instance()->SSN->get_session_data('cart');
2068
-		$step = empty( $cart ) ? 'ticket' : 'questions';
2069
-		switch ( $step ) {
2068
+		$step = empty($cart) ? 'ticket' : 'questions';
2069
+		switch ($step) {
2070 2070
 			case 'ticket' :
2071 2071
 				$template_args['title'] = __('Step One: Select the Ticket for this registration', 'event_espresso');
2072
-				$template_args['content'] = EED_Ticket_Selector::instance()->display_ticket_selector( $this->_reg_event );
2072
+				$template_args['content'] = EED_Ticket_Selector::instance()->display_ticket_selector($this->_reg_event);
2073 2073
 				$template_args['step_button_text'] = __('Add Tickets and Continue to Registrant Details', 'event_espresso');
2074 2074
 				$template_args['show_notification_toggle'] = FALSE;
2075 2075
 				break;
@@ -2082,9 +2082,9 @@  discard block
 block discarded – undo
2082 2082
 				break;
2083 2083
 		}
2084 2084
 
2085
-		$this->_set_add_edit_form_tags( 'process_reg_step', $hidden_fields ); //we come back to the process_registration_step route.
2085
+		$this->_set_add_edit_form_tags('process_reg_step', $hidden_fields); //we come back to the process_registration_step route.
2086 2086
 
2087
-		return EEH_Template::display_template( $template_path, $template_args, TRUE );
2087
+		return EEH_Template::display_template($template_path, $template_args, TRUE);
2088 2088
 	}
2089 2089
 
2090 2090
 
@@ -2098,11 +2098,11 @@  discard block
 block discarded – undo
2098 2098
 	*		@return boolean
2099 2099
 	*/
2100 2100
 	private function _set_reg_event() {
2101
-		if ( is_object( $this->_reg_event )) {
2101
+		if (is_object($this->_reg_event)) {
2102 2102
 			return TRUE;
2103 2103
 		}
2104
-		$EVT_ID = ( ! empty( $this->_req_data['event_id'] )) ? absint( $this->_req_data['event_id'] ) : FALSE;
2105
-		if ( ! $EVT_ID ) {
2104
+		$EVT_ID = ( ! empty($this->_req_data['event_id'])) ? absint($this->_req_data['event_id']) : FALSE;
2105
+		if ( ! $EVT_ID) {
2106 2106
 			return FALSE;
2107 2107
 		}
2108 2108
 
@@ -2123,62 +2123,62 @@  discard block
 block discarded – undo
2123 2123
 	public function process_reg_step() {
2124 2124
 
2125 2125
 		$this->_set_reg_event();
2126
-		EE_Registry::instance()->REQ->set_espresso_page( TRUE );
2126
+		EE_Registry::instance()->REQ->set_espresso_page(TRUE);
2127 2127
 
2128 2128
 		//what step are we on?
2129
-		$cart = EE_Registry::instance()->SSN->get_session_data( 'cart' );
2130
-		$step = empty( $cart ) ? 'ticket' : 'questions';
2129
+		$cart = EE_Registry::instance()->SSN->get_session_data('cart');
2130
+		$step = empty($cart) ? 'ticket' : 'questions';
2131 2131
 
2132 2132
 		//if doing ajax then we need to verify the nonce
2133
-		if ( 'DOING_AJAX' ) {
2134
-			$nonce = isset( $this->_req_data[$this->_req_nonce] ) ? sanitize_text_field( $this->_req_data[$this->_req_nonce] ) : '';
2135
-			$this->_verify_nonce( $nonce, $this->_req_nonce );
2133
+		if ('DOING_AJAX') {
2134
+			$nonce = isset($this->_req_data[$this->_req_nonce]) ? sanitize_text_field($this->_req_data[$this->_req_nonce]) : '';
2135
+			$this->_verify_nonce($nonce, $this->_req_nonce);
2136 2136
 		}
2137 2137
 
2138
-		switch ( $step ) {
2138
+		switch ($step) {
2139 2139
 			case 'ticket' :
2140 2140
 				//process ticket selection
2141 2141
 				$success = EED_Ticket_Selector::instance()->process_ticket_selections();
2142
-				if ( $success ) {
2143
-					EE_Error::add_success( __('Tickets Selected. Now complete the registration.'), 'event_espresso');
2142
+				if ($success) {
2143
+					EE_Error::add_success(__('Tickets Selected. Now complete the registration.'), 'event_espresso');
2144 2144
 				} else {
2145 2145
 					$query_args['step_error'] = $this->_req_data['step_error'] = TRUE;
2146 2146
 				}
2147
-				if ( defined('DOING_AJAX') ) {
2147
+				if (defined('DOING_AJAX')) {
2148 2148
 					$this->new_registration(); //display next step
2149 2149
 				} else {
2150 2150
 					$query_args['action'] = 'new_registration';
2151 2151
 					$query_args['processing_registration'] = true;
2152 2152
 					$query_args['event_id'] = $this->_reg_event->ID();
2153
-					$this->_redirect_after_action( FALSE, '', '', $query_args, TRUE );
2153
+					$this->_redirect_after_action(FALSE, '', '', $query_args, TRUE);
2154 2154
 				}
2155 2155
 				break;
2156 2156
 			case 'questions' :
2157
-				if( ! isset( $this->_req_data[ 'txn_reg_status_change' ], $this->_req_data[ 'txn_reg_status_change' ][ 'send_notifications' ] ) ) {
2158
-					add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15 );
2157
+				if ( ! isset($this->_req_data['txn_reg_status_change'], $this->_req_data['txn_reg_status_change']['send_notifications'])) {
2158
+					add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15);
2159 2159
 				}
2160 2160
 				//process registration
2161 2161
 				$transaction = EED_Single_Page_Checkout::instance()->process_registration_from_admin();
2162
-				if ( ! $transaction instanceof EE_Transaction ) {
2162
+				if ( ! $transaction instanceof EE_Transaction) {
2163 2163
 					$query_args = array(
2164 2164
 						'action' => 'new_registration',
2165 2165
 						'processing_registration' => true,
2166 2166
 						'event_id' => $this->_reg_event->ID()
2167 2167
 					);
2168 2168
 
2169
-					if ( defined('DOING_AJAX' )) {
2169
+					if (defined('DOING_AJAX')) {
2170 2170
 						//display registration form again because there are errors (maybe validation?)
2171 2171
 						$this->new_registration();
2172 2172
 						return;
2173 2173
 					} else {
2174
-						$this->_redirect_after_action( FALSE, '', '', $query_args, TRUE );
2174
+						$this->_redirect_after_action(FALSE, '', '', $query_args, TRUE);
2175 2175
 						return;
2176 2176
 					}
2177 2177
 				}
2178 2178
 				/** @type EE_Transaction_Payments $transaction_payments */
2179
-				$transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' );
2179
+				$transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
2180 2180
 				// maybe update status, and make sure to save transaction if not done already
2181
-				if ( ! $transaction_payments->update_transaction_status_based_on_total_paid( $transaction )) {
2181
+				if ( ! $transaction_payments->update_transaction_status_based_on_total_paid($transaction)) {
2182 2182
 					$transaction->save();
2183 2183
 				}
2184 2184
 				$query_args = array(
@@ -2186,8 +2186,8 @@  discard block
 block discarded – undo
2186 2186
 					'TXN_ID' => $transaction->ID(),
2187 2187
 					'page' => 'espresso_transactions'
2188 2188
 				);
2189
-				EE_Error::add_success( __('Registration Created.  Please review the transaction and add any payments as necessary', 'event_espresso') );
2190
-				$this->_redirect_after_action( FALSE, '', '', $query_args, TRUE );
2189
+				EE_Error::add_success(__('Registration Created.  Please review the transaction and add any payments as necessary', 'event_espresso'));
2190
+				$this->_redirect_after_action(FALSE, '', '', $query_args, TRUE);
2191 2191
 				break;
2192 2192
 			}
2193 2193
 
@@ -2207,7 +2207,7 @@  discard block
 block discarded – undo
2207 2207
 	*		@return void
2208 2208
 	*/
2209 2209
 	protected function _attendee_contact_list_table() {
2210
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
2210
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2211 2211
 		$this->_search_btn_label = __('Contacts', 'event_espresso');
2212 2212
 		$this->display_admin_list_table_page_with_no_sidebar();
2213 2213
 	}
@@ -2222,10 +2222,10 @@  discard block
 block discarded – undo
2222 2222
 	*		@access public
2223 2223
 	*		@return array
2224 2224
 	*/
2225
-	public function get_attendees( $per_page, $count = FALSE, $trash = FALSE ) {
2225
+	public function get_attendees($per_page, $count = FALSE, $trash = FALSE) {
2226 2226
 
2227
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
2228
-		require_once( REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php' );
2227
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2228
+		require_once(REG_ADMIN.'EE_Attendee_Contact_List_Table.class.php');
2229 2229
 		$ATT_MDL = EEM_Attendee::instance();
2230 2230
 
2231 2231
 		$this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : '';
@@ -2253,47 +2253,47 @@  discard block
 block discarded – undo
2253 2253
 				$orderby = 'ATT_lname';
2254 2254
 		}
2255 2255
 
2256
-		$sort = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] )) ? $this->_req_data['order'] : 'ASC';
2256
+		$sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'ASC';
2257 2257
 
2258
-		$current_page = isset( $this->_req_data['paged'] ) && !empty( $this->_req_data['paged'] ) ? $this->_req_data['paged'] : 1;
2259
-		$per_page = isset( $per_page ) && !empty( $per_page ) ? $per_page : 10;
2260
-		$per_page = isset( $this->_req_data['perpage'] ) && !empty( $this->_req_data['perpage'] ) ? $this->_req_data['perpage'] : $per_page;
2258
+		$current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1;
2259
+		$per_page = isset($per_page) && ! empty($per_page) ? $per_page : 10;
2260
+		$per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $per_page;
2261 2261
 
2262 2262
 		$_where = array();
2263 2263
 
2264
-		if ( isset( $this->_req_data['s'] ) ) {
2265
-			$sstr = '%' . $this->_req_data['s'] . '%';
2264
+		if (isset($this->_req_data['s'])) {
2265
+			$sstr = '%'.$this->_req_data['s'].'%';
2266 2266
 			$_where['OR'] = array(
2267
-				'Registration.Event.EVT_name' => array( 'LIKE', $sstr),
2268
-				'Registration.Event.EVT_desc' => array( 'LIKE', $sstr ),
2269
-				'Registration.Event.EVT_short_desc' => array( 'LIKE' , $sstr ),
2270
-				'ATT_fname' => array( 'LIKE', $sstr ),
2271
-				'ATT_lname' => array( 'LIKE', $sstr ),
2272
-				'ATT_short_bio' => array( 'LIKE', $sstr ),
2273
-				'ATT_email' => array('LIKE', $sstr ),
2274
-				'ATT_address' => array( 'LIKE', $sstr ),
2275
-				'ATT_address2' => array( 'LIKE', $sstr ),
2276
-				'ATT_city' => array( 'LIKE', $sstr ),
2277
-				'Country.CNT_name' => array( 'LIKE', $sstr ),
2278
-				'State.STA_name' => array('LIKE', $sstr ),
2279
-				'ATT_phone' => array( 'LIKE', $sstr ),
2280
-				'Registration.REG_final_price' => array( 'LIKE', $sstr ),
2281
-				'Registration.REG_code' => array( 'LIKE', $sstr ),
2282
-				'Registration.REG_count' => array( 'LIKE' , $sstr ),
2283
-				'Registration.REG_group_size' => array( 'LIKE' , $sstr )
2267
+				'Registration.Event.EVT_name' => array('LIKE', $sstr),
2268
+				'Registration.Event.EVT_desc' => array('LIKE', $sstr),
2269
+				'Registration.Event.EVT_short_desc' => array('LIKE', $sstr),
2270
+				'ATT_fname' => array('LIKE', $sstr),
2271
+				'ATT_lname' => array('LIKE', $sstr),
2272
+				'ATT_short_bio' => array('LIKE', $sstr),
2273
+				'ATT_email' => array('LIKE', $sstr),
2274
+				'ATT_address' => array('LIKE', $sstr),
2275
+				'ATT_address2' => array('LIKE', $sstr),
2276
+				'ATT_city' => array('LIKE', $sstr),
2277
+				'Country.CNT_name' => array('LIKE', $sstr),
2278
+				'State.STA_name' => array('LIKE', $sstr),
2279
+				'ATT_phone' => array('LIKE', $sstr),
2280
+				'Registration.REG_final_price' => array('LIKE', $sstr),
2281
+				'Registration.REG_code' => array('LIKE', $sstr),
2282
+				'Registration.REG_count' => array('LIKE', $sstr),
2283
+				'Registration.REG_group_size' => array('LIKE', $sstr)
2284 2284
 				);
2285 2285
 		}
2286 2286
 
2287 2287
 
2288
-		$offset = ($current_page-1)*$per_page;
2289
-		$limit = $count ? NULL : array( $offset, $per_page );
2288
+		$offset = ($current_page - 1) * $per_page;
2289
+		$limit = $count ? NULL : array($offset, $per_page);
2290 2290
 
2291
-		if ( $trash ) {
2292
-			$_where['status'] = array( '!=', 'publish' );
2293
-			$all_attendees = $count ? $ATT_MDL->count( array($_where,'order_by'=>array($orderby=>$sort), 'limit'=>$limit)): $ATT_MDL->get_all( array($_where,'order_by'=>array($orderby=>$sort), 'limit'=>$limit));
2291
+		if ($trash) {
2292
+			$_where['status'] = array('!=', 'publish');
2293
+			$all_attendees = $count ? $ATT_MDL->count(array($_where, 'order_by'=>array($orderby=>$sort), 'limit'=>$limit)) : $ATT_MDL->get_all(array($_where, 'order_by'=>array($orderby=>$sort), 'limit'=>$limit));
2294 2294
 		} else {
2295
-			$_where['status'] = array( 'IN', array( 'publish' ) );
2296
-			$all_attendees = $count ? $ATT_MDL->count( array($_where, 'order_by'=>array($orderby=>$sort),'limit'=>$limit)) : $ATT_MDL->get_all( array($_where, 'order_by'=>array($orderby=>$sort), 'limit'=>$limit) );
2295
+			$_where['status'] = array('IN', array('publish'));
2296
+			$all_attendees = $count ? $ATT_MDL->count(array($_where, 'order_by'=>array($orderby=>$sort), 'limit'=>$limit)) : $ATT_MDL->get_all(array($_where, 'order_by'=>array($orderby=>$sort), 'limit'=>$limit));
2297 2297
 		}
2298 2298
 
2299 2299
 		return $all_attendees;
@@ -2310,10 +2310,10 @@  discard block
 block discarded – undo
2310 2310
 	 */
2311 2311
 	protected function _resend_registration() {
2312 2312
 		$this->_process_resend_registration();
2313
-		$query_args = isset($this->_req_data['redirect_to'] ) ? array('action' => $this->_req_data['redirect_to'], '_REG_ID' => $this->_req_data['_REG_ID'] ) : array(
2313
+		$query_args = isset($this->_req_data['redirect_to']) ? array('action' => $this->_req_data['redirect_to'], '_REG_ID' => $this->_req_data['_REG_ID']) : array(
2314 2314
 			'action' => 'default'
2315 2315
 		);
2316
-		$this->_redirect_after_action(FALSE, '', '', $query_args, TRUE );
2316
+		$this->_redirect_after_action(FALSE, '', '', $query_args, TRUE);
2317 2317
 	}
2318 2318
 
2319 2319
 
@@ -2321,27 +2321,27 @@  discard block
 block discarded – undo
2321 2321
 
2322 2322
 
2323 2323
 
2324
-	public function _registrations_report(){
2325
-		if( ! defined( 'EE_USE_OLD_CSV_REPORT_CLASS' ) ) {
2326
-			wp_redirect( EE_Admin_Page::add_query_args_and_nonce(
2324
+	public function _registrations_report() {
2325
+		if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
2326
+			wp_redirect(EE_Admin_Page::add_query_args_and_nonce(
2327 2327
 				array(
2328 2328
 					'page' => 'espresso_batch',
2329 2329
 					'batch' => 'file',
2330
-					'EVT_ID' => isset( $this->_req_data[ 'EVT_ID'] ) ? $this->_req_data[ 'EVT_ID' ] : NULL,
2331
-					'job_handler' => urlencode( 'EventEspressoBatchRequest\JobHandlers\RegistrationsReport' ),
2332
-					'return_url' => urlencode( $this->_req_data[ 'return_url' ] ),
2333
-				)) );
2330
+					'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : NULL,
2331
+					'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\RegistrationsReport'),
2332
+					'return_url' => urlencode($this->_req_data['return_url']),
2333
+				)));
2334 2334
 		} else {
2335
-			EE_Registry::instance()->load_helper( 'File' );
2335
+			EE_Registry::instance()->load_helper('File');
2336 2336
 			$new_request_args = array(
2337 2337
 				'export' => 'report',
2338 2338
 				'action' => 'registrations_report_for_event',
2339
-				'EVT_ID' => isset( $this->_req_data[ 'EVT_ID'] ) ? $this->_req_data[ 'EVT_ID' ] : NULL,
2339
+				'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : NULL,
2340 2340
 			);
2341 2341
 			$this->_req_data = array_merge($this->_req_data, $new_request_args);
2342 2342
 
2343
-			if ( is_readable(EE_CLASSES . 'EE_Export.class.php')) {
2344
-				require_once(EE_CLASSES . 'EE_Export.class.php');
2343
+			if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
2344
+				require_once(EE_CLASSES.'EE_Export.class.php');
2345 2345
 				$EE_Export = EE_Export::instance($this->_req_data);
2346 2346
 				$EE_Export->export();
2347 2347
 			}
@@ -2350,28 +2350,28 @@  discard block
 block discarded – undo
2350 2350
 
2351 2351
 
2352 2352
 
2353
-	public function _contact_list_export(){
2354
-		EE_Registry::instance()->load_helper( 'File' );
2355
-		if ( is_readable(EE_CLASSES . 'EE_Export.class.php')) {
2356
-			require_once(EE_CLASSES . 'EE_Export.class.php');
2353
+	public function _contact_list_export() {
2354
+		EE_Registry::instance()->load_helper('File');
2355
+		if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
2356
+			require_once(EE_CLASSES.'EE_Export.class.php');
2357 2357
 			$EE_Export = EE_Export::instance($this->_req_data);
2358 2358
 			$EE_Export->export_attendees();
2359 2359
 		}
2360 2360
 	}
2361 2361
 
2362
-	public function _contact_list_report(){
2363
-		if( ! defined( 'EE_USE_OLD_CSV_REPORT_CLASS' ) ) {
2364
-			wp_redirect( EE_Admin_Page::add_query_args_and_nonce(
2362
+	public function _contact_list_report() {
2363
+		if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
2364
+			wp_redirect(EE_Admin_Page::add_query_args_and_nonce(
2365 2365
 				array(
2366 2366
 					'page' => 'espresso_batch',
2367 2367
 					'batch' => 'file',
2368
-					'job_handler' => urlencode( 'EventEspressoBatchRequest\JobHandlers\AttendeesReport' ),
2369
-					'return_url' => urlencode( $this->_req_data[ 'return_url' ] ),
2370
-				)) );
2368
+					'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\AttendeesReport'),
2369
+					'return_url' => urlencode($this->_req_data['return_url']),
2370
+				)));
2371 2371
 		} else {
2372
-			EE_Registry::instance()->load_helper( 'File' );
2373
-			if ( is_readable(EE_CLASSES . 'EE_Export.class.php')) {
2374
-				require_once(EE_CLASSES . 'EE_Export.class.php');
2372
+			EE_Registry::instance()->load_helper('File');
2373
+			if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
2374
+				require_once(EE_CLASSES.'EE_Export.class.php');
2375 2375
 				$EE_Export = EE_Export::instance($this->_req_data);
2376 2376
 				$EE_Export->report_attendees();
2377 2377
 			}
@@ -2391,73 +2391,73 @@  discard block
 block discarded – undo
2391 2391
 	 * @return void
2392 2392
 	 */
2393 2393
 	protected function _duplicate_attendee() {
2394
-		$action = !empty( $this->_req_data['return'] ) ? $this->_req_data['return'] : 'default';
2394
+		$action = ! empty($this->_req_data['return']) ? $this->_req_data['return'] : 'default';
2395 2395
 		//verify we have necessary info
2396
-		if ( empty($this->_req_data['_REG_ID'] )  ) {
2397
-			EE_Error::add_error( __('Unable to create the contact for the registration because the required paramaters are not present (_REG_ID )', 'event_espresso'),  __FILE__, __LINE__, __FUNCTION__ );
2398
-			$query_args = array( 'action' => $action );
2396
+		if (empty($this->_req_data['_REG_ID'])) {
2397
+			EE_Error::add_error(__('Unable to create the contact for the registration because the required paramaters are not present (_REG_ID )', 'event_espresso'), __FILE__, __LINE__, __FUNCTION__);
2398
+			$query_args = array('action' => $action);
2399 2399
 			$this->_redirect_after_action('', '', '', $query_args, TRUE);
2400 2400
 		}
2401 2401
 
2402 2402
 		//okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration.
2403
-		$registration = EEM_Registration::instance()->get_one_by_ID( $this->_req_data['_REG_ID'] );
2403
+		$registration = EEM_Registration::instance()->get_one_by_ID($this->_req_data['_REG_ID']);
2404 2404
 		$attendee = $registration->attendee();
2405 2405
 
2406 2406
 		//remove relation of existing attendee on registration
2407
-		$registration->_remove_relation_to($attendee, 'Attendee' );
2407
+		$registration->_remove_relation_to($attendee, 'Attendee');
2408 2408
 		//new attendee
2409 2409
 		$new_attendee = clone $attendee;
2410
-		$new_attendee->set( 'ATT_ID', 0 );
2410
+		$new_attendee->set('ATT_ID', 0);
2411 2411
 		$new_attendee->save();
2412 2412
 
2413 2413
 		//add new attendee to reg
2414
-		$registration->_add_relation_to( $new_attendee, 'Attendee');
2414
+		$registration->_add_relation_to($new_attendee, 'Attendee');
2415 2415
 
2416
-		EE_Error::add_success( __('New Contact record created.  Now make any edits you wish to make for this contact.', 'event_espresso') );
2416
+		EE_Error::add_success(__('New Contact record created.  Now make any edits you wish to make for this contact.', 'event_espresso'));
2417 2417
 
2418 2418
 		//redirect to edit page for attendee
2419
-		$query_args = array( 'post' => $new_attendee->ID(), 'action' => 'edit_attendee' );
2419
+		$query_args = array('post' => $new_attendee->ID(), 'action' => 'edit_attendee');
2420 2420
 
2421
-		$this->_redirect_after_action( '', '', '', $query_args, TRUE );
2421
+		$this->_redirect_after_action('', '', '', $query_args, TRUE);
2422 2422
 	}
2423 2423
 
2424 2424
 
2425 2425
 	//related to cpt routes
2426 2426
 	protected function _insert_update_cpt_item($post_id, $post) {
2427 2427
 		$success = true;
2428
-		$attendee = EEM_Attendee::instance()->get_one_by_ID( $post_id );
2428
+		$attendee = EEM_Attendee::instance()->get_one_by_ID($post_id);
2429 2429
 		//for attendee updates
2430
-		if ( $post->post_type = 'espresso_attendees' && !empty( $attendee ) ) {
2430
+		if ($post->post_type = 'espresso_attendees' && ! empty($attendee)) {
2431 2431
 			//note we should only be UPDATING attendees at this point.
2432 2432
 			$updated_fields = array(
2433 2433
 				'ATT_fname' => $this->_req_data['ATT_fname'],
2434 2434
 				'ATT_lname' => $this->_req_data['ATT_lname'],
2435
-				'ATT_full_name'=> $this->_req_data['ATT_fname'] . ' ' . $this->_req_data['ATT_lname'],
2435
+				'ATT_full_name'=> $this->_req_data['ATT_fname'].' '.$this->_req_data['ATT_lname'],
2436 2436
 				'ATT_address' => isset($this->_req_data['ATT_address']) ? $this->_req_data['ATT_address'] : '',
2437 2437
 				'ATT_address2' => isset($this->_req_data['ATT_address2']) ? $this->_req_data['ATT_address2'] : '',
2438
-				'ATT_city' => isset( $this->_req_data['ATT_city'] ) ? $this->_req_data['ATT_city'] : '',
2439
-				'STA_ID' => isset( $this->_req_data['STA_ID'] ) ? $this->_req_data['STA_ID'] : '',
2440
-				'CNT_ISO' => isset( $this->_req_data['CNT_ISO'] ) ? $this->_req_data['CNT_ISO'] : '',
2441
-				'ATT_zip' => isset( $this->_req_data['ATT_zip'] ) ? $this->_req_data['ATT_zip'] : '',
2442
-				'ATT_email' => isset( $this->_req_data['ATT_email'] ) ? $this->_req_data['ATT_email'] : '',
2443
-				'ATT_phone' => isset( $this->_req_data['ATT_phone'] ) ? $this->_req_data['ATT_phone'] : ''
2438
+				'ATT_city' => isset($this->_req_data['ATT_city']) ? $this->_req_data['ATT_city'] : '',
2439
+				'STA_ID' => isset($this->_req_data['STA_ID']) ? $this->_req_data['STA_ID'] : '',
2440
+				'CNT_ISO' => isset($this->_req_data['CNT_ISO']) ? $this->_req_data['CNT_ISO'] : '',
2441
+				'ATT_zip' => isset($this->_req_data['ATT_zip']) ? $this->_req_data['ATT_zip'] : '',
2442
+				'ATT_email' => isset($this->_req_data['ATT_email']) ? $this->_req_data['ATT_email'] : '',
2443
+				'ATT_phone' => isset($this->_req_data['ATT_phone']) ? $this->_req_data['ATT_phone'] : ''
2444 2444
 				);
2445
-			foreach ( $updated_fields as $field => $value ) {
2445
+			foreach ($updated_fields as $field => $value) {
2446 2446
 				$attendee->set($field, $value);
2447 2447
 			}
2448 2448
 
2449 2449
 			$success = $attendee->save();
2450 2450
 
2451
-			$attendee_update_callbacks = apply_filters( 'FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update', array() );
2452
-			foreach ( $attendee_update_callbacks as $a_callback ) {
2453
-				if ( FALSE === call_user_func_array( $a_callback, array($attendee, $this->_req_data ) ) ) {
2454
-					throw new EE_Error( sprintf( __('The %s callback given for the "FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update" filter is not a valid callback.  Please check the spelling.', 'event_espresso'), $a_callback ) );
2451
+			$attendee_update_callbacks = apply_filters('FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update', array());
2452
+			foreach ($attendee_update_callbacks as $a_callback) {
2453
+				if (FALSE === call_user_func_array($a_callback, array($attendee, $this->_req_data))) {
2454
+					throw new EE_Error(sprintf(__('The %s callback given for the "FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update" filter is not a valid callback.  Please check the spelling.', 'event_espresso'), $a_callback));
2455 2455
 				}
2456 2456
 			}
2457 2457
 		}
2458 2458
 
2459
-		if ( $success === FALSE )
2460
-			EE_Error::add_error(__('Something went wrong with updating the meta table data for the registration.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
2459
+		if ($success === FALSE)
2460
+			EE_Error::add_error(__('Something went wrong with updating the meta table data for the registration.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
2461 2461
 
2462 2462
 	}
2463 2463
 
@@ -2477,17 +2477,17 @@  discard block
 block discarded – undo
2477 2477
 		remove_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', $this->_cpt_routes[$this->_req_action], 'normal', 'core');
2478 2478
 		remove_meta_box('commentstatusdiv', $this->_cpt_routes[$this->_req_action], 'normal', 'core');
2479 2479
 
2480
-		if ( post_type_supports( 'espresso_attendees', 'excerpt') ) {
2481
-			add_meta_box('postexcerpt', __('Short Biography', 'event_espresso'), 'post_excerpt_meta_box', $this->_cpt_routes[$this->_req_action], 'normal' );
2480
+		if (post_type_supports('espresso_attendees', 'excerpt')) {
2481
+			add_meta_box('postexcerpt', __('Short Biography', 'event_espresso'), 'post_excerpt_meta_box', $this->_cpt_routes[$this->_req_action], 'normal');
2482 2482
 		}
2483 2483
 
2484
-		if ( post_type_supports( 'espresso_attendees', 'comments') ) {
2484
+		if (post_type_supports('espresso_attendees', 'comments')) {
2485 2485
 			add_meta_box('commentsdiv', __('Notes on the Contact', 'event_espresso'), 'post_comment_meta_box', $this->_cpt_routes[$this->_req_action], 'normal', 'core');
2486 2486
 		}
2487 2487
 
2488
-		add_meta_box('attendee_contact_info', __('Contact Info', 'event_espresso'), array( $this, 'attendee_contact_info'), $this->_cpt_routes[$this->_req_action], 'side', 'core' );
2489
-		add_meta_box('attendee_details_address', __('Address Details', 'event_espresso'), array($this, 'attendee_address_details'), $this->_cpt_routes[$this->_req_action], 'normal', 'core' );
2490
-		add_meta_box('attendee_registrations', __('Registrations for this Contact', 'event_espresso'), array( $this, 'attendee_registrations_meta_box'), $this->_cpt_routes[$this->_req_action], 'normal', 'high');
2488
+		add_meta_box('attendee_contact_info', __('Contact Info', 'event_espresso'), array($this, 'attendee_contact_info'), $this->_cpt_routes[$this->_req_action], 'side', 'core');
2489
+		add_meta_box('attendee_details_address', __('Address Details', 'event_espresso'), array($this, 'attendee_address_details'), $this->_cpt_routes[$this->_req_action], 'normal', 'core');
2490
+		add_meta_box('attendee_registrations', __('Registrations for this Contact', 'event_espresso'), array($this, 'attendee_registrations_meta_box'), $this->_cpt_routes[$this->_req_action], 'normal', 'high');
2491 2491
 	}
2492 2492
 
2493 2493
 
@@ -2496,10 +2496,10 @@  discard block
 block discarded – undo
2496 2496
 	 * @param  WP_Post $post wp post object
2497 2497
 	 * @return string        attendee contact info ( and form )
2498 2498
 	 */
2499
-	public function attendee_contact_info( $post ) {
2499
+	public function attendee_contact_info($post) {
2500 2500
 		//get attendee object ( should already have it )
2501 2501
 		$this->_template_args['attendee'] = $this->_cpt_model_obj;
2502
-		$template = REG_TEMPLATE_PATH . 'attendee_contact_info_metabox_content.template.php';
2502
+		$template = REG_TEMPLATE_PATH.'attendee_contact_info_metabox_content.template.php';
2503 2503
 		EEH_Template::display_template($template, $this->_template_args);
2504 2504
 	}
2505 2505
 
@@ -2515,12 +2515,12 @@  discard block
 block discarded – undo
2515 2515
 		$this->_template_args['attendee'] = $this->_cpt_model_obj;
2516 2516
 		$this->_template_args['state_html'] = EEH_Form_Fields::generate_form_input(
2517 2517
 				new EE_Question_Form_Input(
2518
-				EE_Question::new_instance( array(
2518
+				EE_Question::new_instance(array(
2519 2519
 					'QST_ID' => 0,
2520 2520
 					'QST_display_text' => __('State/Province', 'event_espresso'),
2521 2521
 					'QST_system' => 'admin-state'
2522 2522
 					)),
2523
-				EE_Answer::new_instance( array(
2523
+				EE_Answer::new_instance(array(
2524 2524
 					'ANS_ID' => 0,
2525 2525
 					'ANS_value' => $this->_cpt_model_obj->state_ID()
2526 2526
 					)),
@@ -2533,12 +2533,12 @@  discard block
 block discarded – undo
2533 2533
 			));
2534 2534
 		$this->_template_args['country_html'] = EEH_Form_Fields::generate_form_input(
2535 2535
 				new EE_Question_Form_Input(
2536
-				EE_Question::new_instance( array(
2536
+				EE_Question::new_instance(array(
2537 2537
 					'QST_ID' => 0,
2538 2538
 					'QST_display_text' => __('Country', 'event_espresso'),
2539 2539
 					'QST_system' => 'admin-country'
2540 2540
 					)),
2541
-				EE_Answer::new_instance( array(
2541
+				EE_Answer::new_instance(array(
2542 2542
 					'ANS_ID' => 0,
2543 2543
 					'ANS_value' => $this->_cpt_model_obj->country_ID()
2544 2544
 					)),
@@ -2549,8 +2549,8 @@  discard block
 block discarded – undo
2549 2549
 					'append_qstn_id' => FALSE
2550 2550
 					)
2551 2551
 				));
2552
-		$template = REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php';
2553
-		EEH_Template::display_template($template, $this->_template_args );
2552
+		$template = REG_TEMPLATE_PATH.'attendee_address_details_metabox_content.template.php';
2553
+		EEH_Template::display_template($template, $this->_template_args);
2554 2554
 
2555 2555
 	}
2556 2556
 
@@ -2560,11 +2560,11 @@  discard block
 block discarded – undo
2560 2560
 	*		@access protected
2561 2561
 	*		@return void
2562 2562
 	*/
2563
-	public function attendee_registrations_meta_box( $post ) {
2563
+	public function attendee_registrations_meta_box($post) {
2564 2564
 
2565 2565
 		$this->_template_args['attendee'] = $this->_cpt_model_obj;
2566 2566
 		$this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration');
2567
-		$template = REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php';
2567
+		$template = REG_TEMPLATE_PATH.'attendee_registrations_main_meta_box.template.php';
2568 2568
 		EEH_Template::display_template($template, $this->_template_args);
2569 2569
 
2570 2570
 	}
@@ -2578,8 +2578,8 @@  discard block
 block discarded – undo
2578 2578
 	 * @return string        html for new form.
2579 2579
 	 */
2580 2580
 	public function after_title_form_fields($post) {
2581
-		if ( $post->post_type == 'espresso_attendees' ) {
2582
-			$template = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php';
2581
+		if ($post->post_type == 'espresso_attendees') {
2582
+			$template = REG_TEMPLATE_PATH.'attendee_details_after_title_form_fields.template.php';
2583 2583
 			$template_args['attendee'] = $this->_cpt_model_obj;
2584 2584
 			EEH_Template::display_template($template, $template_args);
2585 2585
 		}
@@ -2596,21 +2596,21 @@  discard block
 block discarded – undo
2596 2596
 	*		@access protected
2597 2597
 	*		@return void
2598 2598
 	*/
2599
-	protected function _trash_or_restore_attendees( $trash = TRUE ) {
2599
+	protected function _trash_or_restore_attendees($trash = TRUE) {
2600 2600
 
2601
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
2601
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2602 2602
 
2603 2603
 		$ATT_MDL = EEM_Attendee::instance();
2604 2604
 
2605 2605
 		$success = 1;
2606 2606
 		//Checkboxes
2607
-		if (!empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
2607
+		if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
2608 2608
 			// if array has more than one element than success message should be plural
2609
-			$success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1;
2609
+			$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
2610 2610
 			// cycle thru checkboxes
2611
-			while (list( $ATT_ID, $value ) = each($this->_req_data['checkbox'])) {
2612
-				$updated = $trash ? $ATT_MDL->update_by_ID(array( 'status' => 'trash' ), $ATT_ID) : $ATT_MDL->update_by_ID( array('status' => 'publish' ), $ATT_ID);
2613
-				if ( !$updated ) {
2611
+			while (list($ATT_ID, $value) = each($this->_req_data['checkbox'])) {
2612
+				$updated = $trash ? $ATT_MDL->update_by_ID(array('status' => 'trash'), $ATT_ID) : $ATT_MDL->update_by_ID(array('status' => 'publish'), $ATT_ID);
2613
+				if ( ! $updated) {
2614 2614
 					$success = 0;
2615 2615
 				}
2616 2616
 			}
@@ -2619,18 +2619,18 @@  discard block
 block discarded – undo
2619 2619
 			// grab single id and delete
2620 2620
 			$ATT_ID = absint($this->_req_data['ATT_ID']);
2621 2621
 			//get attendee
2622
-			$att = $ATT_MDL->get_one_by_ID( $ATT_ID );
2622
+			$att = $ATT_MDL->get_one_by_ID($ATT_ID);
2623 2623
 			$updated = $trash ? $att->set_status('trash') : $att->set_status('publish');
2624 2624
 			$updated = $att->save();
2625
-			if ( ! $updated ) {
2625
+			if ( ! $updated) {
2626 2626
 				$success = 0;
2627 2627
 			}
2628 2628
 
2629 2629
 		}
2630 2630
 
2631
-		$what = $success > 1 ? __( 'Contacts', 'event_espresso' ) : __( 'Contact', 'event_espresso' );
2632
-		$action_desc = $trash ? __( 'moved to the trash', 'event_espresso' ) : __( 'restored', 'event_espresso' );
2633
-		$this->_redirect_after_action( $success, $what, $action_desc, array( 'action' => 'contact_list' ) );
2631
+		$what = $success > 1 ? __('Contacts', 'event_espresso') : __('Contact', 'event_espresso');
2632
+		$action_desc = $trash ? __('moved to the trash', 'event_espresso') : __('restored', 'event_espresso');
2633
+		$this->_redirect_after_action($success, $what, $action_desc, array('action' => 'contact_list'));
2634 2634
 
2635 2635
 	}
2636 2636
 
Please login to merge, or discard this patch.
Indentation   +85 added lines, -85 removed lines patch added patch discarded remove patch
@@ -1,26 +1,26 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
2 2
 /**
3
- * Event Espresso
4
- *
5
- * Event Registration and Management Plugin for WordPress
6
- *
7
- * @ package			Event Espresso
8
- * @ author				Seth Shoultes
9
- * @ copyright		(c) 2008-2011 Event Espresso  All Rights Reserved.
10
- * @ license			{@link http://eventespresso.com/support/terms-conditions/}   * see Plugin Licensing *
11
- * @ link					{@link http://www.eventespresso.com}
12
- * @ since		 		4.0
13
- *
14
- * ------------------------------------------------------------------------
15
- *
16
- * Registrations_Admin_Page class
17
- *
18
- * @package			Event Espresso
19
- * @subpackage	includes/core/admin/transactions/Registrations_Admin_Page.core.php
20
- * @author				Brent Christensen
21
- *
22
- * ------------------------------------------------------------------------
23
- */
3
+	 * Event Espresso
4
+	 *
5
+	 * Event Registration and Management Plugin for WordPress
6
+	 *
7
+	 * @ package			Event Espresso
8
+	 * @ author				Seth Shoultes
9
+	 * @ copyright		(c) 2008-2011 Event Espresso  All Rights Reserved.
10
+	 * @ license			{@link http://eventespresso.com/support/terms-conditions/}   * see Plugin Licensing *
11
+	 * @ link					{@link http://www.eventespresso.com}
12
+	 * @ since		 		4.0
13
+	 *
14
+	 * ------------------------------------------------------------------------
15
+	 *
16
+	 * Registrations_Admin_Page class
17
+	 *
18
+	 * @package			Event Espresso
19
+	 * @subpackage	includes/core/admin/transactions/Registrations_Admin_Page.core.php
20
+	 * @author				Brent Christensen
21
+	 *
22
+	 * ------------------------------------------------------------------------
23
+	 */
24 24
 class Registrations_Admin_Page extends EE_Admin_Page_CPT {
25 25
 
26 26
 	/**
@@ -163,9 +163,9 @@  discard block
 block discarded – undo
163 163
 
164 164
 	/**
165 165
 	 * 		grab url requests and route them
166
-	*		@access private
167
-	*		@return void
168
-	*/
166
+	 *		@access private
167
+	 *		@return void
168
+	 */
169 169
 	public function _set_page_routes() {
170 170
 
171 171
 		$this->_get_registration_status_array();
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
 						'title' => __('Registrations Other', 'event_espresso'),
437 437
 						'filename' => 'registrations_overview_other'
438 438
 					)
439
-                ),
439
+				),
440 440
 				'help_tour' => array( 'Registration_Overview_Help_Tour' ),
441 441
 				'qtips' => array('Registration_List_Table_Tips'),
442 442
 				'list_table' => 'EE_Registrations_List_Table',
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
 					'url' => isset($this->_req_data['_REG_ID']) ? add_query_arg(array('_REG_ID' => $this->_req_data['_REG_ID'] ), $this->_current_page_view_url )  : $this->_admin_base_url,
451 451
 					'persistent' => FALSE
452 452
 				),
453
-                'help_tabs' => array(
453
+				'help_tabs' => array(
454 454
 					'registrations_details_help_tab' => array(
455 455
 						'title' => __('Registration Details', 'event_espresso'),
456 456
 						'filename' => 'registrations_details'
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
 					'order' => 20
515 515
 				),
516 516
 				'list_table' => 'EE_Attendee_Contact_List_Table',
517
-                'help_tabs' => array(
517
+				'help_tabs' => array(
518 518
 					'registrations_contact_list_help_tab' => array(
519 519
 						'title' => __('Registrations Contact List', 'event_espresso'),
520 520
 						'filename' => 'registrations_contact_list'
@@ -531,7 +531,7 @@  discard block
 block discarded – undo
531 531
 						'title' => __('Contact List Other', 'event_espresso'),
532 532
 						'filename' => 'registrations_contact_list_other'
533 533
 					)
534
-                ),
534
+				),
535 535
 				'help_tour' => array( 'Contact_List_Help_Tour' ),
536 536
 				'metaboxes' => array(),
537 537
 				'require_nonce' => FALSE
@@ -565,9 +565,9 @@  discard block
 block discarded – undo
565 565
 
566 566
 	/**
567 567
 	 * 		get list of registration statuses
568
-	*		@access private
569
-	*		@return void
570
-	*/
568
+	 *		@access private
569
+	 *		@return void
570
+	 */
571 571
 	private function _get_registration_status_array() {
572 572
 		self::$_reg_status = EEM_Registration::reg_status_array( array(), TRUE);
573 573
 	}
@@ -874,7 +874,7 @@  discard block
 block discarded – undo
874 874
 			return TRUE;
875 875
 		}
876 876
 
877
-	    $REG = EEM_Registration::instance();
877
+		$REG = EEM_Registration::instance();
878 878
 
879 879
 		$REG_ID = ( ! empty( $this->_req_data['_REG_ID'] )) ? absint( $this->_req_data['_REG_ID'] ) : FALSE;
880 880
 
@@ -1097,9 +1097,9 @@  discard block
 block discarded – undo
1097 1097
 
1098 1098
 	/**
1099 1099
 	 * 		generates HTML for the View Registration Details Admin page
1100
-	*		@access protected
1101
-	*		@return void
1102
-	*/
1100
+	 *		@access protected
1101
+	 *		@return void
1102
+	 */
1103 1103
 	protected function _registration_details() {
1104 1104
 
1105 1105
 		$this->_template_args = array();
@@ -1177,9 +1177,9 @@  discard block
 block discarded – undo
1177 1177
 
1178 1178
 	/**
1179 1179
 	 * 		_set_approve_or_decline_reg_status_buttons
1180
-	*		@access protected
1181
-	*		@return string
1182
-	*/
1180
+	 *		@access protected
1181
+	 *		@return string
1182
+	 */
1183 1183
 	public function set_reg_status_buttons_metabox() {
1184 1184
 
1185 1185
 		//is registration for free event OR for a completed transaction? This will determine whether the set to pending option is shown.
@@ -1368,10 +1368,10 @@  discard block
 block discarded – undo
1368 1368
 
1369 1369
 	/**
1370 1370
 	 * 		approve_registration
1371
-	*		@access protected
1372
-	*		@param bool $notify whether or not to notify the registrant about their approval.
1373
-	*		@return void
1374
-	*/
1371
+	 *		@access protected
1372
+	 *		@param bool $notify whether or not to notify the registrant about their approval.
1373
+	 *		@return void
1374
+	 */
1375 1375
 	protected function approve_registration( $notify = false ) {
1376 1376
 		$this->_reg_status_change_return( EEM_Registration::status_id_approved, $notify );
1377 1377
 	}
@@ -1381,10 +1381,10 @@  discard block
 block discarded – undo
1381 1381
 
1382 1382
 	/**
1383 1383
 	 * 		decline_registration
1384
-	*		@access protected
1385
-	*		@param bool $notify whether or not to notify the registrant about their approval.
1386
-	*		@return void
1387
-	*/
1384
+	 *		@access protected
1385
+	 *		@param bool $notify whether or not to notify the registrant about their approval.
1386
+	 *		@return void
1387
+	 */
1388 1388
 	protected function decline_registration( $notify = false ) {
1389 1389
 		$this->_reg_status_change_return( EEM_Registration::status_id_declined, $notify );
1390 1390
 	}
@@ -1394,10 +1394,10 @@  discard block
 block discarded – undo
1394 1394
 
1395 1395
 	/**
1396 1396
 	 * 		cancel_registration
1397
-	*		@access protected
1398
-	*		@param bool $notify whether or not to notify the registrant about their approval.
1399
-	*		@return void
1400
-	*/
1397
+	 *		@access protected
1398
+	 *		@param bool $notify whether or not to notify the registrant about their approval.
1399
+	 *		@return void
1400
+	 */
1401 1401
 	protected function cancel_registration( $notify = false ) {
1402 1402
 		$this->_reg_status_change_return( EEM_Registration::status_id_cancelled, $notify );
1403 1403
 	}
@@ -1408,10 +1408,10 @@  discard block
 block discarded – undo
1408 1408
 
1409 1409
 	/**
1410 1410
 	 * 		not_approve_registration
1411
-	*		@access protected
1412
-	*		@param bool $notify whether or not to notify the registrant about their approval.
1413
-	*		@return void
1414
-	*/
1411
+	 *		@access protected
1412
+	 *		@param bool $notify whether or not to notify the registrant about their approval.
1413
+	 *		@return void
1414
+	 */
1415 1415
 	protected function not_approve_registration( $notify = false ) {
1416 1416
 		$this->_reg_status_change_return( EEM_Registration::status_id_not_approved, $notify );
1417 1417
 	}
@@ -1420,10 +1420,10 @@  discard block
 block discarded – undo
1420 1420
 
1421 1421
 	/**
1422 1422
 	 * 		decline_registration
1423
-	*		@access protected
1424
-	*		@param bool $notify whether or not to notify the registrant about their approval.
1425
-	*		@return void
1426
-	*/
1423
+	 *		@access protected
1424
+	 *		@param bool $notify whether or not to notify the registrant about their approval.
1425
+	 *		@return void
1426
+	 */
1427 1427
 	protected function pending_registration( $notify = false ) {
1428 1428
 		$this->_reg_status_change_return( EEM_Registration::status_id_pending_payment, $notify );
1429 1429
 	}
@@ -1433,9 +1433,9 @@  discard block
 block discarded – undo
1433 1433
 
1434 1434
 	/**
1435 1435
 	 * 		generates HTML for the Registration main meta box
1436
-	*		@access public
1437
-	*		@return void
1438
-	*/
1436
+	 *		@access public
1437
+	 *		@return void
1438
+	 */
1439 1439
 	public function _reg_details_meta_box() {
1440 1440
 		EEH_Autoloader::register_line_item_display_autoloaders();
1441 1441
 		EEH_Autoloader::register_line_item_filter_autoloaders();
@@ -1518,7 +1518,7 @@  discard block
 block discarded – undo
1518 1518
 	 *
1519 1519
 	 * @access public
1520 1520
 	 * @return void
1521
-	*/
1521
+	 */
1522 1522
 	public function _reg_questions_meta_box() {
1523 1523
 		//allow someone to override this method entirely
1524 1524
 		if( apply_filters( 'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', true, $this, $this->_registration ) ) {
@@ -1720,12 +1720,12 @@  discard block
 block discarded – undo
1720 1720
 
1721 1721
 	/**
1722 1722
 	 * 		generates HTML for the Registration main meta box
1723
-	*		@access public
1724
-	*		@return void
1725
-	*/
1723
+	 *		@access public
1724
+	 *		@return void
1725
+	 */
1726 1726
 	public function _reg_attendees_meta_box() {
1727 1727
 
1728
-	    $REG = EEM_Registration::instance();
1728
+		$REG = EEM_Registration::instance();
1729 1729
 		//get all other registrations on this transaction, and cache
1730 1730
 		//the attendees for them so we don't have to run another query using force_join
1731 1731
 		$registrations = $REG->get_all(array(
@@ -1778,9 +1778,9 @@  discard block
 block discarded – undo
1778 1778
 
1779 1779
 	/**
1780 1780
 	 * 		generates HTML for the Edit Registration side meta box
1781
-	*		@access public
1782
-	*		@return void
1783
-	*/
1781
+	 *		@access public
1782
+	 *		@return void
1783
+	 */
1784 1784
 	public function _reg_registrant_side_meta_box() {
1785 1785
 
1786 1786
 		/*@var $attendee EE_Attendee */
@@ -2159,9 +2159,9 @@  discard block
 block discarded – undo
2159 2159
 
2160 2160
 	/**
2161 2161
 	 * 		set_reg_event
2162
-	*		@access private
2163
-	*		@return boolean
2164
-	*/
2162
+	 *		@access private
2163
+	 *		@return boolean
2164
+	 */
2165 2165
 	private function _set_reg_event() {
2166 2166
 		if ( is_object( $this->_reg_event )) {
2167 2167
 			return TRUE;
@@ -2301,9 +2301,9 @@  discard block
 block discarded – undo
2301 2301
 
2302 2302
 	/**
2303 2303
 	 * 		generates HTML for the Attendee Contact List
2304
-	*		@access protected
2305
-	*		@return void
2306
-	*/
2304
+	 *		@access protected
2305
+	 *		@return void
2306
+	 */
2307 2307
 	protected function _attendee_contact_list_table() {
2308 2308
 		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
2309 2309
 		$this->_search_btn_label = __('Contacts', 'event_espresso');
@@ -2317,9 +2317,9 @@  discard block
 block discarded – undo
2317 2317
 	/**
2318 2318
 	 * 		get_attendees
2319 2319
 	 * 		@param bool $count whether to return count or data.
2320
-	*		@access public
2321
-	*		@return array
2322
-	*/
2320
+	 *		@access public
2321
+	 *		@return array
2322
+	 */
2323 2323
 	public function get_attendees( $per_page, $count = FALSE, $trash = FALSE ) {
2324 2324
 
2325 2325
 		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
@@ -2655,9 +2655,9 @@  discard block
 block discarded – undo
2655 2655
 
2656 2656
 	/**
2657 2657
 	 * 		_attendee_details
2658
-	*		@access protected
2659
-	*		@return void
2660
-	*/
2658
+	 *		@access protected
2659
+	 *		@return void
2660
+	 */
2661 2661
 	public function attendee_registrations_meta_box( $post ) {
2662 2662
 
2663 2663
 		$this->_template_args['attendee'] = $this->_cpt_model_obj;
@@ -2690,10 +2690,10 @@  discard block
 block discarded – undo
2690 2690
 
2691 2691
 	/**
2692 2692
 	 * 		_trash_or_restore_attendee
2693
-	*		@param boolean 		$trash - whether to move item to trash (TRUE) or restore it (FALSE)
2694
-	*		@access protected
2695
-	*		@return void
2696
-	*/
2693
+	 *		@param boolean 		$trash - whether to move item to trash (TRUE) or restore it (FALSE)
2694
+	 *		@access protected
2695
+	 *		@return void
2696
+	 */
2697 2697
 	protected function _trash_or_restore_attendees( $trash = TRUE ) {
2698 2698
 
2699 2699
 		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
Please login to merge, or discard this patch.
templates/txn_admin_details_main_meta_box_txn_details.template.php 1 patch
Spacing   +115 added lines, -115 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <div id="admin-primary-mbox-dv" class="admin-primary-mbox-dv">
2 2
 
3 3
 	<h3 class="admin-primary-mbox-h4 hdr-has-icon">
4
-		<span class="dashicons dashicons-cart"></span><?php _e( 'Transaction Items', 'event_espresso' );?>
4
+		<span class="dashicons dashicons-cart"></span><?php _e('Transaction Items', 'event_espresso'); ?>
5 5
 	</h3>
6 6
 
7 7
 	<div class="admin-primary-mbox-tbl-wrap">
@@ -10,27 +10,27 @@  discard block
 block discarded – undo
10 10
 	</div>
11 11
 
12 12
 	<a id="display-additional-transaction-session-info" class="display-the-hidden smaller-text" rel="additional-transaction-session-info">
13
-		<span class="dashicons dashicons-plus-alt"></span><?php _e( 'view additional transaction session details', 'event_espresso' );?>
13
+		<span class="dashicons dashicons-plus-alt"></span><?php _e('view additional transaction session details', 'event_espresso'); ?>
14 14
 	</a>
15 15
 
16 16
 	<div id="additional-transaction-session-info-dv" class="hidden">
17 17
 
18 18
 		<a id="hide-additional-transaction-session-info" class="hide-the-displayed hidden smaller-text" rel="additional-transaction-session-info">
19
-			<span class="dashicons dashicons-dismiss"></span><?php _e( 'hide additional transaction session details', 'event_espresso' );?>
19
+			<span class="dashicons dashicons-dismiss"></span><?php _e('hide additional transaction session details', 'event_espresso'); ?>
20 20
 		</a>
21 21
 	<br class="clear"/>
22 22
 
23
-		<h3 class="admin-primary-mbox-h4"><?php _e( 'Transaction Session Details', 'event_espresso' );?></h3>
23
+		<h3 class="admin-primary-mbox-h4"><?php _e('Transaction Session Details', 'event_espresso'); ?></h3>
24 24
 
25 25
 		<table id="admin-primary-mbox-txn-extra-session-info-tbl" class="form-table skinny-rows">
26 26
 			<tbody>
27
-			<?php foreach ( $txn_details as $key => $txn_detail ) : ?>
27
+			<?php foreach ($txn_details as $key => $txn_detail) : ?>
28 28
 				<tr>
29 29
 					<th>
30
-						<label for="<?php echo $key;?>"><?php echo $txn_detail['label'];?></label>
30
+						<label for="<?php echo $key; ?>"><?php echo $txn_detail['label']; ?></label>
31 31
 					</th>
32 32
 					<td>
33
-						<?php echo $txn_detail['value'];?>
33
+						<?php echo $txn_detail['value']; ?>
34 34
 					</td>
35 35
 				</tr>
36 36
 			<?php endforeach; // $txn_details?>
@@ -40,10 +40,10 @@  discard block
 block discarded – undo
40 40
 	<br class="clear"/>
41 41
 
42 42
 
43
-	<?php if ( $attendee instanceof EE_Attendee && ( $grand_raw_total > 0 || $TXN_status != 'TCM' || ! empty( $payments ) ) ) : ?>
43
+	<?php if ($attendee instanceof EE_Attendee && ($grand_raw_total > 0 || $TXN_status != 'TCM' || ! empty($payments))) : ?>
44 44
 
45 45
 	<h3 class="admin-primary-mbox-h4 hdr-has-icon">
46
-		<span class="ee-icon ee-icon-cash"></span><?php _e( 'Payment Details', 'event_espresso' );?>
46
+		<span class="ee-icon ee-icon-cash"></span><?php _e('Payment Details', 'event_espresso'); ?>
47 47
 	</h3>
48 48
 
49 49
 	<div class="admin-primary-mbox-tbl-wrap">
@@ -52,75 +52,75 @@  discard block
 block discarded – undo
52 52
 				<tr>
53 53
 					<th></th>
54 54
 					<th class="jst-cntr"></th>
55
-					<th class="jst-cntr"><?php _e( 'ID', 'event_espresso' );?></th>
56
-					<th class="jst-left"><?php _e( 'Date', 'event_espresso' );?></th>
57
-					<th class="jst-cntr"><?php _e( 'Source', 'event_espresso' );?></th>
58
-					<th class="jst-left"><?php _e( 'Method', 'event_espresso' );?></th>
59
-					<th class="jst-left"><?php _e( 'Gateway Response', 'event_espresso' );?></th>
60
-					<th class="jst-left"><?php _e( 'TXN&nbsp;ID / CHQ&nbsp;#', 'event_espresso' );?></th>
61
-					<th class="jst-left"><?php _e( 'P.O. / S.O.&nbsp;#', 'event_espresso' );?></th>
62
-					<th class="jst-left"><?php _e( 'Notes / Extra&nbsp;Accounting', 'event_espresso' );?></th>
63
-					<!--<th class="jst-left"><?php _e( 'Details', 'event_espresso' );?></th>-->
64
-					<th class="jst-cntr"><?php _e( 'Amount', 'event_espresso' );?></th>
55
+					<th class="jst-cntr"><?php _e('ID', 'event_espresso'); ?></th>
56
+					<th class="jst-left"><?php _e('Date', 'event_espresso'); ?></th>
57
+					<th class="jst-cntr"><?php _e('Source', 'event_espresso'); ?></th>
58
+					<th class="jst-left"><?php _e('Method', 'event_espresso'); ?></th>
59
+					<th class="jst-left"><?php _e('Gateway Response', 'event_espresso'); ?></th>
60
+					<th class="jst-left"><?php _e('TXN&nbsp;ID / CHQ&nbsp;#', 'event_espresso'); ?></th>
61
+					<th class="jst-left"><?php _e('P.O. / S.O.&nbsp;#', 'event_espresso'); ?></th>
62
+					<th class="jst-left"><?php _e('Notes / Extra&nbsp;Accounting', 'event_espresso'); ?></th>
63
+					<!--<th class="jst-left"><?php _e('Details', 'event_espresso'); ?></th>-->
64
+					<th class="jst-cntr"><?php _e('Amount', 'event_espresso'); ?></th>
65 65
 				</tr>
66 66
 			</thead>
67 67
 			<tbody>
68
-		<?php if ( $payments ) : ?>
68
+		<?php if ($payments) : ?>
69 69
 			<?php $payment_total = 0; ?>
70
-			<?php foreach ( $payments as $PAY_ID => $payment ) : ?>
71
-				<tr id="txn-admin-payment-tr-<?php echo $PAY_ID;?>">
70
+			<?php foreach ($payments as $PAY_ID => $payment) : ?>
71
+				<tr id="txn-admin-payment-tr-<?php echo $PAY_ID; ?>">
72 72
 					<td>
73 73
 						<span id="payment-status-<?php echo $PAY_ID; ?>" class="ee-status-strip-td ee-status-strip pymt-status-<?php echo $payment->STS_ID(); ?>"></span>
74
-						<div id="payment-STS_ID-<?php echo $PAY_ID;?>" class="hidden"><?php echo $payment->STS_ID();?></div>
75
-						<div id="reg-payments-<?php echo $PAY_ID;?>" class="hidden"><?php echo json_encode( $existing_reg_payments[ $PAY_ID ] );?></div>
74
+						<div id="payment-STS_ID-<?php echo $PAY_ID; ?>" class="hidden"><?php echo $payment->STS_ID(); ?></div>
75
+						<div id="reg-payments-<?php echo $PAY_ID; ?>" class="hidden"><?php echo json_encode($existing_reg_payments[$PAY_ID]); ?></div>
76 76
 					</td>
77 77
 					<td class=" jst-cntr">
78 78
 						<ul class="txn-overview-actions-ul">
79 79
 							<li>
80
-								<a class="txn-admin-payment-action-edit-lnk" title="<?php esc_attr_e( 'Edit Payment', 'event_espresso' );?>" data-payment-id="<?php echo $PAY_ID;?>">
80
+								<a class="txn-admin-payment-action-edit-lnk" title="<?php esc_attr_e('Edit Payment', 'event_espresso'); ?>" data-payment-id="<?php echo $PAY_ID; ?>">
81 81
 									<div class="dashicons dashicons-edit" style="margin: 0;"></div>
82 82
 								</a>
83 83
 							</li>
84 84
 							<li>
85
-								<a class="txn-admin-payment-action-delete-lnk" title="<?php esc_attr_e( 'Delete Payment', 'event_espresso' );?>" data-payment-id="<?php echo $PAY_ID;?>">
85
+								<a class="txn-admin-payment-action-delete-lnk" title="<?php esc_attr_e('Delete Payment', 'event_espresso'); ?>" data-payment-id="<?php echo $PAY_ID; ?>">
86 86
 									<div class="dashicons dashicons-trash" style="margin: 0;"></div>
87 87
 								</a>
88 88
 							</li>
89 89
 						</ul>
90 90
 					</td>
91 91
 					<td class=" jst-rght">
92
-						<div id="payment-id-<?php echo $PAY_ID;?>"><?php echo $PAY_ID;?></div>
92
+						<div id="payment-id-<?php echo $PAY_ID; ?>"><?php echo $PAY_ID; ?></div>
93 93
 					</td>
94 94
 					<td class=" jst-left">
95
-						<div id="payment-date-<?php echo $PAY_ID;?>" class="payment-date-dv"><?php echo $payment->timestamp('Y-m-d', 'g:i a');?></div>
95
+						<div id="payment-date-<?php echo $PAY_ID; ?>" class="payment-date-dv"><?php echo $payment->timestamp('Y-m-d', 'g:i a'); ?></div>
96 96
 					</td>
97 97
 					<td class=" jst-cntr">
98
-						<div id="payment-method-<?php echo $PAY_ID;?>">
99
-							<?php echo $payment->source();?>
98
+						<div id="payment-method-<?php echo $PAY_ID; ?>">
99
+							<?php echo $payment->source(); ?>
100 100
 						</div>
101 101
 					</td>
102 102
 					<td class=" jst-left">
103
-						<div id="payment-gateway-<?php echo $PAY_ID;?>">
104
-							<?php echo $payment->payment_method() ?  $payment->payment_method()->admin_name() : __("Unknown", 'event_espresso');?>
103
+						<div id="payment-gateway-<?php echo $PAY_ID; ?>">
104
+							<?php echo $payment->payment_method() ? $payment->payment_method()->admin_name() : __("Unknown", 'event_espresso'); ?>
105 105
 						</div>
106
-						<div id="payment-gateway-id-<?php echo $PAY_ID;?>" class="hidden"><?php echo $payment->payment_method() ? $payment->payment_method()->ID() : 0;?></div>
106
+						<div id="payment-gateway-id-<?php echo $PAY_ID; ?>" class="hidden"><?php echo $payment->payment_method() ? $payment->payment_method()->ID() : 0; ?></div>
107 107
 					</td>
108 108
 					<td class=" jst-left">
109
-						<div id="payment-response-<?php echo $PAY_ID;?>"><?php echo $payment->gateway_response();?></div>
109
+						<div id="payment-response-<?php echo $PAY_ID; ?>"><?php echo $payment->gateway_response(); ?></div>
110 110
 					</td>
111 111
 					<td class=" jst-left">
112
-						<div id="payment-txn-id-chq-nmbr-<?php echo $PAY_ID;?>"><?php echo $payment->txn_id_chq_nmbr();?></div>
112
+						<div id="payment-txn-id-chq-nmbr-<?php echo $PAY_ID; ?>"><?php echo $payment->txn_id_chq_nmbr(); ?></div>
113 113
 					</td>
114 114
 					<td class=" jst-left">
115
-						<div id="payment-po-nmbr-<?php echo $PAY_ID;?>"><?php echo $payment->po_number();?></div>
115
+						<div id="payment-po-nmbr-<?php echo $PAY_ID; ?>"><?php echo $payment->po_number(); ?></div>
116 116
 					</td>
117 117
 					<td class=" jst-left">
118
-						<div id="payment-accntng-<?php echo $PAY_ID;?>"><?php echo $payment->extra_accntng();?></div>
118
+						<div id="payment-accntng-<?php echo $PAY_ID; ?>"><?php echo $payment->extra_accntng(); ?></div>
119 119
 					</td>
120 120
 					<td class=" jst-rght">
121
-						<?php $payment_class = $payment->amount() > 0 ? 'txn-admin-payment-status-' . $payment->STS_ID() : 'txn-admin-payment-status-PDC'; ?>
122
-						<span class="<?php echo $payment_class;?>">
123
-							<div id="payment-amount-<?php echo $PAY_ID;?>" style="display:inline;"><?php echo EEH_Template::format_currency($payment->amount(), FALSE, FALSE ); ?></div>
121
+						<?php $payment_class = $payment->amount() > 0 ? 'txn-admin-payment-status-'.$payment->STS_ID() : 'txn-admin-payment-status-PDC'; ?>
122
+						<span class="<?php echo $payment_class; ?>">
123
+							<div id="payment-amount-<?php echo $PAY_ID; ?>" style="display:inline;"><?php echo EEH_Template::format_currency($payment->amount(), FALSE, FALSE); ?></div>
124 124
 						</span>
125 125
 					</td>
126 126
 				</tr>
@@ -130,25 +130,25 @@  discard block
 block discarded – undo
130 130
 			<?php endforeach; // $payment?>
131 131
 			<?php
132 132
 				$pay_totals_class = $payment_total > $grand_raw_total ? ' important-notice' : '';
133
-				$overpaid = $payment_total > $grand_raw_total ? '<span id="overpaid">' . __( 'This transaction has been overpaid ! ', 'event_espresso' ) . '</span>' : '';
133
+				$overpaid = $payment_total > $grand_raw_total ? '<span id="overpaid">'.__('This transaction has been overpaid ! ', 'event_espresso').'</span>' : '';
134 134
 			?>
135 135
 				<tr id="txn-admin-no-payments-tr" class="admin-primary-mbox-total-tr hidden">
136 136
 					<td class=" jst-rght" colspan="11">
137
-						<span class="important-notice"><?php _e( 'No payments have been applied to this transaction yet. Click "Apply Payment" below to make a payment.', 'event_espresso' ); ?></span>
137
+						<span class="important-notice"><?php _e('No payments have been applied to this transaction yet. Click "Apply Payment" below to make a payment.', 'event_espresso'); ?></span>
138 138
 					</td>
139 139
 				</tr>
140
-				<tr id="txn-admin-payments-total-tr" class="admin-primary-mbox-total-tr<?php echo $pay_totals_class;?>">
141
-					<th class=" jst-rght" colspan="10"><span id="payments-total-spn"><?php echo $overpaid . sprintf( __( 'Payments Total %s', 'event_espresso' ), '(' . EE_Registry::instance()->CFG->currency->code . ')' );?></span></th>
142
-					<th class=" jst-rght"><span id="txn-admin-payment-total"><?php echo EEH_Template::format_currency($payment_total, FALSE, FALSE);?></span></th>
140
+				<tr id="txn-admin-payments-total-tr" class="admin-primary-mbox-total-tr<?php echo $pay_totals_class; ?>">
141
+					<th class=" jst-rght" colspan="10"><span id="payments-total-spn"><?php echo $overpaid.sprintf(__('Payments Total %s', 'event_espresso'), '('.EE_Registry::instance()->CFG->currency->code.')'); ?></span></th>
142
+					<th class=" jst-rght"><span id="txn-admin-payment-total"><?php echo EEH_Template::format_currency($payment_total, FALSE, FALSE); ?></span></th>
143 143
 				</tr>
144 144
 		<?php else : ?>
145 145
 				<tr id="txn-admin-no-payments-tr" class="admin-primary-mbox-total-tr">
146 146
 					<td class=" jst-rght" colspan="11">
147
-						<span class="important-notice"><?php _e( 'No payments have been applied to this transaction yet. Click "Apply Payment" below to make a payment.', 'event_espresso' ); ?></span>
147
+						<span class="important-notice"><?php _e('No payments have been applied to this transaction yet. Click "Apply Payment" below to make a payment.', 'event_espresso'); ?></span>
148 148
 					</td>
149 149
 				</tr>
150 150
 				<tr id="txn-admin-payments-total-tr" class="admin-primary-mbox-total-tr hidden">
151
-					<th class=" jst-rght" colspan="10"><span id="payments-total-spn"><?php echo __( 'Payments Total', 'event_espresso' );?></span></th>
151
+					<th class=" jst-rght" colspan="10"><span id="payments-total-spn"><?php echo __('Payments Total', 'event_espresso'); ?></span></th>
152 152
 					<th class=" jst-rght"><span id="txn-admin-payment-total"></span></th>
153 153
 				</tr>
154 154
 		<?php endif; // $payments?>
@@ -161,12 +161,12 @@  discard block
 block discarded – undo
161 161
 					<td class=" jst-cntr">
162 162
 						<ul class="txn-overview-actions-ul">
163 163
 							<li>
164
-								<a class="txn-admin-payment-action-edit-lnk" title="<?php esc_attr_e( 'Edit Payment', 'event_espresso' );?>" data-payment-id="PAY_ID">
164
+								<a class="txn-admin-payment-action-edit-lnk" title="<?php esc_attr_e('Edit Payment', 'event_espresso'); ?>" data-payment-id="PAY_ID">
165 165
 									<div class="dashicons dashicons-edit" style="margin: 0;"></div>
166 166
 								</a>
167 167
 							</li>
168 168
 							<li>
169
-								<a class="txn-admin-payment-action-delete-lnk" title="<?php esc_attr_e( 'Delete Payment', 'event_espresso' );?>" data-payment-id="PAY_ID">
169
+								<a class="txn-admin-payment-action-delete-lnk" title="<?php esc_attr_e('Delete Payment', 'event_espresso'); ?>" data-payment-id="PAY_ID">
170 170
 									<div class="dashicons dashicons-trash" style="margin: 0;"></div>
171 171
 								</a>
172 172
 							</li>
@@ -213,12 +213,12 @@  discard block
 block discarded – undo
213 213
 	<ul id="txn-admin-payment-options-ul">
214 214
 		<li>
215 215
 			<a id="display-txn-admin-apply-payment" class="button-primary no-icon no-hide" rel="txn-admin-apply-payment" > <!--display-the-hidden -->
216
-				<?php _e( 'Apply Payment', 'event_espresso' );?>
216
+				<?php _e('Apply Payment', 'event_espresso'); ?>
217 217
 			</a>
218 218
 		</li>
219 219
 		<li>
220 220
 			<a id="display-txn-admin-apply-refund" class="button-secondary no-icon no-hide" rel="txn-admin-apply-refund" >  <!--display-the-hidden -->
221
-				<?php _e( 'Apply Refund', 'event_espresso' );?>
221
+				<?php _e('Apply Refund', 'event_espresso'); ?>
222 222
 			</a>
223 223
 		</li>
224 224
 	</ul>
@@ -228,14 +228,14 @@  discard block
 block discarded – undo
228 228
 
229 229
 		<h2 id="admin-modal-dialog-apply-payment-h2" class="admin-modal-dialog-h2 hdr-has-icon" style="display:none;">
230 230
 			<div class="ee-icon ee-icon-cash-add float-left"></div>
231
-			<?php echo __( 'Apply a Payment to Transaction #', 'event_espresso' ) . $txn_nmbr['value'];?>
231
+			<?php echo __('Apply a Payment to Transaction #', 'event_espresso').$txn_nmbr['value']; ?>
232 232
 		</h2>
233 233
 
234 234
 		<h2 id="admin-modal-dialog-edit-payment-h2" class="admin-modal-dialog-h2 hdr-has-icon" style="display:none;">
235 235
 			<div class="ee-icon ee-icon-cash-edit float-left"></div>
236 236
 			<?php
237 237
 			echo sprintf(
238
-				__( 'Edit Payment #%s for Transaction #%s', 'event_espresso' ),
238
+				__('Edit Payment #%s for Transaction #%s', 'event_espresso'),
239 239
 				'<span></span>',
240 240
 				$txn_nmbr['value']
241 241
 			);
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 			<div class="ee-icon ee-icon-cash-edit float-left"></div>
247 247
 			<?php
248 248
 			echo sprintf(
249
-				__( 'Edit Refund #%s for Transaction #%s', 'event_espresso' ),
249
+				__('Edit Refund #%s for Transaction #%s', 'event_espresso'),
250 250
 				'<span></span>',
251 251
 				$txn_nmbr['value']
252 252
 			);
@@ -255,14 +255,14 @@  discard block
 block discarded – undo
255 255
 
256 256
 		<h2 id="admin-modal-dialog-apply-refund-h2" class="admin-modal-dialog-h2 hdr-has-icon" style="display:none;">
257 257
 			<div class="ee-icon ee-icon-cash-remove float-left"></div>
258
-			<?php echo __( 'Apply a Refund to Transaction #', 'event_espresso' ) . $txn_nmbr['value'];?>
258
+			<?php echo __('Apply a Refund to Transaction #', 'event_espresso').$txn_nmbr['value']; ?>
259 259
 		</h2>
260 260
 
261 261
 		<form name="txn-admin-apply-payment-frm" id="txn-admin-apply-payment-frm" action="<?php echo $apply_payment_form_url; ?>">
262 262
 			<div class="admin-modal-dialog-wrap">
263 263
 				<div class="admin-modal-dialog-inner">
264 264
 
265
-					<input  type="hidden" name="espresso_apply_payment_nonce" id="espresso_apply_payment_nonce" value="<?php echo wp_create_nonce( 'espresso_apply_payment_nonce' );?>"/>
265
+					<input  type="hidden" name="espresso_apply_payment_nonce" id="espresso_apply_payment_nonce" value="<?php echo wp_create_nonce('espresso_apply_payment_nonce'); ?>"/>
266 266
 					<input  type="hidden" name="espresso_ajax" id="espresso-ajax" value="0"/>
267 267
 					<input  type="hidden" name="noheader" id="txn-admin-noheader-inp" value="0"/>
268 268
 					<input  type="hidden" name="txn_admin_payment[PAY_ID]" id="txn-admin-payment-payment-id-inp" class="txn-admin-apply-payment-inp" value="0"/>
@@ -270,108 +270,108 @@  discard block
 block discarded – undo
270 270
 					<input  type="hidden" name="txn_admin_payment[type]" id="txn-admin-payment-type-inp" value="1"/>
271 271
 					<input  type="hidden" name="txn_admin_payment[details]" id="txn-admin-payment-details-inp" value=""/>
272 272
 					<input  type="hidden" name="txn_admin_delete_payment_form_url" id="txn-admin-delete-payment-form-url-inp" value="<?php echo $delete_payment_form_url; ?>"/>
273
-					<input  type="hidden" name="txn_admin_todays_date" id="txn-admin-todays-date-inp" value="<?php echo date( 'Y-m-d h:i a', current_time( 'timestamp' )); ?>"/>
273
+					<input  type="hidden" name="txn_admin_todays_date" id="txn-admin-todays-date-inp" value="<?php echo date('Y-m-d h:i a', current_time('timestamp')); ?>"/>
274 274
 
275 275
 					<div class="txn-admin-apply-payment-date-dv admin-modal-dialog-row">
276
-						<div class="validation-notice-dv"><?php _e( 'The following is  a required field', 'event_espresso' );?></div>
277
-						<label for="txn-admin-payment-date-inp" class=""><?php _e( 'Payment Date', 'event_espresso' );?></label>
278
-						<input name="[date]txn_admin_payment" id="txn-admin-payment-date-inp" class="txn-admin-apply-payment-inp required" type="text" value="<?php echo date( 'Y-m-d g:i a', current_time( 'timestamp' )); ?>"/>
279
-						<p class="description"><?php _e( 'The date the payment was actually made on', 'event_espresso' );?></p>
276
+						<div class="validation-notice-dv"><?php _e('The following is  a required field', 'event_espresso'); ?></div>
277
+						<label for="txn-admin-payment-date-inp" class=""><?php _e('Payment Date', 'event_espresso'); ?></label>
278
+						<input name="[date]txn_admin_payment" id="txn-admin-payment-date-inp" class="txn-admin-apply-payment-inp required" type="text" value="<?php echo date('Y-m-d g:i a', current_time('timestamp')); ?>"/>
279
+						<p class="description"><?php _e('The date the payment was actually made on', 'event_espresso'); ?></p>
280 280
 					</div>
281 281
 
282 282
 					<div class="txn-admin-apply-payment-amount-dv admin-modal-dialog-row">
283
-						<div class="validation-notice-dv"><?php _e( 'The following is  a required field', 'event_espresso' );?></div>
284
-						<label for="txn-admin-payment-amount-inp" class=""><?php _e( 'Amount', 'event_espresso' );?></label>
283
+						<div class="validation-notice-dv"><?php _e('The following is  a required field', 'event_espresso'); ?></div>
284
+						<label for="txn-admin-payment-amount-inp" class=""><?php _e('Amount', 'event_espresso'); ?></label>
285 285
 						<input name="txn_admin_payment[amount]" id="txn-admin-payment-amount-inp" class="txn-admin-apply-payment-inp required" type="text" value=""/>
286
-						<p class="description"><?php _e( 'The amount of the payment', 'event_espresso' );?></p>
286
+						<p class="description"><?php _e('The amount of the payment', 'event_espresso'); ?></p>
287 287
 					</div>
288 288
 
289 289
 					<div class="txn-admin-apply-payment-method-dv admin-modal-dialog-row">
290
-						<div class="validation-notice-dv"><?php _e( 'The following is  a required field', 'event_espresso' );?></div>
291
-						<label for="txn-admin-payment-method-inp" class=""><?php _e( 'Method of Payment', 'event_espresso' );?></label>
290
+						<div class="validation-notice-dv"><?php _e('The following is  a required field', 'event_espresso'); ?></div>
291
+						<label for="txn-admin-payment-method-inp" class=""><?php _e('Method of Payment', 'event_espresso'); ?></label>
292 292
 						<select name="txn_admin_payment[PMD_ID]" id="txn-admin-payment-method-slct" class="txn-admin-apply-payment-slct required" type="text" >
293
-						<?php foreach ( $payment_methods as $method ) : ?>
293
+						<?php foreach ($payment_methods as $method) : ?>
294 294
 							<?php $selected = $method->slug() == 'cash' ? ' selected="selected"' : ''; ?>
295
-							<option id="payment-method-opt-<?php echo $method->slug(); ?>" value="<?php echo $method->ID(); ?>"<?php echo $selected; ?>><?php echo sanitize_key( $method->admin_desc() ) ? substr( $method->admin_desc(), 0, 128) : $method->admin_name() ; ?>&nbsp;&nbsp;</option>
295
+							<option id="payment-method-opt-<?php echo $method->slug(); ?>" value="<?php echo $method->ID(); ?>"<?php echo $selected; ?>><?php echo sanitize_key($method->admin_desc()) ? substr($method->admin_desc(), 0, 128) : $method->admin_name(); ?>&nbsp;&nbsp;</option>
296 296
 						<?php endforeach; ?>
297 297
 						</select>
298
-						<p class="description"><?php _e( 'Whether the payment was made via PayPal, Credit Card, Cheque, or Cash', 'event_espresso' );?></p>
298
+						<p class="description"><?php _e('Whether the payment was made via PayPal, Credit Card, Cheque, or Cash', 'event_espresso'); ?></p>
299 299
 					</div>
300 300
 
301 301
 					<div class="mop-PP mop-CC mop-CHQ mop">
302 302
 						<div class="txn-admin-apply-payment-gw-txn-id-dv admin-modal-dialog-row">
303
-							<label for="txn-admin-payment-txn-id-inp" class=""><?php _e( 'TXN ID / CHQ #', 'event_espresso' );?></label>
303
+							<label for="txn-admin-payment-txn-id-inp" class=""><?php _e('TXN ID / CHQ #', 'event_espresso'); ?></label>
304 304
 							<input name="txn_admin_payment[txn_id_chq_nmbr]" id="txn-admin-payment-txn-id-chq-nmbr-inp" class="txn-admin-apply-payment-inp" type="text" maxlength="100"/>
305
-							<p class="description"><?php _e( 'The Transaction ID sent back from the payment gateway, or the Cheque #', 'event_espresso' );?></p>
305
+							<p class="description"><?php _e('The Transaction ID sent back from the payment gateway, or the Cheque #', 'event_espresso'); ?></p>
306 306
 						</div>
307 307
 					</div>
308 308
 
309 309
 					<div class="mop-CC mop" style="display:none">
310 310
 						<div class="txn-admin-apply-payment-response-dv admin-modal-dialog-row">
311
-							<label for="txn-admin-payment-gateway-response-inp" class=""><?php _e( 'Gateway Response', 'event_espresso' );?></label>
311
+							<label for="txn-admin-payment-gateway-response-inp" class=""><?php _e('Gateway Response', 'event_espresso'); ?></label>
312 312
 							<input name="txn_admin_payment[gateway_response]" id="txn-admin-payment-gateway-response-inp" class="txn-admin-apply-payment-inp" type="text"/>
313
-							<p class="description"><?php _e( 'The gateway response string (optional)', 'event_espresso' );?></p>
313
+							<p class="description"><?php _e('The gateway response string (optional)', 'event_espresso'); ?></p>
314 314
 						</div>
315 315
 					</div>
316 316
 
317 317
 					<div class="mop-PP mop-CC mop">
318 318
 						<div class="txn-admin-apply-payment-status-dv admin-modal-dialog-row">
319
-							<label for="txn-admin-payment-status-inp" class=""><?php _e( 'Payment Status', 'event_espresso' );?></label>
319
+							<label for="txn-admin-payment-status-inp" class=""><?php _e('Payment Status', 'event_espresso'); ?></label>
320 320
 							<select name="txn_admin_payment[status]" id="txn-admin-payment-status-slct" class="txn-admin-apply-payment-slct" type="text" >
321
-							<?php foreach ( $payment_status as $STS_ID => $STS_code ) : ?>
321
+							<?php foreach ($payment_status as $STS_ID => $STS_code) : ?>
322 322
 								<?php $selected = $STS_ID == 'PAP' ? ' selected="selected"' : ''; ?>
323 323
 								<option id="payment-status-opt-<?php echo $STS_ID; ?>" value="<?php echo $STS_ID; ?>"<?php echo $selected; ?>><?php echo $STS_code; ?>&nbsp;&nbsp;</option>
324 324
 							<?php endforeach; ?>
325 325
 							</select>
326
-							<p class="description"><?php _e( 'Whether the payment was approved, cancelled, declined or failed after submission to the gateway', 'event_espresso' );?></p>
326
+							<p class="description"><?php _e('Whether the payment was approved, cancelled, declined or failed after submission to the gateway', 'event_espresso'); ?></p>
327 327
 						</div>
328 328
 					</div>
329 329
 
330 330
 					<div class="txn-admin-apply-payment-po-nmbr-dv admin-modal-dialog-row">
331
-						<label for="txn-admin-payment-po-nmbr-inp" class=""><?php _e( 'P.O. / S.O. #', 'event_espresso' );?></label>
331
+						<label for="txn-admin-payment-po-nmbr-inp" class=""><?php _e('P.O. / S.O. #', 'event_espresso'); ?></label>
332 332
 						<input name="txn_admin_payment[po_number]" id="txn-admin-payment-po-nmbr-inp" class="txn-admin-apply-payment-inp" type="text" maxlength="100"/>
333
-						<p class="description"><?php _e( 'The Purchase or Sales Order Number if any (optional)', 'event_espresso' );?></p>
333
+						<p class="description"><?php _e('The Purchase or Sales Order Number if any (optional)', 'event_espresso'); ?></p>
334 334
 					</div>
335 335
 
336 336
 					<div class="txn-admin-apply-payment-accounting-dv admin-modal-dialog-row">
337
-						<label for="txn-admin-payment-accounting-inp" class="last"><?php _e( 'Notes / Extra Accounting', 'event_espresso' );?></label>
337
+						<label for="txn-admin-payment-accounting-inp" class="last"><?php _e('Notes / Extra Accounting', 'event_espresso'); ?></label>
338 338
 						<input name="txn_admin_payment[accounting]" id="txn-admin-payment-accounting-inp" class="txn-admin-apply-payment-inp" type="text" value="<?php echo $REG_code; ?>" maxlength="100"/>		<input type="hidden" id="txn-admin-reg-code-inp" value="<?php echo $REG_code; ?>"/>
339
-						<p class="description"><?php _e( 'An extra field you may use for accounting purposes or simple notes. Defaults to the primary registrant\'s registration code.', 'event_espresso' );?></p>
339
+						<p class="description"><?php _e('An extra field you may use for accounting purposes or simple notes. Defaults to the primary registrant\'s registration code.', 'event_espresso'); ?></p>
340 340
 					</div>
341 341
 
342 342
 					<div class="txn-admin-apply-payment-registrations-dv admin-modal-dialog-row">
343
-						<label for="txn-admin-payment-registrations-inp" class="last"><?php _e( 'Registrations to Apply Payment to:', 'event_espresso' ); ?></label>
343
+						<label for="txn-admin-payment-registrations-inp" class="last"><?php _e('Registrations to Apply Payment to:', 'event_espresso'); ?></label>
344 344
 						<label class="txn-admin-apply-payment-to-registrations-lbl">
345 345
 							<input type="radio" value="1" id="txn-admin-apply-payment-to-all-registrations-inp" name="txn_admin_payment[apply_to_all_registrations]"  checked="checked"/>
346
-							<?php _e( 'ALL Registrations', 'event_espresso' ); ?>
346
+							<?php _e('ALL Registrations', 'event_espresso'); ?>
347 347
 						</label>
348 348
 						<label class="txn-admin-apply-payment-to-registrations-lbl">
349 349
 							<input type="radio" value="0" id="txn-admin-apply-payment-to-some-registrations-inp" name="txn_admin_payment[apply_to_all_registrations]" />
350
-							<?php _e( 'Just the following Registrations', 'event_espresso' ); ?>
350
+							<?php _e('Just the following Registrations', 'event_espresso'); ?>
351 351
 						</label>
352 352
 						<?php echo $registrations_to_apply_payment_to; ?>
353 353
 					</div>
354 354
 
355 355
 					<div class="txn-admin-payment-reg-status-dv admin-modal-dialog-row">
356
-						<label for="txn-admin-payment-reg-status-inp" class="last"><?php _e( 'Change Registration Status?', 'event_espresso' );?></label>
356
+						<label for="txn-admin-payment-reg-status-inp" class="last"><?php _e('Change Registration Status?', 'event_espresso'); ?></label>
357 357
 						<?php echo $status_change_select; ?>
358
-						<p class="description"><?php _e( 'If you wish to change the status for the registrations selected above, then select which status from this dropdown.', 'event_espresso' ); ?></p>
358
+						<p class="description"><?php _e('If you wish to change the status for the registrations selected above, then select which status from this dropdown.', 'event_espresso'); ?></p>
359 359
 						<br/>
360 360
 					</div>
361 361
 
362 362
 					<div class="txn-admin-apply-payment-send-notifications-dv admin-modal-dialog-row">
363 363
 
364
-						<label for="txn-admin-payment-send-notifications-inp" class="last"><?php _e( 'Send Related Messages?', 'event_espresso' );?></label>
364
+						<label for="txn-admin-payment-send-notifications-inp" class="last"><?php _e('Send Related Messages?', 'event_espresso'); ?></label>
365 365
 						<label class="txn-admin-payment-send-notifications-lbl">
366 366
 							<input type="checkbox" value="1" name="txn_payments[send_notifications]" checked="checked" aria-checked="true" style="vertical-align: middle;">
367
-							<?php _e( 'Payment Messages?', 'event_espresso' ); ?>
367
+							<?php _e('Payment Messages?', 'event_espresso'); ?>
368 368
 						</label>
369 369
 						<label class="txn-admin-payment-send-notifications-lbl">
370 370
 							<input type="checkbox" value="1" name="txn_reg_status_change[send_notifications]" style="vertical-align: middle;">
371
-							<?php _e( 'Registration Messages?', 'event_espresso' ); ?>
371
+							<?php _e('Registration Messages?', 'event_espresso'); ?>
372 372
 						</label>
373 373
 						<br class="clear-float"/>
374
-						<p class="description"><?php printf( __('By default %1$sa payment message is sent to the primary registrant%2$s after submitting this form.%3$sHowever, if you check the "Registration Messages" box, the system will also send any related messages matching the status of the registrations to %1$seach registration for this transaction%2$s.', 'event_espresso'), '<strong>', '</strong>', '<br />' ); ?></p>
374
+						<p class="description"><?php printf(__('By default %1$sa payment message is sent to the primary registrant%2$s after submitting this form.%3$sHowever, if you check the "Registration Messages" box, the system will also send any related messages matching the status of the registrations to %1$seach registration for this transaction%2$s.', 'event_espresso'), '<strong>', '</strong>', '<br />'); ?></p>
375 375
 						<label></label>
376 376
 					</div>
377 377
 					<div class="clear"></div>
@@ -382,27 +382,27 @@  discard block
 block discarded – undo
382 382
 			<ul id="admin-modal-dialog-options-ul">
383 383
 				<li>
384 384
 					<a id="txn-admin-modal-dialog-apply-payment-lnk" class="button-primary no-icon" style="display:none;" >
385
-						<?php _e( 'Apply Payment', 'event_espresso' );?>
385
+						<?php _e('Apply Payment', 'event_espresso'); ?>
386 386
 					</a>
387 387
 				</li>
388 388
 				<li>
389 389
 					<a id="txn-admin-modal-dialog-edit-payment-lnk" class="button-primary no-icon" style="display:none;" >
390
-						<?php _e( 'Save Payment Details', 'event_espresso' );?>
390
+						<?php _e('Save Payment Details', 'event_espresso'); ?>
391 391
 					</a>
392 392
 				</li>
393 393
 				<li>
394 394
 					<a id="txn-admin-modal-dialog-edit-refund-lnk" class="button-primary no-icon" style="display:none;" >
395
-						<?php _e( 'Save Refund Details', 'event_espresso' );?>
395
+						<?php _e('Save Refund Details', 'event_espresso'); ?>
396 396
 					</a>
397 397
 				</li>
398 398
 				<li>
399 399
 					<a id="txn-admin-modal-dialog-apply-refund-lnk" class="button-primary no-icon" style="display:none;" >
400
-						<?php _e( 'Apply Refund', 'event_espresso' );?>
400
+						<?php _e('Apply Refund', 'event_espresso'); ?>
401 401
 					</a>
402 402
 				</li>
403 403
 				<li>
404 404
 					<a id="txn-admin-modal-dialog-cancel-lnk" class="button-secondary no-icon" >
405
-						<?php _e( 'Cancel', 'event_espresso' );?>
405
+						<?php _e('Cancel', 'event_espresso'); ?>
406 406
 					</a>
407 407
 				</li>
408 408
 				<li>
@@ -419,29 +419,29 @@  discard block
 block discarded – undo
419 419
 
420 420
 		<h2 id="admin-modal-dialog-delete-payment-h2" class="admin-modal-dialog-h2 hdr-has-icon" style="display:none;">
421 421
 			<span class="ee-icon ee-icon-cash-add"></span>
422
-			<?php echo __( 'Delete Payment/Refund for Transaction #', 'event_espresso' ) . $txn_nmbr['value'];?>
422
+			<?php echo __('Delete Payment/Refund for Transaction #', 'event_espresso').$txn_nmbr['value']; ?>
423 423
 		</h2>
424 424
 
425 425
 		<form name="txn-admin-delete-payment-frm" id="txn-admin-delete-payment-frm" action="<?php echo $delete_payment_url; ?>">
426 426
 			<div class="admin-modal-dialog-wrap">
427 427
 				<div class="admin-modal-dialog-inner">
428 428
 
429
-					<input  type="hidden" name="espresso_delete_payment_nonce" id="espresso_delete_payment_nonce" value="<?php echo wp_create_nonce( 'espresso_delete_payment_nonce' );?>"/>
429
+					<input  type="hidden" name="espresso_delete_payment_nonce" id="espresso_delete_payment_nonce" value="<?php echo wp_create_nonce('espresso_delete_payment_nonce'); ?>"/>
430 430
 					<input  type="hidden" name="delete_espresso_ajax" id="delete-espresso-ajax" value="0"/>
431 431
 					<input  type="hidden" name="delete_noheader" id="delete-txn-admin-noheader-inp" value="0"/>
432 432
 					<input  type="hidden" name="delete_txn_admin_payment[PAY_ID]" id="delete-txn-admin-payment-payment-id-inp" class="txn-admin-apply-payment-inp" value="0"/>
433 433
 					<input  type="hidden" name="delete_txn_admin_payment[TXN_ID]" id="delete-txn-admin-payment-txn-id-inp" value="<?php echo $txn_nmbr['value']; ?>"/>
434 434
 
435 435
 					<div class="txn-admin-apply-payment-accounting-dv admin-modal-dialog-row">
436
-						<label for="delete-txn-admin-payment-reg-status-inp" class="last"><?php _e( 'Change Registration Status?', 'event_espresso' );?></label>
436
+						<label for="delete-txn-admin-payment-reg-status-inp" class="last"><?php _e('Change Registration Status?', 'event_espresso'); ?></label>
437 437
 						<?php echo $delete_status_change_select; ?>
438
-						<p class="description"><?php printf( __('If you wish to change the status of all the registrations associated with this transaction after deleting this payment/refund, then select which status from this dropdown. %sNote: ALL registrations associated with this transaction will be updated to this new status.%s', 'event_espresso'), '<strong>', '</strong>' ); ?></p>
438
+						<p class="description"><?php printf(__('If you wish to change the status of all the registrations associated with this transaction after deleting this payment/refund, then select which status from this dropdown. %sNote: ALL registrations associated with this transaction will be updated to this new status.%s', 'event_espresso'), '<strong>', '</strong>'); ?></p>
439 439
 					</div>
440 440
 
441 441
 					<div class="ee-attention txn-admin-apply-payment-accounting-dv admin-modal-dialog-row">
442
-						<label for="delete-txn-admin-payment-accounting-inp" class="last"><?php _e( 'Send Related Messages?', 'event_espresso' );?></label>
442
+						<label for="delete-txn-admin-payment-accounting-inp" class="last"><?php _e('Send Related Messages?', 'event_espresso'); ?></label>
443 443
 						<input type="checkbox" value="1" name="delete_txn_reg_status_change[send_notifications]">
444
-						<p class="description"><?php _e( 'If you check this box, the system will send any related registration messages matching the status of the registrations to each registration for this transaction. No Payment notifications are sent when deleting a payment.', 'event_espresso' );?></p>
444
+						<p class="description"><?php _e('If you check this box, the system will send any related registration messages matching the status of the registrations to each registration for this transaction. No Payment notifications are sent when deleting a payment.', 'event_espresso'); ?></p>
445 445
 					</div>
446 446
 					<div class="clear"></div>
447 447
 
@@ -451,12 +451,12 @@  discard block
 block discarded – undo
451 451
 			<ul id="del-admin-modal-dialog-options-ul">
452 452
 				<li>
453 453
 					<a id="txn-admin-modal-dialog-delete-lnk" class="button-primary no-icon" style="display:none;" >
454
-						<?php _e( 'Delete', 'event_espresso' );?>
454
+						<?php _e('Delete', 'event_espresso'); ?>
455 455
 					</a>
456 456
 				</li>
457 457
 				<li>
458 458
 					<a id="del-txn-admin-modal-dialog-cancel-lnk" class="button-secondary no-icon" >
459
-						<?php _e( 'Cancel', 'event_espresso' );?>
459
+						<?php _e('Cancel', 'event_espresso'); ?>
460 460
 					</a>
461 461
 				</li>
462 462
 				<li>
@@ -472,30 +472,30 @@  discard block
 block discarded – undo
472 472
 	<?php endif; // $grand_raw_total > 0?>
473 473
 
474 474
 	<?php
475
-	if ( WP_DEBUG ) {
476
-		$delivered_messages = get_option( 'EED_Messages__payment', array() );
477
-		if ( isset( $delivered_messages[ $TXN_ID ] )) {
475
+	if (WP_DEBUG) {
476
+		$delivered_messages = get_option('EED_Messages__payment', array());
477
+		if (isset($delivered_messages[$TXN_ID])) {
478 478
 			?>
479
-			<h4 class="admin-primary-mbox-h4 hdr-has-icon"><span class="dashicons dashicons-email-alt"></span><?php _e( 'Messages Sent to Primary Registrant', 'event_espresso' );?></h4>
479
+			<h4 class="admin-primary-mbox-h4 hdr-has-icon"><span class="dashicons dashicons-email-alt"></span><?php _e('Messages Sent to Primary Registrant', 'event_espresso'); ?></h4>
480 480
 
481 481
 			<div class="admin-primary-mbox-tbl-wrap">
482 482
 				<table class="admin-primary-mbox-tbl">
483 483
 					<thead>
484 484
 						<tr>
485
-							<th class="jst-left"><?php _e( 'Date & Time', 'event_espresso' );?></th>
486
-							<th class="jst-left"><?php _e( 'Message Type', 'event_espresso' );?></th>
487
-							<th class="jst-left"><?php _e( 'Payment Status Upon Sending', 'event_espresso' );?></th>
488
-							<th class="jst-left"><?php _e( 'TXN Status Upon Sending', 'event_espresso' );?></th>
485
+							<th class="jst-left"><?php _e('Date & Time', 'event_espresso'); ?></th>
486
+							<th class="jst-left"><?php _e('Message Type', 'event_espresso'); ?></th>
487
+							<th class="jst-left"><?php _e('Payment Status Upon Sending', 'event_espresso'); ?></th>
488
+							<th class="jst-left"><?php _e('TXN Status Upon Sending', 'event_espresso'); ?></th>
489 489
 						</tr>
490 490
 					</thead>
491 491
 					<tbody>
492
-						<?php foreach ( $delivered_messages[ $TXN_ID ] as $timestamp => $delivered_message ) :
492
+						<?php foreach ($delivered_messages[$TXN_ID] as $timestamp => $delivered_message) :
493 493
 							?>
494 494
 							<tr>
495
-								<td class="jst-left"><?php echo gmdate( get_option('date_format') . ' ' . get_option('time_format'), ( $timestamp + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) ) );?></td>
496
-								<td class="jst-left"><?php echo isset( $delivered_message['message_type'] ) ? $delivered_message['message_type'] : '';?></td>
497
-								<td class="jst-left"><?php echo isset( $delivered_message['pay_status'] ) ? $delivered_message['pay_status'] : '';?></td>
498
-								<td class="jst-left"><?php echo isset( $delivered_message['txn_status'] ) ? $delivered_message['txn_status'] : '';?></td>
495
+								<td class="jst-left"><?php echo gmdate(get_option('date_format').' '.get_option('time_format'), ($timestamp + (get_option('gmt_offset') * HOUR_IN_SECONDS))); ?></td>
496
+								<td class="jst-left"><?php echo isset($delivered_message['message_type']) ? $delivered_message['message_type'] : ''; ?></td>
497
+								<td class="jst-left"><?php echo isset($delivered_message['pay_status']) ? $delivered_message['pay_status'] : ''; ?></td>
498
+								<td class="jst-left"><?php echo isset($delivered_message['txn_status']) ? $delivered_message['txn_status'] : ''; ?></td>
499 499
 							</tr>
500 500
 						<?php endforeach; // $delivered_messages?>
501 501
 					</tbody>
Please login to merge, or discard this patch.
core/db_classes/EE_Soft_Delete_Base_Class.class.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) {
2
-	exit( 'No direct script access allowed' );
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 /**
5 5
  * Event Espresso
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	 * @param boolean $allow_blocking ignored, because we never block soft deletes
35 35
 	 * @return bool|int
36 36
 	 */
37
-	protected function _delete( $allow_blocking = true ) {
37
+	protected function _delete($allow_blocking = true) {
38 38
 		return $this->delete_or_restore();
39 39
 	}
40 40
 
@@ -44,23 +44,23 @@  discard block
 block discarded – undo
44 44
 	 * @param bool $delete true=>delete, false=>restore
45 45
 	 * @return bool|int
46 46
 	 */
47
-	public function delete_or_restore( $delete = true ) {
47
+	public function delete_or_restore($delete = true) {
48 48
 		/**
49 49
 		 * Called just before trashing (soft delete) or restoring a trashed item.
50 50
 		 *
51 51
 		 * @param EE_Base_Class $model_object about to be trashed or restored
52 52
 		 * @param bool          $delete       true the item is being trashed, false the item is being restored.
53 53
 		 */
54
-		do_action( 'AHEE__EE_Soft_Delete_Base_Class__delete_or_restore__before', $this, $delete );
54
+		do_action('AHEE__EE_Soft_Delete_Base_Class__delete_or_restore__before', $this, $delete);
55 55
 		$model = $this->get_model();
56
-		$result = $model->delete_or_restore_by_ID( $delete, $this->ID() );
56
+		$result = $model->delete_or_restore_by_ID($delete, $this->ID());
57 57
 		/**
58 58
 		 * Called just after trashing (soft delete) or restoring a trashed item.
59 59
 		 * @param EE_Base_Class $model_object that was just trashed or restored.
60 60
 		 * @param bool          $delete       true the item is being trashed, false the item is being restored.
61 61
 		 * @param bool|int $result
62 62
 		 */
63
-		do_action( 'AHEE__EE_Soft_Delete_Base_Class__delete_or_restore__after', $this, $delete, $result );
63
+		do_action('AHEE__EE_Soft_Delete_Base_Class__delete_or_restore__after', $this, $delete, $result);
64 64
 		return $result;
65 65
 	}
66 66
 
@@ -71,6 +71,6 @@  discard block
 block discarded – undo
71 71
 	 * @return bool|int
72 72
 	 */
73 73
 	public function restore() {
74
-		return $this->delete_or_restore( false );
74
+		return $this->delete_or_restore(false);
75 75
 	}
76 76
 }
77 77
\ No newline at end of file
Please login to merge, or discard this patch.
core/db_models/EEM_CPT_Base.model.php 1 patch
Spacing   +89 added lines, -89 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-define('EE_Event_Category_Taxonomy','espresso_event_category');
2
+define('EE_Event_Category_Taxonomy', 'espresso_event_category');
3 3
 /**
4 4
  *
5 5
  * EEM_CPT_Base
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  * @author 				Mike Nelson
17 17
  *
18 18
  */
19
-abstract class EEM_CPT_Base extends EEM_Soft_Delete_Base{
19
+abstract class EEM_CPT_Base extends EEM_Soft_Delete_Base {
20 20
 
21 21
 	/**
22 22
 	 * @var string post_status_publish - the wp post status for published cpts
@@ -69,56 +69,56 @@  discard block
 block discarded – undo
69 69
 	 * @param string $timezone
70 70
 	 * @throws \EE_Error
71 71
 	 */
72
-	protected function __construct( $timezone = NULL ){
72
+	protected function __construct($timezone = NULL) {
73 73
 
74 74
 		//adds a relationship to Term_Taxonomy for all these models. For this to work
75 75
 		//Term_Relationship must have a relation to each model subclassing EE_CPT_Base explicitly
76 76
 		//eg, in EEM_Term_Relationship, inside the _model_relations array, there must be an entry
77 77
 		//with key equalling the subclassing model's model name (eg 'Event' or 'Venue'), and the value
78 78
 		//must also be new EE_HABTM_Relation('Term_Relationship');
79
-		$this->_model_relations['Term_Taxonomy'] =new EE_HABTM_Relation('Term_Relationship');
80
-		$this->_model_relations[ 'Post_Meta' ] = new EE_Has_Many_Relation( false );
79
+		$this->_model_relations['Term_Taxonomy'] = new EE_HABTM_Relation('Term_Relationship');
80
+		$this->_model_relations['Post_Meta'] = new EE_Has_Many_Relation(false);
81 81
 		$primary_table_name = NULL;
82 82
 		//add  the common _status field to all CPT primary tables.
83
-		foreach ( $this->_tables as $alias => $table_obj ) {
84
-			if ( $table_obj instanceof EE_Primary_Table ) {
83
+		foreach ($this->_tables as $alias => $table_obj) {
84
+			if ($table_obj instanceof EE_Primary_Table) {
85 85
 				$primary_table_name = $alias;
86 86
 			}
87 87
 		}
88 88
 		//set default wp post statuses if child has not already set.
89
-		if ( ! isset( $this->_fields[$primary_table_name]['status'] )) {
89
+		if ( ! isset($this->_fields[$primary_table_name]['status'])) {
90 90
 			$this->_fields[$primary_table_name]['status'] = new EE_WP_Post_Status_Field('post_status', __("Event Status", "event_espresso"), false, 'draft');
91 91
 		}
92
-		if( ! isset( $this->_fields[$primary_table_name]['to_ping'])){
93
-			$this->_fields[$primary_table_name]['to_ping'] = new EE_DB_Only_Text_Field('to_ping', __( 'To Ping', 'event_espresso' ), FALSE, '');
92
+		if ( ! isset($this->_fields[$primary_table_name]['to_ping'])) {
93
+			$this->_fields[$primary_table_name]['to_ping'] = new EE_DB_Only_Text_Field('to_ping', __('To Ping', 'event_espresso'), FALSE, '');
94 94
 		}
95
-		if( ! isset( $this->_fields[$primary_table_name]['pinged'])){
96
-			$this->_fields[$primary_table_name]['pinged'] = new EE_DB_Only_Text_Field('pinged', __( 'Pinged', 'event_espresso' ), FALSE, '');
95
+		if ( ! isset($this->_fields[$primary_table_name]['pinged'])) {
96
+			$this->_fields[$primary_table_name]['pinged'] = new EE_DB_Only_Text_Field('pinged', __('Pinged', 'event_espresso'), FALSE, '');
97 97
 		}
98 98
 
99
-		if( ! isset( $this->_fields[$primary_table_name]['comment_status'])){
100
-			$this->_fields[$primary_table_name]['comment_status'] = new EE_Plain_Text_Field('comment_status', __('Comment Status', 'event_espresso' ), FALSE, 'open');
99
+		if ( ! isset($this->_fields[$primary_table_name]['comment_status'])) {
100
+			$this->_fields[$primary_table_name]['comment_status'] = new EE_Plain_Text_Field('comment_status', __('Comment Status', 'event_espresso'), FALSE, 'open');
101 101
 		}
102 102
 
103
-		if( ! isset( $this->_fields[$primary_table_name]['ping_status'])){
103
+		if ( ! isset($this->_fields[$primary_table_name]['ping_status'])) {
104 104
 			$this->_fields[$primary_table_name]['ping_status'] = new EE_Plain_Text_Field('ping_status', __('Ping Status', 'event_espresso'), FALSE, 'open');
105 105
 		}
106 106
 
107
-		if( ! isset( $this->_fields[$primary_table_name]['post_content_filtered'])){
108
-			$this->_fields[$primary_table_name]['post_content_filtered'] = new EE_DB_Only_Text_Field('post_content_filtered', __( 'Post Content Filtered', 'event_espresso' ), FALSE, '');
107
+		if ( ! isset($this->_fields[$primary_table_name]['post_content_filtered'])) {
108
+			$this->_fields[$primary_table_name]['post_content_filtered'] = new EE_DB_Only_Text_Field('post_content_filtered', __('Post Content Filtered', 'event_espresso'), FALSE, '');
109 109
 		}
110
-		if( ! isset( $this->_model_relations[ 'Post_Meta' ] ) ) {
110
+		if ( ! isset($this->_model_relations['Post_Meta'])) {
111 111
 			//don't block deletes though because we want to maintain the current behaviour
112
-			$this->_model_relations[ 'Post_Meta' ] = new EE_Has_Many_Relation( false );
112
+			$this->_model_relations['Post_Meta'] = new EE_Has_Many_Relation(false);
113 113
 		}
114
-		if( ! $this->_minimum_where_conditions_strategy instanceof EE_Default_Where_Conditions ){
114
+		if ( ! $this->_minimum_where_conditions_strategy instanceof EE_Default_Where_Conditions) {
115 115
 			//nothing was set during child constructor, so set default
116
-			$this->_minimum_where_conditions_strategy = new EE_CPT_Minimum_Where_Conditions( $this->post_type() );
116
+			$this->_minimum_where_conditions_strategy = new EE_CPT_Minimum_Where_Conditions($this->post_type());
117 117
 		}
118
-		if( ! $this->_default_where_conditions_strategy instanceof EE_Default_Where_Conditions ) {
118
+		if ( ! $this->_default_where_conditions_strategy instanceof EE_Default_Where_Conditions) {
119 119
 			//nothing was set during child constructor, so set default
120 120
 			//it's ok for child classes to specify this, but generally this is more DRY
121
-			$this->_default_where_conditions_strategy = new EE_CPT_Where_Conditions( $this->post_type() );
121
+			$this->_default_where_conditions_strategy = new EE_CPT_Where_Conditions($this->post_type());
122 122
 		}
123 123
 		parent::__construct($timezone);
124 124
 
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 	 */
132 132
 	public function public_event_stati() {
133 133
 		// @see wp-includes/post.php
134
-		return get_post_stati( array( 'public' => TRUE ));
134
+		return get_post_stati(array('public' => TRUE));
135 135
 	}
136 136
 
137 137
 
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 	 * @return string
143 143
 	 * @throws EE_Error
144 144
 	 */
145
-	public function deleted_field_name(){
145
+	public function deleted_field_name() {
146 146
 		throw new EE_Error(sprintf(__("EEM_CPT_Base should nto call deleted_field_name! It should instead use post_status_field_name", "event_espresso")));
147 147
 	}
148 148
 
@@ -153,12 +153,12 @@  discard block
 block discarded – undo
153 153
 	 * @return string
154 154
 	 * @throws EE_Error
155 155
 	 */
156
-	public function post_status_field_name(){
156
+	public function post_status_field_name() {
157 157
 		$field = $this->get_a_field_of_type('EE_WP_Post_Status_Field');
158
-		if($field){
158
+		if ($field) {
159 159
 			return $field->get_name();
160
-		}else{
161
-			throw new EE_Error(sprintf(__('We are trying to find the post status 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)));
160
+		} else {
161
+			throw new EE_Error(sprintf(__('We are trying to find the post status 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)));
162 162
 		}
163 163
 	}
164 164
 
@@ -169,9 +169,9 @@  discard block
 block discarded – undo
169 169
 	 * @param array $query_params like EEM_Base::get_all's $query_params
170 170
 	 * @return array like EEM_Base::get_all's $query_params
171 171
 	 */
172
-	protected function _alter_query_params_so_only_trashed_items_included($query_params){
173
-		$post_status_field_name=$this->post_status_field_name();
174
-		$query_params[0][$post_status_field_name]=self::post_status_trashed;
172
+	protected function _alter_query_params_so_only_trashed_items_included($query_params) {
173
+		$post_status_field_name = $this->post_status_field_name();
174
+		$query_params[0][$post_status_field_name] = self::post_status_trashed;
175 175
 		return $query_params;
176 176
 	}
177 177
 
@@ -182,8 +182,8 @@  discard block
 block discarded – undo
182 182
 	 * @param array $query_params
183 183
 	 * @return array
184 184
 	 */
185
-	protected function _alter_query_params_so_deleted_and_undeleted_items_included($query_params){
186
-		$query_params[ 'default_where_conditions' ] = 'minimum';
185
+	protected function _alter_query_params_so_deleted_and_undeleted_items_included($query_params) {
186
+		$query_params['default_where_conditions'] = 'minimum';
187 187
 		return $query_params;
188 188
 	}
189 189
 
@@ -195,11 +195,11 @@  discard block
 block discarded – undo
195 195
 	 * @param array $query_params like EEM_Base::get_all
196 196
 	 * @return boolean success
197 197
 	 */
198
-	function delete_or_restore($delete=true,$query_params = array()){
199
-		$post_status_field_name=$this->post_status_field_name();
198
+	function delete_or_restore($delete = true, $query_params = array()) {
199
+		$post_status_field_name = $this->post_status_field_name();
200 200
 		$query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params);
201 201
 		$new_status = $delete ? self::post_status_trashed : 'draft';
202
-		if ( $this->update (array($post_status_field_name=>$new_status), $query_params )) {
202
+		if ($this->update(array($post_status_field_name=>$new_status), $query_params)) {
203 203
 			return TRUE;
204 204
 		} else {
205 205
 			return FALSE;
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 	 */
217 217
 	public function meta_table() {
218 218
 		$meta_table = $this->_get_other_tables();
219
-		$meta_table = reset( $meta_table );
219
+		$meta_table = reset($meta_table);
220 220
 		return $meta_table instanceof EE_Secondary_Table ? $meta_table->get_table_name() : NULL;
221 221
 	}
222 222
 
@@ -228,16 +228,16 @@  discard block
 block discarded – undo
228 228
 	 * @param  bool $all triggers whether we include DB_Only fields or JUST non DB_Only fields.  Defaults to false (no db only fields)
229 229
 	 * @return array
230 230
 	 */
231
-	public function get_meta_table_fields( $all = FALSE ) {
231
+	public function get_meta_table_fields($all = FALSE) {
232 232
 		$all_fields = $fields_to_return = array();
233
-		foreach ( $this->_tables as $alias => $table_obj ) {
234
-			if ( $table_obj instanceof EE_Secondary_Table )
235
-				$all_fields = array_merge( $this->_get_fields_for_table($alias), $all_fields );
233
+		foreach ($this->_tables as $alias => $table_obj) {
234
+			if ($table_obj instanceof EE_Secondary_Table)
235
+				$all_fields = array_merge($this->_get_fields_for_table($alias), $all_fields);
236 236
 		}
237 237
 
238
-		if ( !$all ) {
239
-			foreach ( $all_fields as $name => $obj ) {
240
-				if ( $obj instanceof EE_DB_Only_Field_Base )
238
+		if ( ! $all) {
239
+			foreach ($all_fields as $name => $obj) {
240
+				if ($obj instanceof EE_DB_Only_Field_Base)
241 241
 					continue;
242 242
 				$fields_to_return[] = $name;
243 243
 			}
@@ -260,13 +260,13 @@  discard block
 block discarded – undo
260 260
 	 * @param int $parent_term_taxonomy_id
261 261
 	 * @return EE_Term_Taxonomy
262 262
 	 */
263
-	function add_event_category(EE_CPT_Base $cpt_model_object, $category_name, $category_description ='',$parent_term_taxonomy_id = null){
263
+	function add_event_category(EE_CPT_Base $cpt_model_object, $category_name, $category_description = '', $parent_term_taxonomy_id = null) {
264 264
 		//create term
265
-		require_once( EE_MODELS . 'EEM_Term.model.php');
265
+		require_once(EE_MODELS.'EEM_Term.model.php');
266 266
 		//first, check for a term by the same name or slug
267 267
 		$category_slug = sanitize_title($category_name);
268
-		$term = EEM_Term::instance()->get_one(array(array('OR'=>array('name'=>$category_name,'slug'=>$category_slug))));
269
-		if( ! $term ){
268
+		$term = EEM_Term::instance()->get_one(array(array('OR'=>array('name'=>$category_name, 'slug'=>$category_slug))));
269
+		if ( ! $term) {
270 270
 			$term = EE_Term::new_instance(array(
271 271
 				'name'=>$category_name,
272 272
 				'slug'=>$category_slug
@@ -274,10 +274,10 @@  discard block
 block discarded – undo
274 274
 			$term->save();
275 275
 		}
276 276
 		//make sure there's a term-taxonomy entry too
277
-		require_once( EE_MODELS . 'EEM_Term_Taxonomy.model.php');
278
-		$term_taxonomy = EEM_Term_Taxonomy::instance()->get_one(array(array('term_id'=>$term->ID(),'taxonomy'=>EE_Event_Category_Taxonomy)));
277
+		require_once(EE_MODELS.'EEM_Term_Taxonomy.model.php');
278
+		$term_taxonomy = EEM_Term_Taxonomy::instance()->get_one(array(array('term_id'=>$term->ID(), 'taxonomy'=>EE_Event_Category_Taxonomy)));
279 279
 		/** @var $term_taxonomy EE_Term_Taxonomy */
280
-		if( ! $term_taxonomy ){
280
+		if ( ! $term_taxonomy) {
281 281
 			$term_taxonomy = EE_Term_Taxonomy::new_instance(array(
282 282
 				'term_id'=>$term->ID(),
283 283
 				'taxonomy'=>EE_Event_Category_Taxonomy,
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 				'parent'=>$parent_term_taxonomy_id
287 287
 			));
288 288
 			$term_taxonomy->save();
289
-		}else{
289
+		} else {
290 290
 			$term_taxonomy->set_count($term_taxonomy->count() + 1);
291 291
 			$term_taxonomy->save();
292 292
 		}
@@ -301,11 +301,11 @@  discard block
 block discarded – undo
301 301
 	 * @param string $category_name name of the event category (term)
302 302
 	 * @return bool
303 303
 	 */
304
-	function remove_event_category(EE_CPT_Base $cpt_model_object_event, $category_name){
304
+	function remove_event_category(EE_CPT_Base $cpt_model_object_event, $category_name) {
305 305
 		//find the term_taxonomy by that name
306
-		$term_taxonomy = $this->get_first_related($cpt_model_object_event, 'Term_Taxonomy', array(array('Term.name'=>$category_name,'taxonomy'=>EE_Event_Category_Taxonomy)));
306
+		$term_taxonomy = $this->get_first_related($cpt_model_object_event, 'Term_Taxonomy', array(array('Term.name'=>$category_name, 'taxonomy'=>EE_Event_Category_Taxonomy)));
307 307
 		/** @var $term_taxonomy EE_Term_Taxonomy */
308
-		if( $term_taxonomy ){
308
+		if ($term_taxonomy) {
309 309
 			$term_taxonomy->set_count($term_taxonomy->count() - 1);
310 310
 			$term_taxonomy->save();
311 311
 		}
@@ -325,8 +325,8 @@  discard block
 block discarded – undo
325 325
 	 * @param string|array $attr Optional. Query string or array of attributes.
326 326
 	 * @return string HTML image element
327 327
 	 */
328
-	public function get_feature_image( $id, $size = 'thumbnail', $attr = '' ) {
329
-		return get_the_post_thumbnail( $id, $size, $attr );
328
+	public function get_feature_image($id, $size = 'thumbnail', $attr = '') {
329
+		return get_the_post_thumbnail($id, $size, $attr);
330 330
 	}
331 331
 
332 332
 
@@ -339,10 +339,10 @@  discard block
 block discarded – undo
339 339
 	 * @global array $wp_post_statuses set in wp core for storing all the post stati
340 340
 	 * @return array
341 341
 	 */
342
-	public function get_post_statuses(){
342
+	public function get_post_statuses() {
343 343
 		global $wp_post_statuses;
344 344
 		$statuses = array();
345
-		foreach($wp_post_statuses as $post_status => $args_object){
345
+		foreach ($wp_post_statuses as $post_status => $args_object) {
346 346
 			$statuses[$post_status] = $args_object->label;
347 347
 		}
348 348
 		return $statuses;
@@ -357,9 +357,9 @@  discard block
 block discarded – undo
357 357
 	public function get_status_array() {
358 358
 		$statuses = $this->get_post_statuses();
359 359
 		//first the global filter
360
-		$statuses = apply_filters( 'FHEE_EEM_CPT_Base__get_status_array', $statuses );
360
+		$statuses = apply_filters('FHEE_EEM_CPT_Base__get_status_array', $statuses);
361 361
 		//now the class specific filter
362
-		$statuses = apply_filters( 'FHEE_EEM_' . get_class($this) . '__get_status_array', $statuses );
362
+		$statuses = apply_filters('FHEE_EEM_'.get_class($this).'__get_status_array', $statuses);
363 363
 		return $statuses;
364 364
 	}
365 365
 
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
 	 */
372 372
 	public function get_custom_post_statuses() {
373 373
 		$new_stati = array();
374
-		foreach ( $this->_custom_stati as $status => $props ) {
374
+		foreach ($this->_custom_stati as $status => $props) {
375 375
 			$new_stati[$status] = $props['label'];
376 376
 		}
377 377
 		return $new_stati;
@@ -387,24 +387,24 @@  discard block
 block discarded – undo
387 387
 	 * @param WP_Post|array $post
388 388
 	 * @return EE_CPT_Base
389 389
 	 */
390
-	public function instantiate_class_from_post_object_orig($post){
391
-		$post = (array)$post;
390
+	public function instantiate_class_from_post_object_orig($post) {
391
+		$post = (array) $post;
392 392
 		$has_all_necessary_fields_for_table = true;
393 393
 		//check if the post has fields on the meta table already
394
-		foreach($this->_get_other_tables() as $table_obj){
394
+		foreach ($this->_get_other_tables() as $table_obj) {
395 395
 			$fields_for_that_table = $this->_get_fields_for_table($table_obj->get_table_alias());
396
-			foreach($fields_for_that_table as $field_obj){
397
-				if( ! isset($post[$field_obj->get_table_column()])
398
-					&& ! isset($post[$field_obj->get_qualified_column()])){
396
+			foreach ($fields_for_that_table as $field_obj) {
397
+				if ( ! isset($post[$field_obj->get_table_column()])
398
+					&& ! isset($post[$field_obj->get_qualified_column()])) {
399 399
 					$has_all_necessary_fields_for_table = false;
400 400
 				}
401 401
 			}
402 402
 		}
403 403
 		//if we don't have all the fields we need, then just fetch the proper model from the DB
404
-		if( ! $has_all_necessary_fields_for_table){
404
+		if ( ! $has_all_necessary_fields_for_table) {
405 405
 
406 406
 			return $this->get_one_by_ID($post['ID']);
407
-		}else{
407
+		} else {
408 408
 			return $this->instantiate_class_from_array_or_object($post);
409 409
 		}
410 410
 	}
@@ -415,30 +415,30 @@  discard block
 block discarded – undo
415 415
 	 * @param null $post
416 416
 	 * @return EE_Base_Class|EE_Soft_Delete_Base_Class
417 417
 	 */
418
-	public function instantiate_class_from_post_object( $post = NULL ){
419
-		if ( empty( $post )) {
418
+	public function instantiate_class_from_post_object($post = NULL) {
419
+		if (empty($post)) {
420 420
 			global $post;
421 421
 		}
422
-		$post = (array)$post;
422
+		$post = (array) $post;
423 423
 		$tables_needing_to_be_queried = array();
424 424
 		//check if the post has fields on the meta table already
425
-		foreach($this->get_tables() as $table_obj){
425
+		foreach ($this->get_tables() as $table_obj) {
426 426
 			$fields_for_that_table = $this->_get_fields_for_table($table_obj->get_table_alias());
427
-			foreach($fields_for_that_table as $field_obj){
428
-				if( ! isset($post[$field_obj->get_table_column()])
429
-					&& ! isset($post[$field_obj->get_qualified_column()])){
427
+			foreach ($fields_for_that_table as $field_obj) {
428
+				if ( ! isset($post[$field_obj->get_table_column()])
429
+					&& ! isset($post[$field_obj->get_qualified_column()])) {
430 430
 					$tables_needing_to_be_queried[$table_obj->get_table_alias()] = $table_obj;
431 431
 				}
432 432
 			}
433 433
 		}
434 434
 		//if we don't have all the fields we need, then just fetch the proper model from the DB
435
-		if( $tables_needing_to_be_queried){
436
-			if(count($tables_needing_to_be_queried) == 1 && reset($tables_needing_to_be_queried) instanceof EE_Secondary_Table){
435
+		if ($tables_needing_to_be_queried) {
436
+			if (count($tables_needing_to_be_queried) == 1 && reset($tables_needing_to_be_queried) instanceof EE_Secondary_Table) {
437 437
 				//so we're only missing data from a secondary table. Well that's not too hard to query for
438 438
 				$table_to_query = reset($tables_needing_to_be_queried);
439
-				$missing_data = $this->_do_wpdb_query( 'get_row', array( 'SELECT * FROM ' . $table_to_query->get_table_name() . ' WHERE ' . $table_to_query->get_fk_on_table() . ' = ' . $post['ID'], ARRAY_A ));
440
-				if ( ! empty( $missing_data )) {
441
-					$post = array_merge( $post, $missing_data );
439
+				$missing_data = $this->_do_wpdb_query('get_row', array('SELECT * FROM '.$table_to_query->get_table_name().' WHERE '.$table_to_query->get_fk_on_table().' = '.$post['ID'], ARRAY_A));
440
+				if ( ! empty($missing_data)) {
441
+					$post = array_merge($post, $missing_data);
442 442
 				}
443 443
 			} else {
444 444
 				return $this->get_one_by_ID($post['ID']);
@@ -455,15 +455,15 @@  discard block
 block discarded – undo
455 455
 	 * @throws EE_Error
456 456
 	 * @return string
457 457
 	 */
458
-	public function post_type(){
458
+	public function post_type() {
459 459
 		$post_type_field = NULL;
460
-		foreach($this->field_settings(true) as $field_obj){
461
-			if($field_obj instanceof EE_WP_Post_Type_Field){
462
-				$post_type_field = $field_obj;break;
460
+		foreach ($this->field_settings(true) as $field_obj) {
461
+			if ($field_obj instanceof EE_WP_Post_Type_Field) {
462
+				$post_type_field = $field_obj; break;
463 463
 			}
464 464
 		}
465
-		if($post_type_field == NULL){
466
-			throw new EE_Error(sprintf(__("CPT Model %s should have a field of type EE_WP_Post_Type, but doesnt", "event_espresso"),get_class($this)));
465
+		if ($post_type_field == NULL) {
466
+			throw new EE_Error(sprintf(__("CPT Model %s should have a field of type EE_WP_Post_Type, but doesnt", "event_espresso"), get_class($this)));
467 467
 		}
468 468
 		return $post_type_field->get_default_value();
469 469
 	}
Please login to merge, or discard this patch.
core/libraries/messages/EE_message_type.lib.php 1 patch
Spacing   +101 added lines, -101 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!defined('EVENT_ESPRESSO_VERSION') )
2
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
3 3
 	exit('NO direct script access allowed');
4 4
 
5 5
 /**
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 	 * @param  bool   $preview indicate whether a preview is being generated or not.
272 272
 	 * @return void
273 273
 	 */
274
-	public function set_messages($data, EE_messenger $active_messenger, $context = '', $preview = FALSE ) {
274
+	public function set_messages($data, EE_messenger $active_messenger, $context = '', $preview = FALSE) {
275 275
 
276 276
 		$this->_active_messenger = $active_messenger;
277 277
 
@@ -280,10 +280,10 @@  discard block
 block discarded – undo
280 280
 
281 281
 		//this is a special method that allows child message types to trigger an exit from generating messages early (in cases where there may be a delay on send).
282 282
 		$exit = $this->_trigger_exit();
283
-		if ( $exit && ! $this->_preview ) return FALSE;
283
+		if ($exit && ! $this->_preview) return FALSE;
284 284
 
285 285
 		//todo: need to move require into registration hook but for now we'll require here.
286
-		EE_Registry::instance()->load_helper( 'Parse_Shortcodes' );
286
+		EE_Registry::instance()->load_helper('Parse_Shortcodes');
287 287
 		//get shortcode_replace instance- set when _get_messages is called in child...
288 288
 		$this->_shortcode_replace = new EEH_Parse_Shortcodes();
289 289
 
@@ -294,9 +294,9 @@  discard block
 block discarded – undo
294 294
 		$this->_data_handler = ! $this->_preview ? $this->_data_handler : 'Preview';
295 295
 
296 296
 		//if there is an incoming context then this is a preview so let's ONLY show the given context!
297
-		if ( !empty( $context ) ) {
298
-			$cntxt = ! empty( $this->_contexts[$context] ) ? $this->_contexts[$context] : '';
299
-			if ( ! empty( $cntxt )  ) {
297
+		if ( ! empty($context)) {
298
+			$cntxt = ! empty($this->_contexts[$context]) ? $this->_contexts[$context] : '';
299
+			if ( ! empty($cntxt)) {
300 300
 				$this->_contexts = array();
301 301
 				$this->_contexts[$context] = $cntxt;
302 302
 			}
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
 		$exit = $this->_init_data();
306 306
 
307 307
 		//final check for if we exit or not cause child objects may have run conditionals that cleared out data so no addresees generated.
308
-		if ( $exit ) return FALSE;
308
+		if ($exit) return FALSE;
309 309
 
310 310
 		$this->_get_templates(); //get the templates that have been set with this type and for the given messenger that have been saved in the database.
311 311
 		$this->_assemble_messages();
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
 	 * @param int      $id 		Optional. Integer corresponding to the value for the primary key of a EE_Base_Class_Object
342 342
 	 * @return mixed ( EE_Base_Class||EE_Base_Class[] )
343 343
 	 */
344
-	abstract protected function _get_data_for_context( $context, EE_Registration $registration, $id );
344
+	abstract protected function _get_data_for_context($context, EE_Registration $registration, $id);
345 345
 
346 346
 
347 347
 
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
 	 *
374 374
 	 * @return int
375 375
 	 */
376
-	protected function _get_id_for_msg_url( $context, EE_Registration $registration ) {
376
+	protected function _get_id_for_msg_url($context, EE_Registration $registration) {
377 377
 		return 0;
378 378
 	}
379 379
 
@@ -406,28 +406,28 @@  discard block
 block discarded – undo
406 406
 	 *
407 407
 	 * @return string          generated url
408 408
 	 */
409
-	public function get_url_trigger( $context, $sending_messenger, EE_Registration $registration ) {
409
+	public function get_url_trigger($context, $sending_messenger, EE_Registration $registration) {
410 410
 
411 411
 		//validate context
412 412
 		//valid context?
413
-		if ( !isset( $this->_contexts[$context] ) ) {
414
-			throw new EE_Error( sprintf( __('The context %s is not a valid context for %s.', 'event_espresso'), $context, get_class( $this ) ) );
413
+		if ( ! isset($this->_contexts[$context])) {
414
+			throw new EE_Error(sprintf(__('The context %s is not a valid context for %s.', 'event_espresso'), $context, get_class($this)));
415 415
 		}
416 416
 
417 417
 		//valid sending_messenger?
418 418
 		$not_valid_msgr = FALSE;
419
-		foreach ( $this->_with_messengers as $generating => $sendings ) {
420
-			if ( empty( $sendings ) || array_search( $sending_messenger, $sendings ) === FALSE ) {
419
+		foreach ($this->_with_messengers as $generating => $sendings) {
420
+			if (empty($sendings) || array_search($sending_messenger, $sendings) === FALSE) {
421 421
 				$not_valid_msgr = TRUE;
422 422
 			}
423 423
 		}
424 424
 
425
-		if ( $not_valid_msgr ) {
426
-			throw new EE_Error( sprintf( __('The given sending messenger string (%s) does not match a valid sending messenger with the %s.  If this is incorrect, make sure that the message type has defined this messenger as a sending messenger in its $_with_messengers array.', 'event_espresso'), $sending_messenger, get_class( $this ) ) );
425
+		if ($not_valid_msgr) {
426
+			throw new EE_Error(sprintf(__('The given sending messenger string (%s) does not match a valid sending messenger with the %s.  If this is incorrect, make sure that the message type has defined this messenger as a sending messenger in its $_with_messengers array.', 'event_espresso'), $sending_messenger, get_class($this)));
427 427
 		}
428 428
 
429 429
 		EE_Registry::instance()->load_helper('MSG_Template');
430
-		return EEH_MSG_Template::generate_url_trigger( $sending_messenger, $this->_active_messenger->name, $context, $this->name, $registration, $this->_GRP_ID, $this->_get_id_for_msg_url( $context, $registration ) );
430
+		return EEH_MSG_Template::generate_url_trigger($sending_messenger, $this->_active_messenger->name, $context, $this->name, $registration, $this->_GRP_ID, $this->_get_id_for_msg_url($context, $registration));
431 431
 	}
432 432
 
433 433
 
@@ -448,19 +448,19 @@  discard block
 block discarded – undo
448 448
 	 *
449 449
 	 * @return mixed (EE_Base_Class||EE_Base_Class[])
450 450
 	 */
451
-	public function get_data_for_context( $context, EE_Registration $registration, $id = 0 ) {
451
+	public function get_data_for_context($context, EE_Registration $registration, $id = 0) {
452 452
 		//valid context?
453
-		if ( !isset( $this->_contexts[$context] ) ) {
454
-			throw new EE_Error( sprintf( __('The context %s is not a valid context for %s.', 'event_espresso'), $context, get_class( $this ) ) );
453
+		if ( ! isset($this->_contexts[$context])) {
454
+			throw new EE_Error(sprintf(__('The context %s is not a valid context for %s.', 'event_espresso'), $context, get_class($this)));
455 455
 		}
456 456
 
457 457
 		//get data and apply global and class specific filters on it.
458
-		$data = apply_filters( 'FHEE__EE_message_type__get_data_for_context__data', $this->_get_data_for_context( $context, $registration, $id ), $this );
459
-		$data = apply_filters( 'FHEE__' . get_class( $this ) . '__get_data_for_context__data', $data, $this );
458
+		$data = apply_filters('FHEE__EE_message_type__get_data_for_context__data', $this->_get_data_for_context($context, $registration, $id), $this);
459
+		$data = apply_filters('FHEE__'.get_class($this).'__get_data_for_context__data', $data, $this);
460 460
 
461 461
 		//if empty then something went wrong!
462
-		if ( empty( $data ) ) {
463
-			throw new EE_Error( sprintf(  __('There is no data retrieved, it is possible that the id given (%d) does not match any value in the database for the corresponding EE_Base_Class used by the data handler for the %s message type.', 'event_espresso'), $id, $this->name ) );
462
+		if (empty($data)) {
463
+			throw new EE_Error(sprintf(__('There is no data retrieved, it is possible that the id given (%d) does not match any value in the database for the corresponding EE_Base_Class used by the data handler for the %s message type.', 'event_espresso'), $id, $this->name));
464 464
 		}
465 465
 
466 466
 		return $data;
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
 	 */
496 496
 	public function with_messengers() {
497 497
 
498
-		return apply_filters( 'FHEE__EE_message_type__get_with_messengers__with_messengers__' . get_class( $this ), $this->_with_messengers);
498
+		return apply_filters('FHEE__EE_message_type__get_with_messengers__with_messengers__'.get_class($this), $this->_with_messengers);
499 499
 	}
500 500
 
501 501
 
@@ -513,9 +513,9 @@  discard block
 block discarded – undo
513 513
 	 * @access public
514 514
 	 * @return void
515 515
 	 */
516
-	public function get_message_type_admin_page_content($page, $action = NULL, $extra = array(), $messengers = array() ) {
516
+	public function get_message_type_admin_page_content($page, $action = NULL, $extra = array(), $messengers = array()) {
517 517
 		//we can also further refine the context by action (if present).
518
-		return $this->_get_admin_page_content( $page, $action, $extra, $messengers );
518
+		return $this->_get_admin_page_content($page, $action, $extra, $messengers);
519 519
 	}
520 520
 
521 521
 
@@ -559,8 +559,8 @@  discard block
 block discarded – undo
559 559
 	 */
560 560
 	public function get_master_templates() {
561 561
 		//first class specific filter then filter that by the global filter.
562
-		$master_templates = apply_filters( 'FHEE__' . get_class( $this ) . '__get_master_templates', $this->_master_templates );
563
-		return apply_filters( 'FHEE__EE_message_type__get_master_templates', $master_templates, $this );
562
+		$master_templates = apply_filters('FHEE__'.get_class($this).'__get_master_templates', $this->_master_templates);
563
+		return apply_filters('FHEE__EE_message_type__get_master_templates', $master_templates, $this);
564 564
 	}
565 565
 
566 566
 
@@ -579,31 +579,31 @@  discard block
 block discarded – undo
579 579
 		/**
580 580
 		 * first let's make sure that incoming data isn't empty!
581 581
 		 */
582
-		if ( is_array($this->_data) && empty($this->_data) && !$this->_preview ) {
583
-			$msg = sprintf( __( '"%s" message type incoming data is empty.  There is nothing to work with so why are you bugging me?', 'event_espresso'), $this->label['singular'] );
584
-			throw new EE_Error( $msg );
582
+		if (is_array($this->_data) && empty($this->_data) && ! $this->_preview) {
583
+			$msg = sprintf(__('"%s" message type incoming data is empty.  There is nothing to work with so why are you bugging me?', 'event_espresso'), $this->label['singular']);
584
+			throw new EE_Error($msg);
585 585
 		}
586 586
 
587
-		if ( empty( $this->_data_handler) ) {
588
-			$msg = sprintf( __('Hey %s hasn\'t declared a handler for the incoming data, so I\'m stuck', 'event_espresso'), __CLASS__ );
589
-			throw new EE_Error( $msg );
587
+		if (empty($this->_data_handler)) {
588
+			$msg = sprintf(__('Hey %s hasn\'t declared a handler for the incoming data, so I\'m stuck', 'event_espresso'), __CLASS__);
589
+			throw new EE_Error($msg);
590 590
 		}
591 591
 
592 592
 
593 593
 		//setup class name for the data handler
594
-		$classname = 'EE_Messages_' . $this->_data_handler . '_incoming_data';
594
+		$classname = 'EE_Messages_'.$this->_data_handler.'_incoming_data';
595 595
 
596 596
 		//check that the class exists
597
-		if ( !class_exists( $classname ) ) {
597
+		if ( ! class_exists($classname)) {
598 598
 
599 599
 			$msg[] = __('uhoh, Something went wrong and no data handler is found', 'event_espresso');
600
-			$msg[] = sprintf( __('The %s class has set the "$_data_handler" property but the string included (%s) does not match any existing "EE_Messages_incoming_data" classes (found in "/includes/core/messages/data_class").  Looking for %s.', 'event_espresso'), __CLASS__, $this->_data_handler, $classname );
601
-			throw new EE_error( implode('||', $msg) );
600
+			$msg[] = sprintf(__('The %s class has set the "$_data_handler" property but the string included (%s) does not match any existing "EE_Messages_incoming_data" classes (found in "/includes/core/messages/data_class").  Looking for %s.', 'event_espresso'), __CLASS__, $this->_data_handler, $classname);
601
+			throw new EE_error(implode('||', $msg));
602 602
 		}
603 603
 
604 604
 		//k lets get the prepared data object and replace existing data property with it.
605
-		$a = new ReflectionClass( $classname );
606
-		$this->_data = $a->newInstance( $this->_data );
605
+		$a = new ReflectionClass($classname);
606
+		$this->_data = $a->newInstance($this->_data);
607 607
 
608 608
 		$this->_set_default_addressee_data();
609 609
 		return $this->_process_data();
@@ -619,15 +619,15 @@  discard block
 block discarded – undo
619 619
 	protected function _process_data() {
620 620
 		//at a minimum, we NEED EE_Attendee objects.
621 621
 
622
-		if ( empty( $this->_data->attendees ) )
623
-			return TRUE;  //EXIT!
622
+		if (empty($this->_data->attendees))
623
+			return TRUE; //EXIT!
624 624
 
625 625
 		//process addressees for each context.  Child classes will have to have methods for each context defined to handle the processing of the data object within them
626
-		foreach ( $this->_contexts as $context => $details ) {
627
-			$xpctd_method = '_' . $context . '_addressees';
628
-			if ( !method_exists( $this, $xpctd_method ) )
629
-				throw new EE_Error( sprintf( __('The data for %1$s message type cannot be prepared because there is no set method for doing so.  The expected method name is "%2$s" please doublecheck the %1$s message type class and make sure that method is present', 'event_espresso'), $this->label['singular'], $xpctd_method) );
630
-			 $this->_addressees[$context] = call_user_func( array( $this, $xpctd_method ) );
626
+		foreach ($this->_contexts as $context => $details) {
627
+			$xpctd_method = '_'.$context.'_addressees';
628
+			if ( ! method_exists($this, $xpctd_method))
629
+				throw new EE_Error(sprintf(__('The data for %1$s message type cannot be prepared because there is no set method for doing so.  The expected method name is "%2$s" please doublecheck the %1$s message type class and make sure that method is present', 'event_espresso'), $this->label['singular'], $xpctd_method));
630
+			 $this->_addressees[$context] = call_user_func(array($this, $xpctd_method));
631 631
 		}
632 632
 		return FALSE; //DON'T EXIT
633 633
 	}
@@ -662,8 +662,8 @@  discard block
 block discarded – undo
662 662
 			'total_ticket_count' => $this->_data->total_ticket_count
663 663
 			);
664 664
 
665
-		if ( is_array( $this->_data->primary_attendee_data ) ) {
666
-			$this->_default_addressee_data = array_merge( $this->_default_addressee_data, $this->_data->primary_attendee_data );
665
+		if (is_array($this->_data->primary_attendee_data)) {
666
+			$this->_default_addressee_data = array_merge($this->_default_addressee_data, $this->_data->primary_attendee_data);
667 667
 			$this->_default_addressee_data['primary_att_obj'] = $this->_data->primary_attendee_data['att_obj'];
668 668
 			$this->_default_addressee_data['primary_reg_obj'] = $this->_data->primary_attendee_data['reg_obj'];
669 669
 		}
@@ -681,26 +681,26 @@  discard block
 block discarded – undo
681 681
 	 * see abstract declaration in parent class for details, children message types can override these valid shortcodes if desired (we include all for all contexts by default).
682 682
 	 */
683 683
 	protected function _set_valid_shortcodes() {
684
-		$all_shortcodes = array( 'attendee_list', 'attendee', 'datetime_list', 'datetime', 'event_list', 'event_meta', 'event', 'organization', 'recipient_details', 'recipient_list', 'ticket_list', 'ticket', 'transaction', 'venue', 'primary_registration_details', 'primary_registration_list', 'event_author', 'email', 'messenger' );
684
+		$all_shortcodes = array('attendee_list', 'attendee', 'datetime_list', 'datetime', 'event_list', 'event_meta', 'event', 'organization', 'recipient_details', 'recipient_list', 'ticket_list', 'ticket', 'transaction', 'venue', 'primary_registration_details', 'primary_registration_list', 'event_author', 'email', 'messenger');
685 685
 		$contexts = $this->get_contexts();
686
-		foreach ( $contexts as $context => $details ) {
686
+		foreach ($contexts as $context => $details) {
687 687
 			$this->_valid_shortcodes[$context] = $all_shortcodes;
688 688
 
689 689
 			//make sure non admin context does not include the event_author shortcodes
690
-			if ( $context != 'admin' ) {
691
-				if( ($key = array_search('event_author', $this->_valid_shortcodes[$context] ) ) !== false) {
690
+			if ($context != 'admin') {
691
+				if (($key = array_search('event_author', $this->_valid_shortcodes[$context])) !== false) {
692 692
 				    unset($this->_valid_shortcodes[$context][$key]);
693 693
 				}
694 694
 			}
695 695
 		}
696 696
 
697 697
 		//make sure admin context does not include the recipient_details shortcodes IF we have admin context hooked in message types might not have that context.
698
-		if ( !empty( $this->_valid_shortcodes['admin'] ) ) {
699
-			if( ($key = array_search('recipient_details', $this->_valid_shortcodes['admin'] ) ) !== false) {
698
+		if ( ! empty($this->_valid_shortcodes['admin'])) {
699
+			if (($key = array_search('recipient_details', $this->_valid_shortcodes['admin'])) !== false) {
700 700
 				    unset($this->_valid_shortcodes['admin'][$key]);
701 701
 				}
702 702
 			//make sure admin context does not include the recipient_details shortcodes
703
-			if( ($key = array_search('recipient_list', $this->_valid_shortcodes['admin'] ) ) !== false) {
703
+			if (($key = array_search('recipient_list', $this->_valid_shortcodes['admin'])) !== false) {
704 704
 				    unset($this->_valid_shortcodes['admin'][$key]);
705 705
 				}
706 706
 		}
@@ -713,8 +713,8 @@  discard block
 block discarded – undo
713 713
 	 * @param  array  $new_config array of valid shortcodes (by context)
714 714
 	 * @return void               sets valid_shortcodes property
715 715
 	 */
716
-	public function reset_valid_shortcodes_config( $new_config ) {
717
-		foreach ( $new_config as $context => $shortcodes ) {
716
+	public function reset_valid_shortcodes_config($new_config) {
717
+		foreach ($new_config as $context => $shortcodes) {
718 718
 			$this->_valid_shortcodes[$context] = $shortcodes;
719 719
 		}
720 720
 	}
@@ -734,7 +734,7 @@  discard block
 block discarded – undo
734 734
 		$addressees = array();
735 735
 
736 736
 		//first we need to get the event admin user id for all the events and setup an addressee object for each unique admin user.
737
-		foreach ( $this->_data->events as $line_ref => $event ) {
737
+		foreach ($this->_data->events as $line_ref => $event) {
738 738
 			$admin_id = $this->_get_event_admin_id($event['ID']);
739 739
 			//get the user_id for the event
740 740
 			$admin_ids[] = $admin_id;
@@ -746,14 +746,14 @@  discard block
 block discarded – undo
746 746
 		$admin_ids = array_unique($admin_ids);
747 747
 
748 748
 		//k now we can loop through the event_admins and setup the addressee data.
749
-		foreach ( $admin_ids as $event_admin ) {
749
+		foreach ($admin_ids as $event_admin) {
750 750
 			$aee = array(
751 751
 				'user_id' => $event_admin,
752 752
 				'events' => $admin_events[$event_admin],
753 753
 				'attendees' => $this->_data->attendees
754 754
 				);
755
-			$aee = array_merge( $this->_default_addressee_data, $aee );
756
-			$addressees[] = new EE_Messages_Addressee( $aee );
755
+			$aee = array_merge($this->_default_addressee_data, $aee);
756
+			$addressees[] = new EE_Messages_Addressee($aee);
757 757
 		}
758 758
 
759 759
 		return $addressees;
@@ -773,7 +773,7 @@  discard block
 block discarded – undo
773 773
 		$aee['attendees'] = $this->_data->attendees;
774 774
 
775 775
 		//great now we can instantiate the $addressee object and return (as an array);
776
-		$add[] = new EE_Messages_Addressee( $aee );
776
+		$add[] = new EE_Messages_Addressee($aee);
777 777
 		return $add;
778 778
 	}
779 779
 
@@ -792,34 +792,34 @@  discard block
 block discarded – undo
792 792
 		//use to verify unique attendee emails... we don't want to sent multiple copies to the same attendee do we?
793 793
 		$already_processed = array();
794 794
 
795
-		foreach ( $this->_data->attendees as $att_id => $details ) {
795
+		foreach ($this->_data->attendees as $att_id => $details) {
796 796
 			//set the attendee array to blank on each loop;
797 797
 			$aee = array();
798 798
 
799
-			if ( isset( $this->_data->reg_obj ) && ( $this->_data->reg_obj->attendee_ID() != $att_id ) && $this->_single_message ) continue;
799
+			if (isset($this->_data->reg_obj) && ($this->_data->reg_obj->attendee_ID() != $att_id) && $this->_single_message) continue;
800 800
 
801 801
 			//is $this->_regs_for_sending present?  If so, let's make sure we ONLY generate addressee for registrations in that array.
802
-			if ( ! empty( $this->_regs_for_sending ) && is_array( $this->_regs_for_sending ) ) {
803
-				$regs_allowed = array_intersect_key( array_flip( $this->_regs_for_sending ), $details['reg_objs'] );
804
-				if ( empty( $regs_allowed ) ) {
802
+			if ( ! empty($this->_regs_for_sending) && is_array($this->_regs_for_sending)) {
803
+				$regs_allowed = array_intersect_key(array_flip($this->_regs_for_sending), $details['reg_objs']);
804
+				if (empty($regs_allowed)) {
805 805
 					continue;
806 806
 				}
807 807
 			}
808 808
 
809
-			if ( in_array( $details['attendee_email'], $already_processed ) )
809
+			if (in_array($details['attendee_email'], $already_processed))
810 810
 				continue;
811 811
 
812 812
 			$already_processed[] = $details['attendee_email'];
813 813
 
814
-			foreach ( $details as $item => $value ) {
814
+			foreach ($details as $item => $value) {
815 815
 				$aee[$item] = $value;
816
-				if ( $item == 'line_ref' ) {
817
-					foreach ( $value as $event_id ) {
816
+				if ($item == 'line_ref') {
817
+					foreach ($value as $event_id) {
818 818
 						$aee['events'][$event_id] = $this->_data->events[$event_id];
819 819
 					}
820 820
 				}
821 821
 
822
-				if ( $item == 'attendee_email' ) {
822
+				if ($item == 'attendee_email') {
823 823
 					$aee['attendee_email'] = $value;
824 824
 				}
825 825
 
@@ -834,8 +834,8 @@  discard block
 block discarded – undo
834 834
 			$aee['attendees'] = $this->_data->attendees;
835 835
 
836 836
 			//merge in the primary attendee data
837
-			$aee = array_merge( $this->_default_addressee_data, $aee );
838
-			$add[] = new EE_Messages_Addressee( $aee );
837
+			$aee = array_merge($this->_default_addressee_data, $aee);
838
+			$add[] = new EE_Messages_Addressee($aee);
839 839
 		}
840 840
 
841 841
 		return $add;
@@ -860,46 +860,46 @@  discard block
 block discarded – undo
860 860
 		);
861 861
 
862 862
 		//in vanilla EE we're assuming there's only one event.  However, if there are multiple events then we'll just use the default templates instead of different templates per event (which could create problems).
863
-		if ( count($this->_data->events) === 1 ) {
864
-			foreach ( $this->_data->events as $event ) {
863
+		if (count($this->_data->events) === 1) {
864
+			foreach ($this->_data->events as $event) {
865 865
 				$EVT_ID = $event['ID'];
866 866
 			}
867 867
 		}
868 868
 		// is there a Group ID in the incoming request?
869
-		EE_Registry::instance()->load_core( 'Request_Handler' );
869
+		EE_Registry::instance()->load_core('Request_Handler');
870 870
 		// if not, set a default value of false
871
-		$GRP_ID = EE_Registry::instance()->REQ->get( 'GRP_ID', false );
871
+		$GRP_ID = EE_Registry::instance()->REQ->get('GRP_ID', false);
872 872
 		//if this is a preview then we just get whatever message group is for the preview and skip this part!
873
-		if ( $this->_preview && $GRP_ID ) {
874
-			$mtpg = EEM_Message_Template_Group::instance()->get_one_by_ID( $GRP_ID );
873
+		if ($this->_preview && $GRP_ID) {
874
+			$mtpg = EEM_Message_Template_Group::instance()->get_one_by_ID($GRP_ID);
875 875
 		} else {
876 876
 			//not a preview or test send so lets continue on our way!
877 877
 			//is there an evt_id?  If so let's get that. template.
878
-			if ( !empty( $EVT_ID )  ) {
878
+			if ( ! empty($EVT_ID)) {
879 879
 				$evt_qa = array(
880 880
 					'Event.EVT_ID' => $EVT_ID
881 881
 				);
882
-				$qa = array_merge( $template_qa, $evt_qa );
883
-				$mtpg = EEM_Message_Template_Group::instance()->get_one( array( $qa ) );
882
+				$qa = array_merge($template_qa, $evt_qa);
883
+				$mtpg = EEM_Message_Template_Group::instance()->get_one(array($qa));
884 884
 			}
885 885
 
886 886
 			//is there a 'GRP_ID' ? if so let's get that.
887 887
 
888 888
 			//if global template is NOT an override, and there is a 'GRP_ID' in the request, then we'll assume a specific template has ben requested.
889
-			if ( $GRP_ID ) {
890
-				$mtpg = EEM_Message_Template_Group::instance()->get_one_by_ID( $GRP_ID );
889
+			if ($GRP_ID) {
890
+				$mtpg = EEM_Message_Template_Group::instance()->get_one_by_ID($GRP_ID);
891 891
 			}
892 892
 
893 893
 
894 894
 			$template_qa['MTP_is_global'] = TRUE;
895 895
 
896 896
 			//this gets the current global template (message template group) for the active messenger and message type.
897
-			$global_mtpg = EEM_Message_Template_Group::instance()->get_one( array( $template_qa ) );
897
+			$global_mtpg = EEM_Message_Template_Group::instance()->get_one(array($template_qa));
898 898
 
899
-			$mtpg = $mtpg instanceof EE_Message_Template_Group && ! $global_mtpg->get( 'MTP_is_override' ) ? $mtpg : $global_mtpg;
899
+			$mtpg = $mtpg instanceof EE_Message_Template_Group && ! $global_mtpg->get('MTP_is_override') ? $mtpg : $global_mtpg;
900 900
 		}
901 901
 
902
-		if ( ! $mtpg instanceof EE_Message_Template_Group ) {
902
+		if ( ! $mtpg instanceof EE_Message_Template_Group) {
903 903
 			//get out because we can't process anything, there are no message template groups
904 904
 			// and thus some sort of bad setup issues.
905 905
 			return false;
@@ -915,8 +915,8 @@  discard block
 block discarded – undo
915 915
 
916 916
 
917 917
 
918
-		foreach ( $templates as $context => $template_fields ) {
919
-			foreach( $template_fields as $template_field=> $template_obj ) {
918
+		foreach ($templates as $context => $template_fields) {
919
+			foreach ($template_fields as $template_field=> $template_obj) {
920 920
 				$this->_templates[$template_field][$context] = $template_obj->get('MTP_content');
921 921
 			}
922 922
 		}
@@ -931,11 +931,11 @@  discard block
 block discarded – undo
931 931
 	protected function _assemble_messages() {
932 932
 		//make sure any set messages object is cleared
933 933
 		$this->messages = array();
934
-		foreach ( $this->_addressees as $context => $addressees ) {
935
-			foreach ( $addressees as $addressee ) {
934
+		foreach ($this->_addressees as $context => $addressees) {
935
+			foreach ($addressees as $addressee) {
936 936
 				$message = $this->_setup_message_object($context, $addressee);
937 937
 				//only assign message if everything went okay
938
-				if ( $message ) {
938
+				if ($message) {
939 939
 					$message->template_pack = $this->_template_pack;
940 940
 					$message->variation = $this->_variation;
941 941
 					$this->messages[] = $message;
@@ -959,22 +959,22 @@  discard block
 block discarded – undo
959 959
 		$m_shortcodes = $this->_active_messenger->get_valid_shortcodes();
960 960
 
961 961
 		//if the 'to' field is empty (messages will ALWAYS have a "to" field, then we get out because this context is turned off) EXCEPT if we're previewing
962
-		if ( ( isset( $this->_templates['to'][$context] ) && empty( $this->_templates['to'][$context] ) ) && !$this->_preview )
962
+		if ((isset($this->_templates['to'][$context]) && empty($this->_templates['to'][$context])) && ! $this->_preview)
963 963
 			return false;
964 964
 
965
-		if ( empty( $this->_templates ) ) {
965
+		if (empty($this->_templates)) {
966 966
 			//unable to setup any messages because there are no templates.  Some sort of catastrophic setup
967 967
 			//issue exists
968 968
 			return false;
969 969
 		}
970 970
 
971
-		foreach ( $this->_templates as $field => $ctxt ) {
971
+		foreach ($this->_templates as $field => $ctxt) {
972 972
 			//let's setup the valid shortcodes for the incoming context.
973 973
 			$valid_shortcodes = $mt_shortcodes[$context];
974 974
 			//merge in valid shortcodes for the field.
975 975
 			$shortcodes = isset($m_shortcodes[$field]) ? $m_shortcodes[$field] : $valid_shortcodes;
976
-			if ( isset( $this->_templates[$field][$context] ) ) {
977
-				$message->{$field} = $this->_shortcode_replace->parse_message_template($this->_templates[$field][$context], $addressee, $shortcodes, $this, $this->_active_messenger, $context, $this->_GRP_ID );
976
+			if (isset($this->_templates[$field][$context])) {
977
+				$message->{$field} = $this->_shortcode_replace->parse_message_template($this->_templates[$field][$context], $addressee, $shortcodes, $this, $this->_active_messenger, $context, $this->_GRP_ID);
978 978
 			}
979 979
 		}
980 980
 		return $message;
Please login to merge, or discard this patch.
modules/single_page_checkout/EED_Single_Page_Checkout.module.php 1 patch
Spacing   +269 added lines, -269 removed lines patch added patch discarded remove patch
@@ -38,8 +38,8 @@  discard block
 block discarded – undo
38 38
 	 * @return EED_Single_Page_Checkout
39 39
 	 */
40 40
 	public static function instance() {
41
-		add_filter( 'EED_Single_Page_Checkout__SPCO_active', '__return_true' );
42
-		return parent::get_instance( __CLASS__ );
41
+		add_filter('EED_Single_Page_Checkout__SPCO_active', '__return_true');
42
+		return parent::get_instance(__CLASS__);
43 43
 	}
44 44
 
45 45
 
@@ -84,22 +84,22 @@  discard block
 block discarded – undo
84 84
 	 */
85 85
 	public static function set_hooks_admin() {
86 86
 		EED_Single_Page_Checkout::set_definitions();
87
-		if ( defined( 'DOING_AJAX' )) {
87
+		if (defined('DOING_AJAX')) {
88 88
 			// going to start an output buffer in case anything gets accidentally output that might disrupt our JSON response
89 89
 			ob_start();
90 90
 			EED_Single_Page_Checkout::load_request_handler();
91 91
 			EED_Single_Page_Checkout::load_reg_steps();
92 92
 		} else {
93 93
 			// hook into the top of pre_get_posts to set the reg step routing, which gives other modules or plugins a chance to modify the reg steps, but just before the routes get called
94
-			add_action( 'pre_get_posts', array( 'EED_Single_Page_Checkout', 'load_reg_steps' ), 1 );
94
+			add_action('pre_get_posts', array('EED_Single_Page_Checkout', 'load_reg_steps'), 1);
95 95
 		}
96 96
 		// set ajax hooks
97
-		add_action( 'wp_ajax_process_reg_step', array( 'EED_Single_Page_Checkout', 'process_reg_step' ));
98
-		add_action( 'wp_ajax_nopriv_process_reg_step', array( 'EED_Single_Page_Checkout', 'process_reg_step' ));
99
-		add_action( 'wp_ajax_display_spco_reg_step', array( 'EED_Single_Page_Checkout', 'display_reg_step' ));
100
-		add_action( 'wp_ajax_nopriv_display_spco_reg_step', array( 'EED_Single_Page_Checkout', 'display_reg_step' ));
101
-		add_action( 'wp_ajax_update_reg_step', array( 'EED_Single_Page_Checkout', 'update_reg_step' ));
102
-		add_action( 'wp_ajax_nopriv_update_reg_step', array( 'EED_Single_Page_Checkout', 'update_reg_step' ));
97
+		add_action('wp_ajax_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step'));
98
+		add_action('wp_ajax_nopriv_process_reg_step', array('EED_Single_Page_Checkout', 'process_reg_step'));
99
+		add_action('wp_ajax_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step'));
100
+		add_action('wp_ajax_nopriv_display_spco_reg_step', array('EED_Single_Page_Checkout', 'display_reg_step'));
101
+		add_action('wp_ajax_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step'));
102
+		add_action('wp_ajax_nopriv_update_reg_step', array('EED_Single_Page_Checkout', 'update_reg_step'));
103 103
 	}
104 104
 
105 105
 
@@ -108,8 +108,8 @@  discard block
 block discarded – undo
108 108
 	 * 	process ajax request
109 109
 	 * @param string $ajax_action
110 110
 	 */
111
-	public static function process_ajax_request( $ajax_action ) {
112
-		EE_Registry::instance()->REQ->set( 'action', $ajax_action );
111
+	public static function process_ajax_request($ajax_action) {
112
+		EE_Registry::instance()->REQ->set('action', $ajax_action);
113 113
 		EED_Single_Page_Checkout::instance()->_initialize();
114 114
 	}
115 115
 
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 	 * 	ajax display registration step
120 120
 	 */
121 121
 	public static function display_reg_step() {
122
-		EED_Single_Page_Checkout::process_ajax_request( 'display_spco_reg_step' );
122
+		EED_Single_Page_Checkout::process_ajax_request('display_spco_reg_step');
123 123
 	}
124 124
 
125 125
 
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 	 * 	ajax process registration step
129 129
 	 */
130 130
 	public static function process_reg_step() {
131
-		EED_Single_Page_Checkout::process_ajax_request( 'process_reg_step' );
131
+		EED_Single_Page_Checkout::process_ajax_request('process_reg_step');
132 132
 	}
133 133
 
134 134
 
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 	 * 	ajax process registration step
138 138
 	 */
139 139
 	public static function update_reg_step() {
140
-		EED_Single_Page_Checkout::process_ajax_request( 'update_reg_step' );
140
+		EED_Single_Page_Checkout::process_ajax_request('update_reg_step');
141 141
 	}
142 142
 
143 143
 
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 	 * @return void
150 150
 	 */
151 151
 	public static function update_checkout() {
152
-		EED_Single_Page_Checkout::process_ajax_request( 'update_checkout' );
152
+		EED_Single_Page_Checkout::process_ajax_request('update_checkout');
153 153
 	}
154 154
 
155 155
 
@@ -162,8 +162,8 @@  discard block
 block discarded – undo
162 162
 	 */
163 163
 	public static function load_request_handler() {
164 164
 		// load core Request_Handler class
165
-		if ( ! isset( EE_Registry::instance()->REQ )) {
166
-			EE_Registry::instance()->load_core( 'Request_Handler' );
165
+		if ( ! isset(EE_Registry::instance()->REQ)) {
166
+			EE_Registry::instance()->load_core('Request_Handler');
167 167
 		}
168 168
 	}
169 169
 
@@ -176,14 +176,14 @@  discard block
 block discarded – undo
176 176
 	 *  @return 	void
177 177
 	 */
178 178
 	public static function set_definitions() {
179
-		define( 'SPCO_BASE_PATH', rtrim( str_replace( array( '\\', '/' ), DS, plugin_dir_path( __FILE__ )), DS ) . DS );
180
-		define( 'SPCO_CSS_URL', plugin_dir_url( __FILE__ ) . 'css' . DS );
181
-		define( 'SPCO_IMG_URL', plugin_dir_url( __FILE__ ) . 'img' . DS );
182
-		define( 'SPCO_JS_URL', plugin_dir_url( __FILE__ ) . 'js' . DS );
183
-		define( 'SPCO_INC_PATH', SPCO_BASE_PATH . 'inc' . DS );
184
-		define( 'SPCO_REG_STEPS_PATH', SPCO_BASE_PATH . 'reg_steps' . DS );
185
-		define( 'SPCO_TEMPLATES_PATH', SPCO_BASE_PATH . 'templates' . DS );
186
-		EEH_Autoloader::register_autoloaders_for_each_file_in_folder( SPCO_BASE_PATH, TRUE );
179
+		define('SPCO_BASE_PATH', rtrim(str_replace(array('\\', '/'), DS, plugin_dir_path(__FILE__)), DS).DS);
180
+		define('SPCO_CSS_URL', plugin_dir_url(__FILE__).'css'.DS);
181
+		define('SPCO_IMG_URL', plugin_dir_url(__FILE__).'img'.DS);
182
+		define('SPCO_JS_URL', plugin_dir_url(__FILE__).'js'.DS);
183
+		define('SPCO_INC_PATH', SPCO_BASE_PATH.'inc'.DS);
184
+		define('SPCO_REG_STEPS_PATH', SPCO_BASE_PATH.'reg_steps'.DS);
185
+		define('SPCO_TEMPLATES_PATH', SPCO_BASE_PATH.'templates'.DS);
186
+		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(SPCO_BASE_PATH, TRUE);
187 187
 	}
188 188
 
189 189
 
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 	 */
199 199
 	public static function load_reg_steps() {
200 200
 		static $reg_steps_loaded = FALSE;
201
-		if ( $reg_steps_loaded ) {
201
+		if ($reg_steps_loaded) {
202 202
 			return;
203 203
 		}
204 204
 		// filter list of reg_steps
@@ -207,24 +207,24 @@  discard block
 block discarded – undo
207 207
 			EED_Single_Page_Checkout::get_reg_steps()
208 208
 		);
209 209
 		// sort by key (order)
210
-		ksort( $reg_steps_to_load );
210
+		ksort($reg_steps_to_load);
211 211
 		// loop through folders
212
-		foreach ( $reg_steps_to_load as $order => $reg_step ) {
212
+		foreach ($reg_steps_to_load as $order => $reg_step) {
213 213
 			// we need a
214
-			if ( isset( $reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'] )) {
214
+			if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) {
215 215
 				// copy over to the reg_steps_array
216
-				EED_Single_Page_Checkout::$_reg_steps_array[ $order ] = $reg_step;
216
+				EED_Single_Page_Checkout::$_reg_steps_array[$order] = $reg_step;
217 217
 				// register custom key route for each reg step
218 218
 				// ie: step=>"slug" - this is the entire reason we load the reg steps array now
219
-				EE_Config::register_route( $reg_step['slug'], 'EED_Single_Page_Checkout', 'run', 'step' );
219
+				EE_Config::register_route($reg_step['slug'], 'EED_Single_Page_Checkout', 'run', 'step');
220 220
 				// add AJAX or other hooks
221
-				if ( isset( $reg_step['has_hooks'] ) && $reg_step['has_hooks'] ) {
221
+				if (isset($reg_step['has_hooks']) && $reg_step['has_hooks']) {
222 222
 					// setup autoloaders if necessary
223
-					if ( ! class_exists( $reg_step['class_name'] )) {
224
-						EEH_Autoloader::register_autoloaders_for_each_file_in_folder( $reg_step['file_path'], TRUE );
223
+					if ( ! class_exists($reg_step['class_name'])) {
224
+						EEH_Autoloader::register_autoloaders_for_each_file_in_folder($reg_step['file_path'], TRUE);
225 225
 					}
226
-					if ( is_callable( $reg_step['class_name'], 'set_hooks' )) {
227
-						call_user_func( array( $reg_step['class_name'], 'set_hooks' ));
226
+					if (is_callable($reg_step['class_name'], 'set_hooks')) {
227
+						call_user_func(array($reg_step['class_name'], 'set_hooks'));
228 228
 					}
229 229
 				}
230 230
 			}
@@ -243,28 +243,28 @@  discard block
 block discarded – undo
243 243
 	 */
244 244
 	public static function get_reg_steps() {
245 245
 		$reg_steps = EE_Registry::instance()->CFG->registration->reg_steps;
246
-		if ( empty( $reg_steps )) {
246
+		if (empty($reg_steps)) {
247 247
 			$reg_steps = array(
248 248
 				10 => array(
249
-					'file_path' => SPCO_REG_STEPS_PATH . 'attendee_information',
249
+					'file_path' => SPCO_REG_STEPS_PATH.'attendee_information',
250 250
 					'class_name' => 'EE_SPCO_Reg_Step_Attendee_Information',
251 251
 					'slug' => 'attendee_information',
252 252
 					'has_hooks' => FALSE
253 253
 				),
254 254
 				20 => array(
255
-					'file_path' => SPCO_REG_STEPS_PATH . 'registration_confirmation',
255
+					'file_path' => SPCO_REG_STEPS_PATH.'registration_confirmation',
256 256
 					'class_name' => 'EE_SPCO_Reg_Step_Registration_Confirmation',
257 257
 					'slug' => 'registration_confirmation',
258 258
 					'has_hooks' => FALSE
259 259
 				),
260 260
 				30 => array(
261
-					'file_path' => SPCO_REG_STEPS_PATH . 'payment_options',
261
+					'file_path' => SPCO_REG_STEPS_PATH.'payment_options',
262 262
 					'class_name' => 'EE_SPCO_Reg_Step_Payment_Options',
263 263
 					'slug' => 'payment_options',
264 264
 					'has_hooks' => TRUE
265 265
 				),
266 266
 				999 => array(
267
-					'file_path' => SPCO_REG_STEPS_PATH . 'finalize_registration',
267
+					'file_path' => SPCO_REG_STEPS_PATH.'finalize_registration',
268 268
 					'class_name' => 'EE_SPCO_Reg_Step_Finalize_Registration',
269 269
 					'slug' => 'finalize_registration',
270 270
 					'has_hooks' => FALSE
@@ -284,9 +284,9 @@  discard block
 block discarded – undo
284 284
 	 */
285 285
 	public static function registration_checkout_for_admin() {
286 286
 		EED_Single_Page_Checkout::load_reg_steps();
287
-		EE_Registry::instance()->REQ->set( 'step', 'attendee_information' );
288
-		EE_Registry::instance()->REQ->set( 'action', 'display_spco_reg_step' );
289
-		EE_Registry::instance()->REQ->set( 'process_form_submission', false );
287
+		EE_Registry::instance()->REQ->set('step', 'attendee_information');
288
+		EE_Registry::instance()->REQ->set('action', 'display_spco_reg_step');
289
+		EE_Registry::instance()->REQ->set('process_form_submission', false);
290 290
 		EED_Single_Page_Checkout::instance()->_initialize();
291 291
 		EED_Single_Page_Checkout::instance()->_display_spco_reg_form();
292 292
 		return EE_Registry::instance()->REQ->get_output();
@@ -302,14 +302,14 @@  discard block
 block discarded – undo
302 302
 	 */
303 303
 	public static function process_registration_from_admin() {
304 304
 		EED_Single_Page_Checkout::load_reg_steps();
305
-		EE_Registry::instance()->REQ->set( 'step', 'attendee_information' );
306
-		EE_Registry::instance()->REQ->set( 'action', 'process_reg_step' );
307
-		EE_Registry::instance()->REQ->set( 'process_form_submission', true );
305
+		EE_Registry::instance()->REQ->set('step', 'attendee_information');
306
+		EE_Registry::instance()->REQ->set('action', 'process_reg_step');
307
+		EE_Registry::instance()->REQ->set('process_form_submission', true);
308 308
 		EED_Single_Page_Checkout::instance()->_initialize();
309
-		if ( EED_Single_Page_Checkout::instance()->checkout->current_step->completed() ) {
310
-			$final_reg_step = end( EED_Single_Page_Checkout::instance()->checkout->reg_steps );
311
-			if ( $final_reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration ) {
312
-				if ( $final_reg_step->process_reg_step() ) {
309
+		if (EED_Single_Page_Checkout::instance()->checkout->current_step->completed()) {
310
+			$final_reg_step = end(EED_Single_Page_Checkout::instance()->checkout->reg_steps);
311
+			if ($final_reg_step instanceof EE_SPCO_Reg_Step_Finalize_Registration) {
312
+				if ($final_reg_step->process_reg_step()) {
313 313
 					return EED_Single_Page_Checkout::instance()->checkout->transaction;
314 314
 				}
315 315
 			}
@@ -326,11 +326,11 @@  discard block
 block discarded – undo
326 326
 	 * @param WP_Query $WP_Query
327 327
 	 * @return    void
328 328
 	 */
329
-	public function run( $WP_Query ) {
329
+	public function run($WP_Query) {
330 330
 		if (
331 331
 			$WP_Query instanceof WP_Query
332 332
 			&& $WP_Query->is_main_query()
333
-			&& apply_filters( 'FHEE__EED_Single_Page_Checkout__run', true )
333
+			&& apply_filters('FHEE__EED_Single_Page_Checkout__run', true)
334 334
 		) {
335 335
 			$this->_initialize();
336 336
 		}
@@ -346,8 +346,8 @@  discard block
 block discarded – undo
346 346
 	 * @param WP_Query $WP_Query
347 347
 	 * @return    void
348 348
 	 */
349
-	public static function init( $WP_Query ) {
350
-		EED_Single_Page_Checkout::instance()->run( $WP_Query );
349
+	public static function init($WP_Query) {
350
+		EED_Single_Page_Checkout::instance()->run($WP_Query);
351 351
 	}
352 352
 
353 353
 
@@ -361,35 +361,35 @@  discard block
 block discarded – undo
361 361
 	 */
362 362
 	private function _initialize() {
363 363
 		// ensure SPCO doesn't run twice
364
-		if ( EED_Single_Page_Checkout::$_initialized ) {
364
+		if (EED_Single_Page_Checkout::$_initialized) {
365 365
 			return;
366 366
 		}
367 367
 		// setup the EE_Checkout object
368 368
 		$this->checkout = $this->_initialize_checkout();
369 369
 		// filter checkout
370
-		$this->checkout = apply_filters( 'FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout );
370
+		$this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize__checkout', $this->checkout);
371 371
 		// get the $_GET
372 372
 		$this->_get_request_vars();
373 373
 		// filter continue_reg
374
-		$this->checkout->continue_reg = apply_filters( 'FHEE__EED_Single_Page_Checkout__init___continue_reg', TRUE, $this->checkout );
374
+		$this->checkout->continue_reg = apply_filters('FHEE__EED_Single_Page_Checkout__init___continue_reg', TRUE, $this->checkout);
375 375
 		// load the reg steps array
376
-		if ( ! $this->_load_and_instantiate_reg_steps() ) {
376
+		if ( ! $this->_load_and_instantiate_reg_steps()) {
377 377
 			EED_Single_Page_Checkout::$_initialized = true;
378 378
 			return;
379 379
 		}
380 380
 		// set the current step
381
-		$this->checkout->set_current_step( $this->checkout->step );
381
+		$this->checkout->set_current_step($this->checkout->step);
382 382
 		// and the next step
383 383
 		$this->checkout->set_next_step();
384 384
 		// was there already a valid transaction in the checkout from the session ?
385
-		if ( ! $this->checkout->transaction instanceof EE_Transaction ) {
385
+		if ( ! $this->checkout->transaction instanceof EE_Transaction) {
386 386
 			// get transaction from db or session
387 387
 			$this->checkout->transaction = $this->checkout->reg_url_link && ! is_admin()
388 388
 				? $this->_get_transaction_and_cart_for_previous_visit()
389 389
 				: $this->_get_cart_for_current_session_and_setup_new_transaction();
390
-			if ( ! $this->checkout->transaction instanceof EE_Transaction ) {
390
+			if ( ! $this->checkout->transaction instanceof EE_Transaction) {
391 391
 				EE_Error::add_error(
392
-					__( 'Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso' ),
392
+					__('Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso'),
393 393
 					__FILE__, __FUNCTION__, __LINE__
394 394
 				);
395 395
 				// add some style and make it dance
@@ -399,10 +399,10 @@  discard block
 block discarded – undo
399 399
 				return;
400 400
 			}
401 401
 			// and the registrations for the transaction
402
-			$this->_get_registrations( $this->checkout->transaction );
402
+			$this->_get_registrations($this->checkout->transaction);
403 403
 		}
404 404
 		// verify that everything has been setup correctly
405
-		if ( ! $this->_final_verifications() ) {
405
+		if ( ! $this->_final_verifications()) {
406 406
 			EED_Single_Page_Checkout::$_initialized = true;
407 407
 			return;
408 408
 		}
@@ -427,9 +427,9 @@  discard block
 block discarded – undo
427 427
 		// set no cache headers and constants
428 428
 		EE_System::do_not_cache();
429 429
 		// add anchor
430
-		add_action( 'loop_start', array( $this, 'set_checkout_anchor' ), 1 );
430
+		add_action('loop_start', array($this, 'set_checkout_anchor'), 1);
431 431
 		// remove transaction lock
432
-		add_action( 'shutdown', array( $this, 'unlock_transaction' ), 1 );
432
+		add_action('shutdown', array($this, 'unlock_transaction'), 1);
433 433
 	}
434 434
 
435 435
 
@@ -446,20 +446,20 @@  discard block
 block discarded – undo
446 446
 		// look in session for existing checkout
447 447
 		$checkout = EE_Registry::instance()->SSN->checkout();
448 448
 		// verify
449
-		if ( ! $checkout instanceof EE_Checkout ) {
449
+		if ( ! $checkout instanceof EE_Checkout) {
450 450
 			// instantiate EE_Checkout object for handling the properties of the current checkout process
451
-			$checkout = EE_Registry::instance()->load_file( SPCO_INC_PATH, 'EE_Checkout', 'class', array(), FALSE  );
451
+			$checkout = EE_Registry::instance()->load_file(SPCO_INC_PATH, 'EE_Checkout', 'class', array(), FALSE);
452 452
 			// verify again
453
-			if ( ! $checkout instanceof EE_Checkout ) {
454
-				throw new EE_Error( __( 'The EE_Checkout class could not be loaded.', 'event_espresso' ) );
453
+			if ( ! $checkout instanceof EE_Checkout) {
454
+				throw new EE_Error(__('The EE_Checkout class could not be loaded.', 'event_espresso'));
455 455
 			}
456 456
 		} else {
457
-			if ( $checkout->current_step->is_final_step() && $checkout->exit_spco() === true )  {
458
-				wp_safe_redirect( $checkout->redirect_url );
457
+			if ($checkout->current_step->is_final_step() && $checkout->exit_spco() === true) {
458
+				wp_safe_redirect($checkout->redirect_url);
459 459
 				exit();
460 460
 			}
461 461
 		}
462
-		$checkout = apply_filters( 'FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout );
462
+		$checkout = apply_filters('FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', $checkout);
463 463
 		// reset anything that needs a clean slate for each request
464 464
 		$checkout->reset_for_current_request();
465 465
 		return $checkout;
@@ -477,24 +477,24 @@  discard block
 block discarded – undo
477 477
 		// load classes
478 478
 		EED_Single_Page_Checkout::load_request_handler();
479 479
 		//make sure this request is marked as belonging to EE
480
-		EE_Registry::instance()->REQ->set_espresso_page( TRUE );
480
+		EE_Registry::instance()->REQ->set_espresso_page(TRUE);
481 481
 		// which step is being requested ?
482
-		$this->checkout->step = EE_Registry::instance()->REQ->get( 'step', $this->_get_first_step() );
482
+		$this->checkout->step = EE_Registry::instance()->REQ->get('step', $this->_get_first_step());
483 483
 		// which step is being edited ?
484
-		$this->checkout->edit_step = EE_Registry::instance()->REQ->get( 'edit_step', '' );
484
+		$this->checkout->edit_step = EE_Registry::instance()->REQ->get('edit_step', '');
485 485
 		// and what we're doing on the current step
486
-		$this->checkout->action = EE_Registry::instance()->REQ->get( 'action', 'display_spco_reg_step' );
486
+		$this->checkout->action = EE_Registry::instance()->REQ->get('action', 'display_spco_reg_step');
487 487
 		// returning to edit ?
488
-		$this->checkout->reg_url_link = EE_Registry::instance()->REQ->get( 'e_reg_url_link', '' );
488
+		$this->checkout->reg_url_link = EE_Registry::instance()->REQ->get('e_reg_url_link', '');
489 489
 		// or some other kind of revisit ?
490
-		$this->checkout->revisit = EE_Registry::instance()->REQ->get( 'revisit', FALSE );
490
+		$this->checkout->revisit = EE_Registry::instance()->REQ->get('revisit', FALSE);
491 491
 		// and whether or not to generate a reg form for this request
492
-		$this->checkout->generate_reg_form = EE_Registry::instance()->REQ->get( 'generate_reg_form', TRUE ); 		// TRUE 	FALSE
492
+		$this->checkout->generate_reg_form = EE_Registry::instance()->REQ->get('generate_reg_form', TRUE); // TRUE 	FALSE
493 493
 		// and whether or not to process a reg form submission for this request
494
-		$this->checkout->process_form_submission = EE_Registry::instance()->REQ->get( 'process_form_submission', FALSE ); 		// TRUE 	FALSE
494
+		$this->checkout->process_form_submission = EE_Registry::instance()->REQ->get('process_form_submission', FALSE); // TRUE 	FALSE
495 495
 		$this->checkout->process_form_submission = $this->checkout->action !== 'display_spco_reg_step'
496 496
 			? $this->checkout->process_form_submission
497
-			: FALSE; 		// TRUE 	FALSE
497
+			: FALSE; // TRUE 	FALSE
498 498
 		//$this->_display_request_vars();
499 499
 	}
500 500
 
@@ -507,17 +507,17 @@  discard block
 block discarded – undo
507 507
 	 * @return    void
508 508
 	 */
509 509
 	protected function _display_request_vars() {
510
-		if ( ! WP_DEBUG ) {
510
+		if ( ! WP_DEBUG) {
511 511
 			return;
512 512
 		}
513
-		EEH_Debug_Tools::printr( $_REQUEST, '$_REQUEST', __FILE__, __LINE__ );
514
-		EEH_Debug_Tools::printr( $this->checkout->step, '$this->checkout->step', __FILE__, __LINE__ );
515
-		EEH_Debug_Tools::printr( $this->checkout->edit_step, '$this->checkout->edit_step', __FILE__, __LINE__ );
516
-		EEH_Debug_Tools::printr( $this->checkout->action, '$this->checkout->action', __FILE__, __LINE__ );
517
-		EEH_Debug_Tools::printr( $this->checkout->reg_url_link, '$this->checkout->reg_url_link', __FILE__, __LINE__ );
518
-		EEH_Debug_Tools::printr( $this->checkout->revisit, '$this->checkout->revisit', __FILE__, __LINE__ );
519
-		EEH_Debug_Tools::printr( $this->checkout->generate_reg_form, '$this->checkout->generate_reg_form', __FILE__, __LINE__ );
520
-		EEH_Debug_Tools::printr( $this->checkout->process_form_submission, '$this->checkout->process_form_submission', __FILE__, __LINE__ );
513
+		EEH_Debug_Tools::printr($_REQUEST, '$_REQUEST', __FILE__, __LINE__);
514
+		EEH_Debug_Tools::printr($this->checkout->step, '$this->checkout->step', __FILE__, __LINE__);
515
+		EEH_Debug_Tools::printr($this->checkout->edit_step, '$this->checkout->edit_step', __FILE__, __LINE__);
516
+		EEH_Debug_Tools::printr($this->checkout->action, '$this->checkout->action', __FILE__, __LINE__);
517
+		EEH_Debug_Tools::printr($this->checkout->reg_url_link, '$this->checkout->reg_url_link', __FILE__, __LINE__);
518
+		EEH_Debug_Tools::printr($this->checkout->revisit, '$this->checkout->revisit', __FILE__, __LINE__);
519
+		EEH_Debug_Tools::printr($this->checkout->generate_reg_form, '$this->checkout->generate_reg_form', __FILE__, __LINE__);
520
+		EEH_Debug_Tools::printr($this->checkout->process_form_submission, '$this->checkout->process_form_submission', __FILE__, __LINE__);
521 521
 	}
522 522
 
523 523
 
@@ -531,8 +531,8 @@  discard block
 block discarded – undo
531 531
 	 * @return    array
532 532
 	 */
533 533
 	private function _get_first_step() {
534
-		$first_step = reset( EED_Single_Page_Checkout::$_reg_steps_array );
535
-		return isset( $first_step['slug'] ) ? $first_step['slug'] : 'attendee_information';
534
+		$first_step = reset(EED_Single_Page_Checkout::$_reg_steps_array);
535
+		return isset($first_step['slug']) ? $first_step['slug'] : 'attendee_information';
536 536
 	}
537 537
 
538 538
 
@@ -548,27 +548,27 @@  discard block
 block discarded – undo
548 548
 	private function _load_and_instantiate_reg_steps() {
549 549
 		// have reg_steps already been instantiated ?
550 550
 		if (
551
-			empty( $this->checkout->reg_steps ) ||
552
-			apply_filters( 'FHEE__Single_Page_Checkout__load_reg_steps__reload_reg_steps', false, $this->checkout )
551
+			empty($this->checkout->reg_steps) ||
552
+			apply_filters('FHEE__Single_Page_Checkout__load_reg_steps__reload_reg_steps', false, $this->checkout)
553 553
 		) {
554 554
 			// if not, then loop through raw reg steps array
555
-			foreach ( EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step ) {
556
-				if ( ! $this->_load_and_instantiate_reg_step( $reg_step, $order )) {
555
+			foreach (EED_Single_Page_Checkout::$_reg_steps_array as $order => $reg_step) {
556
+				if ( ! $this->_load_and_instantiate_reg_step($reg_step, $order)) {
557 557
 					return false;
558 558
 				}
559 559
 			}
560 560
 			EE_Registry::instance()->CFG->registration->skip_reg_confirmation = TRUE;
561 561
 			EE_Registry::instance()->CFG->registration->reg_confirmation_last = TRUE;
562 562
 			// skip the registration_confirmation page ?
563
-			if ( EE_Registry::instance()->CFG->registration->skip_reg_confirmation ) {
563
+			if (EE_Registry::instance()->CFG->registration->skip_reg_confirmation) {
564 564
 				// just remove it from the reg steps array
565
-				$this->checkout->remove_reg_step( 'registration_confirmation', false );
565
+				$this->checkout->remove_reg_step('registration_confirmation', false);
566 566
 			} else if (
567 567
 				EE_Registry::instance()->CFG->registration->reg_confirmation_last
568
-				&& isset( $this->checkout->reg_steps['registration_confirmation'] )
568
+				&& isset($this->checkout->reg_steps['registration_confirmation'])
569 569
 			) {
570 570
 				// set the order to something big like 100
571
-				$this->checkout->set_reg_step_order( 'registration_confirmation', 100 );
571
+				$this->checkout->set_reg_step_order('registration_confirmation', 100);
572 572
 			}
573 573
 			// filter the array for good luck
574 574
 			$this->checkout->reg_steps = apply_filters(
@@ -578,13 +578,13 @@  discard block
 block discarded – undo
578 578
 			// finally re-sort based on the reg step class order properties
579 579
 			$this->checkout->sort_reg_steps();
580 580
 		} else {
581
-			foreach ( $this->checkout->reg_steps as $reg_step ) {
581
+			foreach ($this->checkout->reg_steps as $reg_step) {
582 582
 				// set all current step stati to FALSE
583
-				$reg_step->set_is_current_step( FALSE );
583
+				$reg_step->set_is_current_step(FALSE);
584 584
 			}
585 585
 		}
586
-		if ( empty( $this->checkout->reg_steps )) {
587
-			EE_Error::add_error( __( 'No Reg Steps were loaded..', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__);
586
+		if (empty($this->checkout->reg_steps)) {
587
+			EE_Error::add_error(__('No Reg Steps were loaded..', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
588 588
 			return false;
589 589
 		}
590 590
 			// make reg step details available to JS
@@ -602,10 +602,10 @@  discard block
 block discarded – undo
602 602
 	 * @param int   $order
603 603
 	 * @return bool
604 604
 	 */
605
-	private function _load_and_instantiate_reg_step( $reg_step = array(), $order = 0 ) {
605
+	private function _load_and_instantiate_reg_step($reg_step = array(), $order = 0) {
606 606
 
607 607
 		// we need a file_path, class_name, and slug to add a reg step
608
-		if ( isset( $reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'] )) {
608
+		if (isset($reg_step['file_path'], $reg_step['class_name'], $reg_step['slug'])) {
609 609
 			// if editing a specific step, but this is NOT that step... (and it's not the 'finalize_registration' step)
610 610
 			if (
611 611
 				$this->checkout->reg_url_link
@@ -623,26 +623,26 @@  discard block
 block discarded – undo
623 623
 				FALSE
624 624
 			);
625 625
 			// did we gets the goods ?
626
-			if ( $reg_step_obj instanceof EE_SPCO_Reg_Step ) {
626
+			if ($reg_step_obj instanceof EE_SPCO_Reg_Step) {
627 627
 				// set reg step order based on config
628
-				$reg_step_obj->set_order( $order );
628
+				$reg_step_obj->set_order($order);
629 629
 				// add instantiated reg step object to the master reg steps array
630
-				$this->checkout->add_reg_step( $reg_step_obj );
630
+				$this->checkout->add_reg_step($reg_step_obj);
631 631
 			} else {
632 632
 				EE_Error::add_error(
633
-					__( 'The current step could not be set.', 'event_espresso' ),
633
+					__('The current step could not be set.', 'event_espresso'),
634 634
 					__FILE__, __FUNCTION__, __LINE__
635 635
 				);
636 636
 				return false;
637 637
 			}
638 638
 		} else {
639
-			if ( WP_DEBUG ) {
639
+			if (WP_DEBUG) {
640 640
 				EE_Error::add_error(
641 641
 					sprintf(
642
-						__( 'A registration step could not be loaded. One or more of the following data points is invalid:%4$s%5$sFile Path: %1$s%6$s%5$sClass Name: %2$s%6$s%5$sSlug: %3$s%6$s%7$s', 'event_espresso' ),
643
-						isset( $reg_step['file_path'] ) ? $reg_step['file_path'] : '',
644
-						isset( $reg_step['class_name'] ) ? $reg_step['class_name'] : '',
645
-						isset( $reg_step['slug'] ) ? $reg_step['slug'] : '',
642
+						__('A registration step could not be loaded. One or more of the following data points is invalid:%4$s%5$sFile Path: %1$s%6$s%5$sClass Name: %2$s%6$s%5$sSlug: %3$s%6$s%7$s', 'event_espresso'),
643
+						isset($reg_step['file_path']) ? $reg_step['file_path'] : '',
644
+						isset($reg_step['class_name']) ? $reg_step['class_name'] : '',
645
+						isset($reg_step['slug']) ? $reg_step['slug'] : '',
646 646
 						'<ul>',
647 647
 						'<li>',
648 648
 						'</li>',
@@ -666,16 +666,16 @@  discard block
 block discarded – undo
666 666
 	 */
667 667
 	private function _get_transaction_and_cart_for_previous_visit() {
668 668
 		/** @var $TXN_model EEM_Transaction */
669
-		$TXN_model = EE_Registry::instance()->load_model( 'Transaction' );
669
+		$TXN_model = EE_Registry::instance()->load_model('Transaction');
670 670
 		// because the reg_url_link is present in the request, this is a return visit to SPCO, so we'll get the transaction data from the db
671
-		$transaction = $TXN_model->get_transaction_from_reg_url_link( $this->checkout->reg_url_link );
671
+		$transaction = $TXN_model->get_transaction_from_reg_url_link($this->checkout->reg_url_link);
672 672
 		// verify transaction
673
-		if ( $transaction instanceof EE_Transaction ) {
673
+		if ($transaction instanceof EE_Transaction) {
674 674
 			// and get the cart that was used for that transaction
675
-			$this->checkout->cart = $this->_get_cart_for_transaction( $transaction );
675
+			$this->checkout->cart = $this->_get_cart_for_transaction($transaction);
676 676
 			return $transaction;
677 677
 		} else {
678
-			EE_Error::add_error( __( 'Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__);
678
+			EE_Error::add_error(__('Your Registration and Transaction information could not be retrieved from the db.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
679 679
 			return NULL;
680 680
 		}
681 681
 	}
@@ -689,11 +689,11 @@  discard block
 block discarded – undo
689 689
 	 * @param EE_Transaction $transaction
690 690
 	 * @return EE_Cart
691 691
 	 */
692
-	private function _get_cart_for_transaction( $transaction ) {
693
-		$cart = $transaction instanceof EE_Transaction ? EE_Cart::get_cart_from_txn( $transaction ) : NULL;
692
+	private function _get_cart_for_transaction($transaction) {
693
+		$cart = $transaction instanceof EE_Transaction ? EE_Cart::get_cart_from_txn($transaction) : NULL;
694 694
 		// verify cart
695
-		if ( ! $cart instanceof EE_Cart ) {
696
-			$cart = EE_Registry::instance()->load_core( 'Cart' );
695
+		if ( ! $cart instanceof EE_Cart) {
696
+			$cart = EE_Registry::instance()->load_core('Cart');
697 697
 		}
698 698
 		return $cart;
699 699
 	}
@@ -708,8 +708,8 @@  discard block
 block discarded – undo
708 708
 	 * @param EE_Transaction $transaction
709 709
 	 * 	@return EE_Cart
710 710
 	 */
711
-	public function get_cart_for_transaction( EE_Transaction $transaction ) {
712
-		return EE_Cart::get_cart_from_txn( $transaction );
711
+	public function get_cart_for_transaction(EE_Transaction $transaction) {
712
+		return EE_Cart::get_cart_from_txn($transaction);
713 713
 	}
714 714
 
715 715
 
@@ -724,17 +724,17 @@  discard block
 block discarded – undo
724 724
 	private function _get_cart_for_current_session_and_setup_new_transaction() {
725 725
 		//  if there's no transaction, then this is the FIRST visit to SPCO
726 726
 		// so load up the cart ( passing nothing for the TXN because it doesn't exist yet )
727
-		$this->checkout->cart = $this->_get_cart_for_transaction( NULL );
727
+		$this->checkout->cart = $this->_get_cart_for_transaction(NULL);
728 728
 		// and then create a new transaction
729 729
 		$transaction = $this->_initialize_transaction();
730 730
 		// verify transaction
731
-		if ( $transaction instanceof EE_Transaction ) {
731
+		if ($transaction instanceof EE_Transaction) {
732 732
 			// save it so that we have an ID for other objects to use
733 733
 			$transaction->save();
734 734
 			// and save TXN data to the cart
735
-			$this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn( $transaction->ID() );
735
+			$this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn($transaction->ID());
736 736
 		} else {
737
-			EE_Error::add_error( __( 'A Valid Transaction could not be initialized.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
737
+			EE_Error::add_error(__('A Valid Transaction could not be initialized.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
738 738
 		}
739 739
 		return $transaction;
740 740
 	}
@@ -754,15 +754,15 @@  discard block
 block discarded – undo
754 754
 			// grab the cart grand total
755 755
 			$cart_total = $this->checkout->cart->get_cart_grand_total();
756 756
 			// create new TXN
757
-			return EE_Transaction::new_instance( array(
757
+			return EE_Transaction::new_instance(array(
758 758
 				'TXN_timestamp' 	=> time(),
759 759
 				'TXN_reg_steps' 		=> $this->checkout->initialize_txn_reg_steps_array(),
760 760
 				'TXN_total' 				=> $cart_total > 0 ? $cart_total : 0,
761 761
 				'TXN_paid' 				=> 0,
762 762
 				'STS_ID' 					=> EEM_Transaction::failed_status_code,
763 763
 			));
764
-		} catch( Exception $e ) {
765
-			EE_Error::add_error( $e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
764
+		} catch (Exception $e) {
765
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
766 766
 		}
767 767
 		return NULL;
768 768
 	}
@@ -776,34 +776,34 @@  discard block
 block discarded – undo
776 776
 	 * @param EE_Transaction $transaction
777 777
 	 * @return EE_Cart
778 778
 	 */
779
-	private function _get_registrations( EE_Transaction $transaction ) {
779
+	private function _get_registrations(EE_Transaction $transaction) {
780 780
 		// first step: grab the registrants  { : o
781
-		$registrations = $transaction->registrations( $this->checkout->reg_cache_where_params, true );
781
+		$registrations = $transaction->registrations($this->checkout->reg_cache_where_params, true);
782 782
 		// verify registrations have been set
783
-		if ( empty( $registrations )) {
783
+		if (empty($registrations)) {
784 784
 			// if no cached registrations, then check the db
785
-			$registrations = $transaction->registrations( $this->checkout->reg_cache_where_params, false );
785
+			$registrations = $transaction->registrations($this->checkout->reg_cache_where_params, false);
786 786
 			// still nothing ? well as long as this isn't a revisit
787
-			if ( empty( $registrations ) && ! $this->checkout->revisit ) {
787
+			if (empty($registrations) && ! $this->checkout->revisit) {
788 788
 				// generate new registrations from scratch
789
-				$registrations = $this->_initialize_registrations( $transaction );
789
+				$registrations = $this->_initialize_registrations($transaction);
790 790
 			}
791 791
 		}
792 792
 		// sort by their original registration order
793
-		usort( $registrations, array( 'EED_Single_Page_Checkout', 'sort_registrations_by_REG_count' ));
793
+		usort($registrations, array('EED_Single_Page_Checkout', 'sort_registrations_by_REG_count'));
794 794
 		// then loop thru the array
795
-		foreach ( $registrations as $registration ) {
795
+		foreach ($registrations as $registration) {
796 796
 			// verify each registration
797
-			if ( $registration instanceof EE_Registration ) {
797
+			if ($registration instanceof EE_Registration) {
798 798
 				// we display all attendee info for the primary registrant
799
-				if ( $this->checkout->reg_url_link == $registration->reg_url_link() && $registration->is_primary_registrant() ) {
799
+				if ($this->checkout->reg_url_link == $registration->reg_url_link() && $registration->is_primary_registrant()) {
800 800
 					$this->checkout->primary_revisit = TRUE;
801 801
 					break;
802
-				} else if ( $this->checkout->revisit && $this->checkout->reg_url_link != $registration->reg_url_link() ) {
802
+				} else if ($this->checkout->revisit && $this->checkout->reg_url_link != $registration->reg_url_link()) {
803 803
 					// but hide info if it doesn't belong to you
804
-					$transaction->clear_cache( 'Registration', $registration->ID() );
804
+					$transaction->clear_cache('Registration', $registration->ID());
805 805
 				}
806
-				$this->checkout->set_reg_status_updated( $registration->ID(), false );
806
+				$this->checkout->set_reg_status_updated($registration->ID(), false);
807 807
 			}
808 808
 		}
809 809
 	}
@@ -817,17 +817,17 @@  discard block
 block discarded – undo
817 817
 	 * @param EE_Transaction $transaction
818 818
 	 * @return    array
819 819
 	 */
820
-	private function _initialize_registrations( EE_Transaction $transaction ) {
820
+	private function _initialize_registrations(EE_Transaction $transaction) {
821 821
 		$att_nmbr = 0;
822 822
 		$registrations = array();
823
-		if ( $transaction instanceof EE_Transaction ) {
823
+		if ($transaction instanceof EE_Transaction) {
824 824
 			/** @type EE_Registration_Processor $registration_processor */
825
-			$registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' );
825
+			$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
826 826
 			$this->checkout->total_ticket_count = $this->checkout->cart->all_ticket_quantity_count();
827 827
 			// now let's add the cart items to the $transaction
828
-			foreach ( $this->checkout->cart->get_tickets() as $line_item ) {
828
+			foreach ($this->checkout->cart->get_tickets() as $line_item) {
829 829
 				//do the following for each ticket of this type they selected
830
-				for ( $x = 1; $x <= $line_item->quantity(); $x++ ) {
830
+				for ($x = 1; $x <= $line_item->quantity(); $x++) {
831 831
 					$att_nmbr++;
832 832
 					$registration = $registration_processor->generate_ONE_registration_from_line_item(
833 833
 						$line_item,
@@ -835,12 +835,12 @@  discard block
 block discarded – undo
835 835
 						$att_nmbr,
836 836
 						$this->checkout->total_ticket_count
837 837
 					);
838
-					if ( $registration instanceof EE_Registration ) {
839
-						$registrations[ $registration->ID() ] = $registration;
838
+					if ($registration instanceof EE_Registration) {
839
+						$registrations[$registration->ID()] = $registration;
840 840
 					}
841 841
 				}
842 842
 			}
843
-			$registration_processor->fix_reg_final_price_rounding_issue( $transaction );
843
+			$registration_processor->fix_reg_final_price_rounding_issue($transaction);
844 844
 		}
845 845
 		return $registrations;
846 846
 	}
@@ -855,12 +855,12 @@  discard block
 block discarded – undo
855 855
 	 * @param EE_Registration $reg_B
856 856
 	 * @return array()
857 857
 	 */
858
-	public static function sort_registrations_by_REG_count( EE_Registration $reg_A, EE_Registration $reg_B ) {
858
+	public static function sort_registrations_by_REG_count(EE_Registration $reg_A, EE_Registration $reg_B) {
859 859
 		// this shouldn't ever happen within the same TXN, but oh well
860
-		if ( $reg_A->count() == $reg_B->count() ) {
860
+		if ($reg_A->count() == $reg_B->count()) {
861 861
 			return 0;
862 862
 		}
863
-		return ( $reg_A->count() > $reg_B->count() ) ? 1 : -1;
863
+		return ($reg_A->count() > $reg_B->count()) ? 1 : -1;
864 864
 	}
865 865
 
866 866
 
@@ -875,35 +875,35 @@  discard block
 block discarded – undo
875 875
 	 */
876 876
 	private function _final_verifications() {
877 877
 		// filter checkout
878
-		$this->checkout = apply_filters( 'FHEE__EED_Single_Page_Checkout___final_verifications__checkout', $this->checkout );
878
+		$this->checkout = apply_filters('FHEE__EED_Single_Page_Checkout___final_verifications__checkout', $this->checkout);
879 879
 		//verify that current step is still set correctly
880
-		if ( ! $this->checkout->current_step instanceof EE_SPCO_Reg_Step ) {
881
-			EE_Error::add_error( __( 'We\'re sorry but the registration process can not proceed because one or more registration steps were not setup correctly. Please refresh the page and try again or contact support.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
880
+		if ( ! $this->checkout->current_step instanceof EE_SPCO_Reg_Step) {
881
+			EE_Error::add_error(__('We\'re sorry but the registration process can not proceed because one or more registration steps were not setup correctly. Please refresh the page and try again or contact support.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
882 882
 			return false;
883 883
 		}
884 884
 		// if returning to SPCO, then verify that primary registrant is set
885
-		if ( ! empty( $this->checkout->reg_url_link )) {
885
+		if ( ! empty($this->checkout->reg_url_link)) {
886 886
 			$valid_registrant = $this->checkout->transaction->primary_registration();
887
-			if ( ! $valid_registrant instanceof EE_Registration ) {
888
-				EE_Error::add_error( __( 'We\'re sorry but there appears to be an error with the "reg_url_link" or the primary registrant for this transaction. Please refresh the page and try again or contact support.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
887
+			if ( ! $valid_registrant instanceof EE_Registration) {
888
+				EE_Error::add_error(__('We\'re sorry but there appears to be an error with the "reg_url_link" or the primary registrant for this transaction. Please refresh the page and try again or contact support.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
889 889
 				return false;
890 890
 			}
891 891
 			$valid_registrant = null;
892
-			foreach ( $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params ) as $registration ) {
893
-				if ( $registration instanceof EE_Registration ) {
894
-					if ( $registration->reg_url_link() == $this->checkout->reg_url_link ) {
892
+			foreach ($this->checkout->transaction->registrations($this->checkout->reg_cache_where_params) as $registration) {
893
+				if ($registration instanceof EE_Registration) {
894
+					if ($registration->reg_url_link() == $this->checkout->reg_url_link) {
895 895
 						$valid_registrant = $registration;
896 896
 					}
897 897
 				}
898 898
 			}
899
-			if ( ! $valid_registrant instanceof EE_Registration ) {
900
-				EE_Error::add_error( __( 'We\'re sorry but there appears to be an error with the "reg_url_link" or the transaction itself. Please refresh the page and try again or contact support.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
899
+			if ( ! $valid_registrant instanceof EE_Registration) {
900
+				EE_Error::add_error(__('We\'re sorry but there appears to be an error with the "reg_url_link" or the transaction itself. Please refresh the page and try again or contact support.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
901 901
 				return false;
902 902
 			}
903 903
 		}
904 904
 		// now that things have been kinda sufficiently verified,
905 905
 		// let's add the checkout to the session so that's available other systems
906
-		EE_Registry::instance()->SSN->set_checkout( $this->checkout );
906
+		EE_Registry::instance()->SSN->set_checkout($this->checkout);
907 907
 		return true;
908 908
 	}
909 909
 
@@ -919,28 +919,28 @@  discard block
 block discarded – undo
919 919
 	 * @access    private
920 920
 	 * @param bool $reinitializing
921 921
 	 */
922
-	private function _initialize_reg_steps( $reinitializing = false ) {
923
-		$this->checkout->set_reg_step_initiated( $this->checkout->current_step );
922
+	private function _initialize_reg_steps($reinitializing = false) {
923
+		$this->checkout->set_reg_step_initiated($this->checkout->current_step);
924 924
 		// loop thru all steps to call their individual "initialize" methods and set i18n strings for JS
925
-		foreach ( $this->checkout->reg_steps as $reg_step ) {
926
-			if ( ! $reg_step->initialize_reg_step() ) {
925
+		foreach ($this->checkout->reg_steps as $reg_step) {
926
+			if ( ! $reg_step->initialize_reg_step()) {
927 927
 				// if not initialized then maybe this step is being removed...
928
-				if ( $reg_step->is_current_step() && ! $reinitializing ) {
928
+				if ($reg_step->is_current_step() && ! $reinitializing) {
929 929
 					// if it was the current step, then we need to start over here
930
-					$this->_initialize_reg_steps( true );
930
+					$this->_initialize_reg_steps(true);
931 931
 					return;
932 932
 				}
933 933
 				continue;
934 934
 			}
935 935
 			// i18n
936 936
 			$reg_step->translate_js_strings();
937
-			if ( $reg_step->is_current_step() ) {
937
+			if ($reg_step->is_current_step()) {
938 938
 				// the text that appears on the reg step form submit button
939 939
 				$reg_step->set_submit_button_text();
940 940
 			}
941 941
 		}
942 942
 		// dynamically creates hook point like: AHEE__Single_Page_Checkout___initialize_reg_step__attendee_information
943
-		do_action( "AHEE__Single_Page_Checkout___initialize_reg_step__{$this->checkout->current_step->slug()}", $this->checkout->current_step );
943
+		do_action("AHEE__Single_Page_Checkout___initialize_reg_step__{$this->checkout->current_step->slug()}", $this->checkout->current_step);
944 944
 	}
945 945
 
946 946
 
@@ -953,39 +953,39 @@  discard block
 block discarded – undo
953 953
 	 */
954 954
 	private function _check_form_submission() {
955 955
 		//does this request require the reg form to be generated ?
956
-		if ( $this->checkout->generate_reg_form ) {
956
+		if ($this->checkout->generate_reg_form) {
957 957
 			// ever heard that song by Blue Rodeo ?
958 958
 			try {
959 959
 				$this->checkout->current_step->reg_form = $this->checkout->current_step->generate_reg_form();
960 960
 				// if not displaying a form, then check for form submission
961
-				if ( $this->checkout->process_form_submission && $this->checkout->current_step->reg_form->was_submitted() ) {
961
+				if ($this->checkout->process_form_submission && $this->checkout->current_step->reg_form->was_submitted()) {
962 962
 					// clear out any old data in case this step is being run again
963
-					$this->checkout->current_step->set_valid_data( array() );
963
+					$this->checkout->current_step->set_valid_data(array());
964 964
 					// capture submitted form data
965 965
 					$this->checkout->current_step->reg_form->receive_form_submission(
966
-						apply_filters( 'FHEE__Single_Page_Checkout___check_form_submission__request_params', EE_Registry::instance()->REQ->params(), $this->checkout )
966
+						apply_filters('FHEE__Single_Page_Checkout___check_form_submission__request_params', EE_Registry::instance()->REQ->params(), $this->checkout)
967 967
 					);
968 968
 					// validate submitted form data
969
-					if ( ! $this->checkout->current_step->reg_form->is_valid() || ! $this->checkout->continue_reg ) {
969
+					if ( ! $this->checkout->current_step->reg_form->is_valid() || ! $this->checkout->continue_reg) {
970 970
 						// thou shall not pass !!!
971 971
 						$this->checkout->continue_reg = FALSE;
972 972
 						// any form validation errors?
973
-						if ( $this->checkout->current_step->reg_form->submission_error_message() != '' ) {
973
+						if ($this->checkout->current_step->reg_form->submission_error_message() != '') {
974 974
 							$submission_error_messages = array();
975 975
 							// bad, bad, bad registrant
976
-							foreach( $this->checkout->current_step->reg_form->get_validation_errors_accumulated() as $validation_error ){
977
-								if ( $validation_error instanceof EE_Validation_Error ) {
978
-									$submission_error_messages[] = sprintf( __( '%s : %s', 'event_espresso' ), $validation_error->get_form_section()->html_label_text(), $validation_error->getMessage() );
976
+							foreach ($this->checkout->current_step->reg_form->get_validation_errors_accumulated() as $validation_error) {
977
+								if ($validation_error instanceof EE_Validation_Error) {
978
+									$submission_error_messages[] = sprintf(__('%s : %s', 'event_espresso'), $validation_error->get_form_section()->html_label_text(), $validation_error->getMessage());
979 979
 								}
980 980
 							}
981
-							EE_Error::add_error( join( '<br />', $submission_error_messages ), __FILE__, __FUNCTION__, __LINE__ );
981
+							EE_Error::add_error(join('<br />', $submission_error_messages), __FILE__, __FUNCTION__, __LINE__);
982 982
 						}
983 983
 						// well not really... what will happen is we'll just get redirected back to redo the current step
984 984
 						$this->go_to_next_step();
985 985
 						return;
986 986
 					}
987 987
 				}
988
-			} catch( EE_Error $e ) {
988
+			} catch (EE_Error $e) {
989 989
 				$e->get_error();
990 990
 			}
991 991
 		}
@@ -1001,38 +1001,38 @@  discard block
 block discarded – undo
1001 1001
 	 */
1002 1002
 	private function _process_form_action() {
1003 1003
 		// what cha wanna do?
1004
-		switch( $this->checkout->action ) {
1004
+		switch ($this->checkout->action) {
1005 1005
 			// AJAX next step reg form
1006 1006
 			case 'display_spco_reg_step' :
1007 1007
 				$this->checkout->redirect = FALSE;
1008
-				if ( EE_Registry::instance()->REQ->ajax ) {
1009
-					$this->checkout->json_response->set_reg_step_html( $this->checkout->current_step->display_reg_form() );
1008
+				if (EE_Registry::instance()->REQ->ajax) {
1009
+					$this->checkout->json_response->set_reg_step_html($this->checkout->current_step->display_reg_form());
1010 1010
 				}
1011 1011
 				break;
1012 1012
 
1013 1013
 			default :
1014 1014
 				// meh... do one of those other steps first
1015
-				if ( ! empty( $this->checkout->action ) && is_callable( array( $this->checkout->current_step, $this->checkout->action ))) {
1015
+				if ( ! empty($this->checkout->action) && is_callable(array($this->checkout->current_step, $this->checkout->action))) {
1016 1016
 					// dynamically creates hook point like: AHEE__Single_Page_Checkout__before_attendee_information__process_reg_step
1017
-					do_action( "AHEE__Single_Page_Checkout__before_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step );
1017
+					do_action("AHEE__Single_Page_Checkout__before_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step);
1018 1018
 					// call action on current step
1019
-					if ( call_user_func( array( $this->checkout->current_step, $this->checkout->action )) ) {
1019
+					if (call_user_func(array($this->checkout->current_step, $this->checkout->action))) {
1020 1020
 						// good registrant, you get to proceed
1021
-						if ( $this->checkout->current_step->success_message() != '' ) {
1022
-							if ( apply_filters( 'FHEE__Single_Page_Checkout___process_form_action__display_success', false ) ) {
1023
-								EE_Error::add_success( $this->checkout->current_step->success_message() . '<br />' . $this->checkout->next_step->_instructions() );
1021
+						if ($this->checkout->current_step->success_message() != '') {
1022
+							if (apply_filters('FHEE__Single_Page_Checkout___process_form_action__display_success', false)) {
1023
+								EE_Error::add_success($this->checkout->current_step->success_message().'<br />'.$this->checkout->next_step->_instructions());
1024 1024
 							}
1025 1025
 						}
1026 1026
 						// pack it up, pack it in...
1027 1027
 						$this->_setup_redirect();
1028 1028
 					}
1029 1029
 					// dynamically creates hook point like: AHEE__Single_Page_Checkout__after_payment_options__process_reg_step
1030
-					do_action( "AHEE__Single_Page_Checkout__after_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step );
1030
+					do_action("AHEE__Single_Page_Checkout__after_{$this->checkout->current_step->slug()}__{$this->checkout->action}", $this->checkout->current_step);
1031 1031
 
1032 1032
 				} else {
1033 1033
 					EE_Error::add_error(
1034 1034
 						sprintf(
1035
-							__( 'The requested form action "%s" does not exist for the current "%s" registration step.', 'event_espresso' ),
1035
+							__('The requested form action "%s" does not exist for the current "%s" registration step.', 'event_espresso'),
1036 1036
 							$this->checkout->action,
1037 1037
 							$this->checkout->current_step->name()
1038 1038
 						),
@@ -1058,10 +1058,10 @@  discard block
 block discarded – undo
1058 1058
 	public function add_styles_and_scripts() {
1059 1059
 		// i18n
1060 1060
 		$this->translate_js_strings();
1061
-		if ( $this->checkout->admin_request ) {
1062
-			add_action('admin_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10 );
1061
+		if ($this->checkout->admin_request) {
1062
+			add_action('admin_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10);
1063 1063
 		} else {
1064
-			add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles_and_scripts' ), 10 );
1064
+			add_action('wp_enqueue_scripts', array($this, 'enqueue_styles_and_scripts'), 10);
1065 1065
 		}
1066 1066
 	}
1067 1067
 
@@ -1077,42 +1077,42 @@  discard block
 block discarded – undo
1077 1077
 		EE_Registry::$i18n_js_strings['revisit'] = $this->checkout->revisit;
1078 1078
 		EE_Registry::$i18n_js_strings['e_reg_url_link'] = $this->checkout->reg_url_link;
1079 1079
 		EE_Registry::$i18n_js_strings['server_error'] = __('An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again or contact support.', 'event_espresso');
1080
-		EE_Registry::$i18n_js_strings['invalid_json_response'] = __( 'An invalid response was returned from the server while attempting to process your request. Please refresh the page and try again or contact support.', 'event_espresso' );
1081
-		EE_Registry::$i18n_js_strings['validation_error'] = __( 'There appears to be a problem with the form validation configuration! Please check the admin settings or contact support.', 'event_espresso' );
1082
-		EE_Registry::$i18n_js_strings['invalid_payment_method'] = __( 'There appears to be a problem with the payment method configuration! Please refresh the page and try again or contact support.', 'event_espresso' );
1080
+		EE_Registry::$i18n_js_strings['invalid_json_response'] = __('An invalid response was returned from the server while attempting to process your request. Please refresh the page and try again or contact support.', 'event_espresso');
1081
+		EE_Registry::$i18n_js_strings['validation_error'] = __('There appears to be a problem with the form validation configuration! Please check the admin settings or contact support.', 'event_espresso');
1082
+		EE_Registry::$i18n_js_strings['invalid_payment_method'] = __('There appears to be a problem with the payment method configuration! Please refresh the page and try again or contact support.', 'event_espresso');
1083 1083
 		EE_Registry::$i18n_js_strings['reg_step_error'] = __('This registration step could not be completed. Please refresh the page and try again.', 'event_espresso');
1084 1084
 		EE_Registry::$i18n_js_strings['invalid_coupon'] = __('We\'re sorry but that coupon code does not appear to be valid. If this is incorrect, please contact the site administrator.', 'event_espresso');
1085
-		EE_Registry::$i18n_js_strings['process_registration'] = sprintf( __( 'Please wait while we process your registration.%sDo not refresh the page or navigate away while this is happening.%sThank you for your patience.', 'event_espresso' ), '<br/>', '<br/>' );
1086
-		EE_Registry::$i18n_js_strings['language'] = get_bloginfo( 'language' );
1085
+		EE_Registry::$i18n_js_strings['process_registration'] = sprintf(__('Please wait while we process your registration.%sDo not refresh the page or navigate away while this is happening.%sThank you for your patience.', 'event_espresso'), '<br/>', '<br/>');
1086
+		EE_Registry::$i18n_js_strings['language'] = get_bloginfo('language');
1087 1087
 		EE_Registry::$i18n_js_strings['EESID'] = EE_Registry::instance()->SSN->id();
1088 1088
 		EE_Registry::$i18n_js_strings['currency'] = EE_Registry::instance()->CFG->currency;
1089 1089
 		EE_Registry::$i18n_js_strings['datepicker_yearRange'] = '-150:+20';
1090
-		EE_Registry::$i18n_js_strings['timer_years'] = __( 'years', 'event_espresso' );
1091
-		EE_Registry::$i18n_js_strings['timer_months'] = __( 'months', 'event_espresso' );
1092
-		EE_Registry::$i18n_js_strings['timer_weeks'] = __( 'weeks', 'event_espresso' );
1093
-		EE_Registry::$i18n_js_strings['timer_days'] = __( 'days', 'event_espresso' );
1094
-		EE_Registry::$i18n_js_strings['timer_hours'] = __( 'hours', 'event_espresso' );
1095
-		EE_Registry::$i18n_js_strings['timer_minutes'] = __( 'minutes', 'event_espresso' );
1096
-		EE_Registry::$i18n_js_strings['timer_seconds'] = __( 'seconds', 'event_espresso' );
1097
-		EE_Registry::$i18n_js_strings['timer_year'] = __( 'year', 'event_espresso' );
1098
-		EE_Registry::$i18n_js_strings['timer_month'] = __( 'month', 'event_espresso' );
1099
-		EE_Registry::$i18n_js_strings['timer_week'] = __( 'week', 'event_espresso' );
1100
-		EE_Registry::$i18n_js_strings['timer_day'] = __( 'day', 'event_espresso' );
1101
-		EE_Registry::$i18n_js_strings['timer_hour'] = __( 'hour', 'event_espresso' );
1102
-		EE_Registry::$i18n_js_strings['timer_minute'] = __( 'minute', 'event_espresso' );
1103
-		EE_Registry::$i18n_js_strings['timer_second'] = __( 'second', 'event_espresso' );
1090
+		EE_Registry::$i18n_js_strings['timer_years'] = __('years', 'event_espresso');
1091
+		EE_Registry::$i18n_js_strings['timer_months'] = __('months', 'event_espresso');
1092
+		EE_Registry::$i18n_js_strings['timer_weeks'] = __('weeks', 'event_espresso');
1093
+		EE_Registry::$i18n_js_strings['timer_days'] = __('days', 'event_espresso');
1094
+		EE_Registry::$i18n_js_strings['timer_hours'] = __('hours', 'event_espresso');
1095
+		EE_Registry::$i18n_js_strings['timer_minutes'] = __('minutes', 'event_espresso');
1096
+		EE_Registry::$i18n_js_strings['timer_seconds'] = __('seconds', 'event_espresso');
1097
+		EE_Registry::$i18n_js_strings['timer_year'] = __('year', 'event_espresso');
1098
+		EE_Registry::$i18n_js_strings['timer_month'] = __('month', 'event_espresso');
1099
+		EE_Registry::$i18n_js_strings['timer_week'] = __('week', 'event_espresso');
1100
+		EE_Registry::$i18n_js_strings['timer_day'] = __('day', 'event_espresso');
1101
+		EE_Registry::$i18n_js_strings['timer_hour'] = __('hour', 'event_espresso');
1102
+		EE_Registry::$i18n_js_strings['timer_minute'] = __('minute', 'event_espresso');
1103
+		EE_Registry::$i18n_js_strings['timer_second'] = __('second', 'event_espresso');
1104 1104
 		EE_Registry::$i18n_js_strings['registration_expiration_notice'] = sprintf(
1105
-			__( '%1$sWe\'re sorry, but your registration time has expired.%2$s%3$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please except our apologies for any inconvenience this may have caused.%8$s', 'event_espresso' ),
1105
+			__('%1$sWe\'re sorry, but your registration time has expired.%2$s%3$s%4$sIf you still wish to complete your registration, please return to the %5$sEvent List%6$sEvent List%7$s and reselect your tickets if available. Please except our apologies for any inconvenience this may have caused.%8$s', 'event_espresso'),
1106 1106
 			'<h4 class="important-notice">',
1107 1107
 			'</h4>',
1108 1108
 			'<br />',
1109 1109
 			'<p>',
1110
-			'<a href="'. get_post_type_archive_link( 'espresso_events' ) . '" title="',
1110
+			'<a href="'.get_post_type_archive_link('espresso_events').'" title="',
1111 1111
 			'">',
1112 1112
 			'</a>',
1113 1113
 			'</p>'
1114 1114
 		);
1115
-		EE_Registry::$i18n_js_strings[ 'ajax_submit' ] = apply_filters( 'FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit', true );
1115
+		EE_Registry::$i18n_js_strings['ajax_submit'] = apply_filters('FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit', true);
1116 1116
 	}
1117 1117
 
1118 1118
 
@@ -1125,25 +1125,25 @@  discard block
 block discarded – undo
1125 1125
 	 */
1126 1126
 	public function enqueue_styles_and_scripts() {
1127 1127
 		// load css
1128
-		wp_register_style( 'single_page_checkout', SPCO_CSS_URL . 'single_page_checkout.css', array(), EVENT_ESPRESSO_VERSION );
1129
-		wp_enqueue_style( 'single_page_checkout' );
1128
+		wp_register_style('single_page_checkout', SPCO_CSS_URL.'single_page_checkout.css', array(), EVENT_ESPRESSO_VERSION);
1129
+		wp_enqueue_style('single_page_checkout');
1130 1130
 		// load JS
1131
-		wp_register_script( 'jquery_plugin', EE_THIRD_PARTY_URL . 'jquery	.plugin.min.js', array( 'jquery' ), '1.0.1', TRUE );
1132
-		wp_register_script( 'jquery_countdown', EE_THIRD_PARTY_URL . 'jquery	.countdown.min.js', array( 'jquery_plugin' ), '2.0.2', TRUE );
1133
-		wp_register_script( 'single_page_checkout', SPCO_JS_URL . 'single_page_checkout.js', array( 'espresso_core', 'underscore', 'ee_form_section_validation', 'jquery_countdown' ), EVENT_ESPRESSO_VERSION, TRUE );
1134
-		wp_enqueue_script( 'single_page_checkout' );
1131
+		wp_register_script('jquery_plugin', EE_THIRD_PARTY_URL.'jquery	.plugin.min.js', array('jquery'), '1.0.1', TRUE);
1132
+		wp_register_script('jquery_countdown', EE_THIRD_PARTY_URL.'jquery	.countdown.min.js', array('jquery_plugin'), '2.0.2', TRUE);
1133
+		wp_register_script('single_page_checkout', SPCO_JS_URL.'single_page_checkout.js', array('espresso_core', 'underscore', 'ee_form_section_validation', 'jquery_countdown'), EVENT_ESPRESSO_VERSION, TRUE);
1134
+		wp_enqueue_script('single_page_checkout');
1135 1135
 
1136 1136
 		/**
1137 1137
 		 * global action hook for enqueueing styles and scripts with
1138 1138
 		 * spco calls.
1139 1139
 		 */
1140
-		do_action( 'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts', $this );
1140
+		do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts', $this);
1141 1141
 
1142 1142
 		/**
1143 1143
 		 * dynamic action hook for enqueueing styles and scripts with spco calls.
1144 1144
 		 * The hook will end up being something like AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__attendee_information
1145 1145
 		 */
1146
-		do_action( 'AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__' . $this->checkout->current_step->slug(), $this );
1146
+		do_action('AHEE__EED_Single_Page_Checkout__enqueue_styles_and_scripts__'.$this->checkout->current_step->slug(), $this);
1147 1147
 
1148 1148
 		// add css and JS for current step
1149 1149
 		$this->checkout->current_step->enqueue_styles_and_scripts();
@@ -1159,20 +1159,20 @@  discard block
 block discarded – undo
1159 1159
 	 */
1160 1160
 	private function _display_spco_reg_form() {
1161 1161
 		// if registering via the admin, just display the reg form for the current step
1162
-		if ( $this->checkout->admin_request ) {
1163
-			EE_Registry::instance()->REQ->add_output( $this->checkout->current_step->display_reg_form() );
1162
+		if ($this->checkout->admin_request) {
1163
+			EE_Registry::instance()->REQ->add_output($this->checkout->current_step->display_reg_form());
1164 1164
 		} else {
1165 1165
 			// add powered by EE msg
1166
-			add_action( 'AHEE__SPCO__reg_form_footer', array( 'EED_Single_Page_Checkout', 'display_registration_footer' ));
1166
+			add_action('AHEE__SPCO__reg_form_footer', array('EED_Single_Page_Checkout', 'display_registration_footer'));
1167 1167
 
1168
-			$empty_cart = count( $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params ) ) < 1 ? true : false;
1168
+			$empty_cart = count($this->checkout->transaction->registrations($this->checkout->reg_cache_where_params)) < 1 ? true : false;
1169 1169
 			$cookies_not_set_msg = '';
1170
-			if ( $empty_cart ) {
1171
-				if ( ! isset( $_COOKIE[ 'ee_cookie_test' ] ) ) {
1170
+			if ($empty_cart) {
1171
+				if ( ! isset($_COOKIE['ee_cookie_test'])) {
1172 1172
 					$cookies_not_set_msg = apply_filters(
1173 1173
 						'FHEE__Single_Page_Checkout__display_spco_reg_form__cookies_not_set_msg',
1174 1174
 						sprintf(
1175
-							__( '%1$s%3$sIt appears your browser is not currently set to accept Cookies%4$s%5$sIn order to register for events, you need to enable cookies.%7$sIf you require assistance, then click the following link to learn how to %8$senable cookies%9$s%6$s%2$s', 'event_espresso' ),
1175
+							__('%1$s%3$sIt appears your browser is not currently set to accept Cookies%4$s%5$sIn order to register for events, you need to enable cookies.%7$sIf you require assistance, then click the following link to learn how to %8$senable cookies%9$s%6$s%2$s', 'event_espresso'),
1176 1176
 							'<div class="ee-attention">',
1177 1177
 							'</div>',
1178 1178
 							'<h6 class="important-notice">',
@@ -1193,7 +1193,7 @@  discard block
 block discarded – undo
1193 1193
 					'layout_strategy' =>
1194 1194
 						new EE_Template_Layout(
1195 1195
 							array(
1196
-								'layout_template_file' 			=> SPCO_TEMPLATES_PATH . 'registration_page_wrapper.template.php',
1196
+								'layout_template_file' 			=> SPCO_TEMPLATES_PATH.'registration_page_wrapper.template.php',
1197 1197
 								'template_args' => array(
1198 1198
 									'empty_cart' 		=> $empty_cart,
1199 1199
 									'revisit' 				=> $this->checkout->revisit,
@@ -1202,8 +1202,8 @@  discard block
 block discarded – undo
1202 1202
 									'empty_msg' 		=> apply_filters(
1203 1203
 										'FHEE__Single_Page_Checkout__display_spco_reg_form__empty_msg',
1204 1204
 										sprintf(
1205
-											__( 'You need to %1$sReturn to Events list%2$sselect at least one event%3$s before you can proceed with the registration process.', 'event_espresso' ),
1206
-											'<a href="' . get_post_type_archive_link( 'espresso_events' ) . '" title="',
1205
+											__('You need to %1$sReturn to Events list%2$sselect at least one event%3$s before you can proceed with the registration process.', 'event_espresso'),
1206
+											'<a href="'.get_post_type_archive_link('espresso_events').'" title="',
1207 1207
 											'">',
1208 1208
 											'</a>'
1209 1209
 										)
@@ -1211,14 +1211,14 @@  discard block
 block discarded – undo
1211 1211
 									'cookies_not_set_msg' 		=> $cookies_not_set_msg,
1212 1212
 									'registration_time_limit' 	=> $this->checkout->get_registration_time_limit(),
1213 1213
 									'session_expiration' 			=>
1214
-										gmdate( 'M d, Y H:i:s', EE_Registry::instance()->SSN->expiration() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) )
1214
+										gmdate('M d, Y H:i:s', EE_Registry::instance()->SSN->expiration() + (get_option('gmt_offset') * HOUR_IN_SECONDS))
1215 1215
 							)
1216 1216
 						)
1217 1217
 					)
1218 1218
 				)
1219 1219
 			);
1220 1220
 			// load template and add to output sent that gets filtered into the_content()
1221
-			EE_Registry::instance()->REQ->add_output( $this->checkout->registration_form->get_html_and_js() );
1221
+			EE_Registry::instance()->REQ->add_output($this->checkout->registration_form->get_html_and_js());
1222 1222
 		}
1223 1223
 	}
1224 1224
 
@@ -1232,8 +1232,8 @@  discard block
 block discarded – undo
1232 1232
 	 * @internal  param string $label
1233 1233
 	 * @return        string
1234 1234
 	 */
1235
-	public function add_extra_finalize_registration_inputs( $next_step ) {
1236
-		if ( $next_step == 'finalize_registration' ) {
1235
+	public function add_extra_finalize_registration_inputs($next_step) {
1236
+		if ($next_step == 'finalize_registration') {
1237 1237
 			echo '<div id="spco-extra-finalize_registration-inputs-dv"></div>';
1238 1238
 		}
1239 1239
 	}
@@ -1247,18 +1247,18 @@  discard block
 block discarded – undo
1247 1247
 	 *  @return 	string
1248 1248
 	 */
1249 1249
 	public static function display_registration_footer() {
1250
-		if ( apply_filters( 'FHEE__EE_Front__Controller__show_reg_footer', EE_Registry::instance()->CFG->admin->show_reg_footer ) ) {
1251
-			EE_Registry::instance()->CFG->admin->affiliate_id = ! empty( EE_Registry::instance()->CFG->admin->affiliate_id ) ? EE_Registry::instance()->CFG->admin->affiliate_id : 'default';
1252
-			$url = add_query_arg( array( 'ap_id' => EE_Registry::instance()->CFG->admin->affiliate_id ), 'https://eventespresso.com/' );
1253
-			$url = apply_filters( 'FHEE__EE_Front_Controller__registration_footer__url', $url );
1250
+		if (apply_filters('FHEE__EE_Front__Controller__show_reg_footer', EE_Registry::instance()->CFG->admin->show_reg_footer)) {
1251
+			EE_Registry::instance()->CFG->admin->affiliate_id = ! empty(EE_Registry::instance()->CFG->admin->affiliate_id) ? EE_Registry::instance()->CFG->admin->affiliate_id : 'default';
1252
+			$url = add_query_arg(array('ap_id' => EE_Registry::instance()->CFG->admin->affiliate_id), 'https://eventespresso.com/');
1253
+			$url = apply_filters('FHEE__EE_Front_Controller__registration_footer__url', $url);
1254 1254
 			echo apply_filters(
1255 1255
 				'FHEE__EE_Front_Controller__display_registration_footer',
1256 1256
 				sprintf(
1257
-					__( '%1$sEvent Registration Powered by Event Espresso%2$sEvent Registration and Ticketing%3$s Powered by %4$sEvent Espresso - Event Registration and Management System for WordPress%5$sEvent Espresso%6$s', 'event_espresso' ),
1258
-					'<div id="espresso-registration-footer-dv"><a href="' . $url . '" title="',
1257
+					__('%1$sEvent Registration Powered by Event Espresso%2$sEvent Registration and Ticketing%3$s Powered by %4$sEvent Espresso - Event Registration and Management System for WordPress%5$sEvent Espresso%6$s', 'event_espresso'),
1258
+					'<div id="espresso-registration-footer-dv"><a href="'.$url.'" title="',
1259 1259
 					'" target="_blank">',
1260 1260
 					'</a>',
1261
-					'<a href="' . $url . '" title="',
1261
+					'<a href="'.$url.'" title="',
1262 1262
 					'" target="_blank">',
1263 1263
 					'</a></div>'
1264 1264
 				)
@@ -1289,12 +1289,12 @@  discard block
 block discarded – undo
1289 1289
 	 * @return 	array
1290 1290
 	 */
1291 1291
 	private function _setup_redirect() {
1292
-		if ( $this->checkout->continue_reg && $this->checkout->next_step instanceof EE_SPCO_Reg_Step ) {
1292
+		if ($this->checkout->continue_reg && $this->checkout->next_step instanceof EE_SPCO_Reg_Step) {
1293 1293
 			$this->checkout->redirect = TRUE;
1294
-			if ( empty( $this->checkout->redirect_url )) {
1294
+			if (empty($this->checkout->redirect_url)) {
1295 1295
 				$this->checkout->redirect_url = $this->checkout->next_step->reg_step_url();
1296 1296
 			}
1297
-			$this->checkout->redirect_url = apply_filters( 'FHEE__EED_Single_Page_Checkout___setup_redirect__checkout_redirect_url', $this->checkout->redirect_url, $this->checkout );
1297
+			$this->checkout->redirect_url = apply_filters('FHEE__EED_Single_Page_Checkout___setup_redirect__checkout_redirect_url', $this->checkout->redirect_url, $this->checkout);
1298 1298
 		}
1299 1299
 	}
1300 1300
 
@@ -1307,12 +1307,12 @@  discard block
 block discarded – undo
1307 1307
 	 * @return void
1308 1308
 	 */
1309 1309
 	public function go_to_next_step() {
1310
-		if ( EE_Registry::instance()->REQ->ajax ) {
1310
+		if (EE_Registry::instance()->REQ->ajax) {
1311 1311
 			// capture contents of output buffer we started earlier in the request, and insert into JSON response
1312
-			$this->checkout->json_response->set_unexpected_errors( ob_get_clean() );
1312
+			$this->checkout->json_response->set_unexpected_errors(ob_get_clean());
1313 1313
 		}
1314 1314
 		// just return for these conditions
1315
-		if ( $this->checkout->admin_request || $this->checkout->action == 'redirect_form' || $this->checkout->action == 'update_checkout' ) {
1315
+		if ($this->checkout->admin_request || $this->checkout->action == 'redirect_form' || $this->checkout->action == 'update_checkout') {
1316 1316
 			return;
1317 1317
 		}
1318 1318
 		// AJAX response
@@ -1333,7 +1333,7 @@  discard block
 block discarded – undo
1333 1333
 	 */
1334 1334
 	protected function _handle_json_response() {
1335 1335
 		// if this is an ajax request
1336
-		if ( EE_Registry::instance()->REQ->ajax ) {
1336
+		if (EE_Registry::instance()->REQ->ajax) {
1337 1337
 			// DEBUG LOG
1338 1338
 			//$this->checkout->log(
1339 1339
 			//	__CLASS__, __FUNCTION__, __LINE__,
@@ -1343,10 +1343,10 @@  discard block
 block discarded – undo
1343 1343
 			//		'continue_reg'               => $this->checkout->continue_reg,
1344 1344
 			//	)
1345 1345
 			//);
1346
-			$this->checkout->json_response->set_registration_time_limit( $this->checkout->get_registration_time_limit() );
1347
-			$this->checkout->json_response->set_payment_amount( $this->checkout->amount_owing );
1346
+			$this->checkout->json_response->set_registration_time_limit($this->checkout->get_registration_time_limit());
1347
+			$this->checkout->json_response->set_payment_amount($this->checkout->amount_owing);
1348 1348
 			// just send the ajax (
1349
-			$json_response = apply_filters( 'FHEE__EE_Single_Page_Checkout__JSON_response', $this->checkout->json_response );
1349
+			$json_response = apply_filters('FHEE__EE_Single_Page_Checkout__JSON_response', $this->checkout->json_response);
1350 1350
 			$this->unlock_transaction();
1351 1351
 			echo $json_response;
1352 1352
 			exit();
@@ -1363,9 +1363,9 @@  discard block
 block discarded – undo
1363 1363
 	 */
1364 1364
 	protected function _handle_html_redirects() {
1365 1365
 		// going somewhere ?
1366
-		if ( $this->checkout->redirect && ! empty( $this->checkout->redirect_url ) ) {
1366
+		if ($this->checkout->redirect && ! empty($this->checkout->redirect_url)) {
1367 1367
 			// store notices in a transient
1368
-			EE_Error::get_notices( false, true, true );
1368
+			EE_Error::get_notices(false, true, true);
1369 1369
 			$this->unlock_transaction();
1370 1370
 			// DEBUG LOG
1371 1371
 			//$this->checkout->log(
@@ -1376,7 +1376,7 @@  discard block
 block discarded – undo
1376 1376
 			//		'headers_list'    => headers_list(),
1377 1377
 			//	)
1378 1378
 			//);
1379
-			wp_safe_redirect( $this->checkout->redirect_url );
1379
+			wp_safe_redirect($this->checkout->redirect_url);
1380 1380
 			exit();
1381 1381
 		}
1382 1382
 	}
Please login to merge, or discard this patch.