Completed
Branch TASK-9118-extensions-page (b89c2b)
by
unknown
506:56 queued 485:08
created
reg_steps/payment_options/EE_SPCO_Reg_Step_Payment_Options.class.php 1 patch
Spacing   +370 added lines, -370 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,27 +1496,27 @@  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
 			if (
1506 1506
 				$payment->status() != EEM_Payment::status_id_approved
1507 1507
 				&& $payment->status() != EEM_Payment::status_id_pending
1508 1508
 				&& $payment->status() != EEM_Payment::status_id_cancelled
1509 1509
 				&& $payment->gateway_response() != ''
1510 1510
 			) {
1511
-				EE_Error::add_error( $payment->gateway_response(), __FILE__, __FUNCTION__, __LINE__ );
1511
+				EE_Error::add_error($payment->gateway_response(), __FILE__, __FUNCTION__, __LINE__);
1512 1512
 			}
1513 1513
 		} else {
1514 1514
 			// not a payment
1515 1515
 			EE_Error::add_error(
1516 1516
 				sprintf(
1517
-					__( 'A valid payment was not generated due to a technical issue.%1$sPlease try again or contact %2$s for assistance.', 'event_espresso' ),
1517
+					__('A valid payment was not generated due to a technical issue.%1$sPlease try again or contact %2$s for assistance.', 'event_espresso'),
1518 1518
 					'<br/>',
1519
-					EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
1519
+					EE_Registry::instance()->CFG->organization->get_pretty('email')
1520 1520
 				), __FILE__, __FUNCTION__, __LINE__
1521 1521
 			);
1522 1522
 			return FALSE;
@@ -1533,23 +1533,23 @@  discard block
 block discarded – undo
1533 1533
 	 * @param EE_Payment $payment
1534 1534
 	 * @return bool
1535 1535
 	 */
1536
-	private function _post_payment_processing( $payment = NULL ) {
1536
+	private function _post_payment_processing($payment = NULL) {
1537 1537
 		// On-Site payment?
1538
-		if ( $this->checkout->payment_method->is_on_site() ) {
1539
-			if ( ! $this->_process_payment_status( $payment, EE_PMT_Base::onsite )) {
1538
+		if ($this->checkout->payment_method->is_on_site()) {
1539
+			if ( ! $this->_process_payment_status($payment, EE_PMT_Base::onsite)) {
1540 1540
 				//$this->_setup_redirect_for_next_step();
1541 1541
 				$this->checkout->continue_reg = false;
1542 1542
 			}
1543 1543
 			// Off-Site payment?
1544
-		} else if ( $this->checkout->payment_method->is_off_site() ) {
1544
+		} else if ($this->checkout->payment_method->is_off_site()) {
1545 1545
 			// if a payment object was made and it specifies a redirect url, then we'll setup that redirect info
1546
-			if ( $payment instanceof EE_Payment && $payment->redirect_url() ){
1547
-				do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $payment->redirect_url(), '$payment->redirect_url()' );
1546
+			if ($payment instanceof EE_Payment && $payment->redirect_url()) {
1547
+				do_action('AHEE_log', __CLASS__, __FUNCTION__, $payment->redirect_url(), '$payment->redirect_url()');
1548 1548
 				$this->checkout->redirect = TRUE;
1549 1549
 				$this->checkout->redirect_form = $payment->redirect_form();
1550
-				$this->checkout->redirect_url = $this->reg_step_url( 'redirect_form' );
1550
+				$this->checkout->redirect_url = $this->reg_step_url('redirect_form');
1551 1551
 				// set JSON response
1552
-				$this->checkout->json_response->set_redirect_form( $this->checkout->redirect_form );
1552
+				$this->checkout->json_response->set_redirect_form($this->checkout->redirect_form);
1553 1553
 				// set cron job for finalizing the TXN
1554 1554
 				// in case the user does not return from the off-site gateway
1555 1555
 				EE_Cron_Tasks::schedule_finalize_abandoned_transactions_check(
@@ -1557,21 +1557,21 @@  discard block
 block discarded – undo
1557 1557
 					$this->checkout->transaction->ID()
1558 1558
 				);
1559 1559
 				// and lastly, let's bump the payment status to pending
1560
-				$payment->set_status( EEM_Payment::status_id_pending );
1560
+				$payment->set_status(EEM_Payment::status_id_pending);
1561 1561
 				$payment->save();
1562 1562
 			} else {
1563 1563
 				// not a payment
1564 1564
 				$this->checkout->continue_reg = false;
1565 1565
 				EE_Error::add_error(
1566 1566
 					sprintf(
1567
-						__( 'It appears the Off Site Payment Method was not configured properly.%sPlease try again or contact %s for assistance.', 'event_espresso' ),
1567
+						__('It appears the Off Site Payment Method was not configured properly.%sPlease try again or contact %s for assistance.', 'event_espresso'),
1568 1568
 						'<br/>',
1569
-						EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
1569
+						EE_Registry::instance()->CFG->organization->get_pretty('email')
1570 1570
 					), __FILE__, __FUNCTION__, __LINE__
1571 1571
 				);
1572 1572
 			}
1573 1573
 			// Off-Line payment?
1574
-		} else if ( $payment === TRUE ) {
1574
+		} else if ($payment === TRUE) {
1575 1575
 			//$this->_setup_redirect_for_next_step();
1576 1576
 			return TRUE;
1577 1577
 		} else {
@@ -1607,65 +1607,65 @@  discard block
 block discarded – undo
1607 1607
 	 * @return bool
1608 1608
 	 * @throws \EE_Error
1609 1609
 	 */
1610
-	private function _process_payment_status( $payment, $payment_occurs = EE_PMT_Base::offline ) {
1610
+	private function _process_payment_status($payment, $payment_occurs = EE_PMT_Base::offline) {
1611 1611
 		// off-line payment? carry on
1612
-		if ( $payment_occurs == EE_PMT_Base::offline ) {
1612
+		if ($payment_occurs == EE_PMT_Base::offline) {
1613 1613
 			return true;
1614 1614
 		}
1615 1615
 		// verify payment validity
1616
-		if ( $payment instanceof EE_Payment ) {
1617
-			do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $payment->status(), '$payment->status()' );
1616
+		if ($payment instanceof EE_Payment) {
1617
+			do_action('AHEE_log', __CLASS__, __FUNCTION__, $payment->status(), '$payment->status()');
1618 1618
 			$msg = $payment->gateway_response();
1619 1619
 			// check results
1620
-			switch ( $payment->status() ) {
1620
+			switch ($payment->status()) {
1621 1621
 
1622 1622
 				// good payment
1623 1623
 				case EEM_Payment::status_id_approved :
1624
-					EE_Error::add_success( __( 'Your payment was processed successfully.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
1624
+					EE_Error::add_success(__('Your payment was processed successfully.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1625 1625
 					return TRUE;
1626 1626
 					break;
1627 1627
 
1628 1628
 				// slow payment
1629 1629
 				case EEM_Payment::status_id_pending :
1630
-					if ( empty( $msg )) {
1631
-						$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' );
1630
+					if (empty($msg)) {
1631
+						$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');
1632 1632
 					}
1633
-					EE_Error::add_success( $msg, __FILE__, __FUNCTION__, __LINE__ );
1633
+					EE_Error::add_success($msg, __FILE__, __FUNCTION__, __LINE__);
1634 1634
 					return TRUE;
1635 1635
 					break;
1636 1636
 
1637 1637
 				// don't wanna payment
1638 1638
 				case EEM_Payment::status_id_cancelled :
1639
-					if ( empty( $msg )) {
1639
+					if (empty($msg)) {
1640 1640
 						$msg = _n(
1641 1641
 							'Payment cancelled. Please try again.',
1642 1642
 							'Payment cancelled. Please try again or select another method of payment.',
1643
-							count( $this->checkout->available_payment_methods ),
1643
+							count($this->checkout->available_payment_methods),
1644 1644
 							'event_espresso'
1645 1645
 						);
1646 1646
 					}
1647
-					EE_Error::add_attention( $msg, __FILE__, __FUNCTION__, __LINE__ );
1647
+					EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__);
1648 1648
 					return FALSE;
1649 1649
 					break;
1650 1650
 
1651 1651
 				// not enough payment
1652 1652
 				case EEM_Payment::status_id_declined :
1653
-					if ( empty( $msg )) {
1653
+					if (empty($msg)) {
1654 1654
 						$msg = _n(
1655 1655
 							'We\'re sorry but your payment was declined. Please try again.',
1656 1656
 							'We\'re sorry but your payment was declined. Please try again or select another method of payment.',
1657
-							count( $this->checkout->available_payment_methods ),
1657
+							count($this->checkout->available_payment_methods),
1658 1658
 							'event_espresso'
1659 1659
 						);
1660 1660
 					}
1661
-					EE_Error::add_attention( $msg, __FILE__, __FUNCTION__, __LINE__ );
1661
+					EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__);
1662 1662
 					return FALSE;
1663 1663
 					break;
1664 1664
 
1665 1665
 				// bad payment
1666 1666
 				case EEM_Payment::status_id_failed :
1667
-					if ( ! empty( $msg ) ) {
1668
-						EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
1667
+					if ( ! empty($msg)) {
1668
+						EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1669 1669
 						return false;
1670 1670
 					}
1671 1671
 					// default to error below
@@ -1675,14 +1675,14 @@  discard block
 block discarded – undo
1675 1675
 		}
1676 1676
 		// off-site payment gateway responses are too unreliable, so let's just assume that
1677 1677
 		// the payment processing is just running slower than the registrant's request
1678
-		if ( $payment_occurs == EE_PMT_Base::offsite ) {
1678
+		if ($payment_occurs == EE_PMT_Base::offsite) {
1679 1679
 			return true;
1680 1680
 		}
1681 1681
 		EE_Error::add_error(
1682 1682
 				sprintf(
1683
-					__( 'Your payment could not be processed successfully due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso' ),
1683
+					__('Your payment could not be processed successfully due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso'),
1684 1684
 					'<br/>',
1685
-					EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
1685
+					EE_Registry::instance()->CFG->organization->get_pretty('email')
1686 1686
 				),
1687 1687
 				__FILE__, __FUNCTION__, __LINE__
1688 1688
 			);
@@ -1715,13 +1715,13 @@  discard block
 block discarded – undo
1715 1715
 	public function process_gateway_response() {
1716 1716
 		$payment = null;
1717 1717
 		// how have they chosen to pay?
1718
-		$this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( true );
1718
+		$this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true);
1719 1719
 		// get EE_Payment_Method object
1720
-		if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment() ) {
1720
+		if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) {
1721 1721
 			$this->checkout->continue_reg = false;
1722 1722
 			return false;
1723 1723
 		}
1724
-		if ( ! $this->checkout->payment_method->is_off_site() ) {
1724
+		if ( ! $this->checkout->payment_method->is_off_site()) {
1725 1725
 			return false;
1726 1726
 		}
1727 1727
 		$this->_validate_offsite_return();
@@ -1735,23 +1735,23 @@  discard block
 block discarded – undo
1735 1735
 		//	true
1736 1736
 		//);
1737 1737
 		// verify TXN
1738
-		if ( $this->checkout->transaction instanceof EE_Transaction ) {
1738
+		if ($this->checkout->transaction instanceof EE_Transaction) {
1739 1739
 			$gateway = $this->checkout->payment_method->type_obj()->get_gateway();
1740
-			if ( ! $gateway instanceof EE_Offsite_Gateway ) {
1740
+			if ( ! $gateway instanceof EE_Offsite_Gateway) {
1741 1741
 				$this->checkout->continue_reg = false;
1742 1742
 				return false;
1743 1743
 			}
1744
-			$payment = $this->_process_off_site_payment( $gateway );
1745
-			$payment = $this->_process_cancelled_payments( $payment );
1746
-			$payment = $this->_validate_payment( $payment );
1744
+			$payment = $this->_process_off_site_payment($gateway);
1745
+			$payment = $this->_process_cancelled_payments($payment);
1746
+			$payment = $this->_validate_payment($payment);
1747 1747
 			// if payment was not declined by the payment gateway or cancelled by the registrant
1748
-			if ( $this->_process_payment_status( $payment, EE_PMT_Base::offsite ) ) {
1748
+			if ($this->_process_payment_status($payment, EE_PMT_Base::offsite)) {
1749 1749
 				//$this->_setup_redirect_for_next_step();
1750 1750
 				// store that for later
1751 1751
 				$this->checkout->payment = $payment;
1752 1752
 				// mark this reg step as completed, as long as gateway doesn't use a separate IPN request,
1753 1753
 				// because we will complete this step during the IPN processing then
1754
-				if ( $gateway instanceof EE_Offsite_Gateway && ! $gateway->uses_separate_IPN_request() ) {
1754
+				if ($gateway instanceof EE_Offsite_Gateway && ! $gateway->uses_separate_IPN_request()) {
1755 1755
 					$this->set_completed();
1756 1756
 				}
1757 1757
 				return true;
@@ -1774,19 +1774,19 @@  discard block
 block discarded – undo
1774 1774
 	 * @return bool
1775 1775
 	 */
1776 1776
 	private function _validate_offsite_return() {
1777
-		$TXN_ID = (int)EE_Registry::instance()->REQ->get( 'spco_txn', 0 );
1778
-		if ( $TXN_ID != $this->checkout->transaction->ID() ) {
1777
+		$TXN_ID = (int) EE_Registry::instance()->REQ->get('spco_txn', 0);
1778
+		if ($TXN_ID != $this->checkout->transaction->ID()) {
1779 1779
 			// Houston... we might have a problem
1780 1780
 			$invalid_TXN = false;
1781 1781
 			// first gather some info
1782
-			$valid_TXN = EEM_Transaction::instance()->get_one_by_ID( $TXN_ID );
1782
+			$valid_TXN = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
1783 1783
 			$primary_registrant = $valid_TXN instanceof EE_Transaction ? $valid_TXN->primary_registration() : null;
1784 1784
 			// let's start by retrieving the cart for this TXN
1785
-			$cart = EE_Cart::get_cart_from_txn( $this->checkout->transaction );
1786
-			if ( $cart instanceof EE_Cart ) {
1785
+			$cart = EE_Cart::get_cart_from_txn($this->checkout->transaction);
1786
+			if ($cart instanceof EE_Cart) {
1787 1787
 				// verify that the current cart has tickets
1788 1788
 				$tickets = $cart->get_tickets();
1789
-				if ( empty( $tickets ) ) {
1789
+				if (empty($tickets)) {
1790 1790
 					$invalid_TXN = true;
1791 1791
 				}
1792 1792
 			} else {
@@ -1794,39 +1794,39 @@  discard block
 block discarded – undo
1794 1794
 			}
1795 1795
 			$valid_TXN_SID = $primary_registrant instanceof EE_Registration ? $primary_registrant->session_ID() : null;
1796 1796
 			// validate current Session ID and compare against valid TXN session ID
1797
-			if ( EE_Session::instance()->id() === null ) {
1797
+			if (EE_Session::instance()->id() === null) {
1798 1798
 				$invalid_TXN = true;
1799
-			} else if ( EE_Session::instance()->id() === $valid_TXN_SID ) {
1799
+			} else if (EE_Session::instance()->id() === $valid_TXN_SID) {
1800 1800
 				// WARNING !!!
1801 1801
 				// this could be PayPal sending back duplicate requests (ya they do that)
1802 1802
 				// or it **could** mean someone is simply registering AGAIN after having just done so
1803 1803
 				// so now we need to determine if this current TXN looks valid or not
1804 1804
 				/** @type EE_Transaction_Processor $transaction_processor */
1805
-				$transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' );
1805
+				$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
1806 1806
 				// has this step even been started ?
1807
-				if ( $transaction_processor->reg_step_completed( $this->checkout->transaction, $this->slug() === false )
1807
+				if ($transaction_processor->reg_step_completed($this->checkout->transaction, $this->slug() === false)
1808 1808
 				) {
1809 1809
 					// really? you're half way through this reg step, but you never started it ?
1810 1810
 					$invalid_TXN = true;
1811 1811
 				}
1812 1812
 			}
1813
-			if ( $invalid_TXN ) {
1813
+			if ($invalid_TXN) {
1814 1814
 				// is the valid TXN completed ?
1815
-				if ( $valid_TXN instanceof EE_Transaction ) {
1815
+				if ($valid_TXN instanceof EE_Transaction) {
1816 1816
 					/** @type EE_Transaction_Processor $transaction_processor */
1817
-					$transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' );
1817
+					$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
1818 1818
 					// has this step even been started ?
1819
-					$reg_step_completed = $transaction_processor->reg_step_completed( $valid_TXN, $this->slug() );
1820
-					if ( $reg_step_completed !== false && $reg_step_completed !== true ) {
1819
+					$reg_step_completed = $transaction_processor->reg_step_completed($valid_TXN, $this->slug());
1820
+					if ($reg_step_completed !== false && $reg_step_completed !== true) {
1821 1821
 						// so it **looks** like this is a double request from PayPal
1822 1822
 						// so let's try to pick up where we left off
1823 1823
 						$this->checkout->transaction = $valid_TXN;
1824
-						$this->checkout->refresh_all_entities( true );
1824
+						$this->checkout->refresh_all_entities(true);
1825 1825
 						return;
1826 1826
 					}
1827 1827
 				}
1828 1828
 				// you appear to be lost?
1829
-				$this->_redirect_wayward_request( $primary_registrant );
1829
+				$this->_redirect_wayward_request($primary_registrant);
1830 1830
 			}
1831 1831
 		}
1832 1832
 	}
@@ -1840,16 +1840,16 @@  discard block
 block discarded – undo
1840 1840
 	 * @param \EE_Registration $primary_registrant
1841 1841
 	 * @return bool
1842 1842
 	 */
1843
-	private function _redirect_wayward_request( EE_Registration $primary_registrant ) {
1844
-		if ( ! $primary_registrant instanceof EE_Registration ) {
1843
+	private function _redirect_wayward_request(EE_Registration $primary_registrant) {
1844
+		if ( ! $primary_registrant instanceof EE_Registration) {
1845 1845
 			// try redirecting based on the current TXN
1846 1846
 			$primary_registrant = $this->checkout->transaction instanceof EE_Transaction ? $this->checkout->transaction->primary_registration() : null;
1847
-			if ( ! $primary_registrant instanceof EE_Registration ) {
1847
+			if ( ! $primary_registrant instanceof EE_Registration) {
1848 1848
 				EE_Error::add_error(
1849 1849
 					sprintf(
1850
-						__( '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' ),
1850
+						__('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'),
1851 1851
 						'<br/>',
1852
-						EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
1852
+						EE_Registry::instance()->CFG->organization->get_pretty('email')
1853 1853
 					),
1854 1854
 					__FILE__, __FUNCTION__, __LINE__
1855 1855
 				);
@@ -1877,16 +1877,16 @@  discard block
 block discarded – undo
1877 1877
 	 * @param \EE_Offsite_Gateway $gateway
1878 1878
 	 * @return \EE_Payment
1879 1879
 	 */
1880
-	private function _process_off_site_payment( EE_Offsite_Gateway $gateway ) {
1880
+	private function _process_off_site_payment(EE_Offsite_Gateway $gateway) {
1881 1881
 		try {
1882 1882
 			// if gateway uses_separate_IPN_request, then we don't have to process the IPN manually
1883
-			if ( $gateway instanceof EE_Offsite_Gateway && $gateway->uses_separate_IPN_request() ) {
1883
+			if ($gateway instanceof EE_Offsite_Gateway && $gateway->uses_separate_IPN_request()) {
1884 1884
 				$payment = $this->checkout->transaction->last_payment();
1885 1885
 				//$payment_source = 'last_payment';
1886 1886
 			} else {
1887 1887
 				// get payment details and process results
1888 1888
 				/** @type EE_Payment_Processor $payment_processor */
1889
-				$payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' );
1889
+				$payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
1890 1890
 				$payment = $payment_processor->process_ipn(
1891 1891
 					$_REQUEST,
1892 1892
 					$this->checkout->transaction,
@@ -1896,14 +1896,14 @@  discard block
 block discarded – undo
1896 1896
 				);
1897 1897
 				//$payment_source = 'process_ipn';
1898 1898
 			}
1899
-		} catch ( Exception $e ) {
1899
+		} catch (Exception $e) {
1900 1900
 			// let's just eat the exception and try to move on using any previously set payment info
1901 1901
 			$payment = $this->checkout->transaction->last_payment();
1902 1902
 			//$payment_source = 'last_payment after Exception';
1903 1903
 			// but if we STILL don't have a payment object
1904
-			if ( ! $payment instanceof EE_Payment ) {
1904
+			if ( ! $payment instanceof EE_Payment) {
1905 1905
 				// then we'll object ! ( not object like a thing... but object like what a lawyer says ! )
1906
-				$this->_handle_payment_processor_exception( $e );
1906
+				$this->_handle_payment_processor_exception($e);
1907 1907
 			}
1908 1908
 		}
1909 1909
 		// DEBUG LOG
@@ -1927,13 +1927,13 @@  discard block
 block discarded – undo
1927 1927
 	 * @param EE_Payment $payment
1928 1928
 	 * @return EE_Payment | FALSE
1929 1929
 	 */
1930
-	private function _process_cancelled_payments( $payment = NULL ) {
1930
+	private function _process_cancelled_payments($payment = NULL) {
1931 1931
 		if (
1932
-			isset( $_REQUEST[ 'ee_cancel_payment' ] )
1932
+			isset($_REQUEST['ee_cancel_payment'])
1933 1933
 			&& $payment instanceof EE_Payment
1934 1934
 			&& $payment->status() == EEM_Payment::status_id_failed
1935 1935
 		) {
1936
-			$payment->set_status( EEM_Payment::status_id_cancelled );
1936
+			$payment->set_status(EEM_Payment::status_id_cancelled);
1937 1937
 		}
1938 1938
 		return $payment;
1939 1939
 	}
@@ -1950,23 +1950,23 @@  discard block
 block discarded – undo
1950 1950
 	public function get_transaction_details_for_gateways() {
1951 1951
 		$txn_details = array();
1952 1952
 		// ya gotta make a choice man
1953
-		if ( empty( $this->checkout->selected_method_of_payment ) ) {
1953
+		if (empty($this->checkout->selected_method_of_payment)) {
1954 1954
 			$txn_details = array(
1955
-				'error' => __( 'Please select a method of payment before proceeding.', 'event_espresso' )
1955
+				'error' => __('Please select a method of payment before proceeding.', 'event_espresso')
1956 1956
 			);
1957 1957
 		}
1958 1958
 		// get EE_Payment_Method object
1959 1959
 		if (
1960
-			empty( $txn_details ) &&
1960
+			empty($txn_details) &&
1961 1961
 			! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()
1962 1962
 		) {
1963 1963
 			$txn_details = array(
1964 1964
 				'selected_method_of_payment' => $this->checkout->selected_method_of_payment,
1965
-				'error' => __( 'A valid Payment Method could not be determined.', 'event_espresso' )
1965
+				'error' => __('A valid Payment Method could not be determined.', 'event_espresso')
1966 1966
 			);
1967 1967
 		}
1968
-		if ( empty( $txn_details ) && $this->checkout->transaction instanceof EE_Transaction ) {
1969
-			$return_url = $this->_get_return_url( $this->checkout->payment_method );
1968
+		if (empty($txn_details) && $this->checkout->transaction instanceof EE_Transaction) {
1969
+			$return_url = $this->_get_return_url($this->checkout->payment_method);
1970 1970
 			$txn_details = array(
1971 1971
 				'TXN_ID'        			=> $this->checkout->transaction->ID(),
1972 1972
 				'TXN_timestamp' 	=> $this->checkout->transaction->datetime(),
@@ -1977,7 +1977,7 @@  discard block
 block discarded – undo
1977 1977
 				'PMD_ID'        			=> $this->checkout->transaction->payment_method_ID(),
1978 1978
 				'payment_amount' => $this->checkout->amount_owing,
1979 1979
 				'return_url' 				=> $return_url,
1980
-				'cancel_url' 				=> add_query_arg( array( 'ee_cancel_payment' => true ), $return_url ),
1980
+				'cancel_url' 				=> add_query_arg(array('ee_cancel_payment' => true), $return_url),
1981 1981
 				'notify_url' 				=> EE_Config::instance()->core->txn_page_url(
1982 1982
 					array(
1983 1983
 						'e_reg_url_link'    			=> $this->checkout->transaction->primary_registration()->reg_url_link(),
@@ -1986,7 +1986,7 @@  discard block
 block discarded – undo
1986 1986
 				)
1987 1987
 			);
1988 1988
 		}
1989
-		echo json_encode( $txn_details );
1989
+		echo json_encode($txn_details);
1990 1990
 		exit();
1991 1991
 	}
1992 1992
 
Please login to merge, or discard this patch.
libraries/line_item_display/EE_SPCO_Line_Item_Display_Strategy.strategy.php 1 patch
Spacing   +120 added lines, -120 removed lines patch added patch discarded remove patch
@@ -69,104 +69,104 @@  discard block
 block discarded – undo
69 69
 	 * @param array        $options
70 70
 	 * @return mixed
71 71
 	 */
72
-	public function display_line_item( EE_Line_Item $line_item, $options = array() ) {
72
+	public function display_line_item(EE_Line_Item $line_item, $options = array()) {
73 73
 
74
-		EE_Registry::instance()->load_helper( 'Template' );
75
-		EE_Registry::instance()->load_helper( 'HTML' );
74
+		EE_Registry::instance()->load_helper('Template');
75
+		EE_Registry::instance()->load_helper('HTML');
76 76
 
77 77
 		$html = '';
78 78
 		// set some default options and merge with incoming
79 79
 		$default_options = array(
80
-			'show_desc' => true,  // 	true 		false
80
+			'show_desc' => true, // 	true 		false
81 81
 			'odd' => false
82 82
 		);
83
-		$options = array_merge( $default_options, (array)$options );
83
+		$options = array_merge($default_options, (array) $options);
84 84
 
85
-		switch( $line_item->type() ) {
85
+		switch ($line_item->type()) {
86 86
 
87 87
 			case EEM_Line_Item::type_line_item:
88 88
 				$this->_show_taxes = $line_item->is_taxable() ? true : $this->_show_taxes;
89
-				if ( $line_item->OBJ_type() == 'Ticket' ) {
89
+				if ($line_item->OBJ_type() == 'Ticket') {
90 90
 					// item row
91
-					$html .= $this->_ticket_row( $line_item, $options );
91
+					$html .= $this->_ticket_row($line_item, $options);
92 92
 					// got any kids?
93
-					foreach ( $line_item->children() as $child_line_item ) {
94
-						$this->display_line_item( $child_line_item, $options );
93
+					foreach ($line_item->children() as $child_line_item) {
94
+						$this->display_line_item($child_line_item, $options);
95 95
 					}
96 96
 				} else {
97 97
 					// item row
98
-					$html .= $this->_item_row( $line_item, $options );
98
+					$html .= $this->_item_row($line_item, $options);
99 99
 					// got any kids?
100
-					foreach ( $line_item->children() as $child_line_item ) {
101
-						$this->display_line_item( $child_line_item, $options );
100
+					foreach ($line_item->children() as $child_line_item) {
101
+						$this->display_line_item($child_line_item, $options);
102 102
 					}
103 103
 				}
104 104
 				break;
105 105
 
106 106
 			case EEM_Line_Item::type_sub_line_item:
107
-				$html .= $this->_sub_item_row( $line_item, $options );
107
+				$html .= $this->_sub_item_row($line_item, $options);
108 108
 				break;
109 109
 
110 110
 			case EEM_Line_Item::type_sub_total:
111 111
 				static $sub_total = 0;
112 112
 				$event_sub_total = 0;
113
-				$text = __( 'Sub-Total', 'event_espresso' );
114
-				if ( $line_item->OBJ_type() == 'Event' ) {
115
-					$options[ 'event_id' ] = $event_id = $line_item->OBJ_ID();
116
-					if ( ! isset( $this->_events[ $options[ 'event_id' ] ] ) ) {
117
-						$event = EEM_Event::instance()->get_one_by_ID( $options[ 'event_id' ] );
118
-						if ( $event instanceof EE_Event ) {
119
-							if ( $event->default_registration_status() == EEM_Registration::status_id_not_approved ) {
113
+				$text = __('Sub-Total', 'event_espresso');
114
+				if ($line_item->OBJ_type() == 'Event') {
115
+					$options['event_id'] = $event_id = $line_item->OBJ_ID();
116
+					if ( ! isset($this->_events[$options['event_id']])) {
117
+						$event = EEM_Event::instance()->get_one_by_ID($options['event_id']);
118
+						if ($event instanceof EE_Event) {
119
+							if ($event->default_registration_status() == EEM_Registration::status_id_not_approved) {
120 120
 								return '';
121 121
 							}
122 122
 						}
123
-						$this->_events[ $options[ 'event_id' ] ] = 0;
124
-						$html .= $this->_event_row( $line_item );
125
-						$text = __( 'Event Sub-Total', 'event_espresso' );
123
+						$this->_events[$options['event_id']] = 0;
124
+						$html .= $this->_event_row($line_item);
125
+						$text = __('Event Sub-Total', 'event_espresso');
126 126
 					}
127 127
 				}
128 128
 				$child_line_items = $line_item->children();
129 129
 				// loop thru children
130
-				foreach( $child_line_items as $child_line_item ) {
130
+				foreach ($child_line_items as $child_line_item) {
131 131
 					// recursively feed children back into this method
132
-					$html .= $this->display_line_item( $child_line_item, $options );
132
+					$html .= $this->display_line_item($child_line_item, $options);
133 133
 				}
134
-				$event_sub_total += isset( $options[ 'event_id' ] ) ? $this->_events[ $options[ 'event_id' ] ] : 0;
134
+				$event_sub_total += isset($options['event_id']) ? $this->_events[$options['event_id']] : 0;
135 135
 				$sub_total += $event_sub_total;
136 136
 				if (
137 137
 					(
138 138
 						// event subtotals
139 139
 						$line_item->code() != 'pre-tax-subtotal' &&
140
-						count( $child_line_items ) > 1
140
+						count($child_line_items) > 1
141 141
 					)
142 142
 					||
143 143
 					(
144 144
 						// pre-tax subtotals
145 145
 						$line_item->code() == 'pre-tax-subtotal' &&
146
-						count( $this->_events ) > 1
146
+						count($this->_events) > 1
147 147
 					)
148 148
 				) {
149 149
 					$options['sub_total'] = $line_item->OBJ_type() == 'Event' ? $event_sub_total : $sub_total;
150
-					$html .= $this->_sub_total_row( $line_item, $text, $options );
150
+					$html .= $this->_sub_total_row($line_item, $text, $options);
151 151
 				}
152 152
 				break;
153 153
 
154 154
 			case EEM_Line_Item::type_tax:
155
-				if ( $this->_show_taxes ) {
156
-					$this->_taxes_html .= $this->_tax_row( $line_item, $options );
155
+				if ($this->_show_taxes) {
156
+					$this->_taxes_html .= $this->_tax_row($line_item, $options);
157 157
 				}
158 158
 				break;
159 159
 
160 160
 			case EEM_Line_Item::type_tax_sub_total:
161
-				if ( $this->_show_taxes ) {
161
+				if ($this->_show_taxes) {
162 162
 					$child_line_items = $line_item->children();
163 163
 					// loop thru children
164
-					foreach( $child_line_items as $child_line_item ) {
164
+					foreach ($child_line_items as $child_line_item) {
165 165
 						// recursively feed children back into this method
166
-						$html .= $this->display_line_item( $child_line_item, $options );
166
+						$html .= $this->display_line_item($child_line_item, $options);
167 167
 					}
168
-					if ( count( $child_line_items ) > 1 ) {
169
-						$this->_taxes_html .= $this->_total_tax_row( $line_item, __( 'Tax Total', 'event_espresso' ) );
168
+					if (count($child_line_items) > 1) {
169
+						$this->_taxes_html .= $this->_total_tax_row($line_item, __('Tax Total', 'event_espresso'));
170 170
 					}
171 171
 				}
172 172
 				break;
@@ -175,25 +175,25 @@  discard block
 block discarded – undo
175 175
 				// get all child line items
176 176
 				$children = $line_item->children();
177 177
 				// loop thru all non-tax child line items
178
-				foreach( $children as $child_line_item ) {
179
-					if ( $child_line_item->type() != EEM_Line_Item::type_tax_sub_total ) {
178
+				foreach ($children as $child_line_item) {
179
+					if ($child_line_item->type() != EEM_Line_Item::type_tax_sub_total) {
180 180
 						// recursively feed children back into this method
181
-						$html .= $this->display_line_item( $child_line_item, $options );
181
+						$html .= $this->display_line_item($child_line_item, $options);
182 182
 					}
183 183
 				}
184 184
 
185 185
 				// now loop thru  tax child line items
186
-				foreach( $children as $child_line_item ) {
187
-					if ( $child_line_item->type() == EEM_Line_Item::type_tax_sub_total ) {
186
+				foreach ($children as $child_line_item) {
187
+					if ($child_line_item->type() == EEM_Line_Item::type_tax_sub_total) {
188 188
 						// recursively feed children back into this method
189
-						$html .= $this->display_line_item( $child_line_item, $options );
189
+						$html .= $this->display_line_item($child_line_item, $options);
190 190
 					}
191 191
 				}
192 192
 				$html .= $this->_taxes_html;
193
-				$html .= $this->_total_row( $line_item, __('Total', 'event_espresso') );
193
+				$html .= $this->_total_row($line_item, __('Total', 'event_espresso'));
194 194
 
195 195
 
196
-				$html .= $this->_payments_and_amount_owing_rows( $line_item, $options );
196
+				$html .= $this->_payments_and_amount_owing_rows($line_item, $options);
197 197
 				break;
198 198
 
199 199
 		}
@@ -208,11 +208,11 @@  discard block
 block discarded – undo
208 208
 	 * @param EE_Line_Item $line_item
209 209
 	 * @return mixed
210 210
 	 */
211
-	private function _event_row( EE_Line_Item $line_item ) {
211
+	private function _event_row(EE_Line_Item $line_item) {
212 212
 		// start of row
213
-		$html = EEH_HTML::tr( '', 'event-cart-total-row', 'total_tr odd' );
213
+		$html = EEH_HTML::tr('', 'event-cart-total-row', 'total_tr odd');
214 214
 		// event name td
215
-		$html .= EEH_HTML::td( EEH_HTML::strong( $line_item->name() ), '', 'event-header', '', ' colspan="4"' );
215
+		$html .= EEH_HTML::td(EEH_HTML::strong($line_item->name()), '', 'event-header', '', ' colspan="4"');
216 216
 		// end of row
217 217
 		$html .= EEH_HTML::trx();
218 218
 		return $html;
@@ -227,10 +227,10 @@  discard block
 block discarded – undo
227 227
 	 * @param array        $options
228 228
 	 * @return mixed
229 229
 	 */
230
-	private function _ticket_row( EE_Line_Item $line_item, $options = array() ) {
230
+	private function _ticket_row(EE_Line_Item $line_item, $options = array()) {
231 231
 		// start of row
232 232
 		$row_class = $options['odd'] ? 'item odd' : 'item';
233
-		$html = EEH_HTML::tr( '', '', $row_class );
233
+		$html = EEH_HTML::tr('', '', $row_class);
234 234
 		// name && desc
235 235
 		$name_and_desc = apply_filters(
236 236
 			'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name',
@@ -239,23 +239,23 @@  discard block
 block discarded – undo
239 239
 		);
240 240
 		$name_and_desc .= apply_filters(
241 241
 			'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc',
242
-			( $options['show_desc'] ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' : '' ),
242
+			($options['show_desc'] ? '<span class="line-item-desc-spn smaller-text">: '.$line_item->desc().'</span>' : ''),
243 243
 			$line_item,
244 244
 			$options
245 245
 		);
246 246
 		$name_and_desc .= $line_item->is_taxable() ? ' * ' : '';
247 247
 		// name td
248
-		$html .= EEH_HTML::td( /*__FUNCTION__ .*/ $name_and_desc, '',  'item_l' );
248
+		$html .= EEH_HTML::td( /*__FUNCTION__ .*/ $name_and_desc, '', 'item_l' );
249 249
 		// price td
250
-		$html .= EEH_HTML::td( $line_item->unit_price_no_code(), '',  'item_c jst-rght' );
250
+		$html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght');
251 251
 		// quantity td
252
-		$html .= EEH_HTML::td( $line_item->quantity(), '', 'item_l jst-rght' );
252
+		$html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght');
253 253
 		$this->_total_items += $line_item->quantity();
254 254
 		// determine total for line item
255 255
 		$total = $line_item->total();
256
-		$this->_events[ $options[ 'event_id' ] ] += $total;
256
+		$this->_events[$options['event_id']] += $total;
257 257
 		// total td
258
-		$html .= EEH_HTML::td( EEH_Template::format_currency( $total, false, false ), '',  'item_r jst-rght' );
258
+		$html .= EEH_HTML::td(EEH_Template::format_currency($total, false, false), '', 'item_r jst-rght');
259 259
 		// end of row
260 260
 		$html .= EEH_HTML::trx();
261 261
 		return $html;
@@ -270,41 +270,41 @@  discard block
 block discarded – undo
270 270
 	 * @param array        $options
271 271
 	 * @return mixed
272 272
 	 */
273
-	private function _item_row( EE_Line_Item $line_item, $options = array() ) {
273
+	private function _item_row(EE_Line_Item $line_item, $options = array()) {
274 274
 		// start of row
275 275
 		$row_class = $options['odd'] ? 'item odd' : 'item';
276
-		$html = EEH_HTML::tr( '', '', $row_class );
277
-		$obj_name = $line_item->OBJ_type() ? $line_item->OBJ_type() . ': ' : '';
276
+		$html = EEH_HTML::tr('', '', $row_class);
277
+		$obj_name = $line_item->OBJ_type() ? $line_item->OBJ_type().': ' : '';
278 278
 		// name && desc
279 279
 		$name_and_desc = apply_filters(
280 280
 			'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name',
281
-			 $obj_name . $line_item->name(),
281
+			 $obj_name.$line_item->name(),
282 282
 			$line_item
283 283
 		);
284 284
 		$name_and_desc .= apply_filters(
285 285
 			'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc',
286
-			( $options['show_desc'] ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' : '' ),
286
+			($options['show_desc'] ? '<span class="line-item-desc-spn smaller-text">: '.$line_item->desc().'</span>' : ''),
287 287
 			$line_item,
288 288
 			$options
289 289
 		);
290 290
 		$name_and_desc .= $line_item->is_taxable() ? ' * ' : '';
291 291
 		// name td
292
-		$html .= EEH_HTML::td( $name_and_desc, '',  'item_l' );
292
+		$html .= EEH_HTML::td($name_and_desc, '', 'item_l');
293 293
 		// price td
294
-		if ( $line_item->is_percent() ) {
295
-			$html .= EEH_HTML::td( $line_item->percent() . '%', '', 'item_c jst-rght' );
294
+		if ($line_item->is_percent()) {
295
+			$html .= EEH_HTML::td($line_item->percent().'%', '', 'item_c jst-rght');
296 296
 		} else {
297
-			$html .= EEH_HTML::td( $line_item->unit_price_no_code(), '', 'item_c jst-rght' );
297
+			$html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght');
298 298
 		}
299 299
 		// quantity td
300
-		$html .= EEH_HTML::td( $line_item->quantity(), '', 'item_l jst-rght' );
300
+		$html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght');
301 301
 		//$total = $line_item->total() * $line_item->quantity();
302 302
 		$total = $line_item->total();
303
-		if( isset( $options[ 'event_id' ] ) && isset( $this->_events[ $options[ 'event_id' ] ] ) ) {
304
-			$this->_events[ $options[ 'event_id' ] ] += $total;
303
+		if (isset($options['event_id']) && isset($this->_events[$options['event_id']])) {
304
+			$this->_events[$options['event_id']] += $total;
305 305
 		}
306 306
 		// total td
307
-		$html .= EEH_HTML::td( EEH_Template::format_currency( $total, false, false ), '',  'item_r jst-rght' );
307
+		$html .= EEH_HTML::td(EEH_Template::format_currency($total, false, false), '', 'item_r jst-rght');
308 308
 		// end of row
309 309
 		$html .= EEH_HTML::trx();
310 310
 		return $html;
@@ -319,22 +319,22 @@  discard block
 block discarded – undo
319 319
 	 * @param array        $options
320 320
 	 * @return mixed
321 321
 	 */
322
-	private function _sub_item_row( EE_Line_Item $line_item, $options = array() ) {
322
+	private function _sub_item_row(EE_Line_Item $line_item, $options = array()) {
323 323
 		// start of row
324
-		$html = EEH_HTML::tr( '', 'item sub-item-row' );
324
+		$html = EEH_HTML::tr('', 'item sub-item-row');
325 325
 		// name && desc
326 326
 		$name_and_desc = $line_item->name();
327
-		$name_and_desc .= $options['show_desc'] ? '<span class="line-sub-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' : '';
327
+		$name_and_desc .= $options['show_desc'] ? '<span class="line-sub-item-desc-spn smaller-text">: '.$line_item->desc().'</span>' : '';
328 328
 		// name td
329
-		$html .= EEH_HTML::td( /*__FUNCTION__ .*/ $name_and_desc, '',  'item_l sub-item' );
329
+		$html .= EEH_HTML::td( /*__FUNCTION__ .*/ $name_and_desc, '', 'item_l sub-item' );
330 330
 		// discount/surcharge td
331
-		if ( $line_item->is_percent() ) {
332
-			$html .= EEH_HTML::td( $line_item->percent() . '%', '',  'item_c' );
331
+		if ($line_item->is_percent()) {
332
+			$html .= EEH_HTML::td($line_item->percent().'%', '', 'item_c');
333 333
 		} else {
334
-			$html .= EEH_HTML::td( $line_item->unit_price_no_code(), '',  'item_c jst-rght' );
334
+			$html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght');
335 335
 		}
336 336
 		// total td
337
-		$html .= EEH_HTML::td( EEH_Template::format_currency( $line_item->total(), false, false ), '',  'item_r jst-rght' );
337
+		$html .= EEH_HTML::td(EEH_Template::format_currency($line_item->total(), false, false), '', 'item_r jst-rght');
338 338
 		// end of row
339 339
 		$html .= EEH_HTML::trx();
340 340
 		return $html;
@@ -349,21 +349,21 @@  discard block
 block discarded – undo
349 349
 	 * @param array        $options
350 350
 	 * @return mixed
351 351
 	 */
352
-	private function _tax_row( EE_Line_Item $line_item, $options = array() ) {
352
+	private function _tax_row(EE_Line_Item $line_item, $options = array()) {
353 353
 		// start of row
354
-		$html = EEH_HTML::tr( '', 'item sub-item tax-total' );
354
+		$html = EEH_HTML::tr('', 'item sub-item tax-total');
355 355
 		// name && desc
356 356
 		$name_and_desc = $line_item->name();
357
-		$name_and_desc .= '<span class="smaller-text lt-grey-text" style="margin:0 0 0 2em;">' . __( ' * taxable items', 'event_espresso' ) . '</span>';
358
-		$name_and_desc .= $options[ 'show_desc' ] ? '<br/>' . $line_item->desc() : '';
357
+		$name_and_desc .= '<span class="smaller-text lt-grey-text" style="margin:0 0 0 2em;">'.__(' * taxable items', 'event_espresso').'</span>';
358
+		$name_and_desc .= $options['show_desc'] ? '<br/>'.$line_item->desc() : '';
359 359
 		// name td
360
-		$html .= EEH_HTML::td( /*__FUNCTION__ .*/ $name_and_desc, '',  'item_l sub-item' );
360
+		$html .= EEH_HTML::td( /*__FUNCTION__ .*/ $name_and_desc, '', 'item_l sub-item' );
361 361
 		// percent td
362
-		$html .= EEH_HTML::td( $line_item->percent() . '%', '',  ' jst-rght', '' );
362
+		$html .= EEH_HTML::td($line_item->percent().'%', '', ' jst-rght', '');
363 363
 		// empty td (price)
364
-		$html .= EEH_HTML::td( EEH_HTML::nbsp() );
364
+		$html .= EEH_HTML::td(EEH_HTML::nbsp());
365 365
 		// total td
366
-		$html .= EEH_HTML::td( EEH_Template::format_currency( $line_item->total(), false, false ), '',  'item_r jst-rght' );
366
+		$html .= EEH_HTML::td(EEH_Template::format_currency($line_item->total(), false, false), '', 'item_r jst-rght');
367 367
 		// end of row
368 368
 		$html .= EEH_HTML::trx();
369 369
 		return $html;
@@ -378,17 +378,17 @@  discard block
 block discarded – undo
378 378
 	 * @param string $text
379 379
 	 * @return mixed
380 380
 	 */
381
-	private function _total_tax_row( EE_Line_Item $line_item, $text = '' ) {
381
+	private function _total_tax_row(EE_Line_Item $line_item, $text = '') {
382 382
 		$html = '';
383
-		if ( $line_item->total() ) {
383
+		if ($line_item->total()) {
384 384
 			// start of row
385
-			$html = EEH_HTML::tr( '', '', 'total_tr odd' );
385
+			$html = EEH_HTML::tr('', '', 'total_tr odd');
386 386
 			// total td
387
-			$html .= EEH_HTML::td( $text, '', 'total_currency total jst-rght', '', ' colspan="2"' );
387
+			$html .= EEH_HTML::td($text, '', 'total_currency total jst-rght', '', ' colspan="2"');
388 388
 			// empty td (price)
389
-			$html .= EEH_HTML::td( EEH_HTML::nbsp() );
389
+			$html .= EEH_HTML::td(EEH_HTML::nbsp());
390 390
 			// total td
391
-			$html .= EEH_HTML::td( EEH_Template::format_currency( $line_item->total(), false, false ), '', 'total jst-rght' );
391
+			$html .= EEH_HTML::td(EEH_Template::format_currency($line_item->total(), false, false), '', 'total jst-rght');
392 392
 			// end of row
393 393
 			$html .= EEH_HTML::trx();
394 394
 		}
@@ -405,15 +405,15 @@  discard block
 block discarded – undo
405 405
 	 * @param array        $options
406 406
 	 * @return mixed
407 407
 	 */
408
-	private function _sub_total_row( EE_Line_Item $line_item, $text = '', $options = array() ) {
408
+	private function _sub_total_row(EE_Line_Item $line_item, $text = '', $options = array()) {
409 409
 		$html = '';
410
-		if ( $line_item->total() ) {
410
+		if ($line_item->total()) {
411 411
 			// start of row
412
-			$html = EEH_HTML::tr( '', '', 'total_tr odd' );
412
+			$html = EEH_HTML::tr('', '', 'total_tr odd');
413 413
 			// total td
414
-			$html .= EEH_HTML::td( $text, '', 'total_currency total jst-rght', '', ' colspan="3"' );
414
+			$html .= EEH_HTML::td($text, '', 'total_currency total jst-rght', '', ' colspan="3"');
415 415
 			// total td
416
-			$html .= EEH_HTML::td( EEH_Template::format_currency( $options[ 'sub_total' ], false, false ), '', 'total jst-rght' );
416
+			$html .= EEH_HTML::td(EEH_Template::format_currency($options['sub_total'], false, false), '', 'total jst-rght');
417 417
 			// end of row
418 418
 			$html .= EEH_HTML::trx();
419 419
 		}
@@ -430,13 +430,13 @@  discard block
 block discarded – undo
430 430
 	 * @param string       $text
431 431
 	 * @return mixed
432 432
 	 */
433
-	private function _total_row( EE_Line_Item $line_item, $text = '' ) {
433
+	private function _total_row(EE_Line_Item $line_item, $text = '') {
434 434
 		// start of row
435
-		$html = EEH_HTML::tr( '', '', 'spco-grand-total total_tr odd' );
435
+		$html = EEH_HTML::tr('', '', 'spco-grand-total total_tr odd');
436 436
 		// total td
437
-		$html .= EEH_HTML::td( $text, '',  'total_currency total jst-rght',  '',  ' colspan="3"' );
437
+		$html .= EEH_HTML::td($text, '', 'total_currency total jst-rght', '', ' colspan="3"');
438 438
 		// total td
439
-		$html .= EEH_HTML::td( EEH_Template::format_currency( $line_item->total(), false, false ), '',  'total jst-rght' );
439
+		$html .= EEH_HTML::td(EEH_Template::format_currency($line_item->total(), false, false), '', 'total jst-rght');
440 440
 		// end of row
441 441
 		$html .= EEH_HTML::trx();
442 442
 		return $html;
@@ -451,30 +451,30 @@  discard block
 block discarded – undo
451 451
 	 * @param array        $options
452 452
 	 * @return mixed
453 453
 	 */
454
-	private function _payments_and_amount_owing_rows( EE_Line_Item $line_item, $options = array() ) {
454
+	private function _payments_and_amount_owing_rows(EE_Line_Item $line_item, $options = array()) {
455 455
 		$html = '';
456 456
 		$owing = $line_item->total();
457
-		$transaction = EEM_Transaction::instance()->get_one_by_ID( $line_item->TXN_ID() );
458
-		if ( $transaction instanceof EE_Transaction ) {
457
+		$transaction = EEM_Transaction::instance()->get_one_by_ID($line_item->TXN_ID());
458
+		if ($transaction instanceof EE_Transaction) {
459 459
 			$registration_payments = array();
460
-			$registrations = ! empty( $options['registrations'] )
461
-				? $options[ 'registrations' ]
460
+			$registrations = ! empty($options['registrations'])
461
+				? $options['registrations']
462 462
 				: $transaction->registrations();
463
-			foreach ( $registrations as $registration ) {
464
-				if ( $registration instanceof EE_Registration && $registration->owes_monies_and_can_pay() ) {
463
+			foreach ($registrations as $registration) {
464
+				if ($registration instanceof EE_Registration && $registration->owes_monies_and_can_pay()) {
465 465
 					$registration_payments = $registration_payments + $registration->registration_payments();
466 466
 				}
467 467
 			}
468
-			if ( ! empty( $registration_payments )) {
469
-				foreach ( $registration_payments as $registration_payment ) {
470
-					if ( $registration_payment instanceof EE_Registration_Payment ) {
468
+			if ( ! empty($registration_payments)) {
469
+				foreach ($registration_payments as $registration_payment) {
470
+					if ($registration_payment instanceof EE_Registration_Payment) {
471 471
 						$owing = $owing - $registration_payment->amount();
472 472
 						$payment = $registration_payment->payment();
473
-						if ( $payment instanceof EE_Payment ) {
473
+						if ($payment instanceof EE_Payment) {
474 474
 							$payment_desc = sprintf(
475
-								__( 'Payment%1$s Received: %2$s', 'event_espresso' ),
475
+								__('Payment%1$s Received: %2$s', 'event_espresso'),
476 476
 								$payment->txn_id_chq_nmbr() != ''
477
-									? ' <span class="small-text">(#' . $payment->txn_id_chq_nmbr() . ')</span> '
477
+									? ' <span class="small-text">(#'.$payment->txn_id_chq_nmbr().')</span> '
478 478
 									: '',
479 479
 								$payment->timestamp()
480 480
 							);
@@ -482,12 +482,12 @@  discard block
 block discarded – undo
482 482
 							$payment_desc = '';
483 483
 						}
484 484
 						// start of row
485
-						$html .= EEH_HTML::tr( '', '', 'total_tr odd' );
485
+						$html .= EEH_HTML::tr('', '', 'total_tr odd');
486 486
 						// payment desc
487
-						$html .= EEH_HTML::td( $payment_desc, '', '', '', ' colspan="3"' );
487
+						$html .= EEH_HTML::td($payment_desc, '', '', '', ' colspan="3"');
488 488
 						// total td
489 489
 						$html .= EEH_HTML::td(
490
-							EEH_Template::format_currency( $registration_payment->amount(), false, false ),
490
+							EEH_Template::format_currency($registration_payment->amount(), false, false),
491 491
 							'',
492 492
 							'total jst-rght'
493 493
 						);
@@ -495,17 +495,17 @@  discard block
 block discarded – undo
495 495
 						$html .= EEH_HTML::trx();
496 496
 					}
497 497
 				}
498
-				if ( $line_item->total() ) {
498
+				if ($line_item->total()) {
499 499
 					// start of row
500
-					$html .= EEH_HTML::tr( '', '', 'total_tr odd' );
500
+					$html .= EEH_HTML::tr('', '', 'total_tr odd');
501 501
 					// total td
502 502
 					$html .= EEH_HTML::td(
503 503
 						__('Amount Owing', 'event_espresso'),
504
-						'',  'total_currency total jst-rght',  '',  ' colspan="3"'
504
+						'', 'total_currency total jst-rght', '', ' colspan="3"'
505 505
 					);
506 506
 					// total td
507 507
 					$html .= EEH_HTML::td(
508
-						EEH_Template::format_currency( $owing, false, false ), '',  'total jst-rght'
508
+						EEH_Template::format_currency($owing, false, false), '', 'total jst-rght'
509 509
 					);
510 510
 					// end of row
511 511
 					$html .= EEH_HTML::trx();
Please login to merge, or discard this patch.
help_tabs/payment_methods_overview_paypalstandard.help_tab.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 <?php _e('Adjust the settings for the PayPal Standard payment gateway.', 'event_espresso'); ?>
4 4
 </p>
5 5
 <p>
6
-<?php printf( __( 'See %1$shere%2$s for list of currencies supported by Paypal Standard.', 'event_espresso' ), "<a href='https://www.paypal.com/multicurrency' target='_blank'>","</a>" ); ?>
6
+<?php printf(__('See %1$shere%2$s for list of currencies supported by Paypal Standard.', 'event_espresso'), "<a href='https://www.paypal.com/multicurrency' target='_blank'>", "</a>"); ?>
7 7
 </p>
8 8
 <h3><?php _e('PayPal Standard Settings', 'event_espresso'); ?></h3>
9 9
 <ul>
@@ -21,18 +21,18 @@  discard block
 block discarded – undo
21 21
 </li>
22 22
 <li>
23 23
 <strong><?php _e('PayPal Calculates Taxes', 'event_espresso'); ?></strong><br />
24
-<?php printf( __('If set to "Yes", we will indicate to PayPal that it should calculate the taxes on the order and add it. This means PayPal\'s tax calculations will be used on the order instead of Event Espresso\'s. %1$sRead here for more information.%2$s', 'event_espresso'), "<a href='https://www.paypal.com/ca/cgi-bin/webscr?cmd=xpt/Marketing/shipping/EasyCalculateShipAndTax-outside' target='_blank'>", '</a>' ); ?><br/>
25
-<?php _e( 'Note: It may confuse users if Event Espresso initially calculates taxes on the order, and then they go to PayPal and it calculates taxes differently. So it is recommended that if PayPal is calculating taxes, that you do not set any taxes in Event Espresso.', 'event_espresso' );?>
24
+<?php printf(__('If set to "Yes", we will indicate to PayPal that it should calculate the taxes on the order and add it. This means PayPal\'s tax calculations will be used on the order instead of Event Espresso\'s. %1$sRead here for more information.%2$s', 'event_espresso'), "<a href='https://www.paypal.com/ca/cgi-bin/webscr?cmd=xpt/Marketing/shipping/EasyCalculateShipAndTax-outside' target='_blank'>", '</a>'); ?><br/>
25
+<?php _e('Note: It may confuse users if Event Espresso initially calculates taxes on the order, and then they go to PayPal and it calculates taxes differently. So it is recommended that if PayPal is calculating taxes, that you do not set any taxes in Event Espresso.', 'event_espresso'); ?>
26 26
 </li>
27 27
 <li>
28 28
 <strong><?php _e('PayPal Calculates Shipping', 'event_espresso'); ?></strong><br />
29 29
 <?php _e('Similar to the "PayPal Calculates Taxes" setting, if this is set to "Yes", we will indicate to PayPal that it should calculate the shipping on each payment (if there are multiple payments for a single transaction, PayPal is permitted to add shipping charges to each payment.)', 'event_espresso'); ?><br/>
30
-<?php _e( 'Important Note: PayPal will ONLY calculate shipping on an order if "Shipping Address Options" is set to "Prompt for an Address" (otherwise how will PayPal know how much to charge for shipping if it doesn\'t know where it\'s shipping to?)', 'event_espresso' );?>
30
+<?php _e('Important Note: PayPal will ONLY calculate shipping on an order if "Shipping Address Options" is set to "Prompt for an Address" (otherwise how will PayPal know how much to charge for shipping if it doesn\'t know where it\'s shipping to?)', 'event_espresso'); ?>
31 31
 <li>
32
-<strong><?php _e( 'Notes Regarding Paypal Taxes and Shipping', 'event_espresso' );?></strong><br/>
33
-<?php _e( 'If you want PayPal to calculate taxes and shipping on an order, those changes will NOT appear during the initial registration process until the user is redirected to PayPal for payment.', 'event_espresso' );?><br/>
34
-<?php _e( 'However, after the user has returned from PayPal, their order in Event Espresso will be updated with the new taxes and added shipping charges (e.g. it will appear on their receipt.)', 'event_espresso' );?><br/>
35
-<?php _e( 'Also Note: In order for PayPal to properly calculate taxes and shipping, they need to receive the entire order at the same time. So if a user goes to make a payment using PayPal, and their order somehow already has a payment on it, PayPal CANNOT calculate taxes or shipping on that order.', 'event_espresso' );?>
32
+<strong><?php _e('Notes Regarding Paypal Taxes and Shipping', 'event_espresso'); ?></strong><br/>
33
+<?php _e('If you want PayPal to calculate taxes and shipping on an order, those changes will NOT appear during the initial registration process until the user is redirected to PayPal for payment.', 'event_espresso'); ?><br/>
34
+<?php _e('However, after the user has returned from PayPal, their order in Event Espresso will be updated with the new taxes and added shipping charges (e.g. it will appear on their receipt.)', 'event_espresso'); ?><br/>
35
+<?php _e('Also Note: In order for PayPal to properly calculate taxes and shipping, they need to receive the entire order at the same time. So if a user goes to make a payment using PayPal, and their order somehow already has a payment on it, PayPal CANNOT calculate taxes or shipping on that order.', 'event_espresso'); ?>
36 36
 </li>
37 37
 <li>
38 38
 <strong><?php _e('Shipping Address Options', 'event_espresso'); ?></strong><br />
Please login to merge, or discard this patch.
admin/extend/registration_form/Extend_Registration_Form_Admin_Page.core.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -126,7 +126,7 @@
 block discarded – undo
126 126
 	 * being address info, and 0 being neither)
127 127
 	 * @global type $wpdb
128 128
 	 * @param type $new_question_group_id
129
-	 * @return boolean
129
+	 * @return integer
130 130
 	 */
131 131
 	private function _is_system_question_group($new_question_group_id){
132 132
 		global $wpdb;
Please login to merge, or discard this patch.
Spacing   +163 added lines, -163 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
 /**
@@ -30,13 +30,13 @@  discard block
 block discarded – undo
30 30
 
31 31
 
32 32
 
33
-	public function __construct( $routing = TRUE ) {
34
-		define( 'REGISTRATION_FORM_CAF_ADMIN', EE_CORE_CAF_ADMIN_EXTEND . 'registration_form' . DS );
35
-		define( 'REGISTRATION_FORM_CAF_ASSETS_PATH', REGISTRATION_FORM_CAF_ADMIN . 'assets' . DS );
36
-		define( 'REGISTRATION_FORM_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/assets/' );
37
-		define( 'REGISTRATION_FORM_CAF_TEMPLATE_PATH', REGISTRATION_FORM_CAF_ADMIN . 'templates' . DS );
38
-		define( 'REGISTRATION_FORM_CAF_TEMPLATE_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/templates/' );
39
-		parent::__construct( $routing );
33
+	public function __construct($routing = TRUE) {
34
+		define('REGISTRATION_FORM_CAF_ADMIN', EE_CORE_CAF_ADMIN_EXTEND.'registration_form'.DS);
35
+		define('REGISTRATION_FORM_CAF_ASSETS_PATH', REGISTRATION_FORM_CAF_ADMIN.'assets'.DS);
36
+		define('REGISTRATION_FORM_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'registration_form/assets/');
37
+		define('REGISTRATION_FORM_CAF_TEMPLATE_PATH', REGISTRATION_FORM_CAF_ADMIN.'templates'.DS);
38
+		define('REGISTRATION_FORM_CAF_TEMPLATE_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'registration_form/templates/');
39
+		parent::__construct($routing);
40 40
 	}
41 41
 
42 42
 
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
 
47 47
 	protected function _extend_page_config() {
48 48
 		$this->_admin_base_path = REGISTRATION_FORM_CAF_ADMIN;
49
-		$qst_id = ! empty( $this->_req_data['QST_ID'] ) && ! is_array( $this->_req_data['QST_ID'] ) ? $this->_req_data['QST_ID'] : 0;
50
-		$qsg_id = ! empty( $this->_req_data['QSG_ID'] ) && ! is_array( $this->_req_data['QSG_ID'] ) ? $this->_req_data['QSG_ID'] : 0;
49
+		$qst_id = ! empty($this->_req_data['QST_ID']) && ! is_array($this->_req_data['QST_ID']) ? $this->_req_data['QST_ID'] : 0;
50
+		$qsg_id = ! empty($this->_req_data['QSG_ID']) && ! is_array($this->_req_data['QSG_ID']) ? $this->_req_data['QSG_ID'] : 0;
51 51
 
52 52
 		$new_page_routes = array(
53 53
 			'question_groups' => array(
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 				'func' => '_trash_or_restore_questions',
81 81
 				'capability' => 'ee_delete_question',
82 82
 				'obj_id' => $qst_id,
83
-				'args' => array( 'trash' => FALSE ),
83
+				'args' => array('trash' => FALSE),
84 84
 				'noheader' => TRUE
85 85
 				),
86 86
 
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 
140 140
 			'trash_question_group' => array(
141 141
 				'func' => '_trash_or_restore_question_groups',
142
-				'args' => array( 'trash' => TRUE ),
142
+				'args' => array('trash' => TRUE),
143 143
 				'capability' => 'ee_delete_question_group',
144 144
 				'obj_id' => $qsg_id,
145 145
 				'noheader' => TRUE
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 
148 148
 			'restore_question_group' => array(
149 149
 				'func' => '_trash_or_restore_question_groups',
150
-				'args' => array( 'trash' => FALSE ),
150
+				'args' => array('trash' => FALSE),
151 151
 				'capability' => 'ee_delete_question_group',
152 152
 				'obj_id' => $qsg_id,
153 153
 				'noheader' => TRUE
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 
163 163
 			'update_question_group' => array(
164 164
 				'func' => '_insert_or_update_question_group',
165
-				'args' => array('new_question_group' => FALSE ),
165
+				'args' => array('new_question_group' => FALSE),
166 166
 				'capability' => 'ee_edit_question_group',
167 167
 				'obj_id' => $qsg_id,
168 168
 				'noheader' => TRUE,
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 					'noheader' => TRUE
201 201
 				),
202 202
 			);
203
-		$this->_page_routes = array_merge( $this->_page_routes, $new_page_routes );
203
+		$this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
204 204
 
205 205
 		$new_page_config = array(
206 206
 
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 						'filename' => 'registration_form_question_groups_views_bulk_actions_search'
225 225
 						),
226 226
 					),
227
-				'help_tour' => array( 'Registration_Form_Question_Groups_Help_Tour'),
227
+				'help_tour' => array('Registration_Form_Question_Groups_Help_Tour'),
228 228
 				'metaboxes' => $this->_default_espresso_metaboxes,
229 229
 				'require_nonce' => FALSE,
230 230
 				'qtips' => array(
@@ -238,14 +238,14 @@  discard block
 block discarded – undo
238 238
 					'order' => 5,
239 239
 					'persistent' => FALSE
240 240
 					),
241
-				'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array('_publish_post_box' ) ),
241
+				'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
242 242
                 'help_tabs' => array(
243 243
 					'registration_form_add_question_help_tab' => array(
244 244
 						'title' => __('Add Question', 'event_espresso'),
245 245
 						'filename' => 'registration_form_add_question'
246 246
 						),
247 247
 					),
248
-                'help_tour' => array( 'Registration_Form_Add_Question_Help_Tour'),
248
+                'help_tour' => array('Registration_Form_Add_Question_Help_Tour'),
249 249
 				'require_nonce' => FALSE
250 250
 				),
251 251
 
@@ -255,14 +255,14 @@  discard block
 block discarded – undo
255 255
 					'order' => 5,
256 256
 					'persistent' => FALSE
257 257
 					),
258
-				'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array('_publish_post_box' ) ),
258
+				'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
259 259
 				'help_tabs' => array(
260 260
 					'registration_form_add_question_group_help_tab' => array(
261 261
 						'title' => __('Add Question Group', 'event_espresso'),
262 262
 						'filename' => 'registration_form_add_question_group'
263 263
 						),
264 264
 					),
265
-                'help_tour' => array( 'Registration_Form_Add_Question_Group_Help_Tour'),
265
+                'help_tour' => array('Registration_Form_Add_Question_Group_Help_Tour'),
266 266
 				'require_nonce' => FALSE
267 267
 				),
268 268
 
@@ -271,16 +271,16 @@  discard block
 block discarded – undo
271 271
 					'label' => __('Edit Question Group', 'event_espresso'),
272 272
 					'order' => 5,
273 273
 					'persistent' => FALSE,
274
-					'url' => isset($this->_req_data['question_group_id']) ? add_query_arg(array('question_group_id' => $this->_req_data['question_group_id'] ), $this->_current_page_view_url )  : $this->_admin_base_url
274
+					'url' => isset($this->_req_data['question_group_id']) ? add_query_arg(array('question_group_id' => $this->_req_data['question_group_id']), $this->_current_page_view_url) : $this->_admin_base_url
275 275
 					),
276
-				'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array('_publish_post_box' ) ),
276
+				'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
277 277
 				'help_tabs' => array(
278 278
 					'registration_form_edit_question_group_help_tab' => array(
279 279
 						'title' => __('Edit Question Group', 'event_espresso'),
280 280
 						'filename' => 'registration_form_edit_question_group'
281 281
 						),
282 282
 					),
283
-                'help_tour' => array( 'Registration_Form_Edit_Question_Group_Help_Tour'),
283
+                'help_tour' => array('Registration_Form_Edit_Question_Group_Help_Tour'),
284 284
 				'require_nonce' => FALSE
285 285
 				),
286 286
 
@@ -292,19 +292,19 @@  discard block
 block discarded – undo
292 292
 				'labels' => array(
293 293
 					'publishbox' => __('Update Settings', 'event_espresso')
294 294
 					),
295
-				'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array( '_publish_post_box' ) ),
295
+				'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
296 296
 				'help_tabs' => array(
297 297
 					'registration_form_reg_form_settings_help_tab' => array(
298 298
 						'title' => __('Registration Form Settings', 'event_espresso'),
299 299
 						'filename' => 'registration_form_reg_form_settings'
300 300
 						),
301 301
 					),
302
-                'help_tour' => array( 'Registration_Form_Settings_Help_Tour'),
302
+                'help_tour' => array('Registration_Form_Settings_Help_Tour'),
303 303
 				'require_nonce' => FALSE
304 304
 				)
305 305
 
306 306
 			);
307
-		$this->_page_config = array_merge( $this->_page_config, $new_page_config );
307
+		$this->_page_config = array_merge($this->_page_config, $new_page_config);
308 308
 
309 309
 		//change the list table we're going to use so it's the NEW list table!
310 310
 		$this->_page_config['default']['list_table'] = 'Extend_Registration_Form_Questions_Admin_List_Table';
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
 			'edit_question_group' => __('Edit Question Group', 'event_espresso'),
319 319
 			'delete_question_group' => __('Delete Question Group', 'event_espresso'),
320 320
 			);
321
-		$this->_labels['buttons'] = array_merge( $this->_labels['buttons'], $new_labels );
321
+		$this->_labels['buttons'] = array_merge($this->_labels['buttons'], $new_labels);
322 322
 
323 323
 	}
324 324
 
@@ -327,14 +327,14 @@  discard block
 block discarded – undo
327 327
 
328 328
 
329 329
 	protected function _ajax_hooks() {
330
-		add_action('wp_ajax_espresso_update_question_group_order', array( $this, 'update_question_group_order' ));
330
+		add_action('wp_ajax_espresso_update_question_group_order', array($this, 'update_question_group_order'));
331 331
 	}
332 332
 
333 333
 
334 334
 
335 335
 
336 336
 	public function load_scripts_styles_question_groups() {
337
-		wp_enqueue_script( 'espresso_ajax_table_sorting' );
337
+		wp_enqueue_script('espresso_ajax_table_sorting');
338 338
 	}
339 339
 
340 340
 
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
 	 * @return void
356 356
 	 */
357 357
 	public function load_sortable_question_script() {
358
-		wp_register_script('ee-question-sortable', REGISTRATION_FORM_CAF_ASSETS_URL . 'ee_question_order.js', array('jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, true);
358
+		wp_register_script('ee-question-sortable', REGISTRATION_FORM_CAF_ASSETS_URL.'ee_question_order.js', array('jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, true);
359 359
 		wp_enqueue_script('ee-question-sortable');
360 360
 	}
361 361
 
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
 				)
375 375
 		);
376 376
 
377
-		if ( EE_Registry::instance()->CAP->current_user_can('ee_delete_questions', 'espresso_registration_form_trash_questions' ) ) {
377
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_questions', 'espresso_registration_form_trash_questions')) {
378 378
 			$this->_views['trash'] = array(
379 379
 				'slug' => 'trash',
380 380
 				'label' => __('Trash', 'event_espresso'),
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
 				)
405 405
 		);
406 406
 
407
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_question_groups', 'espresso_registration_form_trash_question_groups' ) ) {
407
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_question_groups', 'espresso_registration_form_trash_question_groups')) {
408 408
 			$this->_views['trash'] = array(
409 409
 				'slug' => 'trash',
410 410
 				'label' => __('Trash', 'event_espresso'),
@@ -440,24 +440,24 @@  discard block
 block discarded – undo
440 440
 
441 441
 
442 442
 
443
-	protected function _delete_question(){
444
-		$success = $this->_delete_items( $this->_question_model );
443
+	protected function _delete_question() {
444
+		$success = $this->_delete_items($this->_question_model);
445 445
 		$this->_redirect_after_action(
446 446
 			$success,
447
-			$this->_question_model->item_name( $success ),
447
+			$this->_question_model->item_name($success),
448 448
 			'deleted',
449
-			array( 'action' => 'default', 'status' => 'all' )
449
+			array('action' => 'default', 'status' => 'all')
450 450
 		);
451 451
 	}
452 452
 
453 453
 
454 454
 	protected function _delete_questions() {
455
-		$success = $this->_delete_items( $this->_question_model );
455
+		$success = $this->_delete_items($this->_question_model);
456 456
 		$this->_redirect_after_action(
457 457
 			$success,
458
-			$this->_question_model->item_name( $success ),
458
+			$this->_question_model->item_name($success),
459 459
 			'deleted permanently',
460
-			array( 'action' => 'default', 'status' => 'trash' )
460
+			array('action' => 'default', 'status' => 'trash')
461 461
 		);
462 462
 	}
463 463
 
@@ -468,26 +468,26 @@  discard block
 block discarded – undo
468 468
  * @param EEM_Soft_Delete_Base $model
469 469
  * @return int number of items deleted permanently
470 470
  */
471
-	private function _delete_items(EEM_Soft_Delete_Base $model){
471
+	private function _delete_items(EEM_Soft_Delete_Base $model) {
472 472
 		$success = 0;
473
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
474
-		if (!empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
473
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
474
+		if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
475 475
 			// if array has more than one element than success message should be plural
476
-			$success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1;
476
+			$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
477 477
 			// cycle thru bulk action checkboxes
478
-			while (list( $ID, $value ) = each($this->_req_data['checkbox'])) {
479
-				if ( ! $this->_delete_item( $ID, $model ) ) {
478
+			while (list($ID, $value) = each($this->_req_data['checkbox'])) {
479
+				if ( ! $this->_delete_item($ID, $model)) {
480 480
 					$success = 0;
481 481
 				}
482 482
 			}
483 483
 
484
-		}elseif( !empty($this->_req_data['QSG_ID'])){
485
-			$success = $this->_delete_item( $this->_req_data['QSG_ID'], $model );
484
+		}elseif ( ! empty($this->_req_data['QSG_ID'])) {
485
+			$success = $this->_delete_item($this->_req_data['QSG_ID'], $model);
486 486
 
487
-		}elseif( !empty($this->_req_data['QST_ID'])){
488
-			$success = $this->_delete_item( $this->_req_data['QST_ID'], $model );
489
-		}else{
490
-			EE_Error::add_error( sprintf(__("No Questions or Question Groups were selected for deleting. This error usually shows when you've attempted to delete via bulk action but there were no selections.", "event_espresso")), __FILE__, __FUNCTION__, __LINE__ );
487
+		}elseif ( ! empty($this->_req_data['QST_ID'])) {
488
+			$success = $this->_delete_item($this->_req_data['QST_ID'], $model);
489
+		} else {
490
+			EE_Error::add_error(sprintf(__("No Questions or Question Groups were selected for deleting. This error usually shows when you've attempted to delete via bulk action but there were no selections.", "event_espresso")), __FILE__, __FUNCTION__, __LINE__);
491 491
 		}
492 492
 		return $success;
493 493
 	}
@@ -498,11 +498,11 @@  discard block
 block discarded – undo
498 498
 	 * @param EEM_Soft_Delete_Base $model
499 499
 	 * @return boolean
500 500
 	 */
501
-	protected function _delete_item( $id, $model ) {
502
-		if( $model instanceof EEM_Question ) {
503
-			EEM_Question_Option::instance()->delete_permanently( array( array( 'QST_ID' => absint( $id ) ) ) );
501
+	protected function _delete_item($id, $model) {
502
+		if ($model instanceof EEM_Question) {
503
+			EEM_Question_Option::instance()->delete_permanently(array(array('QST_ID' => absint($id))));
504 504
 		}
505
-		return $model->delete_permanently_by_ID( absint( $id ) );
505
+		return $model->delete_permanently_by_ID(absint($id));
506 506
 	}
507 507
 
508 508
 
@@ -514,29 +514,29 @@  discard block
 block discarded – undo
514 514
 
515 515
 
516 516
 
517
-	protected function _edit_question_group( $type = 'add' ) {
518
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
519
-		$ID=isset( $this->_req_data['QSG_ID'] ) && ! empty( $this->_req_data['QSG_ID'] ) ? absint( $this->_req_data['QSG_ID'] ) : FALSE;
520
-		$this->_admin_page_title = ucwords( str_replace( '_', ' ', $this->_req_action ));
517
+	protected function _edit_question_group($type = 'add') {
518
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
519
+		$ID = isset($this->_req_data['QSG_ID']) && ! empty($this->_req_data['QSG_ID']) ? absint($this->_req_data['QSG_ID']) : FALSE;
520
+		$this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action));
521 521
 		// add ID to title if editing
522
-		$this->_admin_page_title = $ID ? $this->_admin_page_title . ' # ' . $ID : $this->_admin_page_title;
523
-		if($ID){
524
-			$questionGroup=$this->_question_group_model->get_one_by_ID($ID);
525
-			$additional_hidden_fields=array('QSG_ID'=>array('type'=>'hidden','value'=>$ID));
522
+		$this->_admin_page_title = $ID ? $this->_admin_page_title.' # '.$ID : $this->_admin_page_title;
523
+		if ($ID) {
524
+			$questionGroup = $this->_question_group_model->get_one_by_ID($ID);
525
+			$additional_hidden_fields = array('QSG_ID'=>array('type'=>'hidden', 'value'=>$ID));
526 526
 			$this->_set_add_edit_form_tags('update_question_group', $additional_hidden_fields);
527
-		}else{
527
+		} else {
528 528
 			$questionGroup = EEM_Question_Group::instance()->create_default_object();
529 529
 			$questionGroup->set_order_to_latest();
530 530
 			$this->_set_add_edit_form_tags('insert_question_group');
531 531
 		}
532 532
 		$this->_template_args['values'] = $this->_yes_no_values;
533
-		$this->_template_args['all_questions']=$questionGroup->questions_in_and_not_in_group();
534
-		$this->_template_args['QSG_ID']=$ID ? $ID : TRUE;
535
-		$this->_template_args['question_group']=$questionGroup;
533
+		$this->_template_args['all_questions'] = $questionGroup->questions_in_and_not_in_group();
534
+		$this->_template_args['QSG_ID'] = $ID ? $ID : TRUE;
535
+		$this->_template_args['question_group'] = $questionGroup;
536 536
 
537
-		$redirect_URL = add_query_arg( array( 'action' => 'question_groups'), $this->_admin_base_url );
538
-		$this->_set_publish_post_box_vars( 'id', $ID, FALSE, $redirect_URL  );
539
-		$this->_template_args['admin_page_content'] = EEH_Template::display_template( REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'question_groups_main_meta_box.template.php', $this->_template_args, TRUE );
537
+		$redirect_URL = add_query_arg(array('action' => 'question_groups'), $this->_admin_base_url);
538
+		$this->_set_publish_post_box_vars('id', $ID, FALSE, $redirect_URL);
539
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(REGISTRATION_FORM_CAF_TEMPLATE_PATH.'question_groups_main_meta_box.template.php', $this->_template_args, TRUE);
540 540
 
541 541
 		// the details template wrapper
542 542
 		$this->display_admin_page_with_sidebar();
@@ -547,76 +547,76 @@  discard block
 block discarded – undo
547 547
 
548 548
 	protected function _delete_question_groups() {
549 549
 		$success = $this->_delete_items($this->_question_group_model);
550
-		$this->_redirect_after_action( $success, $this->_question_group_model->item_name($success), 'deleted permanently', array( 'action'=>'question_groups', 'status'=>'trash' ));
550
+		$this->_redirect_after_action($success, $this->_question_group_model->item_name($success), 'deleted permanently', array('action'=>'question_groups', 'status'=>'trash'));
551 551
 	}
552 552
 
553 553
 
554 554
 
555
-	protected function _insert_or_update_question_group( $new_question_group = TRUE) {
556
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
557
-		$set_column_values=$this->_set_column_values_for($this->_question_group_model);
558
-		if ( $new_question_group ){
555
+	protected function _insert_or_update_question_group($new_question_group = TRUE) {
556
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
557
+		$set_column_values = $this->_set_column_values_for($this->_question_group_model);
558
+		if ($new_question_group) {
559 559
 			$QSG_ID = $this->_question_group_model->insert($set_column_values);
560 560
 			$success = $QSG_ID ? 1 : 0;
561 561
 		} else {
562 562
 			$QSG_ID = absint($this->_req_data['QSG_ID']);
563
-			unset( $set_column_values[ 'QSG_ID' ] );
564
-			$success= $this->_question_group_model->update( $set_column_values, array( array( 'QSG_ID' => $QSG_ID )));
563
+			unset($set_column_values['QSG_ID']);
564
+			$success = $this->_question_group_model->update($set_column_values, array(array('QSG_ID' => $QSG_ID)));
565 565
 		}
566
-		$phone_question_id = EEM_Question::instance()->get_Question_ID_from_system_string( EEM_Attendee::system_question_phone );
566
+		$phone_question_id = EEM_Question::instance()->get_Question_ID_from_system_string(EEM_Attendee::system_question_phone);
567 567
 		// update the existing related questions
568 568
 		// BUT FIRST...  delete the phone question from the Question_Group_Question if it is being added to this question group (therefore removed from the existing group)
569
-		if ( isset( $this->_req_data['questions'], $this->_req_data['questions'][ $phone_question_id ] )) {
569
+		if (isset($this->_req_data['questions'], $this->_req_data['questions'][$phone_question_id])) {
570 570
 			// delete where QST ID = system phone question ID and Question Group ID is NOT this group
571
-			EEM_Question_Group_Question::instance()->delete( array( array( 'QST_ID' => $phone_question_id, 'QSG_ID' => array( '!=', $QSG_ID ))));
571
+			EEM_Question_Group_Question::instance()->delete(array(array('QST_ID' => $phone_question_id, 'QSG_ID' => array('!=', $QSG_ID))));
572 572
 		}
573 573
 		/** @type EE_Question_Group $question_group */
574
-		$question_group=$this->_question_group_model->get_one_by_ID( $QSG_ID );
574
+		$question_group = $this->_question_group_model->get_one_by_ID($QSG_ID);
575 575
 		$questions = $question_group->questions();
576 576
 		// make sure system phone question is added to list of questions for this group
577
-		if ( ! isset( $questions[$phone_question_id ] )) {
578
-			$questions[ $phone_question_id ] = EEM_Question::instance()->get_one_by_ID( $phone_question_id );
577
+		if ( ! isset($questions[$phone_question_id])) {
578
+			$questions[$phone_question_id] = EEM_Question::instance()->get_one_by_ID($phone_question_id);
579 579
 		}
580 580
 
581
-		foreach( $questions as $question_ID => $question ){
581
+		foreach ($questions as $question_ID => $question) {
582 582
 			// first we always check for order.
583
-			if ( ! empty( $this->_req_data['question_orders'][ $question_ID ] ) ){
583
+			if ( ! empty($this->_req_data['question_orders'][$question_ID])) {
584 584
 				//update question order
585
-				$question_group->update_question_order( $question_ID, $this->_req_data['question_orders'][ $question_ID ] );
585
+				$question_group->update_question_order($question_ID, $this->_req_data['question_orders'][$question_ID]);
586 586
 			}
587 587
 
588 588
 			// then we always check if adding or removing.
589
-			if ( isset( $this->_req_data['questions'], $this->_req_data['questions'][ $question_ID ] )) {
590
-				$question_group->add_question( $question_ID );
589
+			if (isset($this->_req_data['questions'], $this->_req_data['questions'][$question_ID])) {
590
+				$question_group->add_question($question_ID);
591 591
 			} else {
592 592
 				// not found, remove it (but only if not a system question for the personal group with the exception of lname system question - we allow removal of it)
593 593
 				if (
594 594
 					in_array(
595 595
 						$question->system_ID(),
596
-						EEM_Question::instance()->required_system_questions_in_system_question_group( $question_group->system_group() )
596
+						EEM_Question::instance()->required_system_questions_in_system_question_group($question_group->system_group())
597 597
 					)
598 598
 				) {
599 599
 					continue;
600 600
 				} else {
601
-					$question_group->remove_question( $question_ID );
601
+					$question_group->remove_question($question_ID);
602 602
 				}
603 603
 			}
604 604
 		}
605 605
 		// save new related questions
606
-		if ( isset( $this->_req_data['questions'] )) {
607
-			foreach( $this->_req_data['questions'] as $QST_ID ){
608
-				$question_group->add_question( $QST_ID );
609
-				if ( isset( $this->_req_data['question_orders'][ $QST_ID ] )) {
610
-					$question_group->update_question_order( $QST_ID, $this->_req_data['question_orders'][ $QST_ID ] );
606
+		if (isset($this->_req_data['questions'])) {
607
+			foreach ($this->_req_data['questions'] as $QST_ID) {
608
+				$question_group->add_question($QST_ID);
609
+				if (isset($this->_req_data['question_orders'][$QST_ID])) {
610
+					$question_group->update_question_order($QST_ID, $this->_req_data['question_orders'][$QST_ID]);
611 611
 				}
612 612
 			}
613 613
 		}
614 614
 
615
-		if ( $success !== FALSE ) {
616
-			$msg = $new_question_group ? sprintf( __('The %s has been created', 'event_espresso'), $this->_question_group_model->item_name() ) : sprintf( __('The %s has been updated', 'event_espresso' ), $this->_question_group_model->item_name() );
617
-			EE_Error::add_success( $msg );
615
+		if ($success !== FALSE) {
616
+			$msg = $new_question_group ? sprintf(__('The %s has been created', 'event_espresso'), $this->_question_group_model->item_name()) : sprintf(__('The %s has been updated', 'event_espresso'), $this->_question_group_model->item_name());
617
+			EE_Error::add_success($msg);
618 618
 		}
619
-		$this->_redirect_after_action(FALSE, '', '', array('action'=>'edit_question_group','QSG_ID'=>$QSG_ID), TRUE);
619
+		$this->_redirect_after_action(FALSE, '', '', array('action'=>'edit_question_group', 'QSG_ID'=>$QSG_ID), TRUE);
620 620
 
621 621
 	}
622 622
 
@@ -624,39 +624,39 @@  discard block
 block discarded – undo
624 624
 	 * duplicates a question and all its question options and redirects to the new question.
625 625
 	 */
626 626
 	public function _duplicate_question() {
627
-		$question_ID = intval( $this->_req_data[ 'QST_ID' ] );
628
-		$question = EEM_Question::instance()->get_one_by_ID( $question_ID );
629
-		if( $question instanceof EE_Question ) {
627
+		$question_ID = intval($this->_req_data['QST_ID']);
628
+		$question = EEM_Question::instance()->get_one_by_ID($question_ID);
629
+		if ($question instanceof EE_Question) {
630 630
 			$new_question = $question->duplicate();
631
-			if( $new_question instanceof EE_Question ) {
632
-				$this->_redirect_after_action( true, __( 'Question', 'event_espresso' ), __( 'Duplicated', 'event_espresso' ), array('action'=>'edit_question', 'QST_ID' => $new_question->ID() ), TRUE);
631
+			if ($new_question instanceof EE_Question) {
632
+				$this->_redirect_after_action(true, __('Question', 'event_espresso'), __('Duplicated', 'event_espresso'), array('action'=>'edit_question', 'QST_ID' => $new_question->ID()), TRUE);
633 633
 			} else {
634 634
 				global $wpdb;
635
-				EE_Error::add_error( sprintf( __( 'Could not duplicate question with ID %1$d because: %2$s', 'event_espresso' ), $question_ID, $wpdb->last_error ), __FILE__, __FUNCTION__, __LINE__ );
636
-			$this->_redirect_after_action(false, '', '', array('action'=>'default'), false );
635
+				EE_Error::add_error(sprintf(__('Could not duplicate question with ID %1$d because: %2$s', 'event_espresso'), $question_ID, $wpdb->last_error), __FILE__, __FUNCTION__, __LINE__);
636
+			$this->_redirect_after_action(false, '', '', array('action'=>'default'), false);
637 637
 			}
638 638
 		} else {
639
-			EE_Error::add_error( sprintf( __( 'Could not duplicate question with ID %d because it didn\'t exist!', 'event_espresso' ), $question_ID ), __FILE__, __FUNCTION__, __LINE__ );
640
-			$this->_redirect_after_action( false, '', '', array( 'action' => 'default' ), false );
639
+			EE_Error::add_error(sprintf(__('Could not duplicate question with ID %d because it didn\'t exist!', 'event_espresso'), $question_ID), __FILE__, __FUNCTION__, __LINE__);
640
+			$this->_redirect_after_action(false, '', '', array('action' => 'default'), false);
641 641
 		}
642 642
 	}
643 643
 
644 644
 
645 645
 
646 646
 	protected function _trash_or_restore_question_groups($trash = TRUE) {
647
-		return $this->_trash_or_restore_items( $this->_question_group_model, $trash );
647
+		return $this->_trash_or_restore_items($this->_question_group_model, $trash);
648 648
 	}
649 649
 
650
-	protected function _trash_question(){
651
-		$success=$this->_question_model->delete_by_ID(intval($this->_req_data['QST_ID']));
652
-		$query_args=array('action'=>'default','status'=>'all');
650
+	protected function _trash_question() {
651
+		$success = $this->_question_model->delete_by_ID(intval($this->_req_data['QST_ID']));
652
+		$query_args = array('action'=>'default', 'status'=>'all');
653 653
 		$this->_redirect_after_action($success, $this->_question_model->item_name($success), 'trashed', $query_args);
654 654
 	}
655 655
 
656 656
 
657 657
 
658
-	protected function _trash_or_restore_questions($trash=TRUE){
659
-		$this->_trash_or_restore_items( $this->_question_model, $trash );
658
+	protected function _trash_or_restore_questions($trash = TRUE) {
659
+		$this->_trash_or_restore_items($this->_question_model, $trash);
660 660
 	}
661 661
 
662 662
 
@@ -667,21 +667,21 @@  discard block
 block discarded – undo
667 667
 	 * @param EEM_Base $model
668 668
 	 * @param boolean $trash wehter to trash or restore
669 669
 	 */
670
-	private function _trash_or_restore_items( EEM_Base $model, $trash = TRUE ) {
670
+	private function _trash_or_restore_items(EEM_Base $model, $trash = TRUE) {
671 671
 
672
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
672
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
673 673
 
674 674
 		$success = 1;
675 675
 		//Checkboxes
676 676
 		//echo "trash $trash";
677 677
 		//var_dump($this->_req_data['checkbox']);die;
678
-		if ( isset( $this->_req_data['checkbox'] )) {
679
-			if ( isset( $this->_req_data['checkbox'] ) && ! empty( $this->_req_data['checkbox'] ) && is_array( $this->_req_data['checkbox'] )) {
678
+		if (isset($this->_req_data['checkbox'])) {
679
+			if (isset($this->_req_data['checkbox']) && ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
680 680
 				// if array has more than one element than success message should be plural
681
-				$success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1;
681
+				$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
682 682
 				// cycle thru bulk action checkboxes
683
-				while (list( $ID, $value ) = each($this->_req_data['checkbox'])) {
684
-					if ( ! $model->delete_or_restore_by_ID($trash,absint($ID))) {
683
+				while (list($ID, $value) = each($this->_req_data['checkbox'])) {
684
+					if ( ! $model->delete_or_restore_by_ID($trash, absint($ID))) {
685 685
 						$success = 0;
686 686
 					}
687 687
 				}
@@ -689,7 +689,7 @@  discard block
 block discarded – undo
689 689
 			} else {
690 690
 				// grab single id and delete
691 691
 				$ID = absint($this->_req_data['checkbox']);
692
-				if ( ! $model->delete_or_restore_by_ID($trash,$ID)) {
692
+				if ( ! $model->delete_or_restore_by_ID($trash, $ID)) {
693 693
 					$success = 0;
694 694
 				}
695 695
 			}
@@ -697,53 +697,53 @@  discard block
 block discarded – undo
697 697
 		} else {
698 698
 			// delete via trash link
699 699
 			// grab single id and delete
700
-			$ID = absint($this->_req_data[ $model->primary_key_name() ]);
701
-			if ( ! $model->delete_or_restore_by_ID($trash,$ID)) {
700
+			$ID = absint($this->_req_data[$model->primary_key_name()]);
701
+			if ( ! $model->delete_or_restore_by_ID($trash, $ID)) {
702 702
 				$success = 0;
703 703
 			}
704 704
 
705 705
 		}
706 706
 
707 707
 
708
-		$action = $model instanceof EEM_Question ? 'default' : 'question_groups';//strtolower( $model->item_name(2) );
708
+		$action = $model instanceof EEM_Question ? 'default' : 'question_groups'; //strtolower( $model->item_name(2) );
709 709
 		//echo "action :$action";
710 710
 		//$action = 'questions' ? 'default' : $action;
711
-		if($trash){
711
+		if ($trash) {
712 712
 			$action_desc = 'trashed';
713 713
 			$status = 'trash';
714
-		}else{
714
+		} else {
715 715
 			$action_desc = 'restored';
716 716
 			$status = 'all';
717 717
 		}
718
-		$this->_redirect_after_action( $success, $model->item_name($success), $action_desc, array( 'action' => $action, 'status'=>$status ) );
718
+		$this->_redirect_after_action($success, $model->item_name($success), $action_desc, array('action' => $action, 'status'=>$status));
719 719
 	}
720 720
 
721 721
 
722 722
 
723 723
 
724
-	public function get_trashed_questions( $per_page,$current_page = 1, $count = FALSE ) {
724
+	public function get_trashed_questions($per_page, $current_page = 1, $count = FALSE) {
725 725
 		$query_params = $this->get_query_params(EEM_Question::instance(), $per_page, $current_page);
726 726
 
727
-		if( $count ){
727
+		if ($count) {
728 728
 			//note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items
729
-			$where = isset( $query_params[0] ) ? array( $query_params[0] ) : array();
730
-			$results=$this->_question_model->count_deleted($where);
731
-		}else{
729
+			$where = isset($query_params[0]) ? array($query_params[0]) : array();
730
+			$results = $this->_question_model->count_deleted($where);
731
+		} else {
732 732
 			//note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items
733
-			$results=$this->_question_model->get_all_deleted($query_params);
733
+			$results = $this->_question_model->get_all_deleted($query_params);
734 734
 		}
735 735
 		return $results;
736 736
 	}
737 737
 
738 738
 
739 739
 
740
-	public function get_question_groups( $per_page, $current_page = 1, $count = FALSE ) {
741
-		$questionGroupModel=EEM_Question_Group::instance();
742
-		$query_params=$this->get_query_params($questionGroupModel,$per_page,$current_page);
743
-		if ($count){
744
-			$where = isset( $query_params[0] ) ? array( $query_params[0] ) : array();
740
+	public function get_question_groups($per_page, $current_page = 1, $count = FALSE) {
741
+		$questionGroupModel = EEM_Question_Group::instance();
742
+		$query_params = $this->get_query_params($questionGroupModel, $per_page, $current_page);
743
+		if ($count) {
744
+			$where = isset($query_params[0]) ? array($query_params[0]) : array();
745 745
 			$results = $questionGroupModel->count($where);
746
-		}else{
746
+		} else {
747 747
 			$results = $questionGroupModel->get_all($query_params);
748 748
 		}
749 749
 		return $results;
@@ -751,14 +751,14 @@  discard block
 block discarded – undo
751 751
 
752 752
 
753 753
 
754
-	public function get_trashed_question_groups( $per_page,$current_page = 1, $count = FALSE ) {
755
-		$questionGroupModel=EEM_Question_Group::instance();
756
-		$query_params=$this->get_query_params($questionGroupModel,$per_page,$current_page);
757
-		if($count){
758
-			$where = isset( $query_params[0] ) ? array($query_params[0]) : array();
754
+	public function get_trashed_question_groups($per_page, $current_page = 1, $count = FALSE) {
755
+		$questionGroupModel = EEM_Question_Group::instance();
756
+		$query_params = $this->get_query_params($questionGroupModel, $per_page, $current_page);
757
+		if ($count) {
758
+			$where = isset($query_params[0]) ? array($query_params[0]) : array();
759 759
 			$query_params['limit'] = NULL;
760 760
 			$results = $questionGroupModel->count_deleted($where);
761
-		}else{
761
+		} else {
762 762
 			$results = $questionGroupModel->get_all_deleted($query_params);
763 763
 		}
764 764
 		return $results;
@@ -771,22 +771,22 @@  discard block
 block discarded – undo
771 771
 	 */
772 772
 	public function update_question_group_order() {
773 773
 
774
-		$success = __( 'Question group order was updated successfully.', 'event_espresso' );
774
+		$success = __('Question group order was updated successfully.', 'event_espresso');
775 775
 
776 776
 		// grab our row IDs
777
-		$row_ids = isset( $this->_req_data['row_ids'] ) && ! empty( $this->_req_data['row_ids'] ) ? explode( ',', rtrim( $this->_req_data['row_ids'], ',' )) : FALSE;
777
+		$row_ids = isset($this->_req_data['row_ids']) && ! empty($this->_req_data['row_ids']) ? explode(',', rtrim($this->_req_data['row_ids'], ',')) : FALSE;
778 778
 
779
-		$perpage = !empty( $this->_req_data['perpage'] ) ? (int) $this->_req_data['perpage'] : NULL;
780
-		$curpage = !empty( $this->_req_data['curpage'] ) ? (int) $this->_req_data['curpage'] : NULL;
779
+		$perpage = ! empty($this->_req_data['perpage']) ? (int) $this->_req_data['perpage'] : NULL;
780
+		$curpage = ! empty($this->_req_data['curpage']) ? (int) $this->_req_data['curpage'] : NULL;
781 781
 
782
-		if ( is_array( $row_ids )) {
782
+		if (is_array($row_ids)) {
783 783
 			//figure out where we start the row_id count at for the current page.
784
-			$qsgcount = empty( $curpage ) ? 0 : ($curpage - 1 ) * $perpage;
784
+			$qsgcount = empty($curpage) ? 0 : ($curpage - 1) * $perpage;
785 785
 
786 786
 			global $wpdb;
787
-			for ( $i = 0; $i < count($row_ids); $i++ ) {
787
+			for ($i = 0; $i < count($row_ids); $i++) {
788 788
 				//Update the questions when re-ordering
789
-				if ( EEM_Question_Group::instance()->update ( array( 'QSG_order' => $qsgcount ), array(array( 'QSG_ID' => $row_ids[$i] ))) === FALSE ) {
789
+				if (EEM_Question_Group::instance()->update(array('QSG_order' => $qsgcount), array(array('QSG_ID' => $row_ids[$i]))) === FALSE) {
790 790
 					$success = FALSE;
791 791
 				}
792 792
 				$qsgcount++;
@@ -795,9 +795,9 @@  discard block
 block discarded – undo
795 795
 			$success = FALSE;
796 796
 		}
797 797
 
798
-		$errors = ! $success ? __( 'An error occurred. The question group order was not updated.', 'event_espresso' ) : FALSE;
798
+		$errors = ! $success ? __('An error occurred. The question group order was not updated.', 'event_espresso') : FALSE;
799 799
 
800
-		echo json_encode( array( 'return_data' => FALSE, 'success' => $success, 'errors' => $errors ));
800
+		echo json_encode(array('return_data' => FALSE, 'success' => $success, 'errors' => $errors));
801 801
 		die();
802 802
 
803 803
 	}
@@ -814,10 +814,10 @@  discard block
 block discarded – undo
814 814
 
815 815
 	protected function _reg_form_settings() {
816 816
 		$this->_template_args['values'] = $this->_yes_no_values;
817
-		$this->_template_args = apply_filters( 'FHEE__Extend_Registration_Form_Admin_Page___reg_form_settings___template_args', $this->_template_args );
818
-		$this->_set_add_edit_form_tags( 'update_reg_form_settings' );
819
-		$this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
820
-		$this->_template_args['admin_page_content'] = EEH_Template::display_template( REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'reg_form_settings.template.php', $this->_template_args, TRUE );
817
+		$this->_template_args = apply_filters('FHEE__Extend_Registration_Form_Admin_Page___reg_form_settings___template_args', $this->_template_args);
818
+		$this->_set_add_edit_form_tags('update_reg_form_settings');
819
+		$this->_set_publish_post_box_vars(NULL, FALSE, FALSE, NULL, FALSE);
820
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(REGISTRATION_FORM_CAF_TEMPLATE_PATH.'reg_form_settings.template.php', $this->_template_args, TRUE);
821 821
 		$this->display_admin_page_with_sidebar();
822 822
 	}
823 823
 
@@ -825,9 +825,9 @@  discard block
 block discarded – undo
825 825
 
826 826
 
827 827
 	protected function _update_reg_form_settings() {
828
-		EE_Registry::instance()->CFG->registration = apply_filters( 'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration', EE_Registry::instance()->CFG->registration );
829
-		$success = $this->_update_espresso_configuration( __('Registration Form Options', 'event_espresso'), EE_Registry::instance()->CFG, __FILE__, __FUNCTION__, __LINE__ );
830
-		$this->_redirect_after_action( $success, __('Registration Form Options', 'event_espresso'), 'updated', array( 'action' => 'view_reg_form_settings' ) );
828
+		EE_Registry::instance()->CFG->registration = apply_filters('FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration', EE_Registry::instance()->CFG->registration);
829
+		$success = $this->_update_espresso_configuration(__('Registration Form Options', 'event_espresso'), EE_Registry::instance()->CFG, __FILE__, __FUNCTION__, __LINE__);
830
+		$this->_redirect_after_action($success, __('Registration Form Options', 'event_espresso'), 'updated', array('action' => 'view_reg_form_settings'));
831 831
 	}
832 832
 
833 833
 }
Please login to merge, or discard this patch.
core/db_classes/EE_Base_Class.class.php 4 patches
Doc Comments   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -510,7 +510,7 @@  discard block
 block discarded – undo
510 510
 	 * @access protected
511 511
 	 * @param string $fieldname the property item the corresponding value is for.
512 512
 	 * @param mixed  $value     The value we are caching.
513
-	 * @param null   $cache_type
513
+	 * @param string   $cache_type
514 514
 	 * @return void
515 515
 	 */
516 516
 	protected function _set_cached_property( $fieldname, $value, $cache_type = NULL ) {
@@ -823,7 +823,7 @@  discard block
 block discarded – undo
823 823
 	 *
824 824
 	 * @param null $field_to_order_by   What field is being used as the reference point.
825 825
 	 * @param array $query_params       Any additional conditions on the query.
826
-	 * @param null $columns_to_select   If left null, then an array of EE_Base_Class objects is returned, otherwise
826
+	 * @param string $columns_to_select   If left null, then an array of EE_Base_Class objects is returned, otherwise
827 827
 	 *                                  you can indicate just the columns you want returned
828 828
 	 *
829 829
 	 * @return array|EE_Base_Class
@@ -848,7 +848,7 @@  discard block
 block discarded – undo
848 848
 	 *
849 849
 	 * @param null $field_to_order_by   What field is being used as the reference point.
850 850
 	 * @param array $query_params       Any additional conditions on the query.
851
-	 * @param null $columns_to_select   If left null, then an EE_Base_Class object is returned, otherwise
851
+	 * @param string $columns_to_select   If left null, then an EE_Base_Class object is returned, otherwise
852 852
 	 *                                  you can indicate just the column you want returned
853 853
 	 *
854 854
 	 * @return array|EE_Base_Class
@@ -911,7 +911,7 @@  discard block
 block discarded – undo
911 911
 	/**
912 912
 	 * This method simply returns the RAW unprocessed value for the given property in this class
913 913
 	 * @param  string $field_name A valid fieldname
914
-	 * @return mixed              Whatever the raw value stored on the property is.
914
+	 * @return integer|null              Whatever the raw value stored on the property is.
915 915
 	 * @throws EE_Error if fieldSettings is misconfigured or the field doesn't exist.
916 916
 	 */
917 917
 	public function get_raw($field_name) {
@@ -985,11 +985,11 @@  discard block
 block discarded – undo
985 985
 	 *
986 986
 	 * @access   protected
987 987
 	 * @param  string  $field_name   Field on the instantiated EE_Base_Class child object
988
-	 * @param null     $dt_frmt 	valid datetime format used for date (if '' then we just use the default on the field, if NULL we use the last-used format)
989
-	 * @param null     $tm_frmt 	Same as above except this is for time format
988
+	 * @param string|null     $dt_frmt 	valid datetime format used for date (if '' then we just use the default on the field, if NULL we use the last-used format)
989
+	 * @param null|string     $tm_frmt 	Same as above except this is for time format
990 990
 	 * @param string   $date_or_time if NULL then both are returned, otherwise "D" = only date and "T" = only time.
991 991
 	 * @param  boolean $echo         Whether the dtt is echoing using pretty echoing or just returned using vanilla get
992
-	 * @return void | string | bool | EE_Error string on success, FALSE on fail, or EE_Error Exception is thrown if field is not a valid dtt field, or void if echoing
992
+	 * @return string|boolean | string | bool | EE_Error string on success, FALSE on fail, or EE_Error Exception is thrown if field is not a valid dtt field, or void if echoing
993 993
 	 */
994 994
 	protected function _get_datetime( $field_name, $dt_frmt = NULL, $tm_frmt = NULL, $date_or_time = NULL, $echo = FALSE ) {
995 995
 
@@ -1162,7 +1162,7 @@  discard block
 block discarded – undo
1162 1162
 	 * sets the time on a datetime property
1163 1163
 	 *
1164 1164
 	 * @access protected
1165
-	 * @param string|Datetime $time      a valid time string for php datetime functions (or DateTime object)
1165
+	 * @param string $time      a valid time string for php datetime functions (or DateTime object)
1166 1166
 	 * @param string $fieldname the name of the field the time is being set on (must match a EE_Datetime_Field)
1167 1167
 	 */
1168 1168
 	protected function _set_time_for( $time, $fieldname ) {
@@ -1177,7 +1177,7 @@  discard block
 block discarded – undo
1177 1177
 	 * sets the date on a datetime property
1178 1178
 	 *
1179 1179
 	 * @access protected
1180
-	 * @param string|DateTime $date      a valid date string for php datetime functions ( or DateTime object)
1180
+	 * @param string $date      a valid date string for php datetime functions ( or DateTime object)
1181 1181
 	 * @param string $fieldname the name of the field the date is being set on (must match a EE_Datetime_Field)
1182 1182
 	 */
1183 1183
 	protected function _set_date_for( $date, $fieldname ) {
@@ -1506,7 +1506,7 @@  discard block
 block discarded – undo
1506 1506
 
1507 1507
 	/**
1508 1508
 	 * for getting a model while instantiated.
1509
-	 * @return \EEM_Base | \EEM_CPT_Base
1509
+	 * @return boolean | \EEM_CPT_Base
1510 1510
 	 */
1511 1511
 	public function get_model() {
1512 1512
 		$modelName = self::_get_model_classname( get_class($this) );
@@ -1537,7 +1537,7 @@  discard block
 block discarded – undo
1537 1537
 	 * If there is a key in the incoming array that matches the primary key for the model AND it is not null, then we check the db. If there's a an object we return it.  If not we return false.
1538 1538
 	 * @param  array  $props_n_values incoming array of properties and their values
1539 1539
 	 * @param  string $classname      the classname of the child class
1540
-	 * @param null    $timezone
1540
+	 * @param null|string    $timezone
1541 1541
 	 * @return mixed (EE_Base_Class|bool)
1542 1542
 	 */
1543 1543
 	protected static function _check_for_object( $props_n_values, $classname, $timezone = NULL ) {
@@ -1573,7 +1573,7 @@  discard block
 block discarded – undo
1573 1573
 	 * @param      $classname
1574 1574
 	 * @param null $timezone
1575 1575
 	 * @throws EE_Error
1576
-	 * @return EEM_Base
1576
+	 * @return boolean
1577 1577
 	 */
1578 1578
 	protected static function  _get_model( $classname, $timezone = NULL ){
1579 1579
 		//find model for this class
@@ -1589,8 +1589,8 @@  discard block
 block discarded – undo
1589 1589
 	/**
1590 1590
 	 * Gets the model instance (eg instance of EEM_Attendee) given its classname (eg EE_Attendee)
1591 1591
 	 * @param string $model_classname
1592
-	 * @param null   $timezone
1593
-	 * @return EEM_Base
1592
+	 * @param string|null   $timezone
1593
+	 * @return boolean
1594 1594
 	 */
1595 1595
 	protected static function _get_model_instance_with_name($model_classname, $timezone = NULL){
1596 1596
 		$model_classname = str_replace( 'EEM_', '', $model_classname );
Please login to merge, or discard this patch.
Indentation   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -47,25 +47,25 @@  discard block
 block discarded – undo
47 47
 
48 48
 
49 49
 	/**
50
-    *	date format
51
-	*
52
-    *	pattern or format for displaying dates
53
-	*
54
-	*	@access	protected
55
-    *	@var string
56
-    */
50
+	 *	date format
51
+	 *
52
+	 *	pattern or format for displaying dates
53
+	 *
54
+	 *	@access	protected
55
+	 *	@var string
56
+	 */
57 57
 	protected $_dt_frmt;
58 58
 
59 59
 
60 60
 
61
-    /**
62
-    *	time format
63
-	*
64
-    *	pattern or format for displaying time
65
-	*
66
-	*	@access	protected
67
-    *	@var string
68
-    */
61
+	/**
62
+	 *	time format
63
+	 *
64
+	 *	pattern or format for displaying time
65
+	 *
66
+	 *	@access	protected
67
+	 *	@var string
68
+	 */
69 69
 	protected $_tm_frmt;
70 70
 
71 71
 
@@ -205,12 +205,12 @@  discard block
 block discarded – undo
205 205
 
206 206
 
207 207
 		/**
208
-	 * Gets the field's original value when this object was constructed during this request.
209
-	 * This can be helpful when determining if a model object has changed or not
210
-	 *
211
-	 * @param string $field_name
212
-	 * @return mixed|null
213
-	 */
208
+		 * Gets the field's original value when this object was constructed during this request.
209
+		 * This can be helpful when determining if a model object has changed or not
210
+		 *
211
+		 * @param string $field_name
212
+		 * @return mixed|null
213
+		 */
214 214
 	public function get_original( $field_name ){
215 215
 		if( isset( $this->_props_n_values_provided_in_constructor[ $field_name ] ) &&
216 216
 				$field_settings = $this->get_Model()->field_settings_for( $field_name )){
@@ -1310,28 +1310,28 @@  discard block
 block discarded – undo
1310 1310
 		return $result ? true : false;
1311 1311
 	}
1312 1312
 
1313
-        /**
1314
-         * When this model object is deleted, it may still be cached on related model objects. This clears the cache of
1315
-         * related model objects
1316
-         */
1317
-        public function refresh_cache_of_related_objects() {
1318
-            foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ) {
1319
-                if( ! empty( $this->_model_relations[ $relation_name ] ) ) {
1320
-                    $related_objects = $this->_model_relations[ $relation_name ];
1321
-                    if( $relation_obj instanceof EE_Belongs_To_Relation ) {
1322
-                        //this relation only stores a single model object, not an array
1323
-                        //but let's make it consistent
1324
-                        $related_objects = array( $related_objects );
1325
-                    }
1326
-                    foreach( $related_objects as $related_object ) {
1327
-                        //only refresh their cache if they're in memory
1328
-                        if( $related_object instanceof EE_Base_Class ) {
1313
+		/**
1314
+		 * When this model object is deleted, it may still be cached on related model objects. This clears the cache of
1315
+		 * related model objects
1316
+		 */
1317
+		public function refresh_cache_of_related_objects() {
1318
+			foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ) {
1319
+				if( ! empty( $this->_model_relations[ $relation_name ] ) ) {
1320
+					$related_objects = $this->_model_relations[ $relation_name ];
1321
+					if( $relation_obj instanceof EE_Belongs_To_Relation ) {
1322
+						//this relation only stores a single model object, not an array
1323
+						//but let's make it consistent
1324
+						$related_objects = array( $related_objects );
1325
+					}
1326
+					foreach( $related_objects as $related_object ) {
1327
+						//only refresh their cache if they're in memory
1328
+						if( $related_object instanceof EE_Base_Class ) {
1329 1329
 							$related_object->clear_cache( $this->get_model()->get_this_model_name(), $this );
1330
-                        }
1331
-                    }
1332
-                }
1333
-            }
1334
-        }
1330
+						}
1331
+					}
1332
+				}
1333
+			}
1334
+		}
1335 1335
 
1336 1336
 
1337 1337
 
@@ -1681,9 +1681,9 @@  discard block
 block discarded – undo
1681 1681
 			$otherObject = $this->get_model()->add_relationship_to( $this, $otherObjectModelObjectOrID, $relationName, $extra_join_model_fields_n_values );
1682 1682
 			//clear cache so future get_many_related and get_first_related() return new results.
1683 1683
 			$this->clear_cache( $relationName, $otherObject, TRUE );
1684
-                        if( $otherObject instanceof EE_Base_Class ) {
1685
-                            $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this );
1686
-                        }
1684
+						if( $otherObject instanceof EE_Base_Class ) {
1685
+							$otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this );
1686
+						}
1687 1687
 		} else {
1688 1688
 			//this thing doesn't exist in the DB,  so just cache it
1689 1689
 			if( ! $otherObjectModelObjectOrID instanceof EE_Base_Class){
@@ -1697,18 +1697,18 @@  discard block
 block discarded – undo
1697 1697
 			}
1698 1698
 			$this->cache( $relationName, $otherObjectModelObjectOrID, $cache_id );
1699 1699
 		}
1700
-                if( $otherObject instanceof EE_Base_Class ) {
1701
-                    //fix the reciprocal relation too
1702
-                    if( $otherObject->ID() ) {
1703
-                            //its saved so assumed relations exist in the DB, so we can just
1704
-                            //clear the cache so future queries use the updated info in the DB
1705
-                            $otherObject->clear_cache( $this->get_model()->get_this_model_name(), null, true );
1706
-                    } else {
1707
-
1708
-                            //it's not saved, so it caches relations like this
1709
-                            $otherObject->cache( $this->get_model()->get_this_model_name(), $this );
1710
-                    }
1711
-                }
1700
+				if( $otherObject instanceof EE_Base_Class ) {
1701
+					//fix the reciprocal relation too
1702
+					if( $otherObject->ID() ) {
1703
+							//its saved so assumed relations exist in the DB, so we can just
1704
+							//clear the cache so future queries use the updated info in the DB
1705
+							$otherObject->clear_cache( $this->get_model()->get_this_model_name(), null, true );
1706
+					} else {
1707
+
1708
+							//it's not saved, so it caches relations like this
1709
+							$otherObject->cache( $this->get_model()->get_this_model_name(), $this );
1710
+					}
1711
+				}
1712 1712
 		return $otherObject;
1713 1713
 	}
1714 1714
 
@@ -1738,9 +1738,9 @@  discard block
 block discarded – undo
1738 1738
 			//this doesn't exist in the DB, just remove it from the cache
1739 1739
 			$otherObject = $this->clear_cache( $relationName, $otherObjectModelObjectOrID );
1740 1740
 		}
1741
-                if( $otherObject instanceof EE_Base_Class ) {
1742
-                    $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this );
1743
-                }
1741
+				if( $otherObject instanceof EE_Base_Class ) {
1742
+					$otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this );
1743
+				}
1744 1744
 		return $otherObject;
1745 1745
 	}
1746 1746
 
@@ -1759,11 +1759,11 @@  discard block
 block discarded – undo
1759 1759
 			//this doesn't exist in the DB, just remove it from the cache
1760 1760
 			$otherObjects = $this->clear_cache( $relationName, null, true );
1761 1761
 		}
1762
-                if( is_array( $otherObjects ) ) {
1763
-                    foreach ( $otherObjects as $otherObject ) {
1764
-                            $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this );
1765
-                    }
1766
-                }
1762
+				if( is_array( $otherObjects ) ) {
1763
+					foreach ( $otherObjects as $otherObject ) {
1764
+							$otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this );
1765
+					}
1766
+				}
1767 1767
 		return $otherObjects;
1768 1768
 	}
1769 1769
 
Please login to merge, or discard this patch.
Spacing   +481 added lines, -481 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1
-<?php if (!defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
2
-do_action( 'AHEE_log', __FILE__, ' FILE LOADED', '' );
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
2
+do_action('AHEE_log', __FILE__, ' FILE LOADED', '');
3 3
 /**
4 4
  *
5 5
  * Event Espresso
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
  * ------------------------------------------------------------------------
25 25
  */
26 26
 
27
-abstract class EE_Base_Class{
27
+abstract class EE_Base_Class {
28 28
 
29 29
 	/**
30 30
 	 * This is an array of the original properties and values provided during construction
@@ -117,60 +117,60 @@  discard block
 block discarded – undo
117 117
 	 * @throws EE_Error
118 118
 	 * @return \EE_Base_Class
119 119
 	 */
120
-	protected function __construct( $fieldValues = array(), $bydb = FALSE, $timezone = '', $date_formats = array() ){
120
+	protected function __construct($fieldValues = array(), $bydb = FALSE, $timezone = '', $date_formats = array()) {
121 121
 
122
-		$className=get_class($this);
122
+		$className = get_class($this);
123 123
 
124
-		do_action("AHEE__{$className}__construct",$this,$fieldValues);
125
-		$model=$this->get_model();
126
-		$model_fields = $model->field_settings( FALSE );
124
+		do_action("AHEE__{$className}__construct", $this, $fieldValues);
125
+		$model = $this->get_model();
126
+		$model_fields = $model->field_settings(FALSE);
127 127
 		// ensure $fieldValues is an array
128
-		$fieldValues = is_array( $fieldValues ) ? $fieldValues : array( $fieldValues );
128
+		$fieldValues = is_array($fieldValues) ? $fieldValues : array($fieldValues);
129 129
 		// EEH_Debug_Tools::printr( $fieldValues, '$fieldValues  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
130 130
 		// verify client code has not passed any invalid field names
131
-		foreach($fieldValues as $field_name=> $field_value){
132
-			if( ! isset( $model_fields[ $field_name] ) ){
133
-				throw new EE_Error(sprintf(__("Invalid field (%s) passed to constructor of %s. Allowed fields are :%s", "event_espresso"),$field_name,get_class($this),implode(", ",array_keys($model_fields))));
131
+		foreach ($fieldValues as $field_name=> $field_value) {
132
+			if ( ! isset($model_fields[$field_name])) {
133
+				throw new EE_Error(sprintf(__("Invalid field (%s) passed to constructor of %s. Allowed fields are :%s", "event_espresso"), $field_name, get_class($this), implode(", ", array_keys($model_fields))));
134 134
 			}
135 135
 		}
136 136
 		// EEH_Debug_Tools::printr( $model_fields, '$model_fields  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
137
-		EE_Registry::instance()->load_helper( 'DTT_Helper' );
138
-		$this->_timezone = EEH_DTT_Helper::get_valid_timezone_string( $timezone );
137
+		EE_Registry::instance()->load_helper('DTT_Helper');
138
+		$this->_timezone = EEH_DTT_Helper::get_valid_timezone_string($timezone);
139 139
 
140
-		if ( ! empty( $date_formats ) && is_array( $date_formats ) ) {
140
+		if ( ! empty($date_formats) && is_array($date_formats)) {
141 141
 			$this->_dt_frmt = $date_formats[0];
142 142
 			$this->_tm_frmt = $date_formats[1];
143 143
 		} else {
144 144
 			//set default formats for date and time
145
-			$this->_dt_frmt = get_option( 'date_format' );
146
-			$this->_tm_frmt = get_option( 'time_format' );
145
+			$this->_dt_frmt = get_option('date_format');
146
+			$this->_tm_frmt = get_option('time_format');
147 147
 		}
148 148
 
149 149
 		//if db model is instantiating
150
-		if ( $bydb ){
150
+		if ($bydb) {
151 151
 			//client code has indicated these field values are from the database
152
-			foreach( $model_fields as $fieldName => $field ){
153
-				$this->set_from_db( $fieldName, isset( $fieldValues[ $fieldName] ) ? $fieldValues[ $fieldName ] : null );
152
+			foreach ($model_fields as $fieldName => $field) {
153
+				$this->set_from_db($fieldName, isset($fieldValues[$fieldName]) ? $fieldValues[$fieldName] : null);
154 154
 			}
155 155
 		} else {
156 156
 			//we're constructing a brand
157 157
 			//new instance of the model object. Generally, this means we'll need to do more field validation
158
-			foreach( $model_fields as $fieldName => $field ){
159
-				$this->set( $fieldName, isset( $fieldValues[ $fieldName ] ) ? $fieldValues[ $fieldName ] : null, true );
158
+			foreach ($model_fields as $fieldName => $field) {
159
+				$this->set($fieldName, isset($fieldValues[$fieldName]) ? $fieldValues[$fieldName] : null, true);
160 160
 			}
161 161
 		}
162 162
 
163 163
 		//remember what values were passed to this constructor
164 164
 		$this->_props_n_values_provided_in_constructor = $fieldValues;
165 165
 		//remember in entity mapper
166
-		if($model->has_primary_key_field() && $this->ID() && ! $bydb ){
166
+		if ($model->has_primary_key_field() && $this->ID() && ! $bydb) {
167 167
 			$model->add_to_entity_map($this);
168 168
 		}
169 169
 		//setup all the relations
170
-		foreach($this->get_model()->relation_settings() as $relation_name=>$relation_obj){
171
-			if($relation_obj instanceof EE_Belongs_To_Relation){
170
+		foreach ($this->get_model()->relation_settings() as $relation_name=>$relation_obj) {
171
+			if ($relation_obj instanceof EE_Belongs_To_Relation) {
172 172
 				$this->_model_relations[$relation_name] = NULL;
173
-			}else{
173
+			} else {
174 174
 				$this->_model_relations[$relation_name] = array();
175 175
 			}
176 176
 		}
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 		 * Action done at the end of each model object construction
179 179
 		 * @param EE_Base_Class $this the model object just created
180 180
 		 */
181
-		do_action( 'AHEE__EE_Base_Class__construct__finished', $this );
181
+		do_action('AHEE__EE_Base_Class__construct__finished', $this);
182 182
 	}
183 183
 
184 184
 	/**
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 	 * @param boolean $allow_persist
199 199
 	 * @return boolean
200 200
 	 */
201
-	function set_allow_persist( $allow_persist ) {
201
+	function set_allow_persist($allow_persist) {
202 202
 		return $this->_allow_persist = $allow_persist;
203 203
 	}
204 204
 
@@ -211,11 +211,11 @@  discard block
 block discarded – undo
211 211
 	 * @param string $field_name
212 212
 	 * @return mixed|null
213 213
 	 */
214
-	public function get_original( $field_name ){
215
-		if( isset( $this->_props_n_values_provided_in_constructor[ $field_name ] ) &&
216
-				$field_settings = $this->get_Model()->field_settings_for( $field_name )){
217
-			return $field_settings->prepare_for_get( $this->_props_n_values_provided_in_constructor[ $field_name ] );
218
-		}else{
214
+	public function get_original($field_name) {
215
+		if (isset($this->_props_n_values_provided_in_constructor[$field_name]) &&
216
+				$field_settings = $this->get_Model()->field_settings_for($field_name)) {
217
+			return $field_settings->prepare_for_get($this->_props_n_values_provided_in_constructor[$field_name]);
218
+		} else {
219 219
 			return NULL;
220 220
 		}
221 221
 	}
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 	 * @param EE_Base_Class $obj
226 226
 	 * @return string
227 227
 	 */
228
-	public function get_class($obj){
228
+	public function get_class($obj) {
229 229
 		return get_class($obj);
230 230
 	}
231 231
 
@@ -238,19 +238,19 @@  discard block
 block discarded – undo
238 238
 	 * @param	mixed 	$field_value
239 239
 	 * @param bool 	$use_default
240 240
 	 */
241
-	public function set( $field_name, $field_value, $use_default = FALSE ){
242
-		$field_obj = $this->get_model()->field_settings_for( $field_name );
243
-		if ( $field_obj instanceof EE_Model_Field_Base ) {
241
+	public function set($field_name, $field_value, $use_default = FALSE) {
242
+		$field_obj = $this->get_model()->field_settings_for($field_name);
243
+		if ($field_obj instanceof EE_Model_Field_Base) {
244 244
 //			if ( method_exists( $field_obj, 'set_timezone' )) {
245
-			if ( $field_obj instanceof EE_Datetime_Field ) {
246
-				$field_obj->set_timezone( $this->_timezone );
247
-				$field_obj->set_date_format( $this->_dt_frmt );
248
-				$field_obj->set_time_format( $this->_tm_frmt );
245
+			if ($field_obj instanceof EE_Datetime_Field) {
246
+				$field_obj->set_timezone($this->_timezone);
247
+				$field_obj->set_date_format($this->_dt_frmt);
248
+				$field_obj->set_time_format($this->_tm_frmt);
249 249
 			}
250 250
 
251 251
 			$holder_of_value = $field_obj->prepare_for_set($field_value);
252 252
 			//should the value be null?
253
-			if( ($field_value === NULL || $holder_of_value === NULL || $holder_of_value ==='') && $use_default){
253
+			if (($field_value === NULL || $holder_of_value === NULL || $holder_of_value === '') && $use_default) {
254 254
 				$this->_fields[$field_name] = $field_obj->get_default_value();
255 255
 
256 256
 				/**
@@ -260,19 +260,19 @@  discard block
 block discarded – undo
260 260
 				 * object.
261 261
 				 * @since 4.6.10+
262 262
 				 */
263
-				if ( $field_obj instanceof EE_Datetime_Field && ! is_null( $this->_fields[$field_name] ) && ! $this->_fields[$field_name] instanceof DateTime ) {
264
-					empty( $this->_fields[$field_name] ) ? $this->set( $field_name, time() ) : $this->set( $field_name, $this->_fields[$field_name] );
263
+				if ($field_obj instanceof EE_Datetime_Field && ! is_null($this->_fields[$field_name]) && ! $this->_fields[$field_name] instanceof DateTime) {
264
+					empty($this->_fields[$field_name]) ? $this->set($field_name, time()) : $this->set($field_name, $this->_fields[$field_name]);
265 265
 				}
266 266
 
267
-			}else{
267
+			} else {
268 268
 				$this->_fields[$field_name] = $holder_of_value;
269 269
 			}
270 270
 
271 271
 			//if we're not in the constructor...
272 272
 			//now check if what we set was a primary key
273
-			if($this->_props_n_values_provided_in_constructor && //note: props_n_values_provided_in_constructor is only set at the END of the constructor
273
+			if ($this->_props_n_values_provided_in_constructor && //note: props_n_values_provided_in_constructor is only set at the END of the constructor
274 274
 				$field_name == $this->_get_primary_key_name(get_class($this)) &&
275
-				$field_value){
275
+				$field_value) {
276 276
 				//if so, we want all this object's fields to be filled either with
277 277
 				//what we've explicitly set on this model
278 278
 				//or what we have in the db
@@ -280,20 +280,20 @@  discard block
 block discarded – undo
280 280
 				$fields_on_model = $this->_get_model(get_class($this))->field_settings();
281 281
 
282 282
 				$obj_in_db = $this->_get_model(get_class($this))->get_one_by_ID($field_value);
283
-				foreach($fields_on_model as $field_obj){
284
-					if( ! array_key_exists($field_obj->get_name(), $this->_props_n_values_provided_in_constructor)
285
-						&& $field_obj->get_name() != $field_name ){
283
+				foreach ($fields_on_model as $field_obj) {
284
+					if ( ! array_key_exists($field_obj->get_name(), $this->_props_n_values_provided_in_constructor)
285
+						&& $field_obj->get_name() != $field_name) {
286 286
 
287
-						$this->set($field_obj->get_name(),$obj_in_db->get($field_obj->get_name()));
287
+						$this->set($field_obj->get_name(), $obj_in_db->get($field_obj->get_name()));
288 288
 					}
289 289
 				}
290 290
 				//oh this model object has an ID? well make sure its in the entity mapper
291 291
 				$this->get_model()->add_to_entity_map($this);
292 292
 			}
293 293
 			//let's unset any cache for this field_name from the $_cached_properties property.
294
-			$this->_clear_cached_property( $field_name );
295
-		}else{
296
-			throw new EE_Error( sprintf( __( "A valid EE_Model_Field_Base could not be found for the given field name: %s", "event_espresso" ), $field_name  ) );
294
+			$this->_clear_cached_property($field_name);
295
+		} else {
296
+			throw new EE_Error(sprintf(__("A valid EE_Model_Field_Base could not be found for the given field name: %s", "event_espresso"), $field_name));
297 297
 		}
298 298
 
299 299
 	}
@@ -312,14 +312,14 @@  discard block
 block discarded – undo
312 312
 	 * @param mixed  $field_value  The value to set.
313 313
 	 * @return int|bool @see EE_Base_Class::update_extra_meta() for return docs.
314 314
 	 */
315
-	public function set_field_or_extra_meta( $field_name, $field_value ) {
316
-		if ( $this->get_model()->has_field( $field_name ) ) {
317
-			$this->set( $field_name, $field_value );
315
+	public function set_field_or_extra_meta($field_name, $field_value) {
316
+		if ($this->get_model()->has_field($field_name)) {
317
+			$this->set($field_name, $field_value);
318 318
 			return true;
319 319
 		} else {
320 320
 			//ensure this object is saved first so that extra meta can be properly related.
321 321
 			$this->save();
322
-			return $this->update_extra_meta( $field_name, $field_value );
322
+			return $this->update_extra_meta($field_name, $field_value);
323 323
 		}
324 324
 	}
325 325
 
@@ -343,12 +343,12 @@  discard block
 block discarded – undo
343 343
 	 * @param  string $field_name  expecting the fully qualified field name.
344 344
 	 * @return mixed|null  value for the field if found.  null if not found.
345 345
 	 */
346
-	public function get_field_or_extra_meta( $field_name ) {
347
-		if ( $this->get_model()->has_field( $field_name ) ) {
348
-			$column_value = $this->get( $field_name );
346
+	public function get_field_or_extra_meta($field_name) {
347
+		if ($this->get_model()->has_field($field_name)) {
348
+			$column_value = $this->get($field_name);
349 349
 		} else {
350 350
 			//This isn't a column in the main table, let's see if it is in the extra meta.
351
-			$column_value = $this->get_extra_meta( $field_name, true, null );
351
+			$column_value = $this->get_extra_meta($field_name, true, null);
352 352
 		}
353 353
 		return $column_value;
354 354
 	}
@@ -367,19 +367,19 @@  discard block
 block discarded – undo
367 367
 	 * @param string $timezone A valid timezone string as described by @link http://www.php.net/manual/en/timezones.php
368 368
 	 * @return void
369 369
 	 */
370
-	public function set_timezone( $timezone = '' ) {
370
+	public function set_timezone($timezone = '') {
371 371
 		EE_Registry::instance()->load_helper('DTT_Helper');
372
-		$this->_timezone = EEH_DTT_Helper::get_valid_timezone_string( $timezone );
372
+		$this->_timezone = EEH_DTT_Helper::get_valid_timezone_string($timezone);
373 373
 		//make sure we clear all cached properties because they won't be relevant now
374 374
 		$this->_clear_cached_properties();
375 375
 
376 376
 		//make sure we update field settings and the date for all EE_Datetime_Fields
377
-		$model_fields = $this->get_model()->field_settings( false );
378
-		foreach ( $model_fields as $field_name => $field_obj ) {
379
-			if ( $field_obj instanceof EE_Datetime_Field ) {
380
-				$field_obj->set_timezone( $this->_timezone );
381
-				if ( isset( $this->_fields[$field_name] ) && $this->_fields[$field_name] instanceof DateTime ) {
382
-					$this->_fields[$field_name]->setTimezone( new DateTimeZone( $this->_timezone ) );
377
+		$model_fields = $this->get_model()->field_settings(false);
378
+		foreach ($model_fields as $field_name => $field_obj) {
379
+			if ($field_obj instanceof EE_Datetime_Field) {
380
+				$field_obj->set_timezone($this->_timezone);
381
+				if (isset($this->_fields[$field_name]) && $this->_fields[$field_name] instanceof DateTime) {
382
+					$this->_fields[$field_name]->setTimezone(new DateTimeZone($this->_timezone));
383 383
 				}
384 384
 			}
385 385
 		}
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
 	 *
409 409
 	 * @param string $format   should be a format recognizable by PHP date() functions.
410 410
 	 */
411
-	public function set_date_format( $format ) {
411
+	public function set_date_format($format) {
412 412
 		$this->_dt_frmt = $format;
413 413
 		//clear cached_properties because they won't be relevant now.
414 414
 		$this->_clear_cached_properties();
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
 	 * @since 4.6
425 425
 	 * @param string $format should be a format recognizable by PHP date() functions.
426 426
 	 */
427
-	public function set_time_format( $format ) {
427
+	public function set_time_format($format) {
428 428
 		$this->_tm_frmt = $format;
429 429
 		//clear cached_properties because they won't be relevant now.
430 430
 		$this->_clear_cached_properties();
@@ -441,8 +441,8 @@  discard block
 block discarded – undo
441 441
 	 *
442 442
 	 * @return mixed string|array
443 443
 	 */
444
-	public function get_format( $full = true ) {
445
-		return $full ? $this->_dt_frmt . ' ' . $this->_tm_frmt : array( $this->_dt_frmt, $this->_tm_frmt );
444
+	public function get_format($full = true) {
445
+		return $full ? $this->_dt_frmt.' '.$this->_tm_frmt : array($this->_dt_frmt, $this->_tm_frmt);
446 446
 	}
447 447
 
448 448
 
@@ -460,17 +460,17 @@  discard block
 block discarded – undo
460 460
 	 * @throws EE_Error
461 461
 	 * @return mixed    index into cache, or just TRUE if the relation is of type Belongs_To (because there's only one related thing, no array)
462 462
 	 */
463
-	public function cache( $relationName = '', $object_to_cache = NULL, $cache_id = NULL ){
463
+	public function cache($relationName = '', $object_to_cache = NULL, $cache_id = NULL) {
464 464
 		// its entirely possible that there IS no related object yet in which case there is nothing to cache.
465
-		if ( ! $object_to_cache instanceof EE_Base_Class ) {
465
+		if ( ! $object_to_cache instanceof EE_Base_Class) {
466 466
 			return FALSE;
467 467
 		}
468 468
 		// also get "how" the object is related, or throw an error
469
-		if( ! $relationship_to_model = $this->get_model()->related_settings_for( $relationName )) {
470
-			throw new EE_Error( sprintf( __( 'There is no relationship to %s on a %s. Cannot cache it', 'event_espresso' ), $relationName, get_class( $this )));
469
+		if ( ! $relationship_to_model = $this->get_model()->related_settings_for($relationName)) {
470
+			throw new EE_Error(sprintf(__('There is no relationship to %s on a %s. Cannot cache it', 'event_espresso'), $relationName, get_class($this)));
471 471
 		}
472 472
 		// how many things are related ?
473
-		if( $relationship_to_model instanceof EE_Belongs_To_Relation ){
473
+		if ($relationship_to_model instanceof EE_Belongs_To_Relation) {
474 474
 			// if it's a "belongs to" relationship, then there's only one related model object  eg, if this is a registration, there's only 1 attendee for it
475 475
 			// so for these model objects just set it to be cached
476 476
 			$this->_model_relations[$relationName] = $object_to_cache;
@@ -478,26 +478,26 @@  discard block
 block discarded – undo
478 478
 		} else {
479 479
 			// otherwise, this is the "many" side of a one to many relationship, so we'll add the object to the array of related objects for that type.
480 480
 			// eg: if this is an event, there are many registrations for that event, so we cache the registrations in an array
481
-			if( ! is_array( $this->_model_relations[$relationName] )) {
481
+			if ( ! is_array($this->_model_relations[$relationName])) {
482 482
 				// if for some reason, the cached item is a model object, then stick that in the array, otherwise start with an empty array
483
-				$this->_model_relations[$relationName] = $this->_model_relations[$relationName] instanceof EE_Base_Class ? array( $this->_model_relations[$relationName] ) : array();
483
+				$this->_model_relations[$relationName] = $this->_model_relations[$relationName] instanceof EE_Base_Class ? array($this->_model_relations[$relationName]) : array();
484 484
 			}
485 485
 			// first check for a cache_id which is normally empty
486
-			if ( ! empty( $cache_id )) {
486
+			if ( ! empty($cache_id)) {
487 487
 				// if the cache_id exists, then it means we are purposely trying to cache this with a known key that can then be used to retrieve the object later on
488
-				$this->_model_relations[$relationName][ $cache_id ] = $object_to_cache;
488
+				$this->_model_relations[$relationName][$cache_id] = $object_to_cache;
489 489
 				$return = $cache_id;
490
-			} elseif ( $object_to_cache->ID() ) {
490
+			} elseif ($object_to_cache->ID()) {
491 491
 				// OR the cached object originally came from the db, so let's just use it's PK for an ID
492
-				$this->_model_relations[$relationName][ $object_to_cache->ID() ] = $object_to_cache;
492
+				$this->_model_relations[$relationName][$object_to_cache->ID()] = $object_to_cache;
493 493
 				$return = $object_to_cache->ID();
494 494
 			} else {
495 495
 				// OR it's a new object with no ID, so just throw it in the array with an auto-incremented ID
496 496
 				$this->_model_relations[$relationName][] = $object_to_cache;
497 497
 				  // move the internal pointer to the end of the array
498
-				end( $this->_model_relations[$relationName] );
498
+				end($this->_model_relations[$relationName]);
499 499
 				// and grab the key so that we can return it
500
-				$return = key( $this->_model_relations[$relationName] );
500
+				$return = key($this->_model_relations[$relationName]);
501 501
 			}
502 502
 
503 503
 		}
@@ -515,11 +515,11 @@  discard block
 block discarded – undo
515 515
 	 * @param null   $cache_type
516 516
 	 * @return void
517 517
 	 */
518
-	protected function _set_cached_property( $fieldname, $value, $cache_type = NULL ) {
518
+	protected function _set_cached_property($fieldname, $value, $cache_type = NULL) {
519 519
 		//first make sure this property exists
520 520
 		$this->get_model()->field_settings_for($fieldname);
521 521
 
522
-		$cache_type = empty( $cache_type ) ? 'standard' : $cache_type;
522
+		$cache_type = empty($cache_type) ? 'standard' : $cache_type;
523 523
 		$this->_cached_properties[$fieldname][$cache_type] = $value;
524 524
 	}
525 525
 
@@ -534,34 +534,34 @@  discard block
 block discarded – undo
534 534
 	 *                                 It can also accept certain pre-defined "schema" strings to define how to output the property. see the field's prepare_for_pretty_echoing for what strings can be used
535 535
 	 * @return mixed                whatever the value for the property is we're retrieving
536 536
 	 */
537
-	protected function _get_cached_property( $fieldname, $pretty = FALSE, $extra_cache_ref = NULL ) {
537
+	protected function _get_cached_property($fieldname, $pretty = FALSE, $extra_cache_ref = NULL) {
538 538
 		//verify the field exists
539 539
 		$this->get_model()->field_settings_for($fieldname);
540 540
 
541 541
 		$cache_type = $pretty ? 'pretty' : 'standard';
542
-		$cache_type .= !empty( $extra_cache_ref ) ? '_' . $extra_cache_ref : '';
542
+		$cache_type .= ! empty($extra_cache_ref) ? '_'.$extra_cache_ref : '';
543 543
 
544
-		if ( isset( $this->_cached_properties[$fieldname][$cache_type] ) ) {
544
+		if (isset($this->_cached_properties[$fieldname][$cache_type])) {
545 545
 			return $this->_cached_properties[$fieldname][$cache_type];
546 546
 		}
547 547
 
548 548
 		$field_obj = $this->get_model()->field_settings_for($fieldname);
549
-		if ( $field_obj instanceof EE_Model_Field_Base ) {
549
+		if ($field_obj instanceof EE_Model_Field_Base) {
550 550
 			/**
551 551
 			 * maybe this is EE_Datetime_Field.  If so we need to make sure timezone and
552 552
 			 * formats are correct.
553 553
 			 */
554
-			if ( $field_obj instanceof EE_Datetime_Field ) {
555
-				$field_obj->set_timezone( $this->_timezone );
556
-				$field_obj->set_date_format( $this->_dt_frmt, $pretty );
557
-				$field_obj->set_time_format( $this->_tm_frmt, $pretty );
554
+			if ($field_obj instanceof EE_Datetime_Field) {
555
+				$field_obj->set_timezone($this->_timezone);
556
+				$field_obj->set_date_format($this->_dt_frmt, $pretty);
557
+				$field_obj->set_time_format($this->_tm_frmt, $pretty);
558 558
 			}
559 559
 
560
-			if( ! isset($this->_fields[$fieldname])){
560
+			if ( ! isset($this->_fields[$fieldname])) {
561 561
 				$this->_fields[$fieldname] = NULL;
562 562
 			}
563
-			$value = $pretty ? $field_obj->prepare_for_pretty_echoing($this->_fields[$fieldname], $extra_cache_ref) : $field_obj->prepare_for_get($this->_fields[$fieldname] );
564
-			$this->_set_cached_property( $fieldname, $value, $cache_type );
563
+			$value = $pretty ? $field_obj->prepare_for_pretty_echoing($this->_fields[$fieldname], $extra_cache_ref) : $field_obj->prepare_for_get($this->_fields[$fieldname]);
564
+			$this->_set_cached_property($fieldname, $value, $cache_type);
565 565
 			return $value;
566 566
 		}
567 567
 		return FALSE;
@@ -587,9 +587,9 @@  discard block
 block discarded – undo
587 587
 	 * @param  string $property_name the property to remove if it exists (from the _cached_properties array)
588 588
 	 * @return void
589 589
 	 */
590
-	protected function _clear_cached_property( $property_name ) {
591
-		if ( isset( $this->_cached_properties[ $property_name ] ) )
592
-			unset( $this->_cached_properties[ $property_name ] );
590
+	protected function _clear_cached_property($property_name) {
591
+		if (isset($this->_cached_properties[$property_name]))
592
+			unset($this->_cached_properties[$property_name]);
593 593
 	}
594 594
 
595 595
 
@@ -600,7 +600,7 @@  discard block
 block discarded – undo
600 600
 	 * @param string $model_name name of the related thing, eg 'Attendee',
601 601
 	 * @return EE_Base_Class
602 602
 	 */
603
-	protected function ensure_related_thing_is_model_obj($object_or_id,$model_name){
603
+	protected function ensure_related_thing_is_model_obj($object_or_id, $model_name) {
604 604
 		$other_model_instance = self::_get_model_instance_with_name(self::_get_model_classname($model_name), $this->_timezone);
605 605
 		$model_obj = $other_model_instance->ensure_is_obj($object_or_id);
606 606
 		return $model_obj;
@@ -620,55 +620,55 @@  discard block
 block discarded – undo
620 620
 	 * @throws EE_Error
621 621
 	 * @return EE_Base_Class | boolean from which was cleared from the cache, or true if we requested to remove a relation from all
622 622
 	 */
623
-	public function clear_cache($relationName, $object_to_remove_or_index_into_array = NULL, $clear_all = FALSE){
623
+	public function clear_cache($relationName, $object_to_remove_or_index_into_array = NULL, $clear_all = FALSE) {
624 624
 		$relationship_to_model = $this->get_model()->related_settings_for($relationName);
625 625
 		$index_in_cache = '';
626
-		if( ! $relationship_to_model){
627
-			throw new EE_Error(sprintf(__("There is no relationship to %s on a %s. Cannot clear that cache",'event_espresso'),$relationName,get_class($this)));
626
+		if ( ! $relationship_to_model) {
627
+			throw new EE_Error(sprintf(__("There is no relationship to %s on a %s. Cannot clear that cache", 'event_espresso'), $relationName, get_class($this)));
628 628
 		}
629
-		if($clear_all){
629
+		if ($clear_all) {
630 630
 			$obj_removed = true;
631 631
 			$this->_model_relations[$relationName]  = null;
632
-		}elseif($relationship_to_model instanceof EE_Belongs_To_Relation){
632
+		}elseif ($relationship_to_model instanceof EE_Belongs_To_Relation) {
633 633
 			$obj_removed = $this->_model_relations[$relationName];
634 634
 			$this->_model_relations[$relationName]  = null;
635
-		}else{
636
-			if($object_to_remove_or_index_into_array instanceof EE_Base_Class && $object_to_remove_or_index_into_array->ID()){
635
+		} else {
636
+			if ($object_to_remove_or_index_into_array instanceof EE_Base_Class && $object_to_remove_or_index_into_array->ID()) {
637 637
 				$index_in_cache = $object_to_remove_or_index_into_array->ID();
638
-				if( is_array($this->_model_relations[$relationName]) && ! isset($this->_model_relations[$relationName][$index_in_cache])){
638
+				if (is_array($this->_model_relations[$relationName]) && ! isset($this->_model_relations[$relationName][$index_in_cache])) {
639 639
 					$index_found_at = NULL;
640 640
 					//find this object in the array even though it has a different key
641
-					foreach($this->_model_relations[$relationName] as $index=>$obj){
642
-						if( $obj instanceof EE_Base_Class && ( $obj == $object_to_remove_or_index_into_array || $obj->ID() == $object_to_remove_or_index_into_array->ID() )) {
641
+					foreach ($this->_model_relations[$relationName] as $index=>$obj) {
642
+						if ($obj instanceof EE_Base_Class && ($obj == $object_to_remove_or_index_into_array || $obj->ID() == $object_to_remove_or_index_into_array->ID())) {
643 643
 							$index_found_at = $index;
644 644
 							break;
645 645
 						}
646 646
 					}
647
-					if($index_found_at){
647
+					if ($index_found_at) {
648 648
 						$index_in_cache = $index_found_at;
649
-					}else{
649
+					} else {
650 650
 						//it wasn't found. huh. well obviously it doesn't need to be removed from teh cache
651 651
 						//if it wasn't in it to begin with. So we're done
652 652
 						return $object_to_remove_or_index_into_array;
653 653
 					}
654 654
 				}
655
-			}elseif($object_to_remove_or_index_into_array instanceof EE_Base_Class){
655
+			}elseif ($object_to_remove_or_index_into_array instanceof EE_Base_Class) {
656 656
 				//so they provided a model object, but it's not yet saved to the DB... so let's go hunting for it!
657
-				foreach($this->get_all_from_cache($relationName) as $index => $potentially_obj_we_want){
658
-					if($potentially_obj_we_want == $object_to_remove_or_index_into_array){
657
+				foreach ($this->get_all_from_cache($relationName) as $index => $potentially_obj_we_want) {
658
+					if ($potentially_obj_we_want == $object_to_remove_or_index_into_array) {
659 659
 						$index_in_cache = $index;
660 660
 					}
661 661
 				}
662
-			}else{
662
+			} else {
663 663
 				$index_in_cache = $object_to_remove_or_index_into_array;
664 664
 			}
665 665
 			//supposedly we've found it. But it could just be that the client code
666 666
 			//provided a bad index/object
667
-			if(isset( $this->_model_relations[$relationName]) &&
668
-					isset( $this->_model_relations[$relationName][$index_in_cache])){
667
+			if (isset($this->_model_relations[$relationName]) &&
668
+					isset($this->_model_relations[$relationName][$index_in_cache])) {
669 669
 				$obj_removed = $this->_model_relations[$relationName][$index_in_cache];
670 670
 				unset($this->_model_relations[$relationName][$index_in_cache]);
671
-			}else{
671
+			} else {
672 672
 				//that thing was never cached anyways.
673 673
 				$obj_removed = NULL;
674 674
 			}
@@ -687,24 +687,24 @@  discard block
 block discarded – undo
687 687
 	 * @param string                $current_cache_id   - the ID that was used when originally caching the object
688 688
 	 * @return boolean TRUE on success, FALSE on fail
689 689
 	 */
690
-	public function update_cache_after_object_save( $relationName, EE_Base_Class $newly_saved_object, $current_cache_id = '') {
690
+	public function update_cache_after_object_save($relationName, EE_Base_Class $newly_saved_object, $current_cache_id = '') {
691 691
 		// verify that incoming object is of the correct type
692
-		$obj_class = 'EE_' . $relationName;
693
-		if ( $newly_saved_object instanceof $obj_class ) {
692
+		$obj_class = 'EE_'.$relationName;
693
+		if ($newly_saved_object instanceof $obj_class) {
694 694
 			/* @type EE_Base_Class $newly_saved_object*/
695 695
 			// now get the type of relation
696
-			$relationship_to_model = $this->get_model()->related_settings_for( $relationName );
696
+			$relationship_to_model = $this->get_model()->related_settings_for($relationName);
697 697
 			// if this is a 1:1 relationship
698
-			if( $relationship_to_model instanceof EE_Belongs_To_Relation ) {
698
+			if ($relationship_to_model instanceof EE_Belongs_To_Relation) {
699 699
 				// then just replace the cached object with the newly saved object
700 700
 				$this->_model_relations[$relationName] = $newly_saved_object;
701 701
 				return TRUE;
702 702
 			// or if it's some kind of sordid feral polyamorous relationship...
703
-			} elseif ( is_array( $this->_model_relations[$relationName] ) && isset( $this->_model_relations[$relationName][ $current_cache_id ] )) {
703
+			} elseif (is_array($this->_model_relations[$relationName]) && isset($this->_model_relations[$relationName][$current_cache_id])) {
704 704
 				// then remove the current cached item
705
-				unset( $this->_model_relations[$relationName][ $current_cache_id ] );
705
+				unset($this->_model_relations[$relationName][$current_cache_id]);
706 706
 				// and cache the newly saved object using it's new ID
707
-				$this->_model_relations[$relationName][ $newly_saved_object->ID() ] = $newly_saved_object;
707
+				$this->_model_relations[$relationName][$newly_saved_object->ID()] = $newly_saved_object;
708 708
 				return TRUE;
709 709
 			}
710 710
 		}
@@ -720,11 +720,11 @@  discard block
 block discarded – undo
720 720
 	 * @param string $relationName
721 721
 	 * @return EE_Base_Class
722 722
 	 */
723
-	public function get_one_from_cache($relationName){
724
-		$cached_array_or_object = isset( $this->_model_relations[$relationName] ) ? $this->_model_relations[$relationName] : null;
725
-		if(is_array($cached_array_or_object)){
723
+	public function get_one_from_cache($relationName) {
724
+		$cached_array_or_object = isset($this->_model_relations[$relationName]) ? $this->_model_relations[$relationName] : null;
725
+		if (is_array($cached_array_or_object)) {
726 726
 			return array_shift($cached_array_or_object);
727
-		}else{
727
+		} else {
728 728
 			return $cached_array_or_object;
729 729
 		}
730 730
 	}
@@ -739,14 +739,14 @@  discard block
 block discarded – undo
739 739
 	 * @throws \EE_Error
740 740
 	 * @return EE_Base_Class[] NOT necessarily indexed by primary keys
741 741
 	 */
742
-	public function get_all_from_cache($relationName){
743
-		$cached_array_or_object =  isset( $this->_model_relations[$relationName] ) ? $this->_model_relations[$relationName] : array();
744
-		if(is_array($cached_array_or_object)){
742
+	public function get_all_from_cache($relationName) {
743
+		$cached_array_or_object = isset($this->_model_relations[$relationName]) ? $this->_model_relations[$relationName] : array();
744
+		if (is_array($cached_array_or_object)) {
745 745
 			$objects = $cached_array_or_object;
746
-		}elseif($cached_array_or_object){
746
+		}elseif ($cached_array_or_object) {
747 747
 			//if the result is not an array, but exists, make it an array
748 748
 			$objects = array($cached_array_or_object);
749
-		}else{
749
+		} else {
750 750
 			//if nothing was found, return an empty array
751 751
 			$objects = array();
752 752
 		}
@@ -754,15 +754,15 @@  discard block
 block discarded – undo
754 754
 		//basically, if this model object was stored in the session, and these cached model objects
755 755
 		//already have IDs, let's make sure they're in their model's entity mapper
756 756
 		//otherwise we will have duplicates next time we call EE_Registry::instance()->load_model( $relationName )->get_one_by_ID( $result->ID() );
757
-		foreach( $objects as $model_object ){
758
-			$model = EE_Registry::instance()->load_model( $relationName );
759
-			if( $model instanceof EEM_Base && $model_object instanceof EE_Base_Class ){
757
+		foreach ($objects as $model_object) {
758
+			$model = EE_Registry::instance()->load_model($relationName);
759
+			if ($model instanceof EEM_Base && $model_object instanceof EE_Base_Class) {
760 760
 				//ensure its in the map if it has an ID; otherwise it will be added to the map when its saved
761
-				if( $model_object->ID() ){
762
-					$model->add_to_entity_map( $model_object );
761
+				if ($model_object->ID()) {
762
+					$model->add_to_entity_map($model_object);
763 763
 				}
764
-			}else{
765
-				throw new EE_Error( sprintf( __( 'Error retrieving related model objects. Either $1%s is not a model or $2%s is not a model object', 'event_espresso' ), $relationName, gettype( $model_object )));
764
+			} else {
765
+				throw new EE_Error(sprintf(__('Error retrieving related model objects. Either $1%s is not a model or $2%s is not a model object', 'event_espresso'), $relationName, gettype($model_object)));
766 766
 			}
767 767
 		}
768 768
 		return $objects;
@@ -781,13 +781,13 @@  discard block
 block discarded – undo
781 781
 	 *
782 782
 	 * @return array|EE_Base_Class[]
783 783
 	 */
784
-	public function next_x( $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) {
785
-		$field = empty( $field_to_order_by ) && $this->get_model()->has_primary_key_field() ? $this->get_model()->get_primary_key_field()->get_name() : $field_to_order_by;
786
-		$current_value = ! empty( $field ) ? $this->get( $field ) : null;
787
-		if ( empty( $field ) || empty( $current_value ) ) {
784
+	public function next_x($field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) {
785
+		$field = empty($field_to_order_by) && $this->get_model()->has_primary_key_field() ? $this->get_model()->get_primary_key_field()->get_name() : $field_to_order_by;
786
+		$current_value = ! empty($field) ? $this->get($field) : null;
787
+		if (empty($field) || empty($current_value)) {
788 788
 			return array();
789 789
 		}
790
-		return $this->get_model()->next_x( $current_value, $field, $limit, $query_params, $columns_to_select );
790
+		return $this->get_model()->next_x($current_value, $field, $limit, $query_params, $columns_to_select);
791 791
 	}
792 792
 
793 793
 
@@ -806,13 +806,13 @@  discard block
 block discarded – undo
806 806
 	 *
807 807
 	 * @return array|EE_Base_Class[]
808 808
 	 */
809
-	public function previous_x( $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) {
810
-		$field = empty( $field_to_order_by ) && $this->get_model()->has_primary_key_field() ? $this->get_model()->get_primary_key_field()->get_name() : $field_to_order_by;
811
-		$current_value = ! empty( $field ) ? $this->get( $field ) : null;
812
-		if ( empty( $field ) || empty( $current_value ) ) {
809
+	public function previous_x($field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) {
810
+		$field = empty($field_to_order_by) && $this->get_model()->has_primary_key_field() ? $this->get_model()->get_primary_key_field()->get_name() : $field_to_order_by;
811
+		$current_value = ! empty($field) ? $this->get($field) : null;
812
+		if (empty($field) || empty($current_value)) {
813 813
 			return array();
814 814
 		}
815
-		return $this->get_model()->previous_x( $current_value, $field, $limit, $query_params, $columns_to_select );
815
+		return $this->get_model()->previous_x($current_value, $field, $limit, $query_params, $columns_to_select);
816 816
 	}
817 817
 
818 818
 
@@ -830,13 +830,13 @@  discard block
 block discarded – undo
830 830
 	 *
831 831
 	 * @return array|EE_Base_Class
832 832
 	 */
833
-	public function next( $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) {
834
-		$field = empty( $field_to_order_by ) && $this->get_model()->has_primary_key_field() ? $this->get_model()->get_primary_key_field()->get_name() : $field_to_order_by;
835
-		$current_value = ! empty( $field ) ? $this->get( $field ) : null;
836
-		if ( empty( $field ) || empty( $current_value ) ) {
833
+	public function next($field_to_order_by = null, $query_params = array(), $columns_to_select = null) {
834
+		$field = empty($field_to_order_by) && $this->get_model()->has_primary_key_field() ? $this->get_model()->get_primary_key_field()->get_name() : $field_to_order_by;
835
+		$current_value = ! empty($field) ? $this->get($field) : null;
836
+		if (empty($field) || empty($current_value)) {
837 837
 			return array();
838 838
 		}
839
-		return $this->get_model()->next( $current_value, $field, $query_params, $columns_to_select );
839
+		return $this->get_model()->next($current_value, $field, $query_params, $columns_to_select);
840 840
 	}
841 841
 
842 842
 
@@ -855,13 +855,13 @@  discard block
 block discarded – undo
855 855
 	 *
856 856
 	 * @return array|EE_Base_Class
857 857
 	 */
858
-	public function previous( $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) {
859
-		$field = empty( $field_to_order_by ) && $this->get_model()->has_primary_key_field() ? $this->get_model()->get_primary_key_field()->get_name() : $field_to_order_by;
860
-		$current_value = ! empty( $field ) ? $this->get( $field ) : null;
861
-		if ( empty( $field ) || empty( $current_value ) ) {
858
+	public function previous($field_to_order_by = null, $query_params = array(), $columns_to_select = null) {
859
+		$field = empty($field_to_order_by) && $this->get_model()->has_primary_key_field() ? $this->get_model()->get_primary_key_field()->get_name() : $field_to_order_by;
860
+		$current_value = ! empty($field) ? $this->get($field) : null;
861
+		if (empty($field) || empty($current_value)) {
862 862
 			return array();
863 863
 		}
864
-		return $this->get_model()->previous( $current_value, $field, $query_params, $columns_to_select );
864
+		return $this->get_model()->previous($current_value, $field, $query_params, $columns_to_select);
865 865
 	}
866 866
 
867 867
 
@@ -875,25 +875,25 @@  discard block
 block discarded – undo
875 875
 	 * @param string $field_name
876 876
 	 * @param mixed  $field_value_from_db
877 877
 	 */
878
-	public function set_from_db($field_name,$field_value_from_db){
878
+	public function set_from_db($field_name, $field_value_from_db) {
879 879
 		$field_obj = $this->get_model()->field_settings_for($field_name);
880
-		if ( $field_obj instanceof EE_Model_Field_Base ) {
880
+		if ($field_obj instanceof EE_Model_Field_Base) {
881 881
 			//you would think the DB has no NULLs for non-null label fields right? wrong!
882 882
 			//eg, a CPT model object could have an entry in the posts table, but no
883 883
 			//entry in the meta table. Meaning that all its columns in the meta table
884 884
 			//are null! yikes! so when we find one like that, use defaults for its meta columns
885
-			if($field_value_from_db === NULL ){
886
-				if( $field_obj->is_nullable()){
885
+			if ($field_value_from_db === NULL) {
886
+				if ($field_obj->is_nullable()) {
887 887
 					//if the field allows nulls, then let it be null
888 888
 					$field_value = NULL;
889
-				}else{
889
+				} else {
890 890
 					$field_value = $field_obj->get_default_value();
891 891
 				}
892
-			}else{
893
-				$field_value = $field_obj->prepare_for_set_from_db( $field_value_from_db );
892
+			} else {
893
+				$field_value = $field_obj->prepare_for_set_from_db($field_value_from_db);
894 894
 			}
895 895
 			$this->_fields[$field_name] = $field_value;
896
-			$this->_clear_cached_property( $field_name );
896
+			$this->_clear_cached_property($field_name);
897 897
 		}
898 898
 	}
899 899
 
@@ -905,8 +905,8 @@  discard block
 block discarded – undo
905 905
 	 * @param string $extra_cache_ref This allows the user to specify an extra cache ref for the given property (in cases where the same property may be used for different outputs - i.e. datetime, money etc.)
906 906
 	 * @return boolean
907 907
 	 */
908
-	public function get($field_name, $extra_cache_ref = NULL ){
909
-		return $this->_get_cached_property( $field_name, FALSE, $extra_cache_ref );
908
+	public function get($field_name, $extra_cache_ref = NULL) {
909
+		return $this->_get_cached_property($field_name, FALSE, $extra_cache_ref);
910 910
 	}
911 911
 
912 912
 
@@ -936,11 +936,11 @@  discard block
 block discarded – undo
936 936
 	 *                    				     just null is returned (because that indicates that likely
937 937
 	 *                    				     this field is nullable).
938 938
 	 */
939
-	public function get_DateTime_object( $field_name ) {
940
-		$field_settings = $this->get_model()->field_settings_for( $field_name );
939
+	public function get_DateTime_object($field_name) {
940
+		$field_settings = $this->get_model()->field_settings_for($field_name);
941 941
 
942
-		if ( ! $field_settings instanceof EE_Datetime_Field ) {
943
-			EE_Error::add_error( sprintf( __('The field %s is not an EE_Datetime_Field field.  There is no DateTime object stored on this field type.', 'event_espresso' ), $field_name ), __FILE__, __FUNCTION__, __LINE__ );
942
+		if ( ! $field_settings instanceof EE_Datetime_Field) {
943
+			EE_Error::add_error(sprintf(__('The field %s is not an EE_Datetime_Field field.  There is no DateTime object stored on this field type.', 'event_espresso'), $field_name), __FILE__, __FUNCTION__, __LINE__);
944 944
 			return false;
945 945
 		}
946 946
 
@@ -956,7 +956,7 @@  discard block
 block discarded – undo
956 956
 	 * @param string         $extra_cache_ref This allows the user to specify an extra cache ref for the given property (in cases where the same property may be used for different outputs - i.e. datetime, money etc.)
957 957
 	 * @return void
958 958
 	 */
959
-	public function e($field_name, $extra_cache_ref = NULL){
959
+	public function e($field_name, $extra_cache_ref = NULL) {
960 960
 		echo $this->get_pretty($field_name, $extra_cache_ref);
961 961
 	}
962 962
 	/**
@@ -965,8 +965,8 @@  discard block
 block discarded – undo
965 965
 	 * @param string $field_name
966 966
 	 * @return void
967 967
 	 */
968
-	public function f($field_name){
969
-		$this->e($field_name,'form_input');
968
+	public function f($field_name) {
969
+		$this->e($field_name, 'form_input');
970 970
 	}
971 971
 
972 972
 	/**
@@ -975,8 +975,8 @@  discard block
 block discarded – undo
975 975
 	 * @param string         $extra_cache_ref This allows the user to specify an extra cache ref for the given property (in cases where the same property may be used for different outputs - i.e. datetime, money etc.)
976 976
 	 * @return mixed
977 977
 	 */
978
-	public function get_pretty($field_name, $extra_cache_ref = NULL){
979
-		return  $this->_get_cached_property( $field_name, TRUE, $extra_cache_ref );
978
+	public function get_pretty($field_name, $extra_cache_ref = NULL) {
979
+		return  $this->_get_cached_property($field_name, TRUE, $extra_cache_ref);
980 980
 	}
981 981
 
982 982
 
@@ -993,37 +993,37 @@  discard block
 block discarded – undo
993 993
 	 * @param  boolean $echo         Whether the dtt is echoing using pretty echoing or just returned using vanilla get
994 994
 	 * @return void | string | bool | EE_Error string on success, FALSE on fail, or EE_Error Exception is thrown if field is not a valid dtt field, or void if echoing
995 995
 	 */
996
-	protected function _get_datetime( $field_name, $dt_frmt = NULL, $tm_frmt = NULL, $date_or_time = NULL, $echo = FALSE ) {
996
+	protected function _get_datetime($field_name, $dt_frmt = NULL, $tm_frmt = NULL, $date_or_time = NULL, $echo = FALSE) {
997 997
 
998
-		$in_dt_frmt = empty($dt_frmt) ? $this->_dt_frmt :  $dt_frmt;
998
+		$in_dt_frmt = empty($dt_frmt) ? $this->_dt_frmt : $dt_frmt;
999 999
 		$in_tm_frmt = empty($tm_frmt) ? $this->_tm_frmt : $tm_frmt;
1000 1000
 
1001 1001
 		//validate field for datetime and returns field settings if valid.
1002
-		$field = $this->_get_dtt_field_settings( $field_name );
1002
+		$field = $this->_get_dtt_field_settings($field_name);
1003 1003
 
1004 1004
 		//clear cached property if either formats are not null.
1005
-		if( $dt_frmt !== null || $tm_frmt !== null ) {
1006
-			$this->_clear_cached_property( $field_name );
1005
+		if ($dt_frmt !== null || $tm_frmt !== null) {
1006
+			$this->_clear_cached_property($field_name);
1007 1007
 			//reset format properties because they are used in get()
1008 1008
 			$this->_dt_frmt = $in_dt_frmt;
1009 1009
 			$this->_tm_frmt = $in_tm_frmt;
1010 1010
 		}
1011 1011
 
1012
-		if ( $echo )
1013
-			$field->set_pretty_date_format( $in_dt_frmt );
1012
+		if ($echo)
1013
+			$field->set_pretty_date_format($in_dt_frmt);
1014 1014
 		else
1015
-			$field->set_date_format( $in_dt_frmt );
1015
+			$field->set_date_format($in_dt_frmt);
1016 1016
 
1017
-		if ( $echo )
1018
-			$field->set_pretty_time_format( $in_tm_frmt );
1017
+		if ($echo)
1018
+			$field->set_pretty_time_format($in_tm_frmt);
1019 1019
 		else
1020
-			$field->set_time_format( $in_tm_frmt );
1020
+			$field->set_time_format($in_tm_frmt);
1021 1021
 
1022 1022
 		//set timezone in field object
1023
-		$field->set_timezone( $this->_timezone );
1023
+		$field->set_timezone($this->_timezone);
1024 1024
 
1025 1025
 		//set the output returned
1026
-		switch ( $date_or_time ) {
1026
+		switch ($date_or_time) {
1027 1027
 
1028 1028
 			case 'D' :
1029 1029
 				$field->set_date_time_output('date');
@@ -1038,11 +1038,11 @@  discard block
 block discarded – undo
1038 1038
 		}
1039 1039
 
1040 1040
 
1041
-		if ( $echo ) {
1042
-			$this->e( $field_name, $date_or_time );
1041
+		if ($echo) {
1042
+			$this->e($field_name, $date_or_time);
1043 1043
 			return '';
1044 1044
 		 }
1045
-		return $this->get( $field_name, $date_or_time );
1045
+		return $this->get($field_name, $date_or_time);
1046 1046
 	}
1047 1047
 
1048 1048
 
@@ -1052,8 +1052,8 @@  discard block
 block discarded – undo
1052 1052
 	 * @param  string $format     format for the date returned (if NULL we use default in dt_frmt property)
1053 1053
 	 * @return string            datetime value formatted
1054 1054
 	 */
1055
-	public function get_date( $field_name, $format = NULL ) {
1056
-		return $this->_get_datetime( $field_name, $format, NULL, 'D' );
1055
+	public function get_date($field_name, $format = NULL) {
1056
+		return $this->_get_datetime($field_name, $format, NULL, 'D');
1057 1057
 	}
1058 1058
 
1059 1059
 
@@ -1062,8 +1062,8 @@  discard block
 block discarded – undo
1062 1062
 	 * @param      $field_name
1063 1063
 	 * @param null $format
1064 1064
 	 */
1065
-	public function e_date( $field_name, $format = NULL ) {
1066
-		$this->_get_datetime( $field_name, $format, NULL, 'D', TRUE );
1065
+	public function e_date($field_name, $format = NULL) {
1066
+		$this->_get_datetime($field_name, $format, NULL, 'D', TRUE);
1067 1067
 	}
1068 1068
 
1069 1069
 
@@ -1073,8 +1073,8 @@  discard block
 block discarded – undo
1073 1073
 	 * @param  string $format     format for the time returned ( if NULL we use default in tm_frmt property)
1074 1074
 	 * @return string             datetime value formatted
1075 1075
 	 */
1076
-	public function get_time( $field_name, $format = NULL ) {
1077
-		return $this->_get_datetime( $field_name, NULL, $format, 'T' );
1076
+	public function get_time($field_name, $format = NULL) {
1077
+		return $this->_get_datetime($field_name, NULL, $format, 'T');
1078 1078
 	}
1079 1079
 
1080 1080
 
@@ -1083,8 +1083,8 @@  discard block
 block discarded – undo
1083 1083
 	 * @param      $field_name
1084 1084
 	 * @param null $format
1085 1085
 	 */
1086
-	public function e_time( $field_name, $format = NULL ) {
1087
-		$this->_get_datetime( $field_name, NULL, $format, 'T', TRUE );
1086
+	public function e_time($field_name, $format = NULL) {
1087
+		$this->_get_datetime($field_name, NULL, $format, 'T', TRUE);
1088 1088
 	}
1089 1089
 
1090 1090
 
@@ -1097,8 +1097,8 @@  discard block
 block discarded – undo
1097 1097
 	 * @param  string $tm_frmt    format for the time returned (if NULL we use default in tm_frmt property)
1098 1098
 	 * @return string             datetime value formatted
1099 1099
 	 */
1100
-	public function get_datetime( $field_name, $dt_frmt = NULL, $tm_frmt = NULL ) {
1101
-		return $this->_get_datetime( $field_name, $dt_frmt, $tm_frmt );
1100
+	public function get_datetime($field_name, $dt_frmt = NULL, $tm_frmt = NULL) {
1101
+		return $this->_get_datetime($field_name, $dt_frmt, $tm_frmt);
1102 1102
 	}
1103 1103
 
1104 1104
 
@@ -1108,8 +1108,8 @@  discard block
 block discarded – undo
1108 1108
 	 * @param null $dt_frmt
1109 1109
 	 * @param null $tm_frmt
1110 1110
 	 */
1111
-	public function e_datetime( $field_name, $dt_frmt = NULL, $tm_frmt = NULL ) {
1112
-		$this->_get_datetime( $field_name, $dt_frmt, $tm_frmt, NULL, TRUE);
1111
+	public function e_datetime($field_name, $dt_frmt = NULL, $tm_frmt = NULL) {
1112
+		$this->_get_datetime($field_name, $dt_frmt, $tm_frmt, NULL, TRUE);
1113 1113
 	}
1114 1114
 
1115 1115
 
@@ -1124,10 +1124,10 @@  discard block
 block discarded – undo
1124 1124
 	 * @return string Date and time string in set locale or false if no field exists for the given
1125 1125
 	 *                         field name.
1126 1126
 	 */
1127
-	public function get_i18n_datetime( $field_name, $format = NULL ) {
1128
-		EE_Registry::instance()->load_helper( 'DTT_Helper' );
1129
-		$format = empty( $format ) ? $this->_dt_frmt . ' ' . $this->_tm_frmt : $format;
1130
-		return date_i18n( $format, EEH_DTT_Helper::get_timestamp_with_offset( $this->get_raw( $field_name ), $this->_timezone ) );
1127
+	public function get_i18n_datetime($field_name, $format = NULL) {
1128
+		EE_Registry::instance()->load_helper('DTT_Helper');
1129
+		$format = empty($format) ? $this->_dt_frmt.' '.$this->_tm_frmt : $format;
1130
+		return date_i18n($format, EEH_DTT_Helper::get_timestamp_with_offset($this->get_raw($field_name), $this->_timezone));
1131 1131
 	}
1132 1132
 
1133 1133
 
@@ -1139,14 +1139,14 @@  discard block
 block discarded – undo
1139 1139
 	 * @throws EE_Error
1140 1140
 	 * @return EE_Datetime_Field
1141 1141
 	 */
1142
-	protected function _get_dtt_field_settings( $field_name ) {
1142
+	protected function _get_dtt_field_settings($field_name) {
1143 1143
 		$field = $this->get_model()->field_settings_for($field_name);
1144 1144
 
1145 1145
 		//check if field is dtt
1146
-		if ( $field instanceof EE_Datetime_Field ) {
1146
+		if ($field instanceof EE_Datetime_Field) {
1147 1147
 			return $field;
1148 1148
 		} else {
1149
-			throw new EE_Error( sprintf( __('The field name "%s" has been requested for the EE_Base_Class datetime functions and it is not a valid EE_Datetime_Field.  Please check the spelling of the field and make sure it has been setup as a EE_Datetime_Field in the %s model constructor', 'event_espresso'), $field_name, self::_get_model_classname( get_class($this) ) ) );
1149
+			throw new EE_Error(sprintf(__('The field name "%s" has been requested for the EE_Base_Class datetime functions and it is not a valid EE_Datetime_Field.  Please check the spelling of the field and make sure it has been setup as a EE_Datetime_Field in the %s model constructor', 'event_espresso'), $field_name, self::_get_model_classname(get_class($this))));
1150 1150
 		}
1151 1151
 	}
1152 1152
 
@@ -1167,8 +1167,8 @@  discard block
 block discarded – undo
1167 1167
 	 * @param string|Datetime $time      a valid time string for php datetime functions (or DateTime object)
1168 1168
 	 * @param string $fieldname the name of the field the time is being set on (must match a EE_Datetime_Field)
1169 1169
 	 */
1170
-	protected function _set_time_for( $time, $fieldname ) {
1171
-		$this->_set_date_time( 'T', $time, $fieldname );
1170
+	protected function _set_time_for($time, $fieldname) {
1171
+		$this->_set_date_time('T', $time, $fieldname);
1172 1172
 	}
1173 1173
 
1174 1174
 
@@ -1182,8 +1182,8 @@  discard block
 block discarded – undo
1182 1182
 	 * @param string|DateTime $date      a valid date string for php datetime functions ( or DateTime object)
1183 1183
 	 * @param string $fieldname the name of the field the date is being set on (must match a EE_Datetime_Field)
1184 1184
 	 */
1185
-	protected function _set_date_for( $date, $fieldname ) {
1186
-		$this->_set_date_time( 'D', $date, $fieldname );
1185
+	protected function _set_date_for($date, $fieldname) {
1186
+		$this->_set_date_time('D', $date, $fieldname);
1187 1187
 	}
1188 1188
 
1189 1189
 
@@ -1199,21 +1199,21 @@  discard block
 block discarded – undo
1199 1199
 	 * @param string|DateTime $datetime_value A valid Date or Time string (or DateTime object)
1200 1200
 	 * @param string $fieldname     the name of the field the date OR time is being set on (must match a EE_Datetime_Field property)
1201 1201
 	 */
1202
-	protected function _set_date_time( $what = 'T', $datetime_value, $fieldname ) {
1203
-		$field = $this->_get_dtt_field_settings( $fieldname );
1204
-		$field->set_timezone( $this->_timezone );
1205
-		$field->set_date_format( $this->_dt_frmt );
1206
-		$field->set_time_format( $this->_tm_frmt );
1202
+	protected function _set_date_time($what = 'T', $datetime_value, $fieldname) {
1203
+		$field = $this->_get_dtt_field_settings($fieldname);
1204
+		$field->set_timezone($this->_timezone);
1205
+		$field->set_date_format($this->_dt_frmt);
1206
+		$field->set_time_format($this->_tm_frmt);
1207 1207
 
1208
-		switch ( $what ) {
1208
+		switch ($what) {
1209 1209
 			case 'T' :
1210
-				$this->_fields[$fieldname] = $field->prepare_for_set_with_new_time( $datetime_value, $this->_fields[$fieldname] );
1210
+				$this->_fields[$fieldname] = $field->prepare_for_set_with_new_time($datetime_value, $this->_fields[$fieldname]);
1211 1211
 				break;
1212 1212
 			case 'D' :
1213
-				$this->_fields[$fieldname] = $field->prepare_for_set_with_new_date( $datetime_value, $this->_fields[$fieldname] );
1213
+				$this->_fields[$fieldname] = $field->prepare_for_set_with_new_date($datetime_value, $this->_fields[$fieldname]);
1214 1214
 				break;
1215 1215
 			case 'B' :
1216
-				$this->_fields[$fieldname] = $field->prepare_for_set( $datetime_value );
1216
+				$this->_fields[$fieldname] = $field->prepare_for_set($datetime_value);
1217 1217
 				break;
1218 1218
 		}
1219 1219
 
@@ -1236,25 +1236,25 @@  discard block
 block discarded – undo
1236 1236
 	 * @throws EE_Error
1237 1237
 	 * @return string timestamp
1238 1238
 	 */
1239
-	public function display_in_my_timezone( $field_name, $callback = 'get_datetime', $args = NULL, $prepend = '', $append = '' ) {
1239
+	public function display_in_my_timezone($field_name, $callback = 'get_datetime', $args = NULL, $prepend = '', $append = '') {
1240 1240
 		EE_Registry::instance()->load_helper('DTT_Helper');
1241 1241
 		$timezone = EEH_DTT_Helper::get_timezone();
1242 1242
 
1243
-		if ( $timezone == $this->_timezone )
1243
+		if ($timezone == $this->_timezone)
1244 1244
 			return '';
1245 1245
 
1246 1246
 		$original_timezone = $this->_timezone;
1247
-		$this->set_timezone( $timezone );
1247
+		$this->set_timezone($timezone);
1248 1248
 
1249 1249
 		$fn = (array) $field_name;
1250
-		$args = array_merge( $fn, (array) $args );
1250
+		$args = array_merge($fn, (array) $args);
1251 1251
 
1252
-		if ( !method_exists( $this, $callback ) )
1253
-			throw new EE_Error(sprintf( __('The method named "%s" given as the callback param in "display_in_my_timezone" does not exist.  Please check your spelling', 'event_espresso'), $callback ) );
1252
+		if ( ! method_exists($this, $callback))
1253
+			throw new EE_Error(sprintf(__('The method named "%s" given as the callback param in "display_in_my_timezone" does not exist.  Please check your spelling', 'event_espresso'), $callback));
1254 1254
 		$args = (array) $args;
1255
-		$return =  $prepend . call_user_func_array( array( $this, $callback ), $args ) . $append;
1255
+		$return = $prepend.call_user_func_array(array($this, $callback), $args).$append;
1256 1256
 
1257
-		$this->set_timezone( $original_timezone );
1257
+		$this->set_timezone($original_timezone);
1258 1258
 		return $return;
1259 1259
 	}
1260 1260
 
@@ -1265,15 +1265,15 @@  discard block
 block discarded – undo
1265 1265
 	 * Deletes this model object. That may mean just 'soft deleting' it though.
1266 1266
 	 * @return boolean | int
1267 1267
 	 */
1268
-	public function delete(){
1268
+	public function delete() {
1269 1269
 		/**
1270 1270
 		 * Called just before SOFT deleting a model object (if soft deleting is
1271 1271
 		 * possible for this model; otherwise a regular hard delete it performed)
1272 1272
 		 *
1273 1273
 		 * @param EE_Base_Class $model_object about to be 'deleted'
1274 1274
 		 */
1275
-		do_action( 'AHEE__EE_Base_Class__delete__before', $this );
1276
-		$result = $this->get_model()->delete_by_ID( $this->ID() );
1275
+		do_action('AHEE__EE_Base_Class__delete__before', $this);
1276
+		$result = $this->get_model()->delete_by_ID($this->ID());
1277 1277
 		$this->refresh_cache_of_related_objects();
1278 1278
 		/**
1279 1279
 		 * Called just after SOFT deleting a model object (if soft deleting is
@@ -1281,7 +1281,7 @@  discard block
 block discarded – undo
1281 1281
 		 * @param EE_Base_Class $model_object that was just 'deleted'
1282 1282
 		 * @param boolean $result
1283 1283
 		 */
1284
-		do_action( 'AHEE__EE_Base_Class__delete__end', $this, $result );
1284
+		do_action('AHEE__EE_Base_Class__delete__end', $this, $result);
1285 1285
 		return $result;
1286 1286
 	}
1287 1287
 
@@ -1291,22 +1291,22 @@  discard block
 block discarded – undo
1291 1291
 	 * Deletes this model object permanently from db (but keep in mind related models my block the delete and return an error)
1292 1292
 	 * @return bool
1293 1293
 	 */
1294
-	public function delete_permanently(){
1294
+	public function delete_permanently() {
1295 1295
 		/**
1296 1296
 		 * Called just before HARD deleting a model object
1297 1297
 		 *
1298 1298
 		 * @param EE_Base_Class $model_object about to be 'deleted'
1299 1299
 		 */
1300
-		do_action( 'AHEE__EE_Base_Class__delete_permanently__before', $this );
1301
-		$model=$this->get_model();
1302
-		$result=$model->delete_permanently_by_ID($this->ID());
1300
+		do_action('AHEE__EE_Base_Class__delete_permanently__before', $this);
1301
+		$model = $this->get_model();
1302
+		$result = $model->delete_permanently_by_ID($this->ID());
1303 1303
 		$this->refresh_cache_of_related_objects();
1304 1304
 		/**
1305 1305
 		 * Called just after HARD deleting a model object
1306 1306
 		 * @param EE_Base_Class $model_object that was just 'deleted'
1307 1307
 		 * @param boolean $result
1308 1308
 		 */
1309
-		do_action( 'AHEE__EE_Base_Class__delete_permanently__end', $this, $result );
1309
+		do_action('AHEE__EE_Base_Class__delete_permanently__end', $this, $result);
1310 1310
 		return $result ? true : false;
1311 1311
 	}
1312 1312
 
@@ -1315,18 +1315,18 @@  discard block
 block discarded – undo
1315 1315
          * related model objects
1316 1316
          */
1317 1317
         public function refresh_cache_of_related_objects() {
1318
-            foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ) {
1319
-                if( ! empty( $this->_model_relations[ $relation_name ] ) ) {
1320
-                    $related_objects = $this->_model_relations[ $relation_name ];
1321
-                    if( $relation_obj instanceof EE_Belongs_To_Relation ) {
1318
+            foreach ($this->get_model()->relation_settings() as $relation_name => $relation_obj) {
1319
+                if ( ! empty($this->_model_relations[$relation_name])) {
1320
+                    $related_objects = $this->_model_relations[$relation_name];
1321
+                    if ($relation_obj instanceof EE_Belongs_To_Relation) {
1322 1322
                         //this relation only stores a single model object, not an array
1323 1323
                         //but let's make it consistent
1324
-                        $related_objects = array( $related_objects );
1324
+                        $related_objects = array($related_objects);
1325 1325
                     }
1326
-                    foreach( $related_objects as $related_object ) {
1326
+                    foreach ($related_objects as $related_object) {
1327 1327
                         //only refresh their cache if they're in memory
1328
-                        if( $related_object instanceof EE_Base_Class ) {
1329
-							$related_object->clear_cache( $this->get_model()->get_this_model_name(), $this );
1328
+                        if ($related_object instanceof EE_Base_Class) {
1329
+							$related_object->clear_cache($this->get_model()->get_this_model_name(), $this);
1330 1330
                         }
1331 1331
                     }
1332 1332
                 }
@@ -1346,17 +1346,17 @@  discard block
 block discarded – undo
1346 1346
 	 * @return int , 1 on a successful update, the ID of the new entry on insert; 0 on failure or if the model object
1347 1347
 	 * isn't allowed to persist (as determined by EE_Base_Class::allow_persist())
1348 1348
 	 */
1349
-	public function save($set_cols_n_values=array()) {
1349
+	public function save($set_cols_n_values = array()) {
1350 1350
 		/**
1351 1351
 		 * Filters the fields we're about to save on the model object
1352 1352
 		 *
1353 1353
 		 * @param array $set_cols_n_values
1354 1354
 		 * @param EE_Base_Class $model_object
1355 1355
 		 */
1356
-		$set_cols_n_values = apply_filters( 'FHEE__EE_Base_Class__save__set_cols_n_values', $set_cols_n_values, $this  );
1356
+		$set_cols_n_values = apply_filters('FHEE__EE_Base_Class__save__set_cols_n_values', $set_cols_n_values, $this);
1357 1357
 		//set attributes as provided in $set_cols_n_values
1358
-		foreach($set_cols_n_values as $column=>$value){
1359
-			$this->set($column,$value);
1358
+		foreach ($set_cols_n_values as $column=>$value) {
1359
+			$this->set($column, $value);
1360 1360
 		}
1361 1361
 		/**
1362 1362
 		 * Saving a model object.
@@ -1364,8 +1364,8 @@  discard block
 block discarded – undo
1364 1364
 		 * Before we perform a save, this action is fired.
1365 1365
 		 * @param EE_Base_Class $model_object the model object about to be saved.
1366 1366
 		 */
1367
-		do_action( 'AHEE__EE_Base_Class__save__begin', $this );
1368
-		if( ! $this->allow_persist() ) {
1367
+		do_action('AHEE__EE_Base_Class__save__begin', $this);
1368
+		if ( ! $this->allow_persist()) {
1369 1369
 			return 0;
1370 1370
 		}
1371 1371
 		//now get current attribute values
@@ -1375,61 +1375,61 @@  discard block
 block discarded – undo
1375 1375
 		$old_assumption_concerning_value_preparation = $this->get_model()->get_assumption_concerning_values_already_prepared_by_model_object();
1376 1376
 		$this->get_model()->assume_values_already_prepared_by_model_object(true);
1377 1377
 		//does this model have an autoincrement PK?
1378
-		if($this->get_model()->has_primary_key_field()){
1379
-			if($this->get_model()->get_primary_key_field()->is_auto_increment()){
1378
+		if ($this->get_model()->has_primary_key_field()) {
1379
+			if ($this->get_model()->get_primary_key_field()->is_auto_increment()) {
1380 1380
 				//ok check if it's set, if so: update; if not, insert
1381
-				if ( ! empty( $save_cols_n_values[self::_get_primary_key_name( get_class($this) )] ) ){
1382
-					$results = $this->get_model()->update_by_ID ( $save_cols_n_values, $this->ID() );
1381
+				if ( ! empty($save_cols_n_values[self::_get_primary_key_name(get_class($this))])) {
1382
+					$results = $this->get_model()->update_by_ID($save_cols_n_values, $this->ID());
1383 1383
 				} else {
1384
-					unset($save_cols_n_values[self::_get_primary_key_name( get_class( $this) )]);
1385
-					$results = $this->get_model()->insert( $save_cols_n_values, true);
1386
-					if($results){
1384
+					unset($save_cols_n_values[self::_get_primary_key_name(get_class($this))]);
1385
+					$results = $this->get_model()->insert($save_cols_n_values, true);
1386
+					if ($results) {
1387 1387
 						//if successful, set the primary key
1388 1388
 						//but don't use the normal SET method, because it will check if
1389 1389
 						//an item with the same ID exists in the mapper & db, then
1390 1390
 						//will find it in the db (because we just added it) and THAT object
1391 1391
 						//will get added to the mapper before we can add this one!
1392 1392
 						//but if we just avoid using the SET method, all that headache can be avoided
1393
-						$pk_field_name =self::_get_primary_key_name( get_class($this));
1393
+						$pk_field_name = self::_get_primary_key_name(get_class($this));
1394 1394
 						$this->_fields[$pk_field_name] = $results;
1395 1395
 						$this->_clear_cached_property($pk_field_name);
1396
-						$this->get_model()->add_to_entity_map( $this );
1396
+						$this->get_model()->add_to_entity_map($this);
1397 1397
 						$this->_update_cached_related_model_objs_fks();
1398 1398
 					}
1399 1399
 				}
1400
-			}else{//PK is NOT auto-increment
1400
+			} else {//PK is NOT auto-increment
1401 1401
 				//so check if one like it already exists in the db
1402
-				if( $this->get_model()->exists_by_ID( $this->ID() ) ){
1403
-					if( ! $this->in_entity_map() && WP_DEBUG ){
1402
+				if ($this->get_model()->exists_by_ID($this->ID())) {
1403
+					if ( ! $this->in_entity_map() && WP_DEBUG) {
1404 1404
 						throw new EE_Error(
1405 1405
 							sprintf(
1406
-								__( 'Using a model object %1$s that is NOT in the entity map, can lead to unexpected errors. You should either: %4$s 1. Put it in the entity mapper by calling %2$s %4$s 2. Discard this model object and use what is in the entity mapper %4$s 3. Fetch from the database using %3$s', 'event_espresso' ),
1406
+								__('Using a model object %1$s that is NOT in the entity map, can lead to unexpected errors. You should either: %4$s 1. Put it in the entity mapper by calling %2$s %4$s 2. Discard this model object and use what is in the entity mapper %4$s 3. Fetch from the database using %3$s', 'event_espresso'),
1407 1407
 								get_class($this),
1408
-								get_class( $this->get_model() ) . '::instance()->add_to_entity_map()',
1409
-								get_class( $this->get_model() ) . '::instance()->get_one_by_ID()',
1408
+								get_class($this->get_model()).'::instance()->add_to_entity_map()',
1409
+								get_class($this->get_model()).'::instance()->get_one_by_ID()',
1410 1410
 								'<br />'
1411 1411
 							)
1412 1412
 						);
1413 1413
 					}
1414 1414
 					$results = $this->get_model()->update_by_ID($save_cols_n_values, $this->ID());
1415
-				}else{
1415
+				} else {
1416 1416
 					$results = $this->get_model()->insert($save_cols_n_values);
1417 1417
 					$this->_update_cached_related_model_objs_fks();
1418 1418
 				}
1419 1419
 			}
1420
-		}else{//there is NO primary key
1420
+		} else {//there is NO primary key
1421 1421
 			$already_in_db = false;
1422
-			foreach($this->get_model()->unique_indexes() as $index){
1422
+			foreach ($this->get_model()->unique_indexes() as $index) {
1423 1423
 				$uniqueness_where_params = array_intersect_key($save_cols_n_values, $index->fields());
1424
-				if($this->get_model()->exists(array($uniqueness_where_params))){
1424
+				if ($this->get_model()->exists(array($uniqueness_where_params))) {
1425 1425
 					$already_in_db = true;
1426 1426
 				}
1427 1427
 			}
1428
-			if( $already_in_db ){
1429
-				$combined_pk_fields_n_values = array_intersect_key( $save_cols_n_values, $this->get_model()->get_combined_primary_key_fields() );
1430
-				$results = $this->get_model()->update( $save_cols_n_values,$combined_pk_fields_n_values );
1431
-			}else{
1432
-				$results = $this->get_model()->insert( $save_cols_n_values );
1428
+			if ($already_in_db) {
1429
+				$combined_pk_fields_n_values = array_intersect_key($save_cols_n_values, $this->get_model()->get_combined_primary_key_fields());
1430
+				$results = $this->get_model()->update($save_cols_n_values, $combined_pk_fields_n_values);
1431
+			} else {
1432
+				$results = $this->get_model()->insert($save_cols_n_values);
1433 1433
 			}
1434 1434
 		}
1435 1435
 		//restore the old assumption about values being prepared by the model object
@@ -1442,7 +1442,7 @@  discard block
 block discarded – undo
1442 1442
 		 * @param boolean|int $results if it were updated, TRUE or FALSE; if it were newly inserted
1443 1443
 		 * the new ID (or 0 if an error occurred and it wasn't updated)
1444 1444
 		 */
1445
-		do_action( 'AHEE__EE_Base_Class__save__end', $this, $results );
1445
+		do_action('AHEE__EE_Base_Class__save__end', $this, $results);
1446 1446
 		return $results;
1447 1447
 	}
1448 1448
 
@@ -1454,13 +1454,13 @@  discard block
 block discarded – undo
1454 1454
 	 * and we want to let its cached relations with foreign keys to it know about that change. Eg: we've created a transaction but haven't saved it to the db. We also create a registration and don't save it to the DB, but we DO cache it on the transaction. Now, when we save the transaction, the registration's TXN_ID will be automatically updated, whether or not they exist in the DB (if they do, their DB records will be automatically updated)
1455 1455
 	 * @return void
1456 1456
 	 */
1457
-	protected function _update_cached_related_model_objs_fks(){
1458
-		foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ){
1459
-			if( $relation_obj instanceof EE_Has_Many_Relation ){
1460
-				foreach( $this->get_all_from_cache( $relation_name ) as $related_model_obj_in_cache) {
1461
-					$fk_to_this = $related_model_obj_in_cache->get_model()->get_foreign_key_to( $this->get_model()->get_this_model_name() );
1462
-					$related_model_obj_in_cache->set($fk_to_this->get_name(), $this->ID() );
1463
-					if( $related_model_obj_in_cache->ID() ){
1457
+	protected function _update_cached_related_model_objs_fks() {
1458
+		foreach ($this->get_model()->relation_settings() as $relation_name => $relation_obj) {
1459
+			if ($relation_obj instanceof EE_Has_Many_Relation) {
1460
+				foreach ($this->get_all_from_cache($relation_name) as $related_model_obj_in_cache) {
1461
+					$fk_to_this = $related_model_obj_in_cache->get_model()->get_foreign_key_to($this->get_model()->get_this_model_name());
1462
+					$related_model_obj_in_cache->set($fk_to_this->get_name(), $this->ID());
1463
+					if ($related_model_obj_in_cache->ID()) {
1464 1464
 						$related_model_obj_in_cache->save();
1465 1465
 					}
1466 1466
 				}
@@ -1476,21 +1476,21 @@  discard block
 block discarded – undo
1476 1476
 	 * and this object and properly setup
1477 1477
 	 * @return int ID of new model object on save; 0 on failure+
1478 1478
 	 */
1479
-	public function save_new_cached_related_model_objs(){
1479
+	public function save_new_cached_related_model_objs() {
1480 1480
 		//make sure this has been saved
1481
-		if( ! $this->ID()){
1481
+		if ( ! $this->ID()) {
1482 1482
 			$id = $this->save();
1483
-		}else{
1483
+		} else {
1484 1484
 			$id = $this->ID();
1485 1485
 		}
1486 1486
 		//now save all the NEW cached model objects  (ie they don't exist in the DB)
1487
-		foreach($this->get_model()->relation_settings() as $relationName => $relationObj){
1487
+		foreach ($this->get_model()->relation_settings() as $relationName => $relationObj) {
1488 1488
 
1489 1489
 
1490
-			if($this->_model_relations[$relationName]){
1490
+			if ($this->_model_relations[$relationName]) {
1491 1491
 				//is this a relation where we should expect just ONE related object (ie, EE_Belongs_To_relation)
1492 1492
 				//or MANY related objects (ie, EE_HABTM_Relation or EE_Has_Many_Relation)?
1493
-				if($relationObj instanceof EE_Belongs_To_Relation){
1493
+				if ($relationObj instanceof EE_Belongs_To_Relation) {
1494 1494
 					//add a relation to that relation type (which saves the appropriate thing in the process)
1495 1495
 					//but ONLY if it DOES NOT exist in the DB
1496 1496
 					/* @var $related_model_obj EE_Base_Class */
@@ -1499,8 +1499,8 @@  discard block
 block discarded – undo
1499 1499
 						$this->_add_relation_to($related_model_obj, $relationName);
1500 1500
 						$related_model_obj->save_new_cached_related_model_objs();
1501 1501
 //					}
1502
-				}else{
1503
-					foreach($this->_model_relations[$relationName] as $related_model_obj){
1502
+				} else {
1503
+					foreach ($this->_model_relations[$relationName] as $related_model_obj) {
1504 1504
 						//add a relation to that relation type (which saves the appropriate thing in the process)
1505 1505
 						//but ONLY if it DOES NOT exist in the DB
1506 1506
 //						if( ! $related_model_obj->ID()){
@@ -1521,8 +1521,8 @@  discard block
 block discarded – undo
1521 1521
 	 * @return \EEM_Base | \EEM_CPT_Base
1522 1522
 	 */
1523 1523
 	public function get_model() {
1524
-		$modelName = self::_get_model_classname( get_class($this) );
1525
-		return self::_get_model_instance_with_name($modelName, $this->_timezone );
1524
+		$modelName = self::_get_model_classname(get_class($this));
1525
+		return self::_get_model_instance_with_name($modelName, $this->_timezone);
1526 1526
 	}
1527 1527
 
1528 1528
 
@@ -1532,10 +1532,10 @@  discard block
 block discarded – undo
1532 1532
 	 * @param $classname
1533 1533
 	 * @return mixed bool|EE_Base_Class|EEM_CPT_Base
1534 1534
 	 */
1535
-	protected static function _get_object_from_entity_mapper($props_n_values, $classname){
1535
+	protected static function _get_object_from_entity_mapper($props_n_values, $classname) {
1536 1536
 		//TODO: will not work for Term_Relationships because they have no PK!
1537
-		$primary_id_ref = self::_get_primary_key_name( $classname );
1538
-		if ( array_key_exists( $primary_id_ref, $props_n_values ) && !empty( $props_n_values[$primary_id_ref] ) ) {
1537
+		$primary_id_ref = self::_get_primary_key_name($classname);
1538
+		if (array_key_exists($primary_id_ref, $props_n_values) && ! empty($props_n_values[$primary_id_ref])) {
1539 1539
 			$id = $props_n_values[$primary_id_ref];
1540 1540
 			return self::_get_model($classname)->get_from_entity_map($id);
1541 1541
 		}
@@ -1552,24 +1552,24 @@  discard block
 block discarded – undo
1552 1552
 	 * @param null    $timezone
1553 1553
 	 * @return mixed (EE_Base_Class|bool)
1554 1554
 	 */
1555
-	protected static function _check_for_object( $props_n_values, $classname, $timezone = NULL ) {
1556
-		if( self::_get_model( $classname )->has_primary_key_field()){
1557
-			$primary_id_ref = self::_get_primary_key_name( $classname );
1555
+	protected static function _check_for_object($props_n_values, $classname, $timezone = NULL) {
1556
+		if (self::_get_model($classname)->has_primary_key_field()) {
1557
+			$primary_id_ref = self::_get_primary_key_name($classname);
1558 1558
 
1559
-			if ( array_key_exists( $primary_id_ref, $props_n_values ) && !empty( $props_n_values[$primary_id_ref] ) ) {
1560
-				$existing = self::_get_model( $classname, $timezone )->get_one_by_ID( $props_n_values[$primary_id_ref] );
1561
-			}else{
1559
+			if (array_key_exists($primary_id_ref, $props_n_values) && ! empty($props_n_values[$primary_id_ref])) {
1560
+				$existing = self::_get_model($classname, $timezone)->get_one_by_ID($props_n_values[$primary_id_ref]);
1561
+			} else {
1562 1562
 				$existing = null;
1563 1563
 			}
1564
-		}elseif( self::_get_model( $classname, $timezone )->has_all_combined_primary_key_fields(  $props_n_values ) ){
1564
+		}elseif (self::_get_model($classname, $timezone)->has_all_combined_primary_key_fields($props_n_values)) {
1565 1565
 			//no primary key on this model, but there's still a matching item in the DB
1566
-				$existing = self::_get_model($classname, $timezone)->get_one_by_ID( self::_get_model($classname, $timezone)->get_index_primary_key_string( $props_n_values ) );
1567
-		}else{
1566
+				$existing = self::_get_model($classname, $timezone)->get_one_by_ID(self::_get_model($classname, $timezone)->get_index_primary_key_string($props_n_values));
1567
+		} else {
1568 1568
 			$existing = null;
1569 1569
 		}
1570
-		if ( $existing ) {
1571
-			foreach ( $props_n_values as $property => $field_value ) {
1572
-				$existing->set( $property, $field_value );
1570
+		if ($existing) {
1571
+			foreach ($props_n_values as $property => $field_value) {
1572
+				$existing->set($property, $field_value);
1573 1573
 			}
1574 1574
 			return $existing;
1575 1575
 		} else {
@@ -1587,13 +1587,13 @@  discard block
 block discarded – undo
1587 1587
 	 * @throws EE_Error
1588 1588
 	 * @return EEM_Base
1589 1589
 	 */
1590
-	protected static function  _get_model( $classname, $timezone = NULL ){
1590
+	protected static function  _get_model($classname, $timezone = NULL) {
1591 1591
 		//find model for this class
1592
-		if( ! $classname ){
1593
-			throw new EE_Error(sprintf(__("What were you thinking calling _get_model(%s)?? You need to specify the class name", "event_espresso"),$classname));
1592
+		if ( ! $classname) {
1593
+			throw new EE_Error(sprintf(__("What were you thinking calling _get_model(%s)?? You need to specify the class name", "event_espresso"), $classname));
1594 1594
 		}
1595
-		$modelName=self::_get_model_classname($classname);
1596
-		return self::_get_model_instance_with_name($modelName, $timezone );
1595
+		$modelName = self::_get_model_classname($classname);
1596
+		return self::_get_model_instance_with_name($modelName, $timezone);
1597 1597
 	}
1598 1598
 
1599 1599
 
@@ -1604,10 +1604,10 @@  discard block
 block discarded – undo
1604 1604
 	 * @param null   $timezone
1605 1605
 	 * @return EEM_Base
1606 1606
 	 */
1607
-	protected static function _get_model_instance_with_name($model_classname, $timezone = NULL){
1608
-		$model_classname = str_replace( 'EEM_', '', $model_classname );
1609
-		$model = EE_Registry::instance()->load_model( $model_classname );
1610
-		$model->set_timezone( $timezone );
1607
+	protected static function _get_model_instance_with_name($model_classname, $timezone = NULL) {
1608
+		$model_classname = str_replace('EEM_', '', $model_classname);
1609
+		$model = EE_Registry::instance()->load_model($model_classname);
1610
+		$model->set_timezone($timezone);
1611 1611
 		return $model;
1612 1612
 	}
1613 1613
 
@@ -1619,10 +1619,10 @@  discard block
 block discarded – undo
1619 1619
 	 * @param null $model_name
1620 1620
 	 * @return string like EEM_Attendee
1621 1621
 	 */
1622
-	private static function _get_model_classname( $model_name = null){
1623
-		if(strpos($model_name,"EE_")===0){
1624
-			$model_classname=str_replace("EE_","EEM_",$model_name);
1625
-		}else{
1622
+	private static function _get_model_classname($model_name = null) {
1623
+		if (strpos($model_name, "EE_") === 0) {
1624
+			$model_classname = str_replace("EE_", "EEM_", $model_name);
1625
+		} else {
1626 1626
 			$model_classname = "EEM_".$model_name;
1627 1627
 		}
1628 1628
 		return $model_classname;
@@ -1636,11 +1636,11 @@  discard block
 block discarded – undo
1636 1636
 	 * @throws EE_Error
1637 1637
 	 * @return string
1638 1638
 	 */
1639
-	protected static function _get_primary_key_name( $classname = NULL ){
1640
-		if( ! $classname){
1641
-			throw new EE_Error(sprintf(__("What were you thinking calling _get_primary_key_name(%s)", "event_espresso"),$classname));
1639
+	protected static function _get_primary_key_name($classname = NULL) {
1640
+		if ( ! $classname) {
1641
+			throw new EE_Error(sprintf(__("What were you thinking calling _get_primary_key_name(%s)", "event_espresso"), $classname));
1642 1642
 		}
1643
-		return self::_get_model( $classname )->get_primary_key_field()->get_name();
1643
+		return self::_get_model($classname)->get_primary_key_field()->get_name();
1644 1644
 	}
1645 1645
 
1646 1646
 
@@ -1652,12 +1652,12 @@  discard block
 block discarded – undo
1652 1652
 	 * Usually defaults for integer primary keys are 0; string primary keys are usually NULL).
1653 1653
 	 * @return mixed, if the primary key is of type INT it'll be an int. Otherwise it could be a string
1654 1654
 	 */
1655
-	public function ID(){
1655
+	public function ID() {
1656 1656
 		//now that we know the name of the variable, use a variable variable to get its value and return its
1657
-		if( $this->get_model()->has_primary_key_field() ) {
1658
-			return $this->_fields[self::_get_primary_key_name( get_class($this) )];
1659
-		}else{
1660
-			return $this->get_model()->get_index_primary_key_string( $this->_fields );
1657
+		if ($this->get_model()->has_primary_key_field()) {
1658
+			return $this->_fields[self::_get_primary_key_name(get_class($this))];
1659
+		} else {
1660
+			return $this->get_model()->get_index_primary_key_string($this->_fields);
1661 1661
 		}
1662 1662
 	}
1663 1663
 
@@ -1675,38 +1675,38 @@  discard block
 block discarded – undo
1675 1675
 	 * @throws EE_Error
1676 1676
 	 * @return EE_Base_Class the object the relation was added to
1677 1677
 	 */
1678
-	public function _add_relation_to( $otherObjectModelObjectOrID,$relationName, $extra_join_model_fields_n_values = array(), $cache_id = NULL ){
1678
+	public function _add_relation_to($otherObjectModelObjectOrID, $relationName, $extra_join_model_fields_n_values = array(), $cache_id = NULL) {
1679 1679
 		//if this thing exists in the DB, save the relation to the DB
1680
-		if( $this->ID() ){
1681
-			$otherObject = $this->get_model()->add_relationship_to( $this, $otherObjectModelObjectOrID, $relationName, $extra_join_model_fields_n_values );
1680
+		if ($this->ID()) {
1681
+			$otherObject = $this->get_model()->add_relationship_to($this, $otherObjectModelObjectOrID, $relationName, $extra_join_model_fields_n_values);
1682 1682
 			//clear cache so future get_many_related and get_first_related() return new results.
1683
-			$this->clear_cache( $relationName, $otherObject, TRUE );
1684
-                        if( $otherObject instanceof EE_Base_Class ) {
1685
-                            $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this );
1683
+			$this->clear_cache($relationName, $otherObject, TRUE);
1684
+                        if ($otherObject instanceof EE_Base_Class) {
1685
+                            $otherObject->clear_cache($this->get_model()->get_this_model_name(), $this);
1686 1686
                         }
1687 1687
 		} else {
1688 1688
 			//this thing doesn't exist in the DB,  so just cache it
1689
-			if( ! $otherObjectModelObjectOrID instanceof EE_Base_Class){
1690
-				throw new EE_Error( sprintf(
1691
-					__( 'Before a model object is saved to the database, calls to _add_relation_to must be passed an actual object, not just an ID. You provided %s as the model object to a %s', 'event_espresso' ),
1689
+			if ( ! $otherObjectModelObjectOrID instanceof EE_Base_Class) {
1690
+				throw new EE_Error(sprintf(
1691
+					__('Before a model object is saved to the database, calls to _add_relation_to must be passed an actual object, not just an ID. You provided %s as the model object to a %s', 'event_espresso'),
1692 1692
 					$otherObjectModelObjectOrID,
1693
-					get_class( $this )
1693
+					get_class($this)
1694 1694
 				));
1695 1695
 			} else {
1696 1696
 				$otherObject = $otherObjectModelObjectOrID;
1697 1697
 			}
1698
-			$this->cache( $relationName, $otherObjectModelObjectOrID, $cache_id );
1698
+			$this->cache($relationName, $otherObjectModelObjectOrID, $cache_id);
1699 1699
 		}
1700
-                if( $otherObject instanceof EE_Base_Class ) {
1700
+                if ($otherObject instanceof EE_Base_Class) {
1701 1701
                     //fix the reciprocal relation too
1702
-                    if( $otherObject->ID() ) {
1702
+                    if ($otherObject->ID()) {
1703 1703
                             //its saved so assumed relations exist in the DB, so we can just
1704 1704
                             //clear the cache so future queries use the updated info in the DB
1705
-                            $otherObject->clear_cache( $this->get_model()->get_this_model_name(), null, true );
1705
+                            $otherObject->clear_cache($this->get_model()->get_this_model_name(), null, true);
1706 1706
                     } else {
1707 1707
 
1708 1708
                             //it's not saved, so it caches relations like this
1709
-                            $otherObject->cache( $this->get_model()->get_this_model_name(), $this );
1709
+                            $otherObject->cache($this->get_model()->get_this_model_name(), $this);
1710 1710
                     }
1711 1711
                 }
1712 1712
 		return $otherObject;
@@ -1729,17 +1729,17 @@  discard block
 block discarded – undo
1729 1729
 	 * 				Also remember that if an exact match isn't found for these extra cols/val pairs, then a NEW row is created in the join table.
1730 1730
 	 * @return EE_Base_Class the relation was removed from
1731 1731
 	 */
1732
-	public function _remove_relation_to($otherObjectModelObjectOrID,$relationName, $where_query = array() ){
1733
-		if ( $this->ID() ) {
1732
+	public function _remove_relation_to($otherObjectModelObjectOrID, $relationName, $where_query = array()) {
1733
+		if ($this->ID()) {
1734 1734
 			//if this exists in the DB, save the relation change to the DB too
1735
-			$otherObject = $this->get_model()->remove_relationship_to( $this, $otherObjectModelObjectOrID, $relationName, $where_query );
1736
-			$this->clear_cache( $relationName, $otherObject );
1735
+			$otherObject = $this->get_model()->remove_relationship_to($this, $otherObjectModelObjectOrID, $relationName, $where_query);
1736
+			$this->clear_cache($relationName, $otherObject);
1737 1737
 		} else {
1738 1738
 			//this doesn't exist in the DB, just remove it from the cache
1739
-			$otherObject = $this->clear_cache( $relationName, $otherObjectModelObjectOrID );
1739
+			$otherObject = $this->clear_cache($relationName, $otherObjectModelObjectOrID);
1740 1740
 		}
1741
-                if( $otherObject instanceof EE_Base_Class ) {
1742
-                    $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this );
1741
+                if ($otherObject instanceof EE_Base_Class) {
1742
+                    $otherObject->clear_cache($this->get_model()->get_this_model_name(), $this);
1743 1743
                 }
1744 1744
 		return $otherObject;
1745 1745
 	}
@@ -1750,18 +1750,18 @@  discard block
 block discarded – undo
1750 1750
 	 * @param array $where_query_params like EEM_Base::get_all's $query_params[0] (where conditions)
1751 1751
 	 * @return EE_Base_Class
1752 1752
 	 */
1753
-	public function _remove_relations($relationName,$where_query_params = array()){
1754
-		if ( $this->ID() ) {
1753
+	public function _remove_relations($relationName, $where_query_params = array()) {
1754
+		if ($this->ID()) {
1755 1755
 			//if this exists in the DB, save the relation change to the DB too
1756
-			$otherObjects = $this->get_model()->remove_relations( $this, $relationName, $where_query_params );
1757
-			$this->clear_cache( $relationName, null, true );
1756
+			$otherObjects = $this->get_model()->remove_relations($this, $relationName, $where_query_params);
1757
+			$this->clear_cache($relationName, null, true);
1758 1758
 		} else {
1759 1759
 			//this doesn't exist in the DB, just remove it from the cache
1760
-			$otherObjects = $this->clear_cache( $relationName, null, true );
1760
+			$otherObjects = $this->clear_cache($relationName, null, true);
1761 1761
 		}
1762
-                if( is_array( $otherObjects ) ) {
1763
-                    foreach ( $otherObjects as $otherObject ) {
1764
-                            $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this );
1762
+                if (is_array($otherObjects)) {
1763
+                    foreach ($otherObjects as $otherObject) {
1764
+                            $otherObject->clear_cache($this->get_model()->get_this_model_name(), $this);
1765 1765
                     }
1766 1766
                 }
1767 1767
 		return $otherObjects;
@@ -1779,26 +1779,26 @@  discard block
 block discarded – undo
1779 1779
 	 * @return EE_Base_Class[] Results not necessarily indexed by IDs, because some results might not have primary keys
1780 1780
 	 * or might not be saved yet. Consider using EEM_Base::get_IDs() on these results if you want IDs
1781 1781
 	 */
1782
-	public function get_many_related($relationName,$query_params = array()){
1783
-		if($this->ID()){//this exists in the DB, so get the related things from either the cache or the DB
1782
+	public function get_many_related($relationName, $query_params = array()) {
1783
+		if ($this->ID()) {//this exists in the DB, so get the related things from either the cache or the DB
1784 1784
 			//if there are query parameters, forget about caching the related model objects.
1785
-			if( $query_params ){
1785
+			if ($query_params) {
1786 1786
 				$related_model_objects = $this->get_model()->get_all_related($this, $relationName, $query_params);
1787
-			}else{
1787
+			} else {
1788 1788
 				//did we already cache the result of this query?
1789 1789
 				$cached_results = $this->get_all_from_cache($relationName);
1790
-				if ( ! $cached_results ){
1790
+				if ( ! $cached_results) {
1791 1791
 					$related_model_objects = $this->get_model()->get_all_related($this, $relationName, $query_params);
1792 1792
 					//if no query parameters were passed, then we got all the related model objects
1793 1793
 					//for that relation. We can cache them then.
1794
-					foreach($related_model_objects as $related_model_object){
1794
+					foreach ($related_model_objects as $related_model_object) {
1795 1795
 						$this->cache($relationName, $related_model_object);
1796 1796
 					}
1797
-				}else{
1797
+				} else {
1798 1798
 					$related_model_objects = $cached_results;
1799 1799
 				}
1800 1800
 			}
1801
-		}else{//this doesn't exist itn eh DB, so just get the related things from the cache
1801
+		} else {//this doesn't exist itn eh DB, so just get the related things from the cache
1802 1802
 			$related_model_objects = $this->get_all_from_cache($relationName);
1803 1803
 		}
1804 1804
 		return $related_model_objects;
@@ -1815,8 +1815,8 @@  discard block
 block discarded – undo
1815 1815
 	 * @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;
1816 1816
 	 * @return int
1817 1817
 	 */
1818
-	public function count_related($relation_name, $query_params =array(),$field_to_count = NULL, $distinct = FALSE){
1819
-		return $this->get_model()->count_related($this,$relation_name,$query_params,$field_to_count,$distinct);
1818
+	public function count_related($relation_name, $query_params = array(), $field_to_count = NULL, $distinct = FALSE) {
1819
+		return $this->get_model()->count_related($this, $relation_name, $query_params, $field_to_count, $distinct);
1820 1820
 	}
1821 1821
 
1822 1822
 
@@ -1830,7 +1830,7 @@  discard block
 block discarded – undo
1830 1830
 	 * 						By default, uses primary key (which doesn't make much sense, so you should probably change it)
1831 1831
 	 * @return int
1832 1832
 	 */
1833
-	public function sum_related($relation_name, $query_params = array(), $field_to_sum = null){
1833
+	public function sum_related($relation_name, $query_params = array(), $field_to_sum = null) {
1834 1834
 		return $this->get_model()->sum_related($this, $relation_name, $query_params, $field_to_sum);
1835 1835
 	}
1836 1836
 
@@ -1842,34 +1842,34 @@  discard block
 block discarded – undo
1842 1842
 	 * @param array  $query_params  like EEM_Base::get_all
1843 1843
 	 * @return EE_Base_Class (not an array, a single object)
1844 1844
 	 */
1845
-	public function get_first_related($relationName,$query_params = array()){
1846
-		if($this->ID()){//this exists in the DB, get from the cache OR the DB
1845
+	public function get_first_related($relationName, $query_params = array()) {
1846
+		if ($this->ID()) {//this exists in the DB, get from the cache OR the DB
1847 1847
 
1848 1848
 			//if they've provided some query parameters, don't bother trying to cache the result
1849 1849
 			//also make sure we're not caching the result of get_first_related
1850 1850
 			//on a relation which should have an array of objects (because the cache might have an array of objects)
1851
-			if ($query_params || ! $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation){
1852
-				$related_model_object =  $this->get_model()->get_first_related($this, $relationName, $query_params);
1853
-			}else{
1851
+			if ($query_params || ! $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation) {
1852
+				$related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params);
1853
+			} else {
1854 1854
 				//first, check if we've already cached the result of this query
1855 1855
 				$cached_result = $this->get_one_from_cache($relationName);
1856
-				if ( ! $cached_result ){
1856
+				if ( ! $cached_result) {
1857 1857
 
1858 1858
 					$related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params);
1859
-					$this->cache($relationName,$related_model_object);
1860
-				}else{
1859
+					$this->cache($relationName, $related_model_object);
1860
+				} else {
1861 1861
 					$related_model_object = $cached_result;
1862 1862
 				}
1863 1863
 			}
1864
-		}else{
1864
+		} else {
1865 1865
 			//this doesn't exist in the Db, but maybe the relation is of type belongs to, and so the related thing might
1866
-			if( $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation){
1867
-				$related_model_object =  $this->get_model()->get_first_related($this, $relationName, $query_params);
1868
-			}else{
1866
+			if ($this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation) {
1867
+				$related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params);
1868
+			} else {
1869 1869
 				$related_model_object = null;
1870 1870
 			}
1871 1871
 			//this doesn't exist in the DB and apparently the thing it belongs to doesn't either, just get what's cached on this object
1872
-			if( ! $related_model_object){
1872
+			if ( ! $related_model_object) {
1873 1873
 				$related_model_object = $this->get_one_from_cache($relationName);
1874 1874
 			}
1875 1875
 
@@ -1888,12 +1888,12 @@  discard block
 block discarded – undo
1888 1888
 	 * @param array $query_params like EEM_Base::get_all's
1889 1889
 	 * @return int how many deleted
1890 1890
 	 */
1891
-	public function delete_related($relationName,$query_params = array()){
1892
-		if($this->ID()){
1893
-			$count =  $this->get_model()->delete_related($this, $relationName, $query_params);
1894
-		}else{
1891
+	public function delete_related($relationName, $query_params = array()) {
1892
+		if ($this->ID()) {
1893
+			$count = $this->get_model()->delete_related($this, $relationName, $query_params);
1894
+		} else {
1895 1895
 			$count = count($this->get_all_from_cache($relationName));
1896
-			$this->clear_cache($relationName,NULL,TRUE);
1896
+			$this->clear_cache($relationName, NULL, TRUE);
1897 1897
 		}
1898 1898
 		return $count;
1899 1899
 	}
@@ -1908,13 +1908,13 @@  discard block
 block discarded – undo
1908 1908
 	 * @param array $query_params like EEM_Base::get_all's
1909 1909
 	 * @return int how many deleted (including those soft deleted)
1910 1910
 	 */
1911
-	public function delete_related_permanently($relationName,$query_params = array()){
1912
-		if($this->ID()){
1913
-			$count =  $this->get_model()->delete_related_permanently($this, $relationName, $query_params);
1914
-		}else{
1911
+	public function delete_related_permanently($relationName, $query_params = array()) {
1912
+		if ($this->ID()) {
1913
+			$count = $this->get_model()->delete_related_permanently($this, $relationName, $query_params);
1914
+		} else {
1915 1915
 			$count = count($this->get_all_from_cache($relationName));
1916 1916
 		}
1917
-		$this->clear_cache($relationName,NULL,TRUE);
1917
+		$this->clear_cache($relationName, NULL, TRUE);
1918 1918
 		return $count;
1919 1919
 	}
1920 1920
 
@@ -1930,7 +1930,7 @@  discard block
 block discarded – undo
1930 1930
 	 * @param  string $field_name property to check
1931 1931
 	 * @return bool            				  TRUE if existing,FALSE if not.
1932 1932
 	 */
1933
-	public function is_set( $field_name ) {
1933
+	public function is_set($field_name) {
1934 1934
 		return isset($this->_fields[$field_name]);
1935 1935
 	}
1936 1936
 
@@ -1942,12 +1942,12 @@  discard block
 block discarded – undo
1942 1942
 	 * @throws EE_Error
1943 1943
 	 * @return bool                              TRUE if existing, throw EE_Error if not.
1944 1944
 	 */
1945
-	protected function _property_exists( $properties ) {
1945
+	protected function _property_exists($properties) {
1946 1946
 
1947
-		foreach ( (array) $properties as $property_name ) {
1947
+		foreach ((array) $properties as $property_name) {
1948 1948
 			//first make sure this property exists
1949
-			if ( ! $this->_fields[ $property_name ] )
1950
-				throw new EE_Error( sprintf( __('Trying to retrieve a non-existent property (%s).  Double check the spelling please', 'event_espresso'), $property_name ) );
1949
+			if ( ! $this->_fields[$property_name])
1950
+				throw new EE_Error(sprintf(__('Trying to retrieve a non-existent property (%s).  Double check the spelling please', 'event_espresso'), $property_name));
1951 1951
 		}
1952 1952
 
1953 1953
 		return TRUE;
@@ -1964,7 +1964,7 @@  discard block
 block discarded – undo
1964 1964
 		$fields = $this->get_model()->field_settings(FALSE);
1965 1965
 		$properties = array();
1966 1966
 		//remove prepended underscore
1967
-		foreach ( $fields as $field_name => $settings ) {
1967
+		foreach ($fields as $field_name => $settings) {
1968 1968
 			$properties[$field_name] = $this->get($field_name);
1969 1969
 		}
1970 1970
 		return $properties;
@@ -1994,14 +1994,14 @@  discard block
 block discarded – undo
1994 1994
 	 * @throws EE_Error
1995 1995
 	 * @return mixed whatever the plugin which calls add_filter decides
1996 1996
 	 */
1997
-	public function __call($methodName,$args){
1998
-		$className=get_class($this);
1999
-		$tagName="FHEE__{$className}__{$methodName}";
2000
-		if(!has_filter($tagName)){
2001
-			throw new EE_Error(sprintf(__("Method %s on class %s does not exist! You can create one with the following code in functions.php or in a plugin: add_filter('%s','my_callback',10,3);function my_callback(\$previousReturnValue,EE_Base_Class \$object, \$argsArray){/*function body*/return \$whatever;}","event_espresso"),
2002
-										$methodName,$className,$tagName));
1997
+	public function __call($methodName, $args) {
1998
+		$className = get_class($this);
1999
+		$tagName = "FHEE__{$className}__{$methodName}";
2000
+		if ( ! has_filter($tagName)) {
2001
+			throw new EE_Error(sprintf(__("Method %s on class %s does not exist! You can create one with the following code in functions.php or in a plugin: add_filter('%s','my_callback',10,3);function my_callback(\$previousReturnValue,EE_Base_Class \$object, \$argsArray){/*function body*/return \$whatever;}", "event_espresso"),
2002
+										$methodName, $className, $tagName));
2003 2003
 		}
2004
-		return apply_filters($tagName,null,$this,$args);
2004
+		return apply_filters($tagName, null, $this, $args);
2005 2005
 	}
2006 2006
 
2007 2007
 
@@ -2016,22 +2016,22 @@  discard block
 block discarded – undo
2016 2016
 	 * @return int records updated (or BOOLEAN if we actually ended up inserting the extra meta row)
2017 2017
 	 * NOTE: if the values haven't changed, returns 0
2018 2018
 	 */
2019
-	public function update_extra_meta($meta_key,$meta_value,$previous_value = NULL){
2020
-		$query_params  = array(array(
2019
+	public function update_extra_meta($meta_key, $meta_value, $previous_value = NULL) {
2020
+		$query_params = array(array(
2021 2021
 			'EXM_key'=>$meta_key,
2022 2022
 			'OBJ_ID'=>$this->ID(),
2023 2023
 			'EXM_type'=>$this->get_model()->get_this_model_name()));
2024
-		if($previous_value !== NULL){
2024
+		if ($previous_value !== NULL) {
2025 2025
 			$query_params[0]['EXM_value'] = $meta_value;
2026 2026
 		}
2027 2027
 		$existing_rows_like_that = EEM_Extra_Meta::instance()->get_all($query_params);
2028
-		if( ! $existing_rows_like_that){
2028
+		if ( ! $existing_rows_like_that) {
2029 2029
 			return $this->add_extra_meta($meta_key, $meta_value);
2030
-		}else{
2031
-			foreach( $existing_rows_like_that as $existing_row){
2032
-				$existing_row->save( array( 'EXM_value' => $meta_value ) );
2030
+		} else {
2031
+			foreach ($existing_rows_like_that as $existing_row) {
2032
+				$existing_row->save(array('EXM_value' => $meta_value));
2033 2033
 			}
2034
-			return count( $existing_rows_like_that );
2034
+			return count($existing_rows_like_that);
2035 2035
 		}
2036 2036
 	}
2037 2037
 
@@ -2044,10 +2044,10 @@  discard block
 block discarded – undo
2044 2044
 	 * @param boolean $unique
2045 2045
 	 * @return boolean
2046 2046
 	 */
2047
-	public function add_extra_meta($meta_key,$meta_value,$unique = false){
2048
-		if($unique){
2049
-			$existing_extra_meta = EEM_Extra_Meta::instance()->get_one(array(array('EXM_key'=>$meta_key,'OBJ_ID'=>$this->ID(),'EXM_type'=>$this->_get_model_classname(get_class($this)))));
2050
-			if($existing_extra_meta){
2047
+	public function add_extra_meta($meta_key, $meta_value, $unique = false) {
2048
+		if ($unique) {
2049
+			$existing_extra_meta = EEM_Extra_Meta::instance()->get_one(array(array('EXM_key'=>$meta_key, 'OBJ_ID'=>$this->ID(), 'EXM_type'=>$this->_get_model_classname(get_class($this)))));
2050
+			if ($existing_extra_meta) {
2051 2051
 				return false;
2052 2052
 			}
2053 2053
 		}
@@ -2067,12 +2067,12 @@  discard block
 block discarded – undo
2067 2067
 	 * @param string $meta_value
2068 2068
 	 * @return int number of extra meta rows deleted
2069 2069
 	 */
2070
-	public function delete_extra_meta($meta_key,$meta_value = NULL){
2071
-		$query_params  = array(array(
2070
+	public function delete_extra_meta($meta_key, $meta_value = NULL) {
2071
+		$query_params = array(array(
2072 2072
 			'EXM_key'=>$meta_key,
2073 2073
 			'OBJ_ID'=>$this->ID(),
2074 2074
 			'EXM_type'=>$this->get_model()->get_this_model_name()));
2075
-		if($meta_value !== NULL){
2075
+		if ($meta_value !== NULL) {
2076 2076
 			$query_params[0]['EXM_value'] = $meta_value;
2077 2077
 		}
2078 2078
 		$count_deleted = EEM_Extra_Meta::instance()->delete($query_params);
@@ -2088,25 +2088,25 @@  discard block
 block discarded – undo
2088 2088
 	 * @param mixed $default if we don't find anything, what should we return?
2089 2089
 	 * @return mixed single value if $single; array if ! $single
2090 2090
 	 */
2091
-	public function get_extra_meta($meta_key,$single = FALSE,$default = NULL){
2092
-		if($single){
2093
-			$result = $this->get_first_related('Extra_Meta',array(array('EXM_key'=>$meta_key)));
2094
-			if ( $result instanceof EE_Extra_Meta ){
2091
+	public function get_extra_meta($meta_key, $single = FALSE, $default = NULL) {
2092
+		if ($single) {
2093
+			$result = $this->get_first_related('Extra_Meta', array(array('EXM_key'=>$meta_key)));
2094
+			if ($result instanceof EE_Extra_Meta) {
2095 2095
 				return $result->value();
2096
-			}else{
2096
+			} else {
2097 2097
 				return $default;
2098 2098
 			}
2099
-		}else{
2100
-			$results =  $this->get_many_related('Extra_Meta',array(array('EXM_key'=>$meta_key)));
2101
-			if($results){
2099
+		} else {
2100
+			$results = $this->get_many_related('Extra_Meta', array(array('EXM_key'=>$meta_key)));
2101
+			if ($results) {
2102 2102
 				$values = array();
2103
-				foreach($results as $result){
2104
-					if ( $result instanceof EE_Extra_Meta ){
2103
+				foreach ($results as $result) {
2104
+					if ($result instanceof EE_Extra_Meta) {
2105 2105
 						$values[$result->ID()] = $result->value();
2106 2106
 					}
2107 2107
 				}
2108 2108
 				return $values;
2109
-			}else{
2109
+			} else {
2110 2110
 				return $default;
2111 2111
 			}
2112 2112
 		}
@@ -2123,20 +2123,20 @@  discard block
 block discarded – undo
2123 2123
 	 * @param boolean $one_of_each_key
2124 2124
 	 * @return array
2125 2125
 	 */
2126
-	public function all_extra_meta_array($one_of_each_key = true){
2126
+	public function all_extra_meta_array($one_of_each_key = true) {
2127 2127
 		$return_array = array();
2128
-		if($one_of_each_key){
2128
+		if ($one_of_each_key) {
2129 2129
 			$extra_meta_objs = $this->get_many_related('Extra_Meta', array('group_by'=>'EXM_key'));
2130
-			foreach($extra_meta_objs as $extra_meta_obj){
2131
-				if ( $extra_meta_obj instanceof EE_Extra_Meta ) {
2130
+			foreach ($extra_meta_objs as $extra_meta_obj) {
2131
+				if ($extra_meta_obj instanceof EE_Extra_Meta) {
2132 2132
 					$return_array[$extra_meta_obj->key()] = $extra_meta_obj->value();
2133 2133
 				}
2134 2134
 			}
2135
-		}else{
2135
+		} else {
2136 2136
 			$extra_meta_objs = $this->get_many_related('Extra_Meta');
2137
-			foreach($extra_meta_objs as $extra_meta_obj){
2138
-				if ( $extra_meta_obj instanceof EE_Extra_Meta ) {
2139
-					if( ! isset($return_array[$extra_meta_obj->key()])){
2137
+			foreach ($extra_meta_objs as $extra_meta_obj) {
2138
+				if ($extra_meta_obj instanceof EE_Extra_Meta) {
2139
+					if ( ! isset($return_array[$extra_meta_obj->key()])) {
2140 2140
 						$return_array[$extra_meta_obj->key()] = array();
2141 2141
 					}
2142 2142
 					$return_array[$extra_meta_obj->key()][$extra_meta_obj->ID()] = $extra_meta_obj->value();
@@ -2149,19 +2149,19 @@  discard block
 block discarded – undo
2149 2149
 	 * Gets a pretty nice displayable nice for this model object. Often overridden
2150 2150
 	 * @return string
2151 2151
 	 */
2152
-	public function name(){
2152
+	public function name() {
2153 2153
 		//find a field that's not a text field
2154 2154
 		$field_we_can_use = $this->get_model()->get_a_field_of_type('EE_Text_Field_Base');
2155
-		if($field_we_can_use){
2155
+		if ($field_we_can_use) {
2156 2156
 			return $this->get($field_we_can_use->get_name());
2157
-		}else{
2157
+		} else {
2158 2158
 			$first_few_properties = $this->model_field_array();
2159
-			$first_few_properties = array_slice($first_few_properties,0,3);
2159
+			$first_few_properties = array_slice($first_few_properties, 0, 3);
2160 2160
 			$name_parts = array();
2161
-			foreach( $first_few_properties as $name=> $value ){
2161
+			foreach ($first_few_properties as $name=> $value) {
2162 2162
 				$name_parts[] = "$name:$value";
2163 2163
 			}
2164
-			return implode(",",$name_parts);
2164
+			return implode(",", $name_parts);
2165 2165
 		}
2166 2166
 	}
2167 2167
 
@@ -2170,11 +2170,11 @@  discard block
 block discarded – undo
2170 2170
 	 * Checks if this model object has been proven to already be in the entity map
2171 2171
 	 * @return boolean
2172 2172
 	 */
2173
-	public function in_entity_map(){
2174
-		if( $this->ID() && $this->get_model()->get_from_entity_map( $this->ID() ) === $this ) {
2173
+	public function in_entity_map() {
2174
+		if ($this->ID() && $this->get_model()->get_from_entity_map($this->ID()) === $this) {
2175 2175
 			//well, if we looked, did we find it in the entity map?
2176 2176
 			return TRUE;
2177
-		}else{
2177
+		} else {
2178 2178
 			return FALSE;
2179 2179
 		}
2180 2180
 	}
@@ -2185,21 +2185,21 @@  discard block
 block discarded – undo
2185 2185
 	 * @throws EE_Error if this model object isn't in the entity mapper (because then you should
2186 2186
 	 * just use what's in the entity mapper and refresh it) and WP_DEBUG is TRUE
2187 2187
 	 */
2188
-	public function refresh_from_db(){
2189
-		if( $this->ID() && $this->in_entity_map() ){
2190
-			$this->get_model()->refresh_entity_map_from_db( $this->ID() );
2191
-		}else{
2188
+	public function refresh_from_db() {
2189
+		if ($this->ID() && $this->in_entity_map()) {
2190
+			$this->get_model()->refresh_entity_map_from_db($this->ID());
2191
+		} else {
2192 2192
 			//if it doesn't have ID, you shouldn't be asking to refresh it from teh database (because its not in the database)
2193 2193
 			//if it has an ID but it's not in the map, and you're asking me to refresh it
2194 2194
 			//that's kinda dangerous. You should just use what's in the entity map, or add this to the entity map if there's
2195 2195
 			//absolutely nothing in it for this ID
2196
-			if( WP_DEBUG ) {
2196
+			if (WP_DEBUG) {
2197 2197
 				throw new EE_Error(
2198 2198
 					sprintf(
2199
-						__( 'Trying to refresh a model object with ID "%1$s" that\'s not in the entity map? First off: you should put it in the entity map by calling %2$s. Second off, if you want what\'s in the database right now, you should just call %3$s yourself and discard this model object.', 'event_espresso' ),
2199
+						__('Trying to refresh a model object with ID "%1$s" that\'s not in the entity map? First off: you should put it in the entity map by calling %2$s. Second off, if you want what\'s in the database right now, you should just call %3$s yourself and discard this model object.', 'event_espresso'),
2200 2200
 						$this->ID(),
2201
-						get_class( $this->get_model() ) . '::instance()->add_to_entity_map()',
2202
-						get_class( $this->get_model() ) . '::instance()->refresh_entity_map()'
2201
+						get_class($this->get_model()).'::instance()->add_to_entity_map()',
2202
+						get_class($this->get_model()).'::instance()->refresh_entity_map()'
2203 2203
 					)
2204 2204
 				);
2205 2205
 			}
@@ -2211,8 +2211,8 @@  discard block
 block discarded – undo
2211 2211
 	 * (probably a bad assumption they have made, oh well)
2212 2212
 	 * @return string
2213 2213
 	 */
2214
-	public function __toString(){
2215
-		return sprintf( '%s (%s)', $this->name(), $this->ID() );
2214
+	public function __toString() {
2215
+		return sprintf('%s (%s)', $this->name(), $this->ID());
2216 2216
 	}
2217 2217
 
2218 2218
 	/**
@@ -2244,16 +2244,16 @@  discard block
 block discarded – undo
2244 2244
 	 * @return array
2245 2245
 	 */
2246 2246
 	public function __sleep() {
2247
-		foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ) {
2248
-			if( $relation_obj instanceof EE_Belongs_To_Relation ) {
2249
-				$classname = 'EE_' . $this->get_model()->get_this_model_name();
2250
-				if( $this->get_one_from_cache( $relation_name ) instanceof $classname &&
2251
-						$this->get_one_from_cache( $relation_name )->ID() ) {
2252
-					$this->clear_cache( $relation_name, $this->get_one_from_cache( $relation_name )->ID() );
2247
+		foreach ($this->get_model()->relation_settings() as $relation_name => $relation_obj) {
2248
+			if ($relation_obj instanceof EE_Belongs_To_Relation) {
2249
+				$classname = 'EE_'.$this->get_model()->get_this_model_name();
2250
+				if ($this->get_one_from_cache($relation_name) instanceof $classname &&
2251
+						$this->get_one_from_cache($relation_name)->ID()) {
2252
+					$this->clear_cache($relation_name, $this->get_one_from_cache($relation_name)->ID());
2253 2253
 				}
2254 2254
 			}
2255 2255
 		}
2256
-		return array_keys( get_object_vars( $this ) );
2256
+		return array_keys(get_object_vars($this));
2257 2257
 	}
2258 2258
 
2259 2259
 
Please login to merge, or discard this patch.
Braces   +69 added lines, -61 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@  discard block
 block discarded – undo
1
-<?php if (!defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
1
+<?php if (!defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3
+}
2 4
 do_action( 'AHEE_log', __FILE__, ' FILE LOADED', '' );
3 5
 /**
4 6
  *
@@ -170,7 +172,7 @@  discard block
 block discarded – undo
170 172
 		foreach($this->get_model()->relation_settings() as $relation_name=>$relation_obj){
171 173
 			if($relation_obj instanceof EE_Belongs_To_Relation){
172 174
 				$this->_model_relations[$relation_name] = NULL;
173
-			}else{
175
+			} else{
174 176
 				$this->_model_relations[$relation_name] = array();
175 177
 			}
176 178
 		}
@@ -215,7 +217,7 @@  discard block
 block discarded – undo
215 217
 		if( isset( $this->_props_n_values_provided_in_constructor[ $field_name ] ) &&
216 218
 				$field_settings = $this->get_Model()->field_settings_for( $field_name )){
217 219
 			return $field_settings->prepare_for_get( $this->_props_n_values_provided_in_constructor[ $field_name ] );
218
-		}else{
220
+		} else{
219 221
 			return NULL;
220 222
 		}
221 223
 	}
@@ -264,7 +266,7 @@  discard block
 block discarded – undo
264 266
 					empty( $this->_fields[$field_name] ) ? $this->set( $field_name, time() ) : $this->set( $field_name, $this->_fields[$field_name] );
265 267
 				}
266 268
 
267
-			}else{
269
+			} else{
268 270
 				$this->_fields[$field_name] = $holder_of_value;
269 271
 			}
270 272
 
@@ -292,7 +294,7 @@  discard block
 block discarded – undo
292 294
 			}
293 295
 			//let's unset any cache for this field_name from the $_cached_properties property.
294 296
 			$this->_clear_cached_property( $field_name );
295
-		}else{
297
+		} else{
296 298
 			throw new EE_Error( sprintf( __( "A valid EE_Model_Field_Base could not be found for the given field name: %s", "event_espresso" ), $field_name  ) );
297 299
 		}
298 300
 
@@ -588,8 +590,9 @@  discard block
 block discarded – undo
588 590
 	 * @return void
589 591
 	 */
590 592
 	protected function _clear_cached_property( $property_name ) {
591
-		if ( isset( $this->_cached_properties[ $property_name ] ) )
592
-			unset( $this->_cached_properties[ $property_name ] );
593
+		if ( isset( $this->_cached_properties[ $property_name ] ) ) {
594
+					unset( $this->_cached_properties[ $property_name ] );
595
+		}
593 596
 	}
594 597
 
595 598
 
@@ -629,10 +632,10 @@  discard block
 block discarded – undo
629 632
 		if($clear_all){
630 633
 			$obj_removed = true;
631 634
 			$this->_model_relations[$relationName]  = null;
632
-		}elseif($relationship_to_model instanceof EE_Belongs_To_Relation){
635
+		} elseif($relationship_to_model instanceof EE_Belongs_To_Relation){
633 636
 			$obj_removed = $this->_model_relations[$relationName];
634 637
 			$this->_model_relations[$relationName]  = null;
635
-		}else{
638
+		} else{
636 639
 			if($object_to_remove_or_index_into_array instanceof EE_Base_Class && $object_to_remove_or_index_into_array->ID()){
637 640
 				$index_in_cache = $object_to_remove_or_index_into_array->ID();
638 641
 				if( is_array($this->_model_relations[$relationName]) && ! isset($this->_model_relations[$relationName][$index_in_cache])){
@@ -646,20 +649,20 @@  discard block
 block discarded – undo
646 649
 					}
647 650
 					if($index_found_at){
648 651
 						$index_in_cache = $index_found_at;
649
-					}else{
652
+					} else{
650 653
 						//it wasn't found. huh. well obviously it doesn't need to be removed from teh cache
651 654
 						//if it wasn't in it to begin with. So we're done
652 655
 						return $object_to_remove_or_index_into_array;
653 656
 					}
654 657
 				}
655
-			}elseif($object_to_remove_or_index_into_array instanceof EE_Base_Class){
658
+			} elseif($object_to_remove_or_index_into_array instanceof EE_Base_Class){
656 659
 				//so they provided a model object, but it's not yet saved to the DB... so let's go hunting for it!
657 660
 				foreach($this->get_all_from_cache($relationName) as $index => $potentially_obj_we_want){
658 661
 					if($potentially_obj_we_want == $object_to_remove_or_index_into_array){
659 662
 						$index_in_cache = $index;
660 663
 					}
661 664
 				}
662
-			}else{
665
+			} else{
663 666
 				$index_in_cache = $object_to_remove_or_index_into_array;
664 667
 			}
665 668
 			//supposedly we've found it. But it could just be that the client code
@@ -668,7 +671,7 @@  discard block
 block discarded – undo
668 671
 					isset( $this->_model_relations[$relationName][$index_in_cache])){
669 672
 				$obj_removed = $this->_model_relations[$relationName][$index_in_cache];
670 673
 				unset($this->_model_relations[$relationName][$index_in_cache]);
671
-			}else{
674
+			} else{
672 675
 				//that thing was never cached anyways.
673 676
 				$obj_removed = NULL;
674 677
 			}
@@ -724,7 +727,7 @@  discard block
 block discarded – undo
724 727
 		$cached_array_or_object = isset( $this->_model_relations[$relationName] ) ? $this->_model_relations[$relationName] : null;
725 728
 		if(is_array($cached_array_or_object)){
726 729
 			return array_shift($cached_array_or_object);
727
-		}else{
730
+		} else{
728 731
 			return $cached_array_or_object;
729 732
 		}
730 733
 	}
@@ -743,10 +746,10 @@  discard block
 block discarded – undo
743 746
 		$cached_array_or_object =  isset( $this->_model_relations[$relationName] ) ? $this->_model_relations[$relationName] : array();
744 747
 		if(is_array($cached_array_or_object)){
745 748
 			$objects = $cached_array_or_object;
746
-		}elseif($cached_array_or_object){
749
+		} elseif($cached_array_or_object){
747 750
 			//if the result is not an array, but exists, make it an array
748 751
 			$objects = array($cached_array_or_object);
749
-		}else{
752
+		} else{
750 753
 			//if nothing was found, return an empty array
751 754
 			$objects = array();
752 755
 		}
@@ -761,7 +764,7 @@  discard block
 block discarded – undo
761 764
 				if( $model_object->ID() ){
762 765
 					$model->add_to_entity_map( $model_object );
763 766
 				}
764
-			}else{
767
+			} else{
765 768
 				throw new EE_Error( sprintf( __( 'Error retrieving related model objects. Either $1%s is not a model or $2%s is not a model object', 'event_espresso' ), $relationName, gettype( $model_object )));
766 769
 			}
767 770
 		}
@@ -886,10 +889,10 @@  discard block
 block discarded – undo
886 889
 				if( $field_obj->is_nullable()){
887 890
 					//if the field allows nulls, then let it be null
888 891
 					$field_value = NULL;
889
-				}else{
892
+				} else{
890 893
 					$field_value = $field_obj->get_default_value();
891 894
 				}
892
-			}else{
895
+			} else{
893 896
 				$field_value = $field_obj->prepare_for_set_from_db( $field_value_from_db );
894 897
 			}
895 898
 			$this->_fields[$field_name] = $field_value;
@@ -1009,15 +1012,17 @@  discard block
 block discarded – undo
1009 1012
 			$this->_tm_frmt = $in_tm_frmt;
1010 1013
 		}
1011 1014
 
1012
-		if ( $echo )
1013
-			$field->set_pretty_date_format( $in_dt_frmt );
1014
-		else
1015
-			$field->set_date_format( $in_dt_frmt );
1015
+		if ( $echo ) {
1016
+					$field->set_pretty_date_format( $in_dt_frmt );
1017
+		} else {
1018
+					$field->set_date_format( $in_dt_frmt );
1019
+		}
1016 1020
 
1017
-		if ( $echo )
1018
-			$field->set_pretty_time_format( $in_tm_frmt );
1019
-		else
1020
-			$field->set_time_format( $in_tm_frmt );
1021
+		if ( $echo ) {
1022
+					$field->set_pretty_time_format( $in_tm_frmt );
1023
+		} else {
1024
+					$field->set_time_format( $in_tm_frmt );
1025
+		}
1021 1026
 
1022 1027
 		//set timezone in field object
1023 1028
 		$field->set_timezone( $this->_timezone );
@@ -1240,8 +1245,9 @@  discard block
 block discarded – undo
1240 1245
 		EE_Registry::instance()->load_helper('DTT_Helper');
1241 1246
 		$timezone = EEH_DTT_Helper::get_timezone();
1242 1247
 
1243
-		if ( $timezone == $this->_timezone )
1244
-			return '';
1248
+		if ( $timezone == $this->_timezone ) {
1249
+					return '';
1250
+		}
1245 1251
 
1246 1252
 		$original_timezone = $this->_timezone;
1247 1253
 		$this->set_timezone( $timezone );
@@ -1249,8 +1255,9 @@  discard block
 block discarded – undo
1249 1255
 		$fn = (array) $field_name;
1250 1256
 		$args = array_merge( $fn, (array) $args );
1251 1257
 
1252
-		if ( !method_exists( $this, $callback ) )
1253
-			throw new EE_Error(sprintf( __('The method named "%s" given as the callback param in "display_in_my_timezone" does not exist.  Please check your spelling', 'event_espresso'), $callback ) );
1258
+		if ( !method_exists( $this, $callback ) ) {
1259
+					throw new EE_Error(sprintf( __('The method named "%s" given as the callback param in "display_in_my_timezone" does not exist.  Please check your spelling', 'event_espresso'), $callback ) );
1260
+		}
1254 1261
 		$args = (array) $args;
1255 1262
 		$return =  $prepend . call_user_func_array( array( $this, $callback ), $args ) . $append;
1256 1263
 
@@ -1397,7 +1404,7 @@  discard block
 block discarded – undo
1397 1404
 						$this->_update_cached_related_model_objs_fks();
1398 1405
 					}
1399 1406
 				}
1400
-			}else{//PK is NOT auto-increment
1407
+			} else{//PK is NOT auto-increment
1401 1408
 				//so check if one like it already exists in the db
1402 1409
 				if( $this->get_model()->exists_by_ID( $this->ID() ) ){
1403 1410
 					if( ! $this->in_entity_map() && WP_DEBUG ){
@@ -1412,12 +1419,12 @@  discard block
 block discarded – undo
1412 1419
 						);
1413 1420
 					}
1414 1421
 					$results = $this->get_model()->update_by_ID($save_cols_n_values, $this->ID());
1415
-				}else{
1422
+				} else{
1416 1423
 					$results = $this->get_model()->insert($save_cols_n_values);
1417 1424
 					$this->_update_cached_related_model_objs_fks();
1418 1425
 				}
1419 1426
 			}
1420
-		}else{//there is NO primary key
1427
+		} else{//there is NO primary key
1421 1428
 			$already_in_db = false;
1422 1429
 			foreach($this->get_model()->unique_indexes() as $index){
1423 1430
 				$uniqueness_where_params = array_intersect_key($save_cols_n_values, $index->fields());
@@ -1428,7 +1435,7 @@  discard block
 block discarded – undo
1428 1435
 			if( $already_in_db ){
1429 1436
 				$combined_pk_fields_n_values = array_intersect_key( $save_cols_n_values, $this->get_model()->get_combined_primary_key_fields() );
1430 1437
 				$results = $this->get_model()->update( $save_cols_n_values,$combined_pk_fields_n_values );
1431
-			}else{
1438
+			} else{
1432 1439
 				$results = $this->get_model()->insert( $save_cols_n_values );
1433 1440
 			}
1434 1441
 		}
@@ -1480,7 +1487,7 @@  discard block
 block discarded – undo
1480 1487
 		//make sure this has been saved
1481 1488
 		if( ! $this->ID()){
1482 1489
 			$id = $this->save();
1483
-		}else{
1490
+		} else{
1484 1491
 			$id = $this->ID();
1485 1492
 		}
1486 1493
 		//now save all the NEW cached model objects  (ie they don't exist in the DB)
@@ -1499,7 +1506,7 @@  discard block
 block discarded – undo
1499 1506
 						$this->_add_relation_to($related_model_obj, $relationName);
1500 1507
 						$related_model_obj->save_new_cached_related_model_objs();
1501 1508
 //					}
1502
-				}else{
1509
+				} else{
1503 1510
 					foreach($this->_model_relations[$relationName] as $related_model_obj){
1504 1511
 						//add a relation to that relation type (which saves the appropriate thing in the process)
1505 1512
 						//but ONLY if it DOES NOT exist in the DB
@@ -1558,13 +1565,13 @@  discard block
 block discarded – undo
1558 1565
 
1559 1566
 			if ( array_key_exists( $primary_id_ref, $props_n_values ) && !empty( $props_n_values[$primary_id_ref] ) ) {
1560 1567
 				$existing = self::_get_model( $classname, $timezone )->get_one_by_ID( $props_n_values[$primary_id_ref] );
1561
-			}else{
1568
+			} else{
1562 1569
 				$existing = null;
1563 1570
 			}
1564
-		}elseif( self::_get_model( $classname, $timezone )->has_all_combined_primary_key_fields(  $props_n_values ) ){
1571
+		} elseif( self::_get_model( $classname, $timezone )->has_all_combined_primary_key_fields(  $props_n_values ) ){
1565 1572
 			//no primary key on this model, but there's still a matching item in the DB
1566 1573
 				$existing = self::_get_model($classname, $timezone)->get_one_by_ID( self::_get_model($classname, $timezone)->get_index_primary_key_string( $props_n_values ) );
1567
-		}else{
1574
+		} else{
1568 1575
 			$existing = null;
1569 1576
 		}
1570 1577
 		if ( $existing ) {
@@ -1622,7 +1629,7 @@  discard block
 block discarded – undo
1622 1629
 	private static function _get_model_classname( $model_name = null){
1623 1630
 		if(strpos($model_name,"EE_")===0){
1624 1631
 			$model_classname=str_replace("EE_","EEM_",$model_name);
1625
-		}else{
1632
+		} else{
1626 1633
 			$model_classname = "EEM_".$model_name;
1627 1634
 		}
1628 1635
 		return $model_classname;
@@ -1656,7 +1663,7 @@  discard block
 block discarded – undo
1656 1663
 		//now that we know the name of the variable, use a variable variable to get its value and return its
1657 1664
 		if( $this->get_model()->has_primary_key_field() ) {
1658 1665
 			return $this->_fields[self::_get_primary_key_name( get_class($this) )];
1659
-		}else{
1666
+		} else{
1660 1667
 			return $this->get_model()->get_index_primary_key_string( $this->_fields );
1661 1668
 		}
1662 1669
 	}
@@ -1784,7 +1791,7 @@  discard block
 block discarded – undo
1784 1791
 			//if there are query parameters, forget about caching the related model objects.
1785 1792
 			if( $query_params ){
1786 1793
 				$related_model_objects = $this->get_model()->get_all_related($this, $relationName, $query_params);
1787
-			}else{
1794
+			} else{
1788 1795
 				//did we already cache the result of this query?
1789 1796
 				$cached_results = $this->get_all_from_cache($relationName);
1790 1797
 				if ( ! $cached_results ){
@@ -1794,11 +1801,11 @@  discard block
 block discarded – undo
1794 1801
 					foreach($related_model_objects as $related_model_object){
1795 1802
 						$this->cache($relationName, $related_model_object);
1796 1803
 					}
1797
-				}else{
1804
+				} else{
1798 1805
 					$related_model_objects = $cached_results;
1799 1806
 				}
1800 1807
 			}
1801
-		}else{//this doesn't exist itn eh DB, so just get the related things from the cache
1808
+		} else{//this doesn't exist itn eh DB, so just get the related things from the cache
1802 1809
 			$related_model_objects = $this->get_all_from_cache($relationName);
1803 1810
 		}
1804 1811
 		return $related_model_objects;
@@ -1850,22 +1857,22 @@  discard block
 block discarded – undo
1850 1857
 			//on a relation which should have an array of objects (because the cache might have an array of objects)
1851 1858
 			if ($query_params || ! $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation){
1852 1859
 				$related_model_object =  $this->get_model()->get_first_related($this, $relationName, $query_params);
1853
-			}else{
1860
+			} else{
1854 1861
 				//first, check if we've already cached the result of this query
1855 1862
 				$cached_result = $this->get_one_from_cache($relationName);
1856 1863
 				if ( ! $cached_result ){
1857 1864
 
1858 1865
 					$related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params);
1859 1866
 					$this->cache($relationName,$related_model_object);
1860
-				}else{
1867
+				} else{
1861 1868
 					$related_model_object = $cached_result;
1862 1869
 				}
1863 1870
 			}
1864
-		}else{
1871
+		} else{
1865 1872
 			//this doesn't exist in the Db, but maybe the relation is of type belongs to, and so the related thing might
1866 1873
 			if( $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation){
1867 1874
 				$related_model_object =  $this->get_model()->get_first_related($this, $relationName, $query_params);
1868
-			}else{
1875
+			} else{
1869 1876
 				$related_model_object = null;
1870 1877
 			}
1871 1878
 			//this doesn't exist in the DB and apparently the thing it belongs to doesn't either, just get what's cached on this object
@@ -1891,7 +1898,7 @@  discard block
 block discarded – undo
1891 1898
 	public function delete_related($relationName,$query_params = array()){
1892 1899
 		if($this->ID()){
1893 1900
 			$count =  $this->get_model()->delete_related($this, $relationName, $query_params);
1894
-		}else{
1901
+		} else{
1895 1902
 			$count = count($this->get_all_from_cache($relationName));
1896 1903
 			$this->clear_cache($relationName,NULL,TRUE);
1897 1904
 		}
@@ -1911,7 +1918,7 @@  discard block
 block discarded – undo
1911 1918
 	public function delete_related_permanently($relationName,$query_params = array()){
1912 1919
 		if($this->ID()){
1913 1920
 			$count =  $this->get_model()->delete_related_permanently($this, $relationName, $query_params);
1914
-		}else{
1921
+		} else{
1915 1922
 			$count = count($this->get_all_from_cache($relationName));
1916 1923
 		}
1917 1924
 		$this->clear_cache($relationName,NULL,TRUE);
@@ -1946,8 +1953,9 @@  discard block
 block discarded – undo
1946 1953
 
1947 1954
 		foreach ( (array) $properties as $property_name ) {
1948 1955
 			//first make sure this property exists
1949
-			if ( ! $this->_fields[ $property_name ] )
1950
-				throw new EE_Error( sprintf( __('Trying to retrieve a non-existent property (%s).  Double check the spelling please', 'event_espresso'), $property_name ) );
1956
+			if ( ! $this->_fields[ $property_name ] ) {
1957
+							throw new EE_Error( sprintf( __('Trying to retrieve a non-existent property (%s).  Double check the spelling please', 'event_espresso'), $property_name ) );
1958
+			}
1951 1959
 		}
1952 1960
 
1953 1961
 		return TRUE;
@@ -2027,7 +2035,7 @@  discard block
 block discarded – undo
2027 2035
 		$existing_rows_like_that = EEM_Extra_Meta::instance()->get_all($query_params);
2028 2036
 		if( ! $existing_rows_like_that){
2029 2037
 			return $this->add_extra_meta($meta_key, $meta_value);
2030
-		}else{
2038
+		} else{
2031 2039
 			foreach( $existing_rows_like_that as $existing_row){
2032 2040
 				$existing_row->save( array( 'EXM_value' => $meta_value ) );
2033 2041
 			}
@@ -2093,10 +2101,10 @@  discard block
 block discarded – undo
2093 2101
 			$result = $this->get_first_related('Extra_Meta',array(array('EXM_key'=>$meta_key)));
2094 2102
 			if ( $result instanceof EE_Extra_Meta ){
2095 2103
 				return $result->value();
2096
-			}else{
2104
+			} else{
2097 2105
 				return $default;
2098 2106
 			}
2099
-		}else{
2107
+		} else{
2100 2108
 			$results =  $this->get_many_related('Extra_Meta',array(array('EXM_key'=>$meta_key)));
2101 2109
 			if($results){
2102 2110
 				$values = array();
@@ -2106,7 +2114,7 @@  discard block
 block discarded – undo
2106 2114
 					}
2107 2115
 				}
2108 2116
 				return $values;
2109
-			}else{
2117
+			} else{
2110 2118
 				return $default;
2111 2119
 			}
2112 2120
 		}
@@ -2132,7 +2140,7 @@  discard block
 block discarded – undo
2132 2140
 					$return_array[$extra_meta_obj->key()] = $extra_meta_obj->value();
2133 2141
 				}
2134 2142
 			}
2135
-		}else{
2143
+		} else{
2136 2144
 			$extra_meta_objs = $this->get_many_related('Extra_Meta');
2137 2145
 			foreach($extra_meta_objs as $extra_meta_obj){
2138 2146
 				if ( $extra_meta_obj instanceof EE_Extra_Meta ) {
@@ -2154,7 +2162,7 @@  discard block
 block discarded – undo
2154 2162
 		$field_we_can_use = $this->get_model()->get_a_field_of_type('EE_Text_Field_Base');
2155 2163
 		if($field_we_can_use){
2156 2164
 			return $this->get($field_we_can_use->get_name());
2157
-		}else{
2165
+		} else{
2158 2166
 			$first_few_properties = $this->model_field_array();
2159 2167
 			$first_few_properties = array_slice($first_few_properties,0,3);
2160 2168
 			$name_parts = array();
@@ -2174,7 +2182,7 @@  discard block
 block discarded – undo
2174 2182
 		if( $this->ID() && $this->get_model()->get_from_entity_map( $this->ID() ) === $this ) {
2175 2183
 			//well, if we looked, did we find it in the entity map?
2176 2184
 			return TRUE;
2177
-		}else{
2185
+		} else{
2178 2186
 			return FALSE;
2179 2187
 		}
2180 2188
 	}
@@ -2188,7 +2196,7 @@  discard block
 block discarded – undo
2188 2196
 	public function refresh_from_db(){
2189 2197
 		if( $this->ID() && $this->in_entity_map() ){
2190 2198
 			$this->get_model()->refresh_entity_map_from_db( $this->ID() );
2191
-		}else{
2199
+		} else{
2192 2200
 			//if it doesn't have ID, you shouldn't be asking to refresh it from teh database (because its not in the database)
2193 2201
 			//if it has an ID but it's not in the map, and you're asking me to refresh it
2194 2202
 			//that's kinda dangerous. You should just use what's in the entity map, or add this to the entity map if there's
Please login to merge, or discard this patch.
admin_pages/events/Events_Admin_Page.core.php 1 patch
Spacing   +405 added lines, -405 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
 /**
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 			'espresso_events' => 'edit'
68 68
 			);
69 69
 
70
-		add_action('AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object', array( $this, 'verify_event_edit' ) );
70
+		add_action('AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object', array($this, 'verify_event_edit'));
71 71
 	}
72 72
 
73 73
 	protected function _ajax_hooks() {
@@ -93,20 +93,20 @@  discard block
 block discarded – undo
93 93
 				'edit' => __('Update Event', 'event_espresso'),
94 94
 				'add_category' => __('Save New Category', 'event_espresso'),
95 95
 				'edit_category' => __('Update Category', 'event_espresso'),
96
-				'template_settings' => __( 'Update Settings', 'event_espresso' )
96
+				'template_settings' => __('Update Settings', 'event_espresso')
97 97
 				)
98 98
 		);
99 99
 	}
100 100
 
101 101
 	protected function _set_page_routes() {
102 102
 		//load formatter helper
103
-		EE_Registry::instance()->load_helper( 'Formatter' );
103
+		EE_Registry::instance()->load_helper('Formatter');
104 104
 		//load field generator helper
105
-		EE_Registry::instance()->load_helper( 'Form_Fields' );
105
+		EE_Registry::instance()->load_helper('Form_Fields');
106 106
 
107 107
 		//is there a evt_id in the request?
108
-		$evt_id = ! empty( $this->_req_data['EVT_ID'] ) && ! is_array( $this->_req_data['EVT_ID'] ) ? $this->_req_data['EVT_ID'] : 0;
109
-		$evt_id = ! empty( $this->_req_data['post'] ) ? $this->_req_data['post'] : $evt_id;
108
+		$evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : 0;
109
+		$evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id;
110 110
 
111 111
 
112 112
 		$this->_page_routes = array(
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
 				'help_tour' => array(
321 321
 					'Event_Editor_Help_Tour'
322 322
 					),
323
-				'qtips' => array( 'EE_Event_Editor_Decaf_Tips' ),
323
+				'qtips' => array('EE_Event_Editor_Decaf_Tips'),
324 324
 				'require_nonce' => FALSE
325 325
 			),
326 326
 			'edit' => array(
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
 				'help_tour' => array(
377 377
 					'Event_Edit_Help_Tour'
378 378
 				),
379
-				'qtips' => array( 'EE_Event_Editor_Decaf_Tips' ),
379
+				'qtips' => array('EE_Event_Editor_Decaf_Tips'),
380 380
 				'require_nonce' => FALSE
381 381
 			),
382 382
 			'default_event_settings' => array(
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
 						'filename' => 'events_default_settings_status'
399 399
 					)
400 400
 				),
401
-				'help_tour' => array( 'Event_Default_Settings_Help_Tour'),
401
+				'help_tour' => array('Event_Default_Settings_Help_Tour'),
402 402
 				'require_nonce' => FALSE
403 403
 			),
404 404
 			//template settings
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
 						'filename' => 'general_settings_templates'
415 415
 					)
416 416
 				),
417
-				'help_tour' => array( 'Templates_Help_Tour' ),
417
+				'help_tour' => array('Templates_Help_Tour'),
418 418
 				'require_nonce' => FALSE
419 419
 			),
420 420
 			//event category stuff
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
 					'label' => __('Edit Category', 'event_espresso'),
439 439
 					'order' => 15,
440 440
 					'persistent' => FALSE,
441
-					'url' => isset($this->_req_data['EVT_CAT_ID']) ? add_query_arg(array('EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID'] ), $this->_current_page_view_url )  : $this->_admin_base_url
441
+					'url' => isset($this->_req_data['EVT_CAT_ID']) ? add_query_arg(array('EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID']), $this->_current_page_view_url) : $this->_admin_base_url
442 442
 					),
443 443
 				'help_tabs' => array(
444 444
 					'edit_category_help_tab' => array(
@@ -508,14 +508,14 @@  discard block
 block discarded – undo
508 508
 
509 509
 	public function load_scripts_styles() {
510 510
 
511
-		wp_register_style('events-admin-css', EVENTS_ASSETS_URL . 'events-admin-page.css', array(), EVENT_ESPRESSO_VERSION);
512
-		wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION );
511
+		wp_register_style('events-admin-css', EVENTS_ASSETS_URL.'events-admin-page.css', array(), EVENT_ESPRESSO_VERSION);
512
+		wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL.'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION);
513 513
 		wp_enqueue_style('events-admin-css');
514 514
 		wp_enqueue_style('ee-cat-admin');
515 515
 		//todo note: we also need to load_scripts_styles per view (i.e. default/view_report/event_details
516 516
 		//registers for all views
517 517
 		//scripts
518
-		wp_register_script('event_editor_js', EVENTS_ASSETS_URL . 'event_editor.js', array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'), EVENT_ESPRESSO_VERSION, TRUE);
518
+		wp_register_script('event_editor_js', EVENTS_ASSETS_URL.'event_editor.js', array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'), EVENT_ESPRESSO_VERSION, TRUE);
519 519
 	}
520 520
 
521 521
 	/**
@@ -533,11 +533,11 @@  discard block
 block discarded – undo
533 533
 	public function load_scripts_styles_edit() {
534 534
 		//styles
535 535
 		wp_enqueue_style('espresso-ui-theme');
536
-		wp_register_style('event-editor-css', EVENTS_ASSETS_URL . 'event-editor.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION );
536
+		wp_register_style('event-editor-css', EVENTS_ASSETS_URL.'event-editor.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION);
537 537
 		wp_enqueue_style('event-editor-css');
538 538
 
539 539
 		//scripts
540
-		wp_register_script('event-datetime-metabox', EVENTS_ASSETS_URL . 'event-datetime-metabox.js', array('event_editor_js', 'ee-datepicker'), EVENT_ESPRESSO_VERSION );
540
+		wp_register_script('event-datetime-metabox', EVENTS_ASSETS_URL.'event-datetime-metabox.js', array('event_editor_js', 'ee-datepicker'), EVENT_ESPRESSO_VERSION);
541 541
 		wp_enqueue_script('event-datetime-metabox');
542 542
 
543 543
 	}
@@ -572,7 +572,7 @@  discard block
 block discarded – undo
572 572
 
573 573
 
574 574
 	public function admin_init() {
575
-		EE_Registry::$i18n_js_strings[ 'image_confirm' ] = __( 'Do you really want to delete this image? Please remember to update your event to complete the removal.', 'event_espresso' );
575
+		EE_Registry::$i18n_js_strings['image_confirm'] = __('Do you really want to delete this image? Please remember to update your event to complete the removal.', 'event_espresso');
576 576
 	}
577 577
 
578 578
 
@@ -593,45 +593,45 @@  discard block
 block discarded – undo
593 593
 	 */
594 594
 	public function verify_event_edit($event = NULL) {
595 595
 		// no event?
596
-		if ( empty( $event )) {
596
+		if (empty($event)) {
597 597
 			// set event
598 598
 			$event = $this->_cpt_model_obj;
599 599
 		}
600 600
 		// STILL no event?
601
-		if ( empty ( $event )) {
601
+		if (empty ($event)) {
602 602
 			return;
603 603
 		}
604 604
 		// first check if event is active.
605
-		if ( $event->is_expired() || $event->is_inactive() || $event->status() == EEM_Event::cancelled || $event->status() == EEM_Event::postponed ) {
605
+		if ($event->is_expired() || $event->is_inactive() || $event->status() == EEM_Event::cancelled || $event->status() == EEM_Event::postponed) {
606 606
 			return;
607 607
 		}
608 608
 		$orig_status = $event->status();
609 609
 		//made it here so it IS active... next check that any of the tickets are sold.
610
-		if ( $event->is_sold_out( true ) ) {
611
-			if ( $event->status() !== $orig_status && $orig_status !== EEM_Event::sold_out  ) {
610
+		if ($event->is_sold_out(true)) {
611
+			if ($event->status() !== $orig_status && $orig_status !== EEM_Event::sold_out) {
612 612
 				EE_Error::add_attention(
613 613
 					sprintf(
614
-						__( 'Please note that the Event Status has automatically been changed to %s because there are no more spaces available for this event.  However, this change is not permanent until you update the event.  You can change the status back to something else before updating if you wish.', 'event_espresso' ),
615
-						EEH_Template::pretty_status( EEM_Event::sold_out, FALSE, 'sentence' )
614
+						__('Please note that the Event Status has automatically been changed to %s because there are no more spaces available for this event.  However, this change is not permanent until you update the event.  You can change the status back to something else before updating if you wish.', 'event_espresso'),
615
+						EEH_Template::pretty_status(EEM_Event::sold_out, FALSE, 'sentence')
616 616
 					)
617 617
 				);
618 618
 			}
619 619
 			return;
620
-		} else if ( $orig_status === EEM_Event::sold_out ) {
620
+		} else if ($orig_status === EEM_Event::sold_out) {
621 621
 			EE_Error::add_attention(
622 622
 				sprintf(
623
-					__( 'Please note that the Event Status has automatically been changed to %s because more spaces have become available for this event, most likely due to abandoned transactions freeing up reserved tickets.  However, this change is not permanent until you update the event. If you wish, you can change the status back to something else before updating.',
624
-						'event_espresso' ),
625
-					EEH_Template::pretty_status( $event->status(), false, 'sentence' )
623
+					__('Please note that the Event Status has automatically been changed to %s because more spaces have become available for this event, most likely due to abandoned transactions freeing up reserved tickets.  However, this change is not permanent until you update the event. If you wish, you can change the status back to something else before updating.',
624
+						'event_espresso'),
625
+					EEH_Template::pretty_status($event->status(), false, 'sentence')
626 626
 				)
627 627
 			);
628 628
 		}
629 629
 		//now we need to determine if the event has any tickets on sale.  If not then we dont' show the error
630
-		if ( ! $event->tickets_on_sale() ) {
630
+		if ( ! $event->tickets_on_sale()) {
631 631
 			return;
632 632
 		}
633 633
 		//made it here so show warning
634
-		EE_Error::add_attention( $this->_edit_event_warning() );
634
+		EE_Error::add_attention($this->_edit_event_warning());
635 635
 	}
636 636
 
637 637
 
@@ -671,7 +671,7 @@  discard block
 block discarded – undo
671 671
 			),
672 672
 		);
673 673
 
674
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_events', 'espresso_events_trash_events' ) ) {
674
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_events', 'espresso_events_trash_events')) {
675 675
 			$this->_views['trash'] = array(
676 676
 				'slug' => 'trash',
677 677
 				'label' => __('Trash', 'event_espresso'),
@@ -701,39 +701,39 @@  discard block
 block discarded – undo
701 701
 				'desc' => __('View Registrations for Event', 'event_espresso')
702 702
 			)
703 703
 		);
704
-		$items  = apply_filters( 'FHEE__Events_Admin_Page___event_legend_items__items', $items );
704
+		$items = apply_filters('FHEE__Events_Admin_Page___event_legend_items__items', $items);
705 705
 		$statuses = array(
706 706
 			'sold_out_status' => array(
707
-				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::sold_out,
708
-				'desc' => EEH_Template::pretty_status( EE_Datetime::sold_out, FALSE, 'sentence' )
707
+				'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::sold_out,
708
+				'desc' => EEH_Template::pretty_status(EE_Datetime::sold_out, FALSE, 'sentence')
709 709
 			),
710 710
 			'active_status' => array(
711
-				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::active,
712
-				'desc' => EEH_Template::pretty_status( EE_Datetime::active, FALSE, 'sentence' )
711
+				'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::active,
712
+				'desc' => EEH_Template::pretty_status(EE_Datetime::active, FALSE, 'sentence')
713 713
 			),
714 714
 			'upcoming_status' => array(
715
-				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::upcoming,
716
-				'desc' => EEH_Template::pretty_status( EE_Datetime::upcoming, FALSE, 'sentence' )
715
+				'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::upcoming,
716
+				'desc' => EEH_Template::pretty_status(EE_Datetime::upcoming, FALSE, 'sentence')
717 717
 			),
718 718
 			'postponed_status' => array(
719
-				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::postponed,
720
-				'desc' => EEH_Template::pretty_status( EE_Datetime::postponed, FALSE, 'sentence' )
719
+				'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::postponed,
720
+				'desc' => EEH_Template::pretty_status(EE_Datetime::postponed, FALSE, 'sentence')
721 721
 			),
722 722
 			'cancelled_status' => array(
723
-				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::cancelled,
724
-				'desc' => EEH_Template::pretty_status( EE_Datetime::cancelled, FALSE, 'sentence' )
723
+				'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::cancelled,
724
+				'desc' => EEH_Template::pretty_status(EE_Datetime::cancelled, FALSE, 'sentence')
725 725
 			),
726 726
 			'expired_status' => array(
727
-				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::expired,
728
-				'desc' => EEH_Template::pretty_status( EE_Datetime::expired, FALSE, 'sentence' )
727
+				'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::expired,
728
+				'desc' => EEH_Template::pretty_status(EE_Datetime::expired, FALSE, 'sentence')
729 729
 			),
730 730
 			'inactive_status' => array(
731
-				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::inactive,
732
-				'desc' => EEH_Template::pretty_status( EE_Datetime::inactive, FALSE, 'sentence' )
731
+				'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::inactive,
732
+				'desc' => EEH_Template::pretty_status(EE_Datetime::inactive, FALSE, 'sentence')
733 733
 			)
734 734
 		);
735
-		$statuses = apply_filters( 'FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses );
736
-		return array_merge( $items, $statuses );
735
+		$statuses = apply_filters('FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses);
736
+		return array_merge($items, $statuses);
737 737
 	}
738 738
 
739 739
 
@@ -745,8 +745,8 @@  discard block
 block discarded – undo
745 745
 	 * @return EEM_Event
746 746
 	 */
747 747
 	private function _event_model() {
748
-		if ( ! $this->_event_model instanceof EEM_Event ) {
749
-			$this->_event_model = EE_Registry::instance()->load_model( 'Event' );
748
+		if ( ! $this->_event_model instanceof EEM_Event) {
749
+			$this->_event_model = EE_Registry::instance()->load_model('Event');
750 750
 		}
751 751
 		return $this->_event_model;
752 752
 	}
@@ -765,12 +765,12 @@  discard block
 block discarded – undo
765 765
 	 * @param  string $new_slug  what the slug is
766 766
 	 * @return string            The new html string for the permalink area
767 767
 	 */
768
-	public function extra_permalink_field_buttons( $return, $id, $new_title, $new_slug ) {
768
+	public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug) {
769 769
 		//make sure this is only when editing
770
-		if ( !empty( $id ) ) {
771
-			$post = get_post( $id );
772
-			$return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#"  tabindex="-1">' . __('Shortcode', 'event_espresso') . '</a> ';
773
-			$return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id=\'' . $post->ID . '\']"">';
770
+		if ( ! empty($id)) {
771
+			$post = get_post($id);
772
+			$return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#"  tabindex="-1">'.__('Shortcode', 'event_espresso').'</a> ';
773
+			$return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id=\''.$post->ID.'\']"">';
774 774
 		}
775 775
 		return $return;
776 776
 	}
@@ -786,8 +786,8 @@  discard block
 block discarded – undo
786 786
 	 * @return string html for generated table
787 787
 	 */
788 788
 	protected function _events_overview_list_table() {
789
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
790
-		$this->_template_args['after_list_table'] = EEH_Template::get_button_or_link( get_post_type_archive_link('espresso_events'), __("View Event Archive Page", "event_espresso"), 'button' ) .
789
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
790
+		$this->_template_args['after_list_table'] = EEH_Template::get_button_or_link(get_post_type_archive_link('espresso_events'), __("View Event Archive Page", "event_espresso"), 'button').
791 791
 		$this->_display_legend($this->_event_legend_items());
792 792
 		$this->_admin_page_title .= $this->get_action_link_or_button('create_new', 'add', array(), 'add-new-h2');
793 793
 		$this->display_admin_list_table_page_with_no_sidebar();
@@ -805,51 +805,51 @@  discard block
 block discarded – undo
805 805
 
806 806
 
807 807
 
808
-	protected function _insert_update_cpt_item( $post_id, $post ) {
808
+	protected function _insert_update_cpt_item($post_id, $post) {
809 809
 
810
-		if ( $post instanceof WP_Post && $post->post_type !== 'espresso_events' ) {
810
+		if ($post instanceof WP_Post && $post->post_type !== 'espresso_events') {
811 811
 			//getout we're not processing an event save.
812 812
 			return;
813 813
 		}
814 814
 
815 815
 		$event_values = array(
816
-			'EVT_display_desc' => !empty( $this->_req_data['display_desc'] ) ? 1 : 0,
817
-			'EVT_display_ticket_selector' => !empty( $this->_req_data['display_ticket_selector'] ) ? 1 : 0,
816
+			'EVT_display_desc' => ! empty($this->_req_data['display_desc']) ? 1 : 0,
817
+			'EVT_display_ticket_selector' => ! empty($this->_req_data['display_ticket_selector']) ? 1 : 0,
818 818
 			'EVT_additional_limit' => min(
819
-					apply_filters( 'FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255 ),
820
-					!empty( $this->_req_data['additional_limit'] ) ? $this->_req_data['additional_limit'] : NULL ),
821
-			'EVT_default_registration_status' => !empty( $this->_req_data['EVT_default_registration_status'] ) ? $this->_req_data['EVT_default_registration_status'] : EE_Registry::instance()->CFG->registration->default_STS_ID,
822
-			'EVT_member_only' => !empty( $this->_req_data['member_only'] ) ? 1 : 0,
823
-			'EVT_allow_overflow' => !empty( $this->_req_data['EVT_allow_overflow'] ) ? 1 : 0,
824
-			'EVT_timezone_string' => !empty( $this->_req_data['timezone_string'] ) ? $this->_req_data['timezone_string'] : NULL,
825
-			'EVT_external_URL' => !empty( $this->_req_data['externalURL'] ) ? $this->_req_data['externalURL'] : NULL,
826
-			'EVT_phone' => !empty( $this->_req_data['event_phone'] ) ? $this->_req_data['event_phone'] : NULL
819
+					apply_filters('FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255),
820
+					! empty($this->_req_data['additional_limit']) ? $this->_req_data['additional_limit'] : NULL ),
821
+			'EVT_default_registration_status' => ! empty($this->_req_data['EVT_default_registration_status']) ? $this->_req_data['EVT_default_registration_status'] : EE_Registry::instance()->CFG->registration->default_STS_ID,
822
+			'EVT_member_only' => ! empty($this->_req_data['member_only']) ? 1 : 0,
823
+			'EVT_allow_overflow' => ! empty($this->_req_data['EVT_allow_overflow']) ? 1 : 0,
824
+			'EVT_timezone_string' => ! empty($this->_req_data['timezone_string']) ? $this->_req_data['timezone_string'] : NULL,
825
+			'EVT_external_URL' => ! empty($this->_req_data['externalURL']) ? $this->_req_data['externalURL'] : NULL,
826
+			'EVT_phone' => ! empty($this->_req_data['event_phone']) ? $this->_req_data['event_phone'] : NULL
827 827
 			);
828 828
 
829 829
 		//update event
830
-		$success = $this->_event_model()->update_by_ID( $event_values, $post_id );
830
+		$success = $this->_event_model()->update_by_ID($event_values, $post_id);
831 831
 
832 832
 
833 833
 		//get event_object for other metaboxes... though it would seem to make sense to just use $this->_event_model()->get_one_by_ID( $post_id ).. i have to setup where conditions to override the filters in the model that filter out autodraft and inherit statuses so we GET the inherit id!
834
-		$get_one_where = array( $this->_event_model()->primary_key_name() => $post_id, 'status' => $post->post_status );
835
-		$event = $this->_event_model()->get_one( array($get_one_where) );
834
+		$get_one_where = array($this->_event_model()->primary_key_name() => $post_id, 'status' => $post->post_status);
835
+		$event = $this->_event_model()->get_one(array($get_one_where));
836 836
 
837 837
 
838 838
 		//the following are default callbacks for event attachment updates that can be overridden by caffeinated functionality and/or addons.
839
-		$event_update_callbacks = apply_filters( 'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', array( array($this, '_default_venue_update' ), array( $this, '_default_tickets_update') ) );
839
+		$event_update_callbacks = apply_filters('FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', array(array($this, '_default_venue_update'), array($this, '_default_tickets_update')));
840 840
 
841 841
 		$att_success = TRUE;
842 842
 
843
-		foreach ( $event_update_callbacks as $e_callback ) {
844
-			$_succ = call_user_func_array( $e_callback, array( $event,  $this->_req_data ) );
845
-			$att_success = !$att_success ? $att_success : $_succ; //if ANY of these updates fail then we want the appropriate global error message
843
+		foreach ($event_update_callbacks as $e_callback) {
844
+			$_succ = call_user_func_array($e_callback, array($event, $this->_req_data));
845
+			$att_success = ! $att_success ? $att_success : $_succ; //if ANY of these updates fail then we want the appropriate global error message
846 846
 		}
847 847
 
848 848
 		//any errors?
849
-		if ( $success && FALSE === $att_success ) {
850
-			EE_Error::add_error( __('Event Details saved successfully but something went wrong with saving attachments.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
851
-		} else if ( $success === FALSE ) {
852
-			EE_Error::add_error( __('Event Details did not save successfully.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
849
+		if ($success && FALSE === $att_success) {
850
+			EE_Error::add_error(__('Event Details saved successfully but something went wrong with saving attachments.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
851
+		} else if ($success === FALSE) {
852
+			EE_Error::add_error(__('Event Details did not save successfully.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
853 853
 		}
854 854
 	}
855 855
 
@@ -859,14 +859,14 @@  discard block
 block discarded – undo
859 859
 	/**
860 860
 	 * @see parent::restore_item()
861 861
 	 */
862
-	protected function _restore_cpt_item( $post_id, $revision_id ) {
862
+	protected function _restore_cpt_item($post_id, $revision_id) {
863 863
 		//copy existing event meta to new post
864 864
 		$post_evt = $this->_event_model()->get_one_by_ID($post_id);
865
-		if ( $post_evt instanceof EE_Event ) {
865
+		if ($post_evt instanceof EE_Event) {
866 866
 			//meta revision restore
867
-			$post_evt->restore_revision( $revision_id );
867
+			$post_evt->restore_revision($revision_id);
868 868
 			//related objs restore
869
-			$post_evt->restore_revision( $revision_id, array( 'Venue', 'Datetime', 'Price' ) );
869
+			$post_evt->restore_revision($revision_id, array('Venue', 'Datetime', 'Price'));
870 870
 		}
871 871
 	}
872 872
 
@@ -879,52 +879,52 @@  discard block
 block discarded – undo
879 879
 	 * @param  array  $data   The request data from the form
880 880
 	 * @return bool           Success or fail.
881 881
 	 */
882
-	protected function _default_venue_update( $evtobj, $data ) {
883
-		require_once( EE_MODELS . 'EEM_Venue.model.php' );
882
+	protected function _default_venue_update($evtobj, $data) {
883
+		require_once(EE_MODELS.'EEM_Venue.model.php');
884 884
 		$venue_model = EE_Registry::instance()->load_model('Venue');
885 885
 		$rows_affected = NULL;
886
-		$venue_id = !empty( $data['venue_id'] ) ? $data['venue_id'] : NULL;
886
+		$venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : NULL;
887 887
 
888 888
 		// very important.  If we don't have a venue name...
889 889
 		// then we'll get out because not necessary to create empty venue
890
-		if ( empty( $data['venue_title'] ) ) {
890
+		if (empty($data['venue_title'])) {
891 891
 			return false;
892 892
 		}
893 893
 
894 894
 		$venue_array = array(
895 895
 				'VNU_wp_user' => $evtobj->get('EVT_wp_user'),
896
-				'VNU_name' => !empty( $data['venue_title'] ) ? $data['venue_title'] : NULL,
897
-				'VNU_desc' => !empty( $data['venue_description'] ) ? $data['venue_description'] : NULL,
898
-				'VNU_identifier' => !empty( $data['venue_identifier'] ) ? $data['venue_identifier'] : NULL,
899
-				'VNU_short_desc' => !empty( $data['venue_short_description'] ) ? $data['venue_short_description'] : NULL,
900
-				'VNU_address' => !empty( $data['address'] ) ? $data['address'] : NULL,
901
-				'VNU_address2' => !empty( $data['address2'] ) ? $data['address2'] : NULL,
902
-				'VNU_city' => !empty( $data['city'] ) ? $data['city'] : NULL,
903
-				'STA_ID' => !empty( $data['state'] ) ? $data['state'] : NULL,
904
-				'CNT_ISO' => !empty( $data['countries'] ) ? $data['countries'] : NULL,
905
-				'VNU_zip' => !empty( $data['zip'] ) ? $data['zip'] : NULL,
906
-				'VNU_phone' => !empty( $data['venue_phone'] ) ? $data['venue_phone'] : NULL,
907
-				'VNU_capacity' => !empty( $data['venue_capacity'] ) ? $data['venue_capacity'] : NULL,
908
-				'VNU_url' => !empty($data['venue_url'] ) ? $data['venue_url'] : NULL,
909
-				'VNU_virtual_phone' => !empty($data['virtual_phone']) ? $data['virtual_phone'] : NULL,
910
-				'VNU_virtual_url' => !empty( $data['virtual_url'] ) ? $data['virtual_url'] : NULL,
911
-				'VNU_enable_for_gmap' => isset( $data['enable_for_gmap'] ) ? 1 : 0,
896
+				'VNU_name' => ! empty($data['venue_title']) ? $data['venue_title'] : NULL,
897
+				'VNU_desc' => ! empty($data['venue_description']) ? $data['venue_description'] : NULL,
898
+				'VNU_identifier' => ! empty($data['venue_identifier']) ? $data['venue_identifier'] : NULL,
899
+				'VNU_short_desc' => ! empty($data['venue_short_description']) ? $data['venue_short_description'] : NULL,
900
+				'VNU_address' => ! empty($data['address']) ? $data['address'] : NULL,
901
+				'VNU_address2' => ! empty($data['address2']) ? $data['address2'] : NULL,
902
+				'VNU_city' => ! empty($data['city']) ? $data['city'] : NULL,
903
+				'STA_ID' => ! empty($data['state']) ? $data['state'] : NULL,
904
+				'CNT_ISO' => ! empty($data['countries']) ? $data['countries'] : NULL,
905
+				'VNU_zip' => ! empty($data['zip']) ? $data['zip'] : NULL,
906
+				'VNU_phone' => ! empty($data['venue_phone']) ? $data['venue_phone'] : NULL,
907
+				'VNU_capacity' => ! empty($data['venue_capacity']) ? $data['venue_capacity'] : NULL,
908
+				'VNU_url' => ! empty($data['venue_url']) ? $data['venue_url'] : NULL,
909
+				'VNU_virtual_phone' => ! empty($data['virtual_phone']) ? $data['virtual_phone'] : NULL,
910
+				'VNU_virtual_url' => ! empty($data['virtual_url']) ? $data['virtual_url'] : NULL,
911
+				'VNU_enable_for_gmap' => isset($data['enable_for_gmap']) ? 1 : 0,
912 912
 				'status' => 'publish'
913 913
 			);
914 914
 
915 915
 
916 916
 		//if we've got the venue_id then we're just updating the existing venue so let's do that and then get out.
917
-		if ( !empty( $venue_id ) ) {
918
-			$update_where = array( $venue_model->primary_key_name() => $venue_id );
919
-			$rows_affected = $venue_model->update( $venue_array, array( $update_where ) );
917
+		if ( ! empty($venue_id)) {
918
+			$update_where = array($venue_model->primary_key_name() => $venue_id);
919
+			$rows_affected = $venue_model->update($venue_array, array($update_where));
920 920
 			//we've gotta make sure that the venue is always attached to a revision.. add_relation_to should take care of making sure that the relation is already present.
921
-			$evtobj->_add_relation_to( $venue_id, 'Venue' );
921
+			$evtobj->_add_relation_to($venue_id, 'Venue');
922 922
 			return $rows_affected > 0 ? TRUE : FALSE;
923 923
 		} else {
924 924
 			//we insert the venue
925
-			$venue_id = $venue_model->insert( $venue_array );
926
-			$evtobj->_add_relation_to( $venue_id, 'Venue' );
927
-			return !empty( $venue_id ) ? TRUE : FALSE;
925
+			$venue_id = $venue_model->insert($venue_array);
926
+			$evtobj->_add_relation_to($venue_id, 'Venue');
927
+			return ! empty($venue_id) ? TRUE : FALSE;
928 928
 		}
929 929
 		//when we have the ancestor come in it's already been handled by the revision save.
930 930
 	}
@@ -938,55 +938,55 @@  discard block
 block discarded – undo
938 938
 	 * @param  array    $data   The request data from the form
939 939
 	 * @return bool             success or fail
940 940
 	 */
941
-	protected function _default_tickets_update( EE_Event $evtobj, $data ) {
941
+	protected function _default_tickets_update(EE_Event $evtobj, $data) {
942 942
 		$success = true;
943 943
 		$saved_dtt = null;
944 944
 		$saved_tickets = array();
945
-		$incoming_date_formats = array( 'Y-m-d', 'h:i a' );
945
+		$incoming_date_formats = array('Y-m-d', 'h:i a');
946 946
 
947
-		foreach ( $data['edit_event_datetimes'] as $row => $dtt ) {
947
+		foreach ($data['edit_event_datetimes'] as $row => $dtt) {
948 948
 			//trim all values to ensure any excess whitespace is removed.
949
-			$dtt =  array_map( 'trim', $dtt );
950
-			$dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty( $dtt['DTT_EVT_end'] ) ? $dtt['DTT_EVT_end'] : $dtt['DTT_EVT_start'];
949
+			$dtt = array_map('trim', $dtt);
950
+			$dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty($dtt['DTT_EVT_end']) ? $dtt['DTT_EVT_end'] : $dtt['DTT_EVT_start'];
951 951
 			$datetime_values = array(
952
-				'DTT_ID' 		=> ! empty( $dtt['DTT_ID'] ) ? $dtt['DTT_ID'] : NULL,
952
+				'DTT_ID' 		=> ! empty($dtt['DTT_ID']) ? $dtt['DTT_ID'] : NULL,
953 953
 				'DTT_EVT_start' => $dtt['DTT_EVT_start'],
954 954
 				'DTT_EVT_end' 	=> $dtt['DTT_EVT_end'],
955
-				'DTT_reg_limit' => empty( $dtt['DTT_reg_limit'] ) ? EE_INF : $dtt['DTT_reg_limit'],
955
+				'DTT_reg_limit' => empty($dtt['DTT_reg_limit']) ? EE_INF : $dtt['DTT_reg_limit'],
956 956
 				'DTT_order' 	=> $row,
957 957
 			);
958 958
 
959 959
 			//if we have an id then let's get existing object first and then set the new values.  Otherwise we instantiate a new object for save.
960 960
 
961
-			if ( !empty( $dtt['DTT_ID'] ) ) {
962
-				$DTM = EE_Registry::instance()->load_model('Datetime', array( $evtobj->get_timezone() ) )->get_one_by_ID($dtt['DTT_ID'] );
963
-				$DTM->set_date_format( $incoming_date_formats[0] );
964
-				$DTM->set_time_format( $incoming_date_formats[1] );
965
-				foreach ( $datetime_values as $field => $value ) {
966
-					$DTM->set( $field, $value );
961
+			if ( ! empty($dtt['DTT_ID'])) {
962
+				$DTM = EE_Registry::instance()->load_model('Datetime', array($evtobj->get_timezone()))->get_one_by_ID($dtt['DTT_ID']);
963
+				$DTM->set_date_format($incoming_date_formats[0]);
964
+				$DTM->set_time_format($incoming_date_formats[1]);
965
+				foreach ($datetime_values as $field => $value) {
966
+					$DTM->set($field, $value);
967 967
 				}
968 968
 
969 969
 				//make sure the $dtt_id here is saved just in case after the add_relation_to() the autosave replaces it.  We need to do this so we dont' TRASH the parent DTT.
970 970
 				$saved_dtts[$DTM->ID()] = $DTM;
971 971
 			} else {
972
-				$DTM = EE_Registry::instance()->load_class('Datetime', array( $datetime_values ), FALSE, FALSE );
973
-				$DTM->set_date_format( $incoming_date_formats[0] );
974
-				$DTM->set_time_format( $incoming_date_formats[1] );
975
-				$DTM->set_timezone( $evtobj->get_timezone() );
976
-				foreach ( $datetime_values as $field => $value ) {
977
-					$DTM->set( $field, $value );
972
+				$DTM = EE_Registry::instance()->load_class('Datetime', array($datetime_values), FALSE, FALSE);
973
+				$DTM->set_date_format($incoming_date_formats[0]);
974
+				$DTM->set_time_format($incoming_date_formats[1]);
975
+				$DTM->set_timezone($evtobj->get_timezone());
976
+				foreach ($datetime_values as $field => $value) {
977
+					$DTM->set($field, $value);
978 978
 				}
979 979
 			}
980 980
 			$DTM->save();
981 981
 
982
-			$DTT = $evtobj->_add_relation_to( $DTM, 'Datetime' );
982
+			$DTT = $evtobj->_add_relation_to($DTM, 'Datetime');
983 983
 
984 984
 			//load DTT helper
985 985
 			EE_Registry::instance()->load_helper('DTT_Helper');
986 986
 
987 987
 			//before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date.
988
-			if( $DTT->get_raw('DTT_EVT_start') > $DTT->get_raw('DTT_EVT_end') ) {
989
-				$DTT->set('DTT_EVT_end', $DTT->get('DTT_EVT_start') );
988
+			if ($DTT->get_raw('DTT_EVT_start') > $DTT->get_raw('DTT_EVT_end')) {
989
+				$DTT->set('DTT_EVT_end', $DTT->get('DTT_EVT_start'));
990 990
 				$DTT = EEH_DTT_Helper::date_time_add($DTT, 'DTT_EVT_end', 'days');
991 991
 				$DTT->save();
992 992
 			}
@@ -994,45 +994,45 @@  discard block
 block discarded – undo
994 994
 			//now we got to make sure we add the new DTT_ID to the $saved_dtts array  because it is possible there was a new one created for the autosave.
995 995
 			$saved_dtt = $DTT;
996 996
 
997
-			$success = !$success ? $success : $DTT; //if ANY of these updates fail then we want the appropriate global error message. //todod this is actually sucky we need a better error message but this is what it is for now.
997
+			$success = ! $success ? $success : $DTT; //if ANY of these updates fail then we want the appropriate global error message. //todod this is actually sucky we need a better error message but this is what it is for now.
998 998
 		}
999 999
 
1000 1000
 		//no dtts get deleted so we don't do any of that logic here.
1001 1001
 		//update tickets next
1002
-		$old_tickets = isset( $data['ticket_IDs'] ) ? explode(',', $data['ticket_IDs'] ) : array();
1003
-		foreach ( $data['edit_tickets'] as $row => $tkt ) {
1004
-			$incoming_date_formats = array( 'Y-m-d', 'h:i a' );
1002
+		$old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array();
1003
+		foreach ($data['edit_tickets'] as $row => $tkt) {
1004
+			$incoming_date_formats = array('Y-m-d', 'h:i a');
1005 1005
 			$update_prices = false;
1006
-			$ticket_price = isset( $data['edit_prices'][$row][1]['PRC_amount'] ) ? $data['edit_prices'][$row][1]['PRC_amount'] : 0;
1006
+			$ticket_price = isset($data['edit_prices'][$row][1]['PRC_amount']) ? $data['edit_prices'][$row][1]['PRC_amount'] : 0;
1007 1007
 
1008 1008
 			// trim inputs to ensure any excess whitespace is removed.
1009
-			$tkt = array_map( 'trim', $tkt );
1009
+			$tkt = array_map('trim', $tkt);
1010 1010
 
1011
-			if ( empty( $tkt['TKT_start_date'] ) ) {
1011
+			if (empty($tkt['TKT_start_date'])) {
1012 1012
 				//let's use now in the set timezone.
1013
-				$now = new DateTime( 'now', new DateTimeZone( $evtobj->get_timezone() ) );
1014
-				$tkt['TKT_start_date'] = $now->format( $incoming_date_formats[0] . ' ' . $incoming_date_formats[1] );
1013
+				$now = new DateTime('now', new DateTimeZone($evtobj->get_timezone()));
1014
+				$tkt['TKT_start_date'] = $now->format($incoming_date_formats[0].' '.$incoming_date_formats[1]);
1015 1015
 			}
1016 1016
 
1017
-			if ( empty( $tkt['TKT_end_date'] ) ) {
1017
+			if (empty($tkt['TKT_end_date'])) {
1018 1018
 				//use the start date of the first datetime
1019 1019
 				$dtt = $evtobj->first_datetime();
1020
-				$tkt['TKT_end_date'] = $dtt->start_date_and_time( $incoming_date_formats[0], $incoming_date_formats[1] );
1020
+				$tkt['TKT_end_date'] = $dtt->start_date_and_time($incoming_date_formats[0], $incoming_date_formats[1]);
1021 1021
 			}
1022 1022
 
1023 1023
 			$TKT_values = array(
1024
-				'TKT_ID' 			=> !empty( $tkt['TKT_ID'] ) ? $tkt['TKT_ID'] : NULL,
1025
-				'TTM_ID' 			=> !empty( $tkt['TTM_ID'] ) ? $tkt['TTM_ID'] : 0,
1026
-				'TKT_name' 			=> !empty( $tkt['TKT_name'] ) ? $tkt['TKT_name'] : '',
1027
-				'TKT_description' 	=> !empty( $tkt['TKT_description'] ) ? $tkt['TKT_description'] : '',
1024
+				'TKT_ID' 			=> ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : NULL,
1025
+				'TTM_ID' 			=> ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0,
1026
+				'TKT_name' 			=> ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '',
1027
+				'TKT_description' 	=> ! empty($tkt['TKT_description']) ? $tkt['TKT_description'] : '',
1028 1028
 				'TKT_start_date' 	=> $tkt['TKT_start_date'],
1029 1029
 				'TKT_end_date' 		=> $tkt['TKT_end_date'],
1030
-				'TKT_qty' 			=> ! isset( $tkt[ 'TKT_qty' ] ) || $tkt[ 'TKT_qty' ] === '' ? EE_INF : $tkt['TKT_qty'],
1031
-				'TKT_uses' 			=> ! isset( $tkt[ 'TKT_uses' ] ) || $tkt[ 'TKT_uses' ] === '' ? EE_INF : $tkt[ 'TKT_uses' ],
1032
-				'TKT_min' 			=> empty( $tkt['TKT_min'] ) ? 0 : $tkt['TKT_min'],
1033
-				'TKT_max' 			=> empty( $tkt['TKT_max'] ) ? EE_INF : $tkt['TKT_max'],
1030
+				'TKT_qty' 			=> ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'],
1031
+				'TKT_uses' 			=> ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'],
1032
+				'TKT_min' 			=> empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'],
1033
+				'TKT_max' 			=> empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'],
1034 1034
 				'TKT_row' 			=> $row,
1035
-				'TKT_order' 		=> isset( $tkt['TKT_order'] ) ? $tkt['TKT_order'] : $row,
1035
+				'TKT_order' 		=> isset($tkt['TKT_order']) ? $tkt['TKT_order'] : $row,
1036 1036
 				'TKT_price' 		=> $ticket_price
1037 1037
 			);
1038 1038
 
@@ -1040,7 +1040,7 @@  discard block
 block discarded – undo
1040 1040
 
1041 1041
 
1042 1042
 			//if this is a default TKT, then we need to set the TKT_ID to 0 and update accordingly, which means in turn that the prices will become new prices as well.
1043
-			if ( isset( $tkt['TKT_is_default'] ) && $tkt['TKT_is_default'] ) {
1043
+			if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) {
1044 1044
 				$TKT_values['TKT_ID'] = 0;
1045 1045
 				$TKT_values['TKT_is_default'] = 0;
1046 1046
 				$TKT_values['TKT_price'] = $ticket_price;
@@ -1051,58 +1051,58 @@  discard block
 block discarded – undo
1051 1051
 			//we actually do our saves a head of doing any add_relations to because its entirely possible that this ticket didn't removed or added to any datetime in the session but DID have it's items modified.
1052 1052
 			//keep in mind that if the TKT has been sold (and we have changed pricing information), then we won't be updating the tkt but instead a new tkt will be created and the old one archived.
1053 1053
 
1054
-			if ( !empty( $tkt['TKT_ID'] ) ) {
1055
-				$TKT = EE_Registry::instance()->load_model( 'Ticket', array( $evtobj->get_timezone() ) )->get_one_by_ID( $tkt['TKT_ID'] );
1056
-				if ( $TKT instanceof EE_Ticket ) {
1057
-					$ticket_sold = $TKT->count_related( 'Registration', array( array( 'STS_ID' => array( 'NOT IN', array( EEM_Registration::status_id_incomplete ) ) ) ) ) > 0 ? true : false;
1054
+			if ( ! empty($tkt['TKT_ID'])) {
1055
+				$TKT = EE_Registry::instance()->load_model('Ticket', array($evtobj->get_timezone()))->get_one_by_ID($tkt['TKT_ID']);
1056
+				if ($TKT instanceof EE_Ticket) {
1057
+					$ticket_sold = $TKT->count_related('Registration', array(array('STS_ID' => array('NOT IN', array(EEM_Registration::status_id_incomplete))))) > 0 ? true : false;
1058 1058
 					//let's just check the total price for the existing ticket and determine if it matches the new total price.  if they are different then we create a new ticket (if tkts sold) if they aren't different then we go ahead and modify existing ticket.
1059
-					$create_new_TKT = $ticket_sold && $ticket_price != $TKT->get( 'TKT_price' ) && ! $TKT->get( 'TKT_deleted' ) ? true : false;
1060
-					$TKT->set_date_format( $incoming_date_formats[ 0 ] );
1061
-					$TKT->set_time_format( $incoming_date_formats[ 1 ] );
1059
+					$create_new_TKT = $ticket_sold && $ticket_price != $TKT->get('TKT_price') && ! $TKT->get('TKT_deleted') ? true : false;
1060
+					$TKT->set_date_format($incoming_date_formats[0]);
1061
+					$TKT->set_time_format($incoming_date_formats[1]);
1062 1062
 					//set new values
1063
-					foreach ( $TKT_values as $field => $value ) {
1064
-						if ( $field == 'TKT_qty' ) {
1065
-							$TKT->set_qty( $value );
1063
+					foreach ($TKT_values as $field => $value) {
1064
+						if ($field == 'TKT_qty') {
1065
+							$TKT->set_qty($value);
1066 1066
 						} else {
1067
-							$TKT->set( $field, $value );
1067
+							$TKT->set($field, $value);
1068 1068
 						}
1069 1069
 					}
1070 1070
 					//if $create_new_TKT is false then we can safely update the existing ticket.  Otherwise we have to create a new ticket.
1071
-					if ( $create_new_TKT ) {
1071
+					if ($create_new_TKT) {
1072 1072
 						//archive the old ticket first
1073
-						$TKT->set( 'TKT_deleted', 1 );
1073
+						$TKT->set('TKT_deleted', 1);
1074 1074
 						$TKT->save();
1075 1075
 						//make sure this ticket is still recorded in our saved_tkts so we don't run it through the regular trash routine.
1076
-						$saved_tickets[ $TKT->ID() ] = $TKT;
1076
+						$saved_tickets[$TKT->ID()] = $TKT;
1077 1077
 						//create new ticket that's a copy of the existing except a new id of course (and not archived) AND has the new TKT_price associated with it.
1078 1078
 						$TKT = clone $TKT;
1079
-						$TKT->set( 'TKT_ID', 0 );
1080
-						$TKT->set( 'TKT_deleted', 0 );
1081
-						$TKT->set( 'TKT_price', $ticket_price );
1082
-						$TKT->set( 'TKT_sold', 0 );
1079
+						$TKT->set('TKT_ID', 0);
1080
+						$TKT->set('TKT_deleted', 0);
1081
+						$TKT->set('TKT_price', $ticket_price);
1082
+						$TKT->set('TKT_sold', 0);
1083 1083
 						//now we need to make sure that $new prices are created as well and attached to new ticket.
1084 1084
 						$update_prices = true;
1085 1085
 					}
1086 1086
 					//make sure price is set if it hasn't been already
1087
-					$TKT->set( 'TKT_price', $ticket_price );
1087
+					$TKT->set('TKT_price', $ticket_price);
1088 1088
 				}
1089 1089
 
1090 1090
 			} else {
1091 1091
 				//no TKT_id so a new TKT
1092 1092
 				$TKT_values['TKT_price'] = $ticket_price;
1093
-				$TKT = EE_Registry::instance()->load_class('Ticket', array( $TKT_values ), FALSE, FALSE );
1094
-				if ( $TKT instanceof EE_Ticket ) {
1093
+				$TKT = EE_Registry::instance()->load_class('Ticket', array($TKT_values), FALSE, FALSE);
1094
+				if ($TKT instanceof EE_Ticket) {
1095 1095
 					//need to reset values to properly account for the date formats
1096
-					$TKT->set_date_format( $incoming_date_formats[0] );
1097
-					$TKT->set_time_format( $incoming_date_formats[1] );
1098
-					$TKT->set_timezone( $evtobj->get_timezone() );
1096
+					$TKT->set_date_format($incoming_date_formats[0]);
1097
+					$TKT->set_time_format($incoming_date_formats[1]);
1098
+					$TKT->set_timezone($evtobj->get_timezone());
1099 1099
 
1100 1100
 					//set new values
1101
-					foreach ( $TKT_values as $field => $value ) {
1102
-						if ( $field == 'TKT_qty' ) {
1103
-							$TKT->set_qty( $value );
1101
+					foreach ($TKT_values as $field => $value) {
1102
+						if ($field == 'TKT_qty') {
1103
+							$TKT->set_qty($value);
1104 1104
 						} else {
1105
-							$TKT->set( $field, $value );
1105
+							$TKT->set($field, $value);
1106 1106
 						}
1107 1107
 					}
1108 1108
 
@@ -1110,32 +1110,32 @@  discard block
 block discarded – undo
1110 1110
 				}
1111 1111
 			}
1112 1112
 			// cap ticket qty by datetime reg limits
1113
-			$TKT->set_qty( min( $TKT->qty(), $TKT->qty( 'reg_limit' ) ) );
1113
+			$TKT->set_qty(min($TKT->qty(), $TKT->qty('reg_limit')));
1114 1114
 			//update ticket.
1115 1115
 			$TKT->save();
1116 1116
 
1117 1117
 			//before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date.
1118
-			if( $TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date') ) {
1119
-				$TKT->set('TKT_end_date', $TKT->get('TKT_start_date') );
1118
+			if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) {
1119
+				$TKT->set('TKT_end_date', $TKT->get('TKT_start_date'));
1120 1120
 				EE_Registry::instance()->load_helper('DTT_Helper');
1121 1121
 				$TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days');
1122 1122
 				$TKT->save();
1123 1123
 			}
1124 1124
 
1125 1125
 			//initially let's add the ticket to the dtt
1126
-			$saved_dtt->_add_relation_to( $TKT, 'Ticket' );
1126
+			$saved_dtt->_add_relation_to($TKT, 'Ticket');
1127 1127
 
1128 1128
 			$saved_tickets[$TKT->ID()] = $TKT;
1129 1129
 
1130 1130
 			//add prices to ticket
1131
-			$this->_add_prices_to_ticket( $data['edit_prices'][$row], $TKT, $update_prices );
1131
+			$this->_add_prices_to_ticket($data['edit_prices'][$row], $TKT, $update_prices);
1132 1132
 		}
1133 1133
 		//however now we need to handle permanently deleting tickets via the ui.  Keep in mind that the ui does not allow deleting/archiving tickets that have ticket sold.  However, it does allow for deleting tickets that have no tickets sold, in which case we want to get rid of permanently because there is no need to save in db.
1134
-		$old_tickets = isset( $old_tickets[0] ) && $old_tickets[0] == '' ? array() : $old_tickets;
1135
-		$tickets_removed = array_diff( $old_tickets, array_keys( $saved_tickets ) );
1134
+		$old_tickets = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets;
1135
+		$tickets_removed = array_diff($old_tickets, array_keys($saved_tickets));
1136 1136
 
1137
-		foreach ( $tickets_removed as $id ) {
1138
-			$id = absint( $id );
1137
+		foreach ($tickets_removed as $id) {
1138
+			$id = absint($id);
1139 1139
 
1140 1140
 			//get the ticket for this id
1141 1141
 			$tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id);
@@ -1143,7 +1143,7 @@  discard block
 block discarded – undo
1143 1143
 			//need to get all the related datetimes on this ticket and remove from every single one of them (remember this process can ONLY kick off if there are NO tkts_sold)
1144 1144
 			$dtts = $tkt_to_remove->get_many_related('Datetime');
1145 1145
 
1146
-			foreach( $dtts as $dtt ) {
1146
+			foreach ($dtts as $dtt) {
1147 1147
 				$tkt_to_remove->_remove_relation_to($dtt, 'Datetime');
1148 1148
 			}
1149 1149
 
@@ -1154,7 +1154,7 @@  discard block
 block discarded – undo
1154 1154
 			//finally let's delete this ticket (which should not be blocked at this point b/c we've removed all our relationships)
1155 1155
 			$tkt_to_remove->delete_permanently();
1156 1156
 		}
1157
-		return array( $saved_dtt, $saved_tickets );
1157
+		return array($saved_dtt, $saved_tickets);
1158 1158
 	}
1159 1159
 
1160 1160
 
@@ -1169,31 +1169,31 @@  discard block
 block discarded – undo
1169 1169
 	 * @param bool 		$new_prices Whether attach existing incoming prices or create new ones.
1170 1170
 	 * @return  void
1171 1171
 	 */
1172
-	private function  _add_prices_to_ticket( $prices, EE_Ticket $ticket, $new_prices = FALSE ) {
1173
-		foreach ( $prices as $row => $prc ) {
1172
+	private function  _add_prices_to_ticket($prices, EE_Ticket $ticket, $new_prices = FALSE) {
1173
+		foreach ($prices as $row => $prc) {
1174 1174
 			$PRC_values = array(
1175
-				'PRC_ID' => !empty( $prc['PRC_ID'] ) ? $prc['PRC_ID'] : NULL,
1176
-				'PRT_ID' => !empty( $prc['PRT_ID'] ) ? $prc['PRT_ID'] : NULL,
1177
-				'PRC_amount' => !empty( $prc['PRC_amount'] ) ? $prc['PRC_amount'] : 0,
1178
-				'PRC_name' => !empty( $prc['PRC_name'] ) ? $prc['PRC_name'] : '',
1179
-				'PRC_desc' => !empty( $prc['PRC_desc'] ) ? $prc['PRC_desc'] : '',
1175
+				'PRC_ID' => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : NULL,
1176
+				'PRT_ID' => ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : NULL,
1177
+				'PRC_amount' => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0,
1178
+				'PRC_name' => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '',
1179
+				'PRC_desc' => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '',
1180 1180
 				'PRC_is_default' => 0, //make sure prices are NOT set as default from this context
1181 1181
 				'PRC_order' => $row
1182 1182
 			);
1183 1183
 
1184
-			if ( $new_prices || empty( $PRC_values['PRC_ID'] ) ) {
1184
+			if ($new_prices || empty($PRC_values['PRC_ID'])) {
1185 1185
 				$PRC_values['PRC_ID'] = 0;
1186
-				$PRC = EE_Registry::instance()->load_class('Price', array( $PRC_values ), FALSE, FALSE);
1186
+				$PRC = EE_Registry::instance()->load_class('Price', array($PRC_values), FALSE, FALSE);
1187 1187
 			} else {
1188
-				$PRC = EE_Registry::instance()->load_model( 'Price' )->get_one_by_ID( $prc['PRC_ID'] );
1188
+				$PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']);
1189 1189
 				//update this price with new values
1190
-				foreach ( $PRC_values as $field => $newprc ) {
1191
-					$PRC->set( $field, $newprc );
1190
+				foreach ($PRC_values as $field => $newprc) {
1191
+					$PRC->set($field, $newprc);
1192 1192
 				}
1193 1193
 				$PRC->save();
1194 1194
 			}
1195 1195
 
1196
-			$ticket->_add_relation_to( $PRC, 'Price' );
1196
+			$ticket->_add_relation_to($PRC, 'Price');
1197 1197
 		}
1198 1198
 	}
1199 1199
 
@@ -1216,33 +1216,33 @@  discard block
 block discarded – undo
1216 1216
 
1217 1217
 		return; //TEMPORARILY EXITING CAUSE THIS IS A TODO
1218 1218
 
1219
-		$postid = isset( $this->_req_data['post_ID'] ) ? $this->_req_data['post_ID'] : NULL;
1219
+		$postid = isset($this->_req_data['post_ID']) ? $this->_req_data['post_ID'] : NULL;
1220 1220
 
1221 1221
 
1222 1222
 		//if no postid then get out cause we need it for stuff in here
1223
-		if ( empty( $postid ) ) return;
1223
+		if (empty($postid)) return;
1224 1224
 
1225 1225
 
1226 1226
 		//handle datetime saves
1227 1227
 		$items = array();
1228 1228
 
1229
-		$get_one_where = array( $this->_event_model()->primary_key_name() => $postid );
1230
-		$event = $this->_event_model()->get_one( array($get_one_where) );
1229
+		$get_one_where = array($this->_event_model()->primary_key_name() => $postid);
1230
+		$event = $this->_event_model()->get_one(array($get_one_where));
1231 1231
 
1232 1232
 		//now let's get the attached datetimes from the most recent autosave
1233 1233
 		$dtts = $event->get_many_related('Datetime');
1234 1234
 
1235 1235
 		$dtt_ids = array();
1236
-		foreach( $dtts as $dtt ) {
1236
+		foreach ($dtts as $dtt) {
1237 1237
 			$dtt_ids[] = $dtt->ID();
1238 1238
 			$order = $dtt->order();
1239 1239
 			$this->_template_args['data']['items']['ID-'.$order] = $dtt->ID();
1240 1240
 		}
1241
-		$this->_template_args['data']['items']['datetime_IDS'] = serialize( $dtt_ids );
1241
+		$this->_template_args['data']['items']['datetime_IDS'] = serialize($dtt_ids);
1242 1242
 
1243 1243
 		//handle DECAF venues
1244 1244
 		//we need to make sure that the venue_id gets updated in the form so that future autosaves will properly conntect that venue to the event.
1245
-		if ( $do_venue_autosaves = apply_filters( 'FHEE__Events_Admin_Page__ee_autosave_edit_do_decaf_venue_save', TRUE ) ) {
1245
+		if ($do_venue_autosaves = apply_filters('FHEE__Events_Admin_Page__ee_autosave_edit_do_decaf_venue_save', TRUE)) {
1246 1246
 			$venue = $event->get_first_related('Venue');
1247 1247
 			$this->_template_args['data']['items']['venue-id'] = $venue->ID();
1248 1248
 		}
@@ -1253,23 +1253,23 @@  discard block
 block discarded – undo
1253 1253
 
1254 1254
 		$ticket_ids = array();
1255 1255
 		$price_ids = array();
1256
-		foreach ( $tickets as $ticket ) {
1256
+		foreach ($tickets as $ticket) {
1257 1257
 			$ticket_ids[] = $price->ID();
1258 1258
 			$ticket_order = $price->get('TKT_order');
1259
-			$this->_template_args['data']['items']['edit-ticket-id-' . $ticket_order] = $ticket->ID();
1260
-			$this->_template_args['data']['items']['edit-ticket-event-id-' . $order] = $event->ID();
1259
+			$this->_template_args['data']['items']['edit-ticket-id-'.$ticket_order] = $ticket->ID();
1260
+			$this->_template_args['data']['items']['edit-ticket-event-id-'.$order] = $event->ID();
1261 1261
 
1262 1262
 			//now we have to make sure the prices are updated appropriately
1263 1263
 			$prices = $ticket->get_many_related('Prices');
1264 1264
 
1265
-			foreach ( $prices as $price ) {
1265
+			foreach ($prices as $price) {
1266 1266
 				$price_ids[] = $price->ID();
1267 1267
 				$price_order = $price->get('PRC_order');
1268
-				$this->_template_args['data']['items']['quick-edit-ticket-price-id-ticketrow-' . $ticket_order . '-' . $price_order] = $price->ID();
1269
-				$this->_template_args['data']['items']['edit-ticket-price-id-ticketrow-' . $ticket_row . '-' . $price_row] = $price->ID();
1270
-				$this->_template_args['data']['items']['edit-ticket-price-is-default-ticketrow-' . $ticket_row . '-' . $price_row] = $price->get('PRC_is_default');
1268
+				$this->_template_args['data']['items']['quick-edit-ticket-price-id-ticketrow-'.$ticket_order.'-'.$price_order] = $price->ID();
1269
+				$this->_template_args['data']['items']['edit-ticket-price-id-ticketrow-'.$ticket_row.'-'.$price_row] = $price->ID();
1270
+				$this->_template_args['data']['items']['edit-ticket-price-is-default-ticketrow-'.$ticket_row.'-'.$price_row] = $price->get('PRC_is_default');
1271 1271
 			}
1272
-			$this->_template_args['data']['items']['price-IDs-ticketrow-' . $ticket_row] = implode(',', $price_ids);
1272
+			$this->_template_args['data']['items']['price-IDs-ticketrow-'.$ticket_row] = implode(',', $price_ids);
1273 1273
 		}
1274 1274
 		$this->_template_args['data']['items']['ticket-IDs'] = implode(',', $ticket_ids);
1275 1275
 	}
@@ -1287,12 +1287,12 @@  discard block
 block discarded – undo
1287 1287
 	private function _generate_publish_box_extra_content() {
1288 1288
 
1289 1289
 		//load formatter helper
1290
-  		EE_Registry::instance()->load_helper( 'Formatter' );
1290
+  		EE_Registry::instance()->load_helper('Formatter');
1291 1291
 
1292 1292
   		//args for getting related registrations
1293
-  		$approved_query_args = array( array( 'REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_approved ) );
1294
-  		$not_approved_query_args = array( array( 'REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_not_approved ) );
1295
-  		$pending_payment_query_args = array( array( 'REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_pending_payment ) );
1293
+  		$approved_query_args = array(array('REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_approved));
1294
+  		$not_approved_query_args = array(array('REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_not_approved));
1295
+  		$pending_payment_query_args = array(array('REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_pending_payment));
1296 1296
 
1297 1297
 
1298 1298
 		// publish box
@@ -1321,9 +1321,9 @@  discard block
 block discarded – undo
1321 1321
 				),
1322 1322
 				REG_ADMIN_URL
1323 1323
 			),
1324
-			'approved_regs' => $this->_cpt_model_obj->count_related( 'Registration', $approved_query_args ),
1325
-			'not_approved_regs' => $this->_cpt_model_obj->count_related( 'Registration', $not_approved_query_args ),
1326
-			'pending_payment_regs' => $this->_cpt_model_obj->count_related( 'Registration', $pending_payment_query_args ),
1324
+			'approved_regs' => $this->_cpt_model_obj->count_related('Registration', $approved_query_args),
1325
+			'not_approved_regs' => $this->_cpt_model_obj->count_related('Registration', $not_approved_query_args),
1326
+			'pending_payment_regs' => $this->_cpt_model_obj->count_related('Registration', $pending_payment_query_args),
1327 1327
 			'misc_pub_section_class' => apply_filters(
1328 1328
 				'FHEE_Events_Admin_Page___generate_publish_box_extra_content__misc_pub_section_class',
1329 1329
 				'misc-pub-section'
@@ -1342,9 +1342,9 @@  discard block
 block discarded – undo
1342 1342
 			'AHEE__Events_Admin_Page___generate_publish_box_extra_content__event_editor_overview_add',
1343 1343
 			$this->_cpt_model_obj
1344 1344
 		);
1345
-		$publish_box_extra_args[ 'event_editor_overview_add' ] = ob_get_clean();
1345
+		$publish_box_extra_args['event_editor_overview_add'] = ob_get_clean();
1346 1346
 		// load template
1347
-		EEH_Template::display_template( EVENTS_TEMPLATE_PATH . 'event_publish_box_extras.template.php', $publish_box_extra_args );
1347
+		EEH_Template::display_template(EVENTS_TEMPLATE_PATH.'event_publish_box_extras.template.php', $publish_box_extra_args);
1348 1348
 	}
1349 1349
 
1350 1350
 
@@ -1376,16 +1376,16 @@  discard block
 block discarded – undo
1376 1376
 		$this->verify_cpt_object();
1377 1377
 		add_meta_box(
1378 1378
 			'espresso_event_editor_tickets',
1379
-			__( 'Event Datetime & Ticket', 'event_espresso' ),
1380
-			array( $this, 'ticket_metabox' ),
1379
+			__('Event Datetime & Ticket', 'event_espresso'),
1380
+			array($this, 'ticket_metabox'),
1381 1381
 			$this->page_slug,
1382 1382
 			'normal',
1383 1383
 			'high'
1384 1384
 		);
1385 1385
 		add_meta_box(
1386 1386
 			'espresso_event_editor_event_options',
1387
-			__( 'Event Registration Options', 'event_espresso' ),
1388
-			array( $this, 'registration_options_meta_box' ),
1387
+			__('Event Registration Options', 'event_espresso'),
1388
+			array($this, 'registration_options_meta_box'),
1389 1389
 			$this->page_slug,
1390 1390
 			'side',
1391 1391
 			'default'
@@ -1415,38 +1415,38 @@  discard block
 block discarded – undo
1415 1415
 			'disabled' => ''
1416 1416
 			);
1417 1417
 
1418
-		$event_id = is_object( $this->_cpt_model_obj ) ? $this->_cpt_model_obj->ID() : NULL;
1418
+		$event_id = is_object($this->_cpt_model_obj) ? $this->_cpt_model_obj->ID() : NULL;
1419 1419
 
1420
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
1420
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1421 1421
 
1422 1422
 		/**
1423 1423
 		 * 1. Start with retrieving Datetimes
1424 1424
 		 * 2. Fore each datetime get related tickets
1425 1425
 		 * 3. For each ticket get related prices
1426 1426
 		 */
1427
-		$times = EE_Registry::instance()->load_model('Datetime' )->get_all_event_dates( $event_id );
1428
-		EE_Registry::instance()->load_helper('DTT_Helper' );
1427
+		$times = EE_Registry::instance()->load_model('Datetime')->get_all_event_dates($event_id);
1428
+		EE_Registry::instance()->load_helper('DTT_Helper');
1429 1429
 		/** @type EE_Datetime $first_datetime */
1430
-		$first_datetime = array_slice( $times, 0, 1 );
1430
+		$first_datetime = array_slice($times, 0, 1);
1431 1431
 		//do we get related tickets?
1432
-		if ( $first_datetime[ 0 ]->get( 'DTT_ID' ) !== 0 ) {
1433
-			foreach ( $times as $time ) {
1434
-				if ( $time instanceof EE_Datetime ) {
1432
+		if ($first_datetime[0]->get('DTT_ID') !== 0) {
1433
+			foreach ($times as $time) {
1434
+				if ($time instanceof EE_Datetime) {
1435 1435
 					$existing_datetime_ids[] = $time->get('DTT_ID');
1436 1436
 					$template_args['time'] = $time;
1437 1437
 					$related_tickets = $time->tickets(
1438 1438
 						array(
1439
-							array( 'OR' => array( 'TKT_deleted' => 1, 'TKT_deleted*' => 0 ) ),
1439
+							array('OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0)),
1440 1440
 							'default_where_conditions' => 'none'
1441 1441
 						)
1442 1442
 					);
1443 1443
 
1444
-					if ( !empty($related_tickets) ) {
1444
+					if ( ! empty($related_tickets)) {
1445 1445
 						$template_args['total_ticket_rows'] = count($related_tickets);
1446 1446
 						$row = 0;
1447
-						foreach ( $related_tickets as $ticket ) {
1447
+						foreach ($related_tickets as $ticket) {
1448 1448
 							$existing_ticket_ids[] = $ticket->get('TKT_ID');
1449
-							$template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, FALSE, $row );
1449
+							$template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, FALSE, $row);
1450 1450
 
1451 1451
 							$row++;
1452 1452
 						}
@@ -1454,7 +1454,7 @@  discard block
 block discarded – undo
1454 1454
 						$template_args['total_ticket_rows'] = 1;
1455 1455
 						/** @type EE_Ticket $ticket */
1456 1456
 						$ticket = EE_Registry::instance()->load_model('Ticket')->create_default_object();
1457
-						$template_args['ticket_rows'] .= $this->_get_ticket_row( $ticket );
1457
+						$template_args['ticket_rows'] .= $this->_get_ticket_row($ticket);
1458 1458
 					}
1459 1459
 				}
1460 1460
 			}
@@ -1462,7 +1462,7 @@  discard block
 block discarded – undo
1462 1462
 			$template_args['time'] = $times[0];
1463 1463
 			/** @type EE_Ticket $ticket */
1464 1464
 			$ticket = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets();
1465
-			$template_args['ticket_rows'] .= $this->_get_ticket_row( $ticket[1] );
1465
+			$template_args['ticket_rows'] .= $this->_get_ticket_row($ticket[1]);
1466 1466
 			// NOTE: we're just sending the first default row
1467 1467
 			// (decaf can't manage default tickets so this should be sufficient);
1468 1468
 		}
@@ -1471,8 +1471,8 @@  discard block
 block discarded – undo
1471 1471
 		$template_args['ticket_options_help_link'] = $this->_get_help_tab_link('ticket_options_info');
1472 1472
 		$template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids);
1473 1473
 		$template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids);
1474
-		$template_args['ticket_js_structure'] = $this->_get_ticket_row( EE_Registry::instance()->load_model('Ticket')->create_default_object(), TRUE );
1475
-		$template = apply_filters( 'FHEE__Events_Admin_Page__ticket_metabox__template', EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php' );
1474
+		$template_args['ticket_js_structure'] = $this->_get_ticket_row(EE_Registry::instance()->load_model('Ticket')->create_default_object(), TRUE);
1475
+		$template = apply_filters('FHEE__Events_Admin_Page__ticket_metabox__template', EVENTS_TEMPLATE_PATH.'event_tickets_metabox_main.template.php');
1476 1476
 		EEH_Template::display_template($template, $template_args);
1477 1477
 	}
1478 1478
 
@@ -1487,21 +1487,21 @@  discard block
 block discarded – undo
1487 1487
 	 * @param int        $row
1488 1488
 	 * @return string generated html for the ticket row.
1489 1489
 	 */
1490
-	private function _get_ticket_row( $ticket, $skeleton = FALSE, $row = 0 ) {
1490
+	private function _get_ticket_row($ticket, $skeleton = FALSE, $row = 0) {
1491 1491
 		$template_args = array(
1492
-			'tkt_status_class' => ' tkt-status-' . $ticket->ticket_status(),
1493
-			'tkt_archive_class' => $ticket->ticket_status() === EE_Ticket::archived && !$skeleton ? ' tkt-archived' : '',
1492
+			'tkt_status_class' => ' tkt-status-'.$ticket->ticket_status(),
1493
+			'tkt_archive_class' => $ticket->ticket_status() === EE_Ticket::archived && ! $skeleton ? ' tkt-archived' : '',
1494 1494
 			'ticketrow' => $skeleton ? 'TICKETNUM' : $row,
1495 1495
 			'TKT_ID' => $ticket->get('TKT_ID'),
1496 1496
 			'TKT_name' => $ticket->get('TKT_name'),
1497 1497
 			'TKT_start_date' => $skeleton ? '' : $ticket->get_date('TKT_start_date', 'Y-m-d h:i a'),
1498 1498
 			'TKT_end_date' => $skeleton ? '' : $ticket->get_date('TKT_end_date', 'Y-m-d h:i a'),
1499 1499
 			'TKT_is_default' => $ticket->get('TKT_is_default'),
1500
-			'TKT_qty' => $ticket->get_pretty('TKT_qty','input'),
1500
+			'TKT_qty' => $ticket->get_pretty('TKT_qty', 'input'),
1501 1501
 			'edit_ticketrow_name' => $skeleton ? 'TICKETNAMEATTR' : 'edit_tickets',
1502 1502
 			'TKT_sold' => $skeleton ? 0 : $ticket->get('TKT_sold'),
1503
-			'trash_icon' => ( $skeleton || ( !empty( $ticket ) && ! $ticket->get('TKT_deleted') ) ) && ( !empty( $ticket ) && $ticket->get('TKT_sold') === 0 ) ? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon',
1504
-			'disabled' => $skeleton || ( !empty( $ticket ) && ! $ticket->get('TKT_deleted' ) ) ? '' : ' disabled=disabled'
1503
+			'trash_icon' => ($skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted'))) && ( ! empty($ticket) && $ticket->get('TKT_sold') === 0) ? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon',
1504
+			'disabled' => $skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted')) ? '' : ' disabled=disabled'
1505 1505
 			);
1506 1506
 
1507 1507
 		$price = $ticket->ID() !== 0 ? $ticket->get_first_related('Price', array('default_where_conditions' => 'none')) : EE_Registry::instance()->load_model('Price')->create_default_object();
@@ -1517,23 +1517,23 @@  discard block
 block discarded – undo
1517 1517
 
1518 1518
 		//make sure we have default start and end dates if skeleton
1519 1519
 		//handle rows that should NOT be empty
1520
-		if ( empty( $template_args['TKT_start_date'] ) ) {
1520
+		if (empty($template_args['TKT_start_date'])) {
1521 1521
 			//if empty then the start date will be now.
1522 1522
 			$template_args['TKT_start_date'] = date('Y-m-d h:i a', current_time('timestamp'));
1523 1523
 		}
1524 1524
 
1525
-		if ( empty( $template_args['TKT_end_date'] ) ) {
1525
+		if (empty($template_args['TKT_end_date'])) {
1526 1526
 			//get the earliest datetime (if present);
1527
-			$earliest_dtt = $this->_cpt_model_obj->ID() > 0 ? $this->_cpt_model_obj->get_first_related('Datetime', array('order_by'=> array('DTT_EVT_start' => 'ASC' ) ) ) : NULL;
1527
+			$earliest_dtt = $this->_cpt_model_obj->ID() > 0 ? $this->_cpt_model_obj->get_first_related('Datetime', array('order_by'=> array('DTT_EVT_start' => 'ASC'))) : NULL;
1528 1528
 
1529
-			if ( !empty( $earliest_dtt ) )
1529
+			if ( ! empty($earliest_dtt))
1530 1530
 				$template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', 'Y-m-d', 'h:i a');
1531 1531
 			else
1532
-				$template_args['TKT_end_date'] = date('Y-m-d h:i a', mktime(0, 0, 0, date("m"), date("d")+7, date("Y") ) );
1532
+				$template_args['TKT_end_date'] = date('Y-m-d h:i a', mktime(0, 0, 0, date("m"), date("d") + 7, date("Y")));
1533 1533
 		}
1534 1534
 
1535
-		$template_args = array_merge( $template_args, $price_args );
1536
-		$template = apply_filters( 'FHEE__Events_Admin_Page__get_ticket_row__template', EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_ticket_row.template.php', $ticket);
1535
+		$template_args = array_merge($template_args, $price_args);
1536
+		$template = apply_filters('FHEE__Events_Admin_Page__get_ticket_row__template', EVENTS_TEMPLATE_PATH.'event_tickets_metabox_ticket_row.template.php', $ticket);
1537 1537
 		return EEH_Template::display_template($template, $template_args, TRUE);
1538 1538
 	}
1539 1539
 
@@ -1562,8 +1562,8 @@  discard block
 block discarded – undo
1562 1562
 		$template_args['default_registration_status'] = EEH_Form_Fields::select_input('default_reg_status', $default_reg_status_values, $this->_cpt_model_obj->default_registration_status());
1563 1563
 		$template_args['display_description'] = EEH_Form_Fields::select_input('display_desc', $yes_no_values, $this->_cpt_model_obj->display_description());
1564 1564
 		$template_args['display_ticket_selector'] = EEH_Form_Fields::select_input('display_ticket_selector', $yes_no_values, $this->_cpt_model_obj->display_ticket_selector(), '', '', false);
1565
-		$template_args['additional_registration_options'] = apply_filters( 'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', '', $template_args, $yes_no_values, $default_reg_status_values );
1566
-		$templatepath = EVENTS_TEMPLATE_PATH . 'event_registration_options.template.php';
1565
+		$template_args['additional_registration_options'] = apply_filters('FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', '', $template_args, $yes_no_values, $default_reg_status_values);
1566
+		$templatepath = EVENTS_TEMPLATE_PATH.'event_registration_options.template.php';
1567 1567
 		EEH_Template::display_template($templatepath, $template_args);
1568 1568
 	}
1569 1569
 
@@ -1591,21 +1591,21 @@  discard block
 block discarded – undo
1591 1591
 		$EEME = $this->_event_model();
1592 1592
 
1593 1593
 		$offset = ($current_page - 1) * $per_page;
1594
-		$limit = $count ? NULL : $offset . ',' . $per_page;
1594
+		$limit = $count ? NULL : $offset.','.$per_page;
1595 1595
 		$orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'EVT_ID';
1596 1596
 		$order = isset($this->_req_data['order']) ? $this->_req_data['order'] : "DESC";
1597 1597
 
1598 1598
 		if (isset($this->_req_data['month_range'])) {
1599 1599
 			$pieces = explode(' ', $this->_req_data['month_range'], 3);
1600
-			$month_r = !empty($pieces[0]) ? date('m', strtotime($pieces[0])) : '';
1601
-			$year_r = !empty($pieces[1]) ? $pieces[1] : '';
1600
+			$month_r = ! empty($pieces[0]) ? date('m', strtotime($pieces[0])) : '';
1601
+			$year_r = ! empty($pieces[1]) ? $pieces[1] : '';
1602 1602
 		}
1603 1603
 
1604 1604
 		$where = array();
1605 1605
 
1606
-		$status = isset( $this->_req_data['status'] ) ? $this->_req_data['status'] : NULL;
1606
+		$status = isset($this->_req_data['status']) ? $this->_req_data['status'] : NULL;
1607 1607
 		//determine what post_status our condition will have for the query.
1608
-		switch ( $status ) {
1608
+		switch ($status) {
1609 1609
 			case 'month' :
1610 1610
 			case 'today' :
1611 1611
 			case NULL :
@@ -1613,7 +1613,7 @@  discard block
 block discarded – undo
1613 1613
 				break;
1614 1614
 
1615 1615
 			case 'draft' :
1616
-				$where['status'] = array( 'IN', array('draft', 'auto-draft') );
1616
+				$where['status'] = array('IN', array('draft', 'auto-draft'));
1617 1617
 				break;
1618 1618
 
1619 1619
 			default :
@@ -1621,43 +1621,43 @@  discard block
 block discarded – undo
1621 1621
 		}
1622 1622
 
1623 1623
 		//categories?
1624
-		$category = isset( $this->_req_data['EVT_CAT'] ) && $this->_req_data['EVT_CAT'] > 0 ? $this->_req_data['EVT_CAT'] : NULL;
1624
+		$category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0 ? $this->_req_data['EVT_CAT'] : NULL;
1625 1625
 
1626
-		if ( !empty ( $category ) ) {
1626
+		if ( ! empty ($category)) {
1627 1627
 			$where['Term_Taxonomy.taxonomy'] = 'espresso_event_categories';
1628 1628
 			$where['Term_Taxonomy.term_id'] = $category;
1629 1629
 		}
1630 1630
 
1631 1631
 		//date where conditions
1632
-		$start_formats = EEM_Datetime::instance()->get_formats_for( 'DTT_EVT_start' );
1632
+		$start_formats = EEM_Datetime::instance()->get_formats_for('DTT_EVT_start');
1633 1633
 		if (isset($this->_req_data['month_range']) && $this->_req_data['month_range'] != '') {
1634
-			$DateTime = new DateTime( $year_r . '-' . $month_r . '-01 00:00:00', new DateTimeZone( EEM_Datetime::instance()->get_timezone() ) );
1635
-			$start = $DateTime->format( implode( ' ', $start_formats  ) );
1636
-			$end = $DateTime->setDate( $year_r, $month_r, $DateTime->format('t') )->setTime(23,59,59)->format( implode( ' ', $start_formats ) );
1637
-			$where['Datetime.DTT_EVT_start'] = array('BETWEEN', array( $start, $end ) );
1634
+			$DateTime = new DateTime($year_r.'-'.$month_r.'-01 00:00:00', new DateTimeZone(EEM_Datetime::instance()->get_timezone()));
1635
+			$start = $DateTime->format(implode(' ', $start_formats));
1636
+			$end = $DateTime->setDate($year_r, $month_r, $DateTime->format('t'))->setTime(23, 59, 59)->format(implode(' ', $start_formats));
1637
+			$where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end));
1638 1638
 		} else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'today') {
1639
-			$DateTime = new DateTime( 'now', new DateTimeZone( EEM_Event::instance()->get_timezone() ) );
1640
-			$start = $DateTime->setTime( 0,0,0 )->format( implode( ' ', $start_formats ) );
1641
-			$end = $DateTime->setTime( 23, 59, 59 )->format( implode( ' ', $start_formats ) );
1642
-			$where['Datetime.DTT_EVT_start'] = array( 'BETWEEN', array( $start, $end ) );
1643
-		} else if ( isset($this->_req_data['status']) && $this->_req_data['status'] == 'month' ) {
1644
-			$now = date( 'Y-m-01' );
1645
-			$DateTime = new DateTime( $now, new DateTimeZone( EEM_Event::instance()->get_timezone() ) );
1646
-			$start = $DateTime->setTime( 0, 0, 0 )->format( implode( ' ', $start_formats ) );
1647
-			$end = $DateTime->setDate( date('Y'), date('m'), $DateTime->format('t' ) )->setTime( 23, 59, 59 )->format( implode( ' ', $start_formats ) );
1648
-			$where['Datetime.DTT_EVT_start'] = array( 'BETWEEN', array( $start, $end ) );
1639
+			$DateTime = new DateTime('now', new DateTimeZone(EEM_Event::instance()->get_timezone()));
1640
+			$start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats));
1641
+			$end = $DateTime->setTime(23, 59, 59)->format(implode(' ', $start_formats));
1642
+			$where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end));
1643
+		} else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'month') {
1644
+			$now = date('Y-m-01');
1645
+			$DateTime = new DateTime($now, new DateTimeZone(EEM_Event::instance()->get_timezone()));
1646
+			$start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats));
1647
+			$end = $DateTime->setDate(date('Y'), date('m'), $DateTime->format('t'))->setTime(23, 59, 59)->format(implode(' ', $start_formats));
1648
+			$where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end));
1649 1649
 		}
1650 1650
 
1651 1651
 
1652
-		if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_events', 'get_events' ) ) {
1653
-			$where['EVT_wp_user'] =  get_current_user_id();
1652
+		if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) {
1653
+			$where['EVT_wp_user'] = get_current_user_id();
1654 1654
 		} else {
1655
-			if ( ! isset( $where['status'] ) ) {
1656
-				if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_private_events', 'get_events' ) ) {
1655
+			if ( ! isset($where['status'])) {
1656
+				if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) {
1657 1657
 					$where['OR'] = array(
1658
-						'status*restrict_private' => array( '!=', 'private' ),
1658
+						'status*restrict_private' => array('!=', 'private'),
1659 1659
 						'AND' => array(
1660
-							'status*inclusive' => array( '=', 'private' ),
1660
+							'status*inclusive' => array('=', 'private'),
1661 1661
 							'EVT_wp_user' => get_current_user_id()
1662 1662
 						)
1663 1663
 					);
@@ -1665,16 +1665,16 @@  discard block
 block discarded – undo
1665 1665
 			}
1666 1666
 		}
1667 1667
 
1668
-		if ( isset( $this->_req_data['EVT_wp_user'] ) ) {
1669
-			if ( $this->_req_data['EVT_wp_user'] != get_current_user_id() && EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_events', 'get_events' ) ) {
1668
+		if (isset($this->_req_data['EVT_wp_user'])) {
1669
+			if ($this->_req_data['EVT_wp_user'] != get_current_user_id() && EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) {
1670 1670
 				$where['EVT_wp_user'] = $this->_req_data['EVT_wp_user'];
1671 1671
 			}
1672 1672
 		}
1673 1673
 
1674 1674
 
1675 1675
 		//search query handling
1676
-		if ( isset( $this->_req_data['s'] ) ) {
1677
-			$search_string = '%' . $this->_req_data['s'] . '%';
1676
+		if (isset($this->_req_data['s'])) {
1677
+			$search_string = '%'.$this->_req_data['s'].'%';
1678 1678
 			$where['OR'] = array(
1679 1679
 				'EVT_name' => array('LIKE', $search_string),
1680 1680
 				'EVT_desc' => array('LIKE', $search_string),
@@ -1683,32 +1683,32 @@  discard block
 block discarded – undo
1683 1683
 		}
1684 1684
 
1685 1685
 
1686
-		$where = apply_filters( 'FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data );
1687
-		$query_params = apply_filters( 'FHEE__Events_Admin_Page__get_events__query_params', array($where, 'limit' => $limit, 'order_by' => $orderby, 'order' => $order, 'group_by' => 'EVT_ID' ), $this->_req_data );
1686
+		$where = apply_filters('FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data);
1687
+		$query_params = apply_filters('FHEE__Events_Admin_Page__get_events__query_params', array($where, 'limit' => $limit, 'order_by' => $orderby, 'order' => $order, 'group_by' => 'EVT_ID'), $this->_req_data);
1688 1688
 
1689 1689
 
1690 1690
 		//let's first check if we have special requests coming in.
1691
-		if ( isset( $this->_req_data['active_status'] ) ) {
1692
-			switch ( $this->_req_data['active_status'] ) {
1691
+		if (isset($this->_req_data['active_status'])) {
1692
+			switch ($this->_req_data['active_status']) {
1693 1693
 				case 'upcoming' :
1694
-					return $EEME->get_upcoming_events( $query_params, $count );
1694
+					return $EEME->get_upcoming_events($query_params, $count);
1695 1695
 					break;
1696 1696
 
1697 1697
 				case 'expired' :
1698
-					return $EEME->get_expired_events( $query_params, $count );
1698
+					return $EEME->get_expired_events($query_params, $count);
1699 1699
 					break;
1700 1700
 
1701 1701
 				case 'active' :
1702
-					return $EEME->get_active_events( $query_params, $count );
1702
+					return $EEME->get_active_events($query_params, $count);
1703 1703
 					break;
1704 1704
 
1705 1705
 				case 'inactive' :
1706
-					return $EEME->get_inactive_events( $query_params, $count );
1706
+					return $EEME->get_inactive_events($query_params, $count);
1707 1707
 					break;
1708 1708
 			}
1709 1709
 		}
1710 1710
 
1711
-		$events = $count ? $EEME->count( array( $where ), 'EVT_ID', true ) : $EEME->get_all( $query_params );
1711
+		$events = $count ? $EEME->count(array($where), 'EVT_ID', true) : $EEME->get_all($query_params);
1712 1712
 
1713 1713
 		return $events;
1714 1714
 	}
@@ -1717,23 +1717,23 @@  discard block
 block discarded – undo
1717 1717
 
1718 1718
 
1719 1719
 	//handling for WordPress CPT actions (trash, restore, delete)
1720
-	public function trash_cpt_item( $post_id ) {
1720
+	public function trash_cpt_item($post_id) {
1721 1721
 		$this->_req_data['EVT_ID'] = $post_id;
1722
-		$this->_trash_or_restore_event( 'trash', FALSE );
1722
+		$this->_trash_or_restore_event('trash', FALSE);
1723 1723
 	}
1724 1724
 
1725 1725
 
1726 1726
 
1727 1727
 
1728
-	public function restore_cpt_item( $post_id ) {
1728
+	public function restore_cpt_item($post_id) {
1729 1729
 		$this->_req_data['EVT_ID'] = $post_id;
1730
-		$this->_trash_or_restore_event( 'draft', FALSE );
1730
+		$this->_trash_or_restore_event('draft', FALSE);
1731 1731
 	}
1732 1732
 
1733 1733
 
1734
-	public function delete_cpt_item( $post_id ) {
1734
+	public function delete_cpt_item($post_id) {
1735 1735
 		$this->_req_data['EVT_ID'] = $post_id;
1736
-		$this->_delete_event( FALSE );
1736
+		$this->_delete_event(FALSE);
1737 1737
 	}
1738 1738
 
1739 1739
 
@@ -1745,7 +1745,7 @@  discard block
 block discarded – undo
1745 1745
 	 * @param  string $event_status
1746 1746
 	 * @return void
1747 1747
 	 */
1748
-	protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = TRUE ) {
1748
+	protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = TRUE) {
1749 1749
 		//determine the event id and set to array.
1750 1750
 		$EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : FALSE;
1751 1751
 		// loop thru events
@@ -1753,7 +1753,7 @@  discard block
 block discarded – undo
1753 1753
 			// clean status
1754 1754
 			$event_status = sanitize_key($event_status);
1755 1755
 			// grab status
1756
-			if (!empty($event_status)) {
1756
+			if ( ! empty($event_status)) {
1757 1757
 				$success = $this->_change_event_status($EVT_ID, $event_status);
1758 1758
 			} else {
1759 1759
 				$success = FALSE;
@@ -1767,7 +1767,7 @@  discard block
 block discarded – undo
1767 1767
 		}
1768 1768
 		$action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash';
1769 1769
 
1770
-		if ( $redirect_after )
1770
+		if ($redirect_after)
1771 1771
 			$this->_redirect_after_action($success, 'Event', $action, array('action' => 'default'));
1772 1772
 	}
1773 1773
 
@@ -1782,7 +1782,7 @@  discard block
 block discarded – undo
1782 1782
 		// clean status
1783 1783
 		$event_status = sanitize_key($event_status);
1784 1784
 		// grab status
1785
-		if (!empty($event_status)) {
1785
+		if ( ! empty($event_status)) {
1786 1786
 			$success = TRUE;
1787 1787
 			//determine the event id and set to array.
1788 1788
 			$EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array();
@@ -1817,15 +1817,15 @@  discard block
 block discarded – undo
1817 1817
 	 * @param  string $event_status
1818 1818
 	 * @return bool
1819 1819
 	 */
1820
-	private function _change_event_status( $EVT_ID = 0, $event_status = '') {
1820
+	private function _change_event_status($EVT_ID = 0, $event_status = '') {
1821 1821
 		// grab event id
1822
-		if (!$EVT_ID) {
1822
+		if ( ! $EVT_ID) {
1823 1823
 			$msg = __('An error occurred. No Event ID or an invalid Event ID was received.', 'event_espresso');
1824 1824
 			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1825 1825
 			return FALSE;
1826 1826
 		}
1827 1827
 
1828
-		$this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID( $EVT_ID );
1828
+		$this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID);
1829 1829
 
1830 1830
 		// clean status
1831 1831
 		$event_status = sanitize_key($event_status);
@@ -1851,7 +1851,7 @@  discard block
 block discarded – undo
1851 1851
 				$hook = FALSE;
1852 1852
 		}
1853 1853
 		//use class to change status
1854
-		$this->_cpt_model_obj->set_status( $event_status );
1854
+		$this->_cpt_model_obj->set_status($event_status);
1855 1855
 		$success = $this->_cpt_model_obj->save();
1856 1856
 
1857 1857
 		if ($success === FALSE) {
@@ -1873,15 +1873,15 @@  discard block
 block discarded – undo
1873 1873
 	 * @access protected
1874 1874
 	 * @param bool $redirect_after
1875 1875
 	 */
1876
-	protected function _delete_event( $redirect_after = TRUE ) {
1876
+	protected function _delete_event($redirect_after = TRUE) {
1877 1877
 		//determine the event id and set to array.
1878 1878
 		$EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : NULL;
1879
-		$EVT_ID = isset( $this->_req_data['post'] ) ? absint( $this->_req_data['post'] ) : $EVT_ID;
1879
+		$EVT_ID = isset($this->_req_data['post']) ? absint($this->_req_data['post']) : $EVT_ID;
1880 1880
 
1881 1881
 
1882 1882
 		// loop thru events
1883 1883
 		if ($EVT_ID) {
1884
-			$success = $this->_permanently_delete_event( $EVT_ID );
1884
+			$success = $this->_permanently_delete_event($EVT_ID);
1885 1885
 			// get list of events with no prices
1886 1886
 			$espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array());
1887 1887
 			// remove this event from the list of events with no prices
@@ -1895,7 +1895,7 @@  discard block
 block discarded – undo
1895 1895
 			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1896 1896
 		}
1897 1897
 
1898
-		if ( $redirect_after )
1898
+		if ($redirect_after)
1899 1899
 			$this->_redirect_after_action($success, 'Event', 'deleted', array('action' => 'default', 'status' => 'trash'));
1900 1900
 	}
1901 1901
 
@@ -1913,12 +1913,12 @@  discard block
 block discarded – undo
1913 1913
 		$EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array();
1914 1914
 		// loop thru events
1915 1915
 		foreach ($EVT_IDs as $EVT_ID) {
1916
-			$EVT_ID = absint( $EVT_ID );
1917
-			if ( $EVT_ID ) {
1918
-				$results = $this->_permanently_delete_event( $EVT_ID );
1916
+			$EVT_ID = absint($EVT_ID);
1917
+			if ($EVT_ID) {
1918
+				$results = $this->_permanently_delete_event($EVT_ID);
1919 1919
 				$success = $results !== FALSE ? $success : FALSE;
1920 1920
 				// remove this event from the list of events with no prices
1921
-				unset( $espresso_no_ticket_prices[ $EVT_ID ] );
1921
+				unset($espresso_no_ticket_prices[$EVT_ID]);
1922 1922
 			} else {
1923 1923
 				$success = FALSE;
1924 1924
 				$msg = __('An error occurred. An event could not be deleted because a valid event ID was not not supplied.', 'event_espresso');
@@ -1938,21 +1938,21 @@  discard block
 block discarded – undo
1938 1938
 	 * @param  int $EVT_ID
1939 1939
 	 * @return bool
1940 1940
 	 */
1941
-	private function _permanently_delete_event( $EVT_ID = 0 ) {
1941
+	private function _permanently_delete_event($EVT_ID = 0) {
1942 1942
 		// grab event id
1943
-		if ( ! $EVT_ID ) {
1943
+		if ( ! $EVT_ID) {
1944 1944
 			$msg = __('An error occurred. No Event ID or an invalid Event ID was received.', 'event_espresso');
1945 1945
 			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1946 1946
 			return FALSE;
1947 1947
 		}
1948
-		$this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID( $EVT_ID );
1948
+		$this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID);
1949 1949
 
1950 1950
 		//need to delete related tickets and prices first.
1951 1951
 		$datetimes = $this->_cpt_model_obj->get_many_related('Datetime');
1952
-		foreach ( $datetimes as $datetime ) {
1952
+		foreach ($datetimes as $datetime) {
1953 1953
 			$this->_cpt_model_obj->_remove_relation_to($datetime, 'Datetime');
1954 1954
 			$tickets = $datetime->get_many_related('Ticket');
1955
-			foreach ( $tickets as $ticket ) {
1955
+			foreach ($tickets as $ticket) {
1956 1956
 				$ticket->_remove_relation_to($datetime, 'Datetime');
1957 1957
 				$ticket->delete_related_permanently('Price');
1958 1958
 				$ticket->delete_permanently();
@@ -1962,14 +1962,14 @@  discard block
 block discarded – undo
1962 1962
 
1963 1963
 		//what about related venues or terms?
1964 1964
 		$venues = $this->_cpt_model_obj->get_many_related('Venue');
1965
-		foreach ( $venues as $venue ) {
1965
+		foreach ($venues as $venue) {
1966 1966
 			$this->_cpt_model_obj->_remove_relation_to($venue, 'Venue');
1967 1967
 		}
1968 1968
 
1969 1969
 		//any attached question groups?
1970 1970
 		$question_groups = $this->_cpt_model_obj->get_many_related('Question_Group');
1971
-		if ( !empty( $question_groups ) ) {
1972
-			foreach ( $question_groups as $question_group ) {
1971
+		if ( ! empty($question_groups)) {
1972
+			foreach ($question_groups as $question_group) {
1973 1973
 				$this->_cpt_model_obj->_remove_relation_to($question_group, 'Question_Group');
1974 1974
 			}
1975 1975
 		}
@@ -1978,12 +1978,12 @@  discard block
 block discarded – undo
1978 1978
 
1979 1979
 
1980 1980
 		//Message Template Groups
1981
-		$this->_cpt_model_obj->_remove_relations( 'Message_Template_Group' );
1981
+		$this->_cpt_model_obj->_remove_relations('Message_Template_Group');
1982 1982
 
1983 1983
 		/** @type EE_Term_Taxonomy[] $term_taxonomies */
1984 1984
 		$term_taxonomies = $this->_cpt_model_obj->term_taxonomies();
1985 1985
 
1986
-		foreach ( $term_taxonomies as $term_taxonomy ) {
1986
+		foreach ($term_taxonomies as $term_taxonomy) {
1987 1987
 			$this->_cpt_model_obj->remove_relation_to_term_taxonomy($term_taxonomy);
1988 1988
 		}
1989 1989
 
@@ -1997,7 +1997,7 @@  discard block
 block discarded – undo
1997 1997
 			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1998 1998
 			return FALSE;
1999 1999
 		}
2000
-		do_action( 'AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $EVT_ID );
2000
+		do_action('AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $EVT_ID);
2001 2001
 		return TRUE;
2002 2002
 	}
2003 2003
 
@@ -2014,7 +2014,7 @@  discard block
 block discarded – undo
2014 2014
 	 */
2015 2015
 	public function total_events() {
2016 2016
 
2017
-		$count = EEM_Event::instance()->count( array( 'caps' => 'read_admin' ), 'EVT_ID', true );
2017
+		$count = EEM_Event::instance()->count(array('caps' => 'read_admin'), 'EVT_ID', true);
2018 2018
 		return $count;
2019 2019
 	}
2020 2020
 
@@ -2029,10 +2029,10 @@  discard block
 block discarded – undo
2029 2029
 	 */
2030 2030
 	public function total_events_draft() {
2031 2031
 		$where = array(
2032
-			'status' => array( 'IN', array('draft', 'auto-draft' ) )
2032
+			'status' => array('IN', array('draft', 'auto-draft'))
2033 2033
 			);
2034 2034
 
2035
-		$count = EEM_Event::instance()->count( array( $where, 'caps' => 'read_admin' ), 'EVT_ID', true );
2035
+		$count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
2036 2036
 		return $count;
2037 2037
 	}
2038 2038
 
@@ -2051,7 +2051,7 @@  discard block
 block discarded – undo
2051 2051
 			'status' => 'trash'
2052 2052
 			);
2053 2053
 
2054
-		$count = EEM_Event::instance()->count( array( $where, 'caps' => 'read_admin' ), 'EVT_ID', true );
2054
+		$count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
2055 2055
 		return $count;
2056 2056
 	}
2057 2057
 
@@ -2079,11 +2079,11 @@  discard block
 block discarded – undo
2079 2079
 			// translated
2080 2080
 			TRUE
2081 2081
 		);
2082
-		$this->_template_args['default_reg_status'] = isset( EE_Registry::instance()->CFG->registration->default_STS_ID ) ? sanitize_text_field( EE_Registry::instance()->CFG->registration->default_STS_ID ) : EEM_Registration::status_id_pending_payment;
2082
+		$this->_template_args['default_reg_status'] = isset(EE_Registry::instance()->CFG->registration->default_STS_ID) ? sanitize_text_field(EE_Registry::instance()->CFG->registration->default_STS_ID) : EEM_Registration::status_id_pending_payment;
2083 2083
 
2084 2084
 		$this->_set_add_edit_form_tags('update_default_event_settings');
2085 2085
 		$this->_set_publish_post_box_vars(NULL, FALSE, FALSE, NULL, FALSE);
2086
-		$this->_template_args['admin_page_content'] = EEH_Template::display_template(EVENTS_TEMPLATE_PATH . 'event_settings.template.php', $this->_template_args, TRUE);
2086
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(EVENTS_TEMPLATE_PATH.'event_settings.template.php', $this->_template_args, TRUE);
2087 2087
 		$this->display_admin_page_with_sidebar();
2088 2088
 	}
2089 2089
 
@@ -2109,9 +2109,9 @@  discard block
 block discarded – undo
2109 2109
 
2110 2110
 	protected function _template_settings() {
2111 2111
 		$this->_admin_page_title = __('Template Settings (Preview)', 'event_espresso');
2112
-		$this->_template_args['preview_img'] = '<img src="' . EVENTS_ASSETS_URL . DS . 'images' . DS . 'caffeinated_template_features.jpg" alt="' . esc_attr__( 'Template Settings Preview screenshot', 'event_espresso' ) . '" />';
2113
-		$this->_template_args['preview_text'] = '<strong>'.__( 'Template Settings is a feature that is only available in the Caffeinated version of Event Espresso. Template Settings allow you to configure some of the appearance options for both the Event List and Event Details pages.', 'event_espresso' ).'</strong>';
2114
-		$this->display_admin_caf_preview_page( 'template_settings_tab' );
2112
+		$this->_template_args['preview_img'] = '<img src="'.EVENTS_ASSETS_URL.DS.'images'.DS.'caffeinated_template_features.jpg" alt="'.esc_attr__('Template Settings Preview screenshot', 'event_espresso').'" />';
2113
+		$this->_template_args['preview_text'] = '<strong>'.__('Template Settings is a feature that is only available in the Caffeinated version of Event Espresso. Template Settings allow you to configure some of the appearance options for both the Event List and Event Details pages.', 'event_espresso').'</strong>';
2114
+		$this->display_admin_caf_preview_page('template_settings_tab');
2115 2115
 	}
2116 2116
 
2117 2117
 
@@ -2124,22 +2124,22 @@  discard block
 block discarded – undo
2124 2124
 	 * @return void
2125 2125
 	 */
2126 2126
 	private function _set_category_object() {
2127
-		if ( isset( $this->_category->id ) && !empty( $this->_category->id ) )
2127
+		if (isset($this->_category->id) && ! empty($this->_category->id))
2128 2128
 			return; //already have the category object so get out.
2129 2129
 
2130 2130
 		//set default category object
2131 2131
 		$this->_set_empty_category_object();
2132 2132
 
2133 2133
 		//only set if we've got an id
2134
-		if ( !isset($this->_req_data['EVT_CAT_ID'] ) ) {
2134
+		if ( ! isset($this->_req_data['EVT_CAT_ID'])) {
2135 2135
 			return;
2136 2136
 		}
2137 2137
 
2138 2138
 		$category_id = absint($this->_req_data['EVT_CAT_ID']);
2139 2139
 
2140
-		$term = get_term( $category_id, 'espresso_event_categories' );
2140
+		$term = get_term($category_id, 'espresso_event_categories');
2141 2141
 
2142
-		if ( !empty( $term ) ) {
2142
+		if ( ! empty($term)) {
2143 2143
 			$this->_category->category_name = $term->name;
2144 2144
 			$this->_category->category_identifier = $term->slug;
2145 2145
 			$this->_category->category_desc = $term->description;
@@ -2153,13 +2153,13 @@  discard block
 block discarded – undo
2153 2153
 
2154 2154
 	private function _set_empty_category_object() {
2155 2155
 		$this->_category = new stdClass();
2156
-		$this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc  = '';
2156
+		$this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = '';
2157 2157
 		$this->_category->id = $this->_category->parent = 0;
2158 2158
 	}
2159 2159
 
2160 2160
 
2161 2161
 	protected function _category_list_table() {
2162
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
2162
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2163 2163
 		$this->_search_btn_label = __('Categories', 'event_espresso');
2164 2164
 		$this->_admin_page_title .= $this->get_action_link_or_button('add_category', 'add_category', array(), 'add-new-h2');
2165 2165
 		$this->display_admin_list_table_page_with_sidebar();
@@ -2169,22 +2169,22 @@  discard block
 block discarded – undo
2169 2169
 	protected function _category_details($view) {
2170 2170
 
2171 2171
 		//load formatter helper
2172
-		EE_Registry::instance()->load_helper( 'Formatter' );
2172
+		EE_Registry::instance()->load_helper('Formatter');
2173 2173
 		//load field generator helper
2174
-		EE_Registry::instance()->load_helper( 'Form_Fields' );
2174
+		EE_Registry::instance()->load_helper('Form_Fields');
2175 2175
 
2176 2176
 		$route = $view == 'edit' ? 'update_category' : 'insert_category';
2177 2177
 		$this->_set_add_edit_form_tags($route);
2178 2178
 
2179 2179
 		$this->_set_category_object();
2180
-		$id = !empty($this->_category->id) ? $this->_category->id : '';
2180
+		$id = ! empty($this->_category->id) ? $this->_category->id : '';
2181 2181
 
2182 2182
 		$delete_action = 'delete_category';
2183 2183
 
2184 2184
 		//custom redirect
2185
-		$redirect = EE_Admin_Page::add_query_args_and_nonce( array('action' => 'category_list'), $this->_admin_base_url );
2185
+		$redirect = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'category_list'), $this->_admin_base_url);
2186 2186
 
2187
-		$this->_set_publish_post_box_vars( 'EVT_CAT_ID', $id, $delete_action, $redirect );
2187
+		$this->_set_publish_post_box_vars('EVT_CAT_ID', $id, $delete_action, $redirect);
2188 2188
 
2189 2189
 		//take care of contents
2190 2190
 		$this->_template_args['admin_page_content'] = $this->_category_details_content();
@@ -2198,25 +2198,25 @@  discard block
 block discarded – undo
2198 2198
 			'type' => 'wp_editor',
2199 2199
 			'value' => EEH_Formatter::admin_format_content($this->_category->category_desc),
2200 2200
 			'class' => 'my_editor_custom',
2201
-			'wpeditor_args' => array('media_buttons' => FALSE )
2201
+			'wpeditor_args' => array('media_buttons' => FALSE)
2202 2202
 		);
2203
-		$_wp_editor = $this->_generate_admin_form_fields( $editor_args, 'array' );
2203
+		$_wp_editor = $this->_generate_admin_form_fields($editor_args, 'array');
2204 2204
 
2205
-		$all_terms = get_terms( array('espresso_event_categories' ), array( 'hide_empty' => 0, 'exclude' => array( $this->_category->id ) ) );
2205
+		$all_terms = get_terms(array('espresso_event_categories'), array('hide_empty' => 0, 'exclude' => array($this->_category->id)));
2206 2206
 
2207 2207
 		//setup category select for term parents.
2208 2208
 		$category_select_values[] = array(
2209 2209
 			'text' => __('No Parent', 'event_espresso'),
2210 2210
 			'id' => 0
2211 2211
 			);
2212
-		foreach ( $all_terms as $term ) {
2212
+		foreach ($all_terms as $term) {
2213 2213
 			$category_select_values[] = array(
2214 2214
 				'text' => $term->name,
2215 2215
 				'id' => $term->term_id
2216 2216
 				);
2217 2217
 		}
2218 2218
 
2219
-		$category_select = EEH_Form_Fields::select_input( 'category_parent', $category_select_values, $this->_category->parent );
2219
+		$category_select = EEH_Form_Fields::select_input('category_parent', $category_select_values, $this->_category->parent);
2220 2220
 
2221 2221
 		$template_args = array(
2222 2222
 			'category' => $this->_category,
@@ -2226,15 +2226,15 @@  discard block
 block discarded – undo
2226 2226
 			'disable' => '',
2227 2227
 			'disabled_message' => FALSE
2228 2228
 			);
2229
-		$template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php';
2230
-		return EEH_Template::display_template($template, $template_args, TRUE );
2229
+		$template = EVENTS_TEMPLATE_PATH.'event_category_details.template.php';
2230
+		return EEH_Template::display_template($template, $template_args, TRUE);
2231 2231
 	}
2232 2232
 
2233 2233
 
2234 2234
 	protected function _delete_categories() {
2235
-		$cat_ids = isset( $this->_req_data['EVT_CAT_ID'] ) ? (array) $this->_req_data['EVT_CAT_ID'] : (array) $this->_req_data['category_id'];
2235
+		$cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array) $this->_req_data['EVT_CAT_ID'] : (array) $this->_req_data['category_id'];
2236 2236
 
2237
-		foreach ( $cat_ids as $cat_id ) {
2237
+		foreach ($cat_ids as $cat_id) {
2238 2238
 			$this->_delete_category($cat_id);
2239 2239
 		}
2240 2240
 
@@ -2242,7 +2242,7 @@  discard block
 block discarded – undo
2242 2242
 		$query_args = array(
2243 2243
 			'action' => 'category_list'
2244 2244
 			);
2245
-		$this->_redirect_after_action(0,'','',$query_args);
2245
+		$this->_redirect_after_action(0, '', '', $query_args);
2246 2246
 
2247 2247
 	}
2248 2248
 
@@ -2252,61 +2252,61 @@  discard block
 block discarded – undo
2252 2252
 
2253 2253
 	protected function _delete_category($cat_id) {
2254 2254
 		global $wpdb;
2255
-		$cat_id = absint( $cat_id );
2256
-		wp_delete_term( $cat_id, 'espresso_event_categories' );
2255
+		$cat_id = absint($cat_id);
2256
+		wp_delete_term($cat_id, 'espresso_event_categories');
2257 2257
 	}
2258 2258
 
2259 2259
 
2260 2260
 
2261 2261
 	protected function _insert_or_update_category($new_category) {
2262 2262
 
2263
-		$cat_id = $new_category ? $this->_insert_category() : $this->_insert_category( TRUE );
2263
+		$cat_id = $new_category ? $this->_insert_category() : $this->_insert_category(TRUE);
2264 2264
 		$success = 0; //we already have a success message so lets not send another.
2265 2265
 
2266
-		if ( $cat_id ) {
2266
+		if ($cat_id) {
2267 2267
 			$query_args = array(
2268 2268
 				'action'     => 'edit_category',
2269 2269
 				'EVT_CAT_ID' => $cat_id
2270 2270
 			);
2271 2271
 		} else {
2272
-			$query_args = array( 'action' => 'add_category' );
2272
+			$query_args = array('action' => 'add_category');
2273 2273
 		}
2274
-		$this->_redirect_after_action( $success, '','', $query_args, TRUE );
2274
+		$this->_redirect_after_action($success, '', '', $query_args, TRUE);
2275 2275
 
2276 2276
 	}
2277 2277
 
2278 2278
 
2279 2279
 
2280
-	private function _insert_category( $update = FALSE ) {
2280
+	private function _insert_category($update = FALSE) {
2281 2281
 		$cat_id = $update ? $this->_req_data['EVT_CAT_ID'] : '';
2282
-		$category_name= isset( $this->_req_data['category_name'] ) ? $this->_req_data['category_name'] : '';
2283
-		$category_desc= isset( $this->_req_data['category_desc'] ) ? $this->_req_data['category_desc'] : '';
2284
-		$category_parent = isset( $this->_req_data['category_parent'] ) ? $this->_req_data['category_parent'] : 0;
2282
+		$category_name = isset($this->_req_data['category_name']) ? $this->_req_data['category_name'] : '';
2283
+		$category_desc = isset($this->_req_data['category_desc']) ? $this->_req_data['category_desc'] : '';
2284
+		$category_parent = isset($this->_req_data['category_parent']) ? $this->_req_data['category_parent'] : 0;
2285 2285
 
2286
-		if ( empty( $category_name ) ) {
2287
-			$msg = __( 'You must add a name for the category.', 'event_espresso' );
2288
-			EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
2286
+		if (empty($category_name)) {
2287
+			$msg = __('You must add a name for the category.', 'event_espresso');
2288
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2289 2289
 			return false;
2290 2290
 		}
2291 2291
 
2292
-		$term_args=array(
2292
+		$term_args = array(
2293 2293
 			'name'=>$category_name,
2294 2294
 			'description'=>$category_desc,
2295 2295
 			'parent'=>$category_parent
2296 2296
 		);
2297 2297
 		//was the category_identifier input disabled?
2298
-		if(isset($this->_req_data['category_identifier'])){
2298
+		if (isset($this->_req_data['category_identifier'])) {
2299 2299
 			$term_args['slug'] = $this->_req_data['category_identifier'];
2300 2300
 		}
2301
-		$insert_ids = $update ? wp_update_term( $cat_id, 'espresso_event_categories', $term_args ) :wp_insert_term( $category_name, 'espresso_event_categories', $term_args );
2301
+		$insert_ids = $update ? wp_update_term($cat_id, 'espresso_event_categories', $term_args) : wp_insert_term($category_name, 'espresso_event_categories', $term_args);
2302 2302
 
2303
-		if ( !is_array( $insert_ids ) ) {
2304
-			$msg = __( 'An error occurred and the category has not been saved to the database.', 'event_espresso' );
2305
-			EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
2303
+		if ( ! is_array($insert_ids)) {
2304
+			$msg = __('An error occurred and the category has not been saved to the database.', 'event_espresso');
2305
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2306 2306
 		} else {
2307 2307
 			$cat_id = $insert_ids['term_id'];
2308
-			$msg = sprintf ( __('The category %s was successfuly saved', 'event_espresso'), $category_name );
2309
-			EE_Error::add_success( $msg );
2308
+			$msg = sprintf(__('The category %s was successfuly saved', 'event_espresso'), $category_name);
2309
+			EE_Error::add_success($msg);
2310 2310
 		}
2311 2311
 
2312 2312
 		return $cat_id;
@@ -2315,32 +2315,32 @@  discard block
 block discarded – undo
2315 2315
 
2316 2316
 
2317 2317
 
2318
-	public function get_categories( $per_page = 10, $current_page = 1, $count = FALSE ) {
2318
+	public function get_categories($per_page = 10, $current_page = 1, $count = FALSE) {
2319 2319
 		global $wpdb;
2320 2320
 
2321 2321
 		//testing term stuff
2322
-		$orderby = isset( $this->_req_data['orderby'] ) ? $this->_req_data['orderby'] : 'Term.term_id';
2323
-		$order = isset( $this->_req_data['order'] ) ? $this->_req_data['order'] : 'DESC';
2324
-		$limit = ($current_page-1)*$per_page;
2322
+		$orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'Term.term_id';
2323
+		$order = isset($this->_req_data['order']) ? $this->_req_data['order'] : 'DESC';
2324
+		$limit = ($current_page - 1) * $per_page;
2325 2325
 
2326
-		$where = array( 'taxonomy' => 'espresso_event_categories' );
2326
+		$where = array('taxonomy' => 'espresso_event_categories');
2327 2327
 
2328
-		if ( isset( $this->_req_data['s'] ) ) {
2329
-			$sstr = '%' . $this->_req_data['s'] . '%';
2328
+		if (isset($this->_req_data['s'])) {
2329
+			$sstr = '%'.$this->_req_data['s'].'%';
2330 2330
 			$where['OR'] = array(
2331
-				'Term.name' => array( 'LIKE', $sstr),
2332
-				'description' => array( 'LIKE', $sstr )
2331
+				'Term.name' => array('LIKE', $sstr),
2332
+				'description' => array('LIKE', $sstr)
2333 2333
 				);
2334 2334
 		}
2335 2335
 
2336 2336
 		$query_params = array(
2337
-			$where ,
2338
-			'order_by' => array( $orderby => $order ),
2339
-			'limit' => $limit . ',' . $per_page,
2337
+			$where,
2338
+			'order_by' => array($orderby => $order),
2339
+			'limit' => $limit.','.$per_page,
2340 2340
 			'force_join' => array('Term')
2341 2341
 			);
2342 2342
 
2343
-		$categories = $count ? EEM_Term_Taxonomy::instance()->count( $query_params, 'term_id' ) :EEM_Term_Taxonomy::instance()->get_all( $query_params );
2343
+		$categories = $count ? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id') : EEM_Term_Taxonomy::instance()->get_all($query_params);
2344 2344
 
2345 2345
 		return $categories;
2346 2346
 	}
Please login to merge, or discard this patch.
admin_pages/payments/Payments_Admin_Page.core.php 1 patch
Spacing   +168 added lines, -168 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
 /**
@@ -44,8 +44,8 @@  discard block
 block discarded – undo
44 44
 	 * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
45 45
 	 * @return \Payments_Admin_Page
46 46
 	 */
47
-	public function __construct( $routing = TRUE ) {
48
-		parent::__construct( $routing );
47
+	public function __construct($routing = TRUE) {
48
+		parent::__construct($routing);
49 49
 	}
50 50
 
51 51
 
@@ -130,19 +130,19 @@  discard block
 block discarded – undo
130 130
 	protected function _set_page_config() {
131 131
 		$payment_method_list_config = array(
132 132
 			'nav'           => array(
133
-				'label' => __( 'Payment Methods', 'event_espresso' ),
133
+				'label' => __('Payment Methods', 'event_espresso'),
134 134
 				'order' => 10
135 135
 			),
136 136
 			'metaboxes'     => $this->_default_espresso_metaboxes,
137 137
 			'help_tabs'     => array_merge(
138 138
 				array(
139 139
 					'payment_methods_overview_help_tab' => array(
140
-						'title'    => __( 'Payment Methods Overview', 'event_espresso' ),
140
+						'title'    => __('Payment Methods Overview', 'event_espresso'),
141 141
 						'filename' => 'payment_methods_overview'
142 142
 					)
143 143
 				),
144 144
 				$this->_add_payment_method_help_tabs() ),
145
-			'help_tour'     => array( 'Payment_Methods_Selection_Help_Tour' ),
145
+			'help_tour'     => array('Payment_Methods_Selection_Help_Tour'),
146 146
 			'require_nonce' => false
147 147
 		);
148 148
 
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 					)
161 161
 				),
162 162
 				//'help_tour' => array( 'Payment_Methods_Settings_Help_Tour' ),
163
-				'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array( '_publish_post_box' ) ),
163
+				'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
164 164
 				'require_nonce' => FALSE
165 165
 			),
166 166
 			'payment_log'=>array(
@@ -179,17 +179,17 @@  discard block
 block discarded – undo
179 179
 	/**
180 180
 	 * @return array
181 181
 	 */
182
-	protected function _add_payment_method_help_tabs(){
182
+	protected function _add_payment_method_help_tabs() {
183 183
 		EE_Registry::instance()->load_lib('Payment_Method_Manager');
184 184
 		$payment_method_types = EE_Payment_Method_Manager::instance()->payment_method_types();
185 185
 		$all_pmt_help_tabs_config = array();
186
-		foreach( $payment_method_types as $payment_method_type ){
187
-			if ( ! EE_Registry::instance()->CAP->current_user_can( $payment_method_type->cap_name(), 'specific_payment_method_type_access' ) ) {
186
+		foreach ($payment_method_types as $payment_method_type) {
187
+			if ( ! EE_Registry::instance()->CAP->current_user_can($payment_method_type->cap_name(), 'specific_payment_method_type_access')) {
188 188
 				continue;
189 189
 			}
190
-			foreach( $payment_method_type->help_tabs_config() as $help_tab_name => $config ){
191
-				$template_args = isset( $config[ 'template_args' ] ) ? $config[ 'template_args' ] : array();
192
-				$template_args[ 'admin_page_obj' ] = $this;
190
+			foreach ($payment_method_type->help_tabs_config() as $help_tab_name => $config) {
191
+				$template_args = isset($config['template_args']) ? $config['template_args'] : array();
192
+				$template_args['admin_page_obj'] = $this;
193 193
 				$all_pmt_help_tabs_config[$help_tab_name] = array(
194 194
 					'title'=>$config['title'],
195 195
 					'content'=>EEH_Template::display_template( 
@@ -216,9 +216,9 @@  discard block
 block discarded – undo
216 216
 
217 217
 
218 218
 	public function load_scripts_styles() {
219
-		wp_enqueue_script( 'ee_admin_js' );
220
-		wp_enqueue_script( 'ee-text-links' );
221
-		wp_enqueue_script( 'espresso_payments', EE_PAYMENTS_ASSETS_URL . 'espresso_payments_admin.js', array( 'espresso-ui-theme', 'ee-datepicker' ), EVENT_ESPRESSO_VERSION, TRUE );
219
+		wp_enqueue_script('ee_admin_js');
220
+		wp_enqueue_script('ee-text-links');
221
+		wp_enqueue_script('espresso_payments', EE_PAYMENTS_ASSETS_URL.'espresso_payments_admin.js', array('espresso-ui-theme', 'ee-datepicker'), EVENT_ESPRESSO_VERSION, TRUE);
222 222
 	}
223 223
 
224 224
 
@@ -227,9 +227,9 @@  discard block
 block discarded – undo
227 227
 
228 228
 	public function load_scripts_styles_default() {
229 229
 		//styles
230
-		wp_register_style( 'espresso_payments', EE_PAYMENTS_ASSETS_URL . 'ee-payments.css', array(), EVENT_ESPRESSO_VERSION );
231
-		wp_enqueue_style( 'espresso_payments' );
232
-		wp_enqueue_style( 'ee-text-links' );
230
+		wp_register_style('espresso_payments', EE_PAYMENTS_ASSETS_URL.'ee-payments.css', array(), EVENT_ESPRESSO_VERSION);
231
+		wp_enqueue_style('espresso_payments');
232
+		wp_enqueue_style('ee-text-links');
233 233
 		//scripts
234 234
 	}
235 235
 
@@ -243,46 +243,46 @@  discard block
 block discarded – undo
243 243
 		 * to the loading process.  However, people MUST setup the details for the payment method so its safe to do a
244 244
 		 * recheck here.
245 245
 		 */
246
-		EE_Registry::instance()->load_lib( 'Payment_Method_Manager' );
246
+		EE_Registry::instance()->load_lib('Payment_Method_Manager');
247 247
 		EEM_Payment_Method::instance()->verify_button_urls();
248
-		EE_Registry::instance()->load_helper( 'Tabbed_Content' );
249
-		EE_Registry::instance()->load_helper( 'HTML' );
248
+		EE_Registry::instance()->load_helper('Tabbed_Content');
249
+		EE_Registry::instance()->load_helper('HTML');
250 250
 		//setup tabs, one for each payment method type
251 251
 		$tabs = array();
252 252
 		$payment_methods = array();
253
-		foreach( EE_Payment_Method_Manager::instance()->payment_method_types() as $pmt_obj ) {
253
+		foreach (EE_Payment_Method_Manager::instance()->payment_method_types() as $pmt_obj) {
254 254
 			// we don't want to show admin-only PMTs for now
255
-			if ( $pmt_obj instanceof EE_PMT_Admin_Only ) {
255
+			if ($pmt_obj instanceof EE_PMT_Admin_Only) {
256 256
 				continue;
257 257
 			}
258 258
 			//check access
259
-			if ( ! EE_Registry::instance()->CAP->current_user_can( $pmt_obj->cap_name(), 'specific_payment_method_type_access' ) ) {
259
+			if ( ! EE_Registry::instance()->CAP->current_user_can($pmt_obj->cap_name(), 'specific_payment_method_type_access')) {
260 260
 				continue;
261 261
 			}
262 262
 			//check for any active pms of that type
263
-			$payment_method = EEM_Payment_Method::instance()->get_one_of_type( $pmt_obj->system_name() );
264
-			if ( ! $payment_method instanceof EE_Payment_Method ) {
263
+			$payment_method = EEM_Payment_Method::instance()->get_one_of_type($pmt_obj->system_name());
264
+			if ( ! $payment_method instanceof EE_Payment_Method) {
265 265
 				$payment_method = EE_Payment_Method::new_instance(
266 266
 					array(
267
-						'PMD_slug'					=>sanitize_key( $pmt_obj->system_name() ),
267
+						'PMD_slug'					=>sanitize_key($pmt_obj->system_name()),
268 268
 						'PMD_type'					=>$pmt_obj->system_name(),
269 269
 						'PMD_name'				=>$pmt_obj->pretty_name(),
270 270
 						'PMD_admin_name'	=>$pmt_obj->pretty_name()
271 271
 					)
272 272
 				);
273 273
 			}
274
-			$payment_methods[ $payment_method->slug() ] = $payment_method;
274
+			$payment_methods[$payment_method->slug()] = $payment_method;
275 275
 		}
276
-		$payment_methods = apply_filters( 'FHEE__Payments_Admin_Page___payment_methods_list__payment_methods', $payment_methods );
277
-		foreach( $payment_methods as $payment_method ) {
278
-			if ( $payment_method instanceof EE_Payment_Method ) {
276
+		$payment_methods = apply_filters('FHEE__Payments_Admin_Page___payment_methods_list__payment_methods', $payment_methods);
277
+		foreach ($payment_methods as $payment_method) {
278
+			if ($payment_method instanceof EE_Payment_Method) {
279 279
 				add_meta_box(
280 280
 					//html id
281
-					'espresso_' . $payment_method->slug() . '_payment_settings',
281
+					'espresso_'.$payment_method->slug().'_payment_settings',
282 282
 					//title
283
-					sprintf( __( '%s Settings', 'event_espresso' ), $payment_method->admin_name() ),
283
+					sprintf(__('%s Settings', 'event_espresso'), $payment_method->admin_name()),
284 284
 					//callback
285
-					array( $this, 'payment_method_settings_meta_box' ),
285
+					array($this, 'payment_method_settings_meta_box'),
286 286
 					//post type
287 287
 					null,
288 288
 					//context
@@ -290,19 +290,19 @@  discard block
 block discarded – undo
290 290
 					//priority
291 291
 					'default',
292 292
 					//callback args
293
-					array( 'payment_method' => $payment_method )
293
+					array('payment_method' => $payment_method)
294 294
 				);
295 295
 				//setup for tabbed content
296
-				$tabs[ $payment_method->slug() ] = array(
296
+				$tabs[$payment_method->slug()] = array(
297 297
 					'label' => $payment_method->admin_name(),
298 298
 					'class' => $payment_method->active() ? 'gateway-active' : '',
299
-					'href'  => 'espresso_' . $payment_method->slug() . '_payment_settings',
300
-					'title' => __( 'Modify this Payment Method', 'event_espresso' ),
299
+					'href'  => 'espresso_'.$payment_method->slug().'_payment_settings',
300
+					'title' => __('Modify this Payment Method', 'event_espresso'),
301 301
 					'slug'  => $payment_method->slug()
302 302
 				);
303 303
 			}
304 304
 		}
305
-		$this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links( $tabs, 'payment_method_links', '|', $this->_get_active_payment_method_slug() );
305
+		$this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links($tabs, 'payment_method_links', '|', $this->_get_active_payment_method_slug());
306 306
 		$this->display_admin_page_with_sidebar();
307 307
 
308 308
 	}
@@ -313,20 +313,20 @@  discard block
 block discarded – undo
313 313
 	 *   _get_active_payment_method_slug
314 314
 	 * 	@return string
315 315
 	 */
316
-	protected function _get_active_payment_method_slug(){
316
+	protected function _get_active_payment_method_slug() {
317 317
 		$payment_method_slug = FALSE;
318 318
 		//decide which payment method tab to open first, as dictated by the request's 'payment_method'
319
-		if ( isset( $this->_req_data['payment_method'] )) {
319
+		if (isset($this->_req_data['payment_method'])) {
320 320
 			// if they provided the current payment method, use it
321
-			$payment_method_slug = sanitize_key( $this->_req_data['payment_method'] );
321
+			$payment_method_slug = sanitize_key($this->_req_data['payment_method']);
322 322
 		}
323
-		$payment_method = EEM_Payment_Method::instance()->get_one( array( array( 'PMD_slug' => $payment_method_slug )));
323
+		$payment_method = EEM_Payment_Method::instance()->get_one(array(array('PMD_slug' => $payment_method_slug)));
324 324
 		// if that didn't work or wasn't provided, find another way to select the current pm
325
-		if ( ! $this->_verify_payment_method( $payment_method )) {
325
+		if ( ! $this->_verify_payment_method($payment_method)) {
326 326
 			// like, looking for an active one
327
-			$payment_method = EEM_Payment_Method::instance()->get_one_active( 'CART' );
327
+			$payment_method = EEM_Payment_Method::instance()->get_one_active('CART');
328 328
 			// test that one as well
329
-			if ( $this->_verify_payment_method( $payment_method )) {
329
+			if ($this->_verify_payment_method($payment_method)) {
330 330
 				$payment_method_slug = $payment_method->slug();
331 331
 			} else {
332 332
 				$payment_method_slug = 'paypal_standard';
@@ -344,11 +344,11 @@  discard block
 block discarded – undo
344 344
 	 * @param \EE_Payment_Method $payment_method
345 345
 	 * @return boolean
346 346
 	 */
347
-	protected function _verify_payment_method( $payment_method ){
347
+	protected function _verify_payment_method($payment_method) {
348 348
 		if (
349 349
 			$payment_method instanceof EE_Payment_Method &&
350 350
 			$payment_method->type_obj() instanceof EE_PMT_Base &&
351
-			EE_Registry::instance()->CAP->current_user_can( $payment_method->type_obj()->cap_name(), 'specific_payment_method_type_access' )
351
+			EE_Registry::instance()->CAP->current_user_can($payment_method->type_obj()->cap_name(), 'specific_payment_method_type_access')
352 352
 		) {
353 353
 			return TRUE;
354 354
 		}
@@ -365,21 +365,21 @@  discard block
 block discarded – undo
365 365
 	 * @return string
366 366
 	 * @throws EE_Error
367 367
 	 */
368
-	public function payment_method_settings_meta_box( $post_obj_which_is_null, $metabox ){
369
-		$payment_method = isset( $metabox['args'], $metabox['args']['payment_method'] ) ? $metabox['args']['payment_method'] : NULL;
370
-		if ( ! $payment_method instanceof EE_Payment_Method ){
371
-			throw new EE_Error( sprintf( __( 'Payment method metabox setup incorrectly. No Payment method object was supplied', 'event_espresso' )));
368
+	public function payment_method_settings_meta_box($post_obj_which_is_null, $metabox) {
369
+		$payment_method = isset($metabox['args'], $metabox['args']['payment_method']) ? $metabox['args']['payment_method'] : NULL;
370
+		if ( ! $payment_method instanceof EE_Payment_Method) {
371
+			throw new EE_Error(sprintf(__('Payment method metabox setup incorrectly. No Payment method object was supplied', 'event_espresso')));
372 372
 		}
373 373
 		$payment_method_scopes = $payment_method->active();
374 374
 		// if the payment method really exists show its form, otherwise the activation template
375
-		if ( $payment_method->ID() && ! empty( $payment_method_scopes )) {
376
-				$form = $this->_generate_payment_method_settings_form( $payment_method );
377
-				if ( $form->form_data_present_in( $this->_req_data )) {
378
-					$form->receive_form_submission( $this->_req_data );
375
+		if ($payment_method->ID() && ! empty($payment_method_scopes)) {
376
+				$form = $this->_generate_payment_method_settings_form($payment_method);
377
+				if ($form->form_data_present_in($this->_req_data)) {
378
+					$form->receive_form_submission($this->_req_data);
379 379
 				}
380
-				echo $form->form_open() . $form->get_html_and_js() . $form->form_close();
380
+				echo $form->form_open().$form->get_html_and_js().$form->form_close();
381 381
 		} else {
382
-			echo $this->_activate_payment_method_button( $payment_method )->get_html_and_js();
382
+			echo $this->_activate_payment_method_button($payment_method)->get_html_and_js();
383 383
 		}
384 384
 	}
385 385
 
@@ -392,14 +392,14 @@  discard block
 block discarded – undo
392 392
 	 * @param \EE_Payment_Method $payment_method
393 393
 	 * @return \EE_Form_Section_Proper
394 394
 	 */
395
-	protected function _generate_payment_method_settings_form( EE_Payment_Method $payment_method ) {
396
-		if ( ! $payment_method instanceof EE_Payment_Method ){
395
+	protected function _generate_payment_method_settings_form(EE_Payment_Method $payment_method) {
396
+		if ( ! $payment_method instanceof EE_Payment_Method) {
397 397
 			return new EE_Form_Section_Proper();
398 398
 		}
399 399
 		return new EE_Form_Section_Proper(
400 400
 			array(
401
-				'name' 	=> $payment_method->slug() . '_settings_form',
402
-				'html_id' 	=> $payment_method->slug() . '_settings_form',
401
+				'name' 	=> $payment_method->slug().'_settings_form',
402
+				'html_id' 	=> $payment_method->slug().'_settings_form',
403 403
 				'action' 	=> EE_Admin_Page::add_query_args_and_nonce(
404 404
 					array(
405 405
 						'action' 						=> 'update_payment_method',
@@ -411,12 +411,12 @@  discard block
 block discarded – undo
411 411
 				'subsections' 			=> apply_filters(
412 412
 					'FHEE__Payments_Admin_Page___generate_payment_method_settings_form__form_subsections',
413 413
 					array(
414
-						'pci_dss_compliance_' . $payment_method->slug() 				=> $this->_pci_dss_compliance( $payment_method ),
415
-						'currency_support_' . $payment_method->slug()					=> $this->_currency_support( $payment_method ),
416
-						'payment_method_settings_' . $payment_method->slug() 	=> $this->_payment_method_settings( $payment_method ),
417
-						'update_' . $payment_method->slug()										=> $this->_update_payment_method_button( $payment_method ),
418
-						'deactivate_' . $payment_method->slug()								=> $this->_deactivate_payment_method_button( $payment_method ),
419
-						'fine_print_' . $payment_method->slug()									=> $this->_fine_print()
414
+						'pci_dss_compliance_'.$payment_method->slug() 				=> $this->_pci_dss_compliance($payment_method),
415
+						'currency_support_'.$payment_method->slug()					=> $this->_currency_support($payment_method),
416
+						'payment_method_settings_'.$payment_method->slug() 	=> $this->_payment_method_settings($payment_method),
417
+						'update_'.$payment_method->slug()										=> $this->_update_payment_method_button($payment_method),
418
+						'deactivate_'.$payment_method->slug()								=> $this->_deactivate_payment_method_button($payment_method),
419
+						'fine_print_'.$payment_method->slug()									=> $this->_fine_print()
420 420
 					),
421 421
 					$payment_method
422 422
 				)
@@ -433,19 +433,19 @@  discard block
 block discarded – undo
433 433
 	 * @param \EE_Payment_Method $payment_method
434 434
 	 * @return \EE_Form_Section_Proper
435 435
 	 */
436
-	protected function _pci_dss_compliance( EE_Payment_Method $payment_method ) {
437
-		if ( $payment_method->type_obj()->requires_https() ) {
436
+	protected function _pci_dss_compliance(EE_Payment_Method $payment_method) {
437
+		if ($payment_method->type_obj()->requires_https()) {
438 438
 			return new EE_Form_Section_HTML(
439 439
 				EEH_HTML::tr(
440 440
 					EEH_HTML::th(
441 441
 						EEH_HTML::label(
442
-							EEH_HTML::strong( __( 'IMPORTANT', 'event_espresso' ), '', 'important-notice' )
442
+							EEH_HTML::strong(__('IMPORTANT', 'event_espresso'), '', 'important-notice')
443 443
 						)
444
-					) .
444
+					).
445 445
 					EEH_HTML::td(
446
-						EEH_HTML::strong( __( 'You are responsible for your own website security and Payment Card Industry Data Security Standards (PCI DSS) compliance.', 'event_espresso' )) .
447
-						EEH_HTML::br() .
448
-						__( 'Learn more about ', 'event_espresso' ) . EEH_HTML::link( 'https://www.pcisecuritystandards.org/merchants/index.php', __( 'PCI DSS compliance', 'event_espresso' ))
446
+						EEH_HTML::strong(__('You are responsible for your own website security and Payment Card Industry Data Security Standards (PCI DSS) compliance.', 'event_espresso')).
447
+						EEH_HTML::br().
448
+						__('Learn more about ', 'event_espresso').EEH_HTML::link('https://www.pcisecuritystandards.org/merchants/index.php', __('PCI DSS compliance', 'event_espresso'))
449 449
 					)
450 450
 				)
451 451
 			);
@@ -463,19 +463,19 @@  discard block
 block discarded – undo
463 463
 	 * @param \EE_Payment_Method $payment_method
464 464
 	 * @return \EE_Form_Section_Proper
465 465
 	 */
466
-	protected function _currency_support( EE_Payment_Method $payment_method ) {
467
-		if ( ! $payment_method->usable_for_currency( EE_Config::instance()->currency->code )) {
466
+	protected function _currency_support(EE_Payment_Method $payment_method) {
467
+		if ( ! $payment_method->usable_for_currency(EE_Config::instance()->currency->code)) {
468 468
 			return new EE_Form_Section_HTML(
469 469
 				EEH_HTML::tr(
470 470
 					EEH_HTML::th(
471 471
 						EEH_HTML::label(
472
-							EEH_HTML::strong( __( 'IMPORTANT', 'event_espresso' ), '', 'important-notice' )
472
+							EEH_HTML::strong(__('IMPORTANT', 'event_espresso'), '', 'important-notice')
473 473
 						)
474
-					) .
474
+					).
475 475
 					EEH_HTML::td(
476 476
 						EEH_HTML::strong(
477 477
 							sprintf(
478
-								__( 'This payment method does not support the currency set on your site (%1$s) and so will not appear as a payment option to registrants. Please activate a different payment method or change your site\'s country and associated currency.', 'event_espresso'),
478
+								__('This payment method does not support the currency set on your site (%1$s) and so will not appear as a payment option to registrants. Please activate a different payment method or change your site\'s country and associated currency.', 'event_espresso'),
479 479
 								EE_Config::instance()->currency->code
480 480
 							)
481 481
 						)
@@ -495,9 +495,9 @@  discard block
 block discarded – undo
495 495
 	 * @param \EE_Payment_Method $payment_method
496 496
 	 * @return \EE_Form_Section_HTML
497 497
 	 */
498
-	protected function _payment_method_settings( EE_Payment_Method $payment_method ) {
498
+	protected function _payment_method_settings(EE_Payment_Method $payment_method) {
499 499
 		//modify the form so we only have/show fields that will be implemented for this version
500
-		return $this->_simplify_form( $payment_method->type_obj()->settings_form(), $payment_method->name() );
500
+		return $this->_simplify_form($payment_method->type_obj()->settings_form(), $payment_method->name());
501 501
 	}
502 502
 
503 503
 
@@ -510,8 +510,8 @@  discard block
 block discarded – undo
510 510
 	 * @return \EE_Payment_Method_Form
511 511
 	 * @throws \EE_Error
512 512
 	 */
513
-	protected function _simplify_form( $form_section, $payment_method_name = '' ){
514
-		if ( $form_section instanceof EE_Payment_Method_Form ) {
513
+	protected function _simplify_form($form_section, $payment_method_name = '') {
514
+		if ($form_section instanceof EE_Payment_Method_Form) {
515 515
 			$form_section->exclude(
516 516
 				array(
517 517
 					'PMD_type', //dont want them changing the type
@@ -522,7 +522,7 @@  discard block
 block discarded – undo
522 522
 			);
523 523
 			return $form_section;
524 524
 		} else {
525
-			throw new EE_Error( sprintf( __( 'The EE_Payment_Method_Form for the "%1$s" payment method is missing or invalid.', 'event_espresso' ), $payment_method_name ));
525
+			throw new EE_Error(sprintf(__('The EE_Payment_Method_Form for the "%1$s" payment method is missing or invalid.', 'event_espresso'), $payment_method_name));
526 526
 		}
527 527
 	}
528 528
 
@@ -535,18 +535,18 @@  discard block
 block discarded – undo
535 535
 	 * @param \EE_Payment_Method $payment_method
536 536
 	 * @return \EE_Form_Section_HTML
537 537
 	 */
538
-	protected function _update_payment_method_button( EE_Payment_Method $payment_method ) {
538
+	protected function _update_payment_method_button(EE_Payment_Method $payment_method) {
539 539
 		$update_button = new EE_Submit_Input(
540 540
 			array(
541
-				'html_id' 		=> 'save_' . $payment_method->slug() . '_settings',
542
-				'default' 		=> sprintf( __( 'Update %s Payment Settings', 'event_espresso' ), $payment_method->admin_name() ),
541
+				'html_id' 		=> 'save_'.$payment_method->slug().'_settings',
542
+				'default' 		=> sprintf(__('Update %s Payment Settings', 'event_espresso'), $payment_method->admin_name()),
543 543
 				'html_label' => EEH_HTML::nbsp()
544 544
 			)
545 545
 		);
546 546
 		return new EE_Form_Section_HTML(
547
-			EEH_HTML::no_row( EEH_HTML::br(2) ) .
547
+			EEH_HTML::no_row(EEH_HTML::br(2)).
548 548
 			EEH_HTML::tr(
549
-				EEH_HTML::th( __( 'Update Settings', 'event_espresso') ) .
549
+				EEH_HTML::th(__('Update Settings', 'event_espresso')).
550 550
 				EEH_HTML::td(
551 551
 					$update_button->get_html_for_input()
552 552
 				)
@@ -563,11 +563,11 @@  discard block
 block discarded – undo
563 563
 	 * @param \EE_Payment_Method $payment_method
564 564
 	 * @return \EE_Form_Section_Proper
565 565
 	 */
566
-	protected function _deactivate_payment_method_button( EE_Payment_Method $payment_method ) {
567
-		$link_text_and_title = sprintf( __( 'Deactivate %1$s Payments?', 'event_espresso'), $payment_method->admin_name() );
566
+	protected function _deactivate_payment_method_button(EE_Payment_Method $payment_method) {
567
+		$link_text_and_title = sprintf(__('Deactivate %1$s Payments?', 'event_espresso'), $payment_method->admin_name());
568 568
 		return new EE_Form_Section_HTML(
569 569
 			EEH_HTML::tr(
570
-				EEH_HTML::th( __( 'Deactivate Payment Method', 'event_espresso') ) .
570
+				EEH_HTML::th(__('Deactivate Payment Method', 'event_espresso')).
571 571
 				EEH_HTML::td(
572 572
 					EEH_HTML::link(
573 573
 						EE_Admin_Page::add_query_args_and_nonce(
@@ -579,7 +579,7 @@  discard block
 block discarded – undo
579 579
 						),
580 580
 						$link_text_and_title,
581 581
 						$link_text_and_title,
582
-						'deactivate_' . $payment_method->slug(),
582
+						'deactivate_'.$payment_method->slug(),
583 583
 						'espresso-button button-secondary'
584 584
 					)
585 585
 				)
@@ -595,12 +595,12 @@  discard block
 block discarded – undo
595 595
 	 * @param \EE_Payment_Method $payment_method
596 596
 	 * @return \EE_Form_Section_Proper
597 597
 	 */
598
-	protected function _activate_payment_method_button( EE_Payment_Method $payment_method ) {
599
-		$link_text_and_title = sprintf( __( 'Activate %1$s Payment Method?', 'event_espresso'), $payment_method->admin_name() );
598
+	protected function _activate_payment_method_button(EE_Payment_Method $payment_method) {
599
+		$link_text_and_title = sprintf(__('Activate %1$s Payment Method?', 'event_espresso'), $payment_method->admin_name());
600 600
 		return new EE_Form_Section_Proper(
601 601
 			array(
602
-				'name' 	=> 'activate_' . $payment_method->slug() . '_settings_form',
603
-				'html_id' 	=> 'activate_' . $payment_method->slug() . '_settings_form',
602
+				'name' 	=> 'activate_'.$payment_method->slug().'_settings_form',
603
+				'html_id' 	=> 'activate_'.$payment_method->slug().'_settings_form',
604 604
 				'action' 	=> '#',
605 605
 				'layout_strategy'		=> new EE_Admin_Two_Column_Layout(),
606 606
 				'subsections' 			=> apply_filters(
@@ -609,8 +609,8 @@  discard block
 block discarded – undo
609 609
 						new EE_Form_Section_HTML(
610 610
 							EEH_HTML::tr(
611 611
 								EEH_HTML::th(
612
-									EEH_HTML::label( __( 'Click to Activate ', 'event_espresso' ))
613
-								) .
612
+									EEH_HTML::label(__('Click to Activate ', 'event_espresso'))
613
+								).
614 614
 								EEH_HTML::td(
615 615
 									EEH_HTML::link(
616 616
 										EE_Admin_Page::add_query_args_and_nonce(
@@ -622,7 +622,7 @@  discard block
 block discarded – undo
622 622
 										),
623 623
 										$link_text_and_title,
624 624
 										$link_text_and_title,
625
-										'activate_' . $payment_method->slug(),
625
+										'activate_'.$payment_method->slug(),
626 626
 										'espresso-button-green button-primary'
627 627
 									)
628 628
 								)
@@ -644,9 +644,9 @@  discard block
 block discarded – undo
644 644
 	protected function _fine_print() {
645 645
 		return new EE_Form_Section_HTML(
646 646
 			EEH_HTML::tr(
647
-				EEH_HTML::th() .
647
+				EEH_HTML::th().
648 648
 				EEH_HTML::td(
649
-					EEH_HTML::p( __( 'All fields marked with a * are required fields', 'event_espresso' ), '', 'grey-text' )
649
+					EEH_HTML::p(__('All fields marked with a * are required fields', 'event_espresso'), '', 'grey-text')
650 650
 				)
651 651
 			)
652 652
 		);
@@ -658,15 +658,15 @@  discard block
 block discarded – undo
658 658
 	 * Activates a payment method of that type. Mostly assuming there is only 1 of that type (or none so far)
659 659
 	 * @global WP_User $current_user
660 660
 	 */
661
-	protected function _activate_payment_method(){
662
-		if(isset($this->_req_data['payment_method_type'])){
661
+	protected function _activate_payment_method() {
662
+		if (isset($this->_req_data['payment_method_type'])) {
663 663
 			$payment_method_type = sanitize_text_field($this->_req_data['payment_method_type']);
664 664
 			//see if one exists
665
-			EE_Registry::instance()->load_lib( 'Payment_Method_Manager' );
666
-			$payment_method = EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type( $payment_method_type );
665
+			EE_Registry::instance()->load_lib('Payment_Method_Manager');
666
+			$payment_method = EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type($payment_method_type);
667 667
 
668
-			$this->_redirect_after_action(1, 'Payment Method', 'activated', array('action' => 'default','payment_method'=>$payment_method->slug()));
669
-		}else{
668
+			$this->_redirect_after_action(1, 'Payment Method', 'activated', array('action' => 'default', 'payment_method'=>$payment_method->slug()));
669
+		} else {
670 670
 			$this->_redirect_after_action(FALSE, 'Payment Method', 'activated', array('action' => 'default'));
671 671
 		}
672 672
 	}
@@ -674,14 +674,14 @@  discard block
 block discarded – undo
674 674
 	/**
675 675
 	 * Deactivates the payment method with the specified slug, and redirects.
676 676
 	 */
677
-	protected function _deactivate_payment_method(){
678
-		if(isset($this->_req_data['payment_method'])){
677
+	protected function _deactivate_payment_method() {
678
+		if (isset($this->_req_data['payment_method'])) {
679 679
 			$payment_method_slug = sanitize_key($this->_req_data['payment_method']);
680 680
 			//deactivate it
681 681
 			EE_Registry::instance()->load_lib('Payment_Method_Manager');
682
-			$count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method( $payment_method_slug );
683
-			$this->_redirect_after_action($count_updated, 'Payment Method', 'deactivated', array('action' => 'default','payment_method'=>$payment_method_slug));
684
-		}else{
682
+			$count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method($payment_method_slug);
683
+			$this->_redirect_after_action($count_updated, 'Payment Method', 'deactivated', array('action' => 'default', 'payment_method'=>$payment_method_slug));
684
+		} else {
685 685
 			$this->_redirect_after_action(FALSE, 'Payment Method', 'deactivated', array('action' => 'default'));
686 686
 		}
687 687
 	}
@@ -695,39 +695,39 @@  discard block
 block discarded – undo
695 695
 	 * subsequently called 'headers_sent_func' which is _payment_methods_list)
696 696
 	 * @return void
697 697
 	 */
698
-	protected function _update_payment_method(){
699
-		if( $_SERVER['REQUEST_METHOD'] == 'POST'){
698
+	protected function _update_payment_method() {
699
+		if ($_SERVER['REQUEST_METHOD'] == 'POST') {
700 700
 			//ok let's find which gateway form to use based on the form input
701 701
 			EE_Registry::instance()->load_lib('Payment_Method_Manager');
702 702
 			/** @var $correct_pmt_form_to_use EE_Payment_Method_Form */
703 703
 			$correct_pmt_form_to_use = NULL;
704 704
 			$pmt_obj = NULL;
705
-			foreach(EE_Payment_Method_Manager::instance()->payment_method_types() as $pmt_obj){
705
+			foreach (EE_Payment_Method_Manager::instance()->payment_method_types() as $pmt_obj) {
706 706
 				/** @var $pmt_obj EE_PMT_Base */
707 707
 				//get the form and simplify it, like what we do when we display it
708 708
 				$pmt_form = $pmt_obj->settings_form();
709 709
 				$this->_simplify_form($pmt_form);
710
-				if($pmt_form->form_data_present_in($this->_req_data)){
710
+				if ($pmt_form->form_data_present_in($this->_req_data)) {
711 711
 					$correct_pmt_form_to_use = $pmt_form;
712 712
 					break;
713 713
 				}
714 714
 			}
715 715
 			//if we couldn't find the correct payment method type...
716
-			if( ! $correct_pmt_form_to_use ){
716
+			if ( ! $correct_pmt_form_to_use) {
717 717
 				EE_Error::add_error(__("We could not find which payment method type your form submission related to. Please contact support", 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
718 718
 				$this->_redirect_after_action(FALSE, 'Payment Method', 'activated', array('action' => 'default'));
719 719
 			}
720 720
 			$correct_pmt_form_to_use->receive_form_submission($this->_req_data);
721
-			if($correct_pmt_form_to_use->is_valid()){
721
+			if ($correct_pmt_form_to_use->is_valid()) {
722 722
 				$correct_pmt_form_to_use->save();
723 723
 				$pm = $correct_pmt_form_to_use->get_model_object();
724 724
 				/** @var $pm EE_Payment_Method */
725
-				$this->_redirect_after_action(TRUE, 'Payment Method', 'updated', array('action' => 'default','payment_method'=>$pm->slug()));
726
-			}else{
725
+				$this->_redirect_after_action(TRUE, 'Payment Method', 'updated', array('action' => 'default', 'payment_method'=>$pm->slug()));
726
+			} else {
727 727
 				EE_Error::add_error(
728 728
 					sprintf(
729 729
 						__('Payment method of type %s was not saved because there were validation errors. They have been marked in the form', 'event_espresso'),
730
-						$pmt_obj instanceof EE_PMT_Base ? $pmt_obj->pretty_name() : __( '"(unknown)"', 'event_espresso' )
730
+						$pmt_obj instanceof EE_PMT_Base ? $pmt_obj->pretty_name() : __('"(unknown)"', 'event_espresso')
731 731
 					),
732 732
 					__FILE__,
733 733
 					__FUNCTION__,
@@ -744,11 +744,11 @@  discard block
 block discarded – undo
744 744
 	protected function _payment_settings() {
745 745
 
746 746
 		$this->_template_args['values'] = $this->_yes_no_values;
747
-		$this->_template_args['show_pending_payment_options'] = isset( EE_Registry::instance()->CFG->registration->show_pending_payment_options ) ? absint( EE_Registry::instance()->CFG->registration->show_pending_payment_options ) : FALSE;
747
+		$this->_template_args['show_pending_payment_options'] = isset(EE_Registry::instance()->CFG->registration->show_pending_payment_options) ? absint(EE_Registry::instance()->CFG->registration->show_pending_payment_options) : FALSE;
748 748
 
749
-		$this->_set_add_edit_form_tags( 'update_payment_settings' );
750
-		$this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
751
-		$this->_template_args['admin_page_content'] = EEH_Template::display_template( EE_PAYMENTS_TEMPLATE_PATH . 'payment_settings.template.php', $this->_template_args, TRUE );
749
+		$this->_set_add_edit_form_tags('update_payment_settings');
750
+		$this->_set_publish_post_box_vars(NULL, FALSE, FALSE, NULL, FALSE);
751
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(EE_PAYMENTS_TEMPLATE_PATH.'payment_settings.template.php', $this->_template_args, TRUE);
752 752
 		$this->display_admin_page_with_sidebar();
753 753
 
754 754
 	}
@@ -762,13 +762,13 @@  discard block
 block discarded – undo
762 762
 	*		@return array
763 763
 	*/
764 764
 	protected function _update_payment_settings() {
765
-		EE_Registry::instance()->CFG->registration->show_pending_payment_options = isset( $this->_req_data['show_pending_payment_options'] ) ? $this->_req_data['show_pending_payment_options'] : FALSE;
766
-		EE_Registry::instance()->CFG = apply_filters( 'FHEE__Payments_Admin_Page___update_payment_settings__CFG', EE_Registry::instance()->CFG );
765
+		EE_Registry::instance()->CFG->registration->show_pending_payment_options = isset($this->_req_data['show_pending_payment_options']) ? $this->_req_data['show_pending_payment_options'] : FALSE;
766
+		EE_Registry::instance()->CFG = apply_filters('FHEE__Payments_Admin_Page___update_payment_settings__CFG', EE_Registry::instance()->CFG);
767 767
 
768 768
 
769
-		$what = __('Payment Settings','event_espresso');
770
-		$success = $this->_update_espresso_configuration( $what, EE_Registry::instance()->CFG, __FILE__, __FUNCTION__, __LINE__ );
771
-		$this->_redirect_after_action( $success, $what, __('updated','event_espresso'), array( 'action' => 'payment_settings' ) );
769
+		$what = __('Payment Settings', 'event_espresso');
770
+		$success = $this->_update_espresso_configuration($what, EE_Registry::instance()->CFG, __FILE__, __FUNCTION__, __LINE__);
771
+		$this->_redirect_after_action($success, $what, __('updated', 'event_espresso'), array('action' => 'payment_settings'));
772 772
 
773 773
 	}
774 774
 	protected function _payment_log_overview_list_table() {
@@ -794,18 +794,18 @@  discard block
 block discarded – undo
794 794
 	 * @param bool $count
795 795
 	 * @return array
796 796
 	 */
797
-	public function get_payment_logs($per_page = 50, $current_page = 0, $count = false){
798
-		EE_Registry::instance()->load_model( 'Change_Log' );
797
+	public function get_payment_logs($per_page = 50, $current_page = 0, $count = false) {
798
+		EE_Registry::instance()->load_model('Change_Log');
799 799
 		//we may need to do multiple queries (joining differently), so we actually wan tan array of query params
800
-		$query_params =  array(array('LOG_type'=>  EEM_Change_Log::type_gateway));
800
+		$query_params = array(array('LOG_type'=>  EEM_Change_Log::type_gateway));
801 801
 		//check if they've selected a specific payment method
802
-		if( isset($this->_req_data['_payment_method']) && $this->_req_data['_payment_method'] !== 'all'){
802
+		if (isset($this->_req_data['_payment_method']) && $this->_req_data['_payment_method'] !== 'all') {
803 803
 			$query_params[0]['OR*pm_or_pay_pm'] = array('Payment.Payment_Method.PMD_ID'=>$this->_req_data['_payment_method'],
804 804
 				'Payment_Method.PMD_ID'=>$this->_req_data['_payment_method']);
805 805
 		}
806 806
 		//take into account search
807
-		if(isset($this->_req_data['s']) && $this->_req_data['s']){
808
-			$similarity_string = array('LIKE','%'.str_replace("","%",$this->_req_data['s']) .'%');
807
+		if (isset($this->_req_data['s']) && $this->_req_data['s']) {
808
+			$similarity_string = array('LIKE', '%'.str_replace("", "%", $this->_req_data['s']).'%');
809 809
 			$query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_fname'] = $similarity_string;
810 810
 			$query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_lname'] = $similarity_string;
811 811
 			$query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_email'] = $similarity_string;
@@ -820,48 +820,48 @@  discard block
 block discarded – undo
820 820
 			$query_params[0]['OR*s']['LOG_message'] = $similarity_string;
821 821
 
822 822
 		}
823
-		if(isset( $this->_req_data['payment-filter-start-date'] ) && isset( $this->_req_data['payment-filter-end-date'] )){
823
+		if (isset($this->_req_data['payment-filter-start-date']) && isset($this->_req_data['payment-filter-end-date'])) {
824 824
 			//add date
825
-			$start_date =wp_strip_all_tags( $this->_req_data['payment-filter-start-date'] );
826
-			$end_date = wp_strip_all_tags( $this->_req_data['payment-filter-end-date'] );
825
+			$start_date = wp_strip_all_tags($this->_req_data['payment-filter-start-date']);
826
+			$end_date = wp_strip_all_tags($this->_req_data['payment-filter-end-date']);
827 827
 			//make sure our timestamps start and end right at the boundaries for each day
828
-			$start_date = date( 'Y-m-d', strtotime( $start_date ) ) . ' 00:00:00';
829
-			$end_date = date( 'Y-m-d', strtotime( $end_date ) ) . ' 23:59:59';
828
+			$start_date = date('Y-m-d', strtotime($start_date)).' 00:00:00';
829
+			$end_date = date('Y-m-d', strtotime($end_date)).' 23:59:59';
830 830
 
831 831
 			//convert to timestamps
832
-			$start_date = strtotime( $start_date );
833
-			$end_date = strtotime( $end_date );
832
+			$start_date = strtotime($start_date);
833
+			$end_date = strtotime($end_date);
834 834
 
835 835
 			//makes sure start date is the lowest value and vice versa
836
-			$start_date = min( $start_date, $end_date );
837
-			$end_date = max( $start_date, $end_date );
836
+			$start_date = min($start_date, $end_date);
837
+			$end_date = max($start_date, $end_date);
838 838
 
839 839
 			//convert for query
840
-			$start_date = EEM_Change_Log::instance()->convert_datetime_for_query( 'LOG_time', date( 'Y-m-d H:i:s', $start_date ), 'Y-m-d H:i:s' );
841
-			$end_date = EEM_Change_Log::instance()->convert_datetime_for_query( 'LOG_time', date( 'Y-m-d H:i:s', $end_date ), 'Y-m-d H:i:s' );
840
+			$start_date = EEM_Change_Log::instance()->convert_datetime_for_query('LOG_time', date('Y-m-d H:i:s', $start_date), 'Y-m-d H:i:s');
841
+			$end_date = EEM_Change_Log::instance()->convert_datetime_for_query('LOG_time', date('Y-m-d H:i:s', $end_date), 'Y-m-d H:i:s');
842 842
 
843
-			$query_params[0]['LOG_time'] = array('BETWEEN',array($start_date,$end_date));
843
+			$query_params[0]['LOG_time'] = array('BETWEEN', array($start_date, $end_date));
844 844
 
845 845
 		}
846
-		if($count){
846
+		if ($count) {
847 847
 			return EEM_Change_Log::instance()->count($query_params);
848 848
 		}
849
-		if(isset($this->_req_data['order'])){
850
-			$sort = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] )) ? $this->_req_data['order'] : 'DESC';
849
+		if (isset($this->_req_data['order'])) {
850
+			$sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'DESC';
851 851
 			$query_params['order_by'] = array('LOG_time' => $sort);
852
-		}else{
852
+		} else {
853 853
 				$query_params['order_by'] = array('LOG_time' => 'DESC');
854 854
 		}
855
-		$offset = ($current_page-1)*$per_page;
855
+		$offset = ($current_page - 1) * $per_page;
856 856
 
857
-		if( ! isset($this->_req_data['download_results'])){
858
-			$query_params['limit'] = array( $offset, $per_page );
857
+		if ( ! isset($this->_req_data['download_results'])) {
858
+			$query_params['limit'] = array($offset, $per_page);
859 859
 		}
860 860
 
861 861
 
862 862
 
863 863
 		//now they've requested to instead just download the file instead of viewing it.
864
-		if(isset($this->_req_data['download_results'])){
864
+		if (isset($this->_req_data['download_results'])) {
865 865
 			$wpdb_results = EEM_Change_Log::instance()->get_all_efficiently($query_params);
866 866
 			header('Content-Disposition: attachment');
867 867
 			header("Content-Disposition: attachment; filename=ee_payment_logs_for_".sanitize_key(site_url()));
@@ -883,36 +883,36 @@  discard block
 block discarded – undo
883 883
 	 * @param EE_Change_Log $logB
884 884
 	 * @return int
885 885
 	 */
886
-	protected function _sort_logs_again($logA,$logB){
886
+	protected function _sort_logs_again($logA, $logB) {
887 887
 		$timeA = $logA->get_raw('LOG_time');
888 888
 		$timeB = $logB->get_raw('LOG_time');
889
-		if($timeA == $timeB){
889
+		if ($timeA == $timeB) {
890 890
 			return 0;
891 891
 		}
892 892
 		$comparison = $timeA < $timeB ? -1 : 1;
893
-		if(strtoupper($this->_sort_logs_again_direction) == 'DESC'){
893
+		if (strtoupper($this->_sort_logs_again_direction) == 'DESC') {
894 894
 			return $comparison * -1;
895
-		}else{
895
+		} else {
896 896
 			return $comparison;
897 897
 		}
898 898
 	}
899 899
 
900 900
 	protected function _payment_log_details() {
901
-		EE_Registry::instance()->load_model( 'Change_Log' );
901
+		EE_Registry::instance()->load_model('Change_Log');
902 902
 		/** @var $payment_log EE_Change_Log */
903 903
 		$payment_log = EEM_Change_Log::instance()->get_one_by_ID($this->_req_data['ID']);
904 904
 		$payment_method = NULL;
905 905
 		$transaction = NULL;
906
-		if( $payment_log instanceof EE_Change_Log ){
907
-			if( $payment_log->object() instanceof EE_Payment ){
906
+		if ($payment_log instanceof EE_Change_Log) {
907
+			if ($payment_log->object() instanceof EE_Payment) {
908 908
 				$payment_method = $payment_log->object()->payment_method();
909 909
 				$transaction = $payment_log->object()->transaction();
910
-			}elseif($payment_log->object() instanceof EE_Payment_Method){
910
+			}elseif ($payment_log->object() instanceof EE_Payment_Method) {
911 911
 				$payment_method = $payment_log->object();
912 912
 			}
913 913
 		}
914 914
 		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
915
-			EE_PAYMENTS_TEMPLATE_PATH . 'payment_log_details.template.php',
915
+			EE_PAYMENTS_TEMPLATE_PATH.'payment_log_details.template.php',
916 916
 			array(
917 917
 				'payment_log'=>$payment_log,
918 918
 				'payment_method'=>$payment_method,
Please login to merge, or discard this patch.
admin_pages/support/Support_Admin_Page.core.php 1 patch
Spacing   +47 added lines, -47 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
 /**
@@ -37,8 +37,8 @@  discard block
 block discarded – undo
37 37
 	protected $_job_step_response = null;
38 38
 
39 39
 
40
-	public function __construct( $routing = TRUE ) {
41
-		parent::__construct( $routing );
40
+	public function __construct($routing = TRUE) {
41
+		parent::__construct($routing);
42 42
 	}
43 43
 
44 44
 
@@ -53,8 +53,8 @@  discard block
 block discarded – undo
53 53
 
54 54
 
55 55
 	protected function _ajax_hooks() {
56
-		add_action('wp_ajax_espresso_batch_continue',array($this,'batch_continue'));
57
-		add_action('wp_ajax_espresso_batch_cleanup',array($this,'batch_cleanup'));
56
+		add_action('wp_ajax_espresso_batch_continue', array($this, 'batch_continue'));
57
+		add_action('wp_ajax_espresso_batch_cleanup', array($this, 'batch_cleanup'));
58 58
 		
59 59
 	}
60 60
 
@@ -102,14 +102,14 @@  discard block
 block discarded – undo
102 102
 				'nav' => array(
103 103
 					'label' => __('Shortcodes', 'event_espresso'),
104 104
 					'order' => 30),
105
-				'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array('_shortcodes_boxes' ) ),
105
+				'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_shortcodes_boxes')),
106 106
 				'require_nonce' => FALSE
107 107
 				),
108 108
 			'contact_support' => array(
109 109
 				'nav' => array(
110 110
 					'label' => __('Support', 'event_espresso'),
111 111
 					'order' => 40),
112
-				'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array( '_support_boxes' ) ),
112
+				'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_support_boxes')),
113 113
 				'require_nonce' => FALSE
114 114
 				),
115 115
 			'developers' => array(
@@ -137,8 +137,8 @@  discard block
 block discarded – undo
137 137
 
138 138
 
139 139
 	protected function _installation() {
140
-		$template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'support_admin_details_installation.template.php';
141
-		$this->_template_args['admin_page_content'] = EEH_Template::display_template( $template_path, '', TRUE);
140
+		$template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH.'support_admin_details_installation.template.php';
141
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, '', TRUE);
142 142
 		$this->display_admin_page_with_sidebar();
143 143
 	}
144 144
 
@@ -163,10 +163,10 @@  discard block
 block discarded – undo
163 163
 			'other_resources' => __('Other Resources', 'event_espresso')
164 164
 			);
165 165
 
166
-		foreach ( $boxes as $box => $label ) {
167
-			$template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'support_admin_details_' . $box . '.template.php';
166
+		foreach ($boxes as $box => $label) {
167
+			$template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH.'support_admin_details_'.$box.'.template.php';
168 168
 			$callback_args = array('template_path' => $template_path);
169
-			add_meta_box( 'espresso_' . $box . '_settings', $label, create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], "", TRUE );'), $this->_current_screen_id, 'normal', 'high', $callback_args);
169
+			add_meta_box('espresso_'.$box.'_settings', $label, create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], "", TRUE );'), $this->_current_screen_id, 'normal', 'high', $callback_args);
170 170
 		}
171 171
 	}
172 172
 
@@ -187,15 +187,15 @@  discard block
 block discarded – undo
187 187
 			'shortcodes_event_listings' => __('Event Listings', 'event_espresso'),
188 188
 			'shortcodes_ticket_selector' => __('Event Ticket Selector', 'event_espresso'),
189 189
 			'shortcodes_category' => __('Event Categories', 'event_espresso'),
190
-			'shortcodes_attendee' => __( 'Event Attendees', 'event_espresso' )
190
+			'shortcodes_attendee' => __('Event Attendees', 'event_espresso')
191 191
 			/*'shortcodes_single_events' => __('Single Events', 'event_espresso'),*/
192 192
 			/*'shortcodes_attendee_listings' => __('Attendee Listings', 'event_espresso'),*/
193 193
 			);
194 194
 
195
-		foreach ( $boxes as $box => $label ) {
196
-			$template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'support_admin_details_' . $box . '.template.php';
195
+		foreach ($boxes as $box => $label) {
196
+			$template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH.'support_admin_details_'.$box.'.template.php';
197 197
 			$callback_args = array('template_path' => $template_path);
198
-			add_meta_box( 'espresso_' . $box . '_settings', $label, create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], "", TRUE );'), $this->_current_screen_id, 'normal', 'high', $callback_args);
198
+			add_meta_box('espresso_'.$box.'_settings', $label, create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], "", TRUE );'), $this->_current_screen_id, 'normal', 'high', $callback_args);
199 199
 		}
200 200
 	}
201 201
 
@@ -214,41 +214,41 @@  discard block
 block discarded – undo
214 214
 			'important_information' => __('Important Information', 'event_espresso')
215 215
 			);
216 216
 
217
-		foreach ( $boxes as $box => $label ) {
218
-			$template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'support_admin_details_' . $box . '.template.php';
217
+		foreach ($boxes as $box => $label) {
218
+			$template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH.'support_admin_details_'.$box.'.template.php';
219 219
 			$callback_args = array('template_path' => $template_path, 'template_args' => $this->_template_args);
220
-			add_meta_box( 'espresso_' . $box . '_settings', $label, create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );'), $this->_current_screen_id, 'normal', 'high', $callback_args);
220
+			add_meta_box('espresso_'.$box.'_settings', $label, create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );'), $this->_current_screen_id, 'normal', 'high', $callback_args);
221 221
 		}
222 222
 	}
223 223
 
224 224
 
225 225
 	protected function _developers() {
226
-		$template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'developers_admin_details.template.php';
227
-		$this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, array(), true );
226
+		$template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH.'developers_admin_details.template.php';
227
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, array(), true);
228 228
 		$this->display_admin_page_with_sidebar();
229 229
 	}
230 230
 	
231 231
 	public function load_scripts_styles_batch_create() {	
232 232
 		$job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job();
233
-		wp_enqueue_script( 'batch_runner', EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/batch_runner.js', array( 'progress_bar' ));
234
-		wp_localize_script( 'support_batch_runner', 'ee_job_response', $job_response->to_array() );
235
-		wp_localize_script( 'support_batch_runner', 'ee_job_i18n', 
233
+		wp_enqueue_script('batch_runner', EE_PLUGIN_DIR_URL.'core/libraries/batch/Assets/batch_runner.js', array('progress_bar'));
234
+		wp_localize_script('support_batch_runner', 'ee_job_response', $job_response->to_array());
235
+		wp_localize_script('support_batch_runner', 'ee_job_i18n', 
236 236
 			array(
237
-				'redirect_url' => $this->_req_data['redirect_url' ],
237
+				'redirect_url' => $this->_req_data['redirect_url'],
238 238
 			));
239 239
 	}
240 240
 	public function load_scripts_styles_batch_file_create() {
241 241
 		//creates a job based on the request variable
242 242
 		$job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job();
243
-		wp_enqueue_script( 'support_batch_file_runner', EE_SUPPORT_ASSETS_URL . 'support_batch_file_runner.js', array( 'batch_runner' ), EVENT_ESPRESSO_VERSION,true);
244
-		wp_localize_script( 'support_batch_file_runner', 'ee_job_response', $job_response->to_array() );
245
-		wp_localize_script( 'support_batch_file_runner', 'ee_job_i18n', 
243
+		wp_enqueue_script('support_batch_file_runner', EE_SUPPORT_ASSETS_URL.'support_batch_file_runner.js', array('batch_runner'), EVENT_ESPRESSO_VERSION, true);
244
+		wp_localize_script('support_batch_file_runner', 'ee_job_response', $job_response->to_array());
245
+		wp_localize_script('support_batch_file_runner', 'ee_job_i18n', 
246 246
 				array(
247 247
 					'download_and_redirecting' => sprintf( 
248 248
 							__('File Generation complete. Downloading, and %1$sredirecting%2$s...', 'event_espresso'),
249
-							'<a href="' . $this->_req_data['redirect_url' ] .'">',
249
+							'<a href="'.$this->_req_data['redirect_url'].'">',
250 250
 							'</a>' ),
251
-					'redirect_url' => $this->_req_data['redirect_url' ],
251
+					'redirect_url' => $this->_req_data['redirect_url'],
252 252
 				));
253 253
 	}
254 254
 	
@@ -259,16 +259,16 @@  discard block
 block discarded – undo
259 259
 	 * @return \EventEspressoBatchRequest\Helpers\JobStepResponse
260 260
 	 */
261 261
 	protected function _enqueue_batch_job_scripts_and_styles_and_start_job() {
262
-		wp_register_script( 'progress_bar', EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.js', array( 'jquery' ) );
263
-		wp_enqueue_style( 'progress_bar', EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.css', array(), EVENT_ESPRESSO_VERSION );
264
-		wp_enqueue_script( 'batch_runner', EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/batch_runner.js', array( 'progress_bar' ));
265
-		$job_handler_classname = stripslashes( $this->_req_data[ 'job_handler' ] );
262
+		wp_register_script('progress_bar', EE_PLUGIN_DIR_URL.'core/libraries/batch/Assets/progress_bar.js', array('jquery'));
263
+		wp_enqueue_style('progress_bar', EE_PLUGIN_DIR_URL.'core/libraries/batch/Assets/progress_bar.css', array(), EVENT_ESPRESSO_VERSION);
264
+		wp_enqueue_script('batch_runner', EE_PLUGIN_DIR_URL.'core/libraries/batch/Assets/batch_runner.js', array('progress_bar'));
265
+		$job_handler_classname = stripslashes($this->_req_data['job_handler']);
266 266
 		$request_data = array_diff_key( 
267 267
 				$this->_req_data, 
268
-				array_flip( array( 'action',  'page' ) ) );
268
+				array_flip(array('action', 'page')) );
269 269
 		$batch_runner = new EventEspressoBatchRequest\BatchRequestProcessor();
270 270
 		//eg 'EventEspressoBatchRequest\JobHandlers\RegistrationsReport'
271
-		$job_response = $batch_runner->create_job( $job_handler_classname, $request_data );
271
+		$job_response = $batch_runner->create_job($job_handler_classname, $request_data);
272 272
 		//remember the response for later. We need it to display the page body
273 273
 		$this->_job_step_response = $job_response;
274 274
 		return $job_response;
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
 	 * Invokes the report-generating code
278 278
 	 */
279 279
 	protected function batch_create() {		
280
-		echo EEH_Template::locate_template( EE_SUPPORT_ADMIN . 'templates' . DS . 'admin_batch_runner.template.html' );
280
+		echo EEH_Template::locate_template(EE_SUPPORT_ADMIN.'templates'.DS.'admin_batch_runner.template.html');
281 281
 	}
282 282
 	
283 283
 	/**
@@ -285,13 +285,13 @@  discard block
 block discarded – undo
285 285
 	 * and then sends the user back to wherever they were before
286 286
 	 */
287 287
 	protected function batch_file_create() {
288
-		if( $this->_job_step_response instanceof \EventEspressoBatchRequest\Helpers\JobStepResponse ) {
289
-			$filename = EEH_File::get_filename_from_filepath( $this->_job_step_response->job_parameters()->extra_datum( 'filepath' ) );
288
+		if ($this->_job_step_response instanceof \EventEspressoBatchRequest\Helpers\JobStepResponse) {
289
+			$filename = EEH_File::get_filename_from_filepath($this->_job_step_response->job_parameters()->extra_datum('filepath'));
290 290
 		} else {
291
-			$filename = __( 'Unknown', 'event_espresso' );
291
+			$filename = __('Unknown', 'event_espresso');
292 292
 		}
293 293
 		echo EEH_Template::locate_template( 
294
-				EE_SUPPORT_ADMIN . 'templates' . DS . 'admin_batch_file_runner.template.html', 
294
+				EE_SUPPORT_ADMIN.'templates'.DS.'admin_batch_file_runner.template.html', 
295 295
 				array( 
296 296
 					'filename' => $filename 
297 297
 				)
@@ -302,10 +302,10 @@  discard block
 block discarded – undo
302 302
 	 * Receives ajax calls for continuing a job
303 303
 	 */
304 304
 	public function batch_continue() {
305
-		$job_id = sanitize_text_field( $this->_req_data[ 'job_id' ] );
305
+		$job_id = sanitize_text_field($this->_req_data['job_id']);
306 306
 		$batch_runner = new EventEspressoBatchRequest\BatchRequestProcessor();
307
-		$responseobj = $batch_runner->continue_job( $job_id);
308
-		$this->_template_args[ 'data' ] = $responseobj->to_array();
307
+		$responseobj = $batch_runner->continue_job($job_id);
308
+		$this->_template_args['data'] = $responseobj->to_array();
309 309
 		$this->_return_json();
310 310
 	}
311 311
 	
@@ -314,10 +314,10 @@  discard block
 block discarded – undo
314 314
 	 * @return type
315 315
 	 */
316 316
 	public function batch_cleanup() {
317
-		$job_id = sanitize_text_field( $this->_req_data[ 'job_id' ] );
317
+		$job_id = sanitize_text_field($this->_req_data['job_id']);
318 318
 		$batch_runner = new EventEspressoBatchRequest\BatchRequestProcessor();
319
-		$response_obj = $batch_runner->cleanup_job( $job_id );
320
-		$this->_template_args[ 'data' ] = $response_obj->to_array();
319
+		$response_obj = $batch_runner->cleanup_job($job_id);
320
+		$this->_template_args['data'] = $response_obj->to_array();
321 321
 		$this->_return_json();
322 322
 	}
323 323
 
Please login to merge, or discard this patch.
caffeinated/admin/new/pricing/espresso_events_Pricing_Hooks.class.php 1 patch
Spacing   +376 added lines, -376 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
 /**
@@ -54,23 +54,23 @@  discard block
 block discarded – undo
54 54
 		$this->_name = 'pricing';
55 55
 
56 56
 		//capability check
57
-		if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_default_prices', 'advanced_ticket_datetime_metabox' ) ) {
57
+		if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_default_prices', 'advanced_ticket_datetime_metabox')) {
58 58
 			return;
59 59
 		}
60 60
 
61
-		EE_Registry::instance()->load_helper( 'DTT_Helper' );
61
+		EE_Registry::instance()->load_helper('DTT_Helper');
62 62
 
63 63
 		//if we were going to add our own metaboxes we'd use the below.
64 64
 		$this->_metaboxes = array(
65 65
 			0 => array(
66
-				'page_route' => array('edit','create_new'),
66
+				'page_route' => array('edit', 'create_new'),
67 67
 				'func' => 'pricing_metabox',
68 68
 				'label' => __('Event Tickets & Datetimes', 'event_espresso'),
69 69
 				'priority' => 'high',
70 70
 				'context' => 'normal'
71 71
 				),
72 72
 
73
-			);/**/
73
+			); /**/
74 74
 
75 75
 		$this->_remove_metaboxes = array(
76 76
 			0 => array(
@@ -89,24 +89,24 @@  discard block
 block discarded – undo
89 89
 		 *
90 90
 		 * @var array  Expected an array returned with 'date' and 'time' keys.
91 91
 		 */
92
-		$this->_date_format_strings = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___set_hooks_properties__date_format_strings', array(
92
+		$this->_date_format_strings = apply_filters('FHEE__espresso_events_Pricing_Hooks___set_hooks_properties__date_format_strings', array(
93 93
 				'date' => 'Y-m-d',
94 94
 				'time' => 'h:i a'
95 95
 			));
96 96
 
97 97
 		//validate
98
-		$this->_date_format_strings['date'] = isset( $this->_date_format_strings['date'] ) ? $this->_date_format_strings['date'] : null;
99
-		$this->_date_format_strings['time'] = isset( $this->_date_format_strings['time'] ) ? $this->_date_format_strings['time'] : null;
98
+		$this->_date_format_strings['date'] = isset($this->_date_format_strings['date']) ? $this->_date_format_strings['date'] : null;
99
+		$this->_date_format_strings['time'] = isset($this->_date_format_strings['time']) ? $this->_date_format_strings['time'] : null;
100 100
 
101 101
 		//validate format strings
102
-		$format_validation = EEH_DTT_Helper::validate_format_string( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] );
103
-		if ( is_array( $format_validation ) ) {
104
-			$msg = '<p>' . sprintf( __( 'The format "%s" was likely added via a filter and is invalid for the following reasons:', 'event_espresso' ), $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ) . '</p><ul>';
105
-			foreach ( $format_validation as $error ) {
106
-				$msg .= '<li>' . $error . '</li>';
102
+		$format_validation = EEH_DTT_Helper::validate_format_string($this->_date_format_strings['date'].' '.$this->_date_format_strings['time']);
103
+		if (is_array($format_validation)) {
104
+			$msg = '<p>'.sprintf(__('The format "%s" was likely added via a filter and is invalid for the following reasons:', 'event_espresso'), $this->_date_format_strings['date'].' '.$this->_date_format_strings['time']).'</p><ul>';
105
+			foreach ($format_validation as $error) {
106
+				$msg .= '<li>'.$error.'</li>';
107 107
 			}
108
-			$msg .= '</ul></p><p>' . sprintf( __( '%sPlease note that your date and time formats have been reset to "Y-m-d" and "h:i a" respectively.%s', 'event_espresso' ), '<span style="color:#D54E21;">', '</span>' ) . '</p>';
109
-			EE_Error::add_attention( $msg, __FILE__, __FUNCTION__, __LINE__ );
108
+			$msg .= '</ul></p><p>'.sprintf(__('%sPlease note that your date and time formats have been reset to "Y-m-d" and "h:i a" respectively.%s', 'event_espresso'), '<span style="color:#D54E21;">', '</span>').'</p>';
109
+			EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__);
110 110
 			$this->_date_format_strings = array(
111 111
 				'date' => 'Y-m-d',
112 112
 				'time' => 'h:i a'
@@ -117,60 +117,60 @@  discard block
 block discarded – undo
117 117
 		$this->_scripts_styles = array(
118 118
 			'registers' => array(
119 119
 				'ee-tickets-datetimes-css' => array(
120
-					'url' => PRICING_ASSETS_URL . 'event-tickets-datetimes.css',
120
+					'url' => PRICING_ASSETS_URL.'event-tickets-datetimes.css',
121 121
 					'type' => 'css'
122 122
 					),
123 123
 				'ee-dtt-ticket-metabox' => array(
124
-					'url' => PRICING_ASSETS_URL . 'ee-datetime-ticket-metabox.js',
124
+					'url' => PRICING_ASSETS_URL.'ee-datetime-ticket-metabox.js',
125 125
 					'depends' => array('ee-datepicker', 'ee-dialog', 'underscore')
126 126
 					)
127 127
 				),
128 128
 			'deregisters' => array(
129
-				'event-editor-css' => array('type' => 'css' ),
129
+				'event-editor-css' => array('type' => 'css'),
130 130
 				'event-datetime-metabox' => array('type' => 'js')
131 131
 				),
132 132
 			'enqueues' => array(
133
-				'ee-tickets-datetimes-css' => array( 'edit', 'create_new' ),
134
-				'ee-dtt-ticket-metabox' => array( 'edit', 'create_new' )
133
+				'ee-tickets-datetimes-css' => array('edit', 'create_new'),
134
+				'ee-dtt-ticket-metabox' => array('edit', 'create_new')
135 135
 				),
136 136
 			'localize' => array(
137 137
 				'ee-dtt-ticket-metabox' => array(
138 138
 					'DTT_TRASH_BLOCK' => array(
139 139
 						'main_warning' => __('The Datetime you are attempting to trash is the only datetime selected for the following ticket(s):', 'event_espresso'),
140 140
 						'after_warning' => __('In order to trash this datetime you must first make sure the above ticket(s) are assigned to other datetimes.', 'event_espresso'),
141
-						'cancel_button' => '<button class="button-secondary ee-modal-cancel">' . __('Cancel', 'event_espresso') . '</button>',
141
+						'cancel_button' => '<button class="button-secondary ee-modal-cancel">'.__('Cancel', 'event_espresso').'</button>',
142 142
 						'single_warning_from_tkt' => __('The Datetime you are attempting to unassign from this ticket is the only remaining datetime for this ticket. Tickets must always have at least one datetime assigned to them.', 'event_espresso'),
143 143
 						'single_warning_from_dtt' => __('The ticket you are attempting to unassign from this datetime cannot be unassigned because the datetime is the only remaining datetime for the ticket.  Tickets must always have at least one datetime assigned to them.', 'event_espresso'),
144
-						'dismiss_button' => '<button class="button-secondary ee-modal-cancel">' . __('Dismiss', 'event_espresso') . '</button>'
144
+						'dismiss_button' => '<button class="button-secondary ee-modal-cancel">'.__('Dismiss', 'event_espresso').'</button>'
145 145
 						),
146 146
 					'DTT_ERROR_MSG' => array(
147 147
 						'no_ticket_name' => __('General Admission', 'event_espresso'),
148
-						'dismiss_button' => '<div class="save-cancel-button-container"><button class="button-secondary ee-modal-cancel">' . __('Dismiss', 'event_espresso') . '</button></div>'
148
+						'dismiss_button' => '<div class="save-cancel-button-container"><button class="button-secondary ee-modal-cancel">'.__('Dismiss', 'event_espresso').'</button></div>'
149 149
 						),
150 150
 					'DTT_OVERSELL_WARNING' => array(
151 151
 						'datetime_ticket' => __('You cannot add this ticket to this datetime because it has a sold amount that is greater than the amount of spots remaining for this datetime.', 'event_espresso'),
152 152
 						'ticket_datetime' => __('You cannot add this datetime to this ticket because the ticket has a sold amount that is greater than the amount of spots remaining on the datetime.', 'event_espresso')
153 153
 						),
154
-					'DTT_CONVERTED_FORMATS' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats( $this->_date_format_strings['date'], $this->_date_format_strings['time'] ),
155
-					'DTT_START_OF_WEEK' => array( 'dayValue' => (int) get_option( 'start_of_week' ) )
154
+					'DTT_CONVERTED_FORMATS' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats($this->_date_format_strings['date'], $this->_date_format_strings['time']),
155
+					'DTT_START_OF_WEEK' => array('dayValue' => (int) get_option('start_of_week'))
156 156
 					)
157 157
 				)
158 158
 			);
159 159
 
160 160
 
161
-		add_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_Extend_Events_Admin_Page', array( $this, 'autosave_handling' ), 10 );
162
-		add_filter('FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', array( $this, 'caf_updates' ), 10 );
161
+		add_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_Extend_Events_Admin_Page', array($this, 'autosave_handling'), 10);
162
+		add_filter('FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', array($this, 'caf_updates'), 10);
163 163
 	}
164 164
 
165 165
 
166 166
 
167
-	public function caf_updates( $update_callbacks ) {
168
-		foreach ( $update_callbacks as $key => $callback ) {
169
-			if ( $callback[1] == '_default_tickets_update' )
170
-				unset( $update_callbacks[$key] );
167
+	public function caf_updates($update_callbacks) {
168
+		foreach ($update_callbacks as $key => $callback) {
169
+			if ($callback[1] == '_default_tickets_update')
170
+				unset($update_callbacks[$key]);
171 171
 		}
172 172
 
173
-		$update_callbacks[] = array( $this, 'dtt_and_tickets_caf_update' );
173
+		$update_callbacks[] = array($this, 'dtt_and_tickets_caf_update');
174 174
 		return $update_callbacks;
175 175
 	}
176 176
 
@@ -183,11 +183,11 @@  discard block
 block discarded – undo
183 183
 	 * @param  array    $data   The request data from the form
184 184
 	 * @return bool             success or fail
185 185
 	 */
186
-	public function dtt_and_tickets_caf_update( $evtobj, $data ) {
186
+	public function dtt_and_tickets_caf_update($evtobj, $data) {
187 187
 		//first we need to start with datetimes cause they are the "root" items attached to events.
188
-		$saved_dtts = $this->_update_dtts( $evtobj, $data );
188
+		$saved_dtts = $this->_update_dtts($evtobj, $data);
189 189
 		//next tackle the tickets (and prices?)
190
-		$this->_update_tkts( $evtobj, $saved_dtts, $data );
190
+		$this->_update_tkts($evtobj, $saved_dtts, $data);
191 191
 	}
192 192
 
193 193
 
@@ -198,41 +198,41 @@  discard block
 block discarded – undo
198 198
 	 * @param  array    	$data    the request data from the form
199 199
 	 * @return EE_Datetime[]
200 200
 	 */
201
-	protected function _update_dtts( $evt_obj, $data ) {
202
-		$timezone = isset( $data['timezone_string'] ) ? $data['timezone_string'] : NULL;
201
+	protected function _update_dtts($evt_obj, $data) {
202
+		$timezone = isset($data['timezone_string']) ? $data['timezone_string'] : NULL;
203 203
 		$saved_dtt_ids = array();
204 204
 		$saved_dtt_objs = array();
205 205
 
206
-		foreach ( $data['edit_event_datetimes'] as $row => $dtt ) {
206
+		foreach ($data['edit_event_datetimes'] as $row => $dtt) {
207 207
 			//trim all values to ensure any excess whitespace is removed.
208 208
 			$dtt = array_map(
209
-				function( $datetime_data ) {
210
-					return is_array( $datetime_data ) ? $datetime_data : trim( $datetime_data );
209
+				function($datetime_data) {
210
+					return is_array($datetime_data) ? $datetime_data : trim($datetime_data);
211 211
 				},
212 212
 				$dtt
213 213
 			);
214
-			$dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty( $dtt['DTT_EVT_end'] ) ? $dtt['DTT_EVT_end'] : $dtt['DTT_EVT_start'];
214
+			$dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty($dtt['DTT_EVT_end']) ? $dtt['DTT_EVT_end'] : $dtt['DTT_EVT_start'];
215 215
 			$datetime_values = array(
216
-				'DTT_ID' 			=> ! empty( $dtt['DTT_ID'] ) ? $dtt['DTT_ID'] : NULL,
217
-				'DTT_name' 			=> ! empty( $dtt['DTT_name'] ) ? $dtt['DTT_name'] : '',
218
-				'DTT_description' 	=> ! empty( $dtt['DTT_description'] ) ? $dtt['DTT_description'] : '',
216
+				'DTT_ID' 			=> ! empty($dtt['DTT_ID']) ? $dtt['DTT_ID'] : NULL,
217
+				'DTT_name' 			=> ! empty($dtt['DTT_name']) ? $dtt['DTT_name'] : '',
218
+				'DTT_description' 	=> ! empty($dtt['DTT_description']) ? $dtt['DTT_description'] : '',
219 219
 				'DTT_EVT_start' 	=> $dtt['DTT_EVT_start'],
220 220
 				'DTT_EVT_end' 		=> $dtt['DTT_EVT_end'],
221
-				'DTT_reg_limit' 	=> empty( $dtt['DTT_reg_limit'] ) ? EE_INF : $dtt[ 'DTT_reg_limit' ],
222
-				'DTT_order' 		=> ! isset( $dtt['DTT_order'] ) ? $row : $dtt['DTT_order'],
221
+				'DTT_reg_limit' 	=> empty($dtt['DTT_reg_limit']) ? EE_INF : $dtt['DTT_reg_limit'],
222
+				'DTT_order' 		=> ! isset($dtt['DTT_order']) ? $row : $dtt['DTT_order'],
223 223
 			);
224 224
 
225 225
 			//if we have an id then let's get existing object first and then set the new values.  Otherwise we instantiate a new object for save.
226 226
 
227
-			if ( !empty( $dtt['DTT_ID'] ) ) {
228
-				$DTM = EE_Registry::instance()->load_model('Datetime', array($timezone) )->get_one_by_ID($dtt['DTT_ID'] );
227
+			if ( ! empty($dtt['DTT_ID'])) {
228
+				$DTM = EE_Registry::instance()->load_model('Datetime', array($timezone))->get_one_by_ID($dtt['DTT_ID']);
229 229
 
230 230
 				//set date and time format according to what is set in this class.
231
-				$DTM->set_date_format( $this->_date_format_strings['date'] );
232
-				$DTM->set_time_format( $this->_date_format_strings['time'] );
231
+				$DTM->set_date_format($this->_date_format_strings['date']);
232
+				$DTM->set_time_format($this->_date_format_strings['time']);
233 233
 
234
-				foreach ( $datetime_values as $field => $value ) {
235
-					$DTM->set( $field, $value );
234
+				foreach ($datetime_values as $field => $value) {
235
+					$DTM->set($field, $value);
236 236
 				}
237 237
 
238 238
 				// make sure the $dtt_id here is saved just in case after the add_relation_to() the autosave replaces it.
@@ -240,24 +240,24 @@  discard block
 block discarded – undo
240 240
 				$saved_dtt_ids[$DTM->ID()] = $DTM->ID();
241 241
 
242 242
 			} else {
243
-				$DTM = EE_Registry::instance()->load_class('Datetime', array( $datetime_values, $timezone ), FALSE, FALSE );
243
+				$DTM = EE_Registry::instance()->load_class('Datetime', array($datetime_values, $timezone), FALSE, FALSE);
244 244
 
245 245
 				//reset date and times to match the format
246
-				$DTM->set_date_format( $this->_date_format_strings['date'] );
247
-				$DTM->set_time_format( $this->_date_format_strings['time'] );
248
-				foreach( $datetime_values as $field => $value ) {
249
-					$DTM->set( $field, $value );
246
+				$DTM->set_date_format($this->_date_format_strings['date']);
247
+				$DTM->set_time_format($this->_date_format_strings['time']);
248
+				foreach ($datetime_values as $field => $value) {
249
+					$DTM->set($field, $value);
250 250
 				}
251 251
 			}
252 252
 
253 253
 
254 254
 			$DTM->save();
255
-			$DTM = $evt_obj->_add_relation_to( $DTM, 'Datetime' );
255
+			$DTM = $evt_obj->_add_relation_to($DTM, 'Datetime');
256 256
 			$evt_obj->save();
257 257
 
258 258
 			//before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date.
259
-			if( $DTM->get_raw('DTT_EVT_start') > $DTM->get_raw('DTT_EVT_end') ) {
260
-				$DTM->set('DTT_EVT_end', $DTM->get('DTT_EVT_start') );
259
+			if ($DTM->get_raw('DTT_EVT_start') > $DTM->get_raw('DTT_EVT_end')) {
260
+				$DTM->set('DTT_EVT_end', $DTM->get('DTT_EVT_start'));
261 261
 				EE_Registry::instance()->load_helper('DTT_Helper');
262 262
 				$DTM = EEH_DTT_Helper::date_time_add($DTM, 'DTT_EVT_end', 'days');
263 263
 				$DTM->save();
@@ -273,25 +273,25 @@  discard block
 block discarded – undo
273 273
 		}
274 274
 
275 275
 		//now we need to REMOVE any dtts that got deleted.  Keep in mind that this process will only kick in for DTT's that don't have any DTT_sold on them. So its safe to permanently delete at this point.
276
-		$old_datetimes = explode(',', $data['datetime_IDs'] );
276
+		$old_datetimes = explode(',', $data['datetime_IDs']);
277 277
 		$old_datetimes = $old_datetimes[0] == '' ? array() : $old_datetimes;
278 278
 
279
-		if ( is_array( $old_datetimes ) ) {
280
-			$dtts_to_delete = array_diff( $old_datetimes, $saved_dtt_ids );
281
-			foreach ( $dtts_to_delete as $id ) {
282
-				$id = absint( $id );
283
-				if ( empty( $id ) )
279
+		if (is_array($old_datetimes)) {
280
+			$dtts_to_delete = array_diff($old_datetimes, $saved_dtt_ids);
281
+			foreach ($dtts_to_delete as $id) {
282
+				$id = absint($id);
283
+				if (empty($id))
284 284
 					continue;
285 285
 
286 286
 				$dtt_to_remove = EE_Registry::instance()->load_model('Datetime')->get_one_by_ID($id);
287 287
 
288 288
 				//remove tkt relationships.
289 289
 				$related_tickets = $dtt_to_remove->get_many_related('Ticket');
290
-				foreach ( $related_tickets as $tkt ) {
290
+				foreach ($related_tickets as $tkt) {
291 291
 					$dtt_to_remove->_remove_relation_to($tkt, 'Ticket');
292 292
 				}
293 293
 
294
-				$evt_obj->_remove_relation_to( $id, 'Datetime' );
294
+				$evt_obj->_remove_relation_to($id, 'Datetime');
295 295
 				$dtt_to_remove->refresh_cache_of_related_objects();
296 296
 
297 297
 			}
@@ -312,86 +312,86 @@  discard block
 block discarded – undo
312 312
 	 * @param  array            $data       incoming request data
313 313
 	 * @return EE_Ticket[]
314 314
 	 */
315
-	protected function _update_tkts( $evtobj, $saved_dtts, $data ) {
315
+	protected function _update_tkts($evtobj, $saved_dtts, $data) {
316 316
 
317 317
 		$new_tkt = null;
318 318
 		$new_default = null;
319 319
 		//stripslashes because WP filtered the $_POST ($data) array to add slashes
320 320
 		$data = stripslashes_deep($data);
321
-		$timezone = isset( $data['timezone_string'] ) ? $data['timezone_string'] : NULL;
321
+		$timezone = isset($data['timezone_string']) ? $data['timezone_string'] : NULL;
322 322
 		$saved_tickets = $dtts_on_existing = array();
323
-		$old_tickets = isset( $data['ticket_IDs'] ) ? explode(',', $data['ticket_IDs'] ) : array();
323
+		$old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array();
324 324
 
325 325
 		//load money helper
326
-		EE_Registry::instance()->load_helper( 'Money' );
326
+		EE_Registry::instance()->load_helper('Money');
327 327
 
328
-		foreach ( $data['edit_tickets'] as $row => $tkt ) {
328
+		foreach ($data['edit_tickets'] as $row => $tkt) {
329 329
 
330 330
 			$update_prices = $create_new_TKT = FALSE;
331 331
 
332 332
 			//figure out what dtts were added to the ticket and what dtts were removed from the ticket in the session.
333 333
 
334
-			$starting_tkt_dtt_rows = explode(',',$data['starting_ticket_datetime_rows'][$row]);
335
-			$tkt_dtt_rows = explode(',', $data['ticket_datetime_rows'][$row] );
334
+			$starting_tkt_dtt_rows = explode(',', $data['starting_ticket_datetime_rows'][$row]);
335
+			$tkt_dtt_rows = explode(',', $data['ticket_datetime_rows'][$row]);
336 336
 			$dtts_added = array_diff($tkt_dtt_rows, $starting_tkt_dtt_rows);
337 337
 			$dtts_removed = array_diff($starting_tkt_dtt_rows, $tkt_dtt_rows);
338 338
 
339 339
 			// trim inputs to ensure any excess whitespace is removed.
340 340
 			$tkt = array_map(
341
-				function( $ticket_data ) {
342
-					return is_array( $ticket_data ) ? $ticket_data : trim( $ticket_data );
341
+				function($ticket_data) {
342
+					return is_array($ticket_data) ? $ticket_data : trim($ticket_data);
343 343
 				},
344 344
 				$tkt
345 345
 			);
346 346
 
347 347
 			//note we are doing conversions to floats here instead of allowing EE_Money_Field to handle because we're doing calcs prior to using the models.
348 348
 			//note incoming ['TKT_price'] value is already in standard notation (via js).
349
-			$ticket_price = isset( $tkt['TKT_price'] ) ?  round ( (float) $tkt['TKT_price'], 3 ) : 0;
349
+			$ticket_price = isset($tkt['TKT_price']) ? round((float) $tkt['TKT_price'], 3) : 0;
350 350
 
351 351
 			//note incoming base price needs converted from localized value.
352
-			$base_price = isset( $tkt['TKT_base_price'] ) ? EEH_Money::convert_to_float_from_localized_money( $tkt['TKT_base_price'] ) : 0;
352
+			$base_price = isset($tkt['TKT_base_price']) ? EEH_Money::convert_to_float_from_localized_money($tkt['TKT_base_price']) : 0;
353 353
 			//if ticket price == 0 and $base_price != 0 then ticket price == base_price
354 354
 			$ticket_price = $ticket_price === 0 && $base_price !== 0 ? $base_price : $ticket_price;
355
-			$base_price_id = isset( $tkt['TKT_base_price_ID'] ) ? $tkt['TKT_base_price_ID'] : 0;
355
+			$base_price_id = isset($tkt['TKT_base_price_ID']) ? $tkt['TKT_base_price_ID'] : 0;
356 356
 
357 357
 			$price_rows = is_array($data['edit_prices']) && isset($data['edit_prices'][$row]) ? $data['edit_prices'][$row] : array();
358 358
 
359 359
 			$now = null;
360
-			if ( empty( $tkt['TKT_start_date'] ) ) {
360
+			if (empty($tkt['TKT_start_date'])) {
361 361
 				//lets' use now in the set timezone.
362
-				$now = new DateTime( 'now', new DateTimeZone( $evtobj->get_timezone() ) );
363
-				$tkt['TKT_start_date'] = $now->format( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] );
362
+				$now = new DateTime('now', new DateTimeZone($evtobj->get_timezone()));
363
+				$tkt['TKT_start_date'] = $now->format($this->_date_format_strings['date'].' '.$this->_date_format_strings['time']);
364 364
 			}
365 365
 
366
-			if ( empty( $tkt['TKT_end_date'] ) ) {
366
+			if (empty($tkt['TKT_end_date'])) {
367 367
 				/**
368 368
 				 * set the TKT_end_date to the first datetime attached to the ticket.
369 369
 				 */
370
-				$first_dtt = $saved_dtts[reset( $tkt_dtt_rows )];
371
-				$tkt['TKT_end_date'] = $first_dtt->start_date_and_time( $this->_date_format_strings['date'] . ' ' . $this->_date_format_string['time'] );
370
+				$first_dtt = $saved_dtts[reset($tkt_dtt_rows)];
371
+				$tkt['TKT_end_date'] = $first_dtt->start_date_and_time($this->_date_format_strings['date'].' '.$this->_date_format_string['time']);
372 372
 			}
373 373
 
374 374
 			$TKT_values = array(
375
-				'TKT_ID' 			=> ! empty( $tkt['TKT_ID'] ) ? $tkt['TKT_ID'] : NULL,
376
-				'TTM_ID' 			=> ! empty( $tkt['TTM_ID'] ) ? $tkt['TTM_ID'] : 0,
377
-				'TKT_name' 			=> ! empty( $tkt['TKT_name'] ) ? $tkt['TKT_name'] : '',
378
-				'TKT_description' 	=> ! empty( $tkt['TKT_description'] ) && $tkt['TKT_description'] != __('You can modify this description', 'event_espresso') ? $tkt['TKT_description'] : '',
375
+				'TKT_ID' 			=> ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : NULL,
376
+				'TTM_ID' 			=> ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0,
377
+				'TKT_name' 			=> ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '',
378
+				'TKT_description' 	=> ! empty($tkt['TKT_description']) && $tkt['TKT_description'] != __('You can modify this description', 'event_espresso') ? $tkt['TKT_description'] : '',
379 379
 				'TKT_start_date' 	=> $tkt['TKT_start_date'],
380 380
 				'TKT_end_date' 		=> $tkt['TKT_end_date'],
381
-				'TKT_qty' 			=> ! isset( $tkt[ 'TKT_qty' ] ) || $tkt[ 'TKT_qty' ] === '' ? EE_INF : $tkt[ 'TKT_qty' ],
382
-				'TKT_uses' 			=> ! isset( $tkt[ 'TKT_uses' ] ) || $tkt[ 'TKT_uses' ] === '' ? EE_INF : $tkt['TKT_uses'],
383
-				'TKT_min' 			=> empty( $tkt['TKT_min'] ) ? 0 : $tkt['TKT_min'],
384
-				'TKT_max' 			=> empty( $tkt['TKT_max'] ) ? EE_INF : $tkt['TKT_max'],
381
+				'TKT_qty' 			=> ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'],
382
+				'TKT_uses' 			=> ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'],
383
+				'TKT_min' 			=> empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'],
384
+				'TKT_max' 			=> empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'],
385 385
 				'TKT_row' 			=> $row,
386
-				'TKT_order' 		=> isset( $tkt['TKT_order'] ) ? $tkt['TKT_order'] : 0,
387
-				'TKT_taxable' 		=> ! empty( $tkt['TKT_taxable'] ) ? 1 : 0,
388
-				'TKT_required' 		=> ! empty( $tkt['TKT_required'] ) ? 1 : 0,
386
+				'TKT_order' 		=> isset($tkt['TKT_order']) ? $tkt['TKT_order'] : 0,
387
+				'TKT_taxable' 		=> ! empty($tkt['TKT_taxable']) ? 1 : 0,
388
+				'TKT_required' 		=> ! empty($tkt['TKT_required']) ? 1 : 0,
389 389
 				'TKT_price' 		=> $ticket_price
390 390
 			);
391 391
 
392 392
 
393 393
 			//if this is a default TKT, then we need to set the TKT_ID to 0 and update accordingly, which means in turn that the prices will become new prices as well.
394
-			if ( isset( $tkt['TKT_is_default'] ) && $tkt['TKT_is_default'] ) {
394
+			if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) {
395 395
 				$TKT_values['TKT_ID'] = 0;
396 396
 				$TKT_values['TKT_is_default'] = 0;
397 397
 				$update_prices = TRUE;
@@ -403,21 +403,21 @@  discard block
 block discarded – undo
403 403
 			// but DID have it's items modified.
404 404
 			// keep in mind that if the TKT has been sold (and we have changed pricing information),
405 405
 			// then we won't be updating the tkt but instead a new tkt will be created and the old one archived.
406
-			if ( absint( $TKT_values['TKT_ID'] ) ) {
407
-				$TKT = EE_Registry::instance()->load_model( 'Ticket', array( $timezone ) )->get_one_by_ID( $tkt['TKT_ID'] );
408
-				if ( $TKT instanceof EE_Ticket ) {
406
+			if (absint($TKT_values['TKT_ID'])) {
407
+				$TKT = EE_Registry::instance()->load_model('Ticket', array($timezone))->get_one_by_ID($tkt['TKT_ID']);
408
+				if ($TKT instanceof EE_Ticket) {
409 409
 
410
-					$TKT = $this->_update_ticket_datetimes( $TKT, $saved_dtts, $dtts_added, $dtts_removed );
410
+					$TKT = $this->_update_ticket_datetimes($TKT, $saved_dtts, $dtts_added, $dtts_removed);
411 411
 					// are there any registrations using this ticket ?
412 412
 					$tickets_sold = $TKT->count_related(
413 413
 						'Registration',
414
-						array( array(
415
-								'STS_ID' => array( 'NOT IN', array( EEM_Registration::status_id_incomplete ) )
416
-						) )
414
+						array(array(
415
+								'STS_ID' => array('NOT IN', array(EEM_Registration::status_id_incomplete))
416
+						))
417 417
 					);
418 418
 					//set ticket formats
419
-					$TKT->set_date_format( $this->_date_format_strings['date'] );
420
-					$TKT->set_time_format( $this->_date_format_strings['time'] );
419
+					$TKT->set_date_format($this->_date_format_strings['date']);
420
+					$TKT->set_time_format($this->_date_format_strings['time']);
421 421
 
422 422
 					// let's just check the total price for the existing ticket
423 423
 					// and determine if it matches the new total price.
@@ -427,17 +427,17 @@  discard block
 block discarded – undo
427 427
 							? TRUE : FALSE;
428 428
 
429 429
 					//set new values
430
-					foreach ( $TKT_values as $field => $value ) {
431
-						if ( $field === 'TKT_qty' ) {
432
-							$TKT->set_qty( $value );
430
+					foreach ($TKT_values as $field => $value) {
431
+						if ($field === 'TKT_qty') {
432
+							$TKT->set_qty($value);
433 433
 						} else {
434
-							$TKT->set( $field, $value );
434
+							$TKT->set($field, $value);
435 435
 						}
436 436
 					}
437 437
 
438 438
 					//if $create_new_TKT is false then we can safely update the existing ticket.  Otherwise we have to create a new ticket.
439
-					if ( $create_new_TKT ) {
440
-						$new_tkt = $this->_duplicate_ticket( $TKT, $price_rows, $ticket_price, $base_price, $base_price_id );
439
+					if ($create_new_TKT) {
440
+						$new_tkt = $this->_duplicate_ticket($TKT, $price_rows, $ticket_price, $base_price, $base_price_id);
441 441
 					}
442 442
 				}
443 443
 
@@ -446,12 +446,12 @@  discard block
 block discarded – undo
446 446
 				$TKT = EE_Ticket::new_instance(
447 447
 					$TKT_values,
448 448
 					$timezone,
449
-					array( $this->_date_format_strings[ 'date' ], $this->_date_format_strings[ 'time' ]  )
449
+					array($this->_date_format_strings['date'], $this->_date_format_strings['time'])
450 450
 				);
451
-				if ( $TKT instanceof EE_Ticket ) {
451
+				if ($TKT instanceof EE_Ticket) {
452 452
 					// make sure ticket has an ID of setting relations won't work
453 453
 					$TKT->save();
454
-					$TKT = $this->_update_ticket_datetimes( $TKT, $saved_dtts, $dtts_added, $dtts_removed );
454
+					$TKT = $this->_update_ticket_datetimes($TKT, $saved_dtts, $dtts_added, $dtts_removed);
455 455
 					$update_prices = TRUE;
456 456
 				}
457 457
 			}
@@ -459,38 +459,38 @@  discard block
 block discarded – undo
459 459
 			//$TKT->save();
460 460
 
461 461
 			//before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date.
462
-			if( $TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date') ) {
463
-				$TKT->set('TKT_end_date', $TKT->get('TKT_start_date') );
462
+			if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) {
463
+				$TKT->set('TKT_end_date', $TKT->get('TKT_start_date'));
464 464
 				EE_Registry::instance()->load_helper('DTT_Helper');
465 465
 				$TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days');
466 466
 			}
467 467
 
468 468
 			//let's make sure the base price is handled
469
-			$TKT = ! $create_new_TKT ? $this->_add_prices_to_ticket( array(), $TKT, $update_prices, $base_price, $base_price_id ) : $TKT;
469
+			$TKT = ! $create_new_TKT ? $this->_add_prices_to_ticket(array(), $TKT, $update_prices, $base_price, $base_price_id) : $TKT;
470 470
 
471 471
 			//add/update price_modifiers
472
-			$TKT = ! $create_new_TKT ? $this->_add_prices_to_ticket( $price_rows, $TKT, $update_prices ) : $TKT;
472
+			$TKT = ! $create_new_TKT ? $this->_add_prices_to_ticket($price_rows, $TKT, $update_prices) : $TKT;
473 473
 
474 474
 			//need to make sue that the TKT_price is accurate after saving the prices.
475 475
 			$TKT->ensure_TKT_Price_correct();
476 476
 
477 477
 			//handle CREATING a default tkt from the incoming tkt but ONLY if this isn't an autosave.
478
-			if ( ! defined('DOING_AUTOSAVE' ) ) {
479
-				if ( !empty($tkt['TKT_is_default_selector'] ) ) {
478
+			if ( ! defined('DOING_AUTOSAVE')) {
479
+				if ( ! empty($tkt['TKT_is_default_selector'])) {
480 480
 					$update_prices = TRUE;
481 481
 					$new_default = clone $TKT;
482
-					$new_default->set( 'TKT_ID', 0 );
483
-					$new_default->set( 'TKT_is_default', 1 );
484
-					$new_default->set( 'TKT_row', 1 );
485
-					$new_default->set( 'TKT_price', $ticket_price );
482
+					$new_default->set('TKT_ID', 0);
483
+					$new_default->set('TKT_is_default', 1);
484
+					$new_default->set('TKT_row', 1);
485
+					$new_default->set('TKT_price', $ticket_price);
486 486
 					//remove any dtt relations cause we DON'T want dtt relations attached (note this is just removing the cached relations in the object)
487 487
 					$new_default->_remove_relations('Datetime');
488 488
 					//todo we need to add the current attached prices as new prices to the new default ticket.
489
-					$new_default = $this->_add_prices_to_ticket( $price_rows, $new_default, $update_prices );
489
+					$new_default = $this->_add_prices_to_ticket($price_rows, $new_default, $update_prices);
490 490
 					//don't forget the base price!
491
-					$new_default = $this->_add_prices_to_ticket( array(), $new_default, $update_prices, $base_price, $base_price_id );
491
+					$new_default = $this->_add_prices_to_ticket(array(), $new_default, $update_prices, $base_price, $base_price_id);
492 492
 					$new_default->save();
493
-					do_action( 'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_default_ticket', $new_default, $row, $TKT, $data );
493
+					do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_new_default_ticket', $new_default, $row, $TKT, $data);
494 494
 				}
495 495
 			}
496 496
 
@@ -501,19 +501,19 @@  discard block
 block discarded – undo
501 501
 			//let's assign any tickets that have been setup to the saved_tickets tracker
502 502
 			//save existing TKT
503 503
 			$TKT->save();
504
-			if ( $create_new_TKT && $new_tkt instanceof EE_Ticket ) {
504
+			if ($create_new_TKT && $new_tkt instanceof EE_Ticket) {
505 505
 				//save new TKT
506 506
 				$new_tkt->save();
507 507
 				//add new ticket to array
508
-				$saved_tickets[ $new_tkt->ID() ] = $new_tkt;
508
+				$saved_tickets[$new_tkt->ID()] = $new_tkt;
509 509
 
510
-				do_action( 'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_ticket', $new_tkt, $row, $tkt, $data );
510
+				do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_new_ticket', $new_tkt, $row, $tkt, $data);
511 511
 
512 512
 			} else {
513 513
 				//add tkt to saved tkts
514
-				$saved_tickets[ $TKT->ID() ] = $TKT;
514
+				$saved_tickets[$TKT->ID()] = $TKT;
515 515
 
516
-				do_action( 'AHEE__espresso_events_Pricing_Hooks___update_tkts_update_ticket', $TKT, $row, $tkt, $data );
516
+				do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_update_ticket', $TKT, $row, $tkt, $data);
517 517
 			}
518 518
 
519 519
 		}
@@ -523,22 +523,22 @@  discard block
 block discarded – undo
523 523
 		// (i.e. autosaves are happening and then in between autosaves the user trashes a ticket).
524 524
 		// Or a draft event was saved and in the process of editing a ticket is trashed.
525 525
 		// No sense in keeping all the related data in the db!
526
-		$old_tickets = isset( $old_tickets[0] ) && $old_tickets[0] == '' ? array() : $old_tickets;
527
-		$tickets_removed = array_diff( $old_tickets, array_keys($saved_tickets) );
526
+		$old_tickets = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets;
527
+		$tickets_removed = array_diff($old_tickets, array_keys($saved_tickets));
528 528
 
529
-		foreach ( $tickets_removed as $id ) {
530
-			$id = absint( $id );
529
+		foreach ($tickets_removed as $id) {
530
+			$id = absint($id);
531 531
 
532 532
 			//get the ticket for this id
533 533
 			$tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id);
534 534
 
535 535
 			//if this tkt is a default tkt we leave it alone cause it won't be attached to the datetime
536
-			if ( $tkt_to_remove->get('TKT_is_default') )
536
+			if ($tkt_to_remove->get('TKT_is_default'))
537 537
 				continue;
538 538
 
539 539
 			// if this tkt has any registrations attached so then we just ARCHIVE
540 540
 			// because we don't actually permanently delete these tickets.
541
-			if ( $tkt_to_remove->count_related('Registration') > 0 ) {
541
+			if ($tkt_to_remove->count_related('Registration') > 0) {
542 542
 				$tkt_to_remove->delete();
543 543
 				continue;
544 544
 			}
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
 			// (remember this process can ONLY kick off if there are NO tkts_sold)
548 548
 			$dtts = $tkt_to_remove->get_many_related('Datetime');
549 549
 
550
-			foreach( $dtts as $dtt ) {
550
+			foreach ($dtts as $dtt) {
551 551
 				$tkt_to_remove->_remove_relation_to($dtt, 'Datetime');
552 552
 			}
553 553
 
@@ -555,7 +555,7 @@  discard block
 block discarded – undo
555 555
 			// tickets can only be trashed if they don't have any TKTs sold (otherwise they are just archived))
556 556
 			$tkt_to_remove->delete_related_permanently('Price');
557 557
 
558
-			do_action( 'AHEE__espresso_events_Pricing_Hooks___update_tkts_delete_ticket', $tkt_to_remove );
558
+			do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_delete_ticket', $tkt_to_remove);
559 559
 
560 560
 			// finally let's delete this ticket
561 561
 			// (which should not be blocked at this point b/c we've removed all our relationships)
@@ -587,39 +587,39 @@  discard block
 block discarded – undo
587 587
 		// and removing the ticket from datetimes it got removed from.
588 588
 
589 589
 		// first let's add datetimes
590
-		if ( ! empty( $added_datetimes ) && is_array( $added_datetimes ) ) {
591
-			foreach ( $added_datetimes as $row_id ) {
592
-				$row_id = (int)$row_id;
593
-				if ( isset( $saved_datetimes[ $row_id ] ) && $saved_datetimes[ $row_id ] instanceof EE_Datetime ) {
594
-					$ticket->_add_relation_to( $saved_datetimes[ $row_id ], 'Datetime' );
590
+		if ( ! empty($added_datetimes) && is_array($added_datetimes)) {
591
+			foreach ($added_datetimes as $row_id) {
592
+				$row_id = (int) $row_id;
593
+				if (isset($saved_datetimes[$row_id]) && $saved_datetimes[$row_id] instanceof EE_Datetime) {
594
+					$ticket->_add_relation_to($saved_datetimes[$row_id], 'Datetime');
595 595
 					// Is this an existing ticket (has an ID) and does it have any sold?
596 596
 					// If so, then we need to add that to the DTT sold because this DTT is getting added.
597
-					if ( $ticket->ID() && $ticket->sold() > 0 ) {
598
-						$saved_datetimes[ $row_id ]->increase_sold( $ticket->sold() );
599
-						$saved_datetimes[ $row_id ]->save();
597
+					if ($ticket->ID() && $ticket->sold() > 0) {
598
+						$saved_datetimes[$row_id]->increase_sold($ticket->sold());
599
+						$saved_datetimes[$row_id]->save();
600 600
 					}
601 601
 				}
602 602
 			}
603 603
 		}
604 604
 		// then remove datetimes
605
-		if ( ! empty( $removed_datetimes ) && is_array( $removed_datetimes ) ) {
606
-			foreach ( $removed_datetimes as $row_id ) {
607
-				$row_id = (int)$row_id;
605
+		if ( ! empty($removed_datetimes) && is_array($removed_datetimes)) {
606
+			foreach ($removed_datetimes as $row_id) {
607
+				$row_id = (int) $row_id;
608 608
 				// its entirely possible that a datetime got deleted (instead of just removed from relationship.
609 609
 				// So make sure we skip over this if the dtt isn't in the $saved_datetimes array)
610
-				if ( isset( $saved_datetimes[ $row_id ] ) && $saved_datetimes[ $row_id ] instanceof EE_Datetime ) {
611
-					$ticket->_remove_relation_to( $saved_datetimes[ $row_id ], 'Datetime' );
610
+				if (isset($saved_datetimes[$row_id]) && $saved_datetimes[$row_id] instanceof EE_Datetime) {
611
+					$ticket->_remove_relation_to($saved_datetimes[$row_id], 'Datetime');
612 612
 					// Is this an existing ticket (has an ID) and does it have any sold?
613 613
 					// If so, then we need to remove it's sold from the DTT_sold.
614
-					if ( $ticket->ID() && $ticket->sold() > 0 ) {
615
-						$saved_datetimes[ $row_id ]->decrease_sold( $ticket->sold() );
616
-						$saved_datetimes[ $row_id ]->save();
614
+					if ($ticket->ID() && $ticket->sold() > 0) {
615
+						$saved_datetimes[$row_id]->decrease_sold($ticket->sold());
616
+						$saved_datetimes[$row_id]->save();
617 617
 					}
618 618
 				}
619 619
 			}
620 620
 		}
621 621
 		// cap ticket qty by datetime reg limits
622
-		$ticket->set_qty( min( $ticket->qty(), $ticket->qty( 'reg_limit' ) ) );
622
+		$ticket->set_qty(min($ticket->qty(), $ticket->qty('reg_limit')));
623 623
 		return $ticket;
624 624
 	}
625 625
 
@@ -640,39 +640,39 @@  discard block
 block discarded – undo
640 640
 		EE_Ticket $ticket,
641 641
 		$price_rows = array(),
642 642
 		$ticket_price = 0,
643
-		$base_price = 0 ,
643
+		$base_price = 0,
644 644
 		$base_price_id = 0
645 645
 	) {
646 646
 
647 647
 		// create new ticket that's a copy of the existing
648 648
 		// except a new id of course (and not archived)
649 649
 		// AND has the new TKT_price associated with it.
650
-		$new_ticket = clone( $ticket );
651
-		$new_ticket->set( 'TKT_ID', 0 );
652
-		$new_ticket->set( 'TKT_deleted', 0 );
653
-		$new_ticket->set( 'TKT_price', $ticket_price );
654
-		$new_ticket->set( 'TKT_sold', 0 );
650
+		$new_ticket = clone($ticket);
651
+		$new_ticket->set('TKT_ID', 0);
652
+		$new_ticket->set('TKT_deleted', 0);
653
+		$new_ticket->set('TKT_price', $ticket_price);
654
+		$new_ticket->set('TKT_sold', 0);
655 655
 		// let's get a new ID for this ticket
656 656
 		$new_ticket->save();
657 657
 		// we also need to make sure this new ticket gets the same datetime attachments as the archived ticket
658
-		$datetimes_on_existing = $ticket->get_many_related( 'Datetime' );
658
+		$datetimes_on_existing = $ticket->get_many_related('Datetime');
659 659
 		$new_ticket = $this->_update_ticket_datetimes(
660 660
 			$new_ticket,
661 661
 			$datetimes_on_existing,
662
-			array_keys( $datetimes_on_existing )
662
+			array_keys($datetimes_on_existing)
663 663
 		);
664 664
 
665 665
 		// $ticket will get archived later b/c we are NOT adding it to the saved_tickets array.
666 666
 		// if existing $ticket has sold amount, then we need to adjust the qty for the new TKT to = the remaining
667 667
 		// available.
668
-		if ( $ticket->sold() > 0 ) {
668
+		if ($ticket->sold() > 0) {
669 669
 			$new_qty = $ticket->qty() - $ticket->sold();
670
-			$new_ticket->set_qty( $new_qty );
670
+			$new_ticket->set_qty($new_qty);
671 671
 		}
672 672
 		//now we update the prices just for this ticket
673
-		$new_ticket = $this->_add_prices_to_ticket( $price_rows, $new_ticket, true );
673
+		$new_ticket = $this->_add_prices_to_ticket($price_rows, $new_ticket, true);
674 674
 		//and we update the base price
675
-		$new_ticket = $this->_add_prices_to_ticket( array(), $new_ticket, true, $base_price, $base_price_id );
675
+		$new_ticket = $this->_add_prices_to_ticket(array(), $new_ticket, true, $base_price, $base_price_id);
676 676
 		return $new_ticket;
677 677
 	}
678 678
 
@@ -692,7 +692,7 @@  discard block
 block discarded – undo
692 692
 	 * @param int|bool 		$base_price_id  if present then this is the base_price_id being updated.
693 693
 	 * @return EE_Ticket
694 694
 	 */
695
-	protected function  _add_prices_to_ticket( $prices = array(), EE_Ticket $ticket, $new_prices = FALSE, $base_price = FALSE, $base_price_id = FALSE ) {
695
+	protected function  _add_prices_to_ticket($prices = array(), EE_Ticket $ticket, $new_prices = FALSE, $base_price = FALSE, $base_price_id = FALSE) {
696 696
 
697 697
 		//let's just get any current prices that may exist on the given ticket so we can remove any prices that got trashed in this session.
698 698
 		$current_prices_on_ticket = $base_price !== FALSE ? $ticket->base_price(TRUE) : $ticket->price_modifiers();
@@ -700,7 +700,7 @@  discard block
 block discarded – undo
700 700
 		$updated_prices = array();
701 701
 
702 702
 		// if $base_price ! FALSE then updating a base price.
703
-		if ( $base_price !== FALSE ) {
703
+		if ($base_price !== FALSE) {
704 704
 			$prices[1] = array(
705 705
 				'PRC_ID' => $new_prices || $base_price_id === 1 ? NULL : $base_price_id,
706 706
 				'PRT_ID' => 1,
@@ -711,47 +711,47 @@  discard block
 block discarded – undo
711 711
 		}
712 712
 
713 713
 		//possibly need to save tkt
714
-		if ( ! $ticket->ID() )
714
+		if ( ! $ticket->ID())
715 715
 			$ticket->save();
716 716
 
717
-		foreach ( $prices as $row => $prc ) {
718
-			$prt_id = !empty( $prc['PRT_ID'] ) ? $prc['PRT_ID'] : NULL;
719
-			if ( empty($prt_id) )
717
+		foreach ($prices as $row => $prc) {
718
+			$prt_id = ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : NULL;
719
+			if (empty($prt_id))
720 720
 				continue; //prices MUST have a price type id.
721 721
 			$PRC_values = array(
722
-				'PRC_ID' => !empty( $prc['PRC_ID'] ) ? $prc['PRC_ID'] : NULL,
722
+				'PRC_ID' => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : NULL,
723 723
 				'PRT_ID' => $prt_id,
724
-				'PRC_amount' => !empty( $prc['PRC_amount'] ) ? $prc['PRC_amount'] : 0,
725
-				'PRC_name' => !empty( $prc['PRC_name'] ) ? $prc['PRC_name'] : '',
726
-				'PRC_desc' => !empty( $prc['PRC_desc'] ) ? $prc['PRC_desc'] : '',
724
+				'PRC_amount' => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0,
725
+				'PRC_name' => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '',
726
+				'PRC_desc' => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '',
727 727
 				'PRC_is_default' => false, //make sure we set PRC_is_default to false for all ticket saves from event_editor
728 728
 				'PRC_order' => $row
729 729
 				);
730
-			if ( $new_prices || empty( $PRC_values['PRC_ID'] ) ) {
730
+			if ($new_prices || empty($PRC_values['PRC_ID'])) {
731 731
 				$PRC_values['PRC_ID'] = 0;
732
-				$PRC = EE_Registry::instance()->load_class('Price', array( $PRC_values ), FALSE, FALSE);
732
+				$PRC = EE_Registry::instance()->load_class('Price', array($PRC_values), FALSE, FALSE);
733 733
 			} else {
734
-				$PRC = EE_Registry::instance()->load_model( 'Price' )->get_one_by_ID( $prc['PRC_ID'] );
734
+				$PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']);
735 735
 				//update this price with new values
736
-				foreach ( $PRC_values as $field => $newprc ) {
737
-					$PRC->set( $field, $newprc );
736
+				foreach ($PRC_values as $field => $newprc) {
737
+					$PRC->set($field, $newprc);
738 738
 				}
739 739
 			}
740 740
 			$PRC->save();
741 741
 			$prcid = $PRC->ID();
742 742
 			$updated_prices[$prcid] = $PRC;
743
-			$ticket->_add_relation_to( $PRC, 'Price' );
743
+			$ticket->_add_relation_to($PRC, 'Price');
744 744
 		}
745 745
 
746 746
 		//now let's remove any prices that got removed from the ticket
747
-		if ( !empty ( $current_prices_on_ticket ) ) {
747
+		if ( ! empty ($current_prices_on_ticket)) {
748 748
 			$current = array_keys($current_prices_on_ticket);
749 749
 			$updated = array_keys($updated_prices);
750 750
 			$prices_to_remove = array_diff($current, $updated);
751
-			if ( !empty( $prices_to_remove ) ) {
752
-				foreach ( $prices_to_remove as $prc_id ) {
751
+			if ( ! empty($prices_to_remove)) {
752
+				foreach ($prices_to_remove as $prc_id) {
753 753
 					$p = $current_prices_on_ticket[$prc_id];
754
-					$ticket->_remove_relation_to( $p, 'Price' );
754
+					$ticket->_remove_relation_to($p, 'Price');
755 755
 
756 756
 					//delete permanently the price
757 757
 					$p->delete_permanently();
@@ -764,7 +764,7 @@  discard block
 block discarded – undo
764 764
 
765 765
 
766 766
 
767
-	public function autosave_handling( $event_admin_obj ) {
767
+	public function autosave_handling($event_admin_obj) {
768 768
 		return $event_admin_obj; //doing nothing for the moment.
769 769
 		//todo when I get to this remember that I need to set the template args on the $event_admin_obj (use the set_template_args() method)
770 770
 
@@ -798,12 +798,12 @@  discard block
 block discarded – undo
798 798
 
799 799
 		//default main template args
800 800
 		$main_template_args = array(
801
-			'event_datetime_help_link' => EEH_Template::get_help_tab_link('event_editor_event_datetimes_help_tab', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE ), //todo need to add a filter to the template for the help text in the Events_Admin_Page core file so we can add further help
801
+			'event_datetime_help_link' => EEH_Template::get_help_tab_link('event_editor_event_datetimes_help_tab', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE), //todo need to add a filter to the template for the help text in the Events_Admin_Page core file so we can add further help
802 802
 			'existing_datetime_ids' => '',
803 803
 			'total_dtt_rows' => 1,
804
-			'add_new_dtt_help_link' => EEH_Template::get_help_tab_link('add_new_dtt_info', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE ), //todo need to add this help info id to the Events_Admin_Page core file so we can access it here.
804
+			'add_new_dtt_help_link' => EEH_Template::get_help_tab_link('add_new_dtt_info', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE), //todo need to add this help info id to the Events_Admin_Page core file so we can access it here.
805 805
 			'datetime_rows' => '',
806
-			'show_tickets_container' => '',//$this->_adminpage_obj->get_cpt_model_obj()->ID() > 1 ? ' style="display:none;"' : '',
806
+			'show_tickets_container' => '', //$this->_adminpage_obj->get_cpt_model_obj()->ID() > 1 ? ' style="display:none;"' : '',
807 807
 			'ticket_rows' => '',
808 808
 			'existing_ticket_ids' => '',
809 809
 			'total_ticket_rows' => 1,
@@ -813,7 +813,7 @@  discard block
 block discarded – undo
813 813
 
814 814
 		$timezone = $evtobj instanceof EE_Event ? $evtobj->timezone_string() : NULL;
815 815
 
816
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
816
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
817 817
 
818 818
 		/**
819 819
 		 * 1. Start with retrieving Datetimes
@@ -821,25 +821,25 @@  discard block
 block discarded – undo
821 821
 		 * 3. For each ticket get related prices
822 822
 		 */
823 823
 
824
-		$DTM = EE_Registry::instance()->load_model('Datetime', array($timezone) );
825
-		$times = $DTM->get_all_event_dates( $evtID );
824
+		$DTM = EE_Registry::instance()->load_model('Datetime', array($timezone));
825
+		$times = $DTM->get_all_event_dates($evtID);
826 826
 
827 827
 
828 828
 
829 829
 		$main_template_args['total_dtt_rows'] = count($times);
830
-		foreach ( $times as $time ) {
830
+		foreach ($times as $time) {
831 831
 			$dttid = $time->get('DTT_ID');
832 832
 			$dttrow = $time->get('DTT_order');
833 833
 			$existing_datetime_ids[] = $dttid;
834 834
 
835 835
 			//tickets attached
836
-			$related_tickets = $time->ID() > 0 ? $time->get_many_related('Ticket', array( array( 'OR' => array( 'TKT_deleted' => 1, 'TKT_deleted*' => 0 ) ), 'default_where_conditions' => 'none', 'order_by' => array('TKT_order' => 'ASC' ) ) ) : array();
836
+			$related_tickets = $time->ID() > 0 ? $time->get_many_related('Ticket', array(array('OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0)), 'default_where_conditions' => 'none', 'order_by' => array('TKT_order' => 'ASC'))) : array();
837 837
 
838 838
 			//if there are no related tickets this is likely a new event OR autodraft
839 839
 			// event so we need to generate the default tickets because dtts
840 840
 			// ALWAYS have at least one related ticket!!.  EXCEPT, we dont' do this if there is already more than one
841 841
 			// datetime on the event.
842
-			if ( empty ( $related_tickets ) && count( $times ) < 2 ) {
842
+			if (empty ($related_tickets) && count($times) < 2) {
843 843
 				$related_tickets = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets();
844 844
 			}
845 845
 
@@ -848,11 +848,11 @@  discard block
 block discarded – undo
848 848
 
849 849
 			//loop through and setup the ticket rows and make sure the order is set.
850 850
 			$order = 0;
851
-			foreach ( $related_tickets as $ticket ) {
851
+			foreach ($related_tickets as $ticket) {
852 852
 				$tktid = $ticket->get('TKT_ID');
853 853
 				$tktrow = $ticket->get('TKT_row');
854 854
 				//we only want unique tickets in our final display!!
855
-				if ( !in_array( $tktid, $existing_ticket_ids ) ) {
855
+				if ( ! in_array($tktid, $existing_ticket_ids)) {
856 856
 					$existing_ticket_ids[] = $tktid;
857 857
 					$all_tickets[] = $ticket;
858 858
 				}
@@ -861,56 +861,56 @@  discard block
 block discarded – undo
861 861
 				$datetime_tickets[$dttid][] = $tktrow;
862 862
 
863 863
 				//temporary cache of this datetime info for this ticket for later processing of ticket rows.
864
-				if ( !isset( $ticket_datetimes[$tktid] ) || ! in_array( $dttrow, $ticket_datetimes[$tktid] ) )
864
+				if ( ! isset($ticket_datetimes[$tktid]) || ! in_array($dttrow, $ticket_datetimes[$tktid]))
865 865
 					$ticket_datetimes[$tktid][] = $dttrow;
866 866
 			}
867 867
 		}
868 868
 
869
-		$main_template_args['total_ticket_rows'] = count( $existing_ticket_ids );
870
-		$main_template_args['existing_ticket_ids'] = implode( ',', $existing_ticket_ids );
871
-		$main_template_args['existing_datetime_ids'] = implode( ',', $existing_datetime_ids );
869
+		$main_template_args['total_ticket_rows'] = count($existing_ticket_ids);
870
+		$main_template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids);
871
+		$main_template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids);
872 872
 
873 873
 		//sort $all_tickets by order
874
-		usort( $all_tickets, function( $a, $b ) {
874
+		usort($all_tickets, function($a, $b) {
875 875
 			$a_order = (int) $a->get('TKT_order');
876 876
 			$b_order = (int) $b->get('TKT_order');
877
-			if ( $a_order == $b_order ) {
877
+			if ($a_order == $b_order) {
878 878
 				return 0;
879 879
 			}
880
-			return ( $a_order < $b_order ) ? -1 : 1;
880
+			return ($a_order < $b_order) ? -1 : 1;
881 881
 		});
882 882
 
883 883
 		//k NOW we have all the data we need for setting up the dtt rows and ticket rows so we start our dtt loop again.
884 884
 		$dttrow = 1;
885
-		foreach ( $times as $time ) {
886
-			$main_template_args['datetime_rows'] .= $this->_get_datetime_row( $dttrow, $time, $datetime_tickets, $all_tickets, FALSE, $times );
885
+		foreach ($times as $time) {
886
+			$main_template_args['datetime_rows'] .= $this->_get_datetime_row($dttrow, $time, $datetime_tickets, $all_tickets, FALSE, $times);
887 887
 			$dttrow++;
888 888
 		}
889 889
 
890 890
 		//then loop through all tickets for the ticket rows.
891 891
 		$tktrow = 1;
892
-		foreach ( $all_tickets as $ticket ) {
893
-			$main_template_args['ticket_rows'] .= $this->_get_ticket_row( $tktrow, $ticket, $ticket_datetimes, $times, FALSE, $all_tickets );
892
+		foreach ($all_tickets as $ticket) {
893
+			$main_template_args['ticket_rows'] .= $this->_get_ticket_row($tktrow, $ticket, $ticket_datetimes, $times, FALSE, $all_tickets);
894 894
 			$tktrow++;
895 895
 		}
896 896
 
897 897
 		$main_template_args['ticket_js_structure'] = $this->_get_ticket_js_structure($times, $all_tickets);
898
-		$template = PRICING_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php';
899
-		EEH_Template::display_template( $template, $main_template_args );
898
+		$template = PRICING_TEMPLATE_PATH.'event_tickets_metabox_main.template.php';
899
+		EEH_Template::display_template($template, $main_template_args);
900 900
 		return;
901 901
 	}
902 902
 
903 903
 
904 904
 
905
-	protected function _get_datetime_row( $dttrow, EE_Datetime $dtt, $datetime_tickets, $all_tickets, $default = FALSE, $all_dtts = array() ) {
905
+	protected function _get_datetime_row($dttrow, EE_Datetime $dtt, $datetime_tickets, $all_tickets, $default = FALSE, $all_dtts = array()) {
906 906
 
907 907
 		$dtt_display_template_args = array(
908
-			'dtt_edit_row' => $this->_get_dtt_edit_row( $dttrow, $dtt, $default, $all_dtts ),
909
-			'dtt_attached_tickets_row' => $this->_get_dtt_attached_tickets_row( $dttrow, $dtt, $datetime_tickets, $all_tickets, $default ),
908
+			'dtt_edit_row' => $this->_get_dtt_edit_row($dttrow, $dtt, $default, $all_dtts),
909
+			'dtt_attached_tickets_row' => $this->_get_dtt_attached_tickets_row($dttrow, $dtt, $datetime_tickets, $all_tickets, $default),
910 910
 			'dtt_row' => $default ? 'DTTNUM' : $dttrow
911 911
 			);
912
-		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_row_wrapper.template.php';
913
-		return EEH_Template::display_template( $template, $dtt_display_template_args, TRUE);
912
+		$template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_row_wrapper.template.php';
913
+		return EEH_Template::display_template($template, $dtt_display_template_args, TRUE);
914 914
 	}
915 915
 
916 916
 
@@ -928,7 +928,7 @@  discard block
 block discarded – undo
928 928
 	 *
929 929
 	 * @return string Generated edit row.
930 930
 	 */
931
-	protected function _get_dtt_edit_row( $dttrow, $dtt, $default, $all_dtts ) {
931
+	protected function _get_dtt_edit_row($dttrow, $dtt, $default, $all_dtts) {
932 932
 
933 933
 		// if the incomign $dtt object is NOT an instance of EE_Datetime then force default to true.
934 934
 		$default = ! $dtt instanceof EE_Datetime ? true : false;
@@ -936,30 +936,30 @@  discard block
 block discarded – undo
936 936
 		$template_args = array(
937 937
 			'dtt_row' => $default ? 'DTTNUM' : $dttrow,
938 938
 			'event_datetimes_name' => $default ? 'DTTNAMEATTR' : 'edit_event_datetimes',
939
-			'edit_dtt_expanded' => '',//$this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? '' : ' ee-edit-editing',
939
+			'edit_dtt_expanded' => '', //$this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? '' : ' ee-edit-editing',
940 940
 			'DTT_ID' => $default ? '' : $dtt->ID(),
941 941
 			'DTT_name' => $default ? '' : $dtt->name(),
942 942
 			'DTT_description' => $default ? '' : $dtt->description(),
943
-			'DTT_EVT_start' => $default ? '' : $dtt->start_date( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ),
944
-			'DTT_EVT_end' => $default ? '' : $dtt->end_date( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ),
945
-			'DTT_reg_limit' => $default ? '' : $dtt->get_pretty('DTT_reg_limit','input'),
943
+			'DTT_EVT_start' => $default ? '' : $dtt->start_date($this->_date_format_strings['date'].' '.$this->_date_format_strings['time']),
944
+			'DTT_EVT_end' => $default ? '' : $dtt->end_date($this->_date_format_strings['date'].' '.$this->_date_format_strings['time']),
945
+			'DTT_reg_limit' => $default ? '' : $dtt->get_pretty('DTT_reg_limit', 'input'),
946 946
 			'DTT_order' => $default ? 'DTTNUM' : $dttrow,
947 947
 			'dtt_sold' => $default ? '0' : $dtt->get('DTT_sold'),
948
-			'clone_icon' => !empty( $dtt ) && $dtt->get('DTT_sold') > 0 ? '' : 'clone-icon ee-icon ee-icon-clone clickable',
949
-			'trash_icon' => !empty( $dtt ) && $dtt->get('DTT_sold') > 0  ? 'ee-lock-icon' : 'trash-icon dashicons dashicons-post-trash clickable'
948
+			'clone_icon' => ! empty($dtt) && $dtt->get('DTT_sold') > 0 ? '' : 'clone-icon ee-icon ee-icon-clone clickable',
949
+			'trash_icon' => ! empty($dtt) && $dtt->get('DTT_sold') > 0 ? 'ee-lock-icon' : 'trash-icon dashicons dashicons-post-trash clickable'
950 950
 			);
951 951
 
952
-		$template_args['show_trash'] = count( $all_dtts ) === 1 && $template_args['trash_icon'] !== 'ee-lock-icon' ? ' style="display:none"' : '';
952
+		$template_args['show_trash'] = count($all_dtts) === 1 && $template_args['trash_icon'] !== 'ee-lock-icon' ? ' style="display:none"' : '';
953 953
 
954 954
 		//allow filtering of template args at this point.
955
-		$template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_dtt_edit_row__template_args', $template_args, $dttrow, $dtt, $default, $all_dtts, $this->_is_creating_event );
955
+		$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_dtt_edit_row__template_args', $template_args, $dttrow, $dtt, $default, $all_dtts, $this->_is_creating_event);
956 956
 
957
-		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_edit_row.template.php';
958
-		return EEH_Template::display_template( $template, $template_args, TRUE );
957
+		$template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_edit_row.template.php';
958
+		return EEH_Template::display_template($template, $template_args, TRUE);
959 959
 	}
960 960
 
961 961
 
962
-	protected function _get_dtt_attached_tickets_row( $dttrow, $dtt, $datetime_tickets, $all_tickets, $default ) {
962
+	protected function _get_dtt_attached_tickets_row($dttrow, $dtt, $datetime_tickets, $all_tickets, $default) {
963 963
 
964 964
 		$template_args = array(
965 965
 			'dtt_row' => $default ? 'DTTNUM' : $dttrow,
@@ -967,47 +967,47 @@  discard block
 block discarded – undo
967 967
 			'DTT_description' => $default ? '' : $dtt->description(),
968 968
 			'datetime_tickets_list' => $default ? '<li class="hidden"></li>' : '',
969 969
 			'show_tickets_row' => ' style="display:none;"', //$default || $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? ' style="display:none;"' : '',
970
-			'add_new_datetime_ticket_help_link' => EEH_Template::get_help_tab_link('add_new_ticket_via_datetime', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE ), //todo need to add this help info id to the Events_Admin_Page core file so we can access it here.
970
+			'add_new_datetime_ticket_help_link' => EEH_Template::get_help_tab_link('add_new_ticket_via_datetime', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE), //todo need to add this help info id to the Events_Admin_Page core file so we can access it here.
971 971
 			'DTT_ID' => $default ? '' : $dtt->ID()
972 972
 			);
973 973
 
974 974
 		//need to setup the list items (but only if this isnt' a default skeleton setup)
975
-		if ( !$default ) {
975
+		if ( ! $default) {
976 976
 			$tktrow = 1;
977
-			foreach ( $all_tickets as $ticket ) {
978
-				$template_args['datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item( $dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default );
977
+			foreach ($all_tickets as $ticket) {
978
+				$template_args['datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item($dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default);
979 979
 				$tktrow++;
980 980
 			}
981 981
 		}
982 982
 
983 983
 		//filter template args at this point
984
-		$template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_dtt_attached_ticket_row__template_args', $template_args, $dttrow, $dtt, $datetime_tickets, $all_tickets, $default, $this->_is_creating_event );
984
+		$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_dtt_attached_ticket_row__template_args', $template_args, $dttrow, $dtt, $datetime_tickets, $all_tickets, $default, $this->_is_creating_event);
985 985
 
986
-		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_attached_tickets_row.template.php';
987
-		return EEH_Template::display_template( $template, $template_args, TRUE );
986
+		$template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_attached_tickets_row.template.php';
987
+		return EEH_Template::display_template($template, $template_args, TRUE);
988 988
 	}
989 989
 
990 990
 
991 991
 
992
-	protected function _get_datetime_tickets_list_item( $dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default ) {
993
-		$tktid = !empty( $ticket ) ? $ticket->ID() : 0;
994
-		$dtt_tkts = $dtt instanceof EE_Datetime && isset( $datetime_tickets[$dtt->ID()] ) ? $datetime_tickets[$dtt->ID()] : array();
992
+	protected function _get_datetime_tickets_list_item($dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default) {
993
+		$tktid = ! empty($ticket) ? $ticket->ID() : 0;
994
+		$dtt_tkts = $dtt instanceof EE_Datetime && isset($datetime_tickets[$dtt->ID()]) ? $datetime_tickets[$dtt->ID()] : array();
995 995
 
996
-		$displayrow = !empty( $ticket ) ? $ticket->get('TKT_row') : 0;
996
+		$displayrow = ! empty($ticket) ? $ticket->get('TKT_row') : 0;
997 997
 		$template_args = array(
998 998
 			'dtt_row' => $default ? 'DTTNUM' : $dttrow,
999
-			'tkt_row' => $default && empty( $ticket ) ? 'TICKETNUM' : $tktrow,
999
+			'tkt_row' => $default && empty($ticket) ? 'TICKETNUM' : $tktrow,
1000 1000
 			'datetime_ticket_checked' => in_array($displayrow, $dtt_tkts) ? ' checked="checked"' : '',
1001 1001
 			'ticket_selected' => in_array($displayrow, $dtt_tkts) ? ' ticket-selected' : '',
1002
-			'TKT_name' => $default && empty( $ticket ) ? 'TKTNAME' : $ticket->get('TKT_name'),
1003
-			'tkt_status_class' => ( $default && empty( $ticket ) ) || $this->_is_creating_event ? ' tkt-status-' . EE_Ticket::onsale : ' tkt-status-' . $ticket->ticket_status(),
1002
+			'TKT_name' => $default && empty($ticket) ? 'TKTNAME' : $ticket->get('TKT_name'),
1003
+			'tkt_status_class' => ($default && empty($ticket)) || $this->_is_creating_event ? ' tkt-status-'.EE_Ticket::onsale : ' tkt-status-'.$ticket->ticket_status(),
1004 1004
 			);
1005 1005
 
1006 1006
 		//filter template args
1007
-		$template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_datetime_tickets_list_item__template_args', $template_args, $dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default, $this->_is_creating_event );
1007
+		$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_datetime_tickets_list_item__template_args', $template_args, $dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default, $this->_is_creating_event);
1008 1008
 
1009
-		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_dtt_tickets_list.template.php';
1010
-		return EEH_Template::display_template( $template, $template_args, TRUE );
1009
+		$template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_dtt_tickets_list.template.php';
1010
+		return EEH_Template::display_template($template, $template_args, TRUE);
1011 1011
 	}
1012 1012
 
1013 1013
 
@@ -1029,32 +1029,32 @@  discard block
 block discarded – undo
1029 1029
 	 *
1030 1030
 	 * @return [type] [description]
1031 1031
 	 */
1032
-	protected function _get_ticket_row( $tktrow, $ticket, $ticket_datetimes, $all_dtts, $default = FALSE, $all_tickets = array() ) {
1032
+	protected function _get_ticket_row($tktrow, $ticket, $ticket_datetimes, $all_dtts, $default = FALSE, $all_tickets = array()) {
1033 1033
 
1034 1034
 		//if $ticket is not an instance of EE_Ticket then force default to true.
1035
-		$default =  ! $ticket instanceof EE_Ticket ? true : false;
1035
+		$default = ! $ticket instanceof EE_Ticket ? true : false;
1036 1036
 
1037 1037
 
1038
-		$prices = !empty($ticket) && !$default ? $ticket->get_many_related('Price', array('default_where_conditions' => 'none', 'order_by' => array('PRC_order' => 'ASC') ) ) : array();
1038
+		$prices = ! empty($ticket) && ! $default ? $ticket->get_many_related('Price', array('default_where_conditions' => 'none', 'order_by' => array('PRC_order' => 'ASC'))) : array();
1039 1039
 
1040 1040
 		// check if we're dealing with a default ticket in which case we don't want any starting_ticket_datetime_row values set (otherwise there won't be any new relationships created for tickets based off of the default ticket).  This will future proof in case there is ever any behaviour change between what the primary_key defaults to.
1041
-		$default_dtt = $default || ($ticket instanceof EE_Ticket && $ticket->get('TKT_is_default') ) ? TRUE : FALSE;
1041
+		$default_dtt = $default || ($ticket instanceof EE_Ticket && $ticket->get('TKT_is_default')) ? TRUE : FALSE;
1042 1042
 
1043
-		$tkt_dtts = $ticket instanceof EE_Ticket && isset( $ticket_datetimes[$ticket->ID()] ) ? $ticket_datetimes[$ticket->ID()] : array();
1043
+		$tkt_dtts = $ticket instanceof EE_Ticket && isset($ticket_datetimes[$ticket->ID()]) ? $ticket_datetimes[$ticket->ID()] : array();
1044 1044
 
1045 1045
 		$ticket_subtotal = $default ? 0 : $ticket->get_ticket_subtotal();
1046
-		$base_price = $default ? NULL :  $ticket->base_price();
1046
+		$base_price = $default ? NULL : $ticket->base_price();
1047 1047
 		$count_price_mods = EEM_Price::instance()->get_all_default_prices(TRUE);
1048 1048
 
1049 1049
 		//breaking out complicated condition for ticket_status
1050
-		if ( $default ) {
1051
-			$ticket_status_class = ' tkt-status-' . EE_Ticket::onsale;
1050
+		if ($default) {
1051
+			$ticket_status_class = ' tkt-status-'.EE_Ticket::onsale;
1052 1052
 		} else {
1053
-			$ticket_status_class =  $ticket->is_default() ? ' tkt-status-' . EE_Ticket::onsale : ' tkt-status-' . $ticket->ticket_status();
1053
+			$ticket_status_class = $ticket->is_default() ? ' tkt-status-'.EE_Ticket::onsale : ' tkt-status-'.$ticket->ticket_status();
1054 1054
 		}
1055 1055
 
1056 1056
 		//breaking out complicated condition for TKT_taxable
1057
-		if ( $default ) {
1057
+		if ($default) {
1058 1058
 			$TKT_taxable = '';
1059 1059
 		} else {
1060 1060
 			$TKT_taxable = $ticket->get('TKT_taxable') ? ' checked="checked"' : '';
@@ -1069,19 +1069,19 @@  discard block
 block discarded – undo
1069 1069
 			'edit_tkt_expanded' => '',
1070 1070
 			'edit_tickets_name' => $default ? 'TICKETNAMEATTR' : 'edit_tickets',
1071 1071
 			'TKT_name' => $default ? '' : $ticket->get('TKT_name'),
1072
-			'TKT_start_date' => $default ? '' : $ticket->get_date('TKT_start_date', $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ),
1073
-			'TKT_end_date' => $default ? '' : $ticket->get_date('TKT_end_date', $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time']  ),
1074
-			'TKT_status' => $default ? EEH_Template::pretty_status(EE_Ticket::onsale, FALSE, 'sentence') : $ticket->is_default() ? EEH_Template::pretty_status( EE_Ticket::onsale, FALSE, 'sentence') : $ticket->ticket_status(TRUE),
1072
+			'TKT_start_date' => $default ? '' : $ticket->get_date('TKT_start_date', $this->_date_format_strings['date'].' '.$this->_date_format_strings['time']),
1073
+			'TKT_end_date' => $default ? '' : $ticket->get_date('TKT_end_date', $this->_date_format_strings['date'].' '.$this->_date_format_strings['time']),
1074
+			'TKT_status' => $default ? EEH_Template::pretty_status(EE_Ticket::onsale, FALSE, 'sentence') : $ticket->is_default() ? EEH_Template::pretty_status(EE_Ticket::onsale, FALSE, 'sentence') : $ticket->ticket_status(TRUE),
1075 1075
 			'TKT_price' => $default ? '' : EEH_Template::format_currency($ticket->get_ticket_total_with_taxes(), FALSE, FALSE),
1076 1076
 			'TKT_price_code' => EE_Registry::instance()->CFG->currency->code,
1077 1077
 			'TKT_price_amount' => $default ? 0 : $ticket_subtotal,
1078
-			'TKT_qty' => $default ? '' : $ticket->get_pretty('TKT_qty','symbol'),
1079
-			'TKT_qty_for_input'=> $default ? '' : $ticket->get_pretty('TKT_qty','input'),
1080
-			'TKT_uses' => $default ? '' : $ticket->get_pretty('TKT_uses','input'),
1081
-			'TKT_min' => $default ? '' : ( $ticket->get('TKT_min') === -1 || $ticket->get('TKT_min') === 0 ? '' : $ticket->get('TKT_min') ),
1082
-			'TKT_max' => $default ? '' :  $ticket->get_pretty('TKT_max','input'),
1078
+			'TKT_qty' => $default ? '' : $ticket->get_pretty('TKT_qty', 'symbol'),
1079
+			'TKT_qty_for_input'=> $default ? '' : $ticket->get_pretty('TKT_qty', 'input'),
1080
+			'TKT_uses' => $default ? '' : $ticket->get_pretty('TKT_uses', 'input'),
1081
+			'TKT_min' => $default ? '' : ($ticket->get('TKT_min') === -1 || $ticket->get('TKT_min') === 0 ? '' : $ticket->get('TKT_min')),
1082
+			'TKT_max' => $default ? '' : $ticket->get_pretty('TKT_max', 'input'),
1083 1083
 			'TKT_sold' => $default ? 0 : $ticket->tickets_sold('ticket'),
1084
-			'TKT_registrations' => $default ? 0 : $ticket->count_registrations( array( array( 'STS_ID' => array( '!=', EEM_Registration::status_id_incomplete ) ) ) ),
1084
+			'TKT_registrations' => $default ? 0 : $ticket->count_registrations(array(array('STS_ID' => array('!=', EEM_Registration::status_id_incomplete)))),
1085 1085
 			'TKT_ID' => $default ? 0 : $ticket->get('TKT_ID'),
1086 1086
 			'TKT_description' => $default ? '' : $ticket->get('TKT_description'),
1087 1087
 			'TKT_is_default' => $default ? 0 : $ticket->get('TKT_is_default'),
@@ -1090,99 +1090,99 @@  discard block
 block discarded – undo
1090 1090
 			'ticket_price_rows' => '',
1091 1091
 			'TKT_base_price' => $default || ! $base_price instanceof EE_Price ? '' : $base_price->get_pretty('PRC_amount', 'localized_float'),
1092 1092
 			'TKT_base_price_ID' => $default || ! $base_price instanceof EE_Price ? 0 : $base_price->ID(),
1093
-			'show_price_modifier' => count($prices) > 1 || ( $default && $count_price_mods > 0 ) ? '' : ' style="display:none;"',
1094
-			'show_price_mod_button' => count($prices) > 1 || ( $default && $count_price_mods > 0 ) || ( !$default && $ticket->get('TKT_deleted') ) ? ' style="display:none;"' : '',
1093
+			'show_price_modifier' => count($prices) > 1 || ($default && $count_price_mods > 0) ? '' : ' style="display:none;"',
1094
+			'show_price_mod_button' => count($prices) > 1 || ($default && $count_price_mods > 0) || ( ! $default && $ticket->get('TKT_deleted')) ? ' style="display:none;"' : '',
1095 1095
 			'total_price_rows' => count($prices) > 1 ? count($prices) : 1,
1096 1096
 			'ticket_datetimes_list' => $default ? '<li class="hidden"></li>' : '',
1097 1097
 			'starting_ticket_datetime_rows' => $default || $default_dtt ? '' : implode(',', $tkt_dtts),
1098 1098
 			'ticket_datetime_rows' => $default ? '' : implode(',', $tkt_dtts),
1099
-			'existing_ticket_price_ids' => $default, '', implode(',', array_keys( $prices) ),
1099
+			'existing_ticket_price_ids' => $default, '', implode(',', array_keys($prices)),
1100 1100
 			'ticket_template_id' => $default ? 0 : $ticket->get('TTM_ID'),
1101 1101
 			'TKT_taxable' => $TKT_taxable,
1102 1102
 			'display_subtotal' => $ticket instanceof EE_Ticket && $ticket->get('TKT_taxable') ? '' : ' style="display:none"',
1103 1103
 			'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign,
1104
-			'TKT_subtotal_amount_display' => EEH_Template::format_currency($ticket_subtotal, FALSE, FALSE ),
1104
+			'TKT_subtotal_amount_display' => EEH_Template::format_currency($ticket_subtotal, FALSE, FALSE),
1105 1105
 			'TKT_subtotal_amount' => $ticket_subtotal,
1106
-			'tax_rows' => $this->_get_tax_rows( $tktrow, $ticket ),
1107
-			'disabled' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? TRUE: FALSE,
1106
+			'tax_rows' => $this->_get_tax_rows($tktrow, $ticket),
1107
+			'disabled' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? TRUE : FALSE,
1108 1108
 			'ticket_archive_class' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? ' ticket-archived' : '',
1109 1109
 			'trash_icon' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? 'ee-lock-icon ' : 'trash-icon dashicons dashicons-post-trash clickable',
1110 1110
 			'clone_icon' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? '' : 'clone-icon ee-icon ee-icon-clone clickable'
1111 1111
 			);
1112 1112
 
1113
-		$template_args['trash_hidden'] = count( $all_tickets ) === 1 && $template_args['trash_icon'] != 'ee-lock-icon' ? ' style="display:none"' : '';
1113
+		$template_args['trash_hidden'] = count($all_tickets) === 1 && $template_args['trash_icon'] != 'ee-lock-icon' ? ' style="display:none"' : '';
1114 1114
 
1115 1115
 		//handle rows that should NOT be empty
1116
-		if ( empty( $template_args['TKT_start_date'] ) ) {
1116
+		if (empty($template_args['TKT_start_date'])) {
1117 1117
 			//if empty then the start date will be now.
1118
-			$template_args['TKT_start_date'] = date( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] , current_time('timestamp'));
1119
-			$template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale;
1118
+			$template_args['TKT_start_date'] = date($this->_date_format_strings['date'].' '.$this->_date_format_strings['time'], current_time('timestamp'));
1119
+			$template_args['tkt_status_class'] = ' tkt-status-'.EE_Ticket::onsale;
1120 1120
 		}
1121 1121
 
1122
-		if ( empty( $template_args['TKT_end_date'] ) ) {
1122
+		if (empty($template_args['TKT_end_date'])) {
1123 1123
 
1124 1124
 			//get the earliest datetime (if present);
1125
-			$earliest_dtt = $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? $this->_adminpage_obj->get_cpt_model_obj()->get_first_related('Datetime', array('order_by'=> array('DTT_EVT_start' => 'ASC' ) ) ) : NULL;
1125
+			$earliest_dtt = $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? $this->_adminpage_obj->get_cpt_model_obj()->get_first_related('Datetime', array('order_by'=> array('DTT_EVT_start' => 'ASC'))) : NULL;
1126 1126
 
1127
-			if ( !empty( $earliest_dtt ) ) {
1128
-				$template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] );
1127
+			if ( ! empty($earliest_dtt)) {
1128
+				$template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', $this->_date_format_strings['date'].' '.$this->_date_format_strings['time']);
1129 1129
 			} else {
1130 1130
 				//default so let's just use what's been set for the default date-time which is 30 days from now.
1131
-				$template_args['TKT_end_date'] = date( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] , mktime(24, 0, 0, date("m"), date("d") + 29, date("Y") )  );
1131
+				$template_args['TKT_end_date'] = date($this->_date_format_strings['date'].' '.$this->_date_format_strings['time'], mktime(24, 0, 0, date("m"), date("d") + 29, date("Y")));
1132 1132
 			}
1133
-			$template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale;
1133
+			$template_args['tkt_status_class'] = ' tkt-status-'.EE_Ticket::onsale;
1134 1134
 		}
1135 1135
 
1136 1136
 		//generate ticket_datetime items
1137
-		if ( ! $default ) {
1137
+		if ( ! $default) {
1138 1138
 			$dttrow = 1;
1139
-			foreach ( $all_dtts as $dtt ) {
1140
-				$template_args['ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item( $dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default );
1139
+			foreach ($all_dtts as $dtt) {
1140
+				$template_args['ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item($dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default);
1141 1141
 				$dttrow++;
1142 1142
 			}
1143 1143
 		}
1144 1144
 
1145 1145
 		$prcrow = 1;
1146
-		foreach ( $prices as $price ) {
1147
-			if ( $price->is_base_price() ) {
1146
+		foreach ($prices as $price) {
1147
+			if ($price->is_base_price()) {
1148 1148
 				$prcrow++;
1149 1149
 				continue;
1150 1150
 			}
1151
-			$show_trash = ( count( $prices ) > 1 && $prcrow === 1 ) || count( $prices ) === 1  ? FALSE : TRUE;
1152
-			$show_create = count( $prices ) > 1 && count( $prices ) !== $prcrow ? FALSE : TRUE;
1153
-			$template_args['ticket_price_rows'] .= $this->_get_ticket_price_row( $tktrow, $prcrow, $price, $default, $ticket, $show_trash, $show_create );
1151
+			$show_trash = (count($prices) > 1 && $prcrow === 1) || count($prices) === 1 ? FALSE : TRUE;
1152
+			$show_create = count($prices) > 1 && count($prices) !== $prcrow ? FALSE : TRUE;
1153
+			$template_args['ticket_price_rows'] .= $this->_get_ticket_price_row($tktrow, $prcrow, $price, $default, $ticket, $show_trash, $show_create);
1154 1154
 			$prcrow++;
1155 1155
 		}
1156 1156
 
1157 1157
 		//filter $template_args
1158
-		$template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_ticket_row__template_args', $template_args, $tktrow, $ticket, $ticket_datetimes, $all_dtts, $default, $all_tickets, $this->_is_creating_event );
1158
+		$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_row__template_args', $template_args, $tktrow, $ticket, $ticket_datetimes, $all_dtts, $default, $all_tickets, $this->_is_creating_event);
1159 1159
 
1160
-		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_row.template.php';
1161
-		return EEH_Template::display_template( $template, $template_args, TRUE );
1160
+		$template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_row.template.php';
1161
+		return EEH_Template::display_template($template, $template_args, TRUE);
1162 1162
 	}
1163 1163
 
1164 1164
 
1165 1165
 
1166 1166
 
1167 1167
 
1168
-	protected function _get_tax_rows( $tktrow, $ticket ) {
1168
+	protected function _get_tax_rows($tktrow, $ticket) {
1169 1169
 		$tax_rows = '';
1170
-		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_tax_row.template.php';
1170
+		$template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_tax_row.template.php';
1171 1171
 		$template_args = array();
1172
-		$taxes = empty( $ticket ) ? EE_Taxes::get_taxes_for_admin() : $ticket->get_ticket_taxes_for_admin();
1173
-		foreach ( $taxes as $tax ) {
1174
-			$tax_added = $this->_get_tax_added( $tax, $ticket );
1172
+		$taxes = empty($ticket) ? EE_Taxes::get_taxes_for_admin() : $ticket->get_ticket_taxes_for_admin();
1173
+		foreach ($taxes as $tax) {
1174
+			$tax_added = $this->_get_tax_added($tax, $ticket);
1175 1175
 			$template_args = array(
1176
-				'display_tax' => !empty( $ticket ) && $ticket->get('TKT_taxable') ? '' : ' style="display:none;"',
1176
+				'display_tax' => ! empty($ticket) && $ticket->get('TKT_taxable') ? '' : ' style="display:none;"',
1177 1177
 				'tax_id' => $tax->ID(),
1178 1178
 				'tkt_row' => $tktrow,
1179 1179
 				'tax_label' => $tax->get('PRC_name'),
1180 1180
 				'tax_added' => $tax_added,
1181
-				'tax_added_display' => EEH_Template::format_currency($tax_added, FALSE, FALSE ),
1181
+				'tax_added_display' => EEH_Template::format_currency($tax_added, FALSE, FALSE),
1182 1182
 				'tax_amount' => $tax->get('PRC_amount')
1183 1183
 				);
1184
-			$template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_tax_rows__template_args', $template_args, $tktrow, $ticket, $this->_is_creating_event  );
1185
-			$tax_rows .= EEH_Template::display_template( $template, $template_args, TRUE );
1184
+			$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_tax_rows__template_args', $template_args, $tktrow, $ticket, $this->_is_creating_event);
1185
+			$tax_rows .= EEH_Template::display_template($template, $template_args, TRUE);
1186 1186
 		}
1187 1187
 
1188 1188
 
@@ -1190,81 +1190,81 @@  discard block
 block discarded – undo
1190 1190
 	}
1191 1191
 
1192 1192
 
1193
-	protected function _get_tax_added( EE_Price $tax, $ticket ) {
1194
-		$subtotal = empty( $ticket ) ? 0 : $ticket->get_ticket_subtotal();
1193
+	protected function _get_tax_added(EE_Price $tax, $ticket) {
1194
+		$subtotal = empty($ticket) ? 0 : $ticket->get_ticket_subtotal();
1195 1195
 		return $subtotal * $tax->get('PRC_amount') / 100;
1196 1196
 	}
1197 1197
 
1198 1198
 
1199 1199
 
1200 1200
 
1201
-	protected function _get_ticket_price_row( $tktrow, $prcrow, $price, $default, $ticket, $show_trash = TRUE, $show_create = TRUE ) {
1202
-		$send_disabled = !empty( $ticket ) && $ticket->get('TKT_deleted') ? TRUE : FALSE;
1201
+	protected function _get_ticket_price_row($tktrow, $prcrow, $price, $default, $ticket, $show_trash = TRUE, $show_create = TRUE) {
1202
+		$send_disabled = ! empty($ticket) && $ticket->get('TKT_deleted') ? TRUE : FALSE;
1203 1203
 		$template_args = array(
1204 1204
 			'tkt_row' => $default && empty($ticket) ? 'TICKETNUM' : $tktrow,
1205 1205
 			'PRC_order' => $default && empty($price) ? 'PRICENUM' : $prcrow,
1206 1206
 			'edit_prices_name' => $default && empty($price) ? 'PRICENAMEATTR' : 'edit_prices',
1207
-			'price_type_selector' => $default && empty( $price ) ? $this->_get_base_price_template( $tktrow, $prcrow, $price, $default ) : $this->_get_price_type_selector( $tktrow, $prcrow, $price, $default, $send_disabled ),
1207
+			'price_type_selector' => $default && empty($price) ? $this->_get_base_price_template($tktrow, $prcrow, $price, $default) : $this->_get_price_type_selector($tktrow, $prcrow, $price, $default, $send_disabled),
1208 1208
 			'PRC_ID' => $default && empty($price) ? 0 : $price->ID(),
1209 1209
 			'PRC_is_default' => $default && empty($price) ? 0 : $price->get('PRC_is_default'),
1210 1210
 			'PRC_name' => $default && empty($price) ? '' : $price->get('PRC_name'),
1211 1211
 			'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign,
1212 1212
 			'show_plus_or_minus' => $default && empty($price) ? '' : ' style="display:none;"',
1213
-			'show_plus' => $default && empty( $price ) ? ' style="display:none;"' : ( $price->is_discount() || $price->is_base_price() ? ' style="display:none;"' : ''),
1214
-			'show_minus' => $default && empty( $price ) ? ' style="display:none;"' : ($price->is_discount() ? '' : ' style="display:none;"'),
1215
-			'show_currency_symbol' => $default && empty( $price ) ? ' style="display:none"' : ($price->is_percent() ? ' style="display:none"' : '' ),
1216
-			'PRC_amount' => $default && empty( $price ) ? 0 : $price->get_pretty('PRC_amount', 'localized_float'),
1217
-			'show_percentage' => $default && empty( $price ) ? ' style="display:none;"' : ( $price->is_percent() ? '' : ' style="display:none;"' ),
1213
+			'show_plus' => $default && empty($price) ? ' style="display:none;"' : ($price->is_discount() || $price->is_base_price() ? ' style="display:none;"' : ''),
1214
+			'show_minus' => $default && empty($price) ? ' style="display:none;"' : ($price->is_discount() ? '' : ' style="display:none;"'),
1215
+			'show_currency_symbol' => $default && empty($price) ? ' style="display:none"' : ($price->is_percent() ? ' style="display:none"' : ''),
1216
+			'PRC_amount' => $default && empty($price) ? 0 : $price->get_pretty('PRC_amount', 'localized_float'),
1217
+			'show_percentage' => $default && empty($price) ? ' style="display:none;"' : ($price->is_percent() ? '' : ' style="display:none;"'),
1218 1218
 			'show_trash_icon' => $show_trash ? '' : ' style="display:none;"',
1219 1219
 			'show_create_button' => $show_create ? '' : ' style="display:none;"',
1220
-			'PRC_desc' => $default && empty( $price ) ? '' : $price->get('PRC_desc'),
1221
-			'disabled' => !empty( $ticket ) && $ticket->get('TKT_deleted') ? TRUE : FALSE
1220
+			'PRC_desc' => $default && empty($price) ? '' : $price->get('PRC_desc'),
1221
+			'disabled' => ! empty($ticket) && $ticket->get('TKT_deleted') ? TRUE : FALSE
1222 1222
 			);
1223 1223
 
1224
-	$template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_ticket_price_row__template_args', $template_args, $tktrow, $prcrow, $price, $default, $ticket, $show_trash, $show_create, $this->_is_creating_event );
1224
+	$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_price_row__template_args', $template_args, $tktrow, $prcrow, $price, $default, $ticket, $show_trash, $show_create, $this->_is_creating_event);
1225 1225
 
1226
-		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_price_row.template.php';
1227
-		return EEH_Template::display_template( $template, $template_args, TRUE );
1226
+		$template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_price_row.template.php';
1227
+		return EEH_Template::display_template($template, $template_args, TRUE);
1228 1228
 	}
1229 1229
 
1230 1230
 
1231
-	protected function _get_price_type_selector( $tktrow, $prcrow, $price, $default, $disabled = FALSE ) {
1232
-		if ( $price->is_base_price() ) {
1233
-			return $this->_get_base_price_template( $tktrow, $prcrow, $price, $default );
1231
+	protected function _get_price_type_selector($tktrow, $prcrow, $price, $default, $disabled = FALSE) {
1232
+		if ($price->is_base_price()) {
1233
+			return $this->_get_base_price_template($tktrow, $prcrow, $price, $default);
1234 1234
 		} else {
1235
-			return $this->_get_price_modifier_template( $tktrow, $prcrow, $price, $default, $disabled );
1235
+			return $this->_get_price_modifier_template($tktrow, $prcrow, $price, $default, $disabled);
1236 1236
 		}
1237 1237
 
1238 1238
 	}
1239 1239
 
1240 1240
 
1241
-	protected function _get_base_price_template( $tktrow, $prcrow, $price, $default ) {
1241
+	protected function _get_base_price_template($tktrow, $prcrow, $price, $default) {
1242 1242
 		$template_args = array(
1243 1243
 				'tkt_row' => $default ? 'TICKETNUM' : $tktrow,
1244
-				'PRC_order' => $default && empty( $price ) ? 'PRICENUM' : $prcrow,
1245
-				'PRT_ID' => $default && empty( $price ) ? 1 : $price->get('PRT_ID'),
1244
+				'PRC_order' => $default && empty($price) ? 'PRICENUM' : $prcrow,
1245
+				'PRT_ID' => $default && empty($price) ? 1 : $price->get('PRT_ID'),
1246 1246
 				'PRT_name' => __('Price', 'event_espresso'),
1247 1247
 				'price_selected_operator' => '+',
1248 1248
 				'price_selected_is_percent' => 0
1249 1249
 			);
1250
-		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_type_base.template.php';
1250
+		$template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_price_type_base.template.php';
1251 1251
 
1252
-		$template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_base_price_template__template_args', $template_args, $tktrow, $prcrow, $price, $default, $this->_is_creating_event );
1252
+		$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_base_price_template__template_args', $template_args, $tktrow, $prcrow, $price, $default, $this->_is_creating_event);
1253 1253
 
1254
-		return EEH_Template::display_template( $template, $template_args, TRUE );
1254
+		return EEH_Template::display_template($template, $template_args, TRUE);
1255 1255
 	}
1256 1256
 
1257 1257
 
1258 1258
 
1259
-	protected function _get_price_modifier_template( $tktrow, $prcrow, $price, $default, $disabled = FALSE ) {
1260
-		$select_name = $default && empty( $price ) ? 'edit_prices[TICKETNUM][PRICENUM][PRT_ID]' : 'edit_prices[' . $tktrow . '][' . $prcrow . '][PRT_ID]';
1261
-		$price_types = EE_Registry::instance()->load_model('Price_Type')->get_all(array( array('OR' => array('PBT_ID' => '2', 'PBT_ID*' => '3' ) ) ) );
1262
-		$price_option_span_template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_option_span.template.php';
1263
-		$all_price_types = $default && empty( $price ) ? array(array('id' => 0, 'text' => __('Select Modifier', 'event_espresso')) ) : array();
1264
-		$selected_price_type_id = $default && empty( $price ) ? 0 : $price->type();
1259
+	protected function _get_price_modifier_template($tktrow, $prcrow, $price, $default, $disabled = FALSE) {
1260
+		$select_name = $default && empty($price) ? 'edit_prices[TICKETNUM][PRICENUM][PRT_ID]' : 'edit_prices['.$tktrow.']['.$prcrow.'][PRT_ID]';
1261
+		$price_types = EE_Registry::instance()->load_model('Price_Type')->get_all(array(array('OR' => array('PBT_ID' => '2', 'PBT_ID*' => '3'))));
1262
+		$price_option_span_template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_price_option_span.template.php';
1263
+		$all_price_types = $default && empty($price) ? array(array('id' => 0, 'text' => __('Select Modifier', 'event_espresso'))) : array();
1264
+		$selected_price_type_id = $default && empty($price) ? 0 : $price->type();
1265 1265
 		$price_option_spans = '';
1266 1266
 		//setup pricetypes for selector
1267
-		foreach ( $price_types as $price_type ) {
1267
+		foreach ($price_types as $price_type) {
1268 1268
 			$all_price_types[] = array(
1269 1269
 				'id' => $price_type->ID(),
1270 1270
 				'text' => $price_type->get('PRT_name'),
@@ -1276,50 +1276,50 @@  discard block
 block discarded – undo
1276 1276
 				'PRT_operator' => $price_type->is_discount() ? '-' : '+',
1277 1277
 				'PRT_is_percent' => $price_type->get('PRT_is_percent') ? 1 : 0
1278 1278
 				);
1279
-			$price_option_spans .= EEH_Template::display_template($price_option_span_template, $spanargs, TRUE );
1279
+			$price_option_spans .= EEH_Template::display_template($price_option_span_template, $spanargs, TRUE);
1280 1280
 		}
1281 1281
 
1282
-		$select_params = $disabled ? 'style="width:auto;" disabled'  : 'style="width:auto;"';
1282
+		$select_params = $disabled ? 'style="width:auto;" disabled' : 'style="width:auto;"';
1283 1283
 		$main_name = $select_name;
1284
-		$select_name = $disabled ? 'archive_price[' . $tktrow . '][' . $prcrow . '][PRT_ID]' : $main_name;
1284
+		$select_name = $disabled ? 'archive_price['.$tktrow.']['.$prcrow.'][PRT_ID]' : $main_name;
1285 1285
 
1286 1286
 		$template_args = array(
1287 1287
 			'tkt_row' => $default ? 'TICKETNUM' : $tktrow,
1288
-			'PRC_order' => $default && empty( $price ) ? 'PRICENUM' : $prcrow,
1289
-			'price_modifier_selector' => EEH_Form_Fields::select_input( $select_name, $all_price_types, $selected_price_type_id, $select_params, 'edit-price-PRT_ID' ),
1288
+			'PRC_order' => $default && empty($price) ? 'PRICENUM' : $prcrow,
1289
+			'price_modifier_selector' => EEH_Form_Fields::select_input($select_name, $all_price_types, $selected_price_type_id, $select_params, 'edit-price-PRT_ID'),
1290 1290
 			'main_name' => $main_name,
1291 1291
 			'selected_price_type_id' => $selected_price_type_id,
1292 1292
 			'price_option_spans' => $price_option_spans,
1293
-			'price_selected_operator' => $default && empty( $price ) ? '' : ( $price->is_discount() ? '-' : '+' ),
1294
-			'price_selected_is_percent' => $default && empty( $price ) ? '' : ( $price->is_percent() ? 1 : 0 ),
1293
+			'price_selected_operator' => $default && empty($price) ? '' : ($price->is_discount() ? '-' : '+'),
1294
+			'price_selected_is_percent' => $default && empty($price) ? '' : ($price->is_percent() ? 1 : 0),
1295 1295
 			'disabled' => $disabled
1296 1296
 			);
1297 1297
 
1298
-		$template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_price_modifier_template__template_args', $template_args, $tktrow, $prcrow, $price, $default, $disabled, $this->_is_creating_event );
1298
+		$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_price_modifier_template__template_args', $template_args, $tktrow, $prcrow, $price, $default, $disabled, $this->_is_creating_event);
1299 1299
 
1300
-		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_modifier_selector.template.php';
1300
+		$template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_price_modifier_selector.template.php';
1301 1301
 
1302
-		return EEH_Template::display_template( $template, $template_args, TRUE );
1302
+		return EEH_Template::display_template($template, $template_args, TRUE);
1303 1303
 	}
1304 1304
 
1305 1305
 
1306 1306
 
1307
-	protected function _get_ticket_datetime_list_item( $dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default ) {
1308
-		$dttid = !empty($dtt) ? $dtt->ID() : 0;
1309
-		$displayrow = !empty($dtt) ? $dtt->get('DTT_order') : 0;
1310
-		$tkt_dtts = $ticket instanceof EE_Ticket && isset( $ticket_datetimes[$ticket->ID()] ) ? $ticket_datetimes[$ticket->ID()] : array();
1307
+	protected function _get_ticket_datetime_list_item($dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default) {
1308
+		$dttid = ! empty($dtt) ? $dtt->ID() : 0;
1309
+		$displayrow = ! empty($dtt) ? $dtt->get('DTT_order') : 0;
1310
+		$tkt_dtts = $ticket instanceof EE_Ticket && isset($ticket_datetimes[$ticket->ID()]) ? $ticket_datetimes[$ticket->ID()] : array();
1311 1311
 		$template_args = array(
1312
-			'dtt_row' => $default && empty( $dtt ) ? 'DTTNUM' : $dttrow,
1312
+			'dtt_row' => $default && empty($dtt) ? 'DTTNUM' : $dttrow,
1313 1313
 			'tkt_row' => $default ? 'TICKETNUM' : $tktrow,
1314
-			'ticket_datetime_selected' => in_array( $displayrow, $tkt_dtts ) ? ' ticket-selected' : '',
1315
-			'ticket_datetime_checked' => in_array( $displayrow, $tkt_dtts ) ? ' checked="checked"' : '',
1316
-			'DTT_name' => $default && empty( $dtt ) ? 'DTTNAME' : $dtt->get_dtt_display_name( TRUE ),
1314
+			'ticket_datetime_selected' => in_array($displayrow, $tkt_dtts) ? ' ticket-selected' : '',
1315
+			'ticket_datetime_checked' => in_array($displayrow, $tkt_dtts) ? ' checked="checked"' : '',
1316
+			'DTT_name' => $default && empty($dtt) ? 'DTTNAME' : $dtt->get_dtt_display_name(TRUE),
1317 1317
 			'tkt_status_class' => '',
1318 1318
 			);
1319 1319
 
1320
-		$template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_ticket_datetime_list_item__template_args', $template_args, $dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default, $this->_is_creating_event );
1321
-		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_datetimes_list_item.template.php';
1322
-		return EEH_Template::display_template( $template, $template_args, TRUE );
1320
+		$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_datetime_list_item__template_args', $template_args, $dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default, $this->_is_creating_event);
1321
+		$template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_datetimes_list_item.template.php';
1322
+		return EEH_Template::display_template($template, $template_args, TRUE);
1323 1323
 	}
1324 1324
 
1325 1325
 
@@ -1327,53 +1327,53 @@  discard block
 block discarded – undo
1327 1327
 	protected function _get_ticket_js_structure($all_dtts, $all_tickets) {
1328 1328
 		$template_args = array(
1329 1329
 			'default_datetime_edit_row' => $this->_get_dtt_edit_row('DTTNUM', NULL, TRUE, $all_dtts),
1330
-			'default_ticket_row' => $this->_get_ticket_row( 'TICKETNUM', NULL, array(), array(), TRUE),
1331
-			'default_price_row' => $this->_get_ticket_price_row( 'TICKETNUM', 'PRICENUM', NULL, TRUE, NULL ),
1330
+			'default_ticket_row' => $this->_get_ticket_row('TICKETNUM', NULL, array(), array(), TRUE),
1331
+			'default_price_row' => $this->_get_ticket_price_row('TICKETNUM', 'PRICENUM', NULL, TRUE, NULL),
1332 1332
 			'default_price_rows' => '',
1333 1333
 			'default_base_price_amount' => 0,
1334 1334
 			'default_base_price_name' => '',
1335 1335
 			'default_base_price_description' => '',
1336
-			'default_price_modifier_selector_row' => $this->_get_price_modifier_template( 'TICKETNUM', 'PRICENUM', NULL, TRUE ),
1337
-			'default_available_tickets_for_datetime' => $this->_get_dtt_attached_tickets_row( 'DTTNUM', NULL, array(), array(), TRUE ),
1336
+			'default_price_modifier_selector_row' => $this->_get_price_modifier_template('TICKETNUM', 'PRICENUM', NULL, TRUE),
1337
+			'default_available_tickets_for_datetime' => $this->_get_dtt_attached_tickets_row('DTTNUM', NULL, array(), array(), TRUE),
1338 1338
 			'existing_available_datetime_tickets_list' => '',
1339 1339
 			'existing_available_ticket_datetimes_list' => '',
1340
-			'new_available_datetime_ticket_list_item' => $this->_get_datetime_tickets_list_item( 'DTTNUM', 'TICKETNUM', NULL, NULL, array(), TRUE ),
1341
-			'new_available_ticket_datetime_list_item' => $this->_get_ticket_datetime_list_item( 'DTTNUM', 'TICKETNUM', NULL, NULL, array(), TRUE )
1340
+			'new_available_datetime_ticket_list_item' => $this->_get_datetime_tickets_list_item('DTTNUM', 'TICKETNUM', NULL, NULL, array(), TRUE),
1341
+			'new_available_ticket_datetime_list_item' => $this->_get_ticket_datetime_list_item('DTTNUM', 'TICKETNUM', NULL, NULL, array(), TRUE)
1342 1342
 			);
1343 1343
 
1344 1344
 		$tktrow = 1;
1345
-		foreach ( $all_tickets as $ticket ) {
1346
-			$template_args['existing_available_datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item( 'DTTNUM', $tktrow, NULL, $ticket, array(), TRUE );
1345
+		foreach ($all_tickets as $ticket) {
1346
+			$template_args['existing_available_datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item('DTTNUM', $tktrow, NULL, $ticket, array(), TRUE);
1347 1347
 			$tktrow++;
1348 1348
 		}
1349 1349
 
1350 1350
 
1351 1351
 		$dttrow = 1;
1352
-		foreach ( $all_dtts as $dtt ) {
1353
-			$template_args['existing_available_ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item( $dttrow, 'TICKETNUM', $dtt, NULL, array(), TRUE );
1352
+		foreach ($all_dtts as $dtt) {
1353
+			$template_args['existing_available_ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item($dttrow, 'TICKETNUM', $dtt, NULL, array(), TRUE);
1354 1354
 			$dttrow++;
1355 1355
 		}
1356 1356
 
1357 1357
 		$default_prices = EE_Registry::instance()->load_model('Price')->get_all_default_prices();
1358 1358
 		$prcrow = 1;
1359
-		foreach ( $default_prices as $price ) {
1360
-			if ( $price->is_base_price() ) {
1359
+		foreach ($default_prices as $price) {
1360
+			if ($price->is_base_price()) {
1361 1361
 				$template_args['default_base_price_amount'] = $price->get_pretty('PRC_amount', 'localized_float');
1362 1362
 				$template_args['default_base_price_name'] = $price->get('PRC_name');
1363 1363
 				$template_args['default_base_price_description'] = $price->get('PRC_desc');
1364 1364
 				$prcrow++;
1365 1365
 				continue;
1366 1366
 			}
1367
-			$show_trash = ( count( $default_prices ) > 1 && $prcrow === 1 ) || count( $default_prices ) === 1  ? FALSE : TRUE;
1368
-			$show_create = count( $default_prices ) > 1 && count( $default_prices ) !== $prcrow ? FALSE : TRUE;
1369
-			$template_args['default_price_rows'] .= $this->_get_ticket_price_row( 'TICKETNUM', $prcrow, $price, TRUE, NULL, $show_trash, $show_create );
1367
+			$show_trash = (count($default_prices) > 1 && $prcrow === 1) || count($default_prices) === 1 ? FALSE : TRUE;
1368
+			$show_create = count($default_prices) > 1 && count($default_prices) !== $prcrow ? FALSE : TRUE;
1369
+			$template_args['default_price_rows'] .= $this->_get_ticket_price_row('TICKETNUM', $prcrow, $price, TRUE, NULL, $show_trash, $show_create);
1370 1370
 			$prcrow++;
1371 1371
 		}
1372 1372
 
1373
-		$template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_ticket_js_structure__template_args', $template_args, $all_dtts, $all_tickets, $this->_is_creating_event );
1373
+		$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_js_structure__template_args', $template_args, $all_dtts, $all_tickets, $this->_is_creating_event);
1374 1374
 
1375
-		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_js_structure.template.php';
1376
-		return EEH_Template::display_template( $template, $template_args, TRUE );
1375
+		$template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_js_structure.template.php';
1376
+		return EEH_Template::display_template($template, $template_args, TRUE);
1377 1377
 	}
1378 1378
 
1379 1379
 
Please login to merge, or discard this patch.