Completed
Branch BUG-8698-ticket-sellouts (0f4efc)
by
unknown
115:32 queued 99:34
created
reg_steps/payment_options/EE_SPCO_Reg_Step_Payment_Options.class.php 2 patches
Doc Comments   +13 added lines, -11 removed lines patch added patch discarded remove patch
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 
104 104
 
105 105
 	/**
106
-	 * @return null
106
+	 * @return EE_Line_Item_Display
107 107
 	 */
108 108
 	public function line_item_display() {
109 109
 		return $this->line_item_display;
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 
113 113
 
114 114
 	/**
115
-	 * @param null $line_item_display
115
+	 * @param EE_Line_Item_Display $line_item_display
116 116
 	 */
117 117
 	public function set_line_item_display( $line_item_display ) {
118 118
 		$this->line_item_display = $line_item_display;
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 
181 181
 
182 182
 	/**
183
-	 * @return bool
183
+	 * @return EE_Form_Section_Proper
184 184
 	 */
185 185
 	public function generate_reg_form() {
186 186
 		EE_Registry::instance()->load_helper( 'HTML' );
@@ -537,6 +537,7 @@  discard block
 block discarded – undo
537 537
 	 *    _apply_registration_payments_to_amount_owing
538 538
 	 *
539 539
 	 * @access    protected
540
+	 * @param EE_Base_Class[] $registrations
540 541
 	 * @return    void
541 542
 	 */
542 543
 	protected function _apply_registration_payments_to_amount_owing( $registrations ) {
@@ -754,7 +755,7 @@  discard block
 block discarded – undo
754 755
 	 * get_billing_form_html_for_payment_method
755 756
 	 *
756 757
 	 * @access public
757
-	 * @return string
758
+	 * @return boolean
758 759
 	 */
759 760
 	public function get_billing_form_html_for_payment_method() {
760 761
 		// how have they chosen to pay?
@@ -874,7 +875,7 @@  discard block
 block discarded – undo
874 875
 	 * switch_payment_method
875 876
 	 *
876 877
 	 * @access public
877
-	 * @return string
878
+	 * @return boolean
878 879
 	 */
879 880
 	public function switch_payment_method() {
880 881
 		if ( ! $this->_verify_payment_method_is_set() ) {
@@ -1041,7 +1042,7 @@  discard block
 block discarded – undo
1041 1042
 
1042 1043
 	/**
1043 1044
 	 * process_reg_step
1044
-	 * @return boolean
1045
+	 * @return null|boolean
1045 1046
 	 */
1046 1047
 	public function process_reg_step() {
1047 1048
 		// how have they chosen to pay?
@@ -1117,7 +1118,7 @@  discard block
 block discarded – undo
1117 1118
 	 *    update_reg_step
1118 1119
 	 *    this is the final step after a user  revisits the site to retry a payment
1119 1120
 	 *
1120
-	 * @return boolean
1121
+	 * @return null|boolean
1121 1122
 	 */
1122 1123
 	public function update_reg_step() {
1123 1124
 		$success = TRUE;
@@ -1399,7 +1400,7 @@  discard block
 block discarded – undo
1399 1400
 	 *
1400 1401
 	 * 	@access 	private
1401 1402
 	 * 	@type 	EE_Payment_Method $payment_method
1402
-	 * 	@return 	mixed	EE_Payment | boolean
1403
+	 * 	@return 	EE_Payment|null	EE_Payment | boolean
1403 1404
 	 */
1404 1405
 	private function _attempt_payment( EE_Payment_Method $payment_method ) {
1405 1406
 		$payment =NULL;
@@ -1602,6 +1603,7 @@  discard block
 block discarded – undo
1602 1603
 	 * @access private
1603 1604
 	 * @type    EE_Payment $payment
1604 1605
 	 * @param string $payment_occurs
1606
+	 * @param EE_Payment|null $payment
1605 1607
 	 * @return bool
1606 1608
 	 * @throws \EE_Error
1607 1609
 	 */
@@ -1708,7 +1710,7 @@  discard block
 block discarded – undo
1708 1710
 	 * 		or present the payment options again
1709 1711
 	 *
1710 1712
 	 * @access private
1711
-	 * @return EE_Payment | FALSE
1713
+	 * @return boolean | FALSE
1712 1714
 	 */
1713 1715
 	public function process_gateway_response() {
1714 1716
 		$payment = null;
@@ -1769,7 +1771,7 @@  discard block
 block discarded – undo
1769 1771
 	 * _validate_return
1770 1772
 	 *
1771 1773
 	 * @access private
1772
-	 * @return bool
1774
+	 * @return boolean|null
1773 1775
 	 */
1774 1776
 	private function _validate_offsite_return() {
1775 1777
 		$TXN_ID = (int)EE_Registry::instance()->REQ->get( 'spco_txn', 0 );
@@ -1836,7 +1838,7 @@  discard block
 block discarded – undo
1836 1838
 	 *
1837 1839
 	 * @access private
1838 1840
 	 * @param \EE_Registration $primary_registrant
1839
-	 * @return bool
1841
+	 * @return false|null
1840 1842
 	 */
1841 1843
 	private function _redirect_wayward_request( EE_Registration $primary_registrant ) {
1842 1844
 		if ( ! $primary_registrant instanceof EE_Registration ) {
Please login to merge, or discard this patch.
Spacing   +384 added lines, -384 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
@@ -195,14 +195,14 @@  discard block
 block discarded – undo
195 195
 		$reg_count = 0;
196 196
 		$no_payment_required = true;
197 197
 		// loop thru registrations to gather info
198
-		$registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params );
199
-		foreach ( $registrations as $registration ) {
198
+		$registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
199
+		foreach ($registrations as $registration) {
200 200
 			/** @var $registration EE_Registration */
201 201
 			$reg_count++;
202 202
 			// registrant is NOT Approved
203
-			if ( $registration->status_ID() === EEM_Registration::status_id_not_approved ) {
203
+			if ($registration->status_ID() === EEM_Registration::status_id_not_approved) {
204 204
 				// add event to list of events with pre-approval reg status
205
-				$registrations_requiring_pre_approval[ $registration->ID() ] = $registration;
205
+				$registrations_requiring_pre_approval[$registration->ID()] = $registration;
206 206
 				do_action(
207 207
 					'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_pre_approval',
208 208
 					$registration->event(),
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 				&& $registration->event()->is_sold_out()
220 220
 			) {
221 221
 				// add event to list of events that are sold out
222
-				$sold_out_events[ $registration->event()->ID() ] = $registration->event();
222
+				$sold_out_events[$registration->event()->ID()] = $registration->event();
223 223
 				do_action(
224 224
 					'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__sold_out_event',
225 225
 					$registration->event(),
@@ -228,29 +228,29 @@  discard block
 block discarded – undo
228 228
 				continue;
229 229
 			}
230 230
 			// are they allowed to pay now and is there monies owing?
231
-			if ( $registration->owes_monies_and_can_pay() ) {
232
-				$registrations_requiring_payment[ $registration->ID() ] = $registration;
231
+			if ($registration->owes_monies_and_can_pay()) {
232
+				$registrations_requiring_payment[$registration->ID()] = $registration;
233 233
 				do_action(
234 234
 					'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_payment',
235 235
 					$registration->event(),
236 236
 					$this
237 237
 				);
238
-			} else if ( ! $this->checkout->revisit && $registration->status_ID() != EEM_Registration::status_id_not_approved && $registration->ticket()->is_free()  ) {
239
-				$registrations_for_free_events[ $registration->event()->ID() ] = $registration;
238
+			} else if ( ! $this->checkout->revisit && $registration->status_ID() != EEM_Registration::status_id_not_approved && $registration->ticket()->is_free()) {
239
+				$registrations_for_free_events[$registration->event()->ID()] = $registration;
240 240
 			}
241 241
 		}
242 242
 		$subsections = array();
243 243
 		// now decide which template to load
244
-		if ( ! empty( $sold_out_events )) {
245
-			$subsections['sold_out_events'] = $this->_sold_out_events( $sold_out_events );
244
+		if ( ! empty($sold_out_events)) {
245
+			$subsections['sold_out_events'] = $this->_sold_out_events($sold_out_events);
246 246
 		}
247
-		if ( ! empty( $registrations_requiring_pre_approval )) {
248
-			$subsections['registrations_requiring_pre_approval'] = $this->_registrations_requiring_pre_approval( $registrations_requiring_pre_approval );
247
+		if ( ! empty($registrations_requiring_pre_approval)) {
248
+			$subsections['registrations_requiring_pre_approval'] = $this->_registrations_requiring_pre_approval($registrations_requiring_pre_approval);
249 249
 		}
250
-		if ( ! empty( $registrations_for_free_events ) ) {
251
-			$subsections[ 'no_payment_required' ] = $this->_no_payment_required( $registrations_for_free_events );
250
+		if ( ! empty($registrations_for_free_events)) {
251
+			$subsections['no_payment_required'] = $this->_no_payment_required($registrations_for_free_events);
252 252
 		}
253
-		if ( ! empty( $registrations_requiring_payment ) ) {
253
+		if ( ! empty($registrations_requiring_payment)) {
254 254
 			// autoload Line_Item_Display classes
255 255
 			EEH_Autoloader::register_line_item_filter_autoloaders();
256 256
 			$line_item_filter_processor = new EE_Line_Item_Filter_Processor(
@@ -261,17 +261,17 @@  discard block
 block discarded – undo
261 261
 				$this->checkout->cart->get_grand_total()
262 262
 			);
263 263
 			$filtered_line_item_tree = $line_item_filter_processor->process();
264
-			if ( $this->checkout->amount_owing > 0 ) {
264
+			if ($this->checkout->amount_owing > 0) {
265 265
 				EEH_Autoloader::register_line_item_display_autoloaders();
266
-				$this->set_line_item_display( new EE_Line_Item_Display( 'spco' ) );
267
-				$subsections[ 'payment_options' ] = $this->_display_payment_options(
266
+				$this->set_line_item_display(new EE_Line_Item_Display('spco'));
267
+				$subsections['payment_options'] = $this->_display_payment_options(
268 268
 					$this->line_item_display->display_line_item(
269 269
 						$filtered_line_item_tree,
270
-						array( 'registrations' => $registrations )
270
+						array('registrations' => $registrations)
271 271
 					)
272 272
 				);
273 273
 				$this->checkout->amount_owing = $filtered_line_item_tree->total();
274
-				$this->_apply_registration_payments_to_amount_owing( $registrations );
274
+				$this->_apply_registration_payments_to_amount_owing($registrations);
275 275
 			}
276 276
 			$no_payment_required = false;
277 277
 		} else {
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 		$this->_save_selected_method_of_payment();
281 281
 
282 282
 		$subsections['default_hidden_inputs'] = $this->reg_step_hidden_inputs();
283
-		$subsections['extra_hidden_inputs' ] = $this->_extra_hidden_inputs( $no_payment_required );
283
+		$subsections['extra_hidden_inputs'] = $this->_extra_hidden_inputs($no_payment_required);
284 284
 
285 285
 		return new EE_Form_Section_Proper(
286 286
 			array(
@@ -308,21 +308,21 @@  discard block
 block discarded – undo
308 308
 	 * @param \EE_Line_Item_Filter_Collection $line_item_filter_collection
309 309
 	 * @return \EE_Line_Item_Filter_Collection
310 310
 	 */
311
-	public static function add_spco_line_item_filters( EE_Line_Item_Filter_Collection $line_item_filter_collection ) {
312
-		if ( ! EE_Registry::instance()->SSN instanceof EE_Session ) {
311
+	public static function add_spco_line_item_filters(EE_Line_Item_Filter_Collection $line_item_filter_collection) {
312
+		if ( ! EE_Registry::instance()->SSN instanceof EE_Session) {
313 313
 			return $line_item_filter_collection;
314 314
 		}
315
-		if ( ! EE_Registry::instance()->SSN->checkout() instanceof EE_Checkout ) {
315
+		if ( ! EE_Registry::instance()->SSN->checkout() instanceof EE_Checkout) {
316 316
 			return $line_item_filter_collection;
317 317
 		}
318
-		if ( ! EE_Registry::instance()->SSN->checkout()->transaction instanceof EE_Transaction ) {
318
+		if ( ! EE_Registry::instance()->SSN->checkout()->transaction instanceof EE_Transaction) {
319 319
 			return $line_item_filter_collection;
320 320
 		}
321 321
 		$registrations = EE_Registry::instance()->SSN->checkout()->transaction->registrations(
322 322
 			EE_Registry::instance()->SSN->checkout()->reg_cache_where_params
323 323
 		);
324
-		$line_item_filter_collection->add( new EE_Billable_Line_Item_Filter( $registrations ) );
325
-		$line_item_filter_collection->add( new EE_Non_Zero_Line_Item_Filter() );
324
+		$line_item_filter_collection->add(new EE_Billable_Line_Item_Filter($registrations));
325
+		$line_item_filter_collection->add(new EE_Non_Zero_Line_Item_Filter());
326 326
 		return $line_item_filter_collection;
327 327
 	}
328 328
 
@@ -336,8 +336,8 @@  discard block
 block discarded – undo
336 336
 	 * @return void
337 337
 	 */
338 338
 	protected function _hide_reg_step_submit_button_if_revisit() {
339
-		if ( $this->checkout->revisit ) {
340
-			add_filter( 'FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', '__return_empty_string' );
339
+		if ($this->checkout->revisit) {
340
+			add_filter('FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', '__return_empty_string');
341 341
 		}
342 342
 	}
343 343
 
@@ -348,25 +348,25 @@  discard block
 block discarded – undo
348 348
 	 * @param \EE_Event[] $sold_out_events_array
349 349
 	 * @return \EE_Form_Section_Proper
350 350
 	 */
351
-	private function _sold_out_events( $sold_out_events_array = array() ) {
351
+	private function _sold_out_events($sold_out_events_array = array()) {
352 352
 		// set some defaults
353 353
 		$this->checkout->selected_method_of_payment = 'events_sold_out';
354 354
 		$sold_out_events = '';
355
-		foreach ( $sold_out_events_array as $sold_out_event ) {
356
-			$sold_out_events .= EEH_HTML::li( EEH_HTML::span( $sold_out_event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text' ));
355
+		foreach ($sold_out_events_array as $sold_out_event) {
356
+			$sold_out_events .= EEH_HTML::li(EEH_HTML::span($sold_out_event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text'));
357 357
 		}
358 358
 		return new EE_Form_Section_Proper(
359 359
 			array(
360 360
 				'layout_strategy'		=> new EE_Template_Layout(
361 361
 					array(
362
-						'layout_template_file' 	=> SPCO_REG_STEPS_PATH . $this->_slug . DS . 'sold_out_events.template.php', // layout_template
362
+						'layout_template_file' 	=> SPCO_REG_STEPS_PATH.$this->_slug.DS.'sold_out_events.template.php', // layout_template
363 363
 						'template_args'  				=> apply_filters(
364 364
 							'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__template_args',
365 365
 							array(
366 366
 								'sold_out_events' 			=> $sold_out_events,
367 367
 								'sold_out_events_msg' 	=> apply_filters(
368 368
 									'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__sold_out_events_msg',
369
-									__( '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' )
369
+									__('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')
370 370
 								)
371 371
 							)
372 372
 						)
@@ -383,14 +383,14 @@  discard block
 block discarded – undo
383 383
 	 * @param array $registrations_requiring_pre_approval
384 384
 	 * @return \EE_Form_Section_Proper
385 385
 	 */
386
-	private function _registrations_requiring_pre_approval( $registrations_requiring_pre_approval = array()) {
386
+	private function _registrations_requiring_pre_approval($registrations_requiring_pre_approval = array()) {
387 387
 		$events_requiring_pre_approval = '';
388
-		foreach ( $registrations_requiring_pre_approval as $registration ) {
389
-			if ( $registration instanceof EE_Registration && $registration->event() instanceof EE_Event ) {
390
-				$events_requiring_pre_approval[ $registration->event()->ID() ] = EEH_HTML::li(
391
-					EEH_HTML::span( '', '', 'dashicons dashicons-marker ee-icon-size-16 orange-text'
388
+		foreach ($registrations_requiring_pre_approval as $registration) {
389
+			if ($registration instanceof EE_Registration && $registration->event() instanceof EE_Event) {
390
+				$events_requiring_pre_approval[$registration->event()->ID()] = EEH_HTML::li(
391
+					EEH_HTML::span('', '', 'dashicons dashicons-marker ee-icon-size-16 orange-text'
392 392
 					)
393
-					. EEH_HTML::span( $registration->event()->name(), '', 'orange-text' )
393
+					. EEH_HTML::span($registration->event()->name(), '', 'orange-text')
394 394
 				);
395 395
 			}
396 396
 		}
@@ -398,14 +398,14 @@  discard block
 block discarded – undo
398 398
 			array(
399 399
 				'layout_strategy'		=> new EE_Template_Layout(
400 400
 					array(
401
-						'layout_template_file' 	=> SPCO_REG_STEPS_PATH . $this->_slug . DS . 'events_requiring_pre_approval.template.php', // layout_template
401
+						'layout_template_file' 	=> SPCO_REG_STEPS_PATH.$this->_slug.DS.'events_requiring_pre_approval.template.php', // layout_template
402 402
 						'template_args'  				=> apply_filters(
403 403
 							'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__template_args',
404 404
 							array(
405
-								'events_requiring_pre_approval' 			=> implode( '', $events_requiring_pre_approval ),
405
+								'events_requiring_pre_approval' 			=> implode('', $events_requiring_pre_approval),
406 406
 								'events_requiring_pre_approval_msg' 	=> apply_filters(
407 407
 									'FHEE__EE_SPCO_Reg_Step_Payment_Options___events_requiring_pre_approval__events_requiring_pre_approval_msg',
408
-									__( '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' )
408
+									__('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')
409 409
 								)
410 410
 							)
411 411
 						),
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
 	 * @param \EE_Event[] $registrations_for_free_events
424 424
 	 * @return \EE_Form_Section_Proper
425 425
 	 */
426
-	private function _no_payment_required( $registrations_for_free_events = array() ) {
426
+	private function _no_payment_required($registrations_for_free_events = array()) {
427 427
 		// set some defaults
428 428
 		$this->checkout->selected_method_of_payment = 'no_payment_required';
429 429
 		// generate no_payment_required form
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
 			array(
432 432
 				'layout_strategy' 	=> new EE_Template_Layout(
433 433
 					array(
434
-						'layout_template_file' 	=> SPCO_REG_STEPS_PATH . $this->_slug . DS . 'no_payment_required.template.php', // layout_template
434
+						'layout_template_file' 	=> SPCO_REG_STEPS_PATH.$this->_slug.DS.'no_payment_required.template.php', // layout_template
435 435
 						'template_args'  				=> apply_filters(
436 436
 							'FHEE__EE_SPCO_Reg_Step_Payment_Options___no_payment_required__template_args',
437 437
 							array(
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
 								'registrations' => array(),
440 440
 								'ticket_count' 	=> array(),
441 441
 								'registrations_for_free_events' 	=> $registrations_for_free_events,
442
-								'no_payment_required_msg' => EEH_HTML::p( __( 'This is a free event, so no billing will occur.', 'event_espresso' ))
442
+								'no_payment_required_msg' => EEH_HTML::p(__('This is a free event, so no billing will occur.', 'event_espresso'))
443 443
 							)
444 444
 						),
445 445
 					)
@@ -456,7 +456,7 @@  discard block
 block discarded – undo
456 456
 	 * @param string $transaction_details
457 457
 	 * @return \EE_Form_Section_Proper
458 458
 	 */
459
-	private function _display_payment_options( $transaction_details = '' ) {
459
+	private function _display_payment_options($transaction_details = '') {
460 460
 		// has method_of_payment been set by no-js user?
461 461
 		$this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment();
462 462
 		// build payment options form
@@ -468,18 +468,18 @@  discard block
 block discarded – undo
468 468
 						'before_payment_options' => apply_filters(
469 469
 							'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__before_payment_options',
470 470
 							new EE_Form_Section_Proper(
471
-								array( 'layout_strategy'	=> new EE_Div_Per_Section_Layout() )
471
+								array('layout_strategy'	=> new EE_Div_Per_Section_Layout())
472 472
 							)
473 473
 						),
474 474
 						'payment_options' => $this->_setup_payment_options(),
475 475
 						'after_payment_options' => apply_filters(
476 476
 							'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__after_payment_options',
477 477
 							new EE_Form_Section_Proper(
478
-								array( 'layout_strategy'	=> new EE_Div_Per_Section_Layout() )
478
+								array('layout_strategy'	=> new EE_Div_Per_Section_Layout())
479 479
 							)
480 480
 						),
481 481
 					),
482
-					'layout_strategy'	=> new EE_Template_Layout( array(
482
+					'layout_strategy'	=> new EE_Template_Layout(array(
483 483
 							'layout_template_file' 	=> $this->_template,
484 484
 							'template_args'  				=> apply_filters(
485 485
 								'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__template_args',
@@ -503,11 +503,11 @@  discard block
 block discarded – undo
503 503
 	 * @param bool $no_payment_required
504 504
 	 * @return \EE_Form_Section_Proper
505 505
 	 */
506
-	private function _extra_hidden_inputs( $no_payment_required = TRUE ) {
506
+	private function _extra_hidden_inputs($no_payment_required = TRUE) {
507 507
 
508 508
 		return new EE_Form_Section_Proper(
509 509
 			array(
510
-				'html_id' 				=> 'ee-' . $this->slug() . '-extra-hidden-inputs',
510
+				'html_id' 				=> 'ee-'.$this->slug().'-extra-hidden-inputs',
511 511
 				'layout_strategy'	=> new EE_Div_Per_Section_Layout(),
512 512
 				'subsections' 		=> array(
513 513
 					'spco_no_payment_required' => new EE_Hidden_Input(
@@ -540,16 +540,16 @@  discard block
 block discarded – undo
540 540
 	 * @access    protected
541 541
 	 * @return    void
542 542
 	 */
543
-	protected function _apply_registration_payments_to_amount_owing( $registrations ) {
543
+	protected function _apply_registration_payments_to_amount_owing($registrations) {
544 544
 		$payments = array();
545
-		foreach ( $registrations as $registration ) {
546
-			if ( $registration instanceof EE_Registration && $registration->owes_monies_and_can_pay() ) {
545
+		foreach ($registrations as $registration) {
546
+			if ($registration instanceof EE_Registration && $registration->owes_monies_and_can_pay()) {
547 547
 				$payments = $payments + $registration->registration_payments();
548 548
 			}
549 549
 		}
550
-		if ( ! empty( $payments ) ) {
551
-			foreach ( $payments as $payment ) {
552
-				if ( $payment instanceof EE_Registration_Payment ) {
550
+		if ( ! empty($payments)) {
551
+			foreach ($payments as $payment) {
552
+				if ($payment instanceof EE_Registration_Payment) {
553 553
 					$this->checkout->amount_owing -= $payment->amount();
554 554
 				}
555 555
 			}
@@ -564,9 +564,9 @@  discard block
 block discarded – undo
564 564
 	 * @param 	bool $force_reset
565 565
 	 * @return 	void
566 566
 	 */
567
-	private function _reset_selected_method_of_payment( $force_reset = FALSE ) {
568
-		$reset_payment_method = $force_reset ? TRUE : sanitize_text_field( EE_Registry::instance()->REQ->get( 'reset_payment_method', FALSE ));
569
-		if ( $reset_payment_method ) {
567
+	private function _reset_selected_method_of_payment($force_reset = FALSE) {
568
+		$reset_payment_method = $force_reset ? TRUE : sanitize_text_field(EE_Registry::instance()->REQ->get('reset_payment_method', FALSE));
569
+		if ($reset_payment_method) {
570 570
 			$this->checkout->selected_method_of_payment = NULL;
571 571
 			$this->checkout->payment_method = NULL;
572 572
 			$this->checkout->billing_form = NULL;
@@ -585,9 +585,9 @@  discard block
 block discarded – undo
585 585
 	 * @param string $selected_method_of_payment
586 586
 	 * 	@return 		EE_Billing_Info_Form
587 587
 	 */
588
-	private function _save_selected_method_of_payment( $selected_method_of_payment = '' ) {
589
-		$selected_method_of_payment = ! empty( $selected_method_of_payment ) ? $selected_method_of_payment : $this->checkout->selected_method_of_payment;
590
-		EE_Registry::instance()->SSN->set_session_data( array( 'selected_method_of_payment' => $selected_method_of_payment ));
588
+	private function _save_selected_method_of_payment($selected_method_of_payment = '') {
589
+		$selected_method_of_payment = ! empty($selected_method_of_payment) ? $selected_method_of_payment : $this->checkout->selected_method_of_payment;
590
+		EE_Registry::instance()->SSN->set_session_data(array('selected_method_of_payment' => $selected_method_of_payment));
591 591
 	}
592 592
 
593 593
 
@@ -600,40 +600,40 @@  discard block
 block discarded – undo
600 600
 		// load payment method classes
601 601
 		$this->checkout->available_payment_methods = $this->_get_available_payment_methods();
602 602
 		// switch up header depending on number of available payment methods
603
-		$payment_method_header = count( $this->checkout->available_payment_methods ) > 1
604
-			? apply_filters( 'FHEE__registration_page_payment_options__method_of_payment_hdr', __( 'Please Select Your Method of Payment', 'event_espresso' ))
605
-			: apply_filters( 'FHEE__registration_page_payment_options__method_of_payment_hdr', __( 'Method of Payment', 'event_espresso' ));
603
+		$payment_method_header = count($this->checkout->available_payment_methods) > 1
604
+			? apply_filters('FHEE__registration_page_payment_options__method_of_payment_hdr', __('Please Select Your Method of Payment', 'event_espresso'))
605
+			: apply_filters('FHEE__registration_page_payment_options__method_of_payment_hdr', __('Method of Payment', 'event_espresso'));
606 606
 		$available_payment_methods = array(
607 607
 			// display the "Payment Method" header
608 608
 			'payment_method_header' => new EE_Form_Section_HTML(
609
-				EEH_HTML::h4 ( $payment_method_header, 'method-of-payment-hdr' )
609
+				EEH_HTML::h4($payment_method_header, 'method-of-payment-hdr')
610 610
 			)
611 611
 		);
612 612
 		// the list of actual payment methods ( invoice, paypal, etc ) in a  ( slug => HTML )  format
613 613
 		$available_payment_method_options = array();
614 614
 		$default_payment_method_option = array();
615 615
 		// additional instructions to be displayed and hidden below payment methods (adding a clearing div to start)
616
-		$payment_methods_billing_info = array( new EE_Form_Section_HTML( EEH_HTML::div ( '<br />', '', '', 'clear:both;' )));
616
+		$payment_methods_billing_info = array(new EE_Form_Section_HTML(EEH_HTML::div('<br />', '', '', 'clear:both;')));
617 617
 		// loop through payment methods
618
-		foreach( $this->checkout->available_payment_methods as $payment_method ) {
619
-			if ( $payment_method instanceof EE_Payment_Method ) {
620
-				$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' );
618
+		foreach ($this->checkout->available_payment_methods as $payment_method) {
619
+			if ($payment_method instanceof EE_Payment_Method) {
620
+				$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');
621 621
 				// check if any payment methods are set as default
622 622
 				// if payment method is already selected OR nothing is selected and this payment method should be open_by_default
623
-				if (( $this->checkout->selected_method_of_payment == $payment_method->slug() ) || ( ! $this->checkout->selected_method_of_payment && $payment_method->open_by_default() )) {
623
+				if (($this->checkout->selected_method_of_payment == $payment_method->slug()) || ( ! $this->checkout->selected_method_of_payment && $payment_method->open_by_default())) {
624 624
 					$this->checkout->selected_method_of_payment = $payment_method->slug();
625 625
 					$this->_save_selected_method_of_payment();
626
-					$default_payment_method_option[ $payment_method->slug() ] =  $payment_method_button;
626
+					$default_payment_method_option[$payment_method->slug()] = $payment_method_button;
627 627
 				} else {
628
-					$available_payment_method_options[ $payment_method->slug() ] =  $payment_method_button;
628
+					$available_payment_method_options[$payment_method->slug()] = $payment_method_button;
629 629
 				}
630
-				$payment_methods_billing_info[ $payment_method->slug() . '-info' ] = $this->_payment_method_billing_info( $payment_method );
630
+				$payment_methods_billing_info[$payment_method->slug().'-info'] = $this->_payment_method_billing_info($payment_method);
631 631
 			}
632 632
 		}
633 633
 		// prepend available_payment_method_options with default_payment_method_option so that it appears first in list of PMs
634 634
 		$available_payment_method_options = $default_payment_method_option + $available_payment_method_options;
635 635
 		// now generate the actual form  inputs
636
-		$available_payment_methods['available_payment_methods'] = $this->_available_payment_method_inputs( $available_payment_method_options );
636
+		$available_payment_methods['available_payment_methods'] = $this->_available_payment_method_inputs($available_payment_method_options);
637 637
 		$available_payment_methods = $available_payment_methods + $payment_methods_billing_info;
638 638
 
639 639
 		// build the available payment methods form
@@ -653,19 +653,19 @@  discard block
 block discarded – undo
653 653
 	 * @return EE_Payment_Method[]
654 654
 	 */
655 655
 	protected function _get_available_payment_methods() {
656
-		if ( ! empty( $this->checkout->available_payment_methods )) {
656
+		if ( ! empty($this->checkout->available_payment_methods)) {
657 657
 			return $this->checkout->available_payment_methods;
658 658
 		}
659 659
 		$available_payment_methods = array();
660 660
 		// load EEM_Payment_Method
661
-		EE_Registry::instance()->load_model( 'Payment_Method' );
661
+		EE_Registry::instance()->load_model('Payment_Method');
662 662
 		/** @type EEM_Payment_Method $EEM_Payment_Method */
663 663
 		$EEM_Payment_Method = EE_Registry::instance()->LIB->EEM_Payment_Method;
664 664
 		// get all active payment methods
665
-		$payment_methods = $EEM_Payment_Method->get_all_for_transaction( $this->checkout->transaction, EEM_Payment_Method::scope_cart );
666
-		foreach ( $payment_methods as $payment_method ) {
667
-			if ( $payment_method instanceof EE_Payment_Method ) {
668
-				$available_payment_methods[ $payment_method->slug() ] = $payment_method;
665
+		$payment_methods = $EEM_Payment_Method->get_all_for_transaction($this->checkout->transaction, EEM_Payment_Method::scope_cart);
666
+		foreach ($payment_methods as $payment_method) {
667
+			if ($payment_method instanceof EE_Payment_Method) {
668
+				$available_payment_methods[$payment_method->slug()] = $payment_method;
669 669
 			}
670 670
 		}
671 671
 		return $available_payment_methods;
@@ -681,14 +681,14 @@  discard block
 block discarded – undo
681 681
 	 * @param 	array $available_payment_method_options
682 682
 	 * @return 	\EE_Form_Section_Proper
683 683
 	 */
684
-	private function _available_payment_method_inputs( $available_payment_method_options = array() ) {
684
+	private function _available_payment_method_inputs($available_payment_method_options = array()) {
685 685
 		// generate inputs
686 686
 		return new EE_Form_Section_Proper(
687 687
 			array(
688 688
 				'html_id' 				=> 'ee-available-payment-method-inputs',
689 689
 				'layout_strategy'	=> new EE_Div_Per_Section_Layout(),
690 690
 				'subsections' 		=> array(
691
-					'' => new EE_Radio_Button_Input (
691
+					'' => new EE_Radio_Button_Input(
692 692
 						$available_payment_method_options,
693 693
 						array(
694 694
 							'html_name' 				=> 'selected_method_of_payment',
@@ -712,36 +712,36 @@  discard block
 block discarded – undo
712 712
 	 * @param 	EE_Payment_Method $payment_method
713 713
 	 * @return 	\EE_Form_Section_Proper
714 714
 	 */
715
-	private function _payment_method_billing_info( EE_Payment_Method $payment_method ) {
715
+	private function _payment_method_billing_info(EE_Payment_Method $payment_method) {
716 716
 		$currently_selected = $this->checkout->selected_method_of_payment == $payment_method->slug() ? TRUE : FALSE;
717 717
 		// generate the billing form for payment method
718
-		$billing_form = $currently_selected ? $this->_get_billing_form_for_payment_method( $payment_method ) : new EE_Form_Section_HTML();
718
+		$billing_form = $currently_selected ? $this->_get_billing_form_for_payment_method($payment_method) : new EE_Form_Section_HTML();
719 719
 		$this->checkout->billing_form = $currently_selected ? $billing_form : $this->checkout->billing_form;
720 720
 		// it's all in the details
721
-		$info_html = EEH_HTML::h3 ( __( 'Important information regarding your payment', 'event_espresso' ), '', 'spco-payment-method-hdr' );
721
+		$info_html = EEH_HTML::h3(__('Important information regarding your payment', 'event_espresso'), '', 'spco-payment-method-hdr');
722 722
 		// 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
723
-		if ( $payment_method->description() ) {
723
+		if ($payment_method->description()) {
724 724
 			$payment_method_info = $payment_method->description();
725
-		} elseif ( $billing_form instanceof EE_Billing_Info_Form ) {
726
-			$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() );
725
+		} elseif ($billing_form instanceof EE_Billing_Info_Form) {
726
+			$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());
727 727
 		} else {
728
-			$payment_method_info = sprintf( __( 'Please click the "%1$s" button below in order to proceed.', 'event_espresso' ), $this->submit_button_text() );
728
+			$payment_method_info = sprintf(__('Please click the "%1$s" button below in order to proceed.', 'event_espresso'), $this->submit_button_text());
729 729
 		}
730
-		$info_html .= EEH_HTML::p (
731
-			apply_filters( 'FHEE__EE_SPCO_Reg_Step_Payment_Options___payment_method_billing_info__payment_method_info', $payment_method_info ),
730
+		$info_html .= EEH_HTML::p(
731
+			apply_filters('FHEE__EE_SPCO_Reg_Step_Payment_Options___payment_method_billing_info__payment_method_info', $payment_method_info),
732 732
 			'',
733 733
 			'spco-payment-method-desc ee-attention'
734 734
 		);
735 735
 
736 736
 		return new EE_Form_Section_Proper(
737 737
 			array(
738
-				'html_id' 					=> 'spco-payment-method-info-' . $payment_method->slug(),
738
+				'html_id' 					=> 'spco-payment-method-info-'.$payment_method->slug(),
739 739
 				'html_class' 			=> 'spco-payment-method-info-dv',
740 740
 				// only display the selected or default PM
741 741
 				'html_style' 			=> $currently_selected ? '' : 'display:none;',
742 742
 				'layout_strategy'		=> new EE_Div_Per_Section_Layout(),
743 743
 				'subsections' 			=> array(
744
-					'info' 					=> new EE_Form_Section_HTML( $info_html ),
744
+					'info' 					=> new EE_Form_Section_HTML($info_html),
745 745
 					'billing_form' 		=> $currently_selected ? $billing_form : new EE_Form_Section_HTML()
746 746
 				)
747 747
 			)
@@ -759,12 +759,12 @@  discard block
 block discarded – undo
759 759
 	 */
760 760
 	public function get_billing_form_html_for_payment_method() {
761 761
 		// how have they chosen to pay?
762
-		$this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( TRUE );
762
+		$this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(TRUE);
763 763
 		$this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment();
764
-		if ( ! $this->checkout->payment_method instanceof EE_Payment_Method ) {
764
+		if ( ! $this->checkout->payment_method instanceof EE_Payment_Method) {
765 765
 			return FALSE;
766 766
 		}
767
-		if ( apply_filters( 'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', false ) ) {
767
+		if (apply_filters('FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', false)) {
768 768
             EE_Error::add_success(
769 769
                 apply_filters(
770 770
                     'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method',
@@ -773,20 +773,20 @@  discard block
 block discarded – undo
773 773
             );
774 774
         }
775 775
 		// now generate billing form for selected method of payment
776
-		$payment_method_billing_form = $this->_get_billing_form_for_payment_method( $this->checkout->payment_method );
776
+		$payment_method_billing_form = $this->_get_billing_form_for_payment_method($this->checkout->payment_method);
777 777
 		// fill form with attendee info if applicable
778
-		if ( $payment_method_billing_form instanceof EE_Billing_Attendee_Info_Form && $this->checkout->transaction_has_primary_registrant() ) {
779
-			$payment_method_billing_form->populate_from_attendee( $this->checkout->transaction->primary_registration()->attendee() );
778
+		if ($payment_method_billing_form instanceof EE_Billing_Attendee_Info_Form && $this->checkout->transaction_has_primary_registrant()) {
779
+			$payment_method_billing_form->populate_from_attendee($this->checkout->transaction->primary_registration()->attendee());
780 780
 		}
781 781
 		// and debug content
782
-		if ( $payment_method_billing_form instanceof EE_Billing_Info_Form && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base ) {
783
-			$payment_method_billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings( $payment_method_billing_form );
782
+		if ($payment_method_billing_form instanceof EE_Billing_Info_Form && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base) {
783
+			$payment_method_billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings($payment_method_billing_form);
784 784
 		}
785 785
 		$billing_info = $payment_method_billing_form instanceof EE_Form_Section_Proper ? $payment_method_billing_form->get_html() : '';
786
-		$this->checkout->json_response->set_return_data( array( 'payment_method_info' => $billing_info ));
786
+		$this->checkout->json_response->set_return_data(array('payment_method_info' => $billing_info));
787 787
 		// localize validation rules for main form
788 788
 		$this->checkout->current_step->reg_form->localize_validation_rules();
789
-		$this->checkout->json_response->add_validation_rules( EE_Form_Section_Proper::js_localization() );
789
+		$this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization());
790 790
 		return TRUE;
791 791
 	}
792 792
 
@@ -799,15 +799,15 @@  discard block
 block discarded – undo
799 799
 	 * @param EE_Payment_Method $payment_method
800 800
 	 * @return \EE_Billing_Info_Form
801 801
 	 */
802
-	private function _get_billing_form_for_payment_method( EE_Payment_Method $payment_method ) {
803
-		$billing_form = $payment_method->type_obj()->billing_form( $this->checkout->transaction, array( 'amount_owing' => $this->checkout->amount_owing ) );
804
-		if ( $billing_form instanceof EE_Billing_Info_Form ) {
805
-			if ( EE_Registry::instance()->REQ->is_set( 'payment_method' )) {
806
-                if ( apply_filters('FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', false )) {
802
+	private function _get_billing_form_for_payment_method(EE_Payment_Method $payment_method) {
803
+		$billing_form = $payment_method->type_obj()->billing_form($this->checkout->transaction, array('amount_owing' => $this->checkout->amount_owing));
804
+		if ($billing_form instanceof EE_Billing_Info_Form) {
805
+			if (EE_Registry::instance()->REQ->is_set('payment_method')) {
806
+                if (apply_filters('FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', false)) {
807 807
                     EE_Error::add_success(
808 808
                         apply_filters(
809 809
                             'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method',
810
-                            sprintf( __( 'You have selected "%s" as your method of payment. Please note the important payment information below.', 'event_espresso' ), $payment_method->name() )
810
+                            sprintf(__('You have selected "%s" as your method of payment. Please note the important payment information below.', 'event_espresso'), $payment_method->name())
811 811
                         )
812 812
                     );
813 813
                 }
@@ -832,27 +832,27 @@  discard block
 block discarded – undo
832 832
 	 * @param string 		$request_param
833 833
 	 * @return NULL|string
834 834
 	 */
835
-	private function _get_selected_method_of_payment( $required = FALSE, $request_param = 'selected_method_of_payment' ) {
835
+	private function _get_selected_method_of_payment($required = FALSE, $request_param = 'selected_method_of_payment') {
836 836
 		// is selected_method_of_payment set in the request ?
837
-		$selected_method_of_payment = EE_Registry::instance()->REQ->get( $request_param, FALSE );
838
-		if ( $selected_method_of_payment ) {
837
+		$selected_method_of_payment = EE_Registry::instance()->REQ->get($request_param, FALSE);
838
+		if ($selected_method_of_payment) {
839 839
 			// sanitize it
840
-			$selected_method_of_payment = is_array( $selected_method_of_payment ) ? array_shift( $selected_method_of_payment ) : $selected_method_of_payment;
841
-			$selected_method_of_payment = sanitize_text_field( $selected_method_of_payment );
840
+			$selected_method_of_payment = is_array($selected_method_of_payment) ? array_shift($selected_method_of_payment) : $selected_method_of_payment;
841
+			$selected_method_of_payment = sanitize_text_field($selected_method_of_payment);
842 842
 			// store it in the session so that it's available for all subsequent requests including AJAX
843
-			$this->_save_selected_method_of_payment( $selected_method_of_payment );
843
+			$this->_save_selected_method_of_payment($selected_method_of_payment);
844 844
 		} else {
845 845
 			// or is is set in the session ?
846
-			$selected_method_of_payment = EE_Registry::instance()->SSN->get_session_data( 'selected_method_of_payment' );
846
+			$selected_method_of_payment = EE_Registry::instance()->SSN->get_session_data('selected_method_of_payment');
847 847
 		}
848 848
 		// do ya really really gotta have it?
849
-		if ( empty( $selected_method_of_payment ) && $required ) {
849
+		if (empty($selected_method_of_payment) && $required) {
850 850
 			EE_Error::add_error(
851 851
 				sprintf(
852
-					__( '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
+					__('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'),
853 853
 					'<br/>',
854 854
 					'<br/>',
855
-					EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
855
+					EE_Registry::instance()->CFG->organization->get_pretty('email')
856 856
 				),
857 857
 				__FILE__, __FUNCTION__, __LINE__
858 858
 			);
@@ -878,37 +878,37 @@  discard block
 block discarded – undo
878 878
 	 * @return string
879 879
 	 */
880 880
 	public function switch_payment_method() {
881
-		if ( ! $this->_verify_payment_method_is_set() ) {
881
+		if ( ! $this->_verify_payment_method_is_set()) {
882 882
 			return false;
883 883
 		}
884
-		if ( apply_filters( 'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', false ) ) {
884
+		if (apply_filters('FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', false)) {
885 885
 			EE_Error::add_success(
886 886
 				apply_filters(
887 887
 					'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method',
888
-					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
+					sprintf(__('You have selected "%s" as your method of payment. Please note the important payment information below.', 'event_espresso'), $this->checkout->payment_method->name())
889 889
 				)
890 890
 			);
891 891
 		}
892 892
 		// generate billing form for selected method of payment if it hasn't been done already
893
-		if ( $this->checkout->payment_method->type_obj()->has_billing_form() ) {
894
-			$this->checkout->billing_form = $this->_get_billing_form_for_payment_method( $this->checkout->payment_method );
893
+		if ($this->checkout->payment_method->type_obj()->has_billing_form()) {
894
+			$this->checkout->billing_form = $this->_get_billing_form_for_payment_method($this->checkout->payment_method);
895 895
 		}
896 896
 		// fill form with attendee info if applicable
897
-		if ( $this->checkout->billing_form instanceof EE_Billing_Attendee_Info_Form && $this->checkout->transaction_has_primary_registrant() ) {
898
-			$this->checkout->billing_form->populate_from_attendee( $this->checkout->transaction->primary_registration()->attendee() );
897
+		if ($this->checkout->billing_form instanceof EE_Billing_Attendee_Info_Form && $this->checkout->transaction_has_primary_registrant()) {
898
+			$this->checkout->billing_form->populate_from_attendee($this->checkout->transaction->primary_registration()->attendee());
899 899
 		}
900 900
 		// and debug content
901
-		if ( $this->checkout->billing_form instanceof EE_Billing_Info_Form && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base ) {
902
-			$this->checkout->billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings( $this->checkout->billing_form );
901
+		if ($this->checkout->billing_form instanceof EE_Billing_Info_Form && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base) {
902
+			$this->checkout->billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings($this->checkout->billing_form);
903 903
 		}
904 904
 		// get html and validation rules for form
905
-		if ( $this->checkout->billing_form instanceof EE_Form_Section_Proper ) {
906
-			$this->checkout->json_response->set_return_data( array( 'payment_method_info' => $this->checkout->billing_form->get_html() ));
905
+		if ($this->checkout->billing_form instanceof EE_Form_Section_Proper) {
906
+			$this->checkout->json_response->set_return_data(array('payment_method_info' => $this->checkout->billing_form->get_html()));
907 907
 			// localize validation rules for main form
908
-			$this->checkout->billing_form->localize_validation_rules( TRUE );
909
-			$this->checkout->json_response->add_validation_rules( EE_Form_Section_Proper::js_localization() );
908
+			$this->checkout->billing_form->localize_validation_rules(TRUE);
909
+			$this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization());
910 910
 		} else {
911
-			$this->checkout->json_response->set_return_data( array( 'payment_method_info' => '' ));
911
+			$this->checkout->json_response->set_return_data(array('payment_method_info' => ''));
912 912
 		}
913 913
 		//prevents advancement to next step
914 914
 		$this->checkout->continue_reg = FALSE;
@@ -923,18 +923,18 @@  discard block
 block discarded – undo
923 923
 	 */
924 924
 	protected function _verify_payment_method_is_set() {
925 925
 		// generate billing form for selected method of payment if it hasn't been done already
926
-		if ( empty( $this->checkout->selected_method_of_payment )) {
926
+		if (empty($this->checkout->selected_method_of_payment)) {
927 927
 			// how have they chosen to pay?
928
-			$this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( TRUE );
928
+			$this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(TRUE);
929 929
 		} else {
930 930
 			// choose your own adventure based on method_of_payment
931
-			switch ( $this->checkout->selected_method_of_payment ) {
931
+			switch ($this->checkout->selected_method_of_payment) {
932 932
 				case 'events_sold_out' :
933 933
 					EE_Error::add_attention(
934 934
 						apply_filters(
935 935
 							'FHEE__EE_SPCO_Reg_Step_Payment_Options___verify_payment_method_is_set__sold_out_events_msg',
936
-							__( 'It appears that the event you were about to make a payment for has sold out since this form first loaded. Please contact the event administrator if you believe this is an error.',
937
-								'event_espresso' )
936
+							__('It appears that the event you were about to make a payment for has sold out since this form first loaded. Please contact the event administrator if you believe this is an error.',
937
+								'event_espresso')
938 938
 						),
939 939
 						__FILE__, __FUNCTION__, __LINE__
940 940
 					);
@@ -944,7 +944,7 @@  discard block
 block discarded – undo
944 944
 					EE_Error::add_attention(
945 945
 						apply_filters(
946 946
 							'FHEE__EE_SPCO_Reg_Step_Payment_Options___verify_payment_method_is_set__payments_closed_msg',
947
-							__( 'It appears that the event you were about to make a payment for is not accepting payments at this time. Please contact the event administrator if you believe this is an error.', 'event_espresso' )
947
+							__('It appears that the event you were about to make a payment for is not accepting payments at this time. Please contact the event administrator if you believe this is an error.', 'event_espresso')
948 948
 						),
949 949
 						__FILE__, __FUNCTION__, __LINE__
950 950
 					);
@@ -954,7 +954,7 @@  discard block
 block discarded – undo
954 954
 					EE_Error::add_attention(
955 955
 						apply_filters(
956 956
 							'FHEE__EE_SPCO_Reg_Step_Payment_Options___verify_payment_method_is_set__no_payment_required_msg',
957
-							__( 'It appears that the event you were about to make a payment for does not require payment. Please contact the event administrator if you believe this is an error.', 'event_espresso' )
957
+							__('It appears that the event you were about to make a payment for does not require payment. Please contact the event administrator if you believe this is an error.', 'event_espresso')
958 958
 						),
959 959
 						__FILE__, __FUNCTION__, __LINE__
960 960
 					);
@@ -964,7 +964,7 @@  discard block
 block discarded – undo
964 964
 			}
965 965
 		}
966 966
 		// verify payment method
967
-		if ( ! $this->checkout->payment_method instanceof EE_Payment_Method ) {
967
+		if ( ! $this->checkout->payment_method instanceof EE_Payment_Method) {
968 968
 			// get payment method for selected method of payment
969 969
 			$this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment();
970 970
 		}
@@ -984,23 +984,23 @@  discard block
 block discarded – undo
984 984
 	 * @return void
985 985
 	 */
986 986
 	public function save_payer_details_via_ajax() {
987
-		if ( ! $this->_verify_payment_method_is_set() ) {
987
+		if ( ! $this->_verify_payment_method_is_set()) {
988 988
 			return;
989 989
 		}
990 990
 		// generate billing form for selected method of payment if it hasn't been done already
991
-		if ( $this->checkout->payment_method->type_obj()->has_billing_form() ) {
992
-			$this->checkout->billing_form = $this->_get_billing_form_for_payment_method( $this->checkout->payment_method );
991
+		if ($this->checkout->payment_method->type_obj()->has_billing_form()) {
992
+			$this->checkout->billing_form = $this->_get_billing_form_for_payment_method($this->checkout->payment_method);
993 993
 		}
994 994
 		// generate primary attendee from payer info if applicable
995 995
 		if ( ! $this->checkout->transaction_has_primary_registrant()) {
996 996
 			$attendee = $this->_create_attendee_from_request_data();
997
-			if ( $attendee instanceof EE_Attendee ) {
998
-				foreach ( $this->checkout->transaction->registrations() as $registration ) {
999
-					if ( $registration->is_primary_registrant() ) {
997
+			if ($attendee instanceof EE_Attendee) {
998
+				foreach ($this->checkout->transaction->registrations() as $registration) {
999
+					if ($registration->is_primary_registrant()) {
1000 1000
 						$this->checkout->primary_attendee_obj = $attendee;
1001
-						$registration->_add_relation_to( $attendee, 'Attendee' );
1002
-						$registration->set_attendee_id( $attendee->ID() );
1003
-						$registration->update_cache_after_object_save( 'Attendee', $attendee );
1001
+						$registration->_add_relation_to($attendee, 'Attendee');
1002
+						$registration->set_attendee_id($attendee->ID());
1003
+						$registration->update_cache_after_object_save('Attendee', $attendee);
1004 1004
 					}
1005 1005
 				}
1006 1006
 			}
@@ -1013,56 +1013,56 @@  discard block
 block discarded – undo
1013 1013
 	 * uses info from alternate GET or POST data (such as AJAX) to create a new attendee
1014 1014
 	 * @return \EE_Attendee
1015 1015
 	 */
1016
-	protected function _create_attendee_from_request_data(){
1016
+	protected function _create_attendee_from_request_data() {
1017 1017
 		// get State ID
1018
-		$STA_ID = ! empty( $_REQUEST['state'] ) ? sanitize_text_field( $_REQUEST['state'] ) : '';
1019
-		if ( ! empty( $STA_ID )) {
1018
+		$STA_ID = ! empty($_REQUEST['state']) ? sanitize_text_field($_REQUEST['state']) : '';
1019
+		if ( ! empty($STA_ID)) {
1020 1020
 			// can we get state object from name ?
1021
-			EE_Registry::instance()->load_model( 'State' );
1022
-			$state = EEM_State::instance()->get_col( array( array( 'STA_name' => $STA_ID ), 'limit' => 1), 'STA_ID' );
1023
-			$STA_ID = is_array( $state ) && ! empty( $state ) ? reset( $state ) : $STA_ID;
1021
+			EE_Registry::instance()->load_model('State');
1022
+			$state = EEM_State::instance()->get_col(array(array('STA_name' => $STA_ID), 'limit' => 1), 'STA_ID');
1023
+			$STA_ID = is_array($state) && ! empty($state) ? reset($state) : $STA_ID;
1024 1024
 		}
1025 1025
 		// get Country ISO
1026
-		$CNT_ISO = ! empty( $_REQUEST['country'] ) ? sanitize_text_field( $_REQUEST['country'] ) : '';
1027
-		if ( ! empty( $CNT_ISO )) {
1026
+		$CNT_ISO = ! empty($_REQUEST['country']) ? sanitize_text_field($_REQUEST['country']) : '';
1027
+		if ( ! empty($CNT_ISO)) {
1028 1028
 			// can we get country object from name ?
1029
-			EE_Registry::instance()->load_model( 'Country' );
1030
-			$country = EEM_Country::instance()->get_col( array( array( 'CNT_name' => $CNT_ISO ), 'limit' => 1), 'CNT_ISO' );
1031
-			$CNT_ISO = is_array( $country ) && ! empty( $country ) ? reset( $country ) : $CNT_ISO;
1029
+			EE_Registry::instance()->load_model('Country');
1030
+			$country = EEM_Country::instance()->get_col(array(array('CNT_name' => $CNT_ISO), 'limit' => 1), 'CNT_ISO');
1031
+			$CNT_ISO = is_array($country) && ! empty($country) ? reset($country) : $CNT_ISO;
1032 1032
 		}
1033 1033
 		// grab attendee data
1034 1034
 		$attendee_data = array(
1035
-			'ATT_fname' 		=> ! empty( $_REQUEST['first_name'] ) ? sanitize_text_field( $_REQUEST['first_name'] ) : '',
1036
-			'ATT_lname' 		=> ! empty( $_REQUEST['last_name'] ) ? sanitize_text_field( $_REQUEST['last_name'] ) : '',
1037
-			'ATT_email' 		=> ! empty( $_REQUEST['email'] ) ? sanitize_email( $_REQUEST['email'] ) : '',
1038
-			'ATT_address' 		=> ! empty( $_REQUEST['address'] ) ? sanitize_text_field( $_REQUEST['address'] ) : '',
1039
-			'ATT_address2' 	=> ! empty( $_REQUEST['address2'] ) ? sanitize_text_field( $_REQUEST['address2'] ) : '',
1040
-			'ATT_city' 			=> ! empty( $_REQUEST['city'] ) ? sanitize_text_field( $_REQUEST['city'] ) : '',
1035
+			'ATT_fname' 		=> ! empty($_REQUEST['first_name']) ? sanitize_text_field($_REQUEST['first_name']) : '',
1036
+			'ATT_lname' 		=> ! empty($_REQUEST['last_name']) ? sanitize_text_field($_REQUEST['last_name']) : '',
1037
+			'ATT_email' 		=> ! empty($_REQUEST['email']) ? sanitize_email($_REQUEST['email']) : '',
1038
+			'ATT_address' 		=> ! empty($_REQUEST['address']) ? sanitize_text_field($_REQUEST['address']) : '',
1039
+			'ATT_address2' 	=> ! empty($_REQUEST['address2']) ? sanitize_text_field($_REQUEST['address2']) : '',
1040
+			'ATT_city' 			=> ! empty($_REQUEST['city']) ? sanitize_text_field($_REQUEST['city']) : '',
1041 1041
 			'STA_ID' 				=> $STA_ID,
1042 1042
 			'CNT_ISO' 			=> $CNT_ISO,
1043
-			'ATT_zip' 				=> ! empty( $_REQUEST['zip'] ) ? sanitize_text_field( $_REQUEST['zip'] ) : '',
1044
-			'ATT_phone' 		=> ! empty( $_REQUEST['phone'] ) ? sanitize_text_field( $_REQUEST['phone'] ) : '',
1043
+			'ATT_zip' 				=> ! empty($_REQUEST['zip']) ? sanitize_text_field($_REQUEST['zip']) : '',
1044
+			'ATT_phone' 		=> ! empty($_REQUEST['phone']) ? sanitize_text_field($_REQUEST['phone']) : '',
1045 1045
 		);
1046 1046
 		// validate the email address since it is the most important piece of info
1047
-		if ( empty( $attendee_data['ATT_email'] ) || $attendee_data['ATT_email'] != $_REQUEST['email'] ) {
1048
-			EE_Error::add_error( __( 'An invalid email address was submitted.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
1047
+		if (empty($attendee_data['ATT_email']) || $attendee_data['ATT_email'] != $_REQUEST['email']) {
1048
+			EE_Error::add_error(__('An invalid email address was submitted.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1049 1049
 		}
1050 1050
 		// does this attendee already exist in the db ? we're searching using a combination of first name, last name, AND email address
1051
-		if ( ! empty( $attendee_data['ATT_fname'] ) && ! empty( $attendee_data['ATT_lname'] ) && ! empty( $attendee_data['ATT_email'] ) ) {
1052
-			$existing_attendee = EE_Registry::instance()->LIB->EEM_Attendee->find_existing_attendee( array(
1051
+		if ( ! empty($attendee_data['ATT_fname']) && ! empty($attendee_data['ATT_lname']) && ! empty($attendee_data['ATT_email'])) {
1052
+			$existing_attendee = EE_Registry::instance()->LIB->EEM_Attendee->find_existing_attendee(array(
1053 1053
 				'ATT_fname' => $attendee_data['ATT_fname'],
1054 1054
 				'ATT_lname' => $attendee_data['ATT_lname'],
1055 1055
 				'ATT_email' => $attendee_data['ATT_email']
1056 1056
 			));
1057
-			if ( $existing_attendee instanceof EE_Attendee ) {
1057
+			if ($existing_attendee instanceof EE_Attendee) {
1058 1058
 				return $existing_attendee;
1059 1059
 			}
1060 1060
 		}
1061 1061
 		// no existing attendee? kk let's create a new one
1062 1062
 		// kinda lame, but we need a first and last name to create an attendee, so use the email address if those don't exist
1063
-		$attendee_data['ATT_fname'] = ! empty( $attendee_data['ATT_fname'] ) ? $attendee_data['ATT_fname'] : $attendee_data['ATT_email'];
1064
-		$attendee_data['ATT_lname'] = ! empty( $attendee_data['ATT_lname'] ) ? $attendee_data['ATT_lname'] : $attendee_data['ATT_email'];
1065
-		return EE_Attendee::new_instance( $attendee_data );
1063
+		$attendee_data['ATT_fname'] = ! empty($attendee_data['ATT_fname']) ? $attendee_data['ATT_fname'] : $attendee_data['ATT_email'];
1064
+		$attendee_data['ATT_lname'] = ! empty($attendee_data['ATT_lname']) ? $attendee_data['ATT_lname'] : $attendee_data['ATT_email'];
1065
+		return EE_Attendee::new_instance($attendee_data);
1066 1066
 	}
1067 1067
 
1068 1068
 
@@ -1082,22 +1082,22 @@  discard block
 block discarded – undo
1082 1082
 	 */
1083 1083
 	public function process_reg_step() {
1084 1084
 		// how have they chosen to pay?
1085
-		$this->checkout->selected_method_of_payment = $this->checkout->transaction->is_free() ? 'no_payment_required' : $this->_get_selected_method_of_payment( TRUE );
1085
+		$this->checkout->selected_method_of_payment = $this->checkout->transaction->is_free() ? 'no_payment_required' : $this->_get_selected_method_of_payment(TRUE);
1086 1086
 		// choose your own adventure based on method_of_payment
1087
-		switch(  $this->checkout->selected_method_of_payment ) {
1087
+		switch ($this->checkout->selected_method_of_payment) {
1088 1088
 
1089 1089
 			case 'events_sold_out' :
1090 1090
 				$this->checkout->redirect = TRUE;
1091 1091
 				$this->checkout->redirect_url = $this->checkout->cancel_page_url;
1092
-				$this->checkout->json_response->set_redirect_url( $this->checkout->redirect_url );
1092
+				$this->checkout->json_response->set_redirect_url($this->checkout->redirect_url);
1093 1093
 				// mark this reg step as completed
1094 1094
 				$this->set_completed();
1095 1095
 				return FALSE;
1096 1096
 				break;
1097 1097
 
1098 1098
 			case 'payments_closed' :
1099
-				if ( apply_filters( 'FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__payments_closed__display_success', false ) ) {
1100
-					EE_Error::add_success( __( 'no payment required at this time.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
1099
+				if (apply_filters('FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__payments_closed__display_success', false)) {
1100
+					EE_Error::add_success(__('no payment required at this time.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1101 1101
 				}
1102 1102
 				// mark this reg step as completed
1103 1103
 				$this->set_completed();
@@ -1105,8 +1105,8 @@  discard block
 block discarded – undo
1105 1105
 				break;
1106 1106
 
1107 1107
 			case 'no_payment_required' :
1108
-				if ( apply_filters( 'FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__no_payment_required__display_success', false ) ) {
1109
-					EE_Error::add_success( __( 'no payment required.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
1108
+				if (apply_filters('FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__no_payment_required__display_success', false)) {
1109
+					EE_Error::add_success(__('no payment required.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1110 1110
 				}
1111 1111
 				// mark this reg step as completed
1112 1112
 				$this->set_completed();
@@ -1115,9 +1115,9 @@  discard block
 block discarded – undo
1115 1115
 
1116 1116
 			default:
1117 1117
 				$payment_successful = $this->_process_payment();
1118
-				if ( $payment_successful ) {
1118
+				if ($payment_successful) {
1119 1119
 					$this->checkout->continue_reg = true;
1120
-					$this->_maybe_set_completed( $this->checkout->payment_method );
1120
+					$this->_maybe_set_completed($this->checkout->payment_method);
1121 1121
 				} else {
1122 1122
 					$this->checkout->continue_reg = false;
1123 1123
 				}
@@ -1135,8 +1135,8 @@  discard block
 block discarded – undo
1135 1135
 	 * @param \EE_Payment_Method $payment_method
1136 1136
 	 * @return void
1137 1137
 	 */
1138
-	protected function _maybe_set_completed( EE_Payment_Method $payment_method ) {
1139
-		switch ( $payment_method->type_obj()->payment_occurs() ) {
1138
+	protected function _maybe_set_completed(EE_Payment_Method $payment_method) {
1139
+		switch ($payment_method->type_obj()->payment_occurs()) {
1140 1140
 			case EE_PMT_Base::offsite :
1141 1141
 				break;
1142 1142
 			case EE_PMT_Base::onsite :
@@ -1159,15 +1159,15 @@  discard block
 block discarded – undo
1159 1159
 	public function update_reg_step() {
1160 1160
 		$success = TRUE;
1161 1161
 		// if payment required
1162
-		if ( $this->checkout->transaction->total() > 0 ) {
1163
-			do_action ('AHEE__EE_Single_Page_Checkout__process_finalize_registration__before_gateway', $this->checkout->transaction );
1162
+		if ($this->checkout->transaction->total() > 0) {
1163
+			do_action('AHEE__EE_Single_Page_Checkout__process_finalize_registration__before_gateway', $this->checkout->transaction);
1164 1164
 			// attempt payment via payment method
1165 1165
 			$success = $this->process_reg_step();
1166 1166
 		}
1167
-		if ( $success && ! $this->checkout->redirect ) {
1168
-			$this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn( $this->checkout->transaction->ID() );
1167
+		if ($success && ! $this->checkout->redirect) {
1168
+			$this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn($this->checkout->transaction->ID());
1169 1169
 			 // set return URL
1170
-			$this->checkout->redirect_url = add_query_arg( array( 'e_reg_url_link' => $this->checkout->reg_url_link ), $this->checkout->thank_you_page_url );
1170
+			$this->checkout->redirect_url = add_query_arg(array('e_reg_url_link' => $this->checkout->reg_url_link), $this->checkout->thank_you_page_url);
1171 1171
 		}
1172 1172
 		return $success;
1173 1173
 	}
@@ -1185,32 +1185,32 @@  discard block
 block discarded – undo
1185 1185
 	 */
1186 1186
 	private function _process_payment() {
1187 1187
 		// basically confirm that the event hasn't sold out since they hit the page
1188
-		if ( ! $this->_last_second_ticket_verifications() ) {
1188
+		if ( ! $this->_last_second_ticket_verifications()) {
1189 1189
 			return false;
1190 1190
 		}
1191 1191
 		// ya gotta make a choice man
1192
-		if ( empty( $this->checkout->selected_method_of_payment )) {
1193
-			$this->checkout->json_response->set_plz_select_method_of_payment( __( 'Please select a method of payment before proceeding.', 'event_espresso' ));
1192
+		if (empty($this->checkout->selected_method_of_payment)) {
1193
+			$this->checkout->json_response->set_plz_select_method_of_payment(__('Please select a method of payment before proceeding.', 'event_espresso'));
1194 1194
 			return FALSE;
1195 1195
 		}
1196 1196
 		// get EE_Payment_Method object
1197
-		if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment() ) {
1197
+		if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) {
1198 1198
 			return FALSE;
1199 1199
 		}
1200 1200
 		// setup billing form
1201
-		if ( $this->checkout->payment_method->is_on_site() ) {
1202
-			$this->checkout->billing_form = $this->_get_billing_form_for_payment_method( $this->checkout->payment_method );
1201
+		if ($this->checkout->payment_method->is_on_site()) {
1202
+			$this->checkout->billing_form = $this->_get_billing_form_for_payment_method($this->checkout->payment_method);
1203 1203
 			// bad billing form ?
1204
-			if ( ! $this->_billing_form_is_valid() ) {
1204
+			if ( ! $this->_billing_form_is_valid()) {
1205 1205
 				return FALSE;
1206 1206
 			}
1207 1207
 		}
1208 1208
 		// ensure primary registrant has been fully processed
1209
-		if ( ! $this->_setup_primary_registrant_prior_to_payment() ) {
1209
+		if ( ! $this->_setup_primary_registrant_prior_to_payment()) {
1210 1210
 			return FALSE;
1211 1211
 		}
1212 1212
 		// if session is close to expiring (under 10 minutes by default)
1213
-		if ( ( time() - EE_Registry::instance()->SSN->expiration() ) < EE_Registry::instance()->SSN->extension() ) {
1213
+		if ((time() - EE_Registry::instance()->SSN->expiration()) < EE_Registry::instance()->SSN->extension()) {
1214 1214
 			// add some time to session expiration so that payment can be completed
1215 1215
 			EE_Registry::instance()->SSN->extend_expiration();
1216 1216
 		}
@@ -1219,24 +1219,24 @@  discard block
 block discarded – undo
1219 1219
 		// 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
1220 1220
 		//$transaction_processor->toggle_registration_statuses_for_default_approved_events( $this->checkout->transaction, $this->checkout->reg_cache_where_params );
1221 1221
 		// attempt payment
1222
-		$payment = $this->_attempt_payment( $this->checkout->payment_method );
1222
+		$payment = $this->_attempt_payment($this->checkout->payment_method);
1223 1223
 		// process results
1224
-		$payment = $this->_validate_payment( $payment );
1225
-		$payment = $this->_post_payment_processing( $payment );
1224
+		$payment = $this->_validate_payment($payment);
1225
+		$payment = $this->_post_payment_processing($payment);
1226 1226
 		// verify payment
1227
-		if ( $payment instanceof EE_Payment ) {
1227
+		if ($payment instanceof EE_Payment) {
1228 1228
 			// store that for later
1229 1229
 			$this->checkout->payment = $payment;
1230 1230
 			/** @type EE_Transaction_Processor $transaction_processor */
1231
-			$transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' );
1231
+			$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
1232 1232
 			// we can also consider the TXN to not have been failed, so temporarily upgrade it's status to abandoned
1233
-			$transaction_processor->toggle_failed_transaction_status( $this->checkout->transaction );
1234
-			if ( $payment->status() == EEM_Payment::status_id_approved || $payment->status() == EEM_Payment::status_id_pending ) {
1233
+			$transaction_processor->toggle_failed_transaction_status($this->checkout->transaction);
1234
+			if ($payment->status() == EEM_Payment::status_id_approved || $payment->status() == EEM_Payment::status_id_pending) {
1235 1235
 				return true;
1236 1236
 			} else {
1237 1237
 				return false;
1238 1238
 			}
1239
-		} else if ( $payment === true ) {
1239
+		} else if ($payment === true) {
1240 1240
 			// please note that offline payment methods will NOT make a payment,
1241 1241
 			// but instead just mark themselves as the PMD_ID on the transaction, and return true
1242 1242
 			$this->checkout->payment = $payment;
@@ -1256,22 +1256,22 @@  discard block
 block discarded – undo
1256 1256
 	 */
1257 1257
 	protected function _last_second_ticket_verifications() {
1258 1258
 		// don't bother re-validating if not a return visit
1259
-		if ( ! $this->checkout->revisit ) {
1259
+		if ( ! $this->checkout->revisit) {
1260 1260
 			return true;
1261 1261
 		}
1262 1262
 		$registrations = $this->checkout->transaction->registrations();
1263
-		if ( empty( $registrations ) ) {
1263
+		if (empty($registrations)) {
1264 1264
 			return false;
1265 1265
 		}
1266
-		foreach ( $registrations as $registration ) {
1267
-			if ( $registration instanceof EE_Registration ) {
1266
+		foreach ($registrations as $registration) {
1267
+			if ($registration instanceof EE_Registration) {
1268 1268
 				$event = $registration->event_obj();
1269
-				if ( ! ( $event instanceof EE_Event && $event->is_sold_out( true ) ) ) {
1269
+				if ( ! ($event instanceof EE_Event && $event->is_sold_out(true))) {
1270 1270
 					EE_Error::add_error(
1271 1271
 						apply_filters(
1272 1272
 							'FHEE__EE_SPCO_Reg_Step_Payment_Options___last_second_ticket_verifications__sold_out_events_msg',
1273 1273
 							sprintf(
1274
-								__( 'It appears that the %1$s event that you were about to make a payment for has sold out since you first registered and/or arrived at this page. Please refresh the page and try again. If you have already made a partial payment towards this event, please contact the event administrator for a refund.', 'event_espresso' ),
1274
+								__('It appears that the %1$s event that you were about to make a payment for has sold out since you first registered and/or arrived at this page. Please refresh the page and try again. If you have already made a partial payment towards this event, please contact the event administrator for a refund.', 'event_espresso'),
1275 1275
 								$event->name()
1276 1276
 							)
1277 1277
 						),
@@ -1295,10 +1295,10 @@  discard block
 block discarded – undo
1295 1295
 	 * @return bool
1296 1296
 	 */
1297 1297
 	public function redirect_form() {
1298
-		$payment_method_billing_info = $this->_payment_method_billing_info( $this->_get_payment_method_for_selected_method_of_payment() );
1298
+		$payment_method_billing_info = $this->_payment_method_billing_info($this->_get_payment_method_for_selected_method_of_payment());
1299 1299
 		$html = $payment_method_billing_info->get_html_and_js();
1300 1300
 		$html .= $this->checkout->redirect_form;
1301
-		EE_Registry::instance()->REQ->add_output( $html );
1301
+		EE_Registry::instance()->REQ->add_output($html);
1302 1302
 		return TRUE;
1303 1303
 	}
1304 1304
 
@@ -1311,33 +1311,33 @@  discard block
 block discarded – undo
1311 1311
 	 * @return bool
1312 1312
 	 */
1313 1313
 	private function _billing_form_is_valid() {
1314
-		if ( $this->checkout->billing_form instanceof EE_Billing_Info_Form ) {
1315
-			if ( $this->checkout->billing_form->was_submitted() ) {
1314
+		if ($this->checkout->billing_form instanceof EE_Billing_Info_Form) {
1315
+			if ($this->checkout->billing_form->was_submitted()) {
1316 1316
 				$this->checkout->billing_form->receive_form_submission();
1317
-				if ( $this->checkout->billing_form->is_valid() ) {
1317
+				if ($this->checkout->billing_form->is_valid()) {
1318 1318
 					return TRUE;
1319 1319
 				}
1320 1320
 				$validation_errors = $this->checkout->billing_form->get_validation_errors_accumulated();
1321 1321
 				$error_strings = array();
1322
-				foreach( $validation_errors as $validation_error ){
1323
-					if( $validation_error instanceof EE_Validation_Error ){
1322
+				foreach ($validation_errors as $validation_error) {
1323
+					if ($validation_error instanceof EE_Validation_Error) {
1324 1324
 						$form_section = $validation_error->get_form_section();
1325
-						if( $form_section instanceof EE_Form_Input_Base ){
1325
+						if ($form_section instanceof EE_Form_Input_Base) {
1326 1326
 							$label = $form_section->html_label_text();
1327
-						}elseif( $form_section instanceof EE_Form_Section_Base ){
1327
+						}elseif ($form_section instanceof EE_Form_Section_Base) {
1328 1328
 							$label = $form_section->name();
1329
-						}else{
1330
-							$label = __( 'Validation Error', 'event_espresso' );
1329
+						} else {
1330
+							$label = __('Validation Error', 'event_espresso');
1331 1331
 						}
1332
-						$error_strings[] = sprintf('%1$s: %2$s', $label, $validation_error->getMessage() );
1332
+						$error_strings[] = sprintf('%1$s: %2$s', $label, $validation_error->getMessage());
1333 1333
 					}
1334 1334
 				}
1335
-				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__ );
1335
+				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__);
1336 1336
 			} else {
1337
-				EE_Error::add_error( __( 'The billing form was not submitted or something prevented it\'s submission.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
1337
+				EE_Error::add_error(__('The billing form was not submitted or something prevented it\'s submission.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1338 1338
 			}
1339 1339
 		} else {
1340
-			EE_Error::add_error( __( 'The submitted billing form is invalid possibly due to a technical reason.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
1340
+			EE_Error::add_error(__('The submitted billing form is invalid possibly due to a technical reason.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1341 1341
 		}
1342 1342
 		return FALSE;
1343 1343
 	}
@@ -1355,9 +1355,9 @@  discard block
 block discarded – undo
1355 1355
 	 */
1356 1356
 		private function _setup_primary_registrant_prior_to_payment() {
1357 1357
 			// check if transaction has a primary registrant and that it has a related Attendee object
1358
-			if ( ! $this->checkout->transaction_has_primary_registrant() ) {
1358
+			if ( ! $this->checkout->transaction_has_primary_registrant()) {
1359 1359
 				// need to at least gather some primary registrant data before attempting payment
1360
-				if ( $this->checkout->billing_form instanceof EE_Billing_Attendee_Info_Form && ! $this->_capture_primary_registration_data_from_billing_form() ) {
1360
+				if ($this->checkout->billing_form instanceof EE_Billing_Attendee_Info_Form && ! $this->_capture_primary_registration_data_from_billing_form()) {
1361 1361
 					return FALSE;
1362 1362
 				}
1363 1363
 			}
@@ -1365,13 +1365,13 @@  discard block
 block discarded – undo
1365 1365
 			// grab the primary_registration object
1366 1366
 			$primary_registration = $this->checkout->transaction->primary_registration();
1367 1367
 			/** @type EE_Transaction_Processor $transaction_processor */
1368
-			$transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' );
1368
+			$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
1369 1369
 			// at this point we'll consider a TXN to not have been failed
1370
-			$transaction_processor->toggle_failed_transaction_status( $this->checkout->transaction );
1370
+			$transaction_processor->toggle_failed_transaction_status($this->checkout->transaction);
1371 1371
 			// save the TXN ( which clears cached copy of primary_registration)
1372 1372
 			$this->checkout->transaction->save();
1373 1373
 			// grab TXN ID and save it to the primary_registration
1374
-			$primary_registration->set_transaction_id( $this->checkout->transaction->ID() );
1374
+			$primary_registration->set_transaction_id($this->checkout->transaction->ID());
1375 1375
 			// save what we have so far
1376 1376
 			$primary_registration->save();
1377 1377
 			return TRUE;
@@ -1388,41 +1388,41 @@  discard block
 block discarded – undo
1388 1388
 		private function _capture_primary_registration_data_from_billing_form() {
1389 1389
 			// convert billing form data into an attendee
1390 1390
 			$this->checkout->primary_attendee_obj = $this->checkout->billing_form->create_attendee_from_billing_form_data();
1391
-			if ( ! $this->checkout->primary_attendee_obj instanceof EE_Attendee ) {
1391
+			if ( ! $this->checkout->primary_attendee_obj instanceof EE_Attendee) {
1392 1392
 				EE_Error::add_error(
1393 1393
 					sprintf(
1394
-						__( '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' ),
1394
+						__('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'),
1395 1395
 						'<br/>',
1396
-						EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
1396
+						EE_Registry::instance()->CFG->organization->get_pretty('email')
1397 1397
 					), __FILE__, __FUNCTION__, __LINE__
1398 1398
 				);
1399 1399
 				return FALSE;
1400 1400
 			}
1401 1401
 			$primary_registration = $this->checkout->transaction->primary_registration();
1402
-			if ( ! $primary_registration instanceof EE_Registration ) {
1402
+			if ( ! $primary_registration instanceof EE_Registration) {
1403 1403
 				EE_Error::add_error(
1404 1404
 					sprintf(
1405
-						__( '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' ),
1405
+						__('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'),
1406 1406
 						'<br/>',
1407
-						EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
1407
+						EE_Registry::instance()->CFG->organization->get_pretty('email')
1408 1408
 					), __FILE__, __FUNCTION__, __LINE__
1409 1409
 				);
1410 1410
 				return FALSE;
1411 1411
 			}
1412
-			if ( ! $primary_registration->_add_relation_to( $this->checkout->primary_attendee_obj, 'Attendee' ) instanceof EE_Attendee ) {
1412
+			if ( ! $primary_registration->_add_relation_to($this->checkout->primary_attendee_obj, 'Attendee') instanceof EE_Attendee) {
1413 1413
 				EE_Error::add_error(
1414 1414
 					sprintf(
1415
-						__( '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' ),
1415
+						__('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'),
1416 1416
 						'<br/>',
1417
-						EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
1417
+						EE_Registry::instance()->CFG->organization->get_pretty('email')
1418 1418
 					), __FILE__, __FUNCTION__, __LINE__
1419 1419
 				);
1420 1420
 				return FALSE;
1421 1421
 			}
1422 1422
 			/** @type EE_Registration_Processor $registration_processor */
1423
-			$registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' );
1423
+			$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
1424 1424
 			// at this point, we should have enough details about the registrant to consider the registration NOT incomplete
1425
-			$registration_processor->toggle_incomplete_registration_status_to_default( $primary_registration );
1425
+			$registration_processor->toggle_incomplete_registration_status_to_default($primary_registration);
1426 1426
 
1427 1427
 			return TRUE;
1428 1428
 		}
@@ -1438,35 +1438,35 @@  discard block
 block discarded – undo
1438 1438
 	 */
1439 1439
 		private function _get_payment_method_for_selected_method_of_payment() {
1440 1440
 			// get EE_Payment_Method object
1441
-			if ( isset( $this->checkout->available_payment_methods[ $this->checkout->selected_method_of_payment ] )) {
1442
-				$payment_method = $this->checkout->available_payment_methods[ $this->checkout->selected_method_of_payment ];
1441
+			if (isset($this->checkout->available_payment_methods[$this->checkout->selected_method_of_payment])) {
1442
+				$payment_method = $this->checkout->available_payment_methods[$this->checkout->selected_method_of_payment];
1443 1443
 			} else {
1444 1444
 				// load EEM_Payment_Method
1445
-				EE_Registry::instance()->load_model( 'Payment_Method' );
1445
+				EE_Registry::instance()->load_model('Payment_Method');
1446 1446
 				/** @type EEM_Payment_Method $EEM_Payment_Method */
1447 1447
 				$EEM_Payment_Method = EE_Registry::instance()->LIB->EEM_Payment_Method;
1448
-				$payment_method = $EEM_Payment_Method->get_one_by_slug( $this->checkout->selected_method_of_payment );
1448
+				$payment_method = $EEM_Payment_Method->get_one_by_slug($this->checkout->selected_method_of_payment);
1449 1449
 			}
1450 1450
 			// verify $payment_method
1451
-			if ( ! $payment_method instanceof EE_Payment_Method ) {
1451
+			if ( ! $payment_method instanceof EE_Payment_Method) {
1452 1452
 				// not a payment
1453 1453
 				EE_Error::add_error(
1454 1454
 					sprintf(
1455
-						__( 'The selected method of payment could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso' ),
1455
+						__('The selected method of payment could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso'),
1456 1456
 						'<br/>',
1457
-						EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
1457
+						EE_Registry::instance()->CFG->organization->get_pretty('email')
1458 1458
 					), __FILE__, __FUNCTION__, __LINE__
1459 1459
 				);
1460 1460
 				return NULL;
1461 1461
 			}
1462 1462
 			// and verify it has a valid Payment_Method Type object
1463
-			if ( ! $payment_method->type_obj() instanceof EE_PMT_Base ) {
1463
+			if ( ! $payment_method->type_obj() instanceof EE_PMT_Base) {
1464 1464
 				// not a payment
1465 1465
 				EE_Error::add_error(
1466 1466
 					sprintf(
1467
-						__( 'A valid payment method could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso' ),
1467
+						__('A valid payment method could not be determined due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso'),
1468 1468
 						'<br/>',
1469
-						EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
1469
+						EE_Registry::instance()->CFG->organization->get_pretty('email')
1470 1470
 					), __FILE__, __FUNCTION__, __LINE__
1471 1471
 				);
1472 1472
 				return NULL;
@@ -1485,30 +1485,30 @@  discard block
 block discarded – undo
1485 1485
 	 * 	@type 	EE_Payment_Method $payment_method
1486 1486
 	 * 	@return 	mixed	EE_Payment | boolean
1487 1487
 	 */
1488
-	private function _attempt_payment( EE_Payment_Method $payment_method ) {
1489
-		$payment =NULL;
1488
+	private function _attempt_payment(EE_Payment_Method $payment_method) {
1489
+		$payment = NULL;
1490 1490
 		$this->checkout->transaction->save();
1491
-		$payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' );
1492
-		if ( ! $payment_processor instanceof EE_Payment_Processor ) {
1491
+		$payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
1492
+		if ( ! $payment_processor instanceof EE_Payment_Processor) {
1493 1493
 			return FALSE;
1494 1494
 		}
1495 1495
 		try {
1496
-			$payment_processor->set_revisit( $this->checkout->revisit );
1496
+			$payment_processor->set_revisit($this->checkout->revisit);
1497 1497
 			// generate payment object
1498 1498
 			$payment = $payment_processor->process_payment(
1499 1499
 				$payment_method,
1500 1500
 				$this->checkout->transaction,
1501 1501
 				$this->checkout->amount_owing,
1502 1502
 				$this->checkout->billing_form,
1503
-				$this->_get_return_url( $payment_method ),
1503
+				$this->_get_return_url($payment_method),
1504 1504
 				'CART',
1505 1505
 				$this->checkout->admin_request,
1506 1506
 				TRUE,
1507 1507
 				$this->reg_step_url()
1508 1508
 			);
1509 1509
 
1510
-		} catch( Exception $e ) {
1511
-			$this->_handle_payment_processor_exception( $e );
1510
+		} catch (Exception $e) {
1511
+			$this->_handle_payment_processor_exception($e);
1512 1512
 		}
1513 1513
 		return $payment;
1514 1514
 	}
@@ -1522,12 +1522,12 @@  discard block
 block discarded – undo
1522 1522
 	 * @param \Exception $e
1523 1523
 	 * @return void
1524 1524
 	 */
1525
-	protected function _handle_payment_processor_exception( Exception $e ) {
1525
+	protected function _handle_payment_processor_exception(Exception $e) {
1526 1526
 		EE_Error::add_error(
1527 1527
 			sprintf(
1528
-				__( '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' ),
1528
+				__('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'),
1529 1529
 				'<br/>',
1530
-				EE_Registry::instance()->CFG->organization->get_pretty( 'email' ),
1530
+				EE_Registry::instance()->CFG->organization->get_pretty('email'),
1531 1531
 				$e->getMessage(),
1532 1532
 				$e->getFile(),
1533 1533
 				$e->getLine()
@@ -1544,9 +1544,9 @@  discard block
 block discarded – undo
1544 1544
 	 * @param \EE_Payment_Method $payment_method
1545 1545
 	 * @return string
1546 1546
 	 */
1547
-	protected function _get_return_url( EE_Payment_Method $payment_method ) {
1547
+	protected function _get_return_url(EE_Payment_Method $payment_method) {
1548 1548
 		$return_url = '';
1549
-		switch ( $payment_method->type_obj()->payment_occurs() ) {
1549
+		switch ($payment_method->type_obj()->payment_occurs()) {
1550 1550
 
1551 1551
 			case EE_PMT_Base::offsite :
1552 1552
 				$return_url = add_query_arg(
@@ -1577,27 +1577,27 @@  discard block
 block discarded – undo
1577 1577
 	 * @param EE_Payment $payment
1578 1578
 	 * @return EE_Payment | FALSE
1579 1579
 	 */
1580
-	private function _validate_payment( $payment = NULL ) {
1581
-		if (  $this->checkout->payment_method->is_off_line() ) {
1580
+	private function _validate_payment($payment = NULL) {
1581
+		if ($this->checkout->payment_method->is_off_line()) {
1582 1582
 			return TRUE;
1583 1583
 		}
1584 1584
 		// verify payment object
1585
-		if ( $payment instanceof EE_Payment ) {
1585
+		if ($payment instanceof EE_Payment) {
1586 1586
 			if (
1587 1587
 				$payment->status() != EEM_Payment::status_id_approved
1588 1588
 				&& $payment->status() != EEM_Payment::status_id_pending
1589 1589
 				&& $payment->status() != EEM_Payment::status_id_cancelled
1590 1590
 				&& $payment->gateway_response() != ''
1591 1591
 			) {
1592
-				EE_Error::add_error( $payment->gateway_response(), __FILE__, __FUNCTION__, __LINE__ );
1592
+				EE_Error::add_error($payment->gateway_response(), __FILE__, __FUNCTION__, __LINE__);
1593 1593
 			}
1594 1594
 		} else {
1595 1595
 			// not a payment
1596 1596
 			EE_Error::add_error(
1597 1597
 				sprintf(
1598
-					__( 'A valid payment was not generated due to a technical issue.%1$sPlease try again or contact %2$s for assistance.', 'event_espresso' ),
1598
+					__('A valid payment was not generated due to a technical issue.%1$sPlease try again or contact %2$s for assistance.', 'event_espresso'),
1599 1599
 					'<br/>',
1600
-					EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
1600
+					EE_Registry::instance()->CFG->organization->get_pretty('email')
1601 1601
 				), __FILE__, __FUNCTION__, __LINE__
1602 1602
 			);
1603 1603
 			return FALSE;
@@ -1614,23 +1614,23 @@  discard block
 block discarded – undo
1614 1614
 	 * @param EE_Payment $payment
1615 1615
 	 * @return bool
1616 1616
 	 */
1617
-	private function _post_payment_processing( $payment = NULL ) {
1617
+	private function _post_payment_processing($payment = NULL) {
1618 1618
 		// On-Site payment?
1619
-		if ( $this->checkout->payment_method->is_on_site() ) {
1620
-			if ( ! $this->_process_payment_status( $payment, EE_PMT_Base::onsite )) {
1619
+		if ($this->checkout->payment_method->is_on_site()) {
1620
+			if ( ! $this->_process_payment_status($payment, EE_PMT_Base::onsite)) {
1621 1621
 				//$this->_setup_redirect_for_next_step();
1622 1622
 				$this->checkout->continue_reg = false;
1623 1623
 			}
1624 1624
 			// Off-Site payment?
1625
-		} else if ( $this->checkout->payment_method->is_off_site() ) {
1625
+		} else if ($this->checkout->payment_method->is_off_site()) {
1626 1626
 			// if a payment object was made and it specifies a redirect url, then we'll setup that redirect info
1627
-			if ( $payment instanceof EE_Payment && $payment->redirect_url() ){
1628
-				do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $payment->redirect_url(), '$payment->redirect_url()' );
1627
+			if ($payment instanceof EE_Payment && $payment->redirect_url()) {
1628
+				do_action('AHEE_log', __CLASS__, __FUNCTION__, $payment->redirect_url(), '$payment->redirect_url()');
1629 1629
 				$this->checkout->redirect = TRUE;
1630 1630
 				$this->checkout->redirect_form = $payment->redirect_form();
1631
-				$this->checkout->redirect_url = $this->reg_step_url( 'redirect_form' );
1631
+				$this->checkout->redirect_url = $this->reg_step_url('redirect_form');
1632 1632
 				// set JSON response
1633
-				$this->checkout->json_response->set_redirect_form( $this->checkout->redirect_form );
1633
+				$this->checkout->json_response->set_redirect_form($this->checkout->redirect_form);
1634 1634
 				// set cron job for finalizing the TXN
1635 1635
 				// in case the user does not return from the off-site gateway
1636 1636
 				EE_Cron_Tasks::schedule_finalize_abandoned_transactions_check(
@@ -1638,21 +1638,21 @@  discard block
 block discarded – undo
1638 1638
 					$this->checkout->transaction->ID()
1639 1639
 				);
1640 1640
 				// and lastly, let's bump the payment status to pending
1641
-				$payment->set_status( EEM_Payment::status_id_pending );
1641
+				$payment->set_status(EEM_Payment::status_id_pending);
1642 1642
 				$payment->save();
1643 1643
 			} else {
1644 1644
 				// not a payment
1645 1645
 				$this->checkout->continue_reg = false;
1646 1646
 				EE_Error::add_error(
1647 1647
 					sprintf(
1648
-						__( 'It appears the Off Site Payment Method was not configured properly.%sPlease try again or contact %s for assistance.', 'event_espresso' ),
1648
+						__('It appears the Off Site Payment Method was not configured properly.%sPlease try again or contact %s for assistance.', 'event_espresso'),
1649 1649
 						'<br/>',
1650
-						EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
1650
+						EE_Registry::instance()->CFG->organization->get_pretty('email')
1651 1651
 					), __FILE__, __FUNCTION__, __LINE__
1652 1652
 				);
1653 1653
 			}
1654 1654
 			// Off-Line payment?
1655
-		} else if ( $payment === TRUE ) {
1655
+		} else if ($payment === TRUE) {
1656 1656
 			//$this->_setup_redirect_for_next_step();
1657 1657
 			return TRUE;
1658 1658
 		} else {
@@ -1688,65 +1688,65 @@  discard block
 block discarded – undo
1688 1688
 	 * @return bool
1689 1689
 	 * @throws \EE_Error
1690 1690
 	 */
1691
-	private function _process_payment_status( $payment, $payment_occurs = EE_PMT_Base::offline ) {
1691
+	private function _process_payment_status($payment, $payment_occurs = EE_PMT_Base::offline) {
1692 1692
 		// off-line payment? carry on
1693
-		if ( $payment_occurs == EE_PMT_Base::offline ) {
1693
+		if ($payment_occurs == EE_PMT_Base::offline) {
1694 1694
 			return true;
1695 1695
 		}
1696 1696
 		// verify payment validity
1697
-		if ( $payment instanceof EE_Payment ) {
1698
-			do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $payment->status(), '$payment->status()' );
1697
+		if ($payment instanceof EE_Payment) {
1698
+			do_action('AHEE_log', __CLASS__, __FUNCTION__, $payment->status(), '$payment->status()');
1699 1699
 			$msg = $payment->gateway_response();
1700 1700
 			// check results
1701
-			switch ( $payment->status() ) {
1701
+			switch ($payment->status()) {
1702 1702
 
1703 1703
 				// good payment
1704 1704
 				case EEM_Payment::status_id_approved :
1705
-					EE_Error::add_success( __( 'Your payment was processed successfully.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
1705
+					EE_Error::add_success(__('Your payment was processed successfully.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1706 1706
 					return TRUE;
1707 1707
 					break;
1708 1708
 
1709 1709
 				// slow payment
1710 1710
 				case EEM_Payment::status_id_pending :
1711
-					if ( empty( $msg )) {
1712
-						$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' );
1711
+					if (empty($msg)) {
1712
+						$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');
1713 1713
 					}
1714
-					EE_Error::add_success( $msg, __FILE__, __FUNCTION__, __LINE__ );
1714
+					EE_Error::add_success($msg, __FILE__, __FUNCTION__, __LINE__);
1715 1715
 					return TRUE;
1716 1716
 					break;
1717 1717
 
1718 1718
 				// don't wanna payment
1719 1719
 				case EEM_Payment::status_id_cancelled :
1720
-					if ( empty( $msg )) {
1720
+					if (empty($msg)) {
1721 1721
 						$msg = _n(
1722 1722
 							'Payment cancelled. Please try again.',
1723 1723
 							'Payment cancelled. Please try again or select another method of payment.',
1724
-							count( $this->checkout->available_payment_methods ),
1724
+							count($this->checkout->available_payment_methods),
1725 1725
 							'event_espresso'
1726 1726
 						);
1727 1727
 					}
1728
-					EE_Error::add_attention( $msg, __FILE__, __FUNCTION__, __LINE__ );
1728
+					EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__);
1729 1729
 					return FALSE;
1730 1730
 					break;
1731 1731
 
1732 1732
 				// not enough payment
1733 1733
 				case EEM_Payment::status_id_declined :
1734
-					if ( empty( $msg )) {
1734
+					if (empty($msg)) {
1735 1735
 						$msg = _n(
1736 1736
 							'We\'re sorry but your payment was declined. Please try again.',
1737 1737
 							'We\'re sorry but your payment was declined. Please try again or select another method of payment.',
1738
-							count( $this->checkout->available_payment_methods ),
1738
+							count($this->checkout->available_payment_methods),
1739 1739
 							'event_espresso'
1740 1740
 						);
1741 1741
 					}
1742
-					EE_Error::add_attention( $msg, __FILE__, __FUNCTION__, __LINE__ );
1742
+					EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__);
1743 1743
 					return FALSE;
1744 1744
 					break;
1745 1745
 
1746 1746
 				// bad payment
1747 1747
 				case EEM_Payment::status_id_failed :
1748
-					if ( ! empty( $msg ) ) {
1749
-						EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
1748
+					if ( ! empty($msg)) {
1749
+						EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1750 1750
 						return false;
1751 1751
 					}
1752 1752
 					// default to error below
@@ -1756,14 +1756,14 @@  discard block
 block discarded – undo
1756 1756
 		}
1757 1757
 		// off-site payment gateway responses are too unreliable, so let's just assume that
1758 1758
 		// the payment processing is just running slower than the registrant's request
1759
-		if ( $payment_occurs == EE_PMT_Base::offsite ) {
1759
+		if ($payment_occurs == EE_PMT_Base::offsite) {
1760 1760
 			return true;
1761 1761
 		}
1762 1762
 		EE_Error::add_error(
1763 1763
 				sprintf(
1764
-					__( 'Your payment could not be processed successfully due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso' ),
1764
+					__('Your payment could not be processed successfully due to a technical issue.%sPlease try again or contact %s for assistance.', 'event_espresso'),
1765 1765
 					'<br/>',
1766
-					EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
1766
+					EE_Registry::instance()->CFG->organization->get_pretty('email')
1767 1767
 				),
1768 1768
 				__FILE__, __FUNCTION__, __LINE__
1769 1769
 			);
@@ -1796,13 +1796,13 @@  discard block
 block discarded – undo
1796 1796
 	public function process_gateway_response() {
1797 1797
 		$payment = null;
1798 1798
 		// how have they chosen to pay?
1799
-		$this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( true );
1799
+		$this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true);
1800 1800
 		// get EE_Payment_Method object
1801
-		if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment() ) {
1801
+		if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) {
1802 1802
 			$this->checkout->continue_reg = false;
1803 1803
 			return false;
1804 1804
 		}
1805
-		if ( ! $this->checkout->payment_method->is_off_site() ) {
1805
+		if ( ! $this->checkout->payment_method->is_off_site()) {
1806 1806
 			return false;
1807 1807
 		}
1808 1808
 		$this->_validate_offsite_return();
@@ -1816,23 +1816,23 @@  discard block
 block discarded – undo
1816 1816
 		//	true
1817 1817
 		//);
1818 1818
 		// verify TXN
1819
-		if ( $this->checkout->transaction instanceof EE_Transaction ) {
1819
+		if ($this->checkout->transaction instanceof EE_Transaction) {
1820 1820
 			$gateway = $this->checkout->payment_method->type_obj()->get_gateway();
1821
-			if ( ! $gateway instanceof EE_Offsite_Gateway ) {
1821
+			if ( ! $gateway instanceof EE_Offsite_Gateway) {
1822 1822
 				$this->checkout->continue_reg = false;
1823 1823
 				return false;
1824 1824
 			}
1825
-			$payment = $this->_process_off_site_payment( $gateway );
1826
-			$payment = $this->_process_cancelled_payments( $payment );
1827
-			$payment = $this->_validate_payment( $payment );
1825
+			$payment = $this->_process_off_site_payment($gateway);
1826
+			$payment = $this->_process_cancelled_payments($payment);
1827
+			$payment = $this->_validate_payment($payment);
1828 1828
 			// if payment was not declined by the payment gateway or cancelled by the registrant
1829
-			if ( $this->_process_payment_status( $payment, EE_PMT_Base::offsite ) ) {
1829
+			if ($this->_process_payment_status($payment, EE_PMT_Base::offsite)) {
1830 1830
 				//$this->_setup_redirect_for_next_step();
1831 1831
 				// store that for later
1832 1832
 				$this->checkout->payment = $payment;
1833 1833
 				// mark this reg step as completed, as long as gateway doesn't use a separate IPN request,
1834 1834
 				// because we will complete this step during the IPN processing then
1835
-				if ( $gateway instanceof EE_Offsite_Gateway && ! $gateway->uses_separate_IPN_request() ) {
1835
+				if ($gateway instanceof EE_Offsite_Gateway && ! $gateway->uses_separate_IPN_request()) {
1836 1836
 					$this->set_completed();
1837 1837
 				}
1838 1838
 				return true;
@@ -1855,19 +1855,19 @@  discard block
 block discarded – undo
1855 1855
 	 * @return bool
1856 1856
 	 */
1857 1857
 	private function _validate_offsite_return() {
1858
-		$TXN_ID = (int)EE_Registry::instance()->REQ->get( 'spco_txn', 0 );
1859
-		if ( $TXN_ID != $this->checkout->transaction->ID() ) {
1858
+		$TXN_ID = (int) EE_Registry::instance()->REQ->get('spco_txn', 0);
1859
+		if ($TXN_ID != $this->checkout->transaction->ID()) {
1860 1860
 			// Houston... we might have a problem
1861 1861
 			$invalid_TXN = false;
1862 1862
 			// first gather some info
1863
-			$valid_TXN = EEM_Transaction::instance()->get_one_by_ID( $TXN_ID );
1863
+			$valid_TXN = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
1864 1864
 			$primary_registrant = $valid_TXN instanceof EE_Transaction ? $valid_TXN->primary_registration() : null;
1865 1865
 			// let's start by retrieving the cart for this TXN
1866
-			$cart = EE_Cart::get_cart_from_txn( $this->checkout->transaction );
1867
-			if ( $cart instanceof EE_Cart ) {
1866
+			$cart = EE_Cart::get_cart_from_txn($this->checkout->transaction);
1867
+			if ($cart instanceof EE_Cart) {
1868 1868
 				// verify that the current cart has tickets
1869 1869
 				$tickets = $cart->get_tickets();
1870
-				if ( empty( $tickets ) ) {
1870
+				if (empty($tickets)) {
1871 1871
 					$invalid_TXN = true;
1872 1872
 				}
1873 1873
 			} else {
@@ -1875,39 +1875,39 @@  discard block
 block discarded – undo
1875 1875
 			}
1876 1876
 			$valid_TXN_SID = $primary_registrant instanceof EE_Registration ? $primary_registrant->session_ID() : null;
1877 1877
 			// validate current Session ID and compare against valid TXN session ID
1878
-			if ( EE_Session::instance()->id() === null ) {
1878
+			if (EE_Session::instance()->id() === null) {
1879 1879
 				$invalid_TXN = true;
1880
-			} else if ( EE_Session::instance()->id() === $valid_TXN_SID ) {
1880
+			} else if (EE_Session::instance()->id() === $valid_TXN_SID) {
1881 1881
 				// WARNING !!!
1882 1882
 				// this could be PayPal sending back duplicate requests (ya they do that)
1883 1883
 				// or it **could** mean someone is simply registering AGAIN after having just done so
1884 1884
 				// so now we need to determine if this current TXN looks valid or not
1885 1885
 				/** @type EE_Transaction_Processor $transaction_processor */
1886
-				$transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' );
1886
+				$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
1887 1887
 				// has this step even been started ?
1888
-				if ( $transaction_processor->reg_step_completed( $this->checkout->transaction, $this->slug() === false )
1888
+				if ($transaction_processor->reg_step_completed($this->checkout->transaction, $this->slug() === false)
1889 1889
 				) {
1890 1890
 					// really? you're half way through this reg step, but you never started it ?
1891 1891
 					$invalid_TXN = true;
1892 1892
 				}
1893 1893
 			}
1894
-			if ( $invalid_TXN ) {
1894
+			if ($invalid_TXN) {
1895 1895
 				// is the valid TXN completed ?
1896
-				if ( $valid_TXN instanceof EE_Transaction ) {
1896
+				if ($valid_TXN instanceof EE_Transaction) {
1897 1897
 					/** @type EE_Transaction_Processor $transaction_processor */
1898
-					$transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' );
1898
+					$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
1899 1899
 					// has this step even been started ?
1900
-					$reg_step_completed = $transaction_processor->reg_step_completed( $valid_TXN, $this->slug() );
1901
-					if ( $reg_step_completed !== false && $reg_step_completed !== true ) {
1900
+					$reg_step_completed = $transaction_processor->reg_step_completed($valid_TXN, $this->slug());
1901
+					if ($reg_step_completed !== false && $reg_step_completed !== true) {
1902 1902
 						// so it **looks** like this is a double request from PayPal
1903 1903
 						// so let's try to pick up where we left off
1904 1904
 						$this->checkout->transaction = $valid_TXN;
1905
-						$this->checkout->refresh_all_entities( true );
1905
+						$this->checkout->refresh_all_entities(true);
1906 1906
 						return;
1907 1907
 					}
1908 1908
 				}
1909 1909
 				// you appear to be lost?
1910
-				$this->_redirect_wayward_request( $primary_registrant );
1910
+				$this->_redirect_wayward_request($primary_registrant);
1911 1911
 			}
1912 1912
 		}
1913 1913
 	}
@@ -1921,16 +1921,16 @@  discard block
 block discarded – undo
1921 1921
 	 * @param \EE_Registration $primary_registrant
1922 1922
 	 * @return bool
1923 1923
 	 */
1924
-	private function _redirect_wayward_request( EE_Registration $primary_registrant ) {
1925
-		if ( ! $primary_registrant instanceof EE_Registration ) {
1924
+	private function _redirect_wayward_request(EE_Registration $primary_registrant) {
1925
+		if ( ! $primary_registrant instanceof EE_Registration) {
1926 1926
 			// try redirecting based on the current TXN
1927 1927
 			$primary_registrant = $this->checkout->transaction instanceof EE_Transaction ? $this->checkout->transaction->primary_registration() : null;
1928
-			if ( ! $primary_registrant instanceof EE_Registration ) {
1928
+			if ( ! $primary_registrant instanceof EE_Registration) {
1929 1929
 				EE_Error::add_error(
1930 1930
 					sprintf(
1931
-						__( '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' ),
1931
+						__('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'),
1932 1932
 						'<br/>',
1933
-						EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
1933
+						EE_Registry::instance()->CFG->organization->get_pretty('email')
1934 1934
 					),
1935 1935
 					__FILE__, __FUNCTION__, __LINE__
1936 1936
 				);
@@ -1958,16 +1958,16 @@  discard block
 block discarded – undo
1958 1958
 	 * @param \EE_Offsite_Gateway $gateway
1959 1959
 	 * @return \EE_Payment
1960 1960
 	 */
1961
-	private function _process_off_site_payment( EE_Offsite_Gateway $gateway ) {
1961
+	private function _process_off_site_payment(EE_Offsite_Gateway $gateway) {
1962 1962
 		try {
1963 1963
 			// if gateway uses_separate_IPN_request, then we don't have to process the IPN manually
1964
-			if ( $gateway instanceof EE_Offsite_Gateway && $gateway->uses_separate_IPN_request() ) {
1964
+			if ($gateway instanceof EE_Offsite_Gateway && $gateway->uses_separate_IPN_request()) {
1965 1965
 				$payment = $this->checkout->transaction->last_payment();
1966 1966
 				//$payment_source = 'last_payment';
1967 1967
 			} else {
1968 1968
 				// get payment details and process results
1969 1969
 				/** @type EE_Payment_Processor $payment_processor */
1970
-				$payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' );
1970
+				$payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
1971 1971
 				$payment = $payment_processor->process_ipn(
1972 1972
 					$_REQUEST,
1973 1973
 					$this->checkout->transaction,
@@ -1977,14 +1977,14 @@  discard block
 block discarded – undo
1977 1977
 				);
1978 1978
 				//$payment_source = 'process_ipn';
1979 1979
 			}
1980
-		} catch ( Exception $e ) {
1980
+		} catch (Exception $e) {
1981 1981
 			// let's just eat the exception and try to move on using any previously set payment info
1982 1982
 			$payment = $this->checkout->transaction->last_payment();
1983 1983
 			//$payment_source = 'last_payment after Exception';
1984 1984
 			// but if we STILL don't have a payment object
1985
-			if ( ! $payment instanceof EE_Payment ) {
1985
+			if ( ! $payment instanceof EE_Payment) {
1986 1986
 				// then we'll object ! ( not object like a thing... but object like what a lawyer says ! )
1987
-				$this->_handle_payment_processor_exception( $e );
1987
+				$this->_handle_payment_processor_exception($e);
1988 1988
 			}
1989 1989
 		}
1990 1990
 		// DEBUG LOG
@@ -2008,13 +2008,13 @@  discard block
 block discarded – undo
2008 2008
 	 * @param EE_Payment $payment
2009 2009
 	 * @return EE_Payment | FALSE
2010 2010
 	 */
2011
-	private function _process_cancelled_payments( $payment = NULL ) {
2011
+	private function _process_cancelled_payments($payment = NULL) {
2012 2012
 		if (
2013
-			isset( $_REQUEST[ 'ee_cancel_payment' ] )
2013
+			isset($_REQUEST['ee_cancel_payment'])
2014 2014
 			&& $payment instanceof EE_Payment
2015 2015
 			&& $payment->status() == EEM_Payment::status_id_failed
2016 2016
 		) {
2017
-			$payment->set_status( EEM_Payment::status_id_cancelled );
2017
+			$payment->set_status(EEM_Payment::status_id_cancelled);
2018 2018
 		}
2019 2019
 		return $payment;
2020 2020
 	}
@@ -2031,23 +2031,23 @@  discard block
 block discarded – undo
2031 2031
 	public function get_transaction_details_for_gateways() {
2032 2032
 		$txn_details = array();
2033 2033
 		// ya gotta make a choice man
2034
-		if ( empty( $this->checkout->selected_method_of_payment ) ) {
2034
+		if (empty($this->checkout->selected_method_of_payment)) {
2035 2035
 			$txn_details = array(
2036
-				'error' => __( 'Please select a method of payment before proceeding.', 'event_espresso' )
2036
+				'error' => __('Please select a method of payment before proceeding.', 'event_espresso')
2037 2037
 			);
2038 2038
 		}
2039 2039
 		// get EE_Payment_Method object
2040 2040
 		if (
2041
-			empty( $txn_details ) &&
2041
+			empty($txn_details) &&
2042 2042
 			! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()
2043 2043
 		) {
2044 2044
 			$txn_details = array(
2045 2045
 				'selected_method_of_payment' => $this->checkout->selected_method_of_payment,
2046
-				'error' => __( 'A valid Payment Method could not be determined.', 'event_espresso' )
2046
+				'error' => __('A valid Payment Method could not be determined.', 'event_espresso')
2047 2047
 			);
2048 2048
 		}
2049
-		if ( empty( $txn_details ) && $this->checkout->transaction instanceof EE_Transaction ) {
2050
-			$return_url = $this->_get_return_url( $this->checkout->payment_method );
2049
+		if (empty($txn_details) && $this->checkout->transaction instanceof EE_Transaction) {
2050
+			$return_url = $this->_get_return_url($this->checkout->payment_method);
2051 2051
 			$txn_details = array(
2052 2052
 				'TXN_ID'        			=> $this->checkout->transaction->ID(),
2053 2053
 				'TXN_timestamp' 	=> $this->checkout->transaction->datetime(),
@@ -2058,7 +2058,7 @@  discard block
 block discarded – undo
2058 2058
 				'PMD_ID'        			=> $this->checkout->transaction->payment_method_ID(),
2059 2059
 				'payment_amount' => $this->checkout->amount_owing,
2060 2060
 				'return_url' 				=> $return_url,
2061
-				'cancel_url' 				=> add_query_arg( array( 'ee_cancel_payment' => true ), $return_url ),
2061
+				'cancel_url' 				=> add_query_arg(array('ee_cancel_payment' => true), $return_url),
2062 2062
 				'notify_url' 				=> EE_Config::instance()->core->txn_page_url(
2063 2063
 					array(
2064 2064
 						'e_reg_url_link'    			=> $this->checkout->transaction->primary_registration()->reg_url_link(),
@@ -2067,7 +2067,7 @@  discard block
 block discarded – undo
2067 2067
 				)
2068 2068
 			);
2069 2069
 		}
2070
-		echo json_encode( $txn_details );
2070
+		echo json_encode($txn_details);
2071 2071
 		exit();
2072 2072
 	}
2073 2073
 
Please login to merge, or discard this patch.
libraries/line_item_display/EE_SPCO_Line_Item_Display_Strategy.strategy.php 1 patch
Spacing   +118 added lines, -118 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,38 +270,38 @@  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 );
276
+		$html = EEH_HTML::tr('', '', $row_class);
277 277
 		// name && desc
278 278
 		$name_and_desc = apply_filters(
279 279
 			'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name',
280
-			$line_item->OBJ_type() . ': ' . $line_item->name(),
280
+			$line_item->OBJ_type().': '.$line_item->name(),
281 281
 			$line_item
282 282
 		);
283 283
 		$name_and_desc .= apply_filters(
284 284
 			'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc',
285
-			( $options['show_desc'] ? '<span class="line-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' : '' ),
285
+			($options['show_desc'] ? '<span class="line-item-desc-spn smaller-text">: '.$line_item->desc().'</span>' : ''),
286 286
 			$line_item,
287 287
 			$options
288 288
 		);
289 289
 		$name_and_desc .= $line_item->is_taxable() ? ' * ' : '';
290 290
 		// name td
291
-		$html .= EEH_HTML::td( $name_and_desc, '',  'item_l' );
291
+		$html .= EEH_HTML::td($name_and_desc, '', 'item_l');
292 292
 		// price td
293
-		if ( $line_item->is_percent() ) {
294
-			$html .= EEH_HTML::td( $line_item->percent() . '%', '', 'item_c jst-rght' );
293
+		if ($line_item->is_percent()) {
294
+			$html .= EEH_HTML::td($line_item->percent().'%', '', 'item_c jst-rght');
295 295
 		} else {
296
-			$html .= EEH_HTML::td( $line_item->unit_price_no_code(), '', 'item_c jst-rght' );
296
+			$html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght');
297 297
 		}
298 298
 		// quantity td
299
-		$html .= EEH_HTML::td( $line_item->quantity(), '', 'item_l jst-rght' );
299
+		$html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght');
300 300
 		//$total = $line_item->total() * $line_item->quantity();
301 301
 		$total = $line_item->total();
302
-		$this->_events[ $options[ 'event_id' ] ] += $total;
302
+		$this->_events[$options['event_id']] += $total;
303 303
 		// total td
304
-		$html .= EEH_HTML::td( EEH_Template::format_currency( $total, false, false ), '',  'item_r jst-rght' );
304
+		$html .= EEH_HTML::td(EEH_Template::format_currency($total, false, false), '', 'item_r jst-rght');
305 305
 		// end of row
306 306
 		$html .= EEH_HTML::trx();
307 307
 		return $html;
@@ -316,22 +316,22 @@  discard block
 block discarded – undo
316 316
 	 * @param array        $options
317 317
 	 * @return mixed
318 318
 	 */
319
-	private function _sub_item_row( EE_Line_Item $line_item, $options = array() ) {
319
+	private function _sub_item_row(EE_Line_Item $line_item, $options = array()) {
320 320
 		// start of row
321
-		$html = EEH_HTML::tr( '', 'item sub-item-row' );
321
+		$html = EEH_HTML::tr('', 'item sub-item-row');
322 322
 		// name && desc
323 323
 		$name_and_desc = $line_item->name();
324
-		$name_and_desc .= $options['show_desc'] ? '<span class="line-sub-item-desc-spn smaller-text">: ' . $line_item->desc() . '</span>' : '';
324
+		$name_and_desc .= $options['show_desc'] ? '<span class="line-sub-item-desc-spn smaller-text">: '.$line_item->desc().'</span>' : '';
325 325
 		// name td
326
-		$html .= EEH_HTML::td( /*__FUNCTION__ .*/ $name_and_desc, '',  'item_l sub-item' );
326
+		$html .= EEH_HTML::td( /*__FUNCTION__ .*/ $name_and_desc, '', 'item_l sub-item' );
327 327
 		// discount/surcharge td
328
-		if ( $line_item->is_percent() ) {
329
-			$html .= EEH_HTML::td( $line_item->percent() . '%', '',  'item_c' );
328
+		if ($line_item->is_percent()) {
329
+			$html .= EEH_HTML::td($line_item->percent().'%', '', 'item_c');
330 330
 		} else {
331
-			$html .= EEH_HTML::td( $line_item->unit_price_no_code(), '',  'item_c jst-rght' );
331
+			$html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght');
332 332
 		}
333 333
 		// total td
334
-		$html .= EEH_HTML::td( EEH_Template::format_currency( $line_item->total(), false, false ), '',  'item_r jst-rght' );
334
+		$html .= EEH_HTML::td(EEH_Template::format_currency($line_item->total(), false, false), '', 'item_r jst-rght');
335 335
 		// end of row
336 336
 		$html .= EEH_HTML::trx();
337 337
 		return $html;
@@ -346,21 +346,21 @@  discard block
 block discarded – undo
346 346
 	 * @param array        $options
347 347
 	 * @return mixed
348 348
 	 */
349
-	private function _tax_row( EE_Line_Item $line_item, $options = array() ) {
349
+	private function _tax_row(EE_Line_Item $line_item, $options = array()) {
350 350
 		// start of row
351
-		$html = EEH_HTML::tr( '', 'item sub-item tax-total' );
351
+		$html = EEH_HTML::tr('', 'item sub-item tax-total');
352 352
 		// name && desc
353 353
 		$name_and_desc = $line_item->name();
354
-		$name_and_desc .= '<span class="smaller-text lt-grey-text" style="margin:0 0 0 2em;">' . __( ' * taxable items', 'event_espresso' ) . '</span>';
355
-		$name_and_desc .= $options[ 'show_desc' ] ? '<br/>' . $line_item->desc() : '';
354
+		$name_and_desc .= '<span class="smaller-text lt-grey-text" style="margin:0 0 0 2em;">'.__(' * taxable items', 'event_espresso').'</span>';
355
+		$name_and_desc .= $options['show_desc'] ? '<br/>'.$line_item->desc() : '';
356 356
 		// name td
357
-		$html .= EEH_HTML::td( /*__FUNCTION__ .*/ $name_and_desc, '',  'item_l sub-item' );
357
+		$html .= EEH_HTML::td( /*__FUNCTION__ .*/ $name_and_desc, '', 'item_l sub-item' );
358 358
 		// percent td
359
-		$html .= EEH_HTML::td( $line_item->percent() . '%', '',  ' jst-rght', '' );
359
+		$html .= EEH_HTML::td($line_item->percent().'%', '', ' jst-rght', '');
360 360
 		// empty td (price)
361
-		$html .= EEH_HTML::td( EEH_HTML::nbsp() );
361
+		$html .= EEH_HTML::td(EEH_HTML::nbsp());
362 362
 		// total td
363
-		$html .= EEH_HTML::td( EEH_Template::format_currency( $line_item->total(), false, false ), '',  'item_r jst-rght' );
363
+		$html .= EEH_HTML::td(EEH_Template::format_currency($line_item->total(), false, false), '', 'item_r jst-rght');
364 364
 		// end of row
365 365
 		$html .= EEH_HTML::trx();
366 366
 		return $html;
@@ -375,17 +375,17 @@  discard block
 block discarded – undo
375 375
 	 * @param string $text
376 376
 	 * @return mixed
377 377
 	 */
378
-	private function _total_tax_row( EE_Line_Item $line_item, $text = '' ) {
378
+	private function _total_tax_row(EE_Line_Item $line_item, $text = '') {
379 379
 		$html = '';
380
-		if ( $line_item->total() ) {
380
+		if ($line_item->total()) {
381 381
 			// start of row
382
-			$html = EEH_HTML::tr( '', '', 'total_tr odd' );
382
+			$html = EEH_HTML::tr('', '', 'total_tr odd');
383 383
 			// total td
384
-			$html .= EEH_HTML::td( $text, '', 'total_currency total jst-rght', '', ' colspan="2"' );
384
+			$html .= EEH_HTML::td($text, '', 'total_currency total jst-rght', '', ' colspan="2"');
385 385
 			// empty td (price)
386
-			$html .= EEH_HTML::td( EEH_HTML::nbsp() );
386
+			$html .= EEH_HTML::td(EEH_HTML::nbsp());
387 387
 			// total td
388
-			$html .= EEH_HTML::td( EEH_Template::format_currency( $line_item->total(), false, false ), '', 'total jst-rght' );
388
+			$html .= EEH_HTML::td(EEH_Template::format_currency($line_item->total(), false, false), '', 'total jst-rght');
389 389
 			// end of row
390 390
 			$html .= EEH_HTML::trx();
391 391
 		}
@@ -402,15 +402,15 @@  discard block
 block discarded – undo
402 402
 	 * @param array        $options
403 403
 	 * @return mixed
404 404
 	 */
405
-	private function _sub_total_row( EE_Line_Item $line_item, $text = '', $options = array() ) {
405
+	private function _sub_total_row(EE_Line_Item $line_item, $text = '', $options = array()) {
406 406
 		$html = '';
407
-		if ( $line_item->total() ) {
407
+		if ($line_item->total()) {
408 408
 			// start of row
409
-			$html = EEH_HTML::tr( '', '', 'total_tr odd' );
409
+			$html = EEH_HTML::tr('', '', 'total_tr odd');
410 410
 			// total td
411
-			$html .= EEH_HTML::td( $text, '', 'total_currency total jst-rght', '', ' colspan="3"' );
411
+			$html .= EEH_HTML::td($text, '', 'total_currency total jst-rght', '', ' colspan="3"');
412 412
 			// total td
413
-			$html .= EEH_HTML::td( EEH_Template::format_currency( $options[ 'sub_total' ], false, false ), '', 'total jst-rght' );
413
+			$html .= EEH_HTML::td(EEH_Template::format_currency($options['sub_total'], false, false), '', 'total jst-rght');
414 414
 			// end of row
415 415
 			$html .= EEH_HTML::trx();
416 416
 		}
@@ -427,13 +427,13 @@  discard block
 block discarded – undo
427 427
 	 * @param string       $text
428 428
 	 * @return mixed
429 429
 	 */
430
-	private function _total_row( EE_Line_Item $line_item, $text = '' ) {
430
+	private function _total_row(EE_Line_Item $line_item, $text = '') {
431 431
 		// start of row
432
-		$html = EEH_HTML::tr( '', '', 'spco-grand-total total_tr odd' );
432
+		$html = EEH_HTML::tr('', '', 'spco-grand-total total_tr odd');
433 433
 		// total td
434
-		$html .= EEH_HTML::td( $text, '',  'total_currency total jst-rght',  '',  ' colspan="3"' );
434
+		$html .= EEH_HTML::td($text, '', 'total_currency total jst-rght', '', ' colspan="3"');
435 435
 		// total td
436
-		$html .= EEH_HTML::td( EEH_Template::format_currency( $line_item->total(), false, false ), '',  'total jst-rght' );
436
+		$html .= EEH_HTML::td(EEH_Template::format_currency($line_item->total(), false, false), '', 'total jst-rght');
437 437
 		// end of row
438 438
 		$html .= EEH_HTML::trx();
439 439
 		return $html;
@@ -448,30 +448,30 @@  discard block
 block discarded – undo
448 448
 	 * @param array        $options
449 449
 	 * @return mixed
450 450
 	 */
451
-	private function _payments_and_amount_owing_rows( EE_Line_Item $line_item, $options = array() ) {
451
+	private function _payments_and_amount_owing_rows(EE_Line_Item $line_item, $options = array()) {
452 452
 		$html = '';
453 453
 		$owing = $line_item->total();
454
-		$transaction = EEM_Transaction::instance()->get_one_by_ID( $line_item->TXN_ID() );
455
-		if ( $transaction instanceof EE_Transaction ) {
454
+		$transaction = EEM_Transaction::instance()->get_one_by_ID($line_item->TXN_ID());
455
+		if ($transaction instanceof EE_Transaction) {
456 456
 			$registration_payments = array();
457
-			$registrations = ! empty( $options['registrations'] )
458
-				? $options[ 'registrations' ]
457
+			$registrations = ! empty($options['registrations'])
458
+				? $options['registrations']
459 459
 				: $transaction->registrations();
460
-			foreach ( $registrations as $registration ) {
461
-				if ( $registration instanceof EE_Registration && $registration->owes_monies_and_can_pay() ) {
460
+			foreach ($registrations as $registration) {
461
+				if ($registration instanceof EE_Registration && $registration->owes_monies_and_can_pay()) {
462 462
 					$registration_payments = $registration_payments + $registration->registration_payments();
463 463
 				}
464 464
 			}
465
-			if ( ! empty( $registration_payments )) {
466
-				foreach ( $registration_payments as $registration_payment ) {
467
-					if ( $registration_payment instanceof EE_Registration_Payment ) {
465
+			if ( ! empty($registration_payments)) {
466
+				foreach ($registration_payments as $registration_payment) {
467
+					if ($registration_payment instanceof EE_Registration_Payment) {
468 468
 						$owing = $owing - $registration_payment->amount();
469 469
 						$payment = $registration_payment->payment();
470
-						if ( $payment instanceof EE_Payment ) {
470
+						if ($payment instanceof EE_Payment) {
471 471
 							$payment_desc = sprintf(
472
-								__( 'Payment%1$s Received: %2$s', 'event_espresso' ),
472
+								__('Payment%1$s Received: %2$s', 'event_espresso'),
473 473
 								$payment->txn_id_chq_nmbr() != ''
474
-									? ' <span class="small-text">(#' . $payment->txn_id_chq_nmbr() . ')</span> '
474
+									? ' <span class="small-text">(#'.$payment->txn_id_chq_nmbr().')</span> '
475 475
 									: '',
476 476
 								$payment->timestamp()
477 477
 							);
@@ -479,12 +479,12 @@  discard block
 block discarded – undo
479 479
 							$payment_desc = '';
480 480
 						}
481 481
 						// start of row
482
-						$html .= EEH_HTML::tr( '', '', 'total_tr odd' );
482
+						$html .= EEH_HTML::tr('', '', 'total_tr odd');
483 483
 						// payment desc
484
-						$html .= EEH_HTML::td( $payment_desc, '', '', '', ' colspan="3"' );
484
+						$html .= EEH_HTML::td($payment_desc, '', '', '', ' colspan="3"');
485 485
 						// total td
486 486
 						$html .= EEH_HTML::td(
487
-							EEH_Template::format_currency( $registration_payment->amount(), false, false ),
487
+							EEH_Template::format_currency($registration_payment->amount(), false, false),
488 488
 							'',
489 489
 							'total jst-rght'
490 490
 						);
@@ -492,17 +492,17 @@  discard block
 block discarded – undo
492 492
 						$html .= EEH_HTML::trx();
493 493
 					}
494 494
 				}
495
-				if ( $line_item->total() ) {
495
+				if ($line_item->total()) {
496 496
 					// start of row
497
-					$html .= EEH_HTML::tr( '', '', 'total_tr odd' );
497
+					$html .= EEH_HTML::tr('', '', 'total_tr odd');
498 498
 					// total td
499 499
 					$html .= EEH_HTML::td(
500 500
 						__('Amount Owing', 'event_espresso'),
501
-						'',  'total_currency total jst-rght',  '',  ' colspan="3"'
501
+						'', 'total_currency total jst-rght', '', ' colspan="3"'
502 502
 					);
503 503
 					// total td
504 504
 					$html .= EEH_HTML::td(
505
-						EEH_Template::format_currency( $owing, false, false ), '',  'total jst-rght'
505
+						EEH_Template::format_currency($owing, false, false), '', 'total jst-rght'
506 506
 					);
507 507
 					// end of row
508 508
 					$html .= EEH_HTML::trx();
Please login to merge, or discard this patch.
admin_pages/payments/Payments_Admin_Page.core.php 1 patch
Spacing   +167 added lines, -167 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,18 +179,18 @@  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 ){
190
+			foreach ($payment_method_type->help_tabs_config() as $help_tab_name => $config) {
191 191
 				$all_pmt_help_tabs_config[$help_tab_name] = array(
192 192
 					'title'=>$config['title'],
193
-					'content'=>EEH_Template::display_template( $payment_method_type->file_folder().'help_tabs'.DS.$config['filename'].'.help_tab.php', array('admin_page_obj'=>$this), true)
193
+					'content'=>EEH_Template::display_template($payment_method_type->file_folder().'help_tabs'.DS.$config['filename'].'.help_tab.php', array('admin_page_obj'=>$this), true)
194 194
 				);
195 195
 			}
196 196
 		}
@@ -211,9 +211,9 @@  discard block
 block discarded – undo
211 211
 
212 212
 
213 213
 	public function load_scripts_styles() {
214
-		wp_enqueue_script( 'ee_admin_js' );
215
-		wp_enqueue_script( 'ee-text-links' );
216
-		wp_enqueue_script( 'espresso_payments', EE_PAYMENTS_ASSETS_URL . 'espresso_payments_admin.js', array( 'espresso-ui-theme', 'ee-datepicker' ), EVENT_ESPRESSO_VERSION, TRUE );
214
+		wp_enqueue_script('ee_admin_js');
215
+		wp_enqueue_script('ee-text-links');
216
+		wp_enqueue_script('espresso_payments', EE_PAYMENTS_ASSETS_URL.'espresso_payments_admin.js', array('espresso-ui-theme', 'ee-datepicker'), EVENT_ESPRESSO_VERSION, TRUE);
217 217
 	}
218 218
 
219 219
 
@@ -222,9 +222,9 @@  discard block
 block discarded – undo
222 222
 
223 223
 	public function load_scripts_styles_default() {
224 224
 		//styles
225
-		wp_register_style( 'espresso_payments', EE_PAYMENTS_ASSETS_URL . 'ee-payments.css', array(), EVENT_ESPRESSO_VERSION );
226
-		wp_enqueue_style( 'espresso_payments' );
227
-		wp_enqueue_style( 'ee-text-links' );
225
+		wp_register_style('espresso_payments', EE_PAYMENTS_ASSETS_URL.'ee-payments.css', array(), EVENT_ESPRESSO_VERSION);
226
+		wp_enqueue_style('espresso_payments');
227
+		wp_enqueue_style('ee-text-links');
228 228
 		//scripts
229 229
 	}
230 230
 
@@ -238,46 +238,46 @@  discard block
 block discarded – undo
238 238
 		 * to the loading process.  However, people MUST setup the details for the payment method so its safe to do a
239 239
 		 * recheck here.
240 240
 		 */
241
-		EE_Registry::instance()->load_lib( 'Payment_Method_Manager' );
241
+		EE_Registry::instance()->load_lib('Payment_Method_Manager');
242 242
 		EEM_Payment_Method::instance()->verify_button_urls();
243
-		EE_Registry::instance()->load_helper( 'Tabbed_Content' );
244
-		EE_Registry::instance()->load_helper( 'HTML' );
243
+		EE_Registry::instance()->load_helper('Tabbed_Content');
244
+		EE_Registry::instance()->load_helper('HTML');
245 245
 		//setup tabs, one for each payment method type
246 246
 		$tabs = array();
247 247
 		$payment_methods = array();
248
-		foreach( EE_Payment_Method_Manager::instance()->payment_method_types() as $pmt_obj ) {
248
+		foreach (EE_Payment_Method_Manager::instance()->payment_method_types() as $pmt_obj) {
249 249
 			// we don't want to show admin-only PMTs for now
250
-			if ( $pmt_obj instanceof EE_PMT_Admin_Only ) {
250
+			if ($pmt_obj instanceof EE_PMT_Admin_Only) {
251 251
 				continue;
252 252
 			}
253 253
 			//check access
254
-			if ( ! EE_Registry::instance()->CAP->current_user_can( $pmt_obj->cap_name(), 'specific_payment_method_type_access' ) ) {
254
+			if ( ! EE_Registry::instance()->CAP->current_user_can($pmt_obj->cap_name(), 'specific_payment_method_type_access')) {
255 255
 				continue;
256 256
 			}
257 257
 			//check for any active pms of that type
258
-			$payment_method = EEM_Payment_Method::instance()->get_one_of_type( $pmt_obj->system_name() );
259
-			if ( ! $payment_method instanceof EE_Payment_Method ) {
258
+			$payment_method = EEM_Payment_Method::instance()->get_one_of_type($pmt_obj->system_name());
259
+			if ( ! $payment_method instanceof EE_Payment_Method) {
260 260
 				$payment_method = EE_Payment_Method::new_instance(
261 261
 					array(
262
-						'PMD_slug'					=>sanitize_key( $pmt_obj->system_name() ),
262
+						'PMD_slug'					=>sanitize_key($pmt_obj->system_name()),
263 263
 						'PMD_type'					=>$pmt_obj->system_name(),
264 264
 						'PMD_name'				=>$pmt_obj->pretty_name(),
265 265
 						'PMD_admin_name'	=>$pmt_obj->pretty_name()
266 266
 					)
267 267
 				);
268 268
 			}
269
-			$payment_methods[ $payment_method->slug() ] = $payment_method;
269
+			$payment_methods[$payment_method->slug()] = $payment_method;
270 270
 		}
271
-		$payment_methods = apply_filters( 'FHEE__Payments_Admin_Page___payment_methods_list__payment_methods', $payment_methods );
272
-		foreach( $payment_methods as $payment_method ) {
273
-			if ( $payment_method instanceof EE_Payment_Method ) {
271
+		$payment_methods = apply_filters('FHEE__Payments_Admin_Page___payment_methods_list__payment_methods', $payment_methods);
272
+		foreach ($payment_methods as $payment_method) {
273
+			if ($payment_method instanceof EE_Payment_Method) {
274 274
 				add_meta_box(
275 275
 					//html id
276
-					'espresso_' . $payment_method->slug() . '_payment_settings',
276
+					'espresso_'.$payment_method->slug().'_payment_settings',
277 277
 					//title
278
-					sprintf( __( '%s Settings', 'event_espresso' ), $payment_method->admin_name() ),
278
+					sprintf(__('%s Settings', 'event_espresso'), $payment_method->admin_name()),
279 279
 					//callback
280
-					array( $this, 'payment_method_settings_meta_box' ),
280
+					array($this, 'payment_method_settings_meta_box'),
281 281
 					//post type
282 282
 					null,
283 283
 					//context
@@ -285,19 +285,19 @@  discard block
 block discarded – undo
285 285
 					//priority
286 286
 					'default',
287 287
 					//callback args
288
-					array( 'payment_method' => $payment_method )
288
+					array('payment_method' => $payment_method)
289 289
 				);
290 290
 				//setup for tabbed content
291
-				$tabs[ $payment_method->slug() ] = array(
291
+				$tabs[$payment_method->slug()] = array(
292 292
 					'label' => $payment_method->admin_name(),
293 293
 					'class' => $payment_method->active() ? 'gateway-active' : '',
294
-					'href'  => 'espresso_' . $payment_method->slug() . '_payment_settings',
295
-					'title' => __( 'Modify this Payment Method', 'event_espresso' ),
294
+					'href'  => 'espresso_'.$payment_method->slug().'_payment_settings',
295
+					'title' => __('Modify this Payment Method', 'event_espresso'),
296 296
 					'slug'  => $payment_method->slug()
297 297
 				);
298 298
 			}
299 299
 		}
300
-		$this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links( $tabs, 'payment_method_links', '|', $this->_get_active_payment_method_slug() );
300
+		$this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links($tabs, 'payment_method_links', '|', $this->_get_active_payment_method_slug());
301 301
 		$this->display_admin_page_with_sidebar();
302 302
 
303 303
 	}
@@ -308,20 +308,20 @@  discard block
 block discarded – undo
308 308
 	 *   _get_active_payment_method_slug
309 309
 	 * 	@return string
310 310
 	 */
311
-	protected function _get_active_payment_method_slug(){
311
+	protected function _get_active_payment_method_slug() {
312 312
 		$payment_method_slug = FALSE;
313 313
 		//decide which payment method tab to open first, as dictated by the request's 'payment_method'
314
-		if ( isset( $this->_req_data['payment_method'] )) {
314
+		if (isset($this->_req_data['payment_method'])) {
315 315
 			// if they provided the current payment method, use it
316
-			$payment_method_slug = sanitize_key( $this->_req_data['payment_method'] );
316
+			$payment_method_slug = sanitize_key($this->_req_data['payment_method']);
317 317
 		}
318
-		$payment_method = EEM_Payment_Method::instance()->get_one( array( array( 'PMD_slug' => $payment_method_slug )));
318
+		$payment_method = EEM_Payment_Method::instance()->get_one(array(array('PMD_slug' => $payment_method_slug)));
319 319
 		// if that didn't work or wasn't provided, find another way to select the current pm
320
-		if ( ! $this->_verify_payment_method( $payment_method )) {
320
+		if ( ! $this->_verify_payment_method($payment_method)) {
321 321
 			// like, looking for an active one
322
-			$payment_method = EEM_Payment_Method::instance()->get_one_active( 'CART' );
322
+			$payment_method = EEM_Payment_Method::instance()->get_one_active('CART');
323 323
 			// test that one as well
324
-			if ( $this->_verify_payment_method( $payment_method )) {
324
+			if ($this->_verify_payment_method($payment_method)) {
325 325
 				$payment_method_slug = $payment_method->slug();
326 326
 			} else {
327 327
 				$payment_method_slug = 'paypal_standard';
@@ -339,11 +339,11 @@  discard block
 block discarded – undo
339 339
 	 * @param \EE_Payment_Method $payment_method
340 340
 	 * @return boolean
341 341
 	 */
342
-	protected function _verify_payment_method( $payment_method ){
342
+	protected function _verify_payment_method($payment_method) {
343 343
 		if (
344 344
 			$payment_method instanceof EE_Payment_Method &&
345 345
 			$payment_method->type_obj() instanceof EE_PMT_Base &&
346
-			EE_Registry::instance()->CAP->current_user_can( $payment_method->type_obj()->cap_name(), 'specific_payment_method_type_access' )
346
+			EE_Registry::instance()->CAP->current_user_can($payment_method->type_obj()->cap_name(), 'specific_payment_method_type_access')
347 347
 		) {
348 348
 			return TRUE;
349 349
 		}
@@ -360,21 +360,21 @@  discard block
 block discarded – undo
360 360
 	 * @return string
361 361
 	 * @throws EE_Error
362 362
 	 */
363
-	public function payment_method_settings_meta_box( $post_obj_which_is_null, $metabox ){
364
-		$payment_method = isset( $metabox['args'], $metabox['args']['payment_method'] ) ? $metabox['args']['payment_method'] : NULL;
365
-		if ( ! $payment_method instanceof EE_Payment_Method ){
366
-			throw new EE_Error( sprintf( __( 'Payment method metabox setup incorrectly. No Payment method object was supplied', 'event_espresso' )));
363
+	public function payment_method_settings_meta_box($post_obj_which_is_null, $metabox) {
364
+		$payment_method = isset($metabox['args'], $metabox['args']['payment_method']) ? $metabox['args']['payment_method'] : NULL;
365
+		if ( ! $payment_method instanceof EE_Payment_Method) {
366
+			throw new EE_Error(sprintf(__('Payment method metabox setup incorrectly. No Payment method object was supplied', 'event_espresso')));
367 367
 		}
368 368
 		$payment_method_scopes = $payment_method->active();
369 369
 		// if the payment method really exists show its form, otherwise the activation template
370
-		if ( $payment_method->ID() && ! empty( $payment_method_scopes )) {
371
-				$form = $this->_generate_payment_method_settings_form( $payment_method );
372
-				if ( $form->form_data_present_in( $this->_req_data )) {
373
-					$form->receive_form_submission( $this->_req_data );
370
+		if ($payment_method->ID() && ! empty($payment_method_scopes)) {
371
+				$form = $this->_generate_payment_method_settings_form($payment_method);
372
+				if ($form->form_data_present_in($this->_req_data)) {
373
+					$form->receive_form_submission($this->_req_data);
374 374
 				}
375
-				echo $form->form_open() . $form->get_html_and_js() . $form->form_close();
375
+				echo $form->form_open().$form->get_html_and_js().$form->form_close();
376 376
 		} else {
377
-			echo $this->_activate_payment_method_button( $payment_method )->get_html_and_js();
377
+			echo $this->_activate_payment_method_button($payment_method)->get_html_and_js();
378 378
 		}
379 379
 	}
380 380
 
@@ -387,14 +387,14 @@  discard block
 block discarded – undo
387 387
 	 * @param \EE_Payment_Method $payment_method
388 388
 	 * @return \EE_Form_Section_Proper
389 389
 	 */
390
-	protected function _generate_payment_method_settings_form( EE_Payment_Method $payment_method ) {
391
-		if ( ! $payment_method instanceof EE_Payment_Method ){
390
+	protected function _generate_payment_method_settings_form(EE_Payment_Method $payment_method) {
391
+		if ( ! $payment_method instanceof EE_Payment_Method) {
392 392
 			return new EE_Form_Section_Proper();
393 393
 		}
394 394
 		return new EE_Form_Section_Proper(
395 395
 			array(
396
-				'name' 	=> $payment_method->slug() . '_settings_form',
397
-				'html_id' 	=> $payment_method->slug() . '_settings_form',
396
+				'name' 	=> $payment_method->slug().'_settings_form',
397
+				'html_id' 	=> $payment_method->slug().'_settings_form',
398 398
 				'action' 	=> EE_Admin_Page::add_query_args_and_nonce(
399 399
 					array(
400 400
 						'action' 						=> 'update_payment_method',
@@ -406,12 +406,12 @@  discard block
 block discarded – undo
406 406
 				'subsections' 			=> apply_filters(
407 407
 					'FHEE__Payments_Admin_Page___generate_payment_method_settings_form__form_subsections',
408 408
 					array(
409
-						'pci_dss_compliance_' . $payment_method->slug() 				=> $this->_pci_dss_compliance( $payment_method ),
410
-						'currency_support_' . $payment_method->slug()					=> $this->_currency_support( $payment_method ),
411
-						'payment_method_settings_' . $payment_method->slug() 	=> $this->_payment_method_settings( $payment_method ),
412
-						'update_' . $payment_method->slug()										=> $this->_update_payment_method_button( $payment_method ),
413
-						'deactivate_' . $payment_method->slug()								=> $this->_deactivate_payment_method_button( $payment_method ),
414
-						'fine_print_' . $payment_method->slug()									=> $this->_fine_print()
409
+						'pci_dss_compliance_'.$payment_method->slug() 				=> $this->_pci_dss_compliance($payment_method),
410
+						'currency_support_'.$payment_method->slug()					=> $this->_currency_support($payment_method),
411
+						'payment_method_settings_'.$payment_method->slug() 	=> $this->_payment_method_settings($payment_method),
412
+						'update_'.$payment_method->slug()										=> $this->_update_payment_method_button($payment_method),
413
+						'deactivate_'.$payment_method->slug()								=> $this->_deactivate_payment_method_button($payment_method),
414
+						'fine_print_'.$payment_method->slug()									=> $this->_fine_print()
415 415
 					),
416 416
 					$payment_method
417 417
 				)
@@ -428,19 +428,19 @@  discard block
 block discarded – undo
428 428
 	 * @param \EE_Payment_Method $payment_method
429 429
 	 * @return \EE_Form_Section_Proper
430 430
 	 */
431
-	protected function _pci_dss_compliance( EE_Payment_Method $payment_method ) {
432
-		if ( $payment_method->type_obj()->requires_https() ) {
431
+	protected function _pci_dss_compliance(EE_Payment_Method $payment_method) {
432
+		if ($payment_method->type_obj()->requires_https()) {
433 433
 			return new EE_Form_Section_HTML(
434 434
 				EEH_HTML::tr(
435 435
 					EEH_HTML::th(
436 436
 						EEH_HTML::label(
437
-							EEH_HTML::strong( __( 'IMPORTANT', 'event_espresso' ), '', 'important-notice' )
437
+							EEH_HTML::strong(__('IMPORTANT', 'event_espresso'), '', 'important-notice')
438 438
 						)
439
-					) .
439
+					).
440 440
 					EEH_HTML::td(
441
-						EEH_HTML::strong( __( 'You are responsible for your own website security and Payment Card Industry Data Security Standards (PCI DSS) compliance.', 'event_espresso' )) .
442
-						EEH_HTML::br() .
443
-						__( 'Learn more about ', 'event_espresso' ) . EEH_HTML::link( 'https://www.pcisecuritystandards.org/merchants/index.php', __( 'PCI DSS compliance', 'event_espresso' ))
441
+						EEH_HTML::strong(__('You are responsible for your own website security and Payment Card Industry Data Security Standards (PCI DSS) compliance.', 'event_espresso')).
442
+						EEH_HTML::br().
443
+						__('Learn more about ', 'event_espresso').EEH_HTML::link('https://www.pcisecuritystandards.org/merchants/index.php', __('PCI DSS compliance', 'event_espresso'))
444 444
 					)
445 445
 				)
446 446
 			);
@@ -458,19 +458,19 @@  discard block
 block discarded – undo
458 458
 	 * @param \EE_Payment_Method $payment_method
459 459
 	 * @return \EE_Form_Section_Proper
460 460
 	 */
461
-	protected function _currency_support( EE_Payment_Method $payment_method ) {
462
-		if ( ! $payment_method->usable_for_currency( EE_Config::instance()->currency->code )) {
461
+	protected function _currency_support(EE_Payment_Method $payment_method) {
462
+		if ( ! $payment_method->usable_for_currency(EE_Config::instance()->currency->code)) {
463 463
 			return new EE_Form_Section_HTML(
464 464
 				EEH_HTML::tr(
465 465
 					EEH_HTML::th(
466 466
 						EEH_HTML::label(
467
-							EEH_HTML::strong( __( 'IMPORTANT', 'event_espresso' ), '', 'important-notice' )
467
+							EEH_HTML::strong(__('IMPORTANT', 'event_espresso'), '', 'important-notice')
468 468
 						)
469
-					) .
469
+					).
470 470
 					EEH_HTML::td(
471 471
 						EEH_HTML::strong(
472 472
 							sprintf(
473
-								__( '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'),
473
+								__('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'),
474 474
 								EE_Config::instance()->currency->code
475 475
 							)
476 476
 						)
@@ -490,9 +490,9 @@  discard block
 block discarded – undo
490 490
 	 * @param \EE_Payment_Method $payment_method
491 491
 	 * @return \EE_Form_Section_HTML
492 492
 	 */
493
-	protected function _payment_method_settings( EE_Payment_Method $payment_method ) {
493
+	protected function _payment_method_settings(EE_Payment_Method $payment_method) {
494 494
 		//modify the form so we only have/show fields that will be implemented for this version
495
-		return $this->_simplify_form( $payment_method->type_obj()->settings_form(), $payment_method->name() );
495
+		return $this->_simplify_form($payment_method->type_obj()->settings_form(), $payment_method->name());
496 496
 	}
497 497
 
498 498
 
@@ -505,8 +505,8 @@  discard block
 block discarded – undo
505 505
 	 * @return \EE_Payment_Method_Form
506 506
 	 * @throws \EE_Error
507 507
 	 */
508
-	protected function _simplify_form( $form_section, $payment_method_name = '' ){
509
-		if ( $form_section instanceof EE_Payment_Method_Form ) {
508
+	protected function _simplify_form($form_section, $payment_method_name = '') {
509
+		if ($form_section instanceof EE_Payment_Method_Form) {
510 510
 			$form_section->exclude(
511 511
 				array(
512 512
 					'PMD_type', //dont want them changing the type
@@ -517,7 +517,7 @@  discard block
 block discarded – undo
517 517
 			);
518 518
 			return $form_section;
519 519
 		} else {
520
-			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 ));
520
+			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));
521 521
 		}
522 522
 	}
523 523
 
@@ -530,18 +530,18 @@  discard block
 block discarded – undo
530 530
 	 * @param \EE_Payment_Method $payment_method
531 531
 	 * @return \EE_Form_Section_HTML
532 532
 	 */
533
-	protected function _update_payment_method_button( EE_Payment_Method $payment_method ) {
533
+	protected function _update_payment_method_button(EE_Payment_Method $payment_method) {
534 534
 		$update_button = new EE_Submit_Input(
535 535
 			array(
536
-				'html_id' 		=> 'save_' . $payment_method->slug() . '_settings',
537
-				'default' 		=> sprintf( __( 'Update %s Payment Settings', 'event_espresso' ), $payment_method->admin_name() ),
536
+				'html_id' 		=> 'save_'.$payment_method->slug().'_settings',
537
+				'default' 		=> sprintf(__('Update %s Payment Settings', 'event_espresso'), $payment_method->admin_name()),
538 538
 				'html_label' => EEH_HTML::nbsp()
539 539
 			)
540 540
 		);
541 541
 		return new EE_Form_Section_HTML(
542
-			EEH_HTML::no_row( EEH_HTML::br(2) ) .
542
+			EEH_HTML::no_row(EEH_HTML::br(2)).
543 543
 			EEH_HTML::tr(
544
-				EEH_HTML::th( __( 'Update Settings', 'event_espresso') ) .
544
+				EEH_HTML::th(__('Update Settings', 'event_espresso')).
545 545
 				EEH_HTML::td(
546 546
 					$update_button->get_html_for_input()
547 547
 				)
@@ -558,11 +558,11 @@  discard block
 block discarded – undo
558 558
 	 * @param \EE_Payment_Method $payment_method
559 559
 	 * @return \EE_Form_Section_Proper
560 560
 	 */
561
-	protected function _deactivate_payment_method_button( EE_Payment_Method $payment_method ) {
562
-		$link_text_and_title = sprintf( __( 'Deactivate %1$s Payments?', 'event_espresso'), $payment_method->admin_name() );
561
+	protected function _deactivate_payment_method_button(EE_Payment_Method $payment_method) {
562
+		$link_text_and_title = sprintf(__('Deactivate %1$s Payments?', 'event_espresso'), $payment_method->admin_name());
563 563
 		return new EE_Form_Section_HTML(
564 564
 			EEH_HTML::tr(
565
-				EEH_HTML::th( __( 'Deactivate Payment Method', 'event_espresso') ) .
565
+				EEH_HTML::th(__('Deactivate Payment Method', 'event_espresso')).
566 566
 				EEH_HTML::td(
567 567
 					EEH_HTML::link(
568 568
 						EE_Admin_Page::add_query_args_and_nonce(
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
 						),
575 575
 						$link_text_and_title,
576 576
 						$link_text_and_title,
577
-						'deactivate_' . $payment_method->slug(),
577
+						'deactivate_'.$payment_method->slug(),
578 578
 						'espresso-button button-secondary'
579 579
 					)
580 580
 				)
@@ -590,12 +590,12 @@  discard block
 block discarded – undo
590 590
 	 * @param \EE_Payment_Method $payment_method
591 591
 	 * @return \EE_Form_Section_Proper
592 592
 	 */
593
-	protected function _activate_payment_method_button( EE_Payment_Method $payment_method ) {
594
-		$link_text_and_title = sprintf( __( 'Activate %1$s Payment Method?', 'event_espresso'), $payment_method->admin_name() );
593
+	protected function _activate_payment_method_button(EE_Payment_Method $payment_method) {
594
+		$link_text_and_title = sprintf(__('Activate %1$s Payment Method?', 'event_espresso'), $payment_method->admin_name());
595 595
 		return new EE_Form_Section_Proper(
596 596
 			array(
597
-				'name' 	=> 'activate_' . $payment_method->slug() . '_settings_form',
598
-				'html_id' 	=> 'activate_' . $payment_method->slug() . '_settings_form',
597
+				'name' 	=> 'activate_'.$payment_method->slug().'_settings_form',
598
+				'html_id' 	=> 'activate_'.$payment_method->slug().'_settings_form',
599 599
 				'action' 	=> '#',
600 600
 				'layout_strategy'		=> new EE_Admin_Two_Column_Layout(),
601 601
 				'subsections' 			=> apply_filters(
@@ -604,8 +604,8 @@  discard block
 block discarded – undo
604 604
 						new EE_Form_Section_HTML(
605 605
 							EEH_HTML::tr(
606 606
 								EEH_HTML::th(
607
-									EEH_HTML::label( __( 'Click to Activate ', 'event_espresso' ))
608
-								) .
607
+									EEH_HTML::label(__('Click to Activate ', 'event_espresso'))
608
+								).
609 609
 								EEH_HTML::td(
610 610
 									EEH_HTML::link(
611 611
 										EE_Admin_Page::add_query_args_and_nonce(
@@ -617,7 +617,7 @@  discard block
 block discarded – undo
617 617
 										),
618 618
 										$link_text_and_title,
619 619
 										$link_text_and_title,
620
-										'activate_' . $payment_method->slug(),
620
+										'activate_'.$payment_method->slug(),
621 621
 										'espresso-button-green button-primary'
622 622
 									)
623 623
 								)
@@ -638,9 +638,9 @@  discard block
 block discarded – undo
638 638
 	protected function _fine_print() {
639 639
 		return new EE_Form_Section_HTML(
640 640
 			EEH_HTML::tr(
641
-				EEH_HTML::th() .
641
+				EEH_HTML::th().
642 642
 				EEH_HTML::td(
643
-					EEH_HTML::p( __( 'All fields marked with a * are required fields', 'event_espresso' ), '', 'grey-text' )
643
+					EEH_HTML::p(__('All fields marked with a * are required fields', 'event_espresso'), '', 'grey-text')
644 644
 				)
645 645
 			)
646 646
 		);
@@ -652,15 +652,15 @@  discard block
 block discarded – undo
652 652
 	 * Activates a payment method of that type. Mostly assuming there is only 1 of that type (or none so far)
653 653
 	 * @global WP_User $current_user
654 654
 	 */
655
-	protected function _activate_payment_method(){
656
-		if(isset($this->_req_data['payment_method_type'])){
655
+	protected function _activate_payment_method() {
656
+		if (isset($this->_req_data['payment_method_type'])) {
657 657
 			$payment_method_type = sanitize_text_field($this->_req_data['payment_method_type']);
658 658
 			//see if one exists
659
-			EE_Registry::instance()->load_lib( 'Payment_Method_Manager' );
660
-			$payment_method = EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type( $payment_method_type );
659
+			EE_Registry::instance()->load_lib('Payment_Method_Manager');
660
+			$payment_method = EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type($payment_method_type);
661 661
 
662
-			$this->_redirect_after_action(1, 'Payment Method', 'activated', array('action' => 'default','payment_method'=>$payment_method->slug()));
663
-		}else{
662
+			$this->_redirect_after_action(1, 'Payment Method', 'activated', array('action' => 'default', 'payment_method'=>$payment_method->slug()));
663
+		} else {
664 664
 			$this->_redirect_after_action(FALSE, 'Payment Method', 'activated', array('action' => 'default'));
665 665
 		}
666 666
 	}
@@ -668,14 +668,14 @@  discard block
 block discarded – undo
668 668
 	/**
669 669
 	 * Deactivates the payment method with the specified slug, and redirects.
670 670
 	 */
671
-	protected function _deactivate_payment_method(){
672
-		if(isset($this->_req_data['payment_method'])){
671
+	protected function _deactivate_payment_method() {
672
+		if (isset($this->_req_data['payment_method'])) {
673 673
 			$payment_method_slug = sanitize_key($this->_req_data['payment_method']);
674 674
 			//deactivate it
675 675
 			EE_Registry::instance()->load_lib('Payment_Method_Manager');
676
-			$count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method( $payment_method_slug );
677
-			$this->_redirect_after_action($count_updated, 'Payment Method', 'deactivated', array('action' => 'default','payment_method'=>$payment_method_slug));
678
-		}else{
676
+			$count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method($payment_method_slug);
677
+			$this->_redirect_after_action($count_updated, 'Payment Method', 'deactivated', array('action' => 'default', 'payment_method'=>$payment_method_slug));
678
+		} else {
679 679
 			$this->_redirect_after_action(FALSE, 'Payment Method', 'deactivated', array('action' => 'default'));
680 680
 		}
681 681
 	}
@@ -689,39 +689,39 @@  discard block
 block discarded – undo
689 689
 	 * subsequently called 'headers_sent_func' which is _payment_methods_list)
690 690
 	 * @return void
691 691
 	 */
692
-	protected function _update_payment_method(){
693
-		if( $_SERVER['REQUEST_METHOD'] == 'POST'){
692
+	protected function _update_payment_method() {
693
+		if ($_SERVER['REQUEST_METHOD'] == 'POST') {
694 694
 			//ok let's find which gateway form to use based on the form input
695 695
 			EE_Registry::instance()->load_lib('Payment_Method_Manager');
696 696
 			/** @var $correct_pmt_form_to_use EE_Payment_Method_Form */
697 697
 			$correct_pmt_form_to_use = NULL;
698 698
 			$pmt_obj = NULL;
699
-			foreach(EE_Payment_Method_Manager::instance()->payment_method_types() as $pmt_obj){
699
+			foreach (EE_Payment_Method_Manager::instance()->payment_method_types() as $pmt_obj) {
700 700
 				/** @var $pmt_obj EE_PMT_Base */
701 701
 				//get the form and simplify it, like what we do when we display it
702 702
 				$pmt_form = $pmt_obj->settings_form();
703 703
 				$this->_simplify_form($pmt_form);
704
-				if($pmt_form->form_data_present_in($this->_req_data)){
704
+				if ($pmt_form->form_data_present_in($this->_req_data)) {
705 705
 					$correct_pmt_form_to_use = $pmt_form;
706 706
 					break;
707 707
 				}
708 708
 			}
709 709
 			//if we couldn't find the correct payment method type...
710
-			if( ! $correct_pmt_form_to_use ){
710
+			if ( ! $correct_pmt_form_to_use) {
711 711
 				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__);
712 712
 				$this->_redirect_after_action(FALSE, 'Payment Method', 'activated', array('action' => 'default'));
713 713
 			}
714 714
 			$correct_pmt_form_to_use->receive_form_submission($this->_req_data);
715
-			if($correct_pmt_form_to_use->is_valid()){
715
+			if ($correct_pmt_form_to_use->is_valid()) {
716 716
 				$correct_pmt_form_to_use->save();
717 717
 				$pm = $correct_pmt_form_to_use->get_model_object();
718 718
 				/** @var $pm EE_Payment_Method */
719
-				$this->_redirect_after_action(TRUE, 'Payment Method', 'updated', array('action' => 'default','payment_method'=>$pm->slug()));
720
-			}else{
719
+				$this->_redirect_after_action(TRUE, 'Payment Method', 'updated', array('action' => 'default', 'payment_method'=>$pm->slug()));
720
+			} else {
721 721
 				EE_Error::add_error(
722 722
 					sprintf(
723 723
 						__('Payment method of type %s was not saved because there were validation errors. They have been marked in the form', 'event_espresso'),
724
-						$pmt_obj instanceof EE_PMT_Base ? $pmt_obj->pretty_name() : __( '"(unknown)"', 'event_espresso' )
724
+						$pmt_obj instanceof EE_PMT_Base ? $pmt_obj->pretty_name() : __('"(unknown)"', 'event_espresso')
725 725
 					),
726 726
 					__FILE__,
727 727
 					__FUNCTION__,
@@ -738,11 +738,11 @@  discard block
 block discarded – undo
738 738
 	protected function _payment_settings() {
739 739
 
740 740
 		$this->_template_args['values'] = $this->_yes_no_values;
741
-		$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;
741
+		$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;
742 742
 
743
-		$this->_set_add_edit_form_tags( 'update_payment_settings' );
744
-		$this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
745
-		$this->_template_args['admin_page_content'] = EEH_Template::display_template( EE_PAYMENTS_TEMPLATE_PATH . 'payment_settings.template.php', $this->_template_args, TRUE );
743
+		$this->_set_add_edit_form_tags('update_payment_settings');
744
+		$this->_set_publish_post_box_vars(NULL, FALSE, FALSE, NULL, FALSE);
745
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(EE_PAYMENTS_TEMPLATE_PATH.'payment_settings.template.php', $this->_template_args, TRUE);
746 746
 		$this->display_admin_page_with_sidebar();
747 747
 
748 748
 	}
@@ -756,13 +756,13 @@  discard block
 block discarded – undo
756 756
 	*		@return array
757 757
 	*/
758 758
 	protected function _update_payment_settings() {
759
-		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;
760
-		EE_Registry::instance()->CFG = apply_filters( 'FHEE__Payments_Admin_Page___update_payment_settings__CFG', EE_Registry::instance()->CFG );
759
+		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;
760
+		EE_Registry::instance()->CFG = apply_filters('FHEE__Payments_Admin_Page___update_payment_settings__CFG', EE_Registry::instance()->CFG);
761 761
 
762 762
 
763
-		$what = __('Payment Settings','event_espresso');
764
-		$success = $this->_update_espresso_configuration( $what, EE_Registry::instance()->CFG, __FILE__, __FUNCTION__, __LINE__ );
765
-		$this->_redirect_after_action( $success, $what, __('updated','event_espresso'), array( 'action' => 'payment_settings' ) );
763
+		$what = __('Payment Settings', 'event_espresso');
764
+		$success = $this->_update_espresso_configuration($what, EE_Registry::instance()->CFG, __FILE__, __FUNCTION__, __LINE__);
765
+		$this->_redirect_after_action($success, $what, __('updated', 'event_espresso'), array('action' => 'payment_settings'));
766 766
 
767 767
 	}
768 768
 	protected function _payment_log_overview_list_table() {
@@ -788,18 +788,18 @@  discard block
 block discarded – undo
788 788
 	 * @param bool $count
789 789
 	 * @return array
790 790
 	 */
791
-	public function get_payment_logs($per_page = 50, $current_page = 0, $count = false){
792
-		EE_Registry::instance()->load_model( 'Change_Log' );
791
+	public function get_payment_logs($per_page = 50, $current_page = 0, $count = false) {
792
+		EE_Registry::instance()->load_model('Change_Log');
793 793
 		//we may need to do multiple queries (joining differently), so we actually wan tan array of query params
794
-		$query_params =  array(array('LOG_type'=>  EEM_Change_Log::type_gateway));
794
+		$query_params = array(array('LOG_type'=>  EEM_Change_Log::type_gateway));
795 795
 		//check if they've selected a specific payment method
796
-		if( isset($this->_req_data['_payment_method']) && $this->_req_data['_payment_method'] !== 'all'){
796
+		if (isset($this->_req_data['_payment_method']) && $this->_req_data['_payment_method'] !== 'all') {
797 797
 			$query_params[0]['OR*pm_or_pay_pm'] = array('Payment.Payment_Method.PMD_ID'=>$this->_req_data['_payment_method'],
798 798
 				'Payment_Method.PMD_ID'=>$this->_req_data['_payment_method']);
799 799
 		}
800 800
 		//take into account search
801
-		if(isset($this->_req_data['s']) && $this->_req_data['s']){
802
-			$similarity_string = array('LIKE','%'.str_replace("","%",$this->_req_data['s']) .'%');
801
+		if (isset($this->_req_data['s']) && $this->_req_data['s']) {
802
+			$similarity_string = array('LIKE', '%'.str_replace("", "%", $this->_req_data['s']).'%');
803 803
 			$query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_fname'] = $similarity_string;
804 804
 			$query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_lname'] = $similarity_string;
805 805
 			$query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_email'] = $similarity_string;
@@ -814,48 +814,48 @@  discard block
 block discarded – undo
814 814
 			$query_params[0]['OR*s']['LOG_message'] = $similarity_string;
815 815
 
816 816
 		}
817
-		if(isset( $this->_req_data['payment-filter-start-date'] ) && isset( $this->_req_data['payment-filter-end-date'] )){
817
+		if (isset($this->_req_data['payment-filter-start-date']) && isset($this->_req_data['payment-filter-end-date'])) {
818 818
 			//add date
819
-			$start_date =wp_strip_all_tags( $this->_req_data['payment-filter-start-date'] );
820
-			$end_date = wp_strip_all_tags( $this->_req_data['payment-filter-end-date'] );
819
+			$start_date = wp_strip_all_tags($this->_req_data['payment-filter-start-date']);
820
+			$end_date = wp_strip_all_tags($this->_req_data['payment-filter-end-date']);
821 821
 			//make sure our timestamps start and end right at the boundaries for each day
822
-			$start_date = date( 'Y-m-d', strtotime( $start_date ) ) . ' 00:00:00';
823
-			$end_date = date( 'Y-m-d', strtotime( $end_date ) ) . ' 23:59:59';
822
+			$start_date = date('Y-m-d', strtotime($start_date)).' 00:00:00';
823
+			$end_date = date('Y-m-d', strtotime($end_date)).' 23:59:59';
824 824
 
825 825
 			//convert to timestamps
826
-			$start_date = strtotime( $start_date );
827
-			$end_date = strtotime( $end_date );
826
+			$start_date = strtotime($start_date);
827
+			$end_date = strtotime($end_date);
828 828
 
829 829
 			//makes sure start date is the lowest value and vice versa
830
-			$start_date = min( $start_date, $end_date );
831
-			$end_date = max( $start_date, $end_date );
830
+			$start_date = min($start_date, $end_date);
831
+			$end_date = max($start_date, $end_date);
832 832
 
833 833
 			//convert for query
834
-			$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' );
835
-			$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' );
834
+			$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');
835
+			$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');
836 836
 
837
-			$query_params[0]['LOG_time'] = array('BETWEEN',array($start_date,$end_date));
837
+			$query_params[0]['LOG_time'] = array('BETWEEN', array($start_date, $end_date));
838 838
 
839 839
 		}
840
-		if($count){
840
+		if ($count) {
841 841
 			return EEM_Change_Log::instance()->count($query_params);
842 842
 		}
843
-		if(isset($this->_req_data['order'])){
844
-			$sort = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] )) ? $this->_req_data['order'] : 'DESC';
843
+		if (isset($this->_req_data['order'])) {
844
+			$sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'DESC';
845 845
 			$query_params['order_by'] = array('LOG_time' => $sort);
846
-		}else{
846
+		} else {
847 847
 				$query_params['order_by'] = array('LOG_time' => 'DESC');
848 848
 		}
849
-		$offset = ($current_page-1)*$per_page;
849
+		$offset = ($current_page - 1) * $per_page;
850 850
 
851
-		if( ! isset($this->_req_data['download_results'])){
852
-			$query_params['limit'] = array( $offset, $per_page );
851
+		if ( ! isset($this->_req_data['download_results'])) {
852
+			$query_params['limit'] = array($offset, $per_page);
853 853
 		}
854 854
 
855 855
 
856 856
 
857 857
 		//now they've requested to instead just download the file instead of viewing it.
858
-		if(isset($this->_req_data['download_results'])){
858
+		if (isset($this->_req_data['download_results'])) {
859 859
 			$wpdb_results = EEM_Change_Log::instance()->get_all_efficiently($query_params);
860 860
 			header('Content-Disposition: attachment');
861 861
 			header("Content-Disposition: attachment; filename=ee_payment_logs_for_".sanitize_key(site_url()));
@@ -877,36 +877,36 @@  discard block
 block discarded – undo
877 877
 	 * @param EE_Change_Log $logB
878 878
 	 * @return int
879 879
 	 */
880
-	protected function _sort_logs_again($logA,$logB){
880
+	protected function _sort_logs_again($logA, $logB) {
881 881
 		$timeA = $logA->get_raw('LOG_time');
882 882
 		$timeB = $logB->get_raw('LOG_time');
883
-		if($timeA == $timeB){
883
+		if ($timeA == $timeB) {
884 884
 			return 0;
885 885
 		}
886 886
 		$comparison = $timeA < $timeB ? -1 : 1;
887
-		if(strtoupper($this->_sort_logs_again_direction) == 'DESC'){
887
+		if (strtoupper($this->_sort_logs_again_direction) == 'DESC') {
888 888
 			return $comparison * -1;
889
-		}else{
889
+		} else {
890 890
 			return $comparison;
891 891
 		}
892 892
 	}
893 893
 
894 894
 	protected function _payment_log_details() {
895
-		EE_Registry::instance()->load_model( 'Change_Log' );
895
+		EE_Registry::instance()->load_model('Change_Log');
896 896
 		/** @var $payment_log EE_Change_Log */
897 897
 		$payment_log = EEM_Change_Log::instance()->get_one_by_ID($this->_req_data['ID']);
898 898
 		$payment_method = NULL;
899 899
 		$transaction = NULL;
900
-		if( $payment_log instanceof EE_Change_Log ){
901
-			if( $payment_log->object() instanceof EE_Payment ){
900
+		if ($payment_log instanceof EE_Change_Log) {
901
+			if ($payment_log->object() instanceof EE_Payment) {
902 902
 				$payment_method = $payment_log->object()->payment_method();
903 903
 				$transaction = $payment_log->object()->transaction();
904
-			}elseif($payment_log->object() instanceof EE_Payment_Method){
904
+			}elseif ($payment_log->object() instanceof EE_Payment_Method) {
905 905
 				$payment_method = $payment_log->object();
906 906
 			}
907 907
 		}
908 908
 		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
909
-			EE_PAYMENTS_TEMPLATE_PATH . 'payment_log_details.template.php',
909
+			EE_PAYMENTS_TEMPLATE_PATH.'payment_log_details.template.php',
910 910
 			array(
911 911
 				'payment_log'=>$payment_log,
912 912
 				'payment_method'=>$payment_method,
Please login to merge, or discard this patch.
core/helpers/EEH_Tabbed_Content.helper.php 1 patch
Spacing   +36 added lines, -36 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
 /**
@@ -46,22 +46,22 @@  discard block
 block discarded – undo
46 46
 	 * @return string the assembled html string containing the tabbed content for display.
47 47
 	 * @throws \EE_Error
48 48
 	 */
49
-	public static function display($tabs_contents, $tabs_names = array(), $small_tabs = true, $tabs_content = TRUE ) {
49
+	public static function display($tabs_contents, $tabs_names = array(), $small_tabs = true, $tabs_content = TRUE) {
50 50
 
51 51
 		//first check if $tabs_names is not empty then the count must match the count of $tabs_content otherwise we've got a problem houston
52
-		if ( !empty( $tabs_names) && ( count( (array) $tabs_names) != count( (array) $tabs_content) ) ) {
53
-			throw new EE_Error( __('The count for $tabs_names and $tabs_content does not match.', 'event_espresso') );
52
+		if ( ! empty($tabs_names) && (count((array) $tabs_names) != count((array) $tabs_content))) {
53
+			throw new EE_Error(__('The count for $tabs_names and $tabs_content does not match.', 'event_espresso'));
54 54
 		}
55 55
 
56 56
 		//make sure we've got incoming data setup properly
57
-		$tabs = !empty( $tabs_names ) ? (array) $tabs_names : array_keys( (array) $tabs_contents );
58
-		$tabs_content = !empty( $tabs_names ) ? array_combine( (array) $tabs_names, (array) $tabs_content ) : $tabs_contents;
57
+		$tabs = ! empty($tabs_names) ? (array) $tabs_names : array_keys((array) $tabs_contents);
58
+		$tabs_content = ! empty($tabs_names) ? array_combine((array) $tabs_names, (array) $tabs_content) : $tabs_contents;
59 59
 
60
-		$all_tabs = '<h2 class="nav-tab-wrapper">' . "\n";
60
+		$all_tabs = '<h2 class="nav-tab-wrapper">'."\n";
61 61
 		$all_tabs_content = '';
62 62
 
63 63
 		$index = 0;
64
-		foreach ( $tabs as $tab ) {
64
+		foreach ($tabs as $tab) {
65 65
 			$active = $index === 0 ? true : false;
66 66
 			$all_tabs .= self::tab($tab, $active);
67 67
 			$all_tabs_content .= self::tab_content($tab, $tabs_content[$tab], $active);
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 
79 79
 		$tab_container_class = $small_tabs ? 'ee-nav-tabs ee-nav-tabs-small' : 'ee-nav-tabs';
80 80
 
81
-		return '<div class="'. $tab_container_class . '">' . "\n\t" . $all_tabs . $all_tabs_content . "\n" . '</div>';
81
+		return '<div class="'.$tab_container_class.'">'."\n\t".$all_tabs.$all_tabs_content."\n".'</div>';
82 82
 	}
83 83
 
84 84
 
@@ -102,11 +102,11 @@  discard block
 block discarded – undo
102 102
 	 * @throws \EE_Error
103 103
 	 */
104 104
 	public static function display_admin_nav_tabs($nav_tabs = array()) {
105
-		if ( empty($nav_tabs) )
106
-			throw new EE_Error( __('Nav Tabs cannot be generated because the tab array is missing', 'event_espresso' ) );
105
+		if (empty($nav_tabs))
106
+			throw new EE_Error(__('Nav Tabs cannot be generated because the tab array is missing', 'event_espresso'));
107 107
 
108
-		$all_tabs = '<h2 class="nav-tab-wrapper">' . "\n";
109
-		foreach ( $nav_tabs as $slug => $tab ) {
108
+		$all_tabs = '<h2 class="nav-tab-wrapper">'."\n";
109
+		foreach ($nav_tabs as $slug => $tab) {
110 110
 			$all_tabs .= self::tab($slug, false, $tab['link_text'], $tab['url'], $tab['css_class']);
111 111
 		}
112 112
 		$all_tabs .= '</h2>';
@@ -122,13 +122,13 @@  discard block
 block discarded – undo
122 122
 	 * @param bool|string $css If string given then the generated tab will include that as the class.
123 123
 	 * @return string          html for tab
124 124
 	 */
125
-	private static function tab($name, $active = false, $nice_name = FALSE, $url = FALSE, $css = FALSE ) {
125
+	private static function tab($name, $active = false, $nice_name = FALSE, $url = FALSE, $css = FALSE) {
126 126
 		$name = str_replace(' ', '-', $name);
127 127
 		$class = $active ? 'nav-tab nav-tab-active' : 'nav-tab';
128
-		$class = $css ? $class . ' ' . $css : $class;
129
-		$nice_name = $nice_name ? $nice_name : ucwords( preg_replace('/(-|_)/', ' ', $name) );
130
-		$url = $url ? $url : '#' . $name;
131
-		$tab = '<a class="' . $class . '" rel="ee-tab-' . $name . '" href="' . $url . '">' . $nice_name . '</a>' . "\n\t";
128
+		$class = $css ? $class.' '.$css : $class;
129
+		$nice_name = $nice_name ? $nice_name : ucwords(preg_replace('/(-|_)/', ' ', $name));
130
+		$url = $url ? $url : '#'.$name;
131
+		$tab = '<a class="'.$class.'" rel="ee-tab-'.$name.'" href="'.$url.'">'.$nice_name.'</a>'."\n\t";
132 132
 		return $tab;
133 133
 	}
134 134
 
@@ -144,9 +144,9 @@  discard block
 block discarded – undo
144 144
 	 */
145 145
 	private static function tab_content($name, $tab_content, $active = false) {
146 146
 		$class = $active ? 'nav-tab-content' : 'nav-tab-content hidden';
147
-		$name = str_replace( ' ', '-', $name);
148
-		$content = "\t" . '<div class="'. $class . '" id="ee-tab-' . $name . '">' . "\n";
149
-		$content .= "\t" . $tab_content . "\n";
147
+		$name = str_replace(' ', '-', $name);
148
+		$content = "\t".'<div class="'.$class.'" id="ee-tab-'.$name.'">'."\n";
149
+		$content .= "\t".$tab_content."\n";
150 150
 		$content .= '<div style="clear:both"></div></div>';
151 151
 		return $content;
152 152
 	}
@@ -172,9 +172,9 @@  discard block
 block discarded – undo
172 172
 	 * @param string $default 			You can include a string for the item that will receive the "item_display" class for the js.
173 173
 	 * @return string                  a html snippet of of all the formatted link elements.
174 174
 	 */
175
-	public static function tab_text_links( $item_array, $container_class = '', $sep = '|', $default = '' ) {
176
-		$item_array = apply_filters( 'FHEE__EEH_Tabbed_Content__tab_text_links', $item_array, $container_class );
177
-		if ( !is_array($item_array) || empty( $item_array ) )
175
+	public static function tab_text_links($item_array, $container_class = '', $sep = '|', $default = '') {
176
+		$item_array = apply_filters('FHEE__EEH_Tabbed_Content__tab_text_links', $item_array, $container_class);
177
+		if ( ! is_array($item_array) || empty($item_array))
178 178
 			return false; //get out we don't have even the basic thing we need!
179 179
 
180 180
 
@@ -185,15 +185,15 @@  discard block
 block discarded – undo
185 185
 			'title' => esc_attr__('Link for Item', 'event_espresso'),
186 186
 			'slug' => 'item_slug'
187 187
 		);
188
-		$container_class = !empty($container_class) ? 'ee-text-links ' . $container_class : 'ee-text-links';
189
-		$list = '<ul class="' . $container_class . '">';
188
+		$container_class = ! empty($container_class) ? 'ee-text-links '.$container_class : 'ee-text-links';
189
+		$list = '<ul class="'.$container_class.'">';
190 190
 
191 191
 		$ci = 1;
192
-		foreach ( $item_array as $item ) {
193
-			$item = wp_parse_args( $item, $defaults );
194
-			$item['class'] = !empty($default) && $default == $item['slug'] ? 'item_display ' . $item['class'] : $item['class'];
192
+		foreach ($item_array as $item) {
193
+			$item = wp_parse_args($item, $defaults);
194
+			$item['class'] = ! empty($default) && $default == $item['slug'] ? 'item_display '.$item['class'] : $item['class'];
195 195
 			$list .= self::_text_link_item($item);
196
-			if ( !empty($sep) && $ci != count($item_array) )
196
+			if ( ! empty($sep) && $ci != count($item_array))
197 197
 				$list .= self::_text_link_item($sep);
198 198
 			$ci++;
199 199
 		}
@@ -204,9 +204,9 @@  discard block
 block discarded – undo
204 204
 
205 205
 
206 206
 
207
-	private static function _text_link_item( $item ) {
207
+	private static function _text_link_item($item) {
208 208
 		//if this isn't an array then we're doing a separator
209
-		if ( !is_array( $item ) ) {
209
+		if ( ! is_array($item)) {
210 210
 			$label = $item;
211 211
 			$class = 'ee-text-link-sep';
212 212
 			$href = '';
@@ -215,12 +215,12 @@  discard block
 block discarded – undo
215 215
 			extract($item);
216 216
 		}
217 217
 
218
-		$class = $class != 'ee-text-link-sep'  ? 'class="ee-text-link-li ' . $class . '"' : 'class="ee-text-link-sep"';
218
+		$class = $class != 'ee-text-link-sep' ? 'class="ee-text-link-li '.$class.'"' : 'class="ee-text-link-sep"';
219 219
 
220
-		$content = '<li ' . $class . '>';
221
-		$content .= !empty($href) ? '<a class="ee-text-link" href="#' . $href . '" title="' . $title . '">' : '';
220
+		$content = '<li '.$class.'>';
221
+		$content .= ! empty($href) ? '<a class="ee-text-link" href="#'.$href.'" title="'.$title.'">' : '';
222 222
 		$content .= $label;
223
-		$content .= !empty($href) ? '</a>' : '';
223
+		$content .= ! empty($href) ? '</a>' : '';
224 224
 		$content .= '</li>';
225 225
 		return $content;
226 226
 	}
Please login to merge, or discard this patch.
core/libraries/payment_methods/EE_Payment_Method_Manager.lib.php 2 patches
Braces   +5 added lines, -3 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
 /**
3 5
  * Event Espresso
4 6
  *
@@ -513,7 +515,7 @@  discard block
 block discarded – undo
513 515
 
514 516
 		if($count){
515 517
 			return EEM_Price::instance()->count_deleted_and_undeleted(array($_where));
516
-		}else{
518
+		} else{
517 519
 			return EEM_Price::instance()->get_all_deleted_and_undeleted($query_params);
518 520
 		}
519 521
 	}
@@ -943,7 +945,7 @@  discard block
 block discarded – undo
943 945
 			'limit'=>$limit);
944 946
 		if($count){
945 947
 			return EEM_Price_Type::instance()->count_deleted_and_undeleted($query_params);
946
-		}else{
948
+		} else{
947 949
 			return EEM_Price_Type::instance()->get_all_deleted_and_undeleted($query_params);
948 950
 		}
949 951
 
Please login to merge, or discard this patch.
Spacing   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	 */
36 36
 	public static function instance() {
37 37
 		// check if class object is instantiated, and instantiated properly
38
-		if ( ! self::$_instance instanceof EE_Payment_Method_Manager ) {
38
+		if ( ! self::$_instance instanceof EE_Payment_Method_Manager) {
39 39
 			self::$_instance = new self();
40 40
 		}
41 41
 		EE_Registry::instance()->load_lib('PMT_Base');
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 	 * Resets the instance and returns a new one
47 47
 	 * @return EE_Payment_Method_Manager
48 48
 	 */
49
-	public static function reset(){
49
+	public static function reset() {
50 50
 		self::$_instance = NULL;
51 51
 		return self::instance();
52 52
 	}
@@ -57,12 +57,12 @@  discard block
 block discarded – undo
57 57
 	 * or just re-use the PMTs we found last time we checked during this request (if
58 58
 	 * we have not yet checked during this request, then we need to check anyways)
59 59
 	 */
60
-	public function maybe_register_payment_methods( $force_recheck = FALSE ){
61
-		if( ! $this->_payment_method_types || $force_recheck ){
60
+	public function maybe_register_payment_methods($force_recheck = FALSE) {
61
+		if ( ! $this->_payment_method_types || $force_recheck) {
62 62
 			$this->_register_payment_methods();
63 63
 			//if in admin lets ensure caps are set.
64
-			if ( is_admin() ) {
65
-				add_filter( 'FHEE__EE_Capabilities__init_caps_map__caps', array( $this, 'add_payment_method_caps' ) );
64
+			if (is_admin()) {
65
+				add_filter('FHEE__EE_Capabilities__init_caps_map__caps', array($this, 'add_payment_method_caps'));
66 66
 				EE_Registry::instance()->CAP->init_caps();
67 67
 			}
68 68
 		}
@@ -75,19 +75,19 @@  discard block
 block discarded – undo
75 75
 	 */
76 76
 	protected function _register_payment_methods() {
77 77
 		// grab list of installed modules
78
-		$pm_to_register = glob( EE_PAYMENT_METHODS . '*', GLOB_ONLYDIR );
78
+		$pm_to_register = glob(EE_PAYMENT_METHODS.'*', GLOB_ONLYDIR);
79 79
 		// filter list of modules to register
80
-		$pm_to_register = apply_filters( 'FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register', $pm_to_register );
80
+		$pm_to_register = apply_filters('FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register', $pm_to_register);
81 81
 
82 82
 		// loop through folders
83
-		foreach ( $pm_to_register as $pm_path ) {
84
-				$this->register_payment_method( $pm_path );
83
+		foreach ($pm_to_register as $pm_path) {
84
+				$this->register_payment_method($pm_path);
85 85
 		}
86
-		do_action( 'FHEE__EE_Payment_Method_Manager__register_payment_methods__registered_payment_methods' );
86
+		do_action('FHEE__EE_Payment_Method_Manager__register_payment_methods__registered_payment_methods');
87 87
 		// filter list of installed modules
88 88
 		//keep them organized alphabetically by the payment method type's name
89
-		ksort( $this->_payment_method_types );
90
-		return apply_filters( 'FHEE__EE_Payment_Method_Manager__register_payment_methods__installed_payment_methods', $this->_payment_method_types );
89
+		ksort($this->_payment_method_types);
90
+		return apply_filters('FHEE__EE_Payment_Method_Manager__register_payment_methods__installed_payment_methods', $this->_payment_method_types);
91 91
 	}
92 92
 
93 93
 
@@ -99,35 +99,35 @@  discard block
 block discarded – undo
99 99
 	 * @param string $payment_method_path - full path up to and including payment method folder
100 100
 	 * @return boolean
101 101
 	 */
102
-	public function register_payment_method( $payment_method_path = '' ) {
103
-		do_action( 'AHEE__EE_Payment_Method_Manager__register_payment_method__begin',$payment_method_path );
102
+	public function register_payment_method($payment_method_path = '') {
103
+		do_action('AHEE__EE_Payment_Method_Manager__register_payment_method__begin', $payment_method_path);
104 104
 		$module_ext = '.pm.php';
105 105
 		// make all separators match
106
-		$payment_method_path = rtrim( str_replace( '/\\', DS, $payment_method_path ), DS );
106
+		$payment_method_path = rtrim(str_replace('/\\', DS, $payment_method_path), DS);
107 107
 		// grab and sanitize module name
108
-		$module_dir = basename( $payment_method_path );
108
+		$module_dir = basename($payment_method_path);
109 109
 		// create classname from module directory name
110
-		$module = str_replace( ' ', '_', str_replace( '_', ' ', $module_dir ));
110
+		$module = str_replace(' ', '_', str_replace('_', ' ', $module_dir));
111 111
 		// add class prefix
112
-		$module_class = 'EE_PMT_' . $module;
112
+		$module_class = 'EE_PMT_'.$module;
113 113
 		// does the module exist ?
114
-		if ( ! is_readable( $payment_method_path . DS . $module_class . $module_ext )) {
115
-			$msg = sprintf( __( 'The requested %s payment method file could not be found or is not readable due to file permissions.', 'event_espresso' ), $module );
116
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
114
+		if ( ! is_readable($payment_method_path.DS.$module_class.$module_ext)) {
115
+			$msg = sprintf(__('The requested %s payment method file could not be found or is not readable due to file permissions.', 'event_espresso'), $module);
116
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
117 117
 			return FALSE;
118 118
 		}
119
-		if ( WP_DEBUG === TRUE ) { EEH_Debug_Tools::instance()->start_timer(); }
119
+		if (WP_DEBUG === TRUE) { EEH_Debug_Tools::instance()->start_timer(); }
120 120
 		// load the module class file
121
-		require_once( $payment_method_path . DS . $module_class . $module_ext );
122
-		if ( WP_DEBUG === TRUE ) { EEH_Debug_Tools::instance()->stop_timer("Requiring payment method $module_class"); }
121
+		require_once($payment_method_path.DS.$module_class.$module_ext);
122
+		if (WP_DEBUG === TRUE) { EEH_Debug_Tools::instance()->stop_timer("Requiring payment method $module_class"); }
123 123
 		// verify that class exists
124
-		if ( ! class_exists( $module_class )) {
125
-			$msg = sprintf( __( 'The requested %s module class does not exist.', 'event_espresso' ), $module_class );
126
-			EE_Error::add_error( $msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__ );
124
+		if ( ! class_exists($module_class)) {
125
+			$msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
126
+			EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
127 127
 			return FALSE;
128 128
 		}
129 129
 		// add to array of registered modules
130
-		$this->_payment_method_types[ $module ] = $payment_method_path . DS . $module_class . $module_ext;
130
+		$this->_payment_method_types[$module] = $payment_method_path.DS.$module_class.$module_ext;
131 131
 		return TRUE;
132 132
 	}
133 133
 	/**
@@ -136,15 +136,15 @@  discard block
 block discarded – undo
136 136
 	 * @param boolean $force_recheck whether to force re-checking for new payment method types
137 137
 	 * @return boolean
138 138
 	 */
139
-	public function payment_method_type_exists($payment_method_name, $force_recheck = FALSE){
140
-		if ( ! is_array( $this->_payment_method_types ) || ! isset( $this->_payment_method_types[$payment_method_name] )
141
-				|| $force_recheck ) {
139
+	public function payment_method_type_exists($payment_method_name, $force_recheck = FALSE) {
140
+		if ( ! is_array($this->_payment_method_types) || ! isset($this->_payment_method_types[$payment_method_name])
141
+				|| $force_recheck) {
142 142
 			$this->maybe_register_payment_methods($force_recheck);
143 143
 		}
144
-		if(isset($this->_payment_method_types[$payment_method_name])){
144
+		if (isset($this->_payment_method_types[$payment_method_name])) {
145 145
 			require_once($this->_payment_method_types[$payment_method_name]);
146 146
 			return true;
147
-		}else{
147
+		} else {
148 148
 			return false;
149 149
 		}
150 150
 	}
@@ -155,16 +155,16 @@  discard block
 block discarded – undo
155 155
 	 * @param boolean $force_recheck whether to force re-checking for new payment method types
156 156
 	 * @return array
157 157
 	 */
158
-	public function payment_method_type_names($with_prefixes = FALSE, $force_recheck = FALSE ){
158
+	public function payment_method_type_names($with_prefixes = FALSE, $force_recheck = FALSE) {
159 159
 		$this->maybe_register_payment_methods($force_recheck);
160
-		if($with_prefixes){
160
+		if ($with_prefixes) {
161 161
 			$classnames = array_keys($this->_payment_method_types);
162 162
 			$payment_methods = array();
163
-			foreach($classnames as $classname){
163
+			foreach ($classnames as $classname) {
164 164
 				$payment_methods[] = $this->payment_method_class_from_type($classname);
165 165
 			}
166 166
 			return $payment_methods;
167
-		}else{
167
+		} else {
168 168
 			return array_keys($this->_payment_method_types);
169 169
 		}
170 170
 	}
@@ -174,10 +174,10 @@  discard block
 block discarded – undo
174 174
 	 * @param boolean $force_recheck whether to force re-checking for new payment method types
175 175
 	 * @return EE_PMT_Base[]
176 176
 	 */
177
-	public function payment_method_types( $force_recheck = FALSE ){
177
+	public function payment_method_types($force_recheck = FALSE) {
178 178
 		$this->maybe_register_payment_methods($force_recheck);
179 179
 		$pmt_objs = array();
180
-		foreach($this->payment_method_type_names(true) as $classname){
180
+		foreach ($this->payment_method_type_names(true) as $classname) {
181 181
 			$pmt_objs[] = new $classname;
182 182
 		}
183 183
 		return $pmt_objs;
@@ -189,8 +189,8 @@  discard block
 block discarded – undo
189 189
 	 * @param string $classname
190 190
 	 * @return string
191 191
 	 */
192
-	public function payment_method_type_sans_class_prefix($classname){
193
-		$pmt_name = str_replace("EE_PMT_","",$classname);
192
+	public function payment_method_type_sans_class_prefix($classname) {
193
+		$pmt_name = str_replace("EE_PMT_", "", $classname);
194 194
 		return $pmt_name;
195 195
 	}
196 196
 
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 	 * @param string $type
200 200
 	 * @return string
201 201
 	 */
202
-	public function payment_method_class_from_type($type){
202
+	public function payment_method_class_from_type($type) {
203 203
 		$this->maybe_register_payment_methods();
204 204
 		return "EE_PMT_".$type;
205 205
 	}
@@ -213,38 +213,38 @@  discard block
 block discarded – undo
213 213
 	 * @return \EE_Payment_Method
214 214
 	 * @throws \EE_Error
215 215
 	 */
216
-	public function activate_a_payment_method_of_type( $payment_method_type ){
216
+	public function activate_a_payment_method_of_type($payment_method_type) {
217 217
 		$payment_method = EEM_Payment_Method::instance()->get_one_of_type($payment_method_type);
218
-		if( ! $payment_method instanceof EE_Payment_Method ){
218
+		if ( ! $payment_method instanceof EE_Payment_Method) {
219 219
 			$pm_type_class = $this->payment_method_class_from_type($payment_method_type);
220
-			if(class_exists($pm_type_class)){
220
+			if (class_exists($pm_type_class)) {
221 221
 				/** @var $pm_type_obj EE_PMT_Base */
222 222
 				$pm_type_obj = new $pm_type_class;
223 223
 				$payment_method = EEM_Payment_Method::instance()->get_one_by_slug($pm_type_obj->system_name());
224
-				if( ! $payment_method){
225
-					$payment_method = $this->create_payment_method_of_type( $pm_type_obj );
224
+				if ( ! $payment_method) {
225
+					$payment_method = $this->create_payment_method_of_type($pm_type_obj);
226 226
 				}
227
-				$payment_method->set_type( $payment_method_type );
228
-				$this->initialize_payment_method( $payment_method );
227
+				$payment_method->set_type($payment_method_type);
228
+				$this->initialize_payment_method($payment_method);
229 229
 			} else {
230 230
 				throw new EE_Error(
231 231
 					sprintf(
232
-						__( 'There is no payment method of type %1$s, so it could not be activated', 'event_espresso'),
232
+						__('There is no payment method of type %1$s, so it could not be activated', 'event_espresso'),
233 233
 						$pm_type_class )
234 234
 				);
235 235
 			}
236 236
 		}
237 237
 		$payment_method->set_active();
238 238
 		$payment_method->save();
239
-		$this->set_usable_currencies_on_payment_method( $payment_method );
240
-		if( $payment_method->type() == 'Invoice' ){
241
-			$messages = EE_Registry::instance()->load_lib( 'messages' );
242
-			$messages->ensure_message_type_is_active( 'invoice', 'html' );
243
-			$messages->ensure_messenger_is_active( 'pdf' );
239
+		$this->set_usable_currencies_on_payment_method($payment_method);
240
+		if ($payment_method->type() == 'Invoice') {
241
+			$messages = EE_Registry::instance()->load_lib('messages');
242
+			$messages->ensure_message_type_is_active('invoice', 'html');
243
+			$messages->ensure_messenger_is_active('pdf');
244 244
 			EE_Error::add_attention(
245 245
 				sprintf(
246
-					__( 'Note, when the invoice payment method is activated, the invoice message type, html messenger, and pdf messenger are activated as well for the %1$smessages system%2$s.', 'event_espresso' ),
247
-					'<a href="' . admin_url( 'admin.php?page=espresso_messages') . '">',
246
+					__('Note, when the invoice payment method is activated, the invoice message type, html messenger, and pdf messenger are activated as well for the %1$smessages system%2$s.', 'event_espresso'),
247
+					'<a href="'.admin_url('admin.php?page=espresso_messages').'">',
248 248
 					'</a>'
249 249
 				)
250 250
 			);
@@ -258,17 +258,17 @@  discard block
 block discarded – undo
258 258
 	 * @param EE_PMT_Base $pm_type_obj
259 259
 	 * @return EE_Payment_Method
260 260
 	 */
261
-	public function create_payment_method_of_type( $pm_type_obj ) {
261
+	public function create_payment_method_of_type($pm_type_obj) {
262 262
 		global $current_user;
263 263
 		$payment_method = EE_Payment_Method::new_instance(
264 264
 			array(
265 265
 				'PMD_type' 		 => $pm_type_obj->system_name(),
266 266
 				'PMD_name' 		 => $pm_type_obj->pretty_name(),
267 267
 				'PMD_admin_name' => $pm_type_obj->pretty_name(),
268
-				'PMD_slug' 		 => $pm_type_obj->system_name(),//automatically converted to slug
268
+				'PMD_slug' 		 => $pm_type_obj->system_name(), //automatically converted to slug
269 269
 				'PMD_wp_user' 	 => $current_user->ID,
270 270
 				'PMD_order' 	 => EEM_Payment_Method::instance()->count(
271
-						array( array( 'PMD_type' => array( '!=', 'Admin_Only' )))
271
+						array(array('PMD_type' => array('!=', 'Admin_Only')))
272 272
 					) * 10,
273 273
 			)
274 274
 		);
@@ -280,16 +280,16 @@  discard block
 block discarded – undo
280 280
 	 * @param EE_Payment_Method $payment_method
281 281
 	 * @return EE_Payment_Method
282 282
 	 */
283
-	public function initialize_payment_method( $payment_method ) {
283
+	public function initialize_payment_method($payment_method) {
284 284
 		$pm_type_obj = $payment_method->type_obj();
285
-		$payment_method->set_description( $pm_type_obj->default_description() );
286
-		if( ! $payment_method->button_url() ){
287
-			$payment_method->set_button_url( $pm_type_obj->default_button_url() );
285
+		$payment_method->set_description($pm_type_obj->default_description());
286
+		if ( ! $payment_method->button_url()) {
287
+			$payment_method->set_button_url($pm_type_obj->default_button_url());
288 288
 		}	
289 289
 		//now add setup its default extra meta properties
290 290
 		$extra_metas = $pm_type_obj->settings_form()->extra_meta_inputs();
291
-		foreach( $extra_metas as $meta_name => $input ){
292
-			$payment_method->update_extra_meta($meta_name, $input->raw_value() );
291
+		foreach ($extra_metas as $meta_name => $input) {
292
+			$payment_method->update_extra_meta($meta_name, $input->raw_value());
293 293
 		}
294 294
 		return $payment_method;
295 295
 	}
@@ -299,8 +299,8 @@  discard block
 block discarded – undo
299 299
 	 * @param EE_Payment_Method $payment_method
300 300
 	 * @return EE_Payment_Method
301 301
 	 */
302
-	public function set_usable_currencies_on_payment_method( $payment_method ) {
303
-		foreach($payment_method->get_all_usable_currencies() as $currency_obj){
302
+	public function set_usable_currencies_on_payment_method($payment_method) {
303
+		foreach ($payment_method->get_all_usable_currencies() as $currency_obj) {
304 304
 			$payment_method->_add_relation_to($currency_obj, 'Currency');
305 305
 		}
306 306
 		return $payment_method;
@@ -318,8 +318,8 @@  discard block
 block discarded – undo
318 318
 	 *
319 319
 	 * @return int count of rows updated.
320 320
 	 */
321
-	public function deactivate_payment_method( $payment_method_slug ) {
322
-		$count_updated = EEM_Payment_Method::instance()->update(array('PMD_scope'=>array()),array(array('PMD_slug'=>$payment_method_slug)));
321
+	public function deactivate_payment_method($payment_method_slug) {
322
+		$count_updated = EEM_Payment_Method::instance()->update(array('PMD_scope'=>array()), array(array('PMD_slug'=>$payment_method_slug)));
323 323
 		return $count_updated;
324 324
 	}
325 325
 
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
 	 * @param array $caps capabilities being filtered
333 333
 	 * @return array
334 334
 	 */
335
-	public function add_payment_method_caps( $caps ) {
335
+	public function add_payment_method_caps($caps) {
336 336
 		/* add dynamic caps from payment methods
337 337
 		 * at the time of writing, october 20 2014, these are the caps added:
338 338
 		 * ee_payment_method_admin_only
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
 		 * their related capability automatically added too, so long as they are
348 348
 		 * registered properly using EE_Register_Payment_Method::register()
349 349
 		 */
350
-		foreach( $this->payment_method_types() as $payment_method_type_obj ){
350
+		foreach ($this->payment_method_types() as $payment_method_type_obj) {
351 351
 			$caps['administrator'][] = $payment_method_type_obj->cap_name();
352 352
 		}
353 353
 		return $caps;
Please login to merge, or discard this patch.
core/data_migration_scripts/EE_DMS_Core_4_8_0.dms.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -715,7 +715,7 @@
 block discarded – undo
715 715
 				}
716 716
 			}
717 717
 		}
718
-        }
718
+		}
719 719
 	/**
720 720
 	 * addresses https://events.codebasehq.com/projects/event-espresso/tickets/8731
721 721
 	 * which should just be a temporary issue for folks who installed 4.8.0-4.8.5;
Please login to merge, or discard this patch.
core/db_models/EEM_Base.model.php 3 patches
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -1,28 +1,28 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- *
4
- * Class EEM_Base
5
- *
6
- * Multi-table model. Especially handles joins when querying.
7
- * An important note about values dealt with in models and model objects:
8
- * values used by models exist in basically 3 different domains, which the EE_Model_Fields help convert between:
9
- * 1. Client-code values (eg, controller code may refer to a date as "March 21, 2013")
10
- * 2. Model object values (eg, after the model object has called set() on the value and saves it onto the model object, it may become a unix timestamp, eg 12312412412)
11
- * 3. Database values (eg, we may later decide to store dates as mysql dates, in which case they'd be stored as '2013-03-21 00:00:00')
12
- * Sometimes these values are the same, but often they are not. When your client code is using a model's functions, you need to be aware
13
- * which domain your data exists in. If it is client-code values (ie, it hasn't had a EE_Model_Field call prepare_for_set on it) then use the
14
- * model functions as normal. However, if you are calling the model functions with values from the model object domain (ie, the code your writing is
15
- * probably within a model object, and all the values you're dealing with have had an EE_Model_Field call prepare_for_set on them), then you'll want
16
- * to set $values_already_prepared_by_model_object to FALSE within the argument-list of the functions you call (in order to avoid re-processing those values).
17
- * If your values are already in the database values domain, you'll either way to convert them into the model object domain by creating model objects
18
- * from those raw db values (ie,using EEM_Base::_create_objects), or just use $wpdb directly.
19
- *
20
- * @package 			Event Espresso
21
- * @subpackage 	core
22
- * @author 				Michael Nelson
23
- * @since 				EE4
24
- *
25
- */
3
+	 *
4
+	 * Class EEM_Base
5
+	 *
6
+	 * Multi-table model. Especially handles joins when querying.
7
+	 * An important note about values dealt with in models and model objects:
8
+	 * values used by models exist in basically 3 different domains, which the EE_Model_Fields help convert between:
9
+	 * 1. Client-code values (eg, controller code may refer to a date as "March 21, 2013")
10
+	 * 2. Model object values (eg, after the model object has called set() on the value and saves it onto the model object, it may become a unix timestamp, eg 12312412412)
11
+	 * 3. Database values (eg, we may later decide to store dates as mysql dates, in which case they'd be stored as '2013-03-21 00:00:00')
12
+	 * Sometimes these values are the same, but often they are not. When your client code is using a model's functions, you need to be aware
13
+	 * which domain your data exists in. If it is client-code values (ie, it hasn't had a EE_Model_Field call prepare_for_set on it) then use the
14
+	 * model functions as normal. However, if you are calling the model functions with values from the model object domain (ie, the code your writing is
15
+	 * probably within a model object, and all the values you're dealing with have had an EE_Model_Field call prepare_for_set on them), then you'll want
16
+	 * to set $values_already_prepared_by_model_object to FALSE within the argument-list of the functions you call (in order to avoid re-processing those values).
17
+	 * If your values are already in the database values domain, you'll either way to convert them into the model object domain by creating model objects
18
+	 * from those raw db values (ie,using EEM_Base::_create_objects), or just use $wpdb directly.
19
+	 *
20
+	 * @package 			Event Espresso
21
+	 * @subpackage 	core
22
+	 * @author 				Michael Nelson
23
+	 * @since 				EE4
24
+	 *
25
+	 */
26 26
 abstract class EEM_Base extends EE_Base{
27 27
 
28 28
 	//admin posty
@@ -578,10 +578,10 @@  discard block
 block discarded – undo
578 578
 	 	$stati = EEM_Status::instance()->get_all(array(array('STS_type' => $status_type) ) );
579 579
 	 	$status_array = array();
580 580
 	 	foreach ( $stati as $status ) {
581
-            $status_array[ $status->ID() ] = $status->get('STS_code');
582
-        }
583
-        return $translated ? EEM_Status::instance()->localized_status($status_array, FALSE, 'sentence') : $status_array;
584
-    }
581
+			$status_array[ $status->ID() ] = $status->get('STS_code');
582
+		}
583
+		return $translated ? EEM_Status::instance()->localized_status($status_array, FALSE, 'sentence') : $status_array;
584
+	}
585 585
 
586 586
 
587 587
 
Please login to merge, or discard this patch.
Doc Comments   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -741,7 +741,7 @@  discard block
 block discarded – undo
741 741
 	 * Returns the name of the field's name that points to the WP_User table
742 742
 	 *  on this model (or follows the _model_chain_to_wp_user and uses that model's
743 743
 	 * foreign key to the WP_User table)
744
-	 * @return string|boolean string on success, boolean false when there is no
744
+	 * @return string|false string on success, boolean false when there is no
745 745
 	 * foreign key to the WP_User table
746 746
 	 */
747 747
 	function wp_user_field_name() {
@@ -837,6 +837,7 @@  discard block
 block discarded – undo
837 837
 	 * If you would like to use these custom selections in WHERE, GROUP_BY, or HAVING clauses, you must instead provide an array.
838 838
 	 * Array keys are the aliases used to refer to this selection, and values are to be numerically-indexed arrays, where 0 is the selection
839 839
 	 * and 1 is the data type. Eg, array('count'=>array('COUNT(REG_ID)','%d'))
840
+	 * @param string $columns_to_select
840 841
 	 * @return stdClass[] like results of $wpdb->get_results($sql,OBJECT), (ie, output type is OBJECT)
841 842
 	 */
842 843
 	public function  get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null){
@@ -1139,7 +1140,7 @@  discard block
 block discarded – undo
1139 1140
 	 * @param bool   $pretty          Whether to return the pretty formats (true) or not (false).
1140 1141
 	 * @throws EE_Error   If the given field_name is not of the EE_Datetime_Field type.
1141 1142
 	 *
1142
-	 * @return array formats in an array with the date format first, and the time format last.
1143
+	 * @return string[] formats in an array with the date format first, and the time format last.
1143 1144
 	 */
1144 1145
 	public function get_formats_for( $field_name, $pretty = false ) {
1145 1146
 		$field_settings = $this->field_settings_for( $field_name );
@@ -1174,7 +1175,7 @@  discard block
 block discarded – undo
1174 1175
 	 *
1175 1176
 	 * @throws EE_Error   	If the given field_name is not of the EE_Datetime_Field type.
1176 1177
 	 *
1177
-	 * @return int|string  If the given field_name is not of the EE_Datetime_Field type, then an EE_Error
1178
+	 * @return string|null  If the given field_name is not of the EE_Datetime_Field type, then an EE_Error
1178 1179
 	 *                    	     exception is triggered.
1179 1180
 	 */
1180 1181
 	public function current_time_for_query( $field_name, $timestamp = false, $what = 'both' ) {
@@ -1474,7 +1475,7 @@  discard block
 block discarded – undo
1474 1475
 	 * Deletes a single row from the DB given the model object's primary key value. (eg, EE_Attendee->ID()'s value).
1475 1476
 	 * Wrapper for EEM_Base::delete()
1476 1477
 	 * @param mixed $id
1477
-	 * @return boolean whether the row got deleted or not
1478
+	 * @return integer whether the row got deleted or not
1478 1479
 	 */
1479 1480
 	public function delete_by_ID( $id ){
1480 1481
 		return $this->delete( array(
@@ -1834,7 +1835,7 @@  discard block
 block discarded – undo
1834 1835
 	/**
1835 1836
 	 * Verifies the EE addons' database is up-to-date and records that we've done it on
1836 1837
 	 * EEM_Base::$_db_verification_level
1837
-	 * @param $wpdb_method
1838
+	 * @param string $wpdb_method
1838 1839
 	 * @param $arguments_to_provide
1839 1840
 	 * @return string
1840 1841
 	 */
@@ -1902,7 +1903,6 @@  discard block
 block discarded – undo
1902 1903
 	 * 'hasAndBelongsToMany' relationships: checks that there isn't already an entry in the join table, and adds one.
1903 1904
 	 * If one of the model Objects has not yet been saved to the database, it is saved before adding the entry in the join table
1904 1905
 	 *
1905
-	 * @param EE_Base_Class/int $thisModelObject
1906 1906
 	 * @param EE_Base_Class/int $id_or_obj EE_base_Class or ID of other Model Object
1907 1907
 	 * @param string $relationName, key in EEM_Base::_relations
1908 1908
 	 * an attendee to a group, you also want to specify which role they will have in that group. So you would use this parameter to specify array('role-column-name'=>'role-id')
@@ -1924,8 +1924,8 @@  discard block
 block discarded – undo
1924 1924
 	 *
1925 1925
 	 * 'hasAndBelongsToMany' relationships:removes any existing entry in the join table between the two models.
1926 1926
 	 *
1927
-	 * @param EE_Base_Class/int $id_or_obj
1928
-	 * @param EE_Base_Class/int $other_model_id_or_obj EE_Base_Class or ID of other Model Object
1927
+	 * @param EE_CPT_Base $id_or_obj
1928
+	 * @param EE_Term_Taxonomy $other_model_id_or_obj EE_Base_Class or ID of other Model Object
1929 1929
 	 * @param string $relationName key in EEM_Base::_relations
1930 1930
 	 * @return boolean of success
1931 1931
 	 * @param array   $where_query This allows you to enter further query params for the relation to for relation to methods that allow you to further specify extra columns to join by (such as HABTM).  Keep in mind that the only acceptable query_params is strict "col" => "value" pairs because these will be inserted in any new rows created as well.
@@ -2001,7 +2001,7 @@  discard block
 block discarded – undo
2001 2001
 	/**
2002 2002
 	 * Instead of getting the related model objects, simply counts them. Ignores default_where_conditions by default,
2003 2003
 	 * unless otherwise specified in the $query_params
2004
-	 * @param int/EE_Base_Class $id_or_obj
2004
+	 * @param EE_Event $id_or_obj
2005 2005
 	 * @param string $model_name like 'Event', or 'Registration'
2006 2006
 	 * @param array $query_params like EEM_Base::get_all's
2007 2007
 	 * @param string $field_to_count name of field to count by. By default, uses primary key
@@ -2390,7 +2390,7 @@  discard block
 block discarded – undo
2390 2390
 	/**
2391 2391
 	 * Finds all the fields that correspond to the given table
2392 2392
 	 * @param string $table_alias, array key in EEM_Base::_tables
2393
-	 * @return EE_Model_Field_Base[]
2393
+	 * @return EE_Model_Field_Base
2394 2394
 	 */
2395 2395
 	function _get_fields_for_table($table_alias){
2396 2396
 		return $this->_fields[$table_alias];
@@ -3454,8 +3454,8 @@  discard block
 block discarded – undo
3454 3454
 	/**
3455 3455
 	 * gets the field object of type 'primary_key' from the fieldsSettings attribute.
3456 3456
 	 * Eg, on EE_Answer that would be ANS_ID field object
3457
-	 * @param $field_obj
3458
-	 * @return EE_Model_Field_Base
3457
+	 * @param EE_Model_Field_Base $field_obj
3458
+	 * @return boolean
3459 3459
 	 */
3460 3460
 	public function is_primary_key_field( $field_obj ){
3461 3461
 		return $field_obj instanceof EE_Primary_Key_Field_Base ? TRUE : FALSE;
@@ -3549,7 +3549,7 @@  discard block
 block discarded – undo
3549 3549
 	 * Gets the actual table for the table alias
3550 3550
 	 * @param string $table_alias eg Event, Event_Meta, Registration, Transaction, but maybe
3551 3551
 	 * a table alias with a model chain prefix, like 'Venue__Event_Venue___Event_Meta'. Either one works
3552
-	 * @return EE_Table_Base
3552
+	 * @return string
3553 3553
 	 */
3554 3554
 	function get_table_for_alias($table_alias){
3555 3555
 		$table_alias_sans_model_relation_chain_prefix = EE_Model_Parser::remove_table_alias_model_relation_chain_prefix($table_alias);
@@ -3676,7 +3676,7 @@  discard block
 block discarded – undo
3676 3676
 	 * The purpose of this method is to allow us to create a model object that is not in the db that holds default values.
3677 3677
 	 * A typical example of where this is used is when creating a new item and the initial load of a form.  We dont' necessarily want to test for if the object is present but just assume it is BUT load the defaults from the object (as set in the model_field!).
3678 3678
 	 *
3679
-	 * @return EE_Base_Class single EE_Base_Class object with default values for the properties.
3679
+	 * @return boolean single EE_Base_Class object with default values for the properties.
3680 3680
 	 */
3681 3681
 	public function create_default_object() {
3682 3682
 
@@ -4066,7 +4066,7 @@  discard block
 block discarded – undo
4066 4066
 	}
4067 4067
 	/**
4068 4068
 	 * Read comments for assume_values_already_prepared_by_model_object()
4069
-	 * @return int
4069
+	 * @return boolean
4070 4070
 	 */
4071 4071
 	public function get_assumption_concerning_values_already_prepared_by_model_object(){
4072 4072
 		return $this->_values_already_prepared_by_model_object;
Please login to merge, or discard this patch.
Spacing   +945 added lines, -945 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  * @since 				EE4
24 24
  *
25 25
  */
26
-abstract class EEM_Base extends EE_Base{
26
+abstract class EEM_Base extends EE_Base {
27 27
 
28 28
 	//admin posty
29 29
 	//basic -> grants access to mine -> if they don't have it, select none
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
 	 * Flag indicating whether this model has a primary key or not
229 229
 	 * @var boolean
230 230
 	 */
231
-	protected $_has_primary_key_field=null;
231
+	protected $_has_primary_key_field = null;
232 232
 
233 233
 	/**
234 234
 	 * Whether or not this model is based off a table in WP core only (CPTs should set
@@ -283,19 +283,19 @@  discard block
 block discarded – undo
283 283
 	 * operators that work like 'BETWEEN'.  Typically used for datetime calculations, i.e. "BETWEEN '12-1-2011' AND '12-31-2012'"
284 284
 	 * @var array
285 285
 	 */
286
-	protected $_between_style_operators = array( 'BETWEEN' );
286
+	protected $_between_style_operators = array('BETWEEN');
287 287
 
288 288
 	/**
289 289
 	 * operators that are used for handling NUll and !NULL queries.  Typically used for when checking if a row exists on a join table.
290 290
 	 * @var array
291 291
 	 */
292
-	protected $_null_style_operators = array( 'IS NOT NULL', 'IS NULL');
292
+	protected $_null_style_operators = array('IS NOT NULL', 'IS NULL');
293 293
 
294 294
 	/**
295 295
 	 * Allowed values for $query_params['order'] for ordering in queries
296 296
 	 * @var array
297 297
 	 */
298
-	protected $_allowed_order_values = array('asc','desc','ASC','DESC');
298
+	protected $_allowed_order_values = array('asc', 'desc', 'ASC', 'DESC');
299 299
 
300 300
 	/**
301 301
 	 * When these are keys in a WHERE or HAVING clause, they are handled much differently
@@ -309,13 +309,13 @@  discard block
 block discarded – undo
309 309
 	 * 'where', but 'where' clauses are so common that we thought we'd omit it
310 310
 	 * @var array
311 311
 	 */
312
-	private $_allowed_query_params = array(0, 'limit','order_by','group_by','having','force_join','order','on_join_limit','default_where_conditions', 'caps');
312
+	private $_allowed_query_params = array(0, 'limit', 'order_by', 'group_by', 'having', 'force_join', 'order', 'on_join_limit', 'default_where_conditions', 'caps');
313 313
 
314 314
 	/**
315 315
 	 * All the data types that can be used in $wpdb->prepare statements.
316 316
 	 * @var array
317 317
 	 */
318
-	private $_valid_wpdb_data_types = array('%d','%s','%f');
318
+	private $_valid_wpdb_data_types = array('%d', '%s', '%f');
319 319
 
320 320
 	/**
321 321
 	 * 	EE_Registry Object
@@ -348,17 +348,17 @@  discard block
 block discarded – undo
348 348
 	/**
349 349
 	 * constant used to show EEM_Base has not yet verified the db on this http request
350 350
 	 */
351
-	const db_verified_none 		= 0;
351
+	const db_verified_none = 0;
352 352
 	/**
353 353
 	 * constant used to show EEM_Base has verified the EE core db on this http request,
354 354
 	 * but not the addons' dbs
355 355
 	 */
356
-	const db_verified_core 		= 1;
356
+	const db_verified_core = 1;
357 357
 	/**
358 358
 	 * constant used to show EEM_Base has verified the addons' dbs (and implicitly
359 359
 	 * the EE core db too)
360 360
 	 */
361
-	const db_verified_addons 	= 2;
361
+	const db_verified_addons = 2;
362 362
 
363 363
 	/**
364 364
 	 * indicates whether an EEM_Base child has already re-verified the DB
@@ -389,13 +389,13 @@  discard block
 block discarded – undo
389 389
 	 * @param null $timezone
390 390
 	 * @throws \EE_Error
391 391
 	 */
392
-	protected function __construct( $timezone = NULL ){
392
+	protected function __construct($timezone = NULL) {
393 393
 		// check that the model has not been loaded too soon
394
-		if ( ! did_action( 'AHEE__EE_System__load_espresso_addons' )) {
395
-			throw new EE_Error (
394
+		if ( ! did_action('AHEE__EE_System__load_espresso_addons')) {
395
+			throw new EE_Error(
396 396
 				sprintf(
397
-					__( 'The %1$s model can not be loaded before the "AHEE__EE_System__load_espresso_addons" hook has been called. This gives other addons a chance to extend this model.', 'event_espresso' ),
398
-					get_class( $this )
397
+					__('The %1$s model can not be loaded before the "AHEE__EE_System__load_espresso_addons" hook has been called. This gives other addons a chance to extend this model.', 'event_espresso'),
398
+					get_class($this)
399 399
 				)
400 400
 			);
401 401
 		}
@@ -405,11 +405,11 @@  discard block
 block discarded – undo
405 405
 		 * just use EE_Register_Model_Extension
406 406
 		 * @var EE_Table_Base[] $_tables
407 407
 		 */
408
-		$this->_tables = apply_filters( 'FHEE__'.get_class($this).'__construct__tables', $this->_tables );
409
-		foreach($this->_tables as $table_alias => $table_obj){
408
+		$this->_tables = apply_filters('FHEE__'.get_class($this).'__construct__tables', $this->_tables);
409
+		foreach ($this->_tables as $table_alias => $table_obj) {
410 410
 			/** @var $table_obj EE_Table_Base */
411 411
 			$table_obj->_construct_finalize_with_alias($table_alias);
412
-			if( $table_obj instanceof EE_Secondary_Table ){
412
+			if ($table_obj instanceof EE_Secondary_Table) {
413 413
 				/** @var $table_obj EE_Secondary_Table */
414 414
 				$table_obj->_construct_finalize_set_table_to_join_with($this->_get_main_table());
415 415
 			}
@@ -419,48 +419,48 @@  discard block
 block discarded – undo
419 419
 		 * EE_Register_Model_Extension
420 420
 		 * @param EE_Model_Field_Base[] $_fields
421 421
 		 */
422
-		$this->_fields = apply_filters('FHEE__'.get_class($this).'__construct__fields',$this->_fields);
423
-		foreach($this->_fields as $table_alias => $fields_for_table){
424
-			if ( ! array_key_exists( $table_alias, $this->_tables )){
425
-				throw new EE_Error(sprintf(__("Table alias %s does not exist in EEM_Base child's _tables array. Only tables defined are %s",'event_espresso'),$table_alias,implode(",",$this->_fields)));
422
+		$this->_fields = apply_filters('FHEE__'.get_class($this).'__construct__fields', $this->_fields);
423
+		foreach ($this->_fields as $table_alias => $fields_for_table) {
424
+			if ( ! array_key_exists($table_alias, $this->_tables)) {
425
+				throw new EE_Error(sprintf(__("Table alias %s does not exist in EEM_Base child's _tables array. Only tables defined are %s", 'event_espresso'), $table_alias, implode(",", $this->_fields)));
426 426
 			}
427
-			foreach($fields_for_table as $field_name => $field_obj){
427
+			foreach ($fields_for_table as $field_name => $field_obj) {
428 428
 				/** @var $field_obj EE_Model_Field_Base | EE_Primary_Key_Field_Base */
429 429
 				//primary key field base has a slightly different _construct_finalize
430 430
 				/** @var $field_obj EE_Model_Field_Base */
431
-				$field_obj->_construct_finalize( $table_alias, $field_name, $this->get_this_model_name() );
431
+				$field_obj->_construct_finalize($table_alias, $field_name, $this->get_this_model_name());
432 432
 			}
433 433
 		}
434 434
 
435 435
 		// everything is related to Extra_Meta
436
-		if( get_class($this) != 'EEM_Extra_Meta'){
436
+		if (get_class($this) != 'EEM_Extra_Meta') {
437 437
 			//make extra meta related to everything, but don't block deleting things just
438 438
 			//because they have related extra meta info. For now just orphan those extra meta
439 439
 			//in the future we should automatically delete them
440
-			$this->_model_relations['Extra_Meta'] = new EE_Has_Many_Any_Relation( FALSE );
440
+			$this->_model_relations['Extra_Meta'] = new EE_Has_Many_Any_Relation(FALSE);
441 441
 		}
442 442
 		//and change logs
443
-		if( get_class( $this) !=  'EEM_Change_Log' ) {
444
-			$this->_model_relations[ 'Change_Log' ] = new EE_Has_Many_Any_Relation( FALSE );
443
+		if (get_class($this) != 'EEM_Change_Log') {
444
+			$this->_model_relations['Change_Log'] = new EE_Has_Many_Any_Relation(FALSE);
445 445
 		}
446 446
 		/**
447 447
 		 * Filters the list of relations on a model. It is best to NOT use this directly and instead just use
448 448
 		 * EE_Register_Model_Extension
449 449
 		 * @param EE_Model_Relation_Base[] $_model_relations
450 450
 		 */
451
-		$this->_model_relations = apply_filters('FHEE__'.get_class($this).'__construct__model_relations',$this->_model_relations);
452
-		foreach($this->_model_relations as $model_name => $relation_obj){
451
+		$this->_model_relations = apply_filters('FHEE__'.get_class($this).'__construct__model_relations', $this->_model_relations);
452
+		foreach ($this->_model_relations as $model_name => $relation_obj) {
453 453
 			/** @var $relation_obj EE_Model_Relation_Base */
454 454
 			$relation_obj->_construct_finalize_set_models($this->get_this_model_name(), $model_name);
455 455
 		}
456
-		foreach($this->_indexes as $index_name => $index_obj){
456
+		foreach ($this->_indexes as $index_name => $index_obj) {
457 457
 			/** @var $index_obj EE_Index */
458 458
 			$index_obj->_construct_finalize($index_name, $this->get_this_model_name());
459 459
 		}
460 460
 
461 461
 		$this->set_timezone($timezone);
462 462
 		//finalize default where condition strategy, or set default
463
-		if( ! $this->_default_where_conditions_strategy){
463
+		if ( ! $this->_default_where_conditions_strategy) {
464 464
 			//nothing was set during child constructor, so set default
465 465
 			$this->_default_where_conditions_strategy = new EE_Default_Where_Conditions();
466 466
 		}
@@ -468,15 +468,15 @@  discard block
 block discarded – undo
468 468
 
469 469
 		//if the cap slug hasn't been set, and we haven't set it to false on purpose
470 470
 		//to indicate to NOT set it, set it to the logical default
471
-		if( $this->_caps_slug === null ) {
472
-			EE_Registry::instance()->load_helper( 'Inflector' );
473
-			$this->_caps_slug = EEH_Inflector::pluralize_and_lower( $this->get_this_model_name() );
471
+		if ($this->_caps_slug === null) {
472
+			EE_Registry::instance()->load_helper('Inflector');
473
+			$this->_caps_slug = EEH_Inflector::pluralize_and_lower($this->get_this_model_name());
474 474
 		}
475 475
 		//initialize the standard cap restriction generators if none were specified by the child constructor
476
-		if( $this->_cap_restriction_generators !== false ){
477
-			foreach( $this->cap_contexts_to_cap_action_map() as $cap_context => $action ){
478
-				if( ! isset( $this->_cap_restriction_generators[ $cap_context ] ) ) {
479
-					$this->_cap_restriction_generators[ $cap_context ] = apply_filters(
476
+		if ($this->_cap_restriction_generators !== false) {
477
+			foreach ($this->cap_contexts_to_cap_action_map() as $cap_context => $action) {
478
+				if ( ! isset($this->_cap_restriction_generators[$cap_context])) {
479
+					$this->_cap_restriction_generators[$cap_context] = apply_filters(
480 480
 						'FHEE__EEM_Base___construct__standard_cap_restriction_generator',
481 481
 						new EE_Restriction_Generator_Protected(),
482 482
 						$cap_context,
@@ -486,23 +486,23 @@  discard block
 block discarded – undo
486 486
 			}
487 487
 		}
488 488
 		//if there are cap restriction generators, use them to make the default cap restrictions
489
-		if( $this->_cap_restriction_generators !== false ){
490
-			foreach( $this->_cap_restriction_generators as $context => $generator_object ) {
491
-				if( ! $generator_object ){
489
+		if ($this->_cap_restriction_generators !== false) {
490
+			foreach ($this->_cap_restriction_generators as $context => $generator_object) {
491
+				if ( ! $generator_object) {
492 492
 					continue;
493 493
 				}
494
-				if( ! $generator_object instanceof EE_Restriction_Generator_Base ){
494
+				if ( ! $generator_object instanceof EE_Restriction_Generator_Base) {
495 495
 					throw new EE_Error(
496 496
 						sprintf(
497
-							__( 'Index "%1$s" in the model %2$s\'s _cap_restriction_generators is not a child of EE_Restriction_Generator_Base. It should be that or NULL.', 'event_espresso' ),
497
+							__('Index "%1$s" in the model %2$s\'s _cap_restriction_generators is not a child of EE_Restriction_Generator_Base. It should be that or NULL.', 'event_espresso'),
498 498
 							$context,
499 499
 							$this->get_this_model_name()
500 500
 						)
501 501
 					);
502 502
 				}
503
-				$action = $this->cap_action_for_context( $context );
504
-				if( ! $generator_object->construction_finalized() ){
505
-					$generator_object->_construct_finalize( $this, $action );
503
+				$action = $this->cap_action_for_context($context);
504
+				if ( ! $generator_object->construction_finalized()) {
505
+					$generator_object->_construct_finalize($this, $action);
506 506
 				}
507 507
 
508 508
 			}
@@ -516,11 +516,11 @@  discard block
 block discarded – undo
516 516
 	 * @param string $context one of EEM_Base::valid_cap_contexts()
517 517
 	 * @return EE_Default_Where_Conditions[]
518 518
 	 */
519
-	protected function _generate_cap_restrictions( $context ){
520
-		if( isset( $this->_cap_restriction_generators[ $context ] ) &&
521
-				$this->_cap_restriction_generators[ $context ] instanceof EE_Restriction_Generator_Base ) {
522
-			return $this->_cap_restriction_generators[ $context ]->generate_restrictions();
523
-		}else{
519
+	protected function _generate_cap_restrictions($context) {
520
+		if (isset($this->_cap_restriction_generators[$context]) &&
521
+				$this->_cap_restriction_generators[$context] instanceof EE_Restriction_Generator_Base) {
522
+			return $this->_cap_restriction_generators[$context]->generate_restrictions();
523
+		} else {
524 524
 			return array();
525 525
 		}
526 526
 }
@@ -533,16 +533,16 @@  discard block
 block discarded – undo
533 533
 	 *		@param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved).  Note this just sends the timezone info to the date time model field objects.  Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option)
534 534
 	 *		@return static (as in the concrete child class)
535 535
 	 */
536
-	public static function instance( $timezone = NULL ){
536
+	public static function instance($timezone = NULL) {
537 537
 
538 538
 		// check if instance of Espresso_model already exists
539 539
 		if ( ! static::$_instance instanceof static) {
540 540
 			// instantiate Espresso_model
541
-			static::$_instance = new static( $timezone );
541
+			static::$_instance = new static($timezone);
542 542
 		}
543 543
 
544 544
 		//we might have a timezone set, let set_timezone decide what to do with it
545
-		static::$_instance->set_timezone( $timezone );
545
+		static::$_instance->set_timezone($timezone);
546 546
 
547 547
 		// Espresso_model object
548 548
 		return static::$_instance;
@@ -555,11 +555,11 @@  discard block
 block discarded – undo
555 555
 	 * @param null | string $timezone
556 556
 	 * @return static
557 557
 	 */
558
-	public static function reset(  $timezone = NULL ){
559
-		if ( ! is_null( static::$_instance ) ) {
558
+	public static function reset($timezone = NULL) {
559
+		if ( ! is_null(static::$_instance)) {
560 560
 			static::$_instance = null;
561 561
 
562
-			return self::instance( $timezone );
562
+			return self::instance($timezone);
563 563
 		}
564 564
 		return null;
565 565
 	}
@@ -570,15 +570,15 @@  discard block
 block discarded – undo
570 570
 	 * @param  boolean $translated return localized strings or JUST the array.
571 571
 	 * @return array
572 572
 	 */
573
-	 public function status_array( $translated = FALSE ) {
574
-	 	if ( !array_key_exists('Status', $this->_model_relations ) )
573
+	 public function status_array($translated = FALSE) {
574
+	 	if ( ! array_key_exists('Status', $this->_model_relations))
575 575
 	 		return array();
576 576
 	 	$model_name = $this->get_this_model_name();
577
-	 	$status_type = str_replace(' ', '_', strtolower( str_replace('_', ' ', $model_name) ) );
578
-	 	$stati = EEM_Status::instance()->get_all(array(array('STS_type' => $status_type) ) );
577
+	 	$status_type = str_replace(' ', '_', strtolower(str_replace('_', ' ', $model_name)));
578
+	 	$stati = EEM_Status::instance()->get_all(array(array('STS_type' => $status_type)));
579 579
 	 	$status_array = array();
580
-	 	foreach ( $stati as $status ) {
581
-            $status_array[ $status->ID() ] = $status->get('STS_code');
580
+	 	foreach ($stati as $status) {
581
+            $status_array[$status->ID()] = $status->get('STS_code');
582 582
         }
583 583
         return $translated ? EEM_Status::instance()->localized_status($status_array, FALSE, 'sentence') : $status_array;
584 584
     }
@@ -719,7 +719,7 @@  discard block
 block discarded – undo
719 719
 	 *			'order_by'=>array('ANS_value'=>'ASC')
720 720
 	 *		));
721 721
 	 */
722
-	function get_all($query_params = array()){
722
+	function get_all($query_params = array()) {
723 723
 		return $this->_create_objects($this->_get_all_wpdb_results($query_params, ARRAY_A, NULL));
724 724
 	}
725 725
 
@@ -729,10 +729,10 @@  discard block
 block discarded – undo
729 729
 	 * @param array $query_params @see EEM_Base::get_all()
730 730
 	 * @return array like EEM_Base::get_all
731 731
 	 */
732
-	function alter_query_params_to_only_include_mine( $query_params = array() ) {
732
+	function alter_query_params_to_only_include_mine($query_params = array()) {
733 733
 		$wp_user_field_name = $this->wp_user_field_name();
734
-		if( $wp_user_field_name ){
735
-			$query_params[0][ $wp_user_field_name ] = get_current_user_id();
734
+		if ($wp_user_field_name) {
735
+			$query_params[0][$wp_user_field_name] = get_current_user_id();
736 736
 		}
737 737
 		return $query_params;
738 738
 	}
@@ -745,19 +745,19 @@  discard block
 block discarded – undo
745 745
 	 * foreign key to the WP_User table
746 746
 	 */
747 747
 	function wp_user_field_name() {
748
-		try{
749
-			if( ! empty( $this->_model_chain_to_wp_user ) ) {
750
-				$models_to_follow_to_wp_users = explode( '.', $this->_model_chain_to_wp_user );
751
-				$last_model_name = end( $models_to_follow_to_wp_users );
752
-				$model_with_fk_to_wp_users = EE_Registry::instance()->load_model( $last_model_name );
753
-				$model_chain_to_wp_user = $this->_model_chain_to_wp_user . '.';
754
-			}else{
748
+		try {
749
+			if ( ! empty($this->_model_chain_to_wp_user)) {
750
+				$models_to_follow_to_wp_users = explode('.', $this->_model_chain_to_wp_user);
751
+				$last_model_name = end($models_to_follow_to_wp_users);
752
+				$model_with_fk_to_wp_users = EE_Registry::instance()->load_model($last_model_name);
753
+				$model_chain_to_wp_user = $this->_model_chain_to_wp_user.'.';
754
+			} else {
755 755
 				$model_with_fk_to_wp_users = $this;
756 756
 				$model_chain_to_wp_user = '';
757 757
 			}
758
-			$wp_user_field = $model_with_fk_to_wp_users->get_foreign_key_to( 'WP_User' );
759
-			return $model_chain_to_wp_user . $wp_user_field->get_name();
760
-		}catch( EE_Error $e ) {
758
+			$wp_user_field = $model_with_fk_to_wp_users->get_foreign_key_to('WP_User');
759
+			return $model_chain_to_wp_user.$wp_user_field->get_name();
760
+		} catch (EE_Error $e) {
761 761
 			return false;
762 762
 		}
763 763
 	}
@@ -771,7 +771,7 @@  discard block
 block discarded – undo
771 771
 	 * (or transietly-related model)
772 772
 	 * @return string
773 773
 	 */
774
-	public function model_chain_to_wp_user(){
774
+	public function model_chain_to_wp_user() {
775 775
 		return $this->_model_chain_to_wp_user;
776 776
 	}
777 777
 
@@ -783,13 +783,13 @@  discard block
 block discarded – undo
783 783
 	 * @return boolean
784 784
 	 */
785 785
 	public function is_owned() {
786
-		if( $this->model_chain_to_wp_user() ){
786
+		if ($this->model_chain_to_wp_user()) {
787 787
 			return true;
788
-		}else{
789
-			try{
790
-				$this->get_foreign_key_to( 'WP_User' );
788
+		} else {
789
+			try {
790
+				$this->get_foreign_key_to('WP_User');
791 791
 				return true;
792
-			}catch( EE_Error $e ){
792
+			} catch (EE_Error $e) {
793 793
 				return false;
794 794
 			}
795 795
 		}
@@ -808,21 +808,21 @@  discard block
 block discarded – undo
808 808
 	 * and 1 is the data type. Eg, array('count'=>array('COUNT(REG_ID)','%d'))
809 809
 	 * @return array|stdClass[] like results of $wpdb->get_results($sql,OBJECT), (ie, output type is OBJECT)
810 810
 	 */
811
-	protected function  _get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null){
811
+	protected function  _get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null) {
812 812
 		//remember the custom selections, if any
813
-		if(is_array($columns_to_select)){
813
+		if (is_array($columns_to_select)) {
814 814
 			$this->_custom_selections = $columns_to_select;
815
-		}elseif(is_string($columns_to_select)){
815
+		}elseif (is_string($columns_to_select)) {
816 816
 			$this->_custom_selections = array($this->_custom_selections);
817
-		}else{
817
+		} else {
818 818
 			$this->_custom_selections = array();
819 819
 		}
820 820
 
821 821
 		$model_query_info = $this->_create_model_query_info_carrier($query_params);
822 822
 		$select_expressions = $columns_to_select ? $this->_construct_select_from_input($columns_to_select) : $this->_construct_default_select_sql($model_query_info);
823
-		$SQL ="SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info);
823
+		$SQL = "SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info);
824 824
 //		echo "sql:$SQL";
825
-		$results =  $this->_do_wpdb_query( 'get_results', array($SQL, $output ) );// $wpdb->get_results($SQL, $output);
825
+		$results = $this->_do_wpdb_query('get_results', array($SQL, $output)); // $wpdb->get_results($SQL, $output);
826 826
 		return $results;
827 827
 	}
828 828
 
@@ -839,7 +839,7 @@  discard block
 block discarded – undo
839 839
 	 * and 1 is the data type. Eg, array('count'=>array('COUNT(REG_ID)','%d'))
840 840
 	 * @return stdClass[] like results of $wpdb->get_results($sql,OBJECT), (ie, output type is OBJECT)
841 841
 	 */
842
-	public function  get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null){
842
+	public function  get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null) {
843 843
 		return $this->_get_all_wpdb_results($query_params, $output, $columns_to_select);
844 844
 	}
845 845
 
@@ -851,21 +851,21 @@  discard block
 block discarded – undo
851 851
 	 * @throws EE_Error
852 852
 	 * @return string
853 853
 	 */
854
-	private function _construct_select_from_input($columns_to_select){
855
-		if(is_array($columns_to_select)){
854
+	private function _construct_select_from_input($columns_to_select) {
855
+		if (is_array($columns_to_select)) {
856 856
 			$select_sql_array = array();
857 857
 
858
-			foreach($columns_to_select as $alias => $selection_and_datatype){
859
-				if( ! is_array($selection_and_datatype) || ! isset($selection_and_datatype[1])){
860
-					throw new EE_Error(sprintf(__("Custom selection %s (alias %s) needs to be an array like array('COUNT(REG_ID)','%%d')", "event_espresso"),$selection_and_datatype,$alias));
858
+			foreach ($columns_to_select as $alias => $selection_and_datatype) {
859
+				if ( ! is_array($selection_and_datatype) || ! isset($selection_and_datatype[1])) {
860
+					throw new EE_Error(sprintf(__("Custom selection %s (alias %s) needs to be an array like array('COUNT(REG_ID)','%%d')", "event_espresso"), $selection_and_datatype, $alias));
861 861
 				}
862
-				if( ! in_array( $selection_and_datatype[1],$this->_valid_wpdb_data_types)){
863
-					throw new EE_Error(sprintf(__("Datatype %s (for selection '%s' and alias '%s') is not a valid wpdb datatype (eg %%s)", "event_espresso"),$selection_and_datatype[1],$selection_and_datatype[0],$alias,implode(",",$this->_valid_wpdb_data_types)));
862
+				if ( ! in_array($selection_and_datatype[1], $this->_valid_wpdb_data_types)) {
863
+					throw new EE_Error(sprintf(__("Datatype %s (for selection '%s' and alias '%s') is not a valid wpdb datatype (eg %%s)", "event_espresso"), $selection_and_datatype[1], $selection_and_datatype[0], $alias, implode(",", $this->_valid_wpdb_data_types)));
864 864
 				}
865 865
 				$select_sql_array[] = "{$selection_and_datatype[0]} AS $alias";
866 866
 			}
867
-			$columns_to_select_string = implode(", ",$select_sql_array);
868
-		}else{
867
+			$columns_to_select_string = implode(", ", $select_sql_array);
868
+		} else {
869 869
 			$columns_to_select_string = $columns_to_select;
870 870
 		}
871 871
 		return $columns_to_select_string;
@@ -878,7 +878,7 @@  discard block
 block discarded – undo
878 878
 	 * Convenient wrapper for getting the primary key field's name. Eg, on Registration, this would be 'REG_ID'
879 879
 	 * @return string
880 880
 	 */
881
-	function primary_key_name(){
881
+	function primary_key_name() {
882 882
 		return $this->get_primary_key_field()->get_name();
883 883
 	}
884 884
 
@@ -890,15 +890,15 @@  discard block
 block discarded – undo
890 890
 	 * @param mixed $id int or string, depending on the type of the model's primary key
891 891
 	 * @return EE_Base_Class
892 892
 	 */
893
-	function get_one_by_ID($id){
894
-		if( $this->get_from_entity_map( $id ) ){
895
-			return $this->get_from_entity_map( $id );
896
-		}elseif( $this->has_primary_key_field ( ) ) {
893
+	function get_one_by_ID($id) {
894
+		if ($this->get_from_entity_map($id)) {
895
+			return $this->get_from_entity_map($id);
896
+		}elseif ($this->has_primary_key_field( )) {
897 897
 			$primary_key_name = $this->get_primary_key_field()->get_name();
898 898
 			return $this->get_one(array(array($primary_key_name => $id)));
899
-		}else{
899
+		} else {
900 900
 			//no primary key, so the $id must be from the get_index_primary_key_string()
901
-			return $this->get_one( array( $this->parse_index_primary_key_string( $id ) ) );
901
+			return $this->get_one(array($this->parse_index_primary_key_string($id)));
902 902
 		}
903 903
 	}
904 904
 
@@ -909,16 +909,16 @@  discard block
 block discarded – undo
909 909
 	 * @param array $query_params like EEM_Base's $query_params variable.
910 910
 	 * @return EE_Base_Class | NULL
911 911
 	 */
912
-	function get_one($query_params = array()){
913
-		if( ! is_array( $query_params ) ){
914
-			EE_Error::doing_it_wrong('EEM_Base::get_one', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' );
912
+	function get_one($query_params = array()) {
913
+		if ( ! is_array($query_params)) {
914
+			EE_Error::doing_it_wrong('EEM_Base::get_one', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0');
915 915
 			$query_params = array();
916 916
 		}
917 917
 		$query_params['limit'] = 1;
918 918
 		$items = $this->get_all($query_params);
919
-		if(empty($items)){
919
+		if (empty($items)) {
920 920
 			return null;
921
-		}else{
921
+		} else {
922 922
 			return array_shift($items);
923 923
 		}
924 924
 	}
@@ -942,8 +942,8 @@  discard block
 block discarded – undo
942 942
 	 *
943 943
 	 * @return EE_Base_Class[]|array
944 944
 	 */
945
-	public function next_x( $current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) {
946
-		return $this->_get_consecutive( $current_field_value, '>', $field_to_order_by, $limit, $query_params, $columns_to_select );
945
+	public function next_x($current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) {
946
+		return $this->_get_consecutive($current_field_value, '>', $field_to_order_by, $limit, $query_params, $columns_to_select);
947 947
 	}
948 948
 
949 949
 
@@ -966,8 +966,8 @@  discard block
 block discarded – undo
966 966
 	 *
967 967
 	 * @return EE_Base_Class[]|array
968 968
 	 */
969
-	public function previous_x( $current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) {
970
-		return $this->_get_consecutive( $current_field_value, '<', $field_to_order_by, $limit, $query_params, $columns_to_select );
969
+	public function previous_x($current_field_value, $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) {
970
+		return $this->_get_consecutive($current_field_value, '<', $field_to_order_by, $limit, $query_params, $columns_to_select);
971 971
 	}
972 972
 
973 973
 
@@ -989,9 +989,9 @@  discard block
 block discarded – undo
989 989
 	 *
990 990
 	 * @return EE_Base_Class|null|array()
991 991
 	 */
992
-	public function next( $current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) {
993
-		$results = $this->_get_consecutive( $current_field_value, '>', $field_to_order_by, 1, $query_params, $columns_to_select );
994
-		return empty( $results ) ? null : reset( $results );
992
+	public function next($current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null) {
993
+		$results = $this->_get_consecutive($current_field_value, '>', $field_to_order_by, 1, $query_params, $columns_to_select);
994
+		return empty($results) ? null : reset($results);
995 995
 	}
996 996
 
997 997
 
@@ -1013,9 +1013,9 @@  discard block
 block discarded – undo
1013 1013
 	 *
1014 1014
 	 * @return EE_Base_Class|null|array()
1015 1015
 	 */
1016
-	public function previous( $current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) {
1017
-		$results = $this->_get_consecutive( $current_field_value, '<', $field_to_order_by, 1, $query_params, $columns_to_select );
1018
-		return empty( $results ) ? null : reset( $results );
1016
+	public function previous($current_field_value, $field_to_order_by = null, $query_params = array(), $columns_to_select = null) {
1017
+		$results = $this->_get_consecutive($current_field_value, '<', $field_to_order_by, 1, $query_params, $columns_to_select);
1018
+		return empty($results) ? null : reset($results);
1019 1019
 	}
1020 1020
 
1021 1021
 
@@ -1041,40 +1041,40 @@  discard block
 block discarded – undo
1041 1041
 	 * @return EE_Base_Class[]|array
1042 1042
 	 * @throws EE_Error
1043 1043
 	 */
1044
-	protected function _get_consecutive( $current_field_value, $operand = '>', $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) {
1044
+	protected function _get_consecutive($current_field_value, $operand = '>', $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) {
1045 1045
 		//if $field_to_order_by is empty then let's assume we're ordering by the primary key.
1046
-		if ( empty( $field_to_order_by ) ) {
1047
-			if ( $this->has_primary_key_field() ) {
1046
+		if (empty($field_to_order_by)) {
1047
+			if ($this->has_primary_key_field()) {
1048 1048
 				$field_to_order_by = $this->get_primary_key_field()->get_name();
1049 1049
 			} else {
1050 1050
 
1051
-				if ( WP_DEBUG ) {
1052
-					throw new EE_Error( __( 'EEM_Base::_get_consecutive() has been called with no $field_to_order_by argument and there is no primary key on the field.  Please provide the field you would like to use as the base for retrieving the next item(s).', 'event_espresso' ) );
1051
+				if (WP_DEBUG) {
1052
+					throw new EE_Error(__('EEM_Base::_get_consecutive() has been called with no $field_to_order_by argument and there is no primary key on the field.  Please provide the field you would like to use as the base for retrieving the next item(s).', 'event_espresso'));
1053 1053
 				}
1054
-				EE_Error::add_error( __('There was an error with the query.', 'event_espresso') );
1054
+				EE_Error::add_error(__('There was an error with the query.', 'event_espresso'));
1055 1055
 				return array();
1056 1056
 			}
1057 1057
 		}
1058 1058
 
1059
-		if( ! is_array( $query_params ) ){
1060
-			EE_Error::doing_it_wrong('EEM_Base::_get_consecutive', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' );
1059
+		if ( ! is_array($query_params)) {
1060
+			EE_Error::doing_it_wrong('EEM_Base::_get_consecutive', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0');
1061 1061
 			$query_params = array();
1062 1062
 		}
1063 1063
 
1064 1064
 		//let's add the where query param for consecutive look up.
1065
-		$query_params[0][ $field_to_order_by ] = array( $operand, $current_field_value );
1065
+		$query_params[0][$field_to_order_by] = array($operand, $current_field_value);
1066 1066
 		$query_params['limit'] = $limit;
1067 1067
 
1068 1068
 		//set direction
1069
-		$incoming_orderby = isset( $query_params['order_by'] ) ? $query_params['order_by'] : array();
1070
-		$query_params['order_by'] = $operand == '>' ? array( $field_to_order_by => 'ASC' ) + $incoming_orderby : array( $field_to_order_by => 'DESC') + $incoming_orderby;
1069
+		$incoming_orderby = isset($query_params['order_by']) ? $query_params['order_by'] : array();
1070
+		$query_params['order_by'] = $operand == '>' ? array($field_to_order_by => 'ASC') + $incoming_orderby : array($field_to_order_by => 'DESC') + $incoming_orderby;
1071 1071
 
1072 1072
 		//if $columns_to_select is empty then that means we're returning EE_Base_Class objects
1073
-		if ( empty( $columns_to_select ) ) {
1074
-			return $this->get_all( $query_params );
1073
+		if (empty($columns_to_select)) {
1074
+			return $this->get_all($query_params);
1075 1075
 		} else {
1076 1076
 			//getting just the fields
1077
-			return $this->_get_all_wpdb_results( $query_params, ARRAY_A, $columns_to_select );
1077
+			return $this->_get_all_wpdb_results($query_params, ARRAY_A, $columns_to_select);
1078 1078
 		}
1079 1079
 	}
1080 1080
 
@@ -1085,18 +1085,18 @@  discard block
 block discarded – undo
1085 1085
 	 * This sets the _timezone property after model object has been instantiated.
1086 1086
 	 * @param null | string $timezone valid PHP DateTimeZone timezone string
1087 1087
 	 */
1088
-	public function set_timezone( $timezone ) {
1089
-		if ( $timezone !== null ) {
1088
+	public function set_timezone($timezone) {
1089
+		if ($timezone !== null) {
1090 1090
 			$this->_timezone = $timezone;
1091 1091
 		}
1092 1092
 		//note we need to loop through relations and set the timezone on those objects as well.
1093
-		foreach ( $this->_model_relations as $relation ) {
1094
-			$relation->set_timezone( $timezone );
1093
+		foreach ($this->_model_relations as $relation) {
1094
+			$relation->set_timezone($timezone);
1095 1095
 		}
1096 1096
 		//and finally we do the same for any datetime fields
1097
-		foreach ( $this->_fields as $field ) {
1098
-			if ( $field instanceof EE_Datetime_Field ) {
1099
-				$field->set_timezone( $timezone );
1097
+		foreach ($this->_fields as $field) {
1098
+			if ($field instanceof EE_Datetime_Field) {
1099
+				$field->set_timezone($timezone);
1100 1100
 			}
1101 1101
 		}
1102 1102
 	}
@@ -1111,9 +1111,9 @@  discard block
 block discarded – undo
1111 1111
 	 */
1112 1112
 	public function get_timezone() {
1113 1113
 		//first validate if timezone is set.  If not, then let's set it be whatever is set on the model fields.
1114
-		if ( empty( $this->_timezone ) ) {
1115
-			foreach( $this->_fields as $field ) {
1116
-				if ( $field instanceof EE_Datetime_Field ) {
1114
+		if (empty($this->_timezone)) {
1115
+			foreach ($this->_fields as $field) {
1116
+				if ($field instanceof EE_Datetime_Field) {
1117 1117
 					$this->set_timezone($field->get_timezone());
1118 1118
 					break;
1119 1119
 				}
@@ -1121,9 +1121,9 @@  discard block
 block discarded – undo
1121 1121
 		}
1122 1122
 
1123 1123
 		//if timezone STILL empty then return the default timezone for the site.
1124
-		if ( empty( $this->_timezone ) ) {
1125
-			EE_Registry::instance()->load_helper( 'DTT_Helper' );
1126
-			$this->set_timezone( EEH_DTT_Helper::get_timezone() );
1124
+		if (empty($this->_timezone)) {
1125
+			EE_Registry::instance()->load_helper('DTT_Helper');
1126
+			$this->set_timezone(EEH_DTT_Helper::get_timezone());
1127 1127
 		}
1128 1128
 		return $this->_timezone;
1129 1129
 	}
@@ -1141,19 +1141,19 @@  discard block
 block discarded – undo
1141 1141
 	 *
1142 1142
 	 * @return array formats in an array with the date format first, and the time format last.
1143 1143
 	 */
1144
-	public function get_formats_for( $field_name, $pretty = false ) {
1145
-		$field_settings = $this->field_settings_for( $field_name );
1144
+	public function get_formats_for($field_name, $pretty = false) {
1145
+		$field_settings = $this->field_settings_for($field_name);
1146 1146
 
1147 1147
 		//if not a valid EE_Datetime_Field then throw error
1148
-		if ( ! $field_settings instanceof EE_Datetime_Field ) {
1149
-			throw new EE_Error( sprintf( __('The field sent into EEM_Base::get_formats_for (%s) is not registered as a EE_Datetime_Field. Please check the spelling and make sure you are submitting the right field name to retrieve date_formats for.', 'event_espresso' ), $field_name ) );
1148
+		if ( ! $field_settings instanceof EE_Datetime_Field) {
1149
+			throw new EE_Error(sprintf(__('The field sent into EEM_Base::get_formats_for (%s) is not registered as a EE_Datetime_Field. Please check the spelling and make sure you are submitting the right field name to retrieve date_formats for.', 'event_espresso'), $field_name));
1150 1150
 		}
1151 1151
 
1152 1152
 		//while we are here, let's make sure the timezone internally in EEM_Base matches what is stored on
1153 1153
 		//the field.
1154 1154
 		$this->_timezone = $field_settings->get_timezone();
1155 1155
 
1156
-		return array( $field_settings->get_date_format( $pretty ), $field_settings->get_time_format( $pretty ) );
1156
+		return array($field_settings->get_date_format($pretty), $field_settings->get_time_format($pretty));
1157 1157
 	}
1158 1158
 
1159 1159
 
@@ -1177,25 +1177,25 @@  discard block
 block discarded – undo
1177 1177
 	 * @return int|string  If the given field_name is not of the EE_Datetime_Field type, then an EE_Error
1178 1178
 	 *                    	     exception is triggered.
1179 1179
 	 */
1180
-	public function current_time_for_query( $field_name, $timestamp = false, $what = 'both' ) {
1181
-		$formats = $this->get_formats_for( $field_name );
1180
+	public function current_time_for_query($field_name, $timestamp = false, $what = 'both') {
1181
+		$formats = $this->get_formats_for($field_name);
1182 1182
 
1183
-		$DateTime = new DateTime( "now", new DateTimeZone( $this->_timezone ) );
1183
+		$DateTime = new DateTime("now", new DateTimeZone($this->_timezone));
1184 1184
 
1185
-		if ( $timestamp ) {
1186
-			return $DateTime->format( 'U' );
1185
+		if ($timestamp) {
1186
+			return $DateTime->format('U');
1187 1187
 		}
1188 1188
 
1189 1189
 		//not returning timestamp, so return formatted string in timezone.
1190
-		switch( $what ) {
1190
+		switch ($what) {
1191 1191
 			case 'time' :
1192
-				return $DateTime->format( $formats[1] );
1192
+				return $DateTime->format($formats[1]);
1193 1193
 				break;
1194 1194
 			case 'date' :
1195
-				return $DateTime->format( $formats[0] );
1195
+				return $DateTime->format($formats[0]);
1196 1196
 				break;
1197 1197
 			default :
1198
-				return $DateTime->format( implode( ' ', $formats ) );
1198
+				return $DateTime->format(implode(' ', $formats));
1199 1199
 				break;
1200 1200
 		}
1201 1201
 	}
@@ -1219,18 +1219,18 @@  discard block
 block discarded – undo
1219 1219
 	 *                           		'U', this is ignored.
1220 1220
 	 * @return DateTime
1221 1221
 	 */
1222
-	public function convert_datetime_for_query( $field_name, $timestring, $incoming_format, $timezone = '' ) {
1222
+	public function convert_datetime_for_query($field_name, $timestring, $incoming_format, $timezone = '') {
1223 1223
 
1224 1224
 		//just using this to ensure the timezone is set correctly internally
1225
-		$this->get_formats_for( $field_name );
1225
+		$this->get_formats_for($field_name);
1226 1226
 
1227 1227
 		//load EEH_DTT_Helper
1228
-		EE_Registry::instance()->load_helper( 'DTT_Helper' );
1229
-		$set_timezone = empty( $timezone ) ? EEH_DTT_Helper::get_timezone() : $timezone;
1228
+		EE_Registry::instance()->load_helper('DTT_Helper');
1229
+		$set_timezone = empty($timezone) ? EEH_DTT_Helper::get_timezone() : $timezone;
1230 1230
 
1231
-		$incomingDateTime = date_create_from_format( $incoming_format, $timestring, new DateTimeZone( $set_timezone ) );
1231
+		$incomingDateTime = date_create_from_format($incoming_format, $timestring, new DateTimeZone($set_timezone));
1232 1232
 
1233
-		return $incomingDateTime->setTimeZone( new DateTimeZone( $this->_timezone ) );
1233
+		return $incomingDateTime->setTimeZone(new DateTimeZone($this->_timezone));
1234 1234
 	}
1235 1235
 
1236 1236
 
@@ -1240,7 +1240,7 @@  discard block
 block discarded – undo
1240 1240
 	 * Gets all the tables comprising this model. Array keys are the table aliases, and values are EE_Table objects
1241 1241
 	 * @return EE_Table_Base[]
1242 1242
 	 */
1243
-	function get_tables(){
1243
+	function get_tables() {
1244 1244
 		return $this->_tables;
1245 1245
 	}
1246 1246
 
@@ -1274,9 +1274,9 @@  discard block
 block discarded – undo
1274 1274
 	 * be aware that model objects being used could get out-of-sync with the database
1275 1275
 	 * @return int how many rows got updated or FALSE if something went wrong with the query (wp returns FALSE or num rows affected which *could* include 0 which DOES NOT mean the query was bad)
1276 1276
 	 */
1277
-	function update($fields_n_values, $query_params, $keep_model_objs_in_sync = TRUE){
1278
-		if( ! is_array( $query_params ) ){
1279
-			EE_Error::doing_it_wrong('EEM_Base::update', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' );
1277
+	function update($fields_n_values, $query_params, $keep_model_objs_in_sync = TRUE) {
1278
+		if ( ! is_array($query_params)) {
1279
+			EE_Error::doing_it_wrong('EEM_Base::update', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0');
1280 1280
 			$query_params = array();
1281 1281
 		}
1282 1282
 		/**
@@ -1286,7 +1286,7 @@  discard block
 block discarded – undo
1286 1286
 		 * @param array $fields_n_values the updated fields and their new values
1287 1287
 		 * @param array $query_params @see EEM_Base::get_all()
1288 1288
 		 */
1289
-		do_action( 'AHEE__EEM_Base__update__begin',$this, $fields_n_values, $query_params );
1289
+		do_action('AHEE__EEM_Base__update__begin', $this, $fields_n_values, $query_params);
1290 1290
 		/**
1291 1291
 		 * Filters the fields about to be updated given the query parameters. You can provide the
1292 1292
 		 * $query_params to $this->get_all() to find exactly which records will be updated
@@ -1294,10 +1294,10 @@  discard block
 block discarded – undo
1294 1294
 		 * @param EEM_Base $model the model being queried
1295 1295
 		 * @param array $query_params see EEM_Base::get_all()
1296 1296
 		 */
1297
-		$fields_n_values = apply_filters( 'FHEE__EEM_Base__update__fields_n_values', $fields_n_values, $this, $query_params );
1297
+		$fields_n_values = apply_filters('FHEE__EEM_Base__update__fields_n_values', $fields_n_values, $this, $query_params);
1298 1298
 		//need to verify that, for any entry we want to update, there are entries in each secondary table.
1299 1299
 		//to do that, for each table, verify that it's PK isn't null.
1300
-		$tables= $this->get_tables();
1300
+		$tables = $this->get_tables();
1301 1301
 
1302 1302
 		//and if the other tables don't have a row for each table-to-be-updated, we'll insert one with whatever values available in the current update query
1303 1303
 		//NOTE: we should make this code more efficient by NOT querying twice
@@ -1307,29 +1307,29 @@  discard block
 block discarded – undo
1307 1307
 			//we want to make sure the default_where strategy is ignored
1308 1308
 			$this->_ignore_where_strategy = TRUE;
1309 1309
 			$wpdb_select_results = $this->_get_all_wpdb_results($query_params);
1310
-			foreach( $wpdb_select_results as $wpdb_result ){
1310
+			foreach ($wpdb_select_results as $wpdb_result) {
1311 1311
 				// type cast stdClass as array
1312
-				$wpdb_result = (array)$wpdb_result;
1312
+				$wpdb_result = (array) $wpdb_result;
1313 1313
 				//get the model object's PK, as we'll want this if we need to insert a row into secondary tables
1314
-				if( $this->has_primary_key_field() ){
1315
-					$main_table_pk_value = $wpdb_result[ $this->get_primary_key_field()->get_qualified_column() ];
1316
-				}else{
1314
+				if ($this->has_primary_key_field()) {
1315
+					$main_table_pk_value = $wpdb_result[$this->get_primary_key_field()->get_qualified_column()];
1316
+				} else {
1317 1317
 					//if there's no primary key, we basically can't support having a 2nd table on the model (we could but it woudl be lots of work)
1318 1318
 					$main_table_pk_value = null;
1319 1319
 				}
1320 1320
 				//if there are more than 1 tables, we'll want to verify that each table for this model has an entry in the other tables
1321 1321
 				//and if the other tables don't have a row for each table-to-be-updated, we'll insert one with whatever values available in the current update query
1322
-				if(count($tables) > 1){
1322
+				if (count($tables) > 1) {
1323 1323
 					//foreach matching row in the DB, ensure that each table's PK isn't null. If so, there must not be an entry
1324 1324
 					//in that table, and so we'll want to insert one
1325
-					foreach($tables as $table_obj){
1325
+					foreach ($tables as $table_obj) {
1326 1326
 						$this_table_pk_column = $table_obj->get_fully_qualified_pk_column();
1327 1327
 						//if there is no private key for this table on the results, it means there's no entry
1328 1328
 						//in this table, right? so insert a row in the current table, using any fields available
1329
-						if( ! ( array_key_exists( $this_table_pk_column, $wpdb_result) && $wpdb_result[ $this_table_pk_column ] )){
1329
+						if ( ! (array_key_exists($this_table_pk_column, $wpdb_result) && $wpdb_result[$this_table_pk_column])) {
1330 1330
 							$success = $this->_insert_into_specific_table($table_obj, $fields_n_values, $main_table_pk_value);
1331 1331
 							//if we died here, report the error
1332
-							if( ! $success ) {
1332
+							if ( ! $success) {
1333 1333
 								return false;
1334 1334
 							}
1335 1335
 						}
@@ -1349,44 +1349,44 @@  discard block
 block discarded – undo
1349 1349
 		//if this wasn't called from a model object (to update itself)
1350 1350
 		//then we want to make sure we keep all the existing
1351 1351
 		//model objects in sync with the db
1352
-		if( $keep_model_objs_in_sync && ! $this->_values_already_prepared_by_model_object ){
1353
-			if( $this->has_primary_key_field() ){
1354
-				$model_objs_affected_ids = $this->get_col( $query_params );
1355
-			}else{
1352
+		if ($keep_model_objs_in_sync && ! $this->_values_already_prepared_by_model_object) {
1353
+			if ($this->has_primary_key_field()) {
1354
+				$model_objs_affected_ids = $this->get_col($query_params);
1355
+			} else {
1356 1356
 				//we need to select a bunch of columns and then combine them into the the "index primary key string"s
1357
-				$models_affected_key_columns = $this->_get_all_wpdb_results($query_params, ARRAY_A );
1357
+				$models_affected_key_columns = $this->_get_all_wpdb_results($query_params, ARRAY_A);
1358 1358
 				$model_objs_affected_ids = array();
1359
-				foreach( $models_affected_key_columns as $row ){
1360
-					$combined_index_key = $this->get_index_primary_key_string( $row );
1361
-					$model_objs_affected_ids[ $combined_index_key ] = $combined_index_key;
1359
+				foreach ($models_affected_key_columns as $row) {
1360
+					$combined_index_key = $this->get_index_primary_key_string($row);
1361
+					$model_objs_affected_ids[$combined_index_key] = $combined_index_key;
1362 1362
 				}
1363 1363
 
1364 1364
 			}
1365 1365
 
1366
-			if( ! $model_objs_affected_ids ){
1366
+			if ( ! $model_objs_affected_ids) {
1367 1367
 				//wait wait wait- if nothing was affected let's stop here
1368 1368
 				return 0;
1369 1369
 			}
1370
-			foreach( $model_objs_affected_ids as $id ){
1371
-				$model_obj_in_entity_map = $this->get_from_entity_map( $id );
1372
-				if( $model_obj_in_entity_map ){
1373
-					foreach( $fields_n_values as $field => $new_value ){
1374
-						$model_obj_in_entity_map->set( $field, $new_value );
1370
+			foreach ($model_objs_affected_ids as $id) {
1371
+				$model_obj_in_entity_map = $this->get_from_entity_map($id);
1372
+				if ($model_obj_in_entity_map) {
1373
+					foreach ($fields_n_values as $field => $new_value) {
1374
+						$model_obj_in_entity_map->set($field, $new_value);
1375 1375
 					}
1376 1376
 				}
1377 1377
 			}
1378 1378
 			//if there is a primary key on this model, we can now do a slight optimization
1379
-			if( $this->has_primary_key_field() ){
1379
+			if ($this->has_primary_key_field()) {
1380 1380
 				//we already know what we want to update. So let's make the query simpler so it's a little more efficient
1381 1381
 				$query_params = array(
1382
-					array( $this->primary_key_name() => array( 'IN', $model_objs_affected_ids ) ),
1383
-					'limit' => count( $model_objs_affected_ids ), 'default_where_conditions' => 'none' );
1382
+					array($this->primary_key_name() => array('IN', $model_objs_affected_ids)),
1383
+					'limit' => count($model_objs_affected_ids), 'default_where_conditions' => 'none' );
1384 1384
 			}
1385 1385
 		}
1386 1386
 
1387
-		$model_query_info = $this->_create_model_query_info_carrier( $query_params );
1388
-		$SQL = "UPDATE ".$model_query_info->get_full_join_sql()." SET ".$this->_construct_update_sql($fields_n_values).$model_query_info->get_where_sql();//note: doesn't use _construct_2nd_half_of_select_query() because doesn't accept LIMIT, ORDER BY, etc.
1389
-		$rows_affected = $this->_do_wpdb_query('query', array( $SQL ) );
1387
+		$model_query_info = $this->_create_model_query_info_carrier($query_params);
1388
+		$SQL = "UPDATE ".$model_query_info->get_full_join_sql()." SET ".$this->_construct_update_sql($fields_n_values).$model_query_info->get_where_sql(); //note: doesn't use _construct_2nd_half_of_select_query() because doesn't accept LIMIT, ORDER BY, etc.
1389
+		$rows_affected = $this->_do_wpdb_query('query', array($SQL));
1390 1390
 		/**
1391 1391
 		 * Action called after a model update call has been made.
1392 1392
 		 *
@@ -1395,8 +1395,8 @@  discard block
 block discarded – undo
1395 1395
 		 * @param array $query_params @see EEM_Base::get_all()
1396 1396
 		 * @param int $rows_affected
1397 1397
 		 */
1398
-		do_action( 'AHEE__EEM_Base__update__end',$this, $fields_n_values, $query_params, $rows_affected );
1399
-		return $rows_affected;//how many supposedly got updated
1398
+		do_action('AHEE__EEM_Base__update__end', $this, $fields_n_values, $query_params, $rows_affected);
1399
+		return $rows_affected; //how many supposedly got updated
1400 1400
 	}
1401 1401
 
1402 1402
 	/**
@@ -1408,22 +1408,22 @@  discard block
 block discarded – undo
1408 1408
 	 * @param string $field_to_select
1409 1409
 	 * @return array just like $wpdb->get_col()
1410 1410
 	 */
1411
-	public function get_col( $query_params  = array(), $field_to_select = NULL ){
1411
+	public function get_col($query_params = array(), $field_to_select = NULL) {
1412 1412
 
1413
-		if( $field_to_select ){
1414
-			$field = $this->field_settings_for( $field_to_select );
1415
-		}elseif( $this->has_primary_key_field ( ) ){
1413
+		if ($field_to_select) {
1414
+			$field = $this->field_settings_for($field_to_select);
1415
+		}elseif ($this->has_primary_key_field( )) {
1416 1416
 			$field = $this->get_primary_key_field();
1417
-		}else{
1417
+		} else {
1418 1418
 			//no primary key, just grab the first column
1419
-			$field = reset( $this->field_settings());
1419
+			$field = reset($this->field_settings());
1420 1420
 		}
1421 1421
 
1422 1422
 
1423 1423
 		$model_query_info = $this->_create_model_query_info_carrier($query_params);
1424 1424
 		$select_expressions = $field->get_qualified_column();
1425
-		$SQL ="SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info);
1426
-		$results =  $this->_do_wpdb_query('get_col', array( $SQL ) );
1425
+		$SQL = "SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info);
1426
+		$results = $this->_do_wpdb_query('get_col', array($SQL));
1427 1427
 		return $results;
1428 1428
 	}
1429 1429
 
@@ -1433,12 +1433,12 @@  discard block
 block discarded – undo
1433 1433
 	 * @param string $field_to_select @see EEM_Base::get_col()
1434 1434
 	 * @return string
1435 1435
 	 */
1436
-	public function get_var( $query_params = array(), $field_to_select = NULL ) {
1437
-		$query_params[ 'limit' ] = 1;
1438
-		$col = $this->get_col( $query_params, $field_to_select );
1439
-		if( ! empty( $col ) ) {
1440
-			return reset( $col );
1441
-		}else{
1436
+	public function get_var($query_params = array(), $field_to_select = NULL) {
1437
+		$query_params['limit'] = 1;
1438
+		$col = $this->get_col($query_params, $field_to_select);
1439
+		if ( ! empty($col)) {
1440
+			return reset($col);
1441
+		} else {
1442 1442
 			return NULL;
1443 1443
 		}
1444 1444
 	}
@@ -1452,19 +1452,19 @@  discard block
 block discarded – undo
1452 1452
 	 * @param array $fields_n_values array keys are field names on this model, and values are what those fields should be updated to in the DB
1453 1453
 	 * @return string of SQL
1454 1454
 	 */
1455
-	function _construct_update_sql($fields_n_values){
1455
+	function _construct_update_sql($fields_n_values) {
1456 1456
 		/** @type WPDB $wpdb */
1457 1457
 		global $wpdb;
1458 1458
 		$cols_n_values = array();
1459
-		foreach($fields_n_values as $field_name => $value){
1459
+		foreach ($fields_n_values as $field_name => $value) {
1460 1460
 			$field_obj = $this->field_settings_for($field_name);
1461 1461
 			//if the value is NULL, we want to assign the value to that.
1462 1462
 			//wpdb->prepare doesn't really handle that properly
1463
-			$prepared_value = $this->_prepare_value_or_use_default( $field_obj, $fields_n_values );
1464
-			$value_sql = $prepared_value===NULL ? 'NULL' : $wpdb->prepare( $field_obj->get_wpdb_data_type(), $prepared_value );
1463
+			$prepared_value = $this->_prepare_value_or_use_default($field_obj, $fields_n_values);
1464
+			$value_sql = $prepared_value === NULL ? 'NULL' : $wpdb->prepare($field_obj->get_wpdb_data_type(), $prepared_value);
1465 1465
 			$cols_n_values[] = $field_obj->get_qualified_column()."=".$value_sql;
1466 1466
 		}
1467
-		return implode(",",$cols_n_values);
1467
+		return implode(",", $cols_n_values);
1468 1468
 
1469 1469
 	}
1470 1470
 
@@ -1476,11 +1476,11 @@  discard block
 block discarded – undo
1476 1476
 	 * @param mixed $id
1477 1477
 	 * @return boolean whether the row got deleted or not
1478 1478
 	 */
1479
-	public function delete_by_ID( $id ){
1480
-		return $this->delete( array(
1481
-			array( $this->get_primary_key_field()->get_name() => $id ),
1479
+	public function delete_by_ID($id) {
1480
+		return $this->delete(array(
1481
+			array($this->get_primary_key_field()->get_name() => $id),
1482 1482
 			'limit' 	=> 1
1483
-		) );
1483
+		));
1484 1484
 	}
1485 1485
 
1486 1486
 
@@ -1495,7 +1495,7 @@  discard block
 block discarded – undo
1495 1495
 	 * which may depend on it. Its generally advisable to always leave this as TRUE, otherwise you could easily corrupt your DB
1496 1496
 	 * @return int how many rows got deleted
1497 1497
 	 */
1498
-	function delete($query_params,$allow_blocking = true){
1498
+	function delete($query_params, $allow_blocking = true) {
1499 1499
 		/**
1500 1500
 		 * Action called just before performing a real deletion query. You can use the
1501 1501
 		 * model and its $query_params to find exactly which items will be deleted
@@ -1504,34 +1504,34 @@  discard block
 block discarded – undo
1504 1504
 		 * @param boolean $allow_blocking whether or not to allow related model objects
1505 1505
 		 * to block (prevent) this deletion
1506 1506
 		 */
1507
-		do_action( 'AHEE__EEM_Base__delete__begin', $this, $query_params, $allow_blocking );
1507
+		do_action('AHEE__EEM_Base__delete__begin', $this, $query_params, $allow_blocking);
1508 1508
 		//some MySQL databases may be running safe mode, which may restrict
1509 1509
 		//deletion if there is no KEY column used in the WHERE statement of a deletion.
1510 1510
 		//to get around this, we first do a SELECT, get all the IDs, and then run another query
1511 1511
 		//to delete them
1512 1512
 		$items_for_deletion = $this->_get_all_wpdb_results($query_params);
1513
-		$deletion_where = $this->_setup_ids_for_delete( $items_for_deletion, $allow_blocking);
1514
-		if($deletion_where){
1513
+		$deletion_where = $this->_setup_ids_for_delete($items_for_deletion, $allow_blocking);
1514
+		if ($deletion_where) {
1515 1515
 			//echo "objects for deletion:";var_dump($objects_for_deletion);
1516 1516
 			$model_query_info = $this->_create_model_query_info_carrier($query_params);
1517 1517
 			$table_aliases = array();
1518
-			foreach(array_keys($this->_tables) as $table_alias){
1518
+			foreach (array_keys($this->_tables) as $table_alias) {
1519 1519
 				$table_aliases[] = $table_alias;
1520 1520
 			}
1521
-			$SQL = "DELETE ".implode(", ",$table_aliases)." FROM ".$model_query_info->get_full_join_sql()." WHERE ".$deletion_where;
1521
+			$SQL = "DELETE ".implode(", ", $table_aliases)." FROM ".$model_query_info->get_full_join_sql()." WHERE ".$deletion_where;
1522 1522
 
1523 1523
 			//		/echo "delete sql:$SQL";
1524
-			$rows_deleted = $this->_do_wpdb_query( 'query', array( $SQL ) );
1525
-		}else{
1524
+			$rows_deleted = $this->_do_wpdb_query('query', array($SQL));
1525
+		} else {
1526 1526
 			$rows_deleted = 0;
1527 1527
 		}
1528 1528
 
1529 1529
 		//and lastly make sure those items are removed from the entity map; if they could be put into it at all
1530
-		if( $this->has_primary_key_field() ){
1531
-			foreach($items_for_deletion as $item_for_deletion_row ){
1532
-				$pk_value = $item_for_deletion_row[ $this->get_primary_key_field()->get_qualified_column() ];
1533
-				if( isset( $this->_entity_map[ $pk_value ] ) ){
1534
-					unset( $this->_entity_map[ $pk_value ] );
1530
+		if ($this->has_primary_key_field()) {
1531
+			foreach ($items_for_deletion as $item_for_deletion_row) {
1532
+				$pk_value = $item_for_deletion_row[$this->get_primary_key_field()->get_qualified_column()];
1533
+				if (isset($this->_entity_map[$pk_value])) {
1534
+					unset($this->_entity_map[$pk_value]);
1535 1535
 				}
1536 1536
 			}
1537 1537
 		}
@@ -1543,8 +1543,8 @@  discard block
 block discarded – undo
1543 1543
 		 * @param array $query_params @see EEM_Base::get_all()
1544 1544
 		 * @param int $rows_deleted
1545 1545
 		 */
1546
-		do_action( 'AHEE__EEM_Base__delete__end', $this, $query_params, $rows_deleted );
1547
-		return $rows_deleted;//how many supposedly got deleted
1546
+		do_action('AHEE__EEM_Base__delete__end', $this, $query_params, $rows_deleted);
1547
+		return $rows_deleted; //how many supposedly got deleted
1548 1548
 	}
1549 1549
 
1550 1550
 
@@ -1560,28 +1560,28 @@  discard block
 block discarded – undo
1560 1560
 	 * blocking its deletion before removing the relation between A and B
1561 1561
 	 * @return boolean
1562 1562
 	 */
1563
-	public function delete_is_blocked_by_related_models($this_model_obj_or_id, $ignore_this_model_obj = null){
1563
+	public function delete_is_blocked_by_related_models($this_model_obj_or_id, $ignore_this_model_obj = null) {
1564 1564
 		//first, if $ignore_this_model_obj was supplied, get its model
1565
-		if($ignore_this_model_obj && $ignore_this_model_obj instanceof EE_Base_Class){
1565
+		if ($ignore_this_model_obj && $ignore_this_model_obj instanceof EE_Base_Class) {
1566 1566
 			$ignored_model = $ignore_this_model_obj->get_model();
1567
-		}else{
1567
+		} else {
1568 1568
 			$ignored_model = null;
1569 1569
 		}
1570 1570
 		//now check all the relations of $this_model_obj_or_id and see if there
1571 1571
 		//are any related model objects blocking it?
1572 1572
 		$is_blocked = false;
1573
-		foreach($this->_model_relations as $relation_name => $relation_obj){
1574
-			if( $relation_obj->block_delete_if_related_models_exist()){
1573
+		foreach ($this->_model_relations as $relation_name => $relation_obj) {
1574
+			if ($relation_obj->block_delete_if_related_models_exist()) {
1575 1575
 				//if $ignore_this_model_obj was supplied, then for the query
1576 1576
 				//on that model needs to be told to ignore $ignore_this_model_obj
1577
-				if($ignored_model && $relation_name == $ignored_model->get_this_model_name()){
1578
-					$related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id,array(
1579
-					array($ignored_model->get_primary_key_field()->get_name() => array('!=',$ignore_this_model_obj->ID()))));
1580
-				}else{
1577
+				if ($ignored_model && $relation_name == $ignored_model->get_this_model_name()) {
1578
+					$related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id, array(
1579
+					array($ignored_model->get_primary_key_field()->get_name() => array('!=', $ignore_this_model_obj->ID()))));
1580
+				} else {
1581 1581
 					$related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id);
1582 1582
 				}
1583 1583
 
1584
-				if($related_model_objects){
1584
+				if ($related_model_objects) {
1585 1585
 					EE_Error::add_error($relation_obj->get_deletion_error_message(), __FILE__, __FUNCTION__, __LINE__);
1586 1586
 					$is_blocked = true;
1587 1587
 				}
@@ -1601,65 +1601,65 @@  discard block
 block discarded – undo
1601 1601
 	 * @throws EE_Error
1602 1602
 	 * @return string    everything that comes after the WHERE statement.
1603 1603
 	 */
1604
-	protected function _setup_ids_for_delete( $objects_for_deletion, $allow_blocking = true) {
1605
-		if($this->has_primary_key_field()){
1604
+	protected function _setup_ids_for_delete($objects_for_deletion, $allow_blocking = true) {
1605
+		if ($this->has_primary_key_field()) {
1606 1606
 			$primary_table = $this->_get_main_table();
1607 1607
 			$other_tables = $this->_get_other_tables();
1608 1608
 			$deletes = $query = array();
1609
-			foreach ( $objects_for_deletion as $delete_object ) {
1609
+			foreach ($objects_for_deletion as $delete_object) {
1610 1610
 				//before we mark this object for deletion,
1611 1611
 				//make sure there's no related objects blocking its deletion (if we're checking)
1612
-				if( $allow_blocking && $this->delete_is_blocked_by_related_models($delete_object[$primary_table->get_fully_qualified_pk_column()]) ){
1612
+				if ($allow_blocking && $this->delete_is_blocked_by_related_models($delete_object[$primary_table->get_fully_qualified_pk_column()])) {
1613 1613
 					continue;
1614 1614
 				}
1615 1615
 
1616 1616
 				//primary table deletes
1617
-				if ( isset( $delete_object[$primary_table->get_fully_qualified_pk_column()] ) )
1617
+				if (isset($delete_object[$primary_table->get_fully_qualified_pk_column()]))
1618 1618
 					$deletes[$primary_table->get_fully_qualified_pk_column()][] = $delete_object[$primary_table->get_fully_qualified_pk_column()];
1619 1619
 
1620 1620
 				//other tables
1621
-				if ( !empty( $other_tables ) ) {
1622
-					foreach ( $other_tables as $ot ) {
1621
+				if ( ! empty($other_tables)) {
1622
+					foreach ($other_tables as $ot) {
1623 1623
 
1624 1624
 						//first check if we've got the foreign key column here.
1625
-						if ( isset( $delete_object[$ot->get_fully_qualified_fk_column()] ) )
1625
+						if (isset($delete_object[$ot->get_fully_qualified_fk_column()]))
1626 1626
 							$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_fk_column()];
1627 1627
 
1628 1628
 						//wait! it's entirely possible that we'll have a the primary key for this table in here if it's a foreign key for one of the other secondary tables
1629
-						if ( isset( $delete_object[$ot->get_fully_qualified_pk_column()] ) )
1629
+						if (isset($delete_object[$ot->get_fully_qualified_pk_column()]))
1630 1630
 							$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()];
1631 1631
 
1632 1632
 						//finally, it is possible that the fk for this table is found in the fully qualified pk column for the fk table, so let's see if that's there!
1633
-						if ( isset( $delete_object[$ot->get_fully_qualified_pk_on_fk_table()]) )
1633
+						if (isset($delete_object[$ot->get_fully_qualified_pk_on_fk_table()]))
1634 1634
 							$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()];
1635 1635
 					}
1636 1636
 				}
1637 1637
 			}
1638 1638
 
1639 1639
 			//we should have deletes now, so let's just go through and setup the where statement
1640
-			foreach ( $deletes as $column => $values ) {
1640
+			foreach ($deletes as $column => $values) {
1641 1641
 				//make sure we have unique $values;
1642 1642
 				$values = array_unique($values);
1643
-				$query[] = $column . ' IN(' . implode(",",$values) . ')';
1643
+				$query[] = $column.' IN('.implode(",", $values).')';
1644 1644
 			}
1645 1645
 
1646
-			return !empty($query) ? implode(' AND ', $query ) : '';
1647
-		}elseif(count($this->get_combined_primary_key_fields()) > 1){
1646
+			return ! empty($query) ? implode(' AND ', $query) : '';
1647
+		}elseif (count($this->get_combined_primary_key_fields()) > 1) {
1648 1648
 			$ways_to_identify_a_row = array();
1649 1649
 			$fields = $this->get_combined_primary_key_fields();
1650 1650
 			//note: because there' sno primary key, that means nothing else  can be pointing to this model, right?
1651
-			foreach($objects_for_deletion as  $delete_object){
1651
+			foreach ($objects_for_deletion as  $delete_object) {
1652 1652
 				$values_for_each_cpk_for_a_row = array();
1653
-				foreach($fields as $cpk_field){
1653
+				foreach ($fields as $cpk_field) {
1654 1654
 					$values_for_each_cpk_for_a_row[] = $cpk_field->get_qualified_column()."=".$delete_object[$cpk_field->get_qualified_column()];
1655 1655
 				}
1656
-				$ways_to_identify_a_row[] = "(".implode(" AND ",$values_for_each_cpk_for_a_row).")";
1656
+				$ways_to_identify_a_row[] = "(".implode(" AND ", $values_for_each_cpk_for_a_row).")";
1657 1657
 			}
1658
-			return implode(" OR ",$ways_to_identify_a_row);
1659
-		}else{
1658
+			return implode(" OR ", $ways_to_identify_a_row);
1659
+		} else {
1660 1660
 			//so there's no primary key and no combined key...
1661 1661
 			//sorry, can't help you
1662
-			throw new EE_Error(sprintf(__("Cannot delete objects of type %s because there is no primary key NOR combined key", "event_espresso"),get_class($this)));
1662
+			throw new EE_Error(sprintf(__("Cannot delete objects of type %s because there is no primary key NOR combined key", "event_espresso"), get_class($this)));
1663 1663
 		}
1664 1664
 	}
1665 1665
 
@@ -1673,21 +1673,21 @@  discard block
 block discarded – undo
1673 1673
 	 * @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;
1674 1674
 	 * @return int
1675 1675
 	 */
1676
-	function count($query_params =array(),$field_to_count = NULL, $distinct = FALSE){
1676
+	function count($query_params = array(), $field_to_count = NULL, $distinct = FALSE) {
1677 1677
 		$model_query_info = $this->_create_model_query_info_carrier($query_params);
1678
-		if($field_to_count){
1678
+		if ($field_to_count) {
1679 1679
 			$field_obj = $this->field_settings_for($field_to_count);
1680 1680
 			$column_to_count = $field_obj->get_qualified_column();
1681
-		}elseif($this->has_primary_key_field ()){
1681
+		}elseif ($this->has_primary_key_field()) {
1682 1682
 			$pk_field_obj = $this->get_primary_key_field();
1683 1683
 			$column_to_count = $pk_field_obj->get_qualified_column();
1684
-		}else{//there's no primary key
1684
+		} else {//there's no primary key
1685 1685
 			$column_to_count = '*';
1686 1686
 		}
1687 1687
 
1688
-		$column_to_count = $distinct ? "DISTINCT (" . $column_to_count . " )" : $column_to_count;
1689
-		$SQL ="SELECT COUNT(".$column_to_count.")" . $this->_construct_2nd_half_of_select_query($model_query_info);
1690
-		return (int)$this->_do_wpdb_query( 'get_var', array( $SQL) );
1688
+		$column_to_count = $distinct ? "DISTINCT (".$column_to_count." )" : $column_to_count;
1689
+		$SQL = "SELECT COUNT(".$column_to_count.")".$this->_construct_2nd_half_of_select_query($model_query_info);
1690
+		return (int) $this->_do_wpdb_query('get_var', array($SQL));
1691 1691
 	}
1692 1692
 
1693 1693
 	/**
@@ -1697,23 +1697,23 @@  discard block
 block discarded – undo
1697 1697
 	 * @param string $field_to_sum name of field (array key in $_fields array)
1698 1698
 	 * @return float
1699 1699
 	 */
1700
-	function sum($query_params, $field_to_sum = NULL){
1700
+	function sum($query_params, $field_to_sum = NULL) {
1701 1701
 		$model_query_info = $this->_create_model_query_info_carrier($query_params);
1702 1702
 
1703
-		if($field_to_sum){
1703
+		if ($field_to_sum) {
1704 1704
 			$field_obj = $this->field_settings_for($field_to_sum);
1705 1705
 
1706
-		}else{
1706
+		} else {
1707 1707
 			$field_obj = $this->get_primary_key_field();
1708 1708
 		}
1709 1709
 		$column_to_count = $field_obj->get_qualified_column();
1710 1710
 
1711
-		$SQL ="SELECT SUM(".$column_to_count.")" . $this->_construct_2nd_half_of_select_query($model_query_info);
1712
-		$return_value = $this->_do_wpdb_query('get_var',array( $SQL ) );
1713
-		if($field_obj->get_wpdb_data_type() == '%d' || $field_obj->get_wpdb_data_type() == '%s' ){
1714
-			return (float)$return_value;
1715
-		}else{//must be %f
1716
-			return (float)$return_value;
1711
+		$SQL = "SELECT SUM(".$column_to_count.")".$this->_construct_2nd_half_of_select_query($model_query_info);
1712
+		$return_value = $this->_do_wpdb_query('get_var', array($SQL));
1713
+		if ($field_obj->get_wpdb_data_type() == '%d' || $field_obj->get_wpdb_data_type() == '%s') {
1714
+			return (float) $return_value;
1715
+		} else {//must be %f
1716
+			return (float) $return_value;
1717 1717
 		}
1718 1718
 	}
1719 1719
 
@@ -1728,33 +1728,33 @@  discard block
 block discarded – undo
1728 1728
 	 * @global wpdb $wpdb
1729 1729
 	 * @return mixed
1730 1730
 	 */
1731
-	protected function _do_wpdb_query( $wpdb_method, $arguments_to_provide ){
1731
+	protected function _do_wpdb_query($wpdb_method, $arguments_to_provide) {
1732 1732
 		//if we're in maintenance mode level 2, DON'T run any queries
1733 1733
 		//because level 2 indicates the database needs updating and
1734 1734
 		//is probably out of sync with the code
1735
-		if( ! EE_Maintenance_Mode::instance()->models_can_query()){
1735
+		if ( ! EE_Maintenance_Mode::instance()->models_can_query()) {
1736 1736
 			throw new EE_Error(sprintf(__("Event Espresso Level 2 Maintenance mode is active. That means EE can not run ANY database queries until the necessary migration scripts have run which will take EE out of maintenance mode level 2. Please inform support of this error.", "event_espresso")));
1737 1737
 		}
1738 1738
 		/** @type WPDB $wpdb */
1739 1739
 		global $wpdb;
1740
-		if( ! method_exists( $wpdb, $wpdb_method ) ){
1741
-			throw new EE_Error( sprintf( __( 'There is no method named "%s" on Wordpress\' $wpdb object','event_espresso' ), $wpdb_method ) );
1740
+		if ( ! method_exists($wpdb, $wpdb_method)) {
1741
+			throw new EE_Error(sprintf(__('There is no method named "%s" on Wordpress\' $wpdb object', 'event_espresso'), $wpdb_method));
1742 1742
 		}
1743
-		if( WP_DEBUG ){
1743
+		if (WP_DEBUG) {
1744 1744
 			$old_show_errors_value = $wpdb->show_errors;
1745
-			$wpdb->show_errors( FALSE );
1746
-		}
1747
-		$result = $this->_process_wpdb_query( $wpdb_method, $arguments_to_provide );
1748
-		$this->show_db_query_if_previously_requested( $wpdb->last_query );
1749
-		if( WP_DEBUG ){
1750
-			$wpdb->show_errors( $old_show_errors_value );
1751
-			if( ! empty( $wpdb->last_error ) ){
1752
-				throw new EE_Error( sprintf( __( 'WPDB Error: "%s"', 'event_espresso' ), $wpdb->last_error ) );
1753
-			}elseif( $result === false ){
1754
-				throw new EE_Error( sprintf( __( 'WPDB Error occurred, but no error message was logged by wpdb! The wpdb method called was "%1$s" and the arguments were "%2$s"', 'event_espresso' ), $wpdb_method, var_export( $arguments_to_provide, true ) ) );
1745
+			$wpdb->show_errors(FALSE);
1746
+		}
1747
+		$result = $this->_process_wpdb_query($wpdb_method, $arguments_to_provide);
1748
+		$this->show_db_query_if_previously_requested($wpdb->last_query);
1749
+		if (WP_DEBUG) {
1750
+			$wpdb->show_errors($old_show_errors_value);
1751
+			if ( ! empty($wpdb->last_error)) {
1752
+				throw new EE_Error(sprintf(__('WPDB Error: "%s"', 'event_espresso'), $wpdb->last_error));
1753
+			}elseif ($result === false) {
1754
+				throw new EE_Error(sprintf(__('WPDB Error occurred, but no error message was logged by wpdb! The wpdb method called was "%1$s" and the arguments were "%2$s"', 'event_espresso'), $wpdb_method, var_export($arguments_to_provide, true)));
1755 1755
 			}
1756
-		}elseif( $result === false ) {
1757
-			EE_Error::add_error( sprintf( __( 'A database error has occurred. Turn on WP_DEBUG for more information.', 'event_espresso' )), __FILE__, __FUNCTION__, __LINE__);
1756
+		}elseif ($result === false) {
1757
+			EE_Error::add_error(sprintf(__('A database error has occurred. Turn on WP_DEBUG for more information.', 'event_espresso')), __FILE__, __FUNCTION__, __LINE__);
1758 1758
 		}
1759 1759
 		return $result;
1760 1760
 	}
@@ -1770,23 +1770,23 @@  discard block
 block discarded – undo
1770 1770
 	 * @param array $arguments_to_provide
1771 1771
 	 * @return mixed
1772 1772
 	 */
1773
-	private function _process_wpdb_query( $wpdb_method, $arguments_to_provide ) {
1773
+	private function _process_wpdb_query($wpdb_method, $arguments_to_provide) {
1774 1774
 		/** @type WPDB $wpdb */
1775 1775
 		global $wpdb;
1776 1776
 		$wpdb->last_error = null;
1777
-		$result = call_user_func_array( array( $wpdb, $wpdb_method ), $arguments_to_provide );
1777
+		$result = call_user_func_array(array($wpdb, $wpdb_method), $arguments_to_provide);
1778 1778
 		// was there an error running the query?
1779
-		if ( ( $result === false || ! empty( $wpdb->last_error ) ) ) {
1780
-			switch ( EEM_Base::$_db_verification_level ) {
1779
+		if (($result === false || ! empty($wpdb->last_error))) {
1780
+			switch (EEM_Base::$_db_verification_level) {
1781 1781
 
1782 1782
 				case EEM_Base::db_verified_none :
1783 1783
 					// let's double-check core's DB
1784
-					$error_message = $this->_verify_core_db( $wpdb_method, $arguments_to_provide );
1784
+					$error_message = $this->_verify_core_db($wpdb_method, $arguments_to_provide);
1785 1785
 					break;
1786 1786
 
1787 1787
 				case EEM_Base::db_verified_core :
1788 1788
 					// STILL NO LOVE?? verify all the addons too. Maybe they need to be fixed
1789
-					$error_message = $this->_verify_addons_db( $wpdb_method, $arguments_to_provide );
1789
+					$error_message = $this->_verify_addons_db($wpdb_method, $arguments_to_provide);
1790 1790
 					break;
1791 1791
 
1792 1792
 				case EEM_Base::db_verified_addons :
@@ -1794,11 +1794,11 @@  discard block
 block discarded – undo
1794 1794
 					return $result;
1795 1795
 					break;
1796 1796
 			}
1797
-			if ( ! empty( $error_message ) ) {
1798
-				EE_Log::instance()->log( __FILE__, __FUNCTION__, $error_message, 'error' );
1799
-				trigger_error( $error_message );
1797
+			if ( ! empty($error_message)) {
1798
+				EE_Log::instance()->log(__FILE__, __FUNCTION__, $error_message, 'error');
1799
+				trigger_error($error_message);
1800 1800
 			}
1801
-			return $this->_process_wpdb_query( $wpdb_method, $arguments_to_provide );
1801
+			return $this->_process_wpdb_query($wpdb_method, $arguments_to_provide);
1802 1802
 
1803 1803
 		}
1804 1804
 
@@ -1814,18 +1814,18 @@  discard block
 block discarded – undo
1814 1814
 	 * @param array $arguments_to_provide
1815 1815
 	 * @return string
1816 1816
 	 */
1817
-	private function _verify_core_db( $wpdb_method, $arguments_to_provide ){
1817
+	private function _verify_core_db($wpdb_method, $arguments_to_provide) {
1818 1818
 		/** @type WPDB $wpdb */
1819 1819
 		global $wpdb;
1820 1820
 		//ok remember that we've already attempted fixing the core db, in case the problem persists
1821 1821
 		EEM_Base::$_db_verification_level = EEM_Base::db_verified_core;
1822 1822
 		$error_message = sprintf(
1823
-			__( 'WPDB Error "%1$s" while running wpdb method "%2$s" with arguments %3$s. Automatically attempting to fix EE Core DB', 'event_espresso' ),
1823
+			__('WPDB Error "%1$s" while running wpdb method "%2$s" with arguments %3$s. Automatically attempting to fix EE Core DB', 'event_espresso'),
1824 1824
 			$wpdb->last_error,
1825 1825
 			$wpdb_method,
1826
-			json_encode( $arguments_to_provide )
1826
+			json_encode($arguments_to_provide)
1827 1827
 		);
1828
-		EE_System::instance()->initialize_db_if_no_migrations_required( false, true );
1828
+		EE_System::instance()->initialize_db_if_no_migrations_required(false, true);
1829 1829
 		return $error_message;
1830 1830
 	}
1831 1831
 
@@ -1838,16 +1838,16 @@  discard block
 block discarded – undo
1838 1838
 	 * @param $arguments_to_provide
1839 1839
 	 * @return string
1840 1840
 	 */
1841
-	private function _verify_addons_db( $wpdb_method, $arguments_to_provide ) {
1841
+	private function _verify_addons_db($wpdb_method, $arguments_to_provide) {
1842 1842
 		/** @type WPDB $wpdb */
1843 1843
 		global $wpdb;
1844 1844
 		//ok remember that we've already attempted fixing the addons dbs, in case the problem persists
1845 1845
 		EEM_Base::$_db_verification_level = EEM_Base::db_verified_addons;
1846 1846
 		$error_message = sprintf(
1847
-			__( 'WPDB AGAIN: Error "%1$s" while running the same method and arguments as before. Automatically attempting to fix EE Addons DB', 'event_espresso' ),
1847
+			__('WPDB AGAIN: Error "%1$s" while running the same method and arguments as before. Automatically attempting to fix EE Addons DB', 'event_espresso'),
1848 1848
 			$wpdb->last_error,
1849 1849
 			$wpdb_method,
1850
-			json_encode( $arguments_to_provide )
1850
+			json_encode($arguments_to_provide)
1851 1851
 		);
1852 1852
 		EE_System::instance()->initialize_addons();
1853 1853
 		return $error_message;
@@ -1862,7 +1862,7 @@  discard block
 block discarded – undo
1862 1862
 	 * @param EE_Model_Query_Info_Carrier $model_query_info
1863 1863
 	 * @return string
1864 1864
 	 */
1865
-	private function _construct_2nd_half_of_select_query(EE_Model_Query_Info_Carrier $model_query_info){
1865
+	private function _construct_2nd_half_of_select_query(EE_Model_Query_Info_Carrier $model_query_info) {
1866 1866
 		return " FROM ".$model_query_info->get_full_join_sql().
1867 1867
 				$model_query_info->get_where_sql().
1868 1868
 				$model_query_info->get_group_by_sql().
@@ -1875,7 +1875,7 @@  discard block
 block discarded – undo
1875 1875
 	 * Set to easily debug the next X queries ran from this model.
1876 1876
 	 * @param int $count
1877 1877
 	 */
1878
-	function show_next_x_db_queries($count = 1){
1878
+	function show_next_x_db_queries($count = 1) {
1879 1879
 		$this->_show_next_x_db_queries = $count;
1880 1880
 	}
1881 1881
 
@@ -1884,8 +1884,8 @@  discard block
 block discarded – undo
1884 1884
 	/**
1885 1885
 	 * @param $sql_query
1886 1886
 	 */
1887
-	function show_db_query_if_previously_requested($sql_query){
1888
-		if($this->_show_next_x_db_queries > 0){
1887
+	function show_db_query_if_previously_requested($sql_query) {
1888
+		if ($this->_show_next_x_db_queries > 0) {
1889 1889
 			echo $sql_query;
1890 1890
 			$this->_show_next_x_db_queries--;
1891 1891
 		}
@@ -1909,7 +1909,7 @@  discard block
 block discarded – undo
1909 1909
 	 * @param array   $extra_join_model_fields_n_values This allows you to enter further query params for the relation to for relation to methods that allow you to further specify extra columns to join by (such as HABTM).  Keep in mind that the only acceptable query_params is strict "col" => "value" pairs because these will be inserted in any new rows created as well.
1910 1910
 	 * @return EE_Base_Class which was added as a relation. Object referred to by $other_model_id_or_obj
1911 1911
 	 */
1912
-	public function add_relationship_to($id_or_obj,$other_model_id_or_obj, $relationName, $extra_join_model_fields_n_values = array()){
1912
+	public function add_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $extra_join_model_fields_n_values = array()) {
1913 1913
 		$relation_obj = $this->related_settings_for($relationName);
1914 1914
 		return $relation_obj->add_relation_to($id_or_obj, $other_model_id_or_obj, $extra_join_model_fields_n_values);
1915 1915
 	}
@@ -1930,9 +1930,9 @@  discard block
 block discarded – undo
1930 1930
 	 * @return boolean of success
1931 1931
 	 * @param array   $where_query This allows you to enter further query params for the relation to for relation to methods that allow you to further specify extra columns to join by (such as HABTM).  Keep in mind that the only acceptable query_params is strict "col" => "value" pairs because these will be inserted in any new rows created as well.
1932 1932
 	 */
1933
-	public function remove_relationship_to($id_or_obj,  $other_model_id_or_obj, $relationName, $where_query= array() ){
1933
+	public function remove_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query = array()) {
1934 1934
 		$relation_obj = $this->related_settings_for($relationName);
1935
-		return $relation_obj->remove_relation_to($id_or_obj, $other_model_id_or_obj, $where_query );
1935
+		return $relation_obj->remove_relation_to($id_or_obj, $other_model_id_or_obj, $where_query);
1936 1936
 	}
1937 1937
 
1938 1938
 
@@ -1945,9 +1945,9 @@  discard block
 block discarded – undo
1945 1945
 	 * @param EE_Base_Class[] objects to which relations were removed
1946 1946
 	 * @return \EE_Base_Class[]
1947 1947
 	 */
1948
-	public function remove_relations($id_or_obj,$relationName,$where_query_params = array()){
1948
+	public function remove_relations($id_or_obj, $relationName, $where_query_params = array()) {
1949 1949
 		$relation_obj = $this->related_settings_for($relationName);
1950
-		return $relation_obj->remove_relations($id_or_obj, $where_query_params );
1950
+		return $relation_obj->remove_relations($id_or_obj, $where_query_params);
1951 1951
 	}
1952 1952
 
1953 1953
 
@@ -1960,10 +1960,10 @@  discard block
 block discarded – undo
1960 1960
 	 * @param array $query_params like EEM_Base::get_all
1961 1961
 	 * @return EE_Base_Class[]
1962 1962
 	 */
1963
-	function get_all_related($id_or_obj, $model_name, $query_params = null){
1963
+	function get_all_related($id_or_obj, $model_name, $query_params = null) {
1964 1964
 		$model_obj = $this->ensure_is_obj($id_or_obj);
1965 1965
 		$relation_settings = $this->related_settings_for($model_name);
1966
-		return $relation_settings->get_all_related($model_obj,$query_params);
1966
+		return $relation_settings->get_all_related($model_obj, $query_params);
1967 1967
 	}
1968 1968
 
1969 1969
 	/**
@@ -1976,10 +1976,10 @@  discard block
 block discarded – undo
1976 1976
 	 * @param array $query_params
1977 1977
 	 * @return int how many deleted
1978 1978
 	 */
1979
-	public function delete_related($id_or_obj,$model_name, $query_params = array()){
1979
+	public function delete_related($id_or_obj, $model_name, $query_params = array()) {
1980 1980
 		$model_obj = $this->ensure_is_obj($id_or_obj);
1981 1981
 		$relation_settings = $this->related_settings_for($model_name);
1982
-		return $relation_settings->delete_all_related($model_obj,$query_params);
1982
+		return $relation_settings->delete_all_related($model_obj, $query_params);
1983 1983
 	}
1984 1984
 
1985 1985
 	/**
@@ -1992,10 +1992,10 @@  discard block
 block discarded – undo
1992 1992
 	 * @param array $query_params
1993 1993
 	 * @return int how many deleted
1994 1994
 	 */
1995
-	public function delete_related_permanently($id_or_obj,$model_name, $query_params = array()){
1995
+	public function delete_related_permanently($id_or_obj, $model_name, $query_params = array()) {
1996 1996
 		$model_obj = $this->ensure_is_obj($id_or_obj);
1997 1997
 		$relation_settings = $this->related_settings_for($model_name);
1998
-		return $relation_settings->delete_related_permanently($model_obj,$query_params);
1998
+		return $relation_settings->delete_related_permanently($model_obj, $query_params);
1999 1999
 	}
2000 2000
 
2001 2001
 	/**
@@ -2008,17 +2008,17 @@  discard block
 block discarded – undo
2008 2008
 	 * @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;
2009 2009
 	 * @return int
2010 2010
 	 */
2011
-	function count_related($id_or_obj,$model_name,$query_params = array(),$field_to_count = null, $distinct = FALSE){
2011
+	function count_related($id_or_obj, $model_name, $query_params = array(), $field_to_count = null, $distinct = FALSE) {
2012 2012
 		$related_model = $this->get_related_model_obj($model_name);
2013 2013
 		//we're just going to use the query params on the related model's normal get_all query,
2014 2014
 		//except add a condition to say to match the current mod
2015
-		if( ! isset($query_params['default_where_conditions'])){
2016
-			$query_params['default_where_conditions']='none';
2015
+		if ( ! isset($query_params['default_where_conditions'])) {
2016
+			$query_params['default_where_conditions'] = 'none';
2017 2017
 		}
2018 2018
 		$this_model_name = $this->get_this_model_name();
2019 2019
 		$this_pk_field_name = $this->get_primary_key_field()->get_name();
2020
-		$query_params[0][$this_model_name.".".$this_pk_field_name]=$id_or_obj;
2021
-		return $related_model->count($query_params,$field_to_count,$distinct);
2020
+		$query_params[0][$this_model_name.".".$this_pk_field_name] = $id_or_obj;
2021
+		return $related_model->count($query_params, $field_to_count, $distinct);
2022 2022
 	}
2023 2023
 
2024 2024
 
@@ -2032,21 +2032,21 @@  discard block
 block discarded – undo
2032 2032
 	 * @param string $field_to_sum name of field to count by. By default, uses primary key
2033 2033
 	 * @return float
2034 2034
 	 */
2035
-	function sum_related($id_or_obj,$model_name,$query_params,$field_to_sum = null){
2035
+	function sum_related($id_or_obj, $model_name, $query_params, $field_to_sum = null) {
2036 2036
 		$related_model = $this->get_related_model_obj($model_name);
2037
-		if( ! is_array( $query_params ) ){
2038
-			EE_Error::doing_it_wrong('EEM_Base::sum_related', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' );
2037
+		if ( ! is_array($query_params)) {
2038
+			EE_Error::doing_it_wrong('EEM_Base::sum_related', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0');
2039 2039
 			$query_params = array();
2040 2040
 		}
2041 2041
 		//we're just going to use the query params on the related model's normal get_all query,
2042 2042
 		//except add a condition to say to match the current mod
2043
-		if( ! isset($query_params['default_where_conditions'])){
2044
-			$query_params['default_where_conditions']='none';
2043
+		if ( ! isset($query_params['default_where_conditions'])) {
2044
+			$query_params['default_where_conditions'] = 'none';
2045 2045
 		}
2046 2046
 		$this_model_name = $this->get_this_model_name();
2047 2047
 		$this_pk_field_name = $this->get_primary_key_field()->get_name();
2048
-		$query_params[0][$this_model_name.".".$this_pk_field_name]=$id_or_obj;
2049
-		return $related_model->sum($query_params,$field_to_sum);
2048
+		$query_params[0][$this_model_name.".".$this_pk_field_name] = $id_or_obj;
2049
+		return $related_model->sum($query_params, $field_to_sum);
2050 2050
 	}
2051 2051
 
2052 2052
 
@@ -2058,12 +2058,12 @@  discard block
 block discarded – undo
2058 2058
 	 * @param array $query_params like EEM_Base::get_all's
2059 2059
 	 * @return EE_Base_Class
2060 2060
 	 */
2061
-	public function get_first_related( EE_Base_Class $id_or_obj, $other_model_name, $query_params ){
2062
-		$query_params['limit']=1;
2063
-		$results = $this->get_all_related($id_or_obj,$other_model_name,$query_params);
2064
-		if( $results ){
2061
+	public function get_first_related(EE_Base_Class $id_or_obj, $other_model_name, $query_params) {
2062
+		$query_params['limit'] = 1;
2063
+		$results = $this->get_all_related($id_or_obj, $other_model_name, $query_params);
2064
+		if ($results) {
2065 2065
 			return array_shift($results);
2066
-		}else{
2066
+		} else {
2067 2067
 			return null;
2068 2068
 		}
2069 2069
 
@@ -2073,8 +2073,8 @@  discard block
 block discarded – undo
2073 2073
 	 * Gets the model's name as it's expected in queries. For example, if this is EEM_Event model, that would be Event
2074 2074
 	 * @return string
2075 2075
 	 */
2076
-	function get_this_model_name(){
2077
-		return str_replace("EEM_","",get_class($this));
2076
+	function get_this_model_name() {
2077
+		return str_replace("EEM_", "", get_class($this));
2078 2078
 	}
2079 2079
 
2080 2080
 	/**
@@ -2082,14 +2082,14 @@  discard block
 block discarded – undo
2082 2082
 	 * @return EE_Any_Foreign_Model_Name_Field
2083 2083
 	 * @throws EE_Error
2084 2084
 	 */
2085
-	public function get_field_containing_related_model_name(){
2086
-		foreach($this->field_settings(true) as $field){
2087
-			if($field instanceof EE_Any_Foreign_Model_Name_Field){
2085
+	public function get_field_containing_related_model_name() {
2086
+		foreach ($this->field_settings(true) as $field) {
2087
+			if ($field instanceof EE_Any_Foreign_Model_Name_Field) {
2088 2088
 				$field_with_model_name = $field;
2089 2089
 			}
2090 2090
 		}
2091
-		if( !isset($field_with_model_name) || !$field_with_model_name ){
2092
-			throw new EE_Error(sprintf(__("There is no EE_Any_Foreign_Model_Name field on model %s", "event_espresso"), $this->get_this_model_name() ));
2091
+		if ( ! isset($field_with_model_name) || ! $field_with_model_name) {
2092
+			throw new EE_Error(sprintf(__("There is no EE_Any_Foreign_Model_Name field on model %s", "event_espresso"), $this->get_this_model_name()));
2093 2093
 		}
2094 2094
 		return $field_with_model_name;
2095 2095
 	}
@@ -2110,19 +2110,19 @@  discard block
 block discarded – undo
2110 2110
 	 * @return int new primary key on main table that got inserted
2111 2111
 	 * @throws EE_Error
2112 2112
 	 */
2113
-	function insert($field_n_values){
2113
+	function insert($field_n_values) {
2114 2114
 		/**
2115 2115
 		 * Filters the fields and their values before inserting an item using the models
2116 2116
 		 * @param array $fields_n_values keys are the fields and values are their new values
2117 2117
 		 * @param EEM_Base $model the model used
2118 2118
 		 */
2119
-		$field_n_values = apply_filters( 'FHEE__EEM_Base__insert__fields_n_values', $field_n_values, $this );
2120
-		if($this->_satisfies_unique_indexes($field_n_values)){
2119
+		$field_n_values = apply_filters('FHEE__EEM_Base__insert__fields_n_values', $field_n_values, $this);
2120
+		if ($this->_satisfies_unique_indexes($field_n_values)) {
2121 2121
 			$main_table = $this->_get_main_table();
2122 2122
 			$new_id = $this->_insert_into_specific_table($main_table, $field_n_values, false);
2123
-			if( $new_id !== false ) {
2124
-				foreach($this->_get_other_tables() as $other_table){
2125
-					$this->_insert_into_specific_table($other_table, $field_n_values,$new_id);
2123
+			if ($new_id !== false) {
2124
+				foreach ($this->_get_other_tables() as $other_table) {
2125
+					$this->_insert_into_specific_table($other_table, $field_n_values, $new_id);
2126 2126
 				}
2127 2127
 			}
2128 2128
 			/**
@@ -2132,9 +2132,9 @@  discard block
 block discarded – undo
2132 2132
 			 * @param array $fields_n_values fields and their values
2133 2133
 			 * @param int|string the ID of the newly-inserted model object
2134 2134
 			 */
2135
-			do_action( 'AHEE__EEM_Base__insert__end', $this, $field_n_values, $new_id );
2135
+			do_action('AHEE__EEM_Base__insert__end', $this, $field_n_values, $new_id);
2136 2136
 			return $new_id;
2137
-		}else{
2137
+		} else {
2138 2138
 			return FALSE;
2139 2139
 		}
2140 2140
 	}
@@ -2147,11 +2147,11 @@  discard block
 block discarded – undo
2147 2147
 	 * @param string $action
2148 2148
 	 * @return boolean
2149 2149
 	 */
2150
-	protected function _satisfies_unique_indexes($field_n_values,$action = 'insert'){
2151
-		foreach($this->unique_indexes() as $index_name => $index){
2150
+	protected function _satisfies_unique_indexes($field_n_values, $action = 'insert') {
2151
+		foreach ($this->unique_indexes() as $index_name => $index) {
2152 2152
 			$uniqueness_where_params = array_intersect_key($field_n_values, $index->fields());
2153
-			if($this->exists(array($uniqueness_where_params))){
2154
-				EE_Error::add_error(sprintf(__("Could not %s %s. %s uniqueness index failed. Fields %s must form a unique set, but an entry already exists with values %s.", "event_espresso"),$action,$this->_get_class_name(),$index_name,implode(",",$index->field_names()),http_build_query($uniqueness_where_params)), __FILE__, __FUNCTION__, __LINE__ );
2153
+			if ($this->exists(array($uniqueness_where_params))) {
2154
+				EE_Error::add_error(sprintf(__("Could not %s %s. %s uniqueness index failed. Fields %s must form a unique set, but an entry already exists with values %s.", "event_espresso"), $action, $this->_get_class_name(), $index_name, implode(",", $index->field_names()), http_build_query($uniqueness_where_params)), __FILE__, __FUNCTION__, __LINE__);
2155 2155
 				return false;
2156 2156
 			}
2157 2157
 		}
@@ -2172,28 +2172,28 @@  discard block
 block discarded – undo
2172 2172
 	 * @throws EE_Error
2173 2173
 	 * @return EE_Base_Class
2174 2174
 	 */
2175
-	public function get_one_conflicting($obj_or_fields_array, $include_primary_key = true ){
2176
-		if($obj_or_fields_array instanceof EE_Base_Class){
2175
+	public function get_one_conflicting($obj_or_fields_array, $include_primary_key = true) {
2176
+		if ($obj_or_fields_array instanceof EE_Base_Class) {
2177 2177
 			$fields_n_values = $obj_or_fields_array->model_field_array();
2178
-		}elseif( is_array($obj_or_fields_array)){
2178
+		}elseif (is_array($obj_or_fields_array)) {
2179 2179
 			$fields_n_values = $obj_or_fields_array;
2180
-		}else{
2181
-			throw new EE_Error(sprintf(__("%s get_all_conflicting should be called with a model object or an array of field names and values, you provided %d", "event_espresso"),get_class($this),$obj_or_fields_array));
2180
+		} else {
2181
+			throw new EE_Error(sprintf(__("%s get_all_conflicting should be called with a model object or an array of field names and values, you provided %d", "event_espresso"), get_class($this), $obj_or_fields_array));
2182 2182
 		}
2183 2183
 		$query_params = array();
2184
-		if( $this->has_primary_key_field() &&
2185
-				( $include_primary_key || $this->get_primary_key_field() instanceof EE_Primary_Key_String_Field) &&
2186
-				isset($fields_n_values[$this->primary_key_name()])){
2184
+		if ($this->has_primary_key_field() &&
2185
+				($include_primary_key || $this->get_primary_key_field() instanceof EE_Primary_Key_String_Field) &&
2186
+				isset($fields_n_values[$this->primary_key_name()])) {
2187 2187
 			$query_params[0]['OR'][$this->primary_key_name()] = $fields_n_values[$this->primary_key_name()];
2188 2188
 		}
2189
-		foreach($this->unique_indexes() as $unique_index_name=>$unique_index){
2189
+		foreach ($this->unique_indexes() as $unique_index_name=>$unique_index) {
2190 2190
 			$uniqueness_where_params = array_intersect_key($fields_n_values, $unique_index->fields());
2191 2191
 			$query_params[0]['OR']['AND*'.$unique_index_name] = $uniqueness_where_params;
2192 2192
 		}
2193 2193
 		//if there is nothing to base this search on, then we shouldn't find anything
2194
-		if( empty( $query_params ) ){
2194
+		if (empty($query_params)) {
2195 2195
 			return array();
2196
-		}else{
2196
+		} else {
2197 2197
 			return $this->get_one($query_params);
2198 2198
 		}
2199 2199
 	}
@@ -2203,7 +2203,7 @@  discard block
 block discarded – undo
2203 2203
 	 * @param array $query_params
2204 2204
 	 * @return boolean
2205 2205
 	 */
2206
-	function exists($query_params){
2206
+	function exists($query_params) {
2207 2207
 		$query_params['limit'] = 1;
2208 2208
 		return $this->count($query_params) > 0;
2209 2209
 	}
@@ -2213,7 +2213,7 @@  discard block
 block discarded – undo
2213 2213
 	 * @param int|string $id
2214 2214
 	 * @return boolean
2215 2215
 	 */
2216
-	function exists_by_ID($id){
2216
+	function exists_by_ID($id) {
2217 2217
 		return $this->exists(array('default_where_conditions'=>'none', array($this->primary_key_name() => $id)));
2218 2218
 	}
2219 2219
 
@@ -2233,45 +2233,45 @@  discard block
 block discarded – undo
2233 2233
 	 * @global WPDB $wpdb only used to get the $wpdb->insert_id after performing an insert
2234 2234
 	 * @return int ID of new row inserted, or FALSE on failure
2235 2235
 	 */
2236
-	protected function _insert_into_specific_table(EE_Table_Base $table, $fields_n_values, $new_id = 0 ){
2236
+	protected function _insert_into_specific_table(EE_Table_Base $table, $fields_n_values, $new_id = 0) {
2237 2237
 		global $wpdb;
2238 2238
 		$insertion_col_n_values = array();
2239 2239
 		$format_for_insertion = array();
2240 2240
 		$fields_on_table = $this->_get_fields_for_table($table->get_table_alias());
2241
-		foreach($fields_on_table as $field_name => $field_obj){
2241
+		foreach ($fields_on_table as $field_name => $field_obj) {
2242 2242
 			//check if its an auto-incrementing column, in which case we should just leave it to do its autoincrement thing
2243
-			if($field_obj->is_auto_increment()){
2243
+			if ($field_obj->is_auto_increment()) {
2244 2244
 				continue;
2245 2245
 			}
2246 2246
 			$prepared_value = $this->_prepare_value_or_use_default($field_obj, $fields_n_values);
2247 2247
 			//if the value we want to assign it to is NULL, just don't mention it for the insertion
2248
-			if( $prepared_value !== NULL ){
2249
-				$insertion_col_n_values[ $field_obj->get_table_column() ] = $prepared_value;
2248
+			if ($prepared_value !== NULL) {
2249
+				$insertion_col_n_values[$field_obj->get_table_column()] = $prepared_value;
2250 2250
 				$format_for_insertion[] = $field_obj->get_wpdb_data_type();
2251 2251
 			}
2252 2252
 		}
2253 2253
 
2254
-		if($table instanceof EE_Secondary_Table && $new_id){
2254
+		if ($table instanceof EE_Secondary_Table && $new_id) {
2255 2255
 			//its not the main table, so we should have already saved the main table's PK which we just inserted
2256 2256
 			//so add the fk to the main table as a column
2257 2257
 			$insertion_col_n_values[$table->get_fk_on_table()] = $new_id;
2258
-			$format_for_insertion[]='%d';//yes right now we're only allowing these foreign keys to be INTs
2258
+			$format_for_insertion[] = '%d'; //yes right now we're only allowing these foreign keys to be INTs
2259 2259
 		}
2260 2260
 		//insert the new entry
2261
-		$result = $this->_do_wpdb_query( 'insert', array( $table->get_table_name(), $insertion_col_n_values, $format_for_insertion ) );
2262
-		if( $result === false ) {
2261
+		$result = $this->_do_wpdb_query('insert', array($table->get_table_name(), $insertion_col_n_values, $format_for_insertion));
2262
+		if ($result === false) {
2263 2263
 			return false;
2264 2264
 		}
2265 2265
 		//ok, now what do we return for the ID of the newly-inserted thing?
2266
-		if($this->has_primary_key_field()){
2267
-			if($this->get_primary_key_field()->is_auto_increment()){
2266
+		if ($this->has_primary_key_field()) {
2267
+			if ($this->get_primary_key_field()->is_auto_increment()) {
2268 2268
 				return $wpdb->insert_id;
2269
-			}else{
2269
+			} else {
2270 2270
 				//it's not an auto-increment primary key, so
2271 2271
 				//it must have been supplied
2272 2272
 				return $fields_n_values[$this->get_primary_key_field()->get_name()];
2273 2273
 			}
2274
-		}else{
2274
+		} else {
2275 2275
 			//we can't return a  primary key because there is none. instead return
2276 2276
 			//a unique string indicating this model
2277 2277
 			return $this->get_index_primary_key_string($fields_n_values);
@@ -2286,15 +2286,15 @@  discard block
 block discarded – undo
2286 2286
 	 * @param array $fields_n_values
2287 2287
 	 * @return mixed string|int|float depending on what the table column will be expecting
2288 2288
 	 */
2289
-	protected function _prepare_value_or_use_default( $field_obj, $fields_n_values ){
2289
+	protected function _prepare_value_or_use_default($field_obj, $fields_n_values) {
2290 2290
 		//if this field doesn't allow nullable, don't allow it
2291
-		if( ! $field_obj->is_nullable() && (
2292
-				! isset( $fields_n_values[ $field_obj->get_name() ] ) ||
2293
-				$fields_n_values[ $field_obj->get_name() ] === NULL ) ){
2294
-			$fields_n_values[ $field_obj->get_name() ] = $field_obj->get_default_value();
2291
+		if ( ! $field_obj->is_nullable() && (
2292
+				! isset($fields_n_values[$field_obj->get_name()]) ||
2293
+				$fields_n_values[$field_obj->get_name()] === NULL )) {
2294
+			$fields_n_values[$field_obj->get_name()] = $field_obj->get_default_value();
2295 2295
 		}
2296
-		$unprepared_value = isset( $fields_n_values[ $field_obj->get_name() ] ) ? $fields_n_values[ $field_obj->get_name() ] : NULL;
2297
-		return $this->_prepare_value_for_use_in_db( $unprepared_value, $field_obj);
2296
+		$unprepared_value = isset($fields_n_values[$field_obj->get_name()]) ? $fields_n_values[$field_obj->get_name()] : NULL;
2297
+		return $this->_prepare_value_for_use_in_db($unprepared_value, $field_obj);
2298 2298
 	}
2299 2299
 
2300 2300
 
@@ -2306,9 +2306,9 @@  discard block
 block discarded – undo
2306 2306
 	 * @param EE_Model_Field_Base $field field which will be doing the preparing of the value. If null, we assume $value is a custom selection
2307 2307
 	 * @return mixed a value ready for use in the database for insertions, updating, or in a where clause
2308 2308
 	 */
2309
-	private function _prepare_value_for_use_in_db($value, $field){
2310
-		if($field && $field instanceof EE_Model_Field_Base){
2311
-			switch( $this->_values_already_prepared_by_model_object ){
2309
+	private function _prepare_value_for_use_in_db($value, $field) {
2310
+		if ($field && $field instanceof EE_Model_Field_Base) {
2311
+			switch ($this->_values_already_prepared_by_model_object) {
2312 2312
 				/** @noinspection PhpMissingBreakStatementInspection */
2313 2313
 				case self::not_prepared_by_model_object:
2314 2314
 					$value = $field->prepare_for_set($value);
@@ -2319,7 +2319,7 @@  discard block
 block discarded – undo
2319 2319
 					//leave the value alone
2320 2320
 			}
2321 2321
 			return $value;
2322
-		}else{
2322
+		} else {
2323 2323
 			return $value;
2324 2324
 		}
2325 2325
 	}
@@ -2329,13 +2329,13 @@  discard block
 block discarded – undo
2329 2329
 	 * @return EE_Primary_Table
2330 2330
 	 * @throws EE_Error
2331 2331
 	 */
2332
-	protected function _get_main_table(){
2333
-		foreach($this->_tables as $table){
2334
-			if($table instanceof EE_Primary_Table){
2332
+	protected function _get_main_table() {
2333
+		foreach ($this->_tables as $table) {
2334
+			if ($table instanceof EE_Primary_Table) {
2335 2335
 				return $table;
2336 2336
 			}
2337 2337
 		}
2338
-		throw new EE_Error(sprintf(__('There are no main tables on %s. They should be added to _tables array in the constructor','event_espresso'),get_class($this)));
2338
+		throw new EE_Error(sprintf(__('There are no main tables on %s. They should be added to _tables array in the constructor', 'event_espresso'), get_class($this)));
2339 2339
 	}
2340 2340
 
2341 2341
 	/**
@@ -2354,7 +2354,7 @@  discard block
 block discarded – undo
2354 2354
 	 */
2355 2355
 	public function second_table() {
2356 2356
 		// grab second table from tables array
2357
-		$second_table = end( $this->_tables );
2357
+		$second_table = end($this->_tables);
2358 2358
 		return $second_table instanceof EE_Secondary_Table ? $second_table->get_table_name() : NULL;
2359 2359
 	}
2360 2360
 
@@ -2367,8 +2367,8 @@  discard block
 block discarded – undo
2367 2367
 	 * @param string $table_alias
2368 2368
 	 * @return EE_Primary_Table | EE_Secondary_Table
2369 2369
 	 */
2370
-	public function get_table_obj_by_alias( $table_alias = '' ) {
2371
-		return isset( $this->_tables[ $table_alias ] ) ? $this->_tables[ $table_alias ] : NULL;
2370
+	public function get_table_obj_by_alias($table_alias = '') {
2371
+		return isset($this->_tables[$table_alias]) ? $this->_tables[$table_alias] : NULL;
2372 2372
 	}
2373 2373
 
2374 2374
 
@@ -2377,10 +2377,10 @@  discard block
 block discarded – undo
2377 2377
 	 * Gets all the tables of type EE_Other_Table from EEM_CPT_Basel_Model::_tables
2378 2378
 	 * @return EE_Secondary_Table[]
2379 2379
 	 */
2380
-	protected function _get_other_tables(){
2381
-		$other_tables =array();
2382
-		foreach($this->_tables as $table_alias => $table){
2383
-			if($table instanceof EE_Secondary_Table){
2380
+	protected function _get_other_tables() {
2381
+		$other_tables = array();
2382
+		foreach ($this->_tables as $table_alias => $table) {
2383
+			if ($table instanceof EE_Secondary_Table) {
2384 2384
 				$other_tables[$table_alias] = $table;
2385 2385
 			}
2386 2386
 		}
@@ -2392,7 +2392,7 @@  discard block
 block discarded – undo
2392 2392
 	 * @param string $table_alias, array key in EEM_Base::_tables
2393 2393
 	 * @return EE_Model_Field_Base[]
2394 2394
 	 */
2395
-	function _get_fields_for_table($table_alias){
2395
+	function _get_fields_for_table($table_alias) {
2396 2396
 		return $this->_fields[$table_alias];
2397 2397
 	}
2398 2398
 
@@ -2404,29 +2404,29 @@  discard block
 block discarded – undo
2404 2404
 	 * @param array $query_params like EEM_Base::get_all's $query_parameters['where']
2405 2405
 	 * @return EE_Model_Query_Info_Carrier
2406 2406
 	 */
2407
-	function _extract_related_models_from_query($query_params){
2407
+	function _extract_related_models_from_query($query_params) {
2408 2408
 		$query_info_carrier = new EE_Model_Query_Info_Carrier();
2409
-		if(array_key_exists(0,$query_params)){
2410
-			$this->_extract_related_models_from_sub_params_array_keys($query_params[0], $query_info_carrier,0);
2411
-		}
2412
-		if(array_key_exists('group_by', $query_params)){
2413
-			if(is_array($query_params['group_by'])){
2414
-				$this->_extract_related_models_from_sub_params_array_values($query_params['group_by'],$query_info_carrier,'group_by');
2415
-			}elseif( ! empty ( $query_params['group_by'] )){
2416
-				$this->_extract_related_model_info_from_query_param( $query_params['group_by'],$query_info_carrier,'group_by');
2409
+		if (array_key_exists(0, $query_params)) {
2410
+			$this->_extract_related_models_from_sub_params_array_keys($query_params[0], $query_info_carrier, 0);
2411
+		}
2412
+		if (array_key_exists('group_by', $query_params)) {
2413
+			if (is_array($query_params['group_by'])) {
2414
+				$this->_extract_related_models_from_sub_params_array_values($query_params['group_by'], $query_info_carrier, 'group_by');
2415
+			}elseif ( ! empty ($query_params['group_by'])) {
2416
+				$this->_extract_related_model_info_from_query_param($query_params['group_by'], $query_info_carrier, 'group_by');
2417 2417
 			}
2418 2418
 		}
2419
-		if(array_key_exists('having',$query_params)){
2420
-			$this->_extract_related_models_from_sub_params_array_keys($query_params[0], $query_info_carrier,'having');
2419
+		if (array_key_exists('having', $query_params)) {
2420
+			$this->_extract_related_models_from_sub_params_array_keys($query_params[0], $query_info_carrier, 'having');
2421 2421
 		}
2422
-		if(array_key_exists('order_by', $query_params)){
2423
-			if ( is_array( $query_params['order_by'] ) )
2424
-				$this->_extract_related_models_from_sub_params_array_keys($query_params['order_by'],$query_info_carrier,'order_by');
2425
-			elseif( ! empty( $query_params['order_by'] ))
2426
-				$this->_extract_related_model_info_from_query_param( $query_params['order_by'], $query_info_carrier,'order_by');
2422
+		if (array_key_exists('order_by', $query_params)) {
2423
+			if (is_array($query_params['order_by']))
2424
+				$this->_extract_related_models_from_sub_params_array_keys($query_params['order_by'], $query_info_carrier, 'order_by');
2425
+			elseif ( ! empty($query_params['order_by']))
2426
+				$this->_extract_related_model_info_from_query_param($query_params['order_by'], $query_info_carrier, 'order_by');
2427 2427
 		}
2428
-		if(array_key_exists('force_join', $query_params)){
2429
-			$this->_extract_related_models_from_sub_params_array_values($query_params['force_join'],$query_info_carrier,'force_join');
2428
+		if (array_key_exists('force_join', $query_params)) {
2429
+			$this->_extract_related_models_from_sub_params_array_values($query_params['force_join'], $query_info_carrier, 'force_join');
2430 2430
 		}
2431 2431
 		return $query_info_carrier;
2432 2432
 	}
@@ -2439,34 +2439,34 @@  discard block
 block discarded – undo
2439 2439
 	 * @throws EE_Error
2440 2440
 	 * @return \EE_Model_Query_Info_Carrier
2441 2441
 	 */
2442
-	private function _extract_related_models_from_sub_params_array_keys($sub_query_params, EE_Model_Query_Info_Carrier $model_query_info_carrier,$query_param_type){
2443
-		if (!empty($sub_query_params)){
2442
+	private function _extract_related_models_from_sub_params_array_keys($sub_query_params, EE_Model_Query_Info_Carrier $model_query_info_carrier, $query_param_type) {
2443
+		if ( ! empty($sub_query_params)) {
2444 2444
 			$sub_query_params = (array) $sub_query_params;
2445
-			foreach($sub_query_params as $param => $possibly_array_of_params){
2445
+			foreach ($sub_query_params as $param => $possibly_array_of_params) {
2446 2446
 				//$param could be simply 'EVT_ID', or it could be 'Registrations.REG_ID', or even 'Registrations.Transactions.Payments.PAY_amount'
2447
-				$this->_extract_related_model_info_from_query_param( $param, $model_query_info_carrier,$query_param_type);
2447
+				$this->_extract_related_model_info_from_query_param($param, $model_query_info_carrier, $query_param_type);
2448 2448
 
2449 2449
 				//if $possibly_array_of_params is an array, try recursing into it, searching for keys which
2450 2450
 				//indicate needed joins. Eg, array('NOT'=>array('Registration.TXN_ID'=>23)). In this case, we tried
2451 2451
 				//extracting models out of the 'NOT', which obviously wasn't successful, and then we recurse into the value
2452 2452
 				//of array('Registration.TXN_ID'=>23)
2453 2453
 				$query_param_sans_stars = $this->_remove_stars_and_anything_after_from_condition_query_param_key($param);
2454
-				if(in_array($query_param_sans_stars, $this->_logic_query_param_keys,true)){
2455
-					if (! is_array($possibly_array_of_params)){
2454
+				if (in_array($query_param_sans_stars, $this->_logic_query_param_keys, true)) {
2455
+					if ( ! is_array($possibly_array_of_params)) {
2456 2456
 						throw new EE_Error(sprintf(__("You used a special where query param %s, but the value isn't an array of where query params, it's just %s'. It should be an array, eg array('EVT_ID'=>23,'OR'=>array('Venue.VNU_ID'=>32,'Venue.VNU_name'=>'monkey_land'))", "event_espresso"),
2457
-							$param,$possibly_array_of_params));
2458
-					}else{
2459
-						$this->_extract_related_models_from_sub_params_array_keys($possibly_array_of_params, $model_query_info_carrier,$query_param_type);
2457
+							$param, $possibly_array_of_params));
2458
+					} else {
2459
+						$this->_extract_related_models_from_sub_params_array_keys($possibly_array_of_params, $model_query_info_carrier, $query_param_type);
2460 2460
 					}
2461
-				}elseif($query_param_type === 0 //ie WHERE
2461
+				}elseif ($query_param_type === 0 //ie WHERE
2462 2462
 						&& is_array($possibly_array_of_params)
2463 2463
 						&& isset($possibly_array_of_params[2])
2464
-						&& $possibly_array_of_params[2] == true){
2464
+						&& $possibly_array_of_params[2] == true) {
2465 2465
 					//then $possible_array_of_params looks something like array('<','DTT_sold',true)
2466 2466
 					//indicating that $possible_array_of_params[1] is actually a field name,
2467 2467
 					//from which we should extract query parameters!
2468
-					if(! isset($possibly_array_of_params[0]) || ! isset($possibly_array_of_params[1])){
2469
-						throw new EE_Error(sprintf(__("Improperly formed query parameter %s. It should be numerically indexed like array('<','DTT_sold',true); but you provided %s", "event_espresso"),$query_param_type,implode(",",$possibly_array_of_params)));
2468
+					if ( ! isset($possibly_array_of_params[0]) || ! isset($possibly_array_of_params[1])) {
2469
+						throw new EE_Error(sprintf(__("Improperly formed query parameter %s. It should be numerically indexed like array('<','DTT_sold',true); but you provided %s", "event_espresso"), $query_param_type, implode(",", $possibly_array_of_params)));
2470 2470
 					}
2471 2471
 					$this->_extract_related_model_info_from_query_param($possibly_array_of_params[1], $model_query_info_carrier, $query_param_type);
2472 2472
 				}
@@ -2485,14 +2485,14 @@  discard block
 block discarded – undo
2485 2485
 	 * @throws EE_Error
2486 2486
 	 * @return \EE_Model_Query_Info_Carrier
2487 2487
 	 */
2488
-	private function _extract_related_models_from_sub_params_array_values($sub_query_params, EE_Model_Query_Info_Carrier $model_query_info_carrier,$query_param_type){
2489
-		if (!empty($sub_query_params)){
2490
-			if(!is_array($sub_query_params)){
2491
-				throw new EE_Error(sprintf(__("Query parameter %s should be an array, but it isn't.", "event_espresso"),$sub_query_params));
2488
+	private function _extract_related_models_from_sub_params_array_values($sub_query_params, EE_Model_Query_Info_Carrier $model_query_info_carrier, $query_param_type) {
2489
+		if ( ! empty($sub_query_params)) {
2490
+			if ( ! is_array($sub_query_params)) {
2491
+				throw new EE_Error(sprintf(__("Query parameter %s should be an array, but it isn't.", "event_espresso"), $sub_query_params));
2492 2492
 			}
2493
-			foreach($sub_query_params as $param){
2493
+			foreach ($sub_query_params as $param) {
2494 2494
 				//$param could be simply 'EVT_ID', or it could be 'Registrations.REG_ID', or even 'Registrations.Transactions.Payments.PAY_amount'
2495
-				$this->_extract_related_model_info_from_query_param( $param, $model_query_info_carrier, $query_param_type);
2495
+				$this->_extract_related_model_info_from_query_param($param, $model_query_info_carrier, $query_param_type);
2496 2496
 			}
2497 2497
 		}
2498 2498
 		return $model_query_info_carrier;
@@ -2511,81 +2511,81 @@  discard block
 block discarded – undo
2511 2511
 	 * @throws EE_Error
2512 2512
 	 * @return EE_Model_Query_Info_Carrier
2513 2513
 	 */
2514
-	function _create_model_query_info_carrier($query_params){
2515
-		if( ! is_array( $query_params ) ){
2516
-			EE_Error::doing_it_wrong('EEM_Base::_create_model_query_info_carrier', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' );
2514
+	function _create_model_query_info_carrier($query_params) {
2515
+		if ( ! is_array($query_params)) {
2516
+			EE_Error::doing_it_wrong('EEM_Base::_create_model_query_info_carrier', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0');
2517 2517
 			$query_params = array();
2518 2518
 		}
2519
-		if( isset( $query_params[0] ) ) {
2519
+		if (isset($query_params[0])) {
2520 2520
 			$where_query_params = $query_params[0];
2521
-		}else{
2521
+		} else {
2522 2522
 			$where_query_params = array();
2523 2523
 		}
2524 2524
 		//first check if we should alter the query to account for caps or not
2525 2525
 		//because the caps might require us to do extra joins
2526
-		if( isset( $query_params[ 'caps' ] ) && $query_params[ 'caps' ] != 'none' ) {
2527
-			$query_params[0] = $where_query_params = array_replace_recursive( $where_query_params, $this->caps_where_conditions( $query_params[ 'caps' ] ) );
2526
+		if (isset($query_params['caps']) && $query_params['caps'] != 'none') {
2527
+			$query_params[0] = $where_query_params = array_replace_recursive($where_query_params, $this->caps_where_conditions($query_params['caps']));
2528 2528
 		}
2529 2529
 		$query_object = $this->_extract_related_models_from_query($query_params);
2530 2530
 
2531 2531
 		//verify where_query_params has NO numeric indexes.... that's simply not how you use it!
2532
-		foreach($where_query_params as $key => $value){
2533
-			if(is_int($key)){
2534
-				throw new EE_Error(sprintf(__("WHERE query params must NOT be numerically-indexed. You provided the array key '%s' for value '%s' while querying model %s. All the query params provided were '%s' Please read documentation on EEM_Base::get_all.", "event_espresso"),$key, var_export( $value, true ), var_export( $query_params, true ), get_class($this)));
2532
+		foreach ($where_query_params as $key => $value) {
2533
+			if (is_int($key)) {
2534
+				throw new EE_Error(sprintf(__("WHERE query params must NOT be numerically-indexed. You provided the array key '%s' for value '%s' while querying model %s. All the query params provided were '%s' Please read documentation on EEM_Base::get_all.", "event_espresso"), $key, var_export($value, true), var_export($query_params, true), get_class($this)));
2535 2535
 			}
2536 2536
 		}
2537
-		if( array_key_exists( 'default_where_conditions',$query_params) && ! empty( $query_params['default_where_conditions'] )){
2537
+		if (array_key_exists('default_where_conditions', $query_params) && ! empty($query_params['default_where_conditions'])) {
2538 2538
 			$use_default_where_conditions = $query_params['default_where_conditions'];
2539
-		}else{
2539
+		} else {
2540 2540
 			$use_default_where_conditions = 'all';
2541 2541
 		}
2542
-		$where_query_params = array_merge($this->_get_default_where_conditions_for_models_in_query($query_object,$use_default_where_conditions,$where_query_params), $where_query_params );
2543
-		$query_object->set_where_sql( $this->_construct_where_clause($where_query_params));
2542
+		$where_query_params = array_merge($this->_get_default_where_conditions_for_models_in_query($query_object, $use_default_where_conditions, $where_query_params), $where_query_params);
2543
+		$query_object->set_where_sql($this->_construct_where_clause($where_query_params));
2544 2544
 
2545 2545
 
2546 2546
 		//if this is a "on_join_limit" then we are limiting on on a specific table in a multi_table join.  So we need to setup a subquery and use that for the main join.  Note for now this only works on the primary table for the model.  So for instance, you could set the limit array like this:
2547 2547
 		//array( 'on_join_limit' => array('Primary_Table_Alias', array(1,10) ) )
2548
-		if ( array_key_exists('on_join_limit', $query_params ) && ! empty( $query_params['on_join_limit'] )) {
2549
-			$query_object->set_main_model_join_sql( $this->_construct_limit_join_select( $query_params['on_join_limit'][0], $query_params['on_join_limit'][1] ) );
2548
+		if (array_key_exists('on_join_limit', $query_params) && ! empty($query_params['on_join_limit'])) {
2549
+			$query_object->set_main_model_join_sql($this->_construct_limit_join_select($query_params['on_join_limit'][0], $query_params['on_join_limit'][1]));
2550 2550
 		}
2551 2551
 
2552 2552
 
2553 2553
 		//set limit
2554
-		if(array_key_exists('limit',$query_params)){
2555
-			if(is_array($query_params['limit'])){
2556
-				if( ! isset($query_params['limit'][0]) || ! isset($query_params['limit'][1])){
2557
-					$e = sprintf(__("Invalid DB query. You passed '%s' for the LIMIT, but only the following are valid: an integer, string representing an integer, a string like 'int,int', or an array like array(int,int)", "event_espresso"),  http_build_query($query_params['limit']));
2554
+		if (array_key_exists('limit', $query_params)) {
2555
+			if (is_array($query_params['limit'])) {
2556
+				if ( ! isset($query_params['limit'][0]) || ! isset($query_params['limit'][1])) {
2557
+					$e = sprintf(__("Invalid DB query. You passed '%s' for the LIMIT, but only the following are valid: an integer, string representing an integer, a string like 'int,int', or an array like array(int,int)", "event_espresso"), http_build_query($query_params['limit']));
2558 2558
 					throw new EE_Error($e."|".$e);
2559 2559
 				}
2560 2560
 				//they passed us an array for the limit. Assume it's like array(50,25), meaning offset by 50, and get 25
2561 2561
 				$query_object->set_limit_sql(" LIMIT ".$query_params['limit'][0].",".$query_params['limit'][1]);
2562
-			}elseif( ! empty ( $query_params['limit'] )){
2562
+			}elseif ( ! empty ($query_params['limit'])) {
2563 2563
 				$query_object->set_limit_sql((" LIMIT ".$query_params['limit']));
2564 2564
 			}
2565 2565
 		}
2566 2566
 		//set order by
2567
-		if(array_key_exists('order_by',$query_params)){
2568
-			if(is_array($query_params['order_by'])){
2567
+		if (array_key_exists('order_by', $query_params)) {
2568
+			if (is_array($query_params['order_by'])) {
2569 2569
 				//if they're using 'order_by' as an array, they can't use 'order' (because 'order_by' must
2570 2570
 				//specify whether to ascend or descend on each field. Eg 'order_by'=>array('EVT_ID'=>'ASC'). So
2571 2571
 				//including 'order' wouldn't make any sense if 'order_by' has already specified which way to order!
2572
-				if(array_key_exists('order', $query_params)){
2572
+				if (array_key_exists('order', $query_params)) {
2573 2573
 					throw new EE_Error(sprintf(__("In querying %s, we are using query parameter 'order_by' as an array (keys:%s,values:%s), and so we can't use query parameter 'order' (value %s). You should just use the 'order_by' parameter ", "event_espresso"),
2574
-							get_class($this),implode(", ",array_keys($query_params['order_by'])),implode(", ",$query_params['order_by']),$query_params['order']));
2574
+							get_class($this), implode(", ", array_keys($query_params['order_by'])), implode(", ", $query_params['order_by']), $query_params['order']));
2575 2575
 				}
2576
-				 $this->_extract_related_models_from_sub_params_array_keys($query_params['order_by'],$query_object,'order_by');
2576
+				 $this->_extract_related_models_from_sub_params_array_keys($query_params['order_by'], $query_object, 'order_by');
2577 2577
 				//assume it's an array of fields to order by
2578 2578
 				$order_array = array();
2579
-				foreach($query_params['order_by'] as $field_name_to_order_by => $order){
2579
+				foreach ($query_params['order_by'] as $field_name_to_order_by => $order) {
2580 2580
 					$order = $this->_extract_order($order);
2581 2581
 					$order_array[] = $this->_deduce_column_name_from_query_param($field_name_to_order_by).SP.$order;
2582 2582
 				}
2583
-				$query_object->set_order_by_sql(" ORDER BY ".implode(",",$order_array));
2584
-			}elseif( ! empty ( $query_params['order_by'] )){
2585
-				$this->_extract_related_model_info_from_query_param($query_params['order_by'],$query_object,'order',$query_params['order_by']);
2586
-				if(isset($query_params['order'])){
2583
+				$query_object->set_order_by_sql(" ORDER BY ".implode(",", $order_array));
2584
+			}elseif ( ! empty ($query_params['order_by'])) {
2585
+				$this->_extract_related_model_info_from_query_param($query_params['order_by'], $query_object, 'order', $query_params['order_by']);
2586
+				if (isset($query_params['order'])) {
2587 2587
 					$order = $this->_extract_order($query_params['order']);
2588
-				}else{
2588
+				} else {
2589 2589
 					$order = 'DESC';
2590 2590
 				}
2591 2591
 				$query_object->set_order_by_sql(" ORDER BY ".$this->_deduce_column_name_from_query_param($query_params['order_by']).SP.$order);
@@ -2593,46 +2593,46 @@  discard block
 block discarded – undo
2593 2593
 		}
2594 2594
 
2595 2595
 		//if 'order_by' wasn't set, maybe they are just using 'order' on its own?
2596
-		if( ! array_key_exists('order_by',$query_params) && array_key_exists('order',$query_params) && ! empty( $query_params['order'] )){
2596
+		if ( ! array_key_exists('order_by', $query_params) && array_key_exists('order', $query_params) && ! empty($query_params['order'])) {
2597 2597
 			$pk_field = $this->get_primary_key_field();
2598 2598
 			$order = $this->_extract_order($query_params['order']);
2599 2599
 			$query_object->set_order_by_sql(" ORDER BY ".$pk_field->get_qualified_column().SP.$order);
2600 2600
 		}
2601 2601
 
2602 2602
 		//set group by
2603
-		if(array_key_exists('group_by',$query_params)){
2604
-			if(is_array($query_params['group_by'])){
2603
+		if (array_key_exists('group_by', $query_params)) {
2604
+			if (is_array($query_params['group_by'])) {
2605 2605
 				//it's an array, so assume we'll be grouping by a bunch of stuff
2606 2606
 				$group_by_array = array();
2607
-				foreach($query_params['group_by'] as $field_name_to_group_by){
2607
+				foreach ($query_params['group_by'] as $field_name_to_group_by) {
2608 2608
 					$group_by_array[] = $this->_deduce_column_name_from_query_param($field_name_to_group_by);
2609 2609
 				}
2610
-				$query_object->set_group_by_sql(" GROUP BY ".implode(", ",$group_by_array));
2611
-			}elseif( ! empty ( $query_params['group_by'] )){
2610
+				$query_object->set_group_by_sql(" GROUP BY ".implode(", ", $group_by_array));
2611
+			}elseif ( ! empty ($query_params['group_by'])) {
2612 2612
 				$query_object->set_group_by_sql(" GROUP BY ".$this->_deduce_column_name_from_query_param($query_params['group_by']));
2613 2613
 			}
2614 2614
 		}
2615 2615
 		//set having
2616
-		if(array_key_exists('having',$query_params) && $query_params['having']){
2617
-			$query_object->set_having_sql( $this->_construct_having_clause($query_params['having']));
2616
+		if (array_key_exists('having', $query_params) && $query_params['having']) {
2617
+			$query_object->set_having_sql($this->_construct_having_clause($query_params['having']));
2618 2618
 		}
2619 2619
 
2620 2620
 		//now, just verify they didn't pass anything wack
2621
-		foreach($query_params as $query_key => $query_value){
2622
-			if( ! in_array($query_key,$this->_allowed_query_params,true)){
2621
+		foreach ($query_params as $query_key => $query_value) {
2622
+			if ( ! in_array($query_key, $this->_allowed_query_params, true)) {
2623 2623
 				throw new EE_Error(
2624 2624
 					sprintf(
2625
-						__("You passed %s as a query parameter to %s, which is illegal! The allowed query parameters are %s",'event_espresso'),
2625
+						__("You passed %s as a query parameter to %s, which is illegal! The allowed query parameters are %s", 'event_espresso'),
2626 2626
 						$query_key,
2627 2627
 						get_class($this),
2628 2628
 //						print_r( $this->_allowed_query_params, TRUE )
2629
-						implode( ',', $this->_allowed_query_params )
2629
+						implode(',', $this->_allowed_query_params)
2630 2630
 					)
2631 2631
 				);
2632 2632
 			}
2633 2633
 		}
2634 2634
 		$main_model_join_sql = $query_object->get_main_model_join_sql();
2635
-		if ( empty( $main_model_join_sql ) )
2635
+		if (empty($main_model_join_sql))
2636 2636
 			$query_object->set_main_model_join_sql($this->_construct_internal_join());
2637 2637
 		return $query_object;
2638 2638
 	}
@@ -2643,17 +2643,17 @@  discard block
 block discarded – undo
2643 2643
 	 * @param string $context one of EEM_Base::valid_cap_contexts()
2644 2644
 	 * @return array like EEM_Base::get_all() 's $query_params[0]
2645 2645
 	 */
2646
-	public function caps_where_conditions( $context = self::caps_read ) {
2647
-		EEM_Base::verify_is_valid_cap_context( $context );
2646
+	public function caps_where_conditions($context = self::caps_read) {
2647
+		EEM_Base::verify_is_valid_cap_context($context);
2648 2648
 		$cap_where_conditions = array();
2649
-		$cap_restrictions = $this->caps_missing( $context );
2649
+		$cap_restrictions = $this->caps_missing($context);
2650 2650
 		/**
2651 2651
 		 * @var $cap_restrictions EE_Default_Where_Conditions[]
2652 2652
 		 */
2653
-		foreach( $cap_restrictions as $cap => $restriction_if_no_cap ) {
2654
-				$cap_where_conditions = array_replace_recursive( $cap_where_conditions, $restriction_if_no_cap->get_default_where_conditions() );
2653
+		foreach ($cap_restrictions as $cap => $restriction_if_no_cap) {
2654
+				$cap_where_conditions = array_replace_recursive($cap_where_conditions, $restriction_if_no_cap->get_default_where_conditions());
2655 2655
 		}
2656
-		return apply_filters( 'FHEE__EEM_Base__caps_where_conditions__return', $cap_where_conditions, $this, $context, $cap_restrictions );
2656
+		return apply_filters('FHEE__EEM_Base__caps_where_conditions__return', $cap_where_conditions, $this, $context, $cap_restrictions);
2657 2657
 	}
2658 2658
 
2659 2659
 	/**
@@ -2663,11 +2663,11 @@  discard block
 block discarded – undo
2663 2663
 	 * @return string either ASC, asc, DESC or desc
2664 2664
 	 * @throws EE_Error
2665 2665
 	 */
2666
-	private function _extract_order($should_be_order_string){
2667
-		if(in_array($should_be_order_string, $this->_allowed_order_values)){
2666
+	private function _extract_order($should_be_order_string) {
2667
+		if (in_array($should_be_order_string, $this->_allowed_order_values)) {
2668 2668
 			return $should_be_order_string;
2669
-		}else{
2670
-			throw new EE_Error(sprintf(__("While performing a query on '%s', tried to use '%s' as an order parameter. ", "event_espresso"),get_class($this),$should_be_order_string));
2669
+		} else {
2670
+			throw new EE_Error(sprintf(__("While performing a query on '%s', tried to use '%s' as an order parameter. ", "event_espresso"), get_class($this), $should_be_order_string));
2671 2671
 		}
2672 2672
 	}
2673 2673
 
@@ -2685,19 +2685,19 @@  discard block
 block discarded – undo
2685 2685
 	 * @throws EE_Error
2686 2686
 	 * @return array like $query_params[0], see EEM_Base::get_all for documentation
2687 2687
 	 */
2688
-	private function _get_default_where_conditions_for_models_in_query(EE_Model_Query_Info_Carrier $query_info_carrier,$use_default_where_conditions = 'all',$where_query_params = array()){
2689
-		$allowed_used_default_where_conditions_values = array('all','this_model_only', 'other_models_only','none');
2690
-		if( ! in_array($use_default_where_conditions,$allowed_used_default_where_conditions_values)){
2691
-			throw new EE_Error(sprintf(__("You passed an invalid value to the query parameter 'default_where_conditions' of '%s'. Allowed values are %s", "event_espresso"),$use_default_where_conditions,implode(", ",$allowed_used_default_where_conditions_values)));
2688
+	private function _get_default_where_conditions_for_models_in_query(EE_Model_Query_Info_Carrier $query_info_carrier, $use_default_where_conditions = 'all', $where_query_params = array()) {
2689
+		$allowed_used_default_where_conditions_values = array('all', 'this_model_only', 'other_models_only', 'none');
2690
+		if ( ! in_array($use_default_where_conditions, $allowed_used_default_where_conditions_values)) {
2691
+			throw new EE_Error(sprintf(__("You passed an invalid value to the query parameter 'default_where_conditions' of '%s'. Allowed values are %s", "event_espresso"), $use_default_where_conditions, implode(", ", $allowed_used_default_where_conditions_values)));
2692 2692
 		}
2693
-		if( in_array($use_default_where_conditions, array('all','this_model_only')) ){
2693
+		if (in_array($use_default_where_conditions, array('all', 'this_model_only'))) {
2694 2694
 			$universal_query_params = $this->_get_default_where_conditions();
2695
-		}else{
2695
+		} else {
2696 2696
 			$universal_query_params = array();
2697 2697
 		}
2698 2698
 
2699
-		if(in_array($use_default_where_conditions,array('all','other_models_only'))){
2700
-			foreach($query_info_carrier->get_model_names_included() as $model_relation_path => $model_name){
2699
+		if (in_array($use_default_where_conditions, array('all', 'other_models_only'))) {
2700
+			foreach ($query_info_carrier->get_model_names_included() as $model_relation_path => $model_name) {
2701 2701
 				$related_model = $this->get_related_model_obj($model_name);
2702 2702
 				$related_model_universal_where_params = $related_model->_get_default_where_conditions($model_relation_path);
2703 2703
 
@@ -2724,22 +2724,22 @@  discard block
 block discarded – undo
2724 2724
 	 * @param string $model_relation_path like 'Transaction.Payment.'
2725 2725
 	 * @return array like EEM_Base::get_all's $query_params[0]
2726 2726
 	 */
2727
-	private function _override_defaults_or_make_null_friendly($default_where_conditions,$provided_where_conditions,$model,$model_relation_path){
2727
+	private function _override_defaults_or_make_null_friendly($default_where_conditions, $provided_where_conditions, $model, $model_relation_path) {
2728 2728
 		$null_friendly_where_conditions = array();
2729 2729
 		$none_overridden = true;
2730 2730
 		$or_condition_key_for_defaults = 'OR*'.get_class($model);
2731 2731
 
2732
-		foreach($default_where_conditions as $key => $val){
2733
-			if( isset($provided_where_conditions[$key])){
2732
+		foreach ($default_where_conditions as $key => $val) {
2733
+			if (isset($provided_where_conditions[$key])) {
2734 2734
 				$none_overridden = false;
2735
-			}else{
2735
+			} else {
2736 2736
 				$null_friendly_where_conditions[$or_condition_key_for_defaults]['AND'][$key] = $val;
2737 2737
 			}
2738 2738
 		}
2739
-		if( $none_overridden && $default_where_conditions){
2740
-			if($model->has_primary_key_field()){
2739
+		if ($none_overridden && $default_where_conditions) {
2740
+			if ($model->has_primary_key_field()) {
2741 2741
 				$null_friendly_where_conditions[$or_condition_key_for_defaults][$model_relation_path.".".$model->primary_key_name()] = array('IS NULL');
2742
-			}else{
2742
+			} else {
2743 2743
 				//@todo NO PK, use other defaults
2744 2744
 			}
2745 2745
 		}
@@ -2754,8 +2754,8 @@  discard block
 block discarded – undo
2754 2754
 	 * @param string $model_relation_path eg, path from Event to Payment is "Registration.Transaction.Payment."
2755 2755
 	 * @return array like EEM_Base::get_all's $query_params[0] (where conditions)
2756 2756
 	 */
2757
-	private function _get_default_where_conditions($model_relation_path = null){
2758
-		if ( $this->_ignore_where_strategy )
2757
+	private function _get_default_where_conditions($model_relation_path = null) {
2758
+		if ($this->_ignore_where_strategy)
2759 2759
 			return array();
2760 2760
 
2761 2761
 		return $this->_default_where_conditions_strategy->get_default_where_conditions($model_relation_path);
@@ -2766,13 +2766,13 @@  discard block
 block discarded – undo
2766 2766
 	 * @param EE_Model_Query_Info_Carrier $model_query_info
2767 2767
 	 * @return string
2768 2768
 	 */
2769
-	private function _construct_default_select_sql(EE_Model_Query_Info_Carrier $model_query_info){
2769
+	private function _construct_default_select_sql(EE_Model_Query_Info_Carrier $model_query_info) {
2770 2770
 		$selects = $this->_get_columns_to_select_for_this_model();
2771
-		foreach($model_query_info->get_model_names_included() as $model_relation_chain => $name_of_other_model_included){
2771
+		foreach ($model_query_info->get_model_names_included() as $model_relation_chain => $name_of_other_model_included) {
2772 2772
 			$other_model_included = $this->get_related_model_obj($name_of_other_model_included);
2773 2773
 			$selects = array_merge($selects, $other_model_included->_get_columns_to_select_for_this_model($model_relation_chain));
2774 2774
 		}
2775
-		return implode(", ",$selects);
2775
+		return implode(", ", $selects);
2776 2776
 	}
2777 2777
 
2778 2778
 	/**
@@ -2781,19 +2781,19 @@  discard block
 block discarded – undo
2781 2781
 	 * @param string $model_relation_chain like 'Question.Question_Group.Event'
2782 2782
 	 * @return array numerically indexed, values are columns to select and rename, eg "Event.ID AS 'Event.ID'"
2783 2783
 	 */
2784
-	public function _get_columns_to_select_for_this_model($model_relation_chain = ''){
2784
+	public function _get_columns_to_select_for_this_model($model_relation_chain = '') {
2785 2785
 		$fields = $this->field_settings();
2786 2786
 		$selects = array();
2787 2787
 		$table_alias_with_model_relation_chain_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_this_model_name());
2788
-		foreach($fields as $field_obj){
2789
-			$selects[] = $table_alias_with_model_relation_chain_prefix . $field_obj->get_table_alias().".".$field_obj->get_table_column()." AS '".$table_alias_with_model_relation_chain_prefix.$field_obj->get_table_alias().".".$field_obj->get_table_column()."'";
2788
+		foreach ($fields as $field_obj) {
2789
+			$selects[] = $table_alias_with_model_relation_chain_prefix.$field_obj->get_table_alias().".".$field_obj->get_table_column()." AS '".$table_alias_with_model_relation_chain_prefix.$field_obj->get_table_alias().".".$field_obj->get_table_column()."'";
2790 2790
 		}
2791 2791
 		//make sure we are also getting the PKs of each table
2792 2792
 		$tables = $this->get_tables();
2793
-		if(count($tables) > 1){
2794
-			foreach($tables as $table_obj){
2795
-				$qualified_pk_column = $table_alias_with_model_relation_chain_prefix . $table_obj->get_fully_qualified_pk_column();
2796
-				if( ! in_array($qualified_pk_column,$selects)){
2793
+		if (count($tables) > 1) {
2794
+			foreach ($tables as $table_obj) {
2795
+				$qualified_pk_column = $table_alias_with_model_relation_chain_prefix.$table_obj->get_fully_qualified_pk_column();
2796
+				if ( ! in_array($qualified_pk_column, $selects)) {
2797 2797
 					$selects[] = "$qualified_pk_column AS '$qualified_pk_column'";
2798 2798
 				}
2799 2799
 			}
@@ -2817,66 +2817,66 @@  discard block
 block discarded – undo
2817 2817
 	 * @throws EE_Error
2818 2818
 	 * @return void only modifies the EEM_Related_Model_Info_Carrier passed into it
2819 2819
 	 */
2820
-	private function _extract_related_model_info_from_query_param( $query_param, EE_Model_Query_Info_Carrier $passed_in_query_info, $query_param_type, $original_query_param = NULL ){
2821
-		if($original_query_param == NULL){
2820
+	private function _extract_related_model_info_from_query_param($query_param, EE_Model_Query_Info_Carrier $passed_in_query_info, $query_param_type, $original_query_param = NULL) {
2821
+		if ($original_query_param == NULL) {
2822 2822
 			$original_query_param = $query_param;
2823 2823
 		}
2824 2824
 		$query_param = $this->_remove_stars_and_anything_after_from_condition_query_param_key($query_param);
2825 2825
 		/** @var $allow_logic_query_params bool whether or not to allow logic_query_params like 'NOT','OR', or 'AND' */
2826
-		$allow_logic_query_params = in_array($query_param_type,array('where','having'));
2827
-		$allow_fields = in_array($query_param_type,array('where','having','order_by','group_by','order'));
2826
+		$allow_logic_query_params = in_array($query_param_type, array('where', 'having'));
2827
+		$allow_fields = in_array($query_param_type, array('where', 'having', 'order_by', 'group_by', 'order'));
2828 2828
 		//check to see if we have a field on this model
2829 2829
 		$this_model_fields = $this->field_settings(true);
2830
-		if(array_key_exists($query_param,$this_model_fields)){
2831
-			if($allow_fields){
2830
+		if (array_key_exists($query_param, $this_model_fields)) {
2831
+			if ($allow_fields) {
2832 2832
 				return;
2833
-			}else{
2833
+			} else {
2834 2834
 				throw new EE_Error(sprintf(__("Using a field name (%s) on model %s is not allowed on this query param type '%s'. Original query param was %s", "event_espresso"),
2835
-						$query_param,get_class($this),$query_param_type,$original_query_param));
2835
+						$query_param, get_class($this), $query_param_type, $original_query_param));
2836 2836
 			}
2837 2837
 		}
2838 2838
 		//check if this is a special logic query param
2839
-		elseif(in_array($query_param, $this->_logic_query_param_keys, TRUE)){
2840
-			if($allow_logic_query_params){
2839
+		elseif (in_array($query_param, $this->_logic_query_param_keys, TRUE)) {
2840
+			if ($allow_logic_query_params) {
2841 2841
 				return;
2842
-			}else{
2842
+			} else {
2843 2843
 				throw new EE_Error(
2844 2844
 					sprintf(
2845
-						__( 'Logic query params ("%1$s") are being used incorrectly with the following query param ("%2$s") on model %3$s. %4$sAdditional Info:%4$s%5$s', 'event_espresso' ),
2846
-						implode( '", "', $this->_logic_query_param_keys ),
2847
-						$query_param ,
2848
-						get_class( $this ),
2845
+						__('Logic query params ("%1$s") are being used incorrectly with the following query param ("%2$s") on model %3$s. %4$sAdditional Info:%4$s%5$s', 'event_espresso'),
2846
+						implode('", "', $this->_logic_query_param_keys),
2847
+						$query_param,
2848
+						get_class($this),
2849 2849
 						'<br />',
2850
-						"\t" . ' $passed_in_query_info = <pre>' . print_r( $passed_in_query_info, TRUE ) . '</pre>' . "\n\t" . ' $query_param_type = ' . $query_param_type . "\n\t" . ' $original_query_param = ' . $original_query_param
2850
+						"\t".' $passed_in_query_info = <pre>'.print_r($passed_in_query_info, TRUE).'</pre>'."\n\t".' $query_param_type = '.$query_param_type."\n\t".' $original_query_param = '.$original_query_param
2851 2851
 					)
2852 2852
 				);
2853 2853
 			}
2854 2854
 		}
2855 2855
 
2856 2856
 		//check if it's a custom selection
2857
-		elseif(array_key_exists($query_param,$this->_custom_selections)){
2857
+		elseif (array_key_exists($query_param, $this->_custom_selections)) {
2858 2858
 			return;
2859 2859
 		}
2860 2860
 
2861 2861
 		//check if has a model name at the beginning
2862 2862
 		//and
2863 2863
 		//check if it's a field on a related model
2864
-		foreach($this->_model_relations as $valid_related_model_name=>$relation_obj){
2865
-			if(strpos($query_param, $valid_related_model_name.".") === 0){
2866
-				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info,$original_query_param);
2864
+		foreach ($this->_model_relations as $valid_related_model_name=>$relation_obj) {
2865
+			if (strpos($query_param, $valid_related_model_name.".") === 0) {
2866
+				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info, $original_query_param);
2867 2867
 				$query_param = substr($query_param, strlen($valid_related_model_name."."));
2868
-				if($query_param == ''){
2868
+				if ($query_param == '') {
2869 2869
 					//nothing left to $query_param
2870 2870
 					//we should actually end in a field name, not a model like this!
2871 2871
 					throw new EE_Error(sprintf(__("Query param '%s' (of type %s on model %s) shouldn't end on a period (.) ", "event_espresso"),
2872
-					$query_param,$query_param_type,get_class($this),$valid_related_model_name));
2873
-				}else{
2872
+					$query_param, $query_param_type, get_class($this), $valid_related_model_name));
2873
+				} else {
2874 2874
 					$related_model_obj = $this->get_related_model_obj($valid_related_model_name);
2875 2875
 					$related_model_obj->_extract_related_model_info_from_query_param($query_param, $passed_in_query_info, $query_param_type, $original_query_param);
2876 2876
 					return;
2877 2877
 				}
2878
-			}elseif($query_param == $valid_related_model_name){
2879
-				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info,$original_query_param);
2878
+			}elseif ($query_param == $valid_related_model_name) {
2879
+				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info, $original_query_param);
2880 2880
 				return;
2881 2881
 			}
2882 2882
 		}
@@ -2886,7 +2886,7 @@  discard block
 block discarded – undo
2886 2886
 		//and we previously confirmed it wasn't a logic query param or field on the current model
2887 2887
 		//it's wack, that's what it is
2888 2888
 		throw new EE_Error(sprintf(__("There is no model named '%s' related to %s. Query param type is %s and original query param is %s", "event_espresso"),
2889
-				$query_param,get_class($this),$query_param_type,$original_query_param));
2889
+				$query_param, get_class($this), $query_param_type, $original_query_param));
2890 2890
 
2891 2891
 	}
2892 2892
 
@@ -2903,26 +2903,26 @@  discard block
 block discarded – undo
2903 2903
 	 * what models to prepend onto its default query params or in case it wants to rename tables (in case there are multiple joins to the same table)
2904 2904
 	 * @return void
2905 2905
 	 */
2906
-	private function _add_join_to_model($model_name, EE_Model_Query_Info_Carrier $passed_in_query_info,$original_query_param){
2906
+	private function _add_join_to_model($model_name, EE_Model_Query_Info_Carrier $passed_in_query_info, $original_query_param) {
2907 2907
 		$relation_obj = $this->related_settings_for($model_name);
2908 2908
 
2909 2909
 		$model_relation_chain = EE_Model_Parser::extract_model_relation_chain($model_name, $original_query_param);
2910 2910
 		//check if the relation is HABTM, because then we're essentially doing two joins
2911 2911
 		//If so, join first to the JOIN table, and add its data types, and then continue as normal
2912
-		if($relation_obj instanceof EE_HABTM_Relation){
2912
+		if ($relation_obj instanceof EE_HABTM_Relation) {
2913 2913
 			$join_model_obj = $relation_obj->get_join_model();
2914 2914
 			//replace the model specified with the join model for this relation chain, whi
2915 2915
 			$relation_chain_to_join_model = EE_Model_Parser::replace_model_name_with_join_model_name_in_model_relation_chain($model_name, $join_model_obj->get_this_model_name(), $model_relation_chain);
2916 2916
 			$new_query_info = new EE_Model_Query_Info_Carrier(
2917 2917
 					array($relation_chain_to_join_model => $join_model_obj->get_this_model_name()),
2918 2918
 					$relation_obj->get_join_to_intermediate_model_statement($relation_chain_to_join_model));
2919
-			$passed_in_query_info->merge( $new_query_info  );
2919
+			$passed_in_query_info->merge($new_query_info);
2920 2920
 		}
2921 2921
 		//now just join to the other table pointed to by the relation object, and add its data types
2922 2922
 		$new_query_info = new EE_Model_Query_Info_Carrier(
2923 2923
 				array($model_relation_chain=>$model_name),
2924 2924
 				$relation_obj->get_join_statement($model_relation_chain));
2925
-		$passed_in_query_info->merge( $new_query_info  );
2925
+		$passed_in_query_info->merge($new_query_info);
2926 2926
 	}
2927 2927
 
2928 2928
 
@@ -2931,11 +2931,11 @@  discard block
 block discarded – undo
2931 2931
 	 * @param array $where_params like EEM_Base::get_all
2932 2932
 	 * @return string of SQL
2933 2933
 	 */
2934
-	private function _construct_where_clause($where_params){
2934
+	private function _construct_where_clause($where_params) {
2935 2935
 		$SQL = $this->_construct_condition_clause_recursive($where_params, ' AND ');
2936
-		if($SQL){
2937
-			return " WHERE ". $SQL;
2938
-		}else{
2936
+		if ($SQL) {
2937
+			return " WHERE ".$SQL;
2938
+		} else {
2939 2939
 			return '';
2940 2940
 		}
2941 2941
 	}
@@ -2946,11 +2946,11 @@  discard block
 block discarded – undo
2946 2946
 	 * @param array $having_params
2947 2947
 	 * @return string
2948 2948
 	 */
2949
-	private function _construct_having_clause($having_params){
2949
+	private function _construct_having_clause($having_params) {
2950 2950
 		$SQL = $this->_construct_condition_clause_recursive($having_params, ' AND ');
2951
-		if($SQL){
2952
-			return " HAVING ". $SQL;
2953
-		}else{
2951
+		if ($SQL) {
2952
+			return " HAVING ".$SQL;
2953
+		} else {
2954 2954
 			return '';
2955 2955
 		}
2956 2956
 
@@ -2964,17 +2964,17 @@  discard block
 block discarded – undo
2964 2964
 	 * @return EE_Model_Field_Base
2965 2965
 	 * @throws EE_Error
2966 2966
 	 */
2967
-	protected function _get_field_on_model($field_name,$model_name){
2967
+	protected function _get_field_on_model($field_name, $model_name) {
2968 2968
 		$model_class = 'EEM_'.$model_name;
2969 2969
 		$model_filepath = $model_class.".model.php";
2970
-		EE_Registry::instance()->load_helper( 'File' );
2971
-		if ( is_readable($model_filepath)){
2970
+		EE_Registry::instance()->load_helper('File');
2971
+		if (is_readable($model_filepath)) {
2972 2972
 			require_once($model_filepath);
2973
-			$model_instance=call_user_func($model_name."::instance");
2973
+			$model_instance = call_user_func($model_name."::instance");
2974 2974
 			/* @var $model_instance EEM_Base */
2975 2975
 			return $model_instance->field_settings_for($field_name);
2976
-		}else{
2977
-			throw new EE_Error(sprintf(__('No model named %s exists, with classname %s and filepath %s','event_espresso'),$model_name,$model_class,$model_filepath));
2976
+		} else {
2977
+			throw new EE_Error(sprintf(__('No model named %s exists, with classname %s and filepath %s', 'event_espresso'), $model_name, $model_class, $model_filepath));
2978 2978
 		}
2979 2979
 	}
2980 2980
 
@@ -2987,43 +2987,43 @@  discard block
 block discarded – undo
2987 2987
 	 * @throws EE_Error
2988 2988
 	 * @return string of SQL
2989 2989
 	 */
2990
-	private function _construct_condition_clause_recursive($where_params, $glue = ' AND'){
2991
-		$where_clauses=array();
2992
-		foreach($where_params as $query_param => $op_and_value_or_sub_condition){
2993
-			$query_param = $this->_remove_stars_and_anything_after_from_condition_query_param_key($query_param);//str_replace("*",'',$query_param);
2994
-			if(in_array($query_param,$this->_logic_query_param_keys)){
2995
-				switch($query_param){
2990
+	private function _construct_condition_clause_recursive($where_params, $glue = ' AND') {
2991
+		$where_clauses = array();
2992
+		foreach ($where_params as $query_param => $op_and_value_or_sub_condition) {
2993
+			$query_param = $this->_remove_stars_and_anything_after_from_condition_query_param_key($query_param); //str_replace("*",'',$query_param);
2994
+			if (in_array($query_param, $this->_logic_query_param_keys)) {
2995
+				switch ($query_param) {
2996 2996
 					case 'not':
2997 2997
 					case 'NOT':
2998
-						$where_clauses[] = "! (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, $glue).")";
2998
+						$where_clauses[] = "! (".$this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, $glue).")";
2999 2999
 						break;
3000 3000
 					case 'and':
3001 3001
 					case 'AND':
3002
-						$where_clauses[] = " (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' AND ') .")";
3002
+						$where_clauses[] = " (".$this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' AND ').")";
3003 3003
 						break;
3004 3004
 					case 'or':
3005 3005
 					case 'OR':
3006
-						$where_clauses[] = " (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' OR ') .")";
3006
+						$where_clauses[] = " (".$this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' OR ').")";
3007 3007
 						break;
3008 3008
 				}
3009
-			}else{
3009
+			} else {
3010 3010
 				$field_obj = $this->_deduce_field_from_query_param($query_param);
3011 3011
 
3012 3012
 				//if it's not a normal field, maybe it's a custom selection?
3013
-				if( ! $field_obj){
3014
-					if(isset( $this->_custom_selections[$query_param][1])){
3013
+				if ( ! $field_obj) {
3014
+					if (isset($this->_custom_selections[$query_param][1])) {
3015 3015
 						$field_obj = $this->_custom_selections[$query_param][1];
3016
-					}else{
3017
-						throw new EE_Error(sprintf(__("%s is neither a valid model field name, nor a custom selection", "event_espresso"),$query_param));
3016
+					} else {
3017
+						throw new EE_Error(sprintf(__("%s is neither a valid model field name, nor a custom selection", "event_espresso"), $query_param));
3018 3018
 					}
3019 3019
 				}
3020 3020
 				$op_and_value_sql = $this->_construct_op_and_value($op_and_value_or_sub_condition, $field_obj);
3021
-				$where_clauses[]=$this->_deduce_column_name_from_query_param($query_param).SP.$op_and_value_sql;
3021
+				$where_clauses[] = $this->_deduce_column_name_from_query_param($query_param).SP.$op_and_value_sql;
3022 3022
 			}
3023 3023
 		}
3024
-		if($where_clauses){
3025
-			$SQL = implode($glue,$where_clauses);
3026
-		}else{
3024
+		if ($where_clauses) {
3025
+			$SQL = implode($glue, $where_clauses);
3026
+		} else {
3027 3027
 			$SQL = '';
3028 3028
 		}
3029 3029
 		return $SQL;
@@ -3037,18 +3037,18 @@  discard block
 block discarded – undo
3037 3037
 	 * @throws EE_Error
3038 3038
 	 * @return string table alias and column name for SQL, eg "Transaction.TXN_ID"
3039 3039
 	 */
3040
-	private function _deduce_column_name_from_query_param($query_param){
3040
+	private function _deduce_column_name_from_query_param($query_param) {
3041 3041
 		$field = $this->_deduce_field_from_query_param($query_param);
3042 3042
 
3043
-		if( $field ){
3044
-			$table_alias_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_from_query_param( $field->get_model_name(), $query_param );
3045
-			return $table_alias_prefix . $field->get_qualified_column();
3046
-		}elseif(array_key_exists($query_param,$this->_custom_selections)){
3043
+		if ($field) {
3044
+			$table_alias_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_from_query_param($field->get_model_name(), $query_param);
3045
+			return $table_alias_prefix.$field->get_qualified_column();
3046
+		}elseif (array_key_exists($query_param, $this->_custom_selections)) {
3047 3047
 			//maybe it's custom selection item?
3048 3048
 			//if so, just use it as the "column name"
3049 3049
 			return $query_param;
3050
-		}else{
3051
-			throw new EE_Error(sprintf(__("%s is not a valid field on this model, nor a custom selection (%s)", "event_espresso"),$query_param,implode(",",$this->_custom_selections)));
3050
+		} else {
3051
+			throw new EE_Error(sprintf(__("%s is not a valid field on this model, nor a custom selection (%s)", "event_espresso"), $query_param, implode(",", $this->_custom_selections)));
3052 3052
 		}
3053 3053
 	}
3054 3054
 
@@ -3060,11 +3060,11 @@  discard block
 block discarded – undo
3060 3060
 	 * @param string $condition_query_param_key
3061 3061
 	 * @return string
3062 3062
 	 */
3063
-	private function _remove_stars_and_anything_after_from_condition_query_param_key($condition_query_param_key){
3063
+	private function _remove_stars_and_anything_after_from_condition_query_param_key($condition_query_param_key) {
3064 3064
 		$pos_of_star = strpos($condition_query_param_key, '*');
3065
-		if($pos_of_star === FALSE){
3065
+		if ($pos_of_star === FALSE) {
3066 3066
 			return $condition_query_param_key;
3067
-		}else{
3067
+		} else {
3068 3068
 			$condition_query_param_sans_star = substr($condition_query_param_key, 0, $pos_of_star);
3069 3069
 			return $condition_query_param_sans_star;
3070 3070
 		}
@@ -3079,54 +3079,54 @@  discard block
 block discarded – undo
3079 3079
 	 * @throws EE_Error
3080 3080
 	 * @return string
3081 3081
 	 */
3082
-	private function _construct_op_and_value($op_and_value, $field_obj){
3083
-		if(is_array( $op_and_value )){
3082
+	private function _construct_op_and_value($op_and_value, $field_obj) {
3083
+		if (is_array($op_and_value)) {
3084 3084
 			$operator = isset($op_and_value[0]) ? $this->_prepare_operator_for_sql($op_and_value[0]) : null;
3085
-			if( ! $operator){
3085
+			if ( ! $operator) {
3086 3086
 				$php_array_like_string = array();
3087
-				foreach($op_and_value as $key => $value){
3087
+				foreach ($op_and_value as $key => $value) {
3088 3088
 					$php_array_like_string[] = "$key=>$value";
3089 3089
 				}
3090
-				throw new EE_Error(sprintf(__("You setup a query parameter like you were going to specify an operator, but didn't. You provided '(%s)', but the operator should be at array key index 0 (eg array('>',32))", "event_espresso"), implode(",",$php_array_like_string)));
3090
+				throw new EE_Error(sprintf(__("You setup a query parameter like you were going to specify an operator, but didn't. You provided '(%s)', but the operator should be at array key index 0 (eg array('>',32))", "event_espresso"), implode(",", $php_array_like_string)));
3091 3091
 			}
3092 3092
 			$value = isset($op_and_value[1]) ? $op_and_value[1] : null;
3093
-		}else{
3093
+		} else {
3094 3094
 			$operator = '=';
3095 3095
 			$value = $op_and_value;
3096 3096
 		}
3097 3097
 
3098 3098
 		//check to see if the value is actually another field
3099
-		if(is_array($op_and_value) && isset($op_and_value[2]) && $op_and_value[2] == true){
3099
+		if (is_array($op_and_value) && isset($op_and_value[2]) && $op_and_value[2] == true) {
3100 3100
 			return $operator.SP.$this->_deduce_column_name_from_query_param($value);
3101
-		}elseif(in_array($operator, $this->_in_style_operators) && is_array($value)){
3101
+		}elseif (in_array($operator, $this->_in_style_operators) && is_array($value)) {
3102 3102
 			//in this case, the value should be an array, or at least a comma-separated list
3103 3103
 			//it will need to handle a little differently
3104 3104
 			$cleaned_value = $this->_construct_in_value($value, $field_obj);
3105 3105
 			//note: $cleaned_value has already been run through $wpdb->prepare()
3106 3106
 			return $operator.SP.$cleaned_value;
3107
-		} elseif( in_array( $operator, $this->_between_style_operators ) && is_array( $value ) ) {
3107
+		} elseif (in_array($operator, $this->_between_style_operators) && is_array($value)) {
3108 3108
 			//the value should be an array with count of two.
3109
-			if ( count($value) !== 2 )
3110
-				throw new EE_Error( sprintf( __("The '%s' operator must be used with an array of values and there must be exactly TWO values in that array.", 'event_espresso'), "BETWEEN" ) );
3111
-			$cleaned_value = $this->_construct_between_value( $value, $field_obj );
3109
+			if (count($value) !== 2)
3110
+				throw new EE_Error(sprintf(__("The '%s' operator must be used with an array of values and there must be exactly TWO values in that array.", 'event_espresso'), "BETWEEN"));
3111
+			$cleaned_value = $this->_construct_between_value($value, $field_obj);
3112 3112
 			return $operator.SP.$cleaned_value;
3113
-		} elseif( in_array( $operator, $this->_null_style_operators ) ) {
3114
-			if($value != NULL){
3115
-				throw new EE_Error(sprintf(__("You attempted to give a value  (%s) while using a NULL-style operator (%s). That isn't valid", "event_espresso"),$value,$operator));
3113
+		} elseif (in_array($operator, $this->_null_style_operators)) {
3114
+			if ($value != NULL) {
3115
+				throw new EE_Error(sprintf(__("You attempted to give a value  (%s) while using a NULL-style operator (%s). That isn't valid", "event_espresso"), $value, $operator));
3116 3116
 			}
3117 3117
 			return $operator;
3118
-		}elseif( $operator == 'LIKE' && ! is_array($value)){
3118
+		}elseif ($operator == 'LIKE' && ! is_array($value)) {
3119 3119
 			//if the operator is 'LIKE', we want to allow percent signs (%) and not
3120 3120
 			//remove other junk. So just treat it as a string.
3121 3121
 			return $operator.SP.$this->_wpdb_prepare_using_field($value, '%s');
3122
-		}elseif( ! in_array($operator, $this->_in_style_operators) && ! is_array($value)){
3123
-			return $operator.SP.$this->_wpdb_prepare_using_field($value,$field_obj);
3124
-		}elseif(in_array($operator, $this->_in_style_operators) && ! is_array($value)){
3125
-			throw new EE_Error(sprintf(__("Operator '%s' must be used with an array of values, eg 'Registration.REG_ID' => array('%s',array(1,2,3))",'event_espresso'),$operator, $operator));
3126
-		}elseif( ! in_array($operator, $this->_in_style_operators) && is_array($value)){
3127
-			throw new EE_Error(sprintf(__("Operator '%s' must be used with a single value, not an array. Eg 'Registration.REG_ID => array('%s',23))",'event_espresso'),$operator,$operator));
3128
-		}else{
3129
-			throw new EE_Error(sprintf(__("It appears you've provided some totally invalid query parameters. Operator and value were:'%s', which isn't right at all", "event_espresso"),  http_build_query($op_and_value)));
3122
+		}elseif ( ! in_array($operator, $this->_in_style_operators) && ! is_array($value)) {
3123
+			return $operator.SP.$this->_wpdb_prepare_using_field($value, $field_obj);
3124
+		}elseif (in_array($operator, $this->_in_style_operators) && ! is_array($value)) {
3125
+			throw new EE_Error(sprintf(__("Operator '%s' must be used with an array of values, eg 'Registration.REG_ID' => array('%s',array(1,2,3))", 'event_espresso'), $operator, $operator));
3126
+		}elseif ( ! in_array($operator, $this->_in_style_operators) && is_array($value)) {
3127
+			throw new EE_Error(sprintf(__("Operator '%s' must be used with a single value, not an array. Eg 'Registration.REG_ID => array('%s',23))", 'event_espresso'), $operator, $operator));
3128
+		} else {
3129
+			throw new EE_Error(sprintf(__("It appears you've provided some totally invalid query parameters. Operator and value were:'%s', which isn't right at all", "event_espresso"), http_build_query($op_and_value)));
3130 3130
 		}
3131 3131
 	}
3132 3132
 
@@ -3138,12 +3138,12 @@  discard block
 block discarded – undo
3138 3138
 	 * @param EE_Model_Field_Base|string $field_obj if string, it should be the datatype to be used when querying, eg '%s'
3139 3139
 	 * @return string
3140 3140
 	 */
3141
-	function _construct_between_value( $values, $field_obj ) {
3141
+	function _construct_between_value($values, $field_obj) {
3142 3142
 		$cleaned_values = array();
3143
-		foreach ( $values as $value ) {
3144
-			$cleaned_values[] = $this->_wpdb_prepare_using_field($value,$field_obj);
3143
+		foreach ($values as $value) {
3144
+			$cleaned_values[] = $this->_wpdb_prepare_using_field($value, $field_obj);
3145 3145
 		}
3146
-		return  $cleaned_values[0] . " AND " . $cleaned_values[1];
3146
+		return  $cleaned_values[0]." AND ".$cleaned_values[1];
3147 3147
 	}
3148 3148
 
3149 3149
 
@@ -3159,26 +3159,26 @@  discard block
 block discarded – undo
3159 3159
 	 * @param EE_Model_Field_Base|string $field_obj if string, it should be a wpdb data type like '%s', or '%d'
3160 3160
 	 * @return string of SQL to follow an 'IN' or 'NOT IN' operator
3161 3161
 	 */
3162
-	function _construct_in_value($values,  $field_obj){
3162
+	function _construct_in_value($values, $field_obj) {
3163 3163
 		//check if the value is a CSV list
3164
-		if(is_string($values)){
3164
+		if (is_string($values)) {
3165 3165
 			//in which case, turn it into an array
3166
-			$values = explode(",",$values);
3166
+			$values = explode(",", $values);
3167 3167
 		}
3168 3168
 		$cleaned_values = array();
3169
-		foreach($values as $value){
3170
-			$cleaned_values[] = $this->_wpdb_prepare_using_field($value,$field_obj);
3169
+		foreach ($values as $value) {
3170
+			$cleaned_values[] = $this->_wpdb_prepare_using_field($value, $field_obj);
3171 3171
 		}
3172 3172
 		//we would just LOVE to leave $cleaned_values as an empty array, and return the value as "()",
3173 3173
 		//but unfortunately that's invalid SQL. So instead we return a string which we KNOW will evaluate to be the empty set
3174 3174
 		//which is effectively equivalent to returning "()". We don't return "(0)" because that only works for auto-incrementing columns
3175
-		if(empty($cleaned_values)){
3175
+		if (empty($cleaned_values)) {
3176 3176
 			$all_fields = $this->field_settings();
3177 3177
 			$a_field = array_shift($all_fields);
3178 3178
 			$main_table = $this->_get_main_table();
3179 3179
 			$cleaned_values[] = "SELECT ".$a_field->get_table_column()." FROM ".$main_table->get_table_name()." WHERE FALSE";
3180 3180
 		}
3181
-		return "(".implode(",",$cleaned_values).")";
3181
+		return "(".implode(",", $cleaned_values).")";
3182 3182
 	}
3183 3183
 
3184 3184
 
@@ -3190,16 +3190,16 @@  discard block
 block discarded – undo
3190 3190
 	 * @throws EE_Error
3191 3191
 	 * @return false|null|string
3192 3192
 	 */
3193
-	private function _wpdb_prepare_using_field($value,$field_obj){
3193
+	private function _wpdb_prepare_using_field($value, $field_obj) {
3194 3194
 		/** @type WPDB $wpdb */
3195 3195
 		global $wpdb;
3196
-		if($field_obj instanceof EE_Model_Field_Base){
3197
-			return $wpdb->prepare($field_obj->get_wpdb_data_type(),$this->_prepare_value_for_use_in_db($value, $field_obj));
3198
-		}else{//$field_obj should really just be a data type
3199
-			if( ! in_array($field_obj,$this->_valid_wpdb_data_types)){
3200
-				throw new EE_Error(sprintf(__("%s is not a valid wpdb datatype. Valid ones are %s", "event_espresso"),$field_obj,implode(",",$this->_valid_wpdb_data_types)));
3196
+		if ($field_obj instanceof EE_Model_Field_Base) {
3197
+			return $wpdb->prepare($field_obj->get_wpdb_data_type(), $this->_prepare_value_for_use_in_db($value, $field_obj));
3198
+		} else {//$field_obj should really just be a data type
3199
+			if ( ! in_array($field_obj, $this->_valid_wpdb_data_types)) {
3200
+				throw new EE_Error(sprintf(__("%s is not a valid wpdb datatype. Valid ones are %s", "event_espresso"), $field_obj, implode(",", $this->_valid_wpdb_data_types)));
3201 3201
 			}
3202
-			return $wpdb->prepare($field_obj,$value);
3202
+			return $wpdb->prepare($field_obj, $value);
3203 3203
 		}
3204 3204
 	}
3205 3205
 
@@ -3211,27 +3211,27 @@  discard block
 block discarded – undo
3211 3211
 	 * @throws EE_Error
3212 3212
 	 * @return EE_Model_Field_Base
3213 3213
 	 */
3214
-	protected function _deduce_field_from_query_param($query_param_name){
3214
+	protected function _deduce_field_from_query_param($query_param_name) {
3215 3215
 		//ok, now proceed with deducing which part is the model's name, and which is the field's name
3216 3216
 		//which will help us find the database table and column
3217 3217
 
3218
-		$query_param_parts = explode(".",$query_param_name);
3219
-		if(empty($query_param_parts)){
3220
-			throw new EE_Error(sprintf(__("_extract_column_name is empty when trying to extract column and table name from %s",'event_espresso'),$query_param_name));
3218
+		$query_param_parts = explode(".", $query_param_name);
3219
+		if (empty($query_param_parts)) {
3220
+			throw new EE_Error(sprintf(__("_extract_column_name is empty when trying to extract column and table name from %s", 'event_espresso'), $query_param_name));
3221 3221
 		}
3222 3222
 		$number_of_parts = count($query_param_parts);
3223
-		$last_query_param_part = $query_param_parts[ count($query_param_parts) - 1 ];
3224
-		if($number_of_parts == 1){
3223
+		$last_query_param_part = $query_param_parts[count($query_param_parts) - 1];
3224
+		if ($number_of_parts == 1) {
3225 3225
 			$field_name = $last_query_param_part;
3226 3226
 			$model_obj = $this;
3227
-		}else{// $number_of_parts >= 2
3227
+		} else {// $number_of_parts >= 2
3228 3228
 			//the last part is the column name, and there are only 2parts. therefore...
3229 3229
 			$field_name = $last_query_param_part;
3230
-			$model_obj = $this->get_related_model_obj( $query_param_parts[ $number_of_parts - 2 ]);
3230
+			$model_obj = $this->get_related_model_obj($query_param_parts[$number_of_parts - 2]);
3231 3231
 		}
3232
-		try{
3232
+		try {
3233 3233
 			return $model_obj->field_settings_for($field_name);
3234
-		}catch(EE_Error $e){
3234
+		} catch (EE_Error $e) {
3235 3235
 			return null;
3236 3236
 		}
3237 3237
 	}
@@ -3245,13 +3245,13 @@  discard block
 block discarded – undo
3245 3245
 	 * @throws EE_Error
3246 3246
 	 * @return string
3247 3247
 	 */
3248
-	function _get_qualified_column_for_field($field_name){
3248
+	function _get_qualified_column_for_field($field_name) {
3249 3249
 		$all_fields = $this->field_settings();
3250 3250
 		$field = isset($all_fields[$field_name]) ? $all_fields[$field_name] : FALSE;
3251
-		if($field){
3251
+		if ($field) {
3252 3252
 			return $field->get_qualified_column();
3253
-		}else{
3254
-			throw new EE_Error(sprintf(__("There is no field titled %s on model %s. Either the query trying to use it is bad, or you need to add it to the list of fields on the model.",'event_espresso'),$field_name,get_class($this)));
3253
+		} else {
3254
+			throw new EE_Error(sprintf(__("There is no field titled %s on model %s. Either the query trying to use it is bad, or you need to add it to the list of fields on the model.", 'event_espresso'), $field_name, get_class($this)));
3255 3255
 		}
3256 3256
 	}
3257 3257
 
@@ -3265,14 +3265,14 @@  discard block
 block discarded – undo
3265 3265
 	 * @param  mixed|string $limit The limit for this select
3266 3266
 	 * @return string 				The final select join element for the query.
3267 3267
 	 */
3268
-	function _construct_limit_join_select( $table_alias, $limit ) {
3268
+	function _construct_limit_join_select($table_alias, $limit) {
3269 3269
 		$SQL = '';
3270 3270
 
3271
-		foreach ( $this->_tables as $table_obj ) {
3272
-			if ( $table_obj instanceof EE_Primary_Table ) {
3273
-				$SQL .= $table_alias == $table_obj->get_table_alias() ? $table_obj->get_select_join_limit( $limit ) : SP.$table_obj->get_table_name()." AS ".$table_obj->get_table_alias().SP;
3274
-			} elseif ( $table_obj instanceof EE_Secondary_Table ) {
3275
-				$SQL .= $table_alias == $table_obj->get_table_alias() ? $table_obj->get_select_join_limit_join($limit) : SP . $table_obj->get_join_sql( $table_alias ).SP;
3271
+		foreach ($this->_tables as $table_obj) {
3272
+			if ($table_obj instanceof EE_Primary_Table) {
3273
+				$SQL .= $table_alias == $table_obj->get_table_alias() ? $table_obj->get_select_join_limit($limit) : SP.$table_obj->get_table_name()." AS ".$table_obj->get_table_alias().SP;
3274
+			} elseif ($table_obj instanceof EE_Secondary_Table) {
3275
+				$SQL .= $table_alias == $table_obj->get_table_alias() ? $table_obj->get_select_join_limit_join($limit) : SP.$table_obj->get_join_sql($table_alias).SP;
3276 3276
 			}
3277 3277
 		}
3278 3278
 		return $SQL;
@@ -3285,7 +3285,7 @@  discard block
 block discarded – undo
3285 3285
 	 * Eg "wp_post AS Event" or "wp_post AS Event INNER JOIN wp_postmeta Event_Meta ON Event.ID = Event_Meta.post_id"
3286 3286
 	 * @return string SQL
3287 3287
 	 */
3288
-	function _construct_internal_join(){
3288
+	function _construct_internal_join() {
3289 3289
 		$SQL = $this->_get_main_table()->get_table_sql();
3290 3290
 		$SQL .= $this->_construct_internal_join_to_table_with_alias($this->_get_main_table()->get_table_alias());
3291 3291
 		return $SQL;
@@ -3306,17 +3306,17 @@  discard block
 block discarded – undo
3306 3306
 	 * @param string $alias_prefixed table alias to join to (this table should already be in the FROM SQL clause)
3307 3307
 	 * @return string
3308 3308
 	 */
3309
-	function _construct_internal_join_to_table_with_alias($alias_prefixed){
3309
+	function _construct_internal_join_to_table_with_alias($alias_prefixed) {
3310 3310
 		$SQL = '';
3311 3311
 		$alias_sans_prefix = EE_Model_Parser::remove_table_alias_model_relation_chain_prefix($alias_prefixed);
3312
-		foreach($this->_tables as $table_obj){
3313
-			if($table_obj instanceof EE_Secondary_Table){//table is secondary table
3314
-				if($alias_sans_prefix == $table_obj->get_table_alias()){
3312
+		foreach ($this->_tables as $table_obj) {
3313
+			if ($table_obj instanceof EE_Secondary_Table) {//table is secondary table
3314
+				if ($alias_sans_prefix == $table_obj->get_table_alias()) {
3315 3315
 					//so we're joining to this table, meaning the table is already in
3316 3316
 					//the FROM statement, BUT the primary table isn't. So we want
3317 3317
 					//to add the inverse join sql
3318 3318
 					$SQL .= $table_obj->get_inverse_join_sql($alias_prefixed);
3319
-				}else{
3319
+				} else {
3320 3320
 					//just add a regular JOIN to this table from the primary table
3321 3321
 					$SQL .= $table_obj->get_join_sql($alias_prefixed);
3322 3322
 				}
@@ -3330,9 +3330,9 @@  discard block
 block discarded – undo
3330 3330
 	 * This should be a growing array of keys being table-columns (eg 'EVT_ID' and 'Event.EVT_ID'), and values being their data type (eg, '%s', '%d', etc)
3331 3331
 	 * @return array
3332 3332
 	 */
3333
-	function _get_data_types(){
3333
+	function _get_data_types() {
3334 3334
 		$data_types = array();
3335
-		foreach(array_values($this->field_settings()) as $field_obj){
3335
+		foreach (array_values($this->field_settings()) as $field_obj) {
3336 3336
 			//$data_types[$field_obj->get_table_column()] = $field_obj->get_wpdb_data_type();
3337 3337
 			/** @var $field_obj EE_Model_Field_Base */
3338 3338
 			$data_types[$field_obj->get_qualified_column()] = $field_obj->get_wpdb_data_type();
@@ -3348,11 +3348,11 @@  discard block
 block discarded – undo
3348 3348
 	 * @throws EE_Error
3349 3349
 	 * @return EEM_Base
3350 3350
 	 */
3351
-	function get_related_model_obj($model_name){
3351
+	function get_related_model_obj($model_name) {
3352 3352
 
3353 3353
 		$model_classname = "EEM_".$model_name;
3354
-		if(!class_exists($model_classname)){
3355
-			throw new EE_Error(sprintf(__("You specified a related model named %s in your query. No such model exists, if it did, it would have the classname %s",'event_espresso'),$model_name,$model_classname));
3354
+		if ( ! class_exists($model_classname)) {
3355
+			throw new EE_Error(sprintf(__("You specified a related model named %s in your query. No such model exists, if it did, it would have the classname %s", 'event_espresso'), $model_name, $model_classname));
3356 3356
 		}
3357 3357
 		$model_obj = call_user_func($model_classname."::instance");
3358 3358
 		return $model_obj;
@@ -3363,7 +3363,7 @@  discard block
 block discarded – undo
3363 3363
 	 * Returns the array of EE_ModelRelations for this model.
3364 3364
 	 * @return EE_Model_Relation_Base[]
3365 3365
 	 */
3366
-	public function relation_settings(){
3366
+	public function relation_settings() {
3367 3367
 		return $this->_model_relations;
3368 3368
 	}
3369 3369
 
@@ -3373,10 +3373,10 @@  discard block
 block discarded – undo
3373 3373
 	 * (Eg, without an event, datetimes have little purpose.)
3374 3374
 	 * @return EE_Belongs_To_Relation[]
3375 3375
 	 */
3376
-	public function belongs_to_relations(){
3376
+	public function belongs_to_relations() {
3377 3377
 		$belongs_to_relations = array();
3378
-		foreach($this->relation_settings() as $model_name => $relation_obj){
3379
-			if($relation_obj instanceof EE_Belongs_To_Relation){
3378
+		foreach ($this->relation_settings() as $model_name => $relation_obj) {
3379
+			if ($relation_obj instanceof EE_Belongs_To_Relation) {
3380 3380
 				$belongs_to_relations[$model_name] = $relation_obj;
3381 3381
 			}
3382 3382
 		}
@@ -3391,15 +3391,15 @@  discard block
 block discarded – undo
3391 3391
 	 * @throws EE_Error
3392 3392
 	 * @return EE_Model_Relation_Base
3393 3393
 	 */
3394
-	public function related_settings_for($relation_name){
3395
-		$relatedModels=$this->relation_settings();
3396
-		if(!array_key_exists($relation_name,$relatedModels)){
3394
+	public function related_settings_for($relation_name) {
3395
+		$relatedModels = $this->relation_settings();
3396
+		if ( ! array_key_exists($relation_name, $relatedModels)) {
3397 3397
 			throw new EE_Error(
3398 3398
 				sprintf(
3399
-					__('Cannot get %s related to %s. There is no model relation of that type. There is, however, %s...','event_espresso'),
3399
+					__('Cannot get %s related to %s. There is no model relation of that type. There is, however, %s...', 'event_espresso'),
3400 3400
 					$relation_name,
3401 3401
 					$this->_get_class_name(),
3402
-					implode( ', ', array_keys( $relatedModels ))
3402
+					implode(', ', array_keys($relatedModels))
3403 3403
 				)
3404 3404
 			);
3405 3405
 		}
@@ -3414,10 +3414,10 @@  discard block
 block discarded – undo
3414 3414
 	 * @throws EE_Error
3415 3415
 	 * @return EE_Model_Field_Base
3416 3416
 	 */
3417
-	public function field_settings_for($fieldName){
3418
-		$fieldSettings=$this->field_settings(true);
3419
-		if( ! array_key_exists($fieldName,$fieldSettings)){
3420
-			throw new EE_Error(sprintf(__("There is no field/column '%s' on '%s'",'event_espresso'),$fieldName,get_class($this)));
3417
+	public function field_settings_for($fieldName) {
3418
+		$fieldSettings = $this->field_settings(true);
3419
+		if ( ! array_key_exists($fieldName, $fieldSettings)) {
3420
+			throw new EE_Error(sprintf(__("There is no field/column '%s' on '%s'", 'event_espresso'), $fieldName, get_class($this)));
3421 3421
 		}
3422 3422
 		return $fieldSettings[$fieldName];
3423 3423
 	}
@@ -3427,11 +3427,11 @@  discard block
 block discarded – undo
3427 3427
 	 * @param string $fieldName a key in the model's _field_settings array
3428 3428
 	 * @return boolean
3429 3429
 	 */
3430
-	public function has_field($fieldName){
3430
+	public function has_field($fieldName) {
3431 3431
 		$fieldSettings = $this->field_settings(true);
3432
-		if( isset($fieldSettings[$fieldName])){
3432
+		if (isset($fieldSettings[$fieldName])) {
3433 3433
 			return true;
3434
-		}else{
3434
+		} else {
3435 3435
 			return false;
3436 3436
 		}
3437 3437
 	}
@@ -3441,11 +3441,11 @@  discard block
 block discarded – undo
3441 3441
 	 * @param string $relation_name possibly one of the keys in the relation_settings array
3442 3442
 	 * @return boolean
3443 3443
 	 */
3444
-	public function has_relation($relation_name){
3444
+	public function has_relation($relation_name) {
3445 3445
 		$relations = $this->relation_settings();
3446
-		if(isset($relations[$relation_name])){
3446
+		if (isset($relations[$relation_name])) {
3447 3447
 			return true;
3448
-		}else{
3448
+		} else {
3449 3449
 			return false;
3450 3450
 		}
3451 3451
 	}
@@ -3457,7 +3457,7 @@  discard block
 block discarded – undo
3457 3457
 	 * @param $field_obj
3458 3458
 	 * @return EE_Model_Field_Base
3459 3459
 	 */
3460
-	public function is_primary_key_field( $field_obj ){
3460
+	public function is_primary_key_field($field_obj) {
3461 3461
 		return $field_obj instanceof EE_Primary_Key_Field_Base ? TRUE : FALSE;
3462 3462
 	}
3463 3463
 
@@ -3469,16 +3469,16 @@  discard block
 block discarded – undo
3469 3469
 	 * @return EE_Model_Field_Base
3470 3470
 	 * @throws EE_Error
3471 3471
 	 */
3472
-	public function get_primary_key_field(){
3473
-		if( $this->_primary_key_field === NULL ){
3474
-			foreach( $this->field_settings( TRUE ) as $field_obj ){
3475
-				if( $this->is_primary_key_field( $field_obj )){
3472
+	public function get_primary_key_field() {
3473
+		if ($this->_primary_key_field === NULL) {
3474
+			foreach ($this->field_settings(TRUE) as $field_obj) {
3475
+				if ($this->is_primary_key_field($field_obj)) {
3476 3476
 					$this->_primary_key_field = $field_obj;
3477 3477
 					break;
3478 3478
 				}
3479 3479
 			}
3480
-			if( ! $this->_primary_key_field instanceof EE_Primary_Key_Field_Base ){
3481
-				throw new EE_Error(sprintf(__("There is no Primary Key defined on model %s",'event_espresso'),get_class($this)));
3480
+			if ( ! $this->_primary_key_field instanceof EE_Primary_Key_Field_Base) {
3481
+				throw new EE_Error(sprintf(__("There is no Primary Key defined on model %s", 'event_espresso'), get_class($this)));
3482 3482
 			}
3483 3483
 		}
3484 3484
 		return $this->_primary_key_field;
@@ -3491,12 +3491,12 @@  discard block
 block discarded – undo
3491 3491
 	 * Internally does some caching.
3492 3492
 	 * @return boolean
3493 3493
 	 */
3494
-	public function has_primary_key_field(){
3495
-		if($this->_has_primary_key_field === null){
3496
-			try{
3494
+	public function has_primary_key_field() {
3495
+		if ($this->_has_primary_key_field === null) {
3496
+			try {
3497 3497
 				$this->get_primary_key_field();
3498 3498
 				$this->_has_primary_key_field = true;
3499
-			}catch(EE_Error $e){
3499
+			} catch (EE_Error $e) {
3500 3500
 				$this->_has_primary_key_field = false;
3501 3501
 			}
3502 3502
 		}
@@ -3510,9 +3510,9 @@  discard block
 block discarded – undo
3510 3510
 	 * @param string $field_class_name class name of field that you want to find. Eg, EE_Datetime_Field, EE_Foreign_Key_Field, etc
3511 3511
 	 * @return EE_Model_Field_Base or null if none is found
3512 3512
 	 */
3513
-	public function get_a_field_of_type($field_class_name){
3514
-		foreach($this->field_settings() as $field){
3515
-			if( $field instanceof $field_class_name ){
3513
+	public function get_a_field_of_type($field_class_name) {
3514
+		foreach ($this->field_settings() as $field) {
3515
+			if ($field instanceof $field_class_name) {
3516 3516
 				return $field;
3517 3517
 			}
3518 3518
 		}
@@ -3526,21 +3526,21 @@  discard block
 block discarded – undo
3526 3526
 	 * @return EE_Foreign_Key_Field_Base
3527 3527
 	 * @throws EE_Error
3528 3528
 	 */
3529
-	public function get_foreign_key_to($model_name){
3530
-		if( ! isset( $this->_cache_foreign_key_to_fields[ $model_name ] ) ){
3531
-			foreach($this->field_settings() as $field){
3529
+	public function get_foreign_key_to($model_name) {
3530
+		if ( ! isset($this->_cache_foreign_key_to_fields[$model_name])) {
3531
+			foreach ($this->field_settings() as $field) {
3532 3532
 //				if(is_subclass_of($field, 'EE_Foreign_Key_Field_Base')){
3533
-				if( $field instanceof EE_Foreign_Key_Field_Base ){
3534
-					if (in_array($model_name,$field->get_model_names_pointed_to() ) ) {
3535
-						$this->_cache_foreign_key_to_fields[ $model_name ] = $field;
3533
+				if ($field instanceof EE_Foreign_Key_Field_Base) {
3534
+					if (in_array($model_name, $field->get_model_names_pointed_to())) {
3535
+						$this->_cache_foreign_key_to_fields[$model_name] = $field;
3536 3536
 					}
3537 3537
 				}
3538 3538
 			}
3539
-			if( ! isset( $this->_cache_foreign_key_to_fields[ $model_name ] ) ){
3540
-				throw new EE_Error(sprintf(__("There is no foreign key field pointing to model %s on model %s",'event_espresso'),$model_name,get_class($this)));
3539
+			if ( ! isset($this->_cache_foreign_key_to_fields[$model_name])) {
3540
+				throw new EE_Error(sprintf(__("There is no foreign key field pointing to model %s on model %s", 'event_espresso'), $model_name, get_class($this)));
3541 3541
 			}
3542 3542
 		}
3543
-		return $this->_cache_foreign_key_to_fields[ $model_name ];
3543
+		return $this->_cache_foreign_key_to_fields[$model_name];
3544 3544
 	}
3545 3545
 
3546 3546
 
@@ -3551,7 +3551,7 @@  discard block
 block discarded – undo
3551 3551
 	 * a table alias with a model chain prefix, like 'Venue__Event_Venue___Event_Meta'. Either one works
3552 3552
 	 * @return EE_Table_Base
3553 3553
 	 */
3554
-	function get_table_for_alias($table_alias){
3554
+	function get_table_for_alias($table_alias) {
3555 3555
 		$table_alias_sans_model_relation_chain_prefix = EE_Model_Parser::remove_table_alias_model_relation_chain_prefix($table_alias);
3556 3556
 		return $this->_tables[$table_alias_sans_model_relation_chain_prefix]->get_table_name();
3557 3557
 	}
@@ -3564,25 +3564,25 @@  discard block
 block discarded – undo
3564 3564
 	 * @param bool $include_db_only_fields flag indicating whether or not to include the db-only fields
3565 3565
 	 * @return EE_Model_Field_Base[] where the keys are the field's name
3566 3566
 	 */
3567
-	public function field_settings($include_db_only_fields = false){
3568
-		if( $include_db_only_fields ){
3569
-			if( $this->_cached_fields === NULL ){
3567
+	public function field_settings($include_db_only_fields = false) {
3568
+		if ($include_db_only_fields) {
3569
+			if ($this->_cached_fields === NULL) {
3570 3570
 				$this->_cached_fields = array();
3571
-				foreach($this->_fields as $fields_corresponding_to_table){
3572
-					foreach($fields_corresponding_to_table as $field_name => $field_obj){
3573
-						$this->_cached_fields[$field_name]=$field_obj;
3571
+				foreach ($this->_fields as $fields_corresponding_to_table) {
3572
+					foreach ($fields_corresponding_to_table as $field_name => $field_obj) {
3573
+						$this->_cached_fields[$field_name] = $field_obj;
3574 3574
 					}
3575 3575
 				}
3576 3576
 			}
3577 3577
 			return $this->_cached_fields;
3578
-		}else{
3579
-			if( $this->_cached_fields_non_db_only === NULL ){
3578
+		} else {
3579
+			if ($this->_cached_fields_non_db_only === NULL) {
3580 3580
 				$this->_cached_fields_non_db_only = array();
3581
-				foreach($this->_fields as $fields_corresponding_to_table){
3582
-					foreach($fields_corresponding_to_table as $field_name => $field_obj){
3581
+				foreach ($this->_fields as $fields_corresponding_to_table) {
3582
+					foreach ($fields_corresponding_to_table as $field_name => $field_obj) {
3583 3583
 						/** @var $field_obj EE_Model_Field_Base */
3584
-						if( ! $field_obj->is_db_only_field() ){
3585
-							$this->_cached_fields_non_db_only[$field_name]=$field_obj;
3584
+						if ( ! $field_obj->is_db_only_field()) {
3585
+							$this->_cached_fields_non_db_only[$field_name] = $field_obj;
3586 3586
 						}
3587 3587
 					}
3588 3588
 				}
@@ -3601,67 +3601,67 @@  discard block
 block discarded – undo
3601 3601
 	 * @return \EE_Base_Class[] array keys are primary keys (if there is a primary key on the model. if not, numerically indexed)
3602 3602
 	 * @throws \EE_Error
3603 3603
 	 */
3604
-	protected function _create_objects( $rows = array() ) {
3605
-		$array_of_objects=array();
3606
-		if(empty($rows)){
3604
+	protected function _create_objects($rows = array()) {
3605
+		$array_of_objects = array();
3606
+		if (empty($rows)) {
3607 3607
 			return array();
3608 3608
 		}
3609 3609
 		$count_if_model_has_no_primary_key = 0;
3610 3610
 		$has_primary_key = $this->has_primary_key_field();
3611
-		if( $has_primary_key ) {
3611
+		if ($has_primary_key) {
3612 3612
 			$primary_key_field = $this->get_primary_key_field();
3613 3613
 		} else {
3614 3614
 			$primary_key_field = null;
3615 3615
 		}
3616
-		foreach ( $rows as $row ) {
3617
-			if(empty($row)){
3616
+		foreach ($rows as $row) {
3617
+			if (empty($row)) {
3618 3618
 				//wp did its weird thing where it returns an array like array(0=>null), which is totally not helpful...
3619 3619
 				return array();
3620 3620
 			}
3621 3621
 			//check if we've already set this object in the results array,
3622 3622
 			//in which case there's no need to process it further (again)
3623
-			if( $has_primary_key ) {
3623
+			if ($has_primary_key) {
3624 3624
 				$table_pk_value = $this->_get_column_value_with_table_alias_or_not(
3625 3625
 					$row,
3626 3626
 					$primary_key_field->get_qualified_column(),
3627 3627
 					$primary_key_field->get_table_column()
3628 3628
 				);
3629
-				if( $table_pk_value &&
3630
-					isset( $array_of_objects[ $table_pk_value ] ) ) {
3629
+				if ($table_pk_value &&
3630
+					isset($array_of_objects[$table_pk_value])) {
3631 3631
 					continue;
3632 3632
 				}
3633 3633
 			}
3634
-			$classInstance=$this->instantiate_class_from_array_or_object($row);
3635
-			if( ! $classInstance ) {
3634
+			$classInstance = $this->instantiate_class_from_array_or_object($row);
3635
+			if ( ! $classInstance) {
3636 3636
 				throw new EE_Error(
3637 3637
 					sprintf(
3638
-						__( 'Could not create instance of class %s from row %s', 'event_espresso' ),
3638
+						__('Could not create instance of class %s from row %s', 'event_espresso'),
3639 3639
 						$this->get_this_model_name(),
3640
-						http_build_query( $row )
3640
+						http_build_query($row)
3641 3641
 					)
3642 3642
 				);
3643 3643
 			}
3644 3644
 			//set the timezone on the instantiated objects
3645
-			$classInstance->set_timezone( $this->_timezone );
3645
+			$classInstance->set_timezone($this->_timezone);
3646 3646
 			//make sure if there is any timezone setting present that we set the timezone for the object
3647 3647
 			$key = $has_primary_key ? $classInstance->ID() : $count_if_model_has_no_primary_key++;
3648
-			$array_of_objects[ $key ] = $classInstance;
3648
+			$array_of_objects[$key] = $classInstance;
3649 3649
 			//also, for all the relations of type BelongsTo, see if we can cache
3650 3650
 			//those related models
3651 3651
 			//(we could do this for other relations too, but if there are conditions
3652 3652
 			//that filtered out some fo the results, then we'd be caching an incomplete set
3653 3653
 			//so it requires a little more thought than just caching them immediately...)
3654
-			foreach($this->_model_relations as $modelName => $relation_obj){
3655
-				if( $relation_obj instanceof EE_Belongs_To_Relation){
3654
+			foreach ($this->_model_relations as $modelName => $relation_obj) {
3655
+				if ($relation_obj instanceof EE_Belongs_To_Relation) {
3656 3656
 					//check if this model's INFO is present. If so, cache it on the model
3657 3657
 					$other_model = $relation_obj->get_other_model();
3658 3658
 
3659 3659
 					$other_model_obj_maybe = $other_model->instantiate_class_from_array_or_object($row);
3660 3660
 
3661 3661
 					//if we managed to make a model object from the results, cache it on the main model object
3662
-					if( $other_model_obj_maybe ){
3662
+					if ($other_model_obj_maybe) {
3663 3663
 						//set timezone on these other model objects if they are present
3664
-						$other_model_obj_maybe->set_timezone( $this->_timezone );
3664
+						$other_model_obj_maybe->set_timezone($this->_timezone);
3665 3665
 						$classInstance->cache($modelName, $other_model_obj_maybe);
3666 3666
 					}
3667 3667
 				}
@@ -3682,12 +3682,12 @@  discard block
 block discarded – undo
3682 3682
 
3683 3683
 		$this_model_fields_and_values = array();
3684 3684
 		//setup the row using default values;
3685
-		foreach ( $this->field_settings() as $field_name => $field_obj ) {
3685
+		foreach ($this->field_settings() as $field_name => $field_obj) {
3686 3686
 			$this_model_fields_and_values[$field_name] = $field_obj->get_default_value();
3687 3687
 		}
3688 3688
 
3689 3689
 		$className = $this->_get_class_name();
3690
-		$classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_and_values ), FALSE, FALSE );
3690
+		$classInstance = EE_Registry::instance()->load_class($className, array($this_model_fields_and_values), FALSE, FALSE);
3691 3691
 
3692 3692
 		return $classInstance;
3693 3693
 	}
@@ -3700,45 +3700,45 @@  discard block
 block discarded – undo
3700 3700
 	 * or an stdClass where each property is the name of a column,
3701 3701
 	 * @return EE_Base_Class
3702 3702
 	 */
3703
-	public function instantiate_class_from_array_or_object($cols_n_values){
3704
-		if( ! is_array( $cols_n_values ) && is_object( $cols_n_values )) {
3705
-			$cols_n_values = get_object_vars( $cols_n_values );
3703
+	public function instantiate_class_from_array_or_object($cols_n_values) {
3704
+		if ( ! is_array($cols_n_values) && is_object($cols_n_values)) {
3705
+			$cols_n_values = get_object_vars($cols_n_values);
3706 3706
 		}
3707 3707
 		$primary_key = NULL;
3708 3708
 		//make sure the array only has keys that are fields/columns on this model
3709
-		$this_model_fields_n_values = $this->_deduce_fields_n_values_from_cols_n_values( $cols_n_values );
3710
-		if( $this->has_primary_key_field() && isset( $this_model_fields_n_values[ $this->primary_key_name() ] ) ){
3711
-			$primary_key = $this_model_fields_n_values[ $this->primary_key_name() ];
3709
+		$this_model_fields_n_values = $this->_deduce_fields_n_values_from_cols_n_values($cols_n_values);
3710
+		if ($this->has_primary_key_field() && isset($this_model_fields_n_values[$this->primary_key_name()])) {
3711
+			$primary_key = $this_model_fields_n_values[$this->primary_key_name()];
3712 3712
 		}
3713
-		$className=$this->_get_class_name();
3713
+		$className = $this->_get_class_name();
3714 3714
 
3715 3715
 		//check we actually found results that we can use to build our model object
3716 3716
 		//if not, return null
3717
-		if( $this->has_primary_key_field()){
3718
-			if(empty( $this_model_fields_n_values[$this->primary_key_name()] )){
3717
+		if ($this->has_primary_key_field()) {
3718
+			if (empty($this_model_fields_n_values[$this->primary_key_name()])) {
3719 3719
 				return NULL;
3720 3720
 			}
3721
-		}else if($this->unique_indexes()){
3721
+		} else if ($this->unique_indexes()) {
3722 3722
 			$first_column = reset($this_model_fields_n_values);
3723
-			if(empty($first_column)){
3723
+			if (empty($first_column)) {
3724 3724
 				return NULL;
3725 3725
 			}
3726 3726
 		}
3727 3727
 
3728 3728
 		// if there is no primary key or the object doesn't already exist in the entity map, then create a new instance
3729
-		if ( $primary_key){
3730
-			$classInstance = $this->get_from_entity_map( $primary_key );
3731
-			if( ! $classInstance) {
3732
-				$classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_n_values, $this->_timezone ), TRUE, FALSE );
3729
+		if ($primary_key) {
3730
+			$classInstance = $this->get_from_entity_map($primary_key);
3731
+			if ( ! $classInstance) {
3732
+				$classInstance = EE_Registry::instance()->load_class($className, array($this_model_fields_n_values, $this->_timezone), TRUE, FALSE);
3733 3733
 				// add this new object to the entity map
3734
-				$classInstance = $this->add_to_entity_map( $classInstance );
3734
+				$classInstance = $this->add_to_entity_map($classInstance);
3735 3735
 			}
3736
-		}else{
3737
-			$classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_n_values, $this->_timezone ), TRUE, FALSE );
3736
+		} else {
3737
+			$classInstance = EE_Registry::instance()->load_class($className, array($this_model_fields_n_values, $this->_timezone), TRUE, FALSE);
3738 3738
 		}
3739 3739
 
3740 3740
 			//it is entirely possible that the instantiated class object has a set timezone_string db field and has set it's internal _timezone property accordingly (see new_instance_from_db in model objects particularly EE_Event for example).  In this case, we want to make sure the model object doesn't have its timezone string overwritten by any timezone property currently set here on the model so, we intentionally override the model _timezone property with the model_object timezone property.
3741
-		$this->set_timezone( $classInstance->get_timezone() );
3741
+		$this->set_timezone($classInstance->get_timezone());
3742 3742
 		return $classInstance;
3743 3743
 	}
3744 3744
 	/**
@@ -3746,8 +3746,8 @@  discard block
 block discarded – undo
3746 3746
 	 * @param int|string $id the ID of the model object
3747 3747
 	 * @return EE_Base_Class
3748 3748
 	 */
3749
-	public function get_from_entity_map( $id ){
3750
-		return isset( $this->_entity_map[ $id ] ) ? $this->_entity_map[ $id ] : NULL;
3749
+	public function get_from_entity_map($id) {
3750
+		return isset($this->_entity_map[$id]) ? $this->_entity_map[$id] : NULL;
3751 3751
 	}
3752 3752
 
3753 3753
 
@@ -3766,21 +3766,21 @@  discard block
 block discarded – undo
3766 3766
 	 * @throws EE_Error
3767 3767
 	 * @return \EE_Base_Class
3768 3768
 	 */
3769
-	public function add_to_entity_map( EE_Base_Class $object) {
3769
+	public function add_to_entity_map(EE_Base_Class $object) {
3770 3770
 		$className = $this->_get_class_name();
3771
-		if( ! $object instanceof $className ){
3772
-			throw new EE_Error(sprintf(__("You tried adding a %s to a mapping of %ss", "event_espresso"),is_object( $object ) ? get_class( $object ) : $object, $className ) );
3771
+		if ( ! $object instanceof $className) {
3772
+			throw new EE_Error(sprintf(__("You tried adding a %s to a mapping of %ss", "event_espresso"), is_object($object) ? get_class($object) : $object, $className));
3773 3773
 		}
3774 3774
 		/** @var $object EE_Base_Class */
3775
-		if ( ! $object->ID() ){
3776
-			throw new EE_Error(sprintf(__("You tried storing a model object with NO ID in the %s entity mapper.", "event_espresso"),get_class($this)));
3775
+		if ( ! $object->ID()) {
3776
+			throw new EE_Error(sprintf(__("You tried storing a model object with NO ID in the %s entity mapper.", "event_espresso"), get_class($this)));
3777 3777
 		}
3778 3778
 		// double check it's not already there
3779
-		$classInstance = $this->get_from_entity_map( $object->ID() );
3780
-		if ( $classInstance ) {
3779
+		$classInstance = $this->get_from_entity_map($object->ID());
3780
+		if ($classInstance) {
3781 3781
 			return $classInstance;
3782 3782
 		} else {
3783
-			$this->_entity_map[ $object->ID() ] = $object;
3783
+			$this->_entity_map[$object->ID()] = $object;
3784 3784
 			return $object;
3785 3785
 		}
3786 3786
 	}
@@ -3793,8 +3793,8 @@  discard block
 block discarded – undo
3793 3793
 	 * @param array $cols_n_values
3794 3794
 	 * @return array
3795 3795
 	 */
3796
-	public function deduce_fields_n_values_from_cols_n_values( $cols_n_values ) {
3797
-		return $this->_deduce_fields_n_values_from_cols_n_values( $cols_n_values );
3796
+	public function deduce_fields_n_values_from_cols_n_values($cols_n_values) {
3797
+		return $this->_deduce_fields_n_values_from_cols_n_values($cols_n_values);
3798 3798
 	}
3799 3799
 
3800 3800
 
@@ -3807,40 +3807,40 @@  discard block
 block discarded – undo
3807 3807
 	 * @param string $cols_n_values
3808 3808
 	 * @return array
3809 3809
 	 */
3810
-	protected function _deduce_fields_n_values_from_cols_n_values( $cols_n_values ){
3810
+	protected function _deduce_fields_n_values_from_cols_n_values($cols_n_values) {
3811 3811
 		$this_model_fields_n_values = array();
3812
-		foreach( $this->get_tables() as $table_alias => $table_obj ) {
3813
-			$table_pk_value = $this->_get_column_value_with_table_alias_or_not($cols_n_values, $table_obj->get_fully_qualified_pk_column(), $table_obj->get_pk_column() );
3812
+		foreach ($this->get_tables() as $table_alias => $table_obj) {
3813
+			$table_pk_value = $this->_get_column_value_with_table_alias_or_not($cols_n_values, $table_obj->get_fully_qualified_pk_column(), $table_obj->get_pk_column());
3814 3814
 			//there is a primary key on this table and its not set. Use defaults for all its columns
3815
-			if( $table_obj->get_pk_column() && $table_pk_value === NULL ){
3816
-				foreach( $this->_get_fields_for_table( $table_alias ) as $field_name => $field_obj ) {
3817
-					if( ! $field_obj->is_db_only_field() ){
3815
+			if ($table_obj->get_pk_column() && $table_pk_value === NULL) {
3816
+				foreach ($this->_get_fields_for_table($table_alias) as $field_name => $field_obj) {
3817
+					if ( ! $field_obj->is_db_only_field()) {
3818 3818
 						//prepare field as if its coming from db
3819
-						$prepared_value = $field_obj->prepare_for_set( $field_obj->get_default_value() );
3820
-						$this_model_fields_n_values[$field_name] = $field_obj->prepare_for_use_in_db( $prepared_value );
3819
+						$prepared_value = $field_obj->prepare_for_set($field_obj->get_default_value());
3820
+						$this_model_fields_n_values[$field_name] = $field_obj->prepare_for_use_in_db($prepared_value);
3821 3821
 					}
3822 3822
 				}
3823
-			}else{
3823
+			} else {
3824 3824
 				//the table's rows existed. Use their values
3825
-				foreach( $this->_get_fields_for_table( $table_alias ) as $field_name => $field_obj ) {
3826
-					if( ! $field_obj->is_db_only_field() )
3827
-					$this_model_fields_n_values[$field_name] = $this->_get_column_value_with_table_alias_or_not($cols_n_values, $field_obj->get_qualified_column(), $field_obj->get_table_column() );
3825
+				foreach ($this->_get_fields_for_table($table_alias) as $field_name => $field_obj) {
3826
+					if ( ! $field_obj->is_db_only_field())
3827
+					$this_model_fields_n_values[$field_name] = $this->_get_column_value_with_table_alias_or_not($cols_n_values, $field_obj->get_qualified_column(), $field_obj->get_table_column());
3828 3828
 				}
3829 3829
 			}
3830 3830
 		}
3831 3831
 		return $this_model_fields_n_values;
3832 3832
 	}
3833 3833
 
3834
-	protected function _get_column_value_with_table_alias_or_not( $cols_n_values, $qualified_column, $regular_column ){
3834
+	protected function _get_column_value_with_table_alias_or_not($cols_n_values, $qualified_column, $regular_column) {
3835 3835
 		//ask the field what it think it's table_name.column_name should be, and call it the "qualified column"
3836 3836
 		//does the field on the model relate to this column retrieved from the db?
3837 3837
 		//or is it a db-only field? (not relating to the model)
3838
-		if( isset( $cols_n_values[ $qualified_column ] ) ){
3839
-			$value = $cols_n_values[ $qualified_column ];
3838
+		if (isset($cols_n_values[$qualified_column])) {
3839
+			$value = $cols_n_values[$qualified_column];
3840 3840
 
3841
-		}elseif( isset( $cols_n_values[ $regular_column ] ) ){
3842
-			$value = $cols_n_values[ $regular_column ];
3843
-		}else{
3841
+		}elseif (isset($cols_n_values[$regular_column])) {
3842
+			$value = $cols_n_values[$regular_column];
3843
+		} else {
3844 3844
 			$value = NULL;
3845 3845
 		}
3846 3846
 
@@ -3858,24 +3858,24 @@  discard block
 block discarded – undo
3858 3858
 	 * @param int|string $id
3859 3859
 	 * @return EE_Base_Class
3860 3860
 	 */
3861
-	public function refresh_entity_map_from_db( $id ){
3862
-		$obj_in_map = $this->get_from_entity_map( $id );
3863
-		if( $obj_in_map ){
3864
-			$wpdb_results = $this->_get_all_wpdb_results( array( array ( $this->get_primary_key_field()->get_name() => $id ), 'limit' => 1 ) );
3865
-			if( $wpdb_results && is_array( $wpdb_results ) ){
3866
-				$one_row = reset( $wpdb_results );
3867
-				foreach( $this->_deduce_fields_n_values_from_cols_n_values($one_row ) as $field_name => $db_value ) {
3868
-					$obj_in_map->set_from_db( $field_name, $db_value );
3861
+	public function refresh_entity_map_from_db($id) {
3862
+		$obj_in_map = $this->get_from_entity_map($id);
3863
+		if ($obj_in_map) {
3864
+			$wpdb_results = $this->_get_all_wpdb_results(array(array($this->get_primary_key_field()->get_name() => $id), 'limit' => 1));
3865
+			if ($wpdb_results && is_array($wpdb_results)) {
3866
+				$one_row = reset($wpdb_results);
3867
+				foreach ($this->_deduce_fields_n_values_from_cols_n_values($one_row) as $field_name => $db_value) {
3868
+					$obj_in_map->set_from_db($field_name, $db_value);
3869 3869
 				}
3870 3870
 				//clear the cache of related model objects
3871
-				foreach ( $this->relation_settings() as $relation_name => $relation_obj ){
3872
-					$obj_in_map->clear_cache($relation_name, NULL, TRUE );
3871
+				foreach ($this->relation_settings() as $relation_name => $relation_obj) {
3872
+					$obj_in_map->clear_cache($relation_name, NULL, TRUE);
3873 3873
 				}
3874 3874
 			}
3875
-			$this->_entity_map[ $id ] = $obj_in_map;
3875
+			$this->_entity_map[$id] = $obj_in_map;
3876 3876
 			return $obj_in_map;
3877
-		}else{
3878
-			return $this->get_one_by_ID( $id );
3877
+		} else {
3878
+			return $this->get_one_by_ID($id);
3879 3879
 		}
3880 3880
 	}
3881 3881
 
@@ -3893,24 +3893,24 @@  discard block
 block discarded – undo
3893 3893
 	 * @param EE_Base_Class $replacing_model_obj
3894 3894
 	 * @return \EE_Base_Class
3895 3895
 	 */
3896
-	public function refresh_entity_map_with( $id, $replacing_model_obj ) {
3897
-		$obj_in_map = $this->get_from_entity_map( $id );
3898
-		if( $obj_in_map ){
3899
-			if( $replacing_model_obj instanceof EE_Base_Class ){
3900
-				foreach( $replacing_model_obj->model_field_array() as $field_name => $value ) {
3901
-					$obj_in_map->set( $field_name, $value );
3896
+	public function refresh_entity_map_with($id, $replacing_model_obj) {
3897
+		$obj_in_map = $this->get_from_entity_map($id);
3898
+		if ($obj_in_map) {
3899
+			if ($replacing_model_obj instanceof EE_Base_Class) {
3900
+				foreach ($replacing_model_obj->model_field_array() as $field_name => $value) {
3901
+					$obj_in_map->set($field_name, $value);
3902 3902
 				}
3903 3903
 				//make the model object in the entity map's cache match the $replacing_model_obj
3904
-				foreach ( $this->relation_settings() as $relation_name => $relation_obj ){
3905
-					$obj_in_map->clear_cache($relation_name, NULL, TRUE );
3906
-					foreach( $replacing_model_obj->get_all_from_cache( $relation_name ) as $cache_id => $cached_obj ) {
3907
-						$obj_in_map->cache( $relation_name, $cached_obj, $cache_id );
3904
+				foreach ($this->relation_settings() as $relation_name => $relation_obj) {
3905
+					$obj_in_map->clear_cache($relation_name, NULL, TRUE);
3906
+					foreach ($replacing_model_obj->get_all_from_cache($relation_name) as $cache_id => $cached_obj) {
3907
+						$obj_in_map->cache($relation_name, $cached_obj, $cache_id);
3908 3908
 					}
3909 3909
 				}
3910 3910
 			}
3911 3911
 			return $obj_in_map;
3912
-		}else{
3913
-			$this->add_to_entity_map( $replacing_model_obj );
3912
+		} else {
3913
+			$this->add_to_entity_map($replacing_model_obj);
3914 3914
 			return $replacing_model_obj;
3915 3915
 		}
3916 3916
 	}
@@ -3923,7 +3923,7 @@  discard block
 block discarded – undo
3923 3923
 	 * require_once($this->_getClassName().".class.php");
3924 3924
 	 * @return string
3925 3925
 	 */
3926
-	private function _get_class_name(){
3926
+	private function _get_class_name() {
3927 3927
 		return "EE_".$this->get_this_model_name();
3928 3928
 	}
3929 3929
 
@@ -3936,10 +3936,10 @@  discard block
 block discarded – undo
3936 3936
 	 * @param int $quantity
3937 3937
 	 * @return string
3938 3938
 	 */
3939
-	public function item_name($quantity = 1){
3940
-		if($quantity == 1){
3939
+	public function item_name($quantity = 1) {
3940
+		if ($quantity == 1) {
3941 3941
 			return $this->singular_item;
3942
-		}else{
3942
+		} else {
3943 3943
 			return $this->plural_item;
3944 3944
 		}
3945 3945
 	}
@@ -3968,13 +3968,13 @@  discard block
 block discarded – undo
3968 3968
 	 * @throws EE_Error
3969 3969
 	 * @return mixed whatever the plugin which calls add_filter decides
3970 3970
 	 */
3971
-	public function __call($methodName,$args){
3972
-		$className=get_class($this);
3973
-		$tagName="FHEE__{$className}__{$methodName}";
3974
-		if(!has_filter($tagName)){
3971
+	public function __call($methodName, $args) {
3972
+		$className = get_class($this);
3973
+		$tagName = "FHEE__{$className}__{$methodName}";
3974
+		if ( ! has_filter($tagName)) {
3975 3975
 			throw new EE_Error(
3976 3976
 				sprintf(
3977
-					__( 'Method %1$s on model %2$s does not exist! You can create one with the following code in functions.php or in a plugin: %4$s function my_callback(%4$s \$previousReturnValue, EEM_Base \$object\ $argsArray=NULL ){%4$s     /*function body*/%4$s      return \$whatever;%4$s }%4$s add_filter( \'%3$s\', \'my_callback\', 10, 3 );', 'event_espresso' ),
3977
+					__('Method %1$s on model %2$s does not exist! You can create one with the following code in functions.php or in a plugin: %4$s function my_callback(%4$s \$previousReturnValue, EEM_Base \$object\ $argsArray=NULL ){%4$s     /*function body*/%4$s      return \$whatever;%4$s }%4$s add_filter( \'%3$s\', \'my_callback\', 10, 3 );', 'event_espresso'),
3978 3978
 					$methodName,
3979 3979
 					$className,
3980 3980
 					$tagName,
@@ -3983,7 +3983,7 @@  discard block
 block discarded – undo
3983 3983
 			);
3984 3984
 		}
3985 3985
 
3986
-		return apply_filters($tagName,null,$this,$args);
3986
+		return apply_filters($tagName, null, $this, $args);
3987 3987
 	}
3988 3988
 
3989 3989
 
@@ -3996,22 +3996,22 @@  discard block
 block discarded – undo
3996 3996
 	 * @throws EE_Error
3997 3997
 	 * @return EE_Base_Class
3998 3998
 	 */
3999
-	public function ensure_is_obj( $base_class_obj_or_id, $ensure_is_in_db = FALSE ){
3999
+	public function ensure_is_obj($base_class_obj_or_id, $ensure_is_in_db = FALSE) {
4000 4000
 		$className = $this->_get_class_name();
4001 4001
 		$primary_key_field = $this->get_primary_key_field();
4002
-		if( $base_class_obj_or_id instanceof $className ){
4002
+		if ($base_class_obj_or_id instanceof $className) {
4003 4003
 			$model_object = $base_class_obj_or_id;
4004
-		}elseif( $primary_key_field instanceof EE_Primary_Key_Int_Field && (
4005
-				is_int( $base_class_obj_or_id ) ||
4006
-				is_string( $base_class_obj_or_id ) )){//assume it's an ID. either a proper integer or a string representing an integer (eg "101" instead of 101)
4004
+		}elseif ($primary_key_field instanceof EE_Primary_Key_Int_Field && (
4005
+				is_int($base_class_obj_or_id) ||
4006
+				is_string($base_class_obj_or_id) )) {//assume it's an ID. either a proper integer or a string representing an integer (eg "101" instead of 101)
4007 4007
 			$model_object = $this->get_one_by_ID($base_class_obj_or_id);
4008
-		}elseif( $primary_key_field instanceof EE_Primary_Key_String_Field && is_string($base_class_obj_or_id) ){
4008
+		}elseif ($primary_key_field instanceof EE_Primary_Key_String_Field && is_string($base_class_obj_or_id)) {
4009 4009
 			//assume its a string representation of the object
4010 4010
 			$model_object = $this->get_one_by_ID($base_class_obj_or_id);
4011
-		}else{
4012
-			throw new EE_Error(sprintf(__("'%s' is neither an object of type %s, nor an ID! Its full value is '%s'",'event_espresso'),$base_class_obj_or_id,$this->_get_class_name(),print_r($base_class_obj_or_id,true)));
4011
+		} else {
4012
+			throw new EE_Error(sprintf(__("'%s' is neither an object of type %s, nor an ID! Its full value is '%s'", 'event_espresso'), $base_class_obj_or_id, $this->_get_class_name(), print_r($base_class_obj_or_id, true)));
4013 4013
 		}
4014
-		if( $model_object->ID() == NULL && $ensure_is_in_db){
4014
+		if ($model_object->ID() == NULL && $ensure_is_in_db) {
4015 4015
 			$model_object->save();
4016 4016
 		}
4017 4017
 		return $model_object;
@@ -4027,19 +4027,19 @@  discard block
 block discarded – undo
4027 4027
 	 * @return int|string depending on the type of this model object's ID
4028 4028
 	 * @throws EE_Error
4029 4029
 	 */
4030
-	public function ensure_is_ID($base_class_obj_or_id){
4030
+	public function ensure_is_ID($base_class_obj_or_id) {
4031 4031
 		$className = $this->_get_class_name();
4032
-		if( $base_class_obj_or_id instanceof $className ){
4032
+		if ($base_class_obj_or_id instanceof $className) {
4033 4033
 			/** @var $base_class_obj_or_id EE_Base_Class */
4034 4034
 			$id = $base_class_obj_or_id->ID();
4035
-		}elseif(is_int($base_class_obj_or_id)){
4035
+		}elseif (is_int($base_class_obj_or_id)) {
4036 4036
 			//assume it's an ID
4037 4037
 			$id = $base_class_obj_or_id;
4038
-		}elseif(is_string($base_class_obj_or_id)){
4038
+		}elseif (is_string($base_class_obj_or_id)) {
4039 4039
 			//assume its a string representation of the object
4040 4040
 			$id = $base_class_obj_or_id;
4041
-		}else{
4042
-			throw new EE_Error(sprintf(__("'%s' is neither an object of type %s, nor an ID! Its full value is '%s'",'event_espresso'),$base_class_obj_or_id,$this->_get_class_name(),print_r($base_class_obj_or_id,true)));
4041
+		} else {
4042
+			throw new EE_Error(sprintf(__("'%s' is neither an object of type %s, nor an ID! Its full value is '%s'", 'event_espresso'), $base_class_obj_or_id, $this->_get_class_name(), print_r($base_class_obj_or_id, true)));
4043 4043
 		}
4044 4044
 		return $id;
4045 4045
 	}
@@ -4062,14 +4062,14 @@  discard block
 block discarded – undo
4062 4062
 	 * @param int $values_already_prepared like one of the constants on EEM_Base
4063 4063
 	 * @return void
4064 4064
 	 */
4065
-	public function assume_values_already_prepared_by_model_object($values_already_prepared = self::not_prepared_by_model_object){
4065
+	public function assume_values_already_prepared_by_model_object($values_already_prepared = self::not_prepared_by_model_object) {
4066 4066
 		$this->_values_already_prepared_by_model_object = $values_already_prepared;
4067 4067
 	}
4068 4068
 	/**
4069 4069
 	 * Read comments for assume_values_already_prepared_by_model_object()
4070 4070
 	 * @return int
4071 4071
 	 */
4072
-	public function get_assumption_concerning_values_already_prepared_by_model_object(){
4072
+	public function get_assumption_concerning_values_already_prepared_by_model_object() {
4073 4073
 		return $this->_values_already_prepared_by_model_object;
4074 4074
 	}
4075 4075
 
@@ -4077,17 +4077,17 @@  discard block
 block discarded – undo
4077 4077
 	 * Gets all the indexes on this model
4078 4078
 	 * @return EE_Index[]
4079 4079
 	 */
4080
-	public function indexes(){
4080
+	public function indexes() {
4081 4081
 		return $this->_indexes;
4082 4082
 	}
4083 4083
 	/**
4084 4084
 	 * Gets all the Unique Indexes on this model
4085 4085
 	 * @return EE_Unique_Index[]
4086 4086
 	 */
4087
-	public function unique_indexes(){
4087
+	public function unique_indexes() {
4088 4088
 		$unique_indexes = array();
4089
-		foreach($this->_indexes as $name => $index){
4090
-			if($index instanceof EE_Unique_Index){
4089
+		foreach ($this->_indexes as $name => $index) {
4090
+			if ($index instanceof EE_Unique_Index) {
4091 4091
 				$unique_indexes [$name] = $index;
4092 4092
 			}
4093 4093
 		}
@@ -4100,9 +4100,9 @@  discard block
 block discarded – undo
4100 4100
 	 * on a primary index
4101 4101
 	 * @return EE_Model_Field_Base[]
4102 4102
 	 */
4103
-	public function get_combined_primary_key_fields(){
4104
-		foreach($this->indexes() as $index){
4105
-			if($index instanceof EE_Primary_Key_Index){
4103
+	public function get_combined_primary_key_fields() {
4104
+		foreach ($this->indexes() as $index) {
4105
+			if ($index instanceof EE_Primary_Key_Index) {
4106 4106
 				return $index->fields();
4107 4107
 			}
4108 4108
 		}
@@ -4115,7 +4115,7 @@  discard block
 block discarded – undo
4115 4115
 	 * @param array $cols_n_values keys are field names, values are their values
4116 4116
 	 * @return string
4117 4117
 	 */
4118
-	public function get_index_primary_key_string($cols_n_values){
4118
+	public function get_index_primary_key_string($cols_n_values) {
4119 4119
 		$cols_n_values_for_primary_key_index = array_intersect_key($cols_n_values, $this->get_combined_primary_key_fields());
4120 4120
 		return http_build_query($cols_n_values_for_primary_key_index);
4121 4121
 	}
@@ -4127,13 +4127,13 @@  discard block
 block discarded – undo
4127 4127
 	 * @param string $index_primary_key_string
4128 4128
 	 * @return null|array
4129 4129
 	 */
4130
-	function parse_index_primary_key_string( $index_primary_key_string) {
4130
+	function parse_index_primary_key_string($index_primary_key_string) {
4131 4131
 		$key_fields = $this->get_combined_primary_key_fields();
4132 4132
 		//check all of them are in the $id
4133 4133
 		$key_vals_in_combined_pk = array();
4134
-		parse_str( $index_primary_key_string, $key_vals_in_combined_pk );
4135
-		foreach( $key_fields as $key_field_name => $field_obj ) {
4136
-			if( ! isset( $key_vals_in_combined_pk[ $key_field_name ] ) ){
4134
+		parse_str($index_primary_key_string, $key_vals_in_combined_pk);
4135
+		foreach ($key_fields as $key_field_name => $field_obj) {
4136
+			if ( ! isset($key_vals_in_combined_pk[$key_field_name])) {
4137 4137
 				return NULL;
4138 4138
 			}
4139 4139
 		}
@@ -4146,10 +4146,10 @@  discard block
 block discarded – undo
4146 4146
 	 * @param array $key_vals
4147 4147
 	 * @return boolean
4148 4148
 	 */
4149
-	function has_all_combined_primary_key_fields( $key_vals ) {
4150
-		$keys_it_should_have = array_keys( $this->get_combined_primary_key_fields() );
4151
-		foreach( $keys_it_should_have as $key ){
4152
-			if( ! isset( $key_vals[ $key ] ) ){
4149
+	function has_all_combined_primary_key_fields($key_vals) {
4150
+		$keys_it_should_have = array_keys($this->get_combined_primary_key_fields());
4151
+		foreach ($keys_it_should_have as $key) {
4152
+			if ( ! isset($key_vals[$key])) {
4153 4153
 				return false;
4154 4154
 			}
4155 4155
 		}
@@ -4165,23 +4165,23 @@  discard block
 block discarded – undo
4165 4165
 	 * @throws EE_Error
4166 4166
 	 * @return \EE_Base_Class[] Array keys are object IDs (if there is a primary key on the model. if not, numerically indexed)
4167 4167
 	 */
4168
-	public function get_all_copies($model_object_or_attributes_array, $query_params = array()){
4168
+	public function get_all_copies($model_object_or_attributes_array, $query_params = array()) {
4169 4169
 
4170
-		if($model_object_or_attributes_array instanceof EE_Base_Class){
4170
+		if ($model_object_or_attributes_array instanceof EE_Base_Class) {
4171 4171
 			$attributes_array = $model_object_or_attributes_array->model_field_array();
4172
-		}elseif(is_array($model_object_or_attributes_array)){
4172
+		}elseif (is_array($model_object_or_attributes_array)) {
4173 4173
 			$attributes_array = $model_object_or_attributes_array;
4174
-		}else{
4175
-			throw new EE_Error(sprintf(__("get_all_copies should be provided with either a model object or an array of field-value-pairs, but was given %s", "event_espresso"),$model_object_or_attributes_array));
4174
+		} else {
4175
+			throw new EE_Error(sprintf(__("get_all_copies should be provided with either a model object or an array of field-value-pairs, but was given %s", "event_espresso"), $model_object_or_attributes_array));
4176 4176
 		}
4177 4177
 		//even copies obviously won't have the same ID, so remove the primary key
4178 4178
 		//from the WHERE conditions for finding copies (if there is a primary key, of course)
4179
-		if($this->has_primary_key_field() && isset($attributes_array[$this->primary_key_name()])){
4179
+		if ($this->has_primary_key_field() && isset($attributes_array[$this->primary_key_name()])) {
4180 4180
 			unset($attributes_array[$this->primary_key_name()]);
4181 4181
 		}
4182
-		if(isset($query_params[0])){
4183
-			$query_params[0] = array_merge($attributes_array,$query_params);
4184
-		}else{
4182
+		if (isset($query_params[0])) {
4183
+			$query_params[0] = array_merge($attributes_array, $query_params);
4184
+		} else {
4185 4185
 			$query_params[0] = $attributes_array;
4186 4186
 		}
4187 4187
 		return $this->get_all($query_params);
@@ -4195,16 +4195,16 @@  discard block
 block discarded – undo
4195 4195
 	 * @param array $query_params
4196 4196
 	 * @return EE_Base_Class
4197 4197
 	 */
4198
-	function get_one_copy($model_object_or_attributes_array,$query_params = array()){
4199
-		if( ! is_array( $query_params ) ){
4200
-			EE_Error::doing_it_wrong('EEM_Base::get_one_copy', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' );
4198
+	function get_one_copy($model_object_or_attributes_array, $query_params = array()) {
4199
+		if ( ! is_array($query_params)) {
4200
+			EE_Error::doing_it_wrong('EEM_Base::get_one_copy', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0');
4201 4201
 			$query_params = array();
4202 4202
 		}
4203 4203
 		$query_params['limit'] = 1;
4204
-		$copies = $this->get_all_copies($model_object_or_attributes_array,$query_params);
4205
-		if(is_array($copies)){
4204
+		$copies = $this->get_all_copies($model_object_or_attributes_array, $query_params);
4205
+		if (is_array($copies)) {
4206 4206
 			return array_shift($copies);
4207
-		}else{
4207
+		} else {
4208 4208
 			return null;
4209 4209
 		}
4210 4210
 	}
@@ -4218,10 +4218,10 @@  discard block
 block discarded – undo
4218 4218
 	 * @param int|string $id the value of the primary key to update
4219 4219
 	 * @return int number of rows updated
4220 4220
 	 */
4221
-	public function update_by_ID($fields_n_values,$id){
4221
+	public function update_by_ID($fields_n_values, $id) {
4222 4222
 		$query_params = array(0=>array($this->get_primary_key_field()->get_name() => $id),
4223 4223
 			'default_where_conditions'=>'other_models_only',);
4224
-		return $this->update($fields_n_values,$query_params);
4224
+		return $this->update($fields_n_values, $query_params);
4225 4225
 	}
4226 4226
 
4227 4227
 
@@ -4232,12 +4232,12 @@  discard block
 block discarded – undo
4232 4232
 	 * @return string an operator which can be used in SQL
4233 4233
 	 * @throws EE_Error
4234 4234
 	 */
4235
-	private function _prepare_operator_for_sql($operator_supplied){
4235
+	private function _prepare_operator_for_sql($operator_supplied) {
4236 4236
 		$sql_operator = isset($this->_valid_operators[$operator_supplied]) ? $this->_valid_operators[$operator_supplied] : null;
4237
-		if($sql_operator){
4237
+		if ($sql_operator) {
4238 4238
 			return $sql_operator;
4239
-		}else{
4240
-			throw new EE_Error(sprintf(__("The operator '%s' is not in the list of valid operators: %s", "event_espresso"),$operator_supplied,implode(",",array_keys($this->_valid_operators))));
4239
+		} else {
4240
+			throw new EE_Error(sprintf(__("The operator '%s' is not in the list of valid operators: %s", "event_espresso"), $operator_supplied, implode(",", array_keys($this->_valid_operators))));
4241 4241
 		}
4242 4242
 	}
4243 4243
 
@@ -4247,10 +4247,10 @@  discard block
 block discarded – undo
4247 4247
 	 * @param array $query_params like get_all's
4248 4248
 	 * @return string[]
4249 4249
 	 */
4250
-	public function get_all_names($query_params = array()){
4250
+	public function get_all_names($query_params = array()) {
4251 4251
 		$objs = $this->get_all($query_params);
4252 4252
 		$names = array();
4253
-		foreach($objs as $obj){
4253
+		foreach ($objs as $obj) {
4254 4254
 			$names[$obj->ID()] = $obj->name();
4255 4255
 		}
4256 4256
 		return $names;
@@ -4265,22 +4265,22 @@  discard block
 block discarded – undo
4265 4265
 	 * @param boolean $filter_out_empty_ids if a model object has an ID of '' or 0, don't bother including it in the returned array
4266 4266
 	 * @return array
4267 4267
 	 */
4268
-	public function get_IDs( $model_objects, $filter_out_empty_ids = false) {
4269
-		if( ! $this->has_primary_key_field() ) {
4270
-			if( WP_DEBUG ) {
4271
-				EE_Error::add_error( __( 'Trying to get IDs from a model than has no primary key', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
4268
+	public function get_IDs($model_objects, $filter_out_empty_ids = false) {
4269
+		if ( ! $this->has_primary_key_field()) {
4270
+			if (WP_DEBUG) {
4271
+				EE_Error::add_error(__('Trying to get IDs from a model than has no primary key', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
4272 4272
 				return array();
4273 4273
 			}
4274 4274
 		}
4275 4275
 		$IDs = array();
4276
-		foreach( $model_objects as $model_object ) {
4276
+		foreach ($model_objects as $model_object) {
4277 4277
 			$id = $model_object->ID();
4278
-			if( ! $id ) {
4279
-				if( $filter_out_empty_ids ) {
4278
+			if ( ! $id) {
4279
+				if ($filter_out_empty_ids) {
4280 4280
 					continue;
4281 4281
 				}
4282
-				if( WP_DEBUG ) {
4283
-					EE_Error::add_error(__( 'Called %1$s on a model object that has no ID and so probably hasn\'t been saved to the database', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
4282
+				if (WP_DEBUG) {
4283
+					EE_Error::add_error(__('Called %1$s on a model object that has no ID and so probably hasn\'t been saved to the database', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
4284 4284
 				}
4285 4285
 			}
4286 4286
 			$IDs[] = $id;
@@ -4293,8 +4293,8 @@  discard block
 block discarded – undo
4293 4293
 	 * are no capabilities that relate to this model returns false
4294 4294
 	 * @return string|false
4295 4295
 	 */
4296
-	public function cap_slug(){
4297
-		return apply_filters( 'FHEE__EEM_Base__cap_slug', $this->_caps_slug, $this);
4296
+	public function cap_slug() {
4297
+		return apply_filters('FHEE__EEM_Base__cap_slug', $this->_caps_slug, $this);
4298 4298
 	}
4299 4299
 
4300 4300
 	/**
@@ -4306,27 +4306,27 @@  discard block
 block discarded – undo
4306 4306
 	 * @param string $context
4307 4307
 	 * @return EE_Default_Where_Conditions[] indexed by associated capability
4308 4308
 	 */
4309
-	public function cap_restrictions( $context = EEM_Base::caps_read ) {
4310
-		EEM_Base::verify_is_valid_cap_context( $context );
4309
+	public function cap_restrictions($context = EEM_Base::caps_read) {
4310
+		EEM_Base::verify_is_valid_cap_context($context);
4311 4311
 		//check if we ought to run the restriction generator first
4312
-		if( isset( $this->_cap_restriction_generators[ $context ] ) &&
4313
-				$this->_cap_restriction_generators[ $context ] instanceof EE_Restriction_Generator_Base &&
4314
-				! $this->_cap_restriction_generators[ $context ]->has_generated_cap_restrictions() ) {
4315
-			$this->_cap_restrictions[ $context ] = array_merge( $this->_cap_restrictions[ $context ],  $this->_cap_restriction_generators[ $context ]->generate_restrictions() );
4312
+		if (isset($this->_cap_restriction_generators[$context]) &&
4313
+				$this->_cap_restriction_generators[$context] instanceof EE_Restriction_Generator_Base &&
4314
+				! $this->_cap_restriction_generators[$context]->has_generated_cap_restrictions()) {
4315
+			$this->_cap_restrictions[$context] = array_merge($this->_cap_restrictions[$context], $this->_cap_restriction_generators[$context]->generate_restrictions());
4316 4316
 		}
4317 4317
 		//and make sure we've finalized the construction of each restriction
4318
-		foreach( $this->_cap_restrictions[ $context ] as $where_conditions_obj ) {
4319
-			$where_conditions_obj->_finalize_construct( $this );
4318
+		foreach ($this->_cap_restrictions[$context] as $where_conditions_obj) {
4319
+			$where_conditions_obj->_finalize_construct($this);
4320 4320
 		}
4321 4321
 
4322
-		return $this->_cap_restrictions[ $context ];
4322
+		return $this->_cap_restrictions[$context];
4323 4323
 	}
4324 4324
 
4325 4325
 	/**
4326 4326
 	 * Indicating whether or not this model thinks its a wp core model
4327 4327
 	 * @return boolean
4328 4328
 	 */
4329
-	public function is_wp_core_model(){
4329
+	public function is_wp_core_model() {
4330 4330
 		return $this->_wp_core_model;
4331 4331
 	}
4332 4332
 
@@ -4336,12 +4336,12 @@  discard block
 block discarded – undo
4336 4336
 	 * @param string $context one of EEM_Base::caps_ constants
4337 4337
 	 * @return EE_Default_Where_Conditions[] indexed by capability name
4338 4338
 	 */
4339
-	public function caps_missing( $context = EEM_Base::caps_read ) {
4339
+	public function caps_missing($context = EEM_Base::caps_read) {
4340 4340
 		$missing_caps = array();
4341
-		$cap_restrictions = $this->cap_restrictions( $context );
4342
-		foreach( $cap_restrictions as $cap => $restriction_if_no_cap ) {
4343
-			if( ! EE_Capabilities::instance()->current_user_can( $cap, $this->get_this_model_name() . '_model_applying_caps') ) {
4344
-				$missing_caps[ $cap ] = $restriction_if_no_cap;
4341
+		$cap_restrictions = $this->cap_restrictions($context);
4342
+		foreach ($cap_restrictions as $cap => $restriction_if_no_cap) {
4343
+			if ( ! EE_Capabilities::instance()->current_user_can($cap, $this->get_this_model_name().'_model_applying_caps')) {
4344
+				$missing_caps[$cap] = $restriction_if_no_cap;
4345 4345
 			}
4346 4346
 		}
4347 4347
 		return $missing_caps;
@@ -4353,7 +4353,7 @@  discard block
 block discarded – undo
4353 4353
 	 * one of 'read', 'edit', or 'delete'
4354 4354
 	 */
4355 4355
 	public function cap_contexts_to_cap_action_map() {
4356
-		return apply_filters( 'FHEE__EEM_Base__cap_contexts_to_cap_action_map', $this->_cap_contexts_to_cap_action_map, $this );
4356
+		return apply_filters('FHEE__EEM_Base__cap_contexts_to_cap_action_map', $this->_cap_contexts_to_cap_action_map, $this);
4357 4357
 	}
4358 4358
 
4359 4359
 
@@ -4364,19 +4364,19 @@  discard block
 block discarded – undo
4364 4364
 	 * @return string one of EEM_Base::cap_contexts_to_cap_action_map() values
4365 4365
 	 * @throws \EE_Error
4366 4366
 	 */
4367
-	public function cap_action_for_context( $context ) {
4367
+	public function cap_action_for_context($context) {
4368 4368
 		$mapping = $this->cap_contexts_to_cap_action_map();
4369
-		if( isset( $mapping[ $context ] ) ) {
4370
-			return $mapping[ $context ];
4369
+		if (isset($mapping[$context])) {
4370
+			return $mapping[$context];
4371 4371
 		}
4372
-		if( $action = apply_filters( 'FHEE__EEM_Base__cap_action_for_context', null, $this, $mapping, $context ) ) {
4372
+		if ($action = apply_filters('FHEE__EEM_Base__cap_action_for_context', null, $this, $mapping, $context)) {
4373 4373
 			return $action;
4374 4374
 		}
4375 4375
 		throw new EE_Error(
4376 4376
 			sprintf(
4377
-				__( 'Cannot find capability restrictions for context "%1$s", allowed values are:%2$s', 'event_espresso' ),
4377
+				__('Cannot find capability restrictions for context "%1$s", allowed values are:%2$s', 'event_espresso'),
4378 4378
 				$context,
4379
-				implode(',', array_keys( $this->cap_contexts_to_cap_action_map() ) )
4379
+				implode(',', array_keys($this->cap_contexts_to_cap_action_map()))
4380 4380
 			)
4381 4381
 		);
4382 4382
 
@@ -4387,7 +4387,7 @@  discard block
 block discarded – undo
4387 4387
 	 * @return array
4388 4388
 	 */
4389 4389
 	static public function valid_cap_contexts() {
4390
-		return apply_filters( 'FHEE__EEM_Base__valid_cap_contexts', array(
4390
+		return apply_filters('FHEE__EEM_Base__valid_cap_contexts', array(
4391 4391
 			self::caps_read,
4392 4392
 			self::caps_read_admin,
4393 4393
 			self::caps_edit,
@@ -4403,17 +4403,17 @@  discard block
 block discarded – undo
4403 4403
 	 * @return bool
4404 4404
 	 * @throws \EE_Error
4405 4405
 	 */
4406
-	static public function verify_is_valid_cap_context( $context ) {
4406
+	static public function verify_is_valid_cap_context($context) {
4407 4407
 		$valid_cap_contexts = EEM_Base::valid_cap_contexts();
4408
-		if( in_array( $context, $valid_cap_contexts ) ) {
4408
+		if (in_array($context, $valid_cap_contexts)) {
4409 4409
 			return true;
4410
-		}else{
4410
+		} else {
4411 4411
 			throw new EE_Error(
4412 4412
 				sprintf(
4413
-					__( 'Context "%1$s" passed into model "%2$s" is not a valid context. They are: %3$s', 'event_espresso' ),
4413
+					__('Context "%1$s" passed into model "%2$s" is not a valid context. They are: %3$s', 'event_espresso'),
4414 4414
 					$context,
4415
-					'EEM_Base' ,
4416
-					implode(',', $valid_cap_contexts )
4415
+					'EEM_Base',
4416
+					implode(',', $valid_cap_contexts)
4417 4417
 				)
4418 4418
 			);
4419 4419
 		}
Please login to merge, or discard this patch.
core/admin/EE_Admin.core.php 2 patches
Braces   +16 added lines, -8 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
 /**
3 5
  * Event Espresso
4 6
  *
@@ -220,8 +222,9 @@  discard block
 block discarded – undo
220 222
 	 */
221 223
 	public function remove_pages_from_nav_menu( $post_type ) {
222 224
 		//if this isn't the "pages" post type let's get out
223
-		if ( $post_type->name !== 'page' )
224
-			return $post_type;
225
+		if ( $post_type->name !== 'page' ) {
226
+					return $post_type;
227
+		}
225 228
 
226 229
 		$critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array();
227 230
 
@@ -296,8 +299,9 @@  discard block
 block discarded – undo
296 299
 	 * @return string  the (maybe) modified link
297 300
 	 */
298 301
 	public function modify_edit_post_link( $link, $id, $context ) {
299
-		if ( ! $post = get_post( $id ) )
300
-			return $link;
302
+		if ( ! $post = get_post( $id ) ) {
303
+					return $link;
304
+		}
301 305
 
302 306
 		if ( $post->post_type == 'espresso_attendees' ) {
303 307
 			$query_args = array(
@@ -337,7 +341,10 @@  discard block
 block discarded – undo
337 341
 		<div id="posttype-extra-nav-menu-pages" class="posttypediv">
338 342
 			<ul id="posttype-extra-nav-menu-pages-tabs" class="posttype-tabs add-menu-item-tabs">
339 343
 				<li <?php echo ( 'event-archives' == $current_tab ? ' class="tabs"' : '' ); ?>>
340
-					<a class="nav-tab-link" data-type="tabs-panel-posttype-extra-nav-menu-pages-event-archives" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg('extra-nav-menu-pages-tab', 'event-archives', remove_query_arg($removed_args))); ?>#tabs-panel-posttype-extra-nav-menu-pages-event-archives">
344
+					<a class="nav-tab-link" data-type="tabs-panel-posttype-extra-nav-menu-pages-event-archives" href="<?php if ( $nav_menu_selected_id ) {
345
+	echo esc_url(add_query_arg('extra-nav-menu-pages-tab', 'event-archives', remove_query_arg($removed_args)));
346
+}
347
+?>#tabs-panel-posttype-extra-nav-menu-pages-event-archives">
341 348
 						<?php _e( 'Event Archive Pages', 'event_espresso' ); ?>
342 349
 					</a>
343 350
 				</li>
@@ -870,8 +877,9 @@  discard block
 block discarded – undo
870 877
 	 */
871 878
 	public static function register_ee_admin_page( $page_basename, $page_path, $config = array() ) {
872 879
 		EE_Error::doing_it_wrong( __METHOD__, sprintf( __('Usage is deprecated.  Use EE_Register_Admin_Page::register() for registering the %s admin page.', 'event_espresso'), $page_basename), '4.3' );
873
-		if ( class_exists( 'EE_Register_Admin_Page' ) )
874
-			$config['page_path'] = $page_path;
880
+		if ( class_exists( 'EE_Register_Admin_Page' ) ) {
881
+					$config['page_path'] = $page_path;
882
+		}
875 883
 			EE_Register_Admin_Page::register( $page_basename, $config );
876 884
 	}
877 885
 
Please login to merge, or discard this patch.
Spacing   +174 added lines, -174 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	 */
48 48
 	public static function instance() {
49 49
 		// check if class object is instantiated
50
-		if (  ! self::$_instance instanceof EE_Admin ) {
50
+		if ( ! self::$_instance instanceof EE_Admin) {
51 51
 			self::$_instance = new self();
52 52
 		}
53 53
 		return self::$_instance;
@@ -62,25 +62,25 @@  discard block
 block discarded – undo
62 62
 		// define global EE_Admin constants
63 63
 		$this->_define_all_constants();
64 64
 		// set autoloaders for our admin page classes based on included path information
65
-		EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder( EE_ADMIN );
65
+		EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_ADMIN);
66 66
 		// admin hooks
67
-		add_filter( 'plugin_action_links', array( $this, 'filter_plugin_actions' ), 10, 2 );
67
+		add_filter('plugin_action_links', array($this, 'filter_plugin_actions'), 10, 2);
68 68
 		// load EE_Request_Handler early
69
-		add_action( 'AHEE__EE_System__core_loaded_and_ready', array( $this, 'get_request' ));
70
-		add_action( 'AHEE__EE_System__initialize_last', array( $this, 'init' ));
71
-		add_action( 'AHEE__EE_Admin_Page__route_admin_request', array( $this, 'route_admin_request' ), 100, 2 );
72
-		add_action( 'wp_loaded', array( $this, 'wp_loaded' ), 100 );
73
-		add_action( 'admin_init', array( $this, 'admin_init' ), 100 );
74
-		add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_scripts' ), 20 );
75
-		add_action( 'admin_notices', array( $this, 'display_admin_notices' ), 10 );
76
-		add_action( 'network_admin_notices', array( $this, 'display_admin_notices' ), 10 );
77
-		add_filter( 'pre_update_option', array( $this, 'check_for_invalid_datetime_formats' ), 100, 2 );
78
-		add_filter('admin_footer_text', array( $this, 'espresso_admin_footer' ));
69
+		add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'get_request'));
70
+		add_action('AHEE__EE_System__initialize_last', array($this, 'init'));
71
+		add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'route_admin_request'), 100, 2);
72
+		add_action('wp_loaded', array($this, 'wp_loaded'), 100);
73
+		add_action('admin_init', array($this, 'admin_init'), 100);
74
+		add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'), 20);
75
+		add_action('admin_notices', array($this, 'display_admin_notices'), 10);
76
+		add_action('network_admin_notices', array($this, 'display_admin_notices'), 10);
77
+		add_filter('pre_update_option', array($this, 'check_for_invalid_datetime_formats'), 100, 2);
78
+		add_filter('admin_footer_text', array($this, 'espresso_admin_footer'));
79 79
 
80 80
 		//reset Environment config (we only do this on admin page loads);
81 81
 		EE_Registry::instance()->CFG->environment->recheck_values();
82 82
 
83
-		do_action( 'AHEE__EE_Admin__loaded' );
83
+		do_action('AHEE__EE_Admin__loaded');
84 84
 	}
85 85
 
86 86
 
@@ -95,12 +95,12 @@  discard block
 block discarded – undo
95 95
 	 * @return void
96 96
 	 */
97 97
 	private function _define_all_constants() {
98
-		define( 'EE_ADMIN_URL', EE_PLUGIN_DIR_URL . 'core/admin/' );
99
-		define( 'EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL . 'admin_pages/' );
100
-		define( 'EE_ADMIN_TEMPLATE', EE_ADMIN . 'templates' . DS );
101
-		define( 'WP_ADMIN_PATH', ABSPATH . 'wp-admin/' );
102
-		define( 'WP_AJAX_URL', admin_url( 'admin-ajax.php' ));
103
-		define( 'JQPLOT_URL', EE_GLOBAL_ASSETS_URL . 'scripts/jqplot/' );
98
+		define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL.'core/admin/');
99
+		define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL.'admin_pages/');
100
+		define('EE_ADMIN_TEMPLATE', EE_ADMIN.'templates'.DS);
101
+		define('WP_ADMIN_PATH', ABSPATH.'wp-admin/');
102
+		define('WP_AJAX_URL', admin_url('admin-ajax.php'));
103
+		define('JQPLOT_URL', EE_GLOBAL_ASSETS_URL.'scripts/jqplot/');
104 104
 	}
105 105
 
106 106
 
@@ -113,23 +113,23 @@  discard block
 block discarded – undo
113 113
 	 * @param 	string 	$plugin
114 114
 	 * @return 	array
115 115
 	 */
116
-	public function filter_plugin_actions( $links, $plugin ) {
116
+	public function filter_plugin_actions($links, $plugin) {
117 117
 		// set $main_file in stone
118 118
 		static $main_file;
119 119
 		// if $main_file is not set yet
120
-		if ( ! $main_file ) {
121
-			$main_file = plugin_basename( EVENT_ESPRESSO_MAIN_FILE );
120
+		if ( ! $main_file) {
121
+			$main_file = plugin_basename(EVENT_ESPRESSO_MAIN_FILE);
122 122
 		}
123
-		 if ( $plugin == $main_file ) {
123
+		 if ($plugin == $main_file) {
124 124
 		 	// compare current plugin to this one
125
-			if ( EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance ) {
126
-				$maintenance_link = '<a href="admin.php?page=espresso_maintenance_settings" title="Event Espresso is in maintenance mode.  Click this link to learn why.">' . __('Maintenance Mode Active', 'event_espresso' ) . '</a>';
127
-				array_unshift( $links, $maintenance_link );
125
+			if (EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance) {
126
+				$maintenance_link = '<a href="admin.php?page=espresso_maintenance_settings" title="Event Espresso is in maintenance mode.  Click this link to learn why.">'.__('Maintenance Mode Active', 'event_espresso').'</a>';
127
+				array_unshift($links, $maintenance_link);
128 128
 			} else {
129
-				$org_settings_link = '<a href="admin.php?page=espresso_general_settings">' . __( 'Settings', 'event_espresso' ) . '</a>';
130
-				$events_link = '<a href="admin.php?page=espresso_events">' . __( 'Events', 'event_espresso' ) . '</a>';
129
+				$org_settings_link = '<a href="admin.php?page=espresso_general_settings">'.__('Settings', 'event_espresso').'</a>';
130
+				$events_link = '<a href="admin.php?page=espresso_events">'.__('Events', 'event_espresso').'</a>';
131 131
 				// add before other links
132
-				array_unshift( $links, $org_settings_link, $events_link );
132
+				array_unshift($links, $org_settings_link, $events_link);
133 133
 			}
134 134
 		}
135 135
 		return $links;
@@ -144,8 +144,8 @@  discard block
 block discarded – undo
144 144
 	 *	@return void
145 145
 	 */
146 146
 	public function get_request() {
147
-		EE_Registry::instance()->load_core( 'Request_Handler' );
148
-		EE_Registry::instance()->load_core( 'CPT_Strategy' );
147
+		EE_Registry::instance()->load_core('Request_Handler');
148
+		EE_Registry::instance()->load_core('CPT_Strategy');
149 149
 	}
150 150
 
151 151
 
@@ -157,11 +157,11 @@  discard block
 block discarded – undo
157 157
 	 * @param array $admin_page_folder_names
158 158
 	 * @return array
159 159
 	 */
160
-	public function hide_admin_pages_except_maintenance_mode( $admin_page_folder_names = array() ){
160
+	public function hide_admin_pages_except_maintenance_mode($admin_page_folder_names = array()) {
161 161
 		return array(
162
-			'maintenance' => EE_ADMIN_PAGES . 'maintenance' . DS,
163
-			'about' => EE_ADMIN_PAGES . 'about' . DS,
164
-			'support' => EE_ADMIN_PAGES . 'support' . DS
162
+			'maintenance' => EE_ADMIN_PAGES.'maintenance'.DS,
163
+			'about' => EE_ADMIN_PAGES.'about'.DS,
164
+			'support' => EE_ADMIN_PAGES.'support'.DS
165 165
 		);
166 166
 	}
167 167
 
@@ -176,36 +176,36 @@  discard block
 block discarded – undo
176 176
 	public function init() {
177 177
 
178 178
 		//only enable most of the EE_Admin IF we're not in full maintenance mode
179
-		if ( EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance ){
179
+		if (EE_Maintenance_Mode::instance()->level() != EE_Maintenance_Mode::level_2_complete_maintenance) {
180 180
 			//ok so we want to enable the entire admin
181
-			add_action( 'wp_ajax_dismiss_ee_nag_notice', array( $this, 'dismiss_ee_nag_notice_callback' ));
182
-			add_action( 'save_post', array( 'EE_Admin', 'parse_post_content_on_save' ), 100, 2 );
183
-			add_action( 'update_option', array( $this, 'reset_page_for_posts_on_change' ), 100, 3 );
184
-			add_filter( 'content_save_pre', array( $this, 'its_eSpresso' ), 10, 1 );
185
-			add_action( 'admin_notices', array( $this, 'get_persistent_admin_notices' ), 9 );
186
-			add_action( 'network_admin_notices', array( $this, 'get_persistent_admin_notices' ), 9 );
181
+			add_action('wp_ajax_dismiss_ee_nag_notice', array($this, 'dismiss_ee_nag_notice_callback'));
182
+			add_action('save_post', array('EE_Admin', 'parse_post_content_on_save'), 100, 2);
183
+			add_action('update_option', array($this, 'reset_page_for_posts_on_change'), 100, 3);
184
+			add_filter('content_save_pre', array($this, 'its_eSpresso'), 10, 1);
185
+			add_action('admin_notices', array($this, 'get_persistent_admin_notices'), 9);
186
+			add_action('network_admin_notices', array($this, 'get_persistent_admin_notices'), 9);
187 187
 			//at a glance dashboard widget
188
-			add_filter( 'dashboard_glance_items', array( $this, 'dashboard_glance_items'), 10 );
188
+			add_filter('dashboard_glance_items', array($this, 'dashboard_glance_items'), 10);
189 189
 			//filter for get_edit_post_link used on comments for custom post types
190
-			add_filter('get_edit_post_link', array( $this, 'modify_edit_post_link' ), 10, 3 );
190
+			add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 3);
191 191
 		}
192 192
 
193 193
 		// run the admin page factory but ONLY if we are doing an ee admin ajax request
194
-		if ( !defined('DOING_AJAX') || EE_ADMIN_AJAX ) {
194
+		if ( ! defined('DOING_AJAX') || EE_ADMIN_AJAX) {
195 195
 			try {
196 196
 				//this loads the controller for the admin pages which will setup routing etc
197
-				EE_Registry::instance()->load_core( 'Admin_Page_Loader' );
198
-			} catch ( EE_Error $e ) {
197
+				EE_Registry::instance()->load_core('Admin_Page_Loader');
198
+			} catch (EE_Error $e) {
199 199
 				$e->get_error();
200 200
 			}
201 201
 		}
202 202
 
203 203
 		//make sure our CPTs and custom taxonomy metaboxes get shown for first time users
204
-		add_action('admin_head', array($this, 'enable_hidden_ee_nav_menu_metaboxes' ), 10 );
205
-		add_action('admin_head', array( $this, 'register_custom_nav_menu_boxes' ), 10 );
204
+		add_action('admin_head', array($this, 'enable_hidden_ee_nav_menu_metaboxes'), 10);
205
+		add_action('admin_head', array($this, 'register_custom_nav_menu_boxes'), 10);
206 206
 
207 207
 		//exclude EE critical pages from all nav menus and wp_list_pages
208
-		add_filter('nav_menu_meta_box_object', array( $this, 'remove_pages_from_nav_menu'), 10 );
208
+		add_filter('nav_menu_meta_box_object', array($this, 'remove_pages_from_nav_menu'), 10);
209 209
 	}
210 210
 
211 211
 
@@ -218,9 +218,9 @@  discard block
 block discarded – undo
218 218
 	 * @param  object $post_type WP post type object
219 219
 	 * @return object            WP post type object
220 220
 	 */
221
-	public function remove_pages_from_nav_menu( $post_type ) {
221
+	public function remove_pages_from_nav_menu($post_type) {
222 222
 		//if this isn't the "pages" post type let's get out
223
-		if ( $post_type->name !== 'page' )
223
+		if ($post_type->name !== 'page')
224 224
 			return $post_type;
225 225
 
226 226
 		$critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array();
@@ -240,28 +240,28 @@  discard block
 block discarded – undo
240 240
 	 */
241 241
 	public function enable_hidden_ee_nav_menu_metaboxes() {
242 242
 		global $wp_meta_boxes, $pagenow;
243
-		if ( ! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php' ) {
243
+		if ( ! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') {
244 244
 			return;
245 245
 		}
246 246
 		$user = wp_get_current_user();
247 247
 		//has this been done yet?
248
-		if ( get_user_option( 'ee_nav_menu_initialized', $user->ID ) ) {
248
+		if (get_user_option('ee_nav_menu_initialized', $user->ID)) {
249 249
 			return;
250 250
 		}
251 251
 
252
-		$hidden_meta_boxes = get_user_option( 'metaboxhidden_nav-menus', $user->ID );
253
-		$initial_meta_boxes = apply_filters( 'FHEE__EE_Admin__enable_hidden_ee_nav_menu_boxes__initial_meta_boxes', array( 'nav-menu-theme-locations', 'add-page', 'add-custom-links', 'add-category', 'add-espresso_events', 'add-espresso_venues', 'add-espresso_event_categories', 'add-espresso_venue_categories', 'add-post-type-post', 'add-post-type-page' ) );
252
+		$hidden_meta_boxes = get_user_option('metaboxhidden_nav-menus', $user->ID);
253
+		$initial_meta_boxes = apply_filters('FHEE__EE_Admin__enable_hidden_ee_nav_menu_boxes__initial_meta_boxes', array('nav-menu-theme-locations', 'add-page', 'add-custom-links', 'add-category', 'add-espresso_events', 'add-espresso_venues', 'add-espresso_event_categories', 'add-espresso_venue_categories', 'add-post-type-post', 'add-post-type-page'));
254 254
 
255
-		if ( is_array( $hidden_meta_boxes ) ) {
256
-			foreach ( $hidden_meta_boxes as $key => $meta_box_id ) {
257
-				if ( in_array( $meta_box_id, $initial_meta_boxes ) ) {
258
-					unset( $hidden_meta_boxes[ $key ] );
255
+		if (is_array($hidden_meta_boxes)) {
256
+			foreach ($hidden_meta_boxes as $key => $meta_box_id) {
257
+				if (in_array($meta_box_id, $initial_meta_boxes)) {
258
+					unset($hidden_meta_boxes[$key]);
259 259
 				}
260 260
 			}
261 261
 		}
262 262
 
263
-		update_user_option( $user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true );
264
-		update_user_option( $user->ID, 'ee_nav_menu_initialized', 1, true );
263
+		update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true);
264
+		update_user_option($user->ID, 'ee_nav_menu_initialized', 1, true);
265 265
 	}
266 266
 
267 267
 
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 	 * @return void
281 281
 	 */
282 282
 	public function register_custom_nav_menu_boxes() {
283
-		add_meta_box( 'add-extra-nav-menu-pages', __('Event Espresso Pages', 'event_espresso'), array( $this, 'ee_cpt_archive_pages' ), 'nav-menus', 'side', 'core' );
283
+		add_meta_box('add-extra-nav-menu-pages', __('Event Espresso Pages', 'event_espresso'), array($this, 'ee_cpt_archive_pages'), 'nav-menus', 'side', 'core');
284 284
 	}
285 285
 
286 286
 
@@ -297,17 +297,17 @@  discard block
 block discarded – undo
297 297
 	 *
298 298
 	 * @return string  the (maybe) modified link
299 299
 	 */
300
-	public function modify_edit_post_link( $link, $id, $context ) {
301
-		if ( ! $post = get_post( $id ) )
300
+	public function modify_edit_post_link($link, $id, $context) {
301
+		if ( ! $post = get_post($id))
302 302
 			return $link;
303 303
 
304
-		if ( $post->post_type == 'espresso_attendees' ) {
304
+		if ($post->post_type == 'espresso_attendees') {
305 305
 			$query_args = array(
306 306
 				'action' => 'edit_attendee',
307 307
 				'post' => $id
308 308
 				);
309 309
 			EE_Registry::instance()->load_helper('URL');
310
-			return EEH_URL::add_query_args_and_nonce( $query_args, admin_url('admin.php?page=espresso_registrations') );
310
+			return EEH_URL::add_query_args_and_nonce($query_args, admin_url('admin.php?page=espresso_registrations'));
311 311
 		}
312 312
 		return $link;
313 313
 	}
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 		global $nav_menu_selected_id;
320 320
 
321 321
 		$db_fields = false;
322
-		$walker = new Walker_Nav_Menu_Checklist( $db_fields );
322
+		$walker = new Walker_Nav_Menu_Checklist($db_fields);
323 323
 		$current_tab = 'event-archives';
324 324
 
325 325
 		/*if ( ! empty( $_REQUEST['quick-search-posttype-' . $post_type_name] ) ) {
@@ -338,9 +338,9 @@  discard block
 block discarded – undo
338 338
 		?>
339 339
 		<div id="posttype-extra-nav-menu-pages" class="posttypediv">
340 340
 			<ul id="posttype-extra-nav-menu-pages-tabs" class="posttype-tabs add-menu-item-tabs">
341
-				<li <?php echo ( 'event-archives' == $current_tab ? ' class="tabs"' : '' ); ?>>
342
-					<a class="nav-tab-link" data-type="tabs-panel-posttype-extra-nav-menu-pages-event-archives" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg('extra-nav-menu-pages-tab', 'event-archives', remove_query_arg($removed_args))); ?>#tabs-panel-posttype-extra-nav-menu-pages-event-archives">
343
-						<?php _e( 'Event Archive Pages', 'event_espresso' ); ?>
341
+				<li <?php echo ('event-archives' == $current_tab ? ' class="tabs"' : ''); ?>>
342
+					<a class="nav-tab-link" data-type="tabs-panel-posttype-extra-nav-menu-pages-event-archives" href="<?php if ($nav_menu_selected_id) echo esc_url(add_query_arg('extra-nav-menu-pages-tab', 'event-archives', remove_query_arg($removed_args))); ?>#tabs-panel-posttype-extra-nav-menu-pages-event-archives">
343
+						<?php _e('Event Archive Pages', 'event_espresso'); ?>
344 344
 					</a>
345 345
 				</li>
346 346
 			<?php /* // temporarily removing but leaving skeleton in place in case we ever decide to add more tabs.
@@ -358,13 +358,13 @@  discard block
 block discarded – undo
358 358
  			<?php */ ?>
359 359
 
360 360
 			<div id="tabs-panel-posttype-extra-nav-menu-pages-event-archives" class="tabs-panel <?php
361
-			echo ( 'event-archives' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' );
361
+			echo ('event-archives' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive');
362 362
 			?>">
363 363
 				<ul id="extra-nav-menu-pageschecklist-event-archives" class="categorychecklist form-no-clear">
364 364
 					<?php
365 365
 					$pages = $this->_get_extra_nav_menu_pages_items();
366 366
 					$args['walker'] = $walker;
367
-					echo walk_nav_menu_tree( array_map( array( $this, '_setup_extra_nav_menu_pages_items' ), $pages), 0, (object) $args );
367
+					echo walk_nav_menu_tree(array_map(array($this, '_setup_extra_nav_menu_pages_items'), $pages), 0, (object) $args);
368 368
 					?>
369 369
 				</ul>
370 370
 			</div><!-- /.tabs-panel -->
@@ -372,18 +372,18 @@  discard block
 block discarded – undo
372 372
 			<p class="button-controls">
373 373
 				<span class="list-controls">
374 374
 					<a href="<?php
375
-						echo esc_url( add_query_arg(
375
+						echo esc_url(add_query_arg(
376 376
 							array(
377 377
 								'extra-nav-menu-pages-tab' => 'event-archives',
378 378
 								'selectall' => 1,
379 379
 							),
380
-							remove_query_arg( $removed_args )
380
+							remove_query_arg($removed_args)
381 381
 						));
382 382
 					?>#posttype-extra-nav-menu-pages>" class="select-all"><?php _e('Select All'); ?></a>
383 383
 				</span>
384 384
 
385 385
 				<span class="add-to-menu">
386
-					<input type="submit"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e( __( 'Add to Menu' ) ); ?>" name="add-post-type-menu-item" id="<?php esc_attr_e( 'submit-posttype-extra-nav-menu-pages' ); ?>" />
386
+					<input type="submit"<?php wp_nav_menu_disabled_check($nav_menu_selected_id); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e(__('Add to Menu')); ?>" name="add-post-type-menu-item" id="<?php esc_attr_e('submit-posttype-extra-nav-menu-pages'); ?>" />
387 387
 					<span class="spinner"></span>
388 388
 				</span>
389 389
 			</p>
@@ -404,10 +404,10 @@  discard block
 block discarded – undo
404 404
 	private function _get_extra_nav_menu_pages_items() {
405 405
 		$menuitems[] = array(
406 406
 			'title' => __('Event List', 'event_espresso'),
407
-			'url' => get_post_type_archive_link( 'espresso_events' ),
407
+			'url' => get_post_type_archive_link('espresso_events'),
408 408
 			'description' => __('Archive page for all events.', 'event_espresso')
409 409
 		);
410
-		return apply_filters( 'FHEE__EE_Admin__get_extra_nav_menu_pages_items', $menuitems );
410
+		return apply_filters('FHEE__EE_Admin__get_extra_nav_menu_pages_items', $menuitems);
411 411
 	}
412 412
 
413 413
 
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
 	 * @param $menuitem
420 420
 	 * @return stdClass
421 421
 	 */
422
-	private function _setup_extra_nav_menu_pages_items( $menuitem ) {
422
+	private function _setup_extra_nav_menu_pages_items($menuitem) {
423 423
 		$menu_item = new stdClass();
424 424
 		$keys = array(
425 425
 			'ID' => 0,
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
 			'xfn' => ''
440 440
 			);
441 441
 
442
-		foreach ( $keys as $key => $value) {
442
+		foreach ($keys as $key => $value) {
443 443
 			$menu_item->$key = isset($menuitem[$key]) ? $menuitem[$key] : $value;
444 444
 		}
445 445
 		return $menu_item;
@@ -479,10 +479,10 @@  discard block
 block discarded – undo
479 479
 		 * - check if doing post processing of one of EE CPTs
480 480
 		 * - instantiate the corresponding EE CPT model for the post_type being processed.
481 481
 		 */
482
-		if ( isset( $_POST['action'] ) && $_POST['action'] == 'editpost' ) {
483
-			if ( isset( $_POST['post_type'] ) ) {
484
-				EE_Registry::instance()->load_core( 'Register_CPTs' );
485
-				EE_Register_CPTs::instantiate_cpt_models( $_POST['post_type'] );
482
+		if (isset($_POST['action']) && $_POST['action'] == 'editpost') {
483
+			if (isset($_POST['post_type'])) {
484
+				EE_Registry::instance()->load_core('Register_CPTs');
485
+				EE_Register_CPTs::instantiate_cpt_models($_POST['post_type']);
486 486
 			}
487 487
 		}
488 488
 
@@ -492,8 +492,8 @@  discard block
 block discarded – undo
492 492
 		 * 'options-reading.php' core WordPress admin settings page.  This is for user-proofing.
493 493
 		 */
494 494
 		global $pagenow;
495
-		if ( $pagenow == 'options-reading.php' ) {
496
-			add_filter( 'wp_dropdown_pages', array( $this, 'modify_dropdown_pages' ) );
495
+		if ($pagenow == 'options-reading.php') {
496
+			add_filter('wp_dropdown_pages', array($this, 'modify_dropdown_pages'));
497 497
 		}
498 498
 
499 499
 	}
@@ -505,25 +505,25 @@  discard block
 block discarded – undo
505 505
 	 * @param string $output  Current output.
506 506
 	 * @return string
507 507
 	 */
508
-	public function modify_dropdown_pages( $output ) {
508
+	public function modify_dropdown_pages($output) {
509 509
 		//get critical pages
510 510
 		$critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array();
511 511
 
512 512
 		//split current output by line break for easier parsing.
513
-		$split_output = explode( "\n", $output );
513
+		$split_output = explode("\n", $output);
514 514
 
515 515
 		//loop through to remove any critical pages from the array.
516
-		foreach ( $critical_pages as $page_id ) {
517
-			$needle = 'value="' . $page_id . '"';
518
-			foreach( $split_output as $key => $haystack ) {
519
-				if( strpos( $haystack, $needle ) !== false ) {
520
-					unset( $split_output[$key] );
516
+		foreach ($critical_pages as $page_id) {
517
+			$needle = 'value="'.$page_id.'"';
518
+			foreach ($split_output as $key => $haystack) {
519
+				if (strpos($haystack, $needle) !== false) {
520
+					unset($split_output[$key]);
521 521
 				}
522 522
 			}
523 523
 		}
524 524
 
525 525
 		//replace output with the new contents
526
-		$output = implode( "\n", $split_output );
526
+		$output = implode("\n", $split_output);
527 527
 
528 528
 		return $output;
529 529
 	}
@@ -539,37 +539,37 @@  discard block
 block discarded – undo
539 539
 	public function enqueue_admin_scripts() {
540 540
 		// this javascript is loaded on every admin page to catch any injections ee needs to add to wp run js.
541 541
 		// Note: the intention of this script is to only do TARGETED injections.  I.E, only injecting on certain script calls.
542
-		wp_enqueue_script('ee-inject-wp', EE_ADMIN_URL . 'assets/ee-cpt-wp-injects.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE);
542
+		wp_enqueue_script('ee-inject-wp', EE_ADMIN_URL.'assets/ee-cpt-wp-injects.js', array('jquery'), EVENT_ESPRESSO_VERSION, TRUE);
543 543
 		// register cookie script for future dependencies
544
-		wp_register_script('jquery-cookie', EE_THIRD_PARTY_URL . 'joyride/jquery.cookie.js', array('jquery'), '2.1', TRUE );
544
+		wp_register_script('jquery-cookie', EE_THIRD_PARTY_URL.'joyride/jquery.cookie.js', array('jquery'), '2.1', TRUE);
545 545
 		// jquery_validate loading is turned OFF by default, but prior to the admin_enqueue_scripts hook, can be turned back on again via:  add_filter( 'FHEE_load_jquery_validate', '__return_true' );
546
-		if ( apply_filters( 'FHEE_load_jquery_validate', FALSE ) ) {
546
+		if (apply_filters('FHEE_load_jquery_validate', FALSE)) {
547 547
 			// register jQuery Validate
548
-			wp_register_script('jquery-validate', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.validate.min.js', array('jquery'), '1.11.1', TRUE);
548
+			wp_register_script('jquery-validate', EE_GLOBAL_ASSETS_URL.'scripts/jquery.validate.min.js', array('jquery'), '1.11.1', TRUE);
549 549
 		}
550 550
 		//joyride is turned OFF by default, but prior to the admin_enqueue_scripts hook, can be turned back on again vai: add_filter('FHEE_load_joyride', '__return_true' );
551
-		if ( apply_filters( 'FHEE_load_joyride', FALSE ) ) {
551
+		if (apply_filters('FHEE_load_joyride', FALSE)) {
552 552
 			//joyride style
553
-			wp_register_style('joyride-css', EE_THIRD_PARTY_URL . 'joyride/joyride-2.1.css', array(), '2.1');
554
-			wp_register_style('ee-joyride-css', EE_GLOBAL_ASSETS_URL . 'css/ee-joyride-styles.css', array('joyride-css'), EVENT_ESPRESSO_VERSION );
555
-			wp_register_script('joyride-modernizr', EE_THIRD_PARTY_URL . 'joyride/modernizr.mq.js', array(), '2.1', TRUE );
553
+			wp_register_style('joyride-css', EE_THIRD_PARTY_URL.'joyride/joyride-2.1.css', array(), '2.1');
554
+			wp_register_style('ee-joyride-css', EE_GLOBAL_ASSETS_URL.'css/ee-joyride-styles.css', array('joyride-css'), EVENT_ESPRESSO_VERSION);
555
+			wp_register_script('joyride-modernizr', EE_THIRD_PARTY_URL.'joyride/modernizr.mq.js', array(), '2.1', TRUE);
556 556
 			//joyride JS
557
-			wp_register_script('jquery-joyride', EE_THIRD_PARTY_URL . 'joyride/jquery.joyride-2.1.js', array('jquery-cookie', 'joyride-modernizr'), '2.1', TRUE );
557
+			wp_register_script('jquery-joyride', EE_THIRD_PARTY_URL.'joyride/jquery.joyride-2.1.js', array('jquery-cookie', 'joyride-modernizr'), '2.1', TRUE);
558 558
 			// wanna go for a joyride?
559 559
 			wp_enqueue_style('ee-joyride-css');
560 560
 			wp_enqueue_script('jquery-joyride');
561 561
 		}
562 562
 		//qtip is turned OFF by default, but prior to the admin_enqueue_scripts hook, can be turned back on again via: add_filter('FHEE_load_qtips', '__return_true' );
563
-		if ( apply_filters( 'FHEE_load_qtip', FALSE ) ) {
563
+		if (apply_filters('FHEE_load_qtip', FALSE)) {
564 564
 			EE_Registry::instance()->load_helper('Qtip_Loader');
565 565
 			EEH_Qtip_Loader::instance()->register_and_enqueue();
566 566
 		}
567 567
 		//accounting.js library
568 568
 		// @link http://josscrowcroft.github.io/accounting.js/
569
-		if ( apply_filters( 'FHEE_load_accounting_js', FALSE ) ) {
570
-			wp_register_script( 'ee-accounting', EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', array('ee-accounting-core'), EVENT_ESPRESSO_VERSION, TRUE );
571
-			wp_register_script( 'ee-accounting-core', EE_THIRD_PARTY_URL . 'accounting/accounting.js', array('underscore'), '0.3.2', TRUE );
572
-			wp_enqueue_script( 'ee-accounting' );
569
+		if (apply_filters('FHEE_load_accounting_js', FALSE)) {
570
+			wp_register_script('ee-accounting', EE_GLOBAL_ASSETS_URL.'scripts/ee-accounting-config.js', array('ee-accounting-core'), EVENT_ESPRESSO_VERSION, TRUE);
571
+			wp_register_script('ee-accounting-core', EE_THIRD_PARTY_URL.'accounting/accounting.js', array('underscore'), '0.3.2', TRUE);
572
+			wp_enqueue_script('ee-accounting');
573 573
 			// array of settings to get converted to JSON array via wp_localize_script
574 574
 			$currency_config = array(
575 575
 				'currency' => array(
@@ -616,11 +616,11 @@  discard block
 block discarded – undo
616 616
 	public function get_persistent_admin_notices() {
617 617
 		// http://www.example.com/wp-admin/admin.php?page=espresso_general_settings&action=critical_pages&critical_pages_nonce=2831ce0f30
618 618
 		$args = array(
619
-			'page' => EE_Registry::instance()->REQ->is_set( 'page' ) ? EE_Registry::instance()->REQ->get( 'page' ) : '',
620
-			'action' => EE_Registry::instance()->REQ->is_set( 'action' ) ? EE_Registry::instance()->REQ->get( 'action' ) : '',
619
+			'page' => EE_Registry::instance()->REQ->is_set('page') ? EE_Registry::instance()->REQ->get('page') : '',
620
+			'action' => EE_Registry::instance()->REQ->is_set('action') ? EE_Registry::instance()->REQ->get('action') : '',
621 621
 		);
622
-		$return_url = EE_Admin_Page::add_query_args_and_nonce( $args, EE_ADMIN_URL );
623
-		echo EE_Error::get_persistent_admin_notices( $return_url );
622
+		$return_url = EE_Admin_Page::add_query_args_and_nonce($args, EE_ADMIN_URL);
623
+		echo EE_Error::get_persistent_admin_notices($return_url);
624 624
 	}
625 625
 
626 626
 
@@ -641,26 +641,26 @@  discard block
 block discarded – undo
641 641
 	 * @param $elements
642 642
 	 * @return array
643 643
 	 */
644
-	public function dashboard_glance_items( $elements ) {
644
+	public function dashboard_glance_items($elements) {
645 645
 		$events = EEM_Event::instance()->count();
646
-		$items['events']['url'] = EE_Admin_Page::add_query_args_and_nonce( array('page' => 'espresso_events'), admin_url('admin.php') );
647
-		$items['events']['text'] = sprintf( _n( '%s Event', '%s Events', $events ), number_format_i18n( $events ) );
646
+		$items['events']['url'] = EE_Admin_Page::add_query_args_and_nonce(array('page' => 'espresso_events'), admin_url('admin.php'));
647
+		$items['events']['text'] = sprintf(_n('%s Event', '%s Events', $events), number_format_i18n($events));
648 648
 		$items['events']['title'] = __('Click to view all Events', 'event_espresso');
649 649
 		$registrations = EEM_Registration::instance()->count(
650 650
 			array(
651 651
 				array(
652
-					'STS_ID' => array( '!=', EEM_Registration::status_id_incomplete )
652
+					'STS_ID' => array('!=', EEM_Registration::status_id_incomplete)
653 653
 				)
654 654
 			)
655 655
 		);
656
-		$items['registrations']['url'] = EE_Admin_Page::add_query_args_and_nonce( array('page' => 'espresso_registrations' ), admin_url('admin.php') );
657
-		$items['registrations']['text'] = sprintf( _n( '%s Registration', '%s Registrations', $registrations ), number_format_i18n($registrations) );
656
+		$items['registrations']['url'] = EE_Admin_Page::add_query_args_and_nonce(array('page' => 'espresso_registrations'), admin_url('admin.php'));
657
+		$items['registrations']['text'] = sprintf(_n('%s Registration', '%s Registrations', $registrations), number_format_i18n($registrations));
658 658
 		$items['registrations']['title'] = __('Click to view all registrations', 'event_espresso');
659 659
 
660
-		$items = apply_filters( 'FHEE__EE_Admin__dashboard_glance_items__items', $items );
660
+		$items = apply_filters('FHEE__EE_Admin__dashboard_glance_items__items', $items);
661 661
 
662
-		foreach ( $items as $type => $item_properties ) {
663
-			$elements[] = sprintf( '<a class="ee-dashboard-link-' . $type . '" href="%s" title="%s">%s</a>', $item_properties['url'], $item_properties['title'], $item_properties['text'] );
662
+		foreach ($items as $type => $item_properties) {
663
+			$elements[] = sprintf('<a class="ee-dashboard-link-'.$type.'" href="%s" title="%s">%s</a>', $item_properties['url'], $item_properties['title'], $item_properties['text']);
664 664
 		}
665 665
 		return $elements;
666 666
 	}
@@ -679,63 +679,63 @@  discard block
 block discarded – undo
679 679
 	 * @param $post
680 680
 	 * @return    void
681 681
 	 */
682
-	public static function parse_post_content_on_save( $post_ID, $post ) {
682
+	public static function parse_post_content_on_save($post_ID, $post) {
683 683
 		// default post types
684
-		$post_types = array( 'post' => 0, 'page' => 1 );
684
+		$post_types = array('post' => 0, 'page' => 1);
685 685
 		// add CPTs
686 686
 		$CPTs = EE_Register_CPTs::get_CPTs();
687
-		$post_types = array_merge( $post_types, $CPTs );
687
+		$post_types = array_merge($post_types, $CPTs);
688 688
 		// for default or CPT posts...
689
-		if ( isset( $post_types[ $post->post_type ] )) {
689
+		if (isset($post_types[$post->post_type])) {
690 690
 			// post on frontpage ?
691 691
 			$page_for_posts = EE_Config::get_page_for_posts();
692 692
 			$maybe_remove_from_posts = array();
693 693
 			// critical page shortcodes that we do NOT want added to the Posts page (blog)
694 694
 			$critical_shortcodes = EE_Registry::instance()->CFG->core->get_critical_pages_shortcodes_array();
695 695
 			// array of shortcodes indexed by post name
696
-			EE_Registry::instance()->CFG->core->post_shortcodes = isset( EE_Registry::instance()->CFG->core->post_shortcodes ) ? EE_Registry::instance()->CFG->core->post_shortcodes : array();
696
+			EE_Registry::instance()->CFG->core->post_shortcodes = isset(EE_Registry::instance()->CFG->core->post_shortcodes) ? EE_Registry::instance()->CFG->core->post_shortcodes : array();
697 697
 			// whether to proceed with update, if an entry already exists for this post, then we want to update
698
-			$update_post_shortcodes = isset( EE_Registry::instance()->CFG->core->post_shortcodes[ $post->post_name ] ) ? true : false;
698
+			$update_post_shortcodes = isset(EE_Registry::instance()->CFG->core->post_shortcodes[$post->post_name]) ? true : false;
699 699
 			// empty both arrays
700
-			EE_Registry::instance()->CFG->core->post_shortcodes[ $post->post_name ] = array();
700
+			EE_Registry::instance()->CFG->core->post_shortcodes[$post->post_name] = array();
701 701
 			// check that posts page is already being tracked
702
-			if ( ! isset( EE_Registry::instance()->CFG->core->post_shortcodes[ $page_for_posts ] ) ) {
702
+			if ( ! isset(EE_Registry::instance()->CFG->core->post_shortcodes[$page_for_posts])) {
703 703
 				// if not, then ensure that it is properly added
704
-				EE_Registry::instance()->CFG->core->post_shortcodes[ $page_for_posts ] = array();
704
+				EE_Registry::instance()->CFG->core->post_shortcodes[$page_for_posts] = array();
705 705
 			}
706 706
 			// loop thru shortcodes
707
-			foreach ( EE_Registry::instance()->shortcodes as $EES_Shortcode => $shortcode_dir ) {
707
+			foreach (EE_Registry::instance()->shortcodes as $EES_Shortcode => $shortcode_dir) {
708 708
 				// convert to UPPERCASE to get actual shortcode
709
-				$EES_Shortcode = strtoupper( $EES_Shortcode );
709
+				$EES_Shortcode = strtoupper($EES_Shortcode);
710 710
 				// is the shortcode in the post_content ?
711
-				if ( strpos( $post->post_content, $EES_Shortcode ) !== FALSE ) {
711
+				if (strpos($post->post_content, $EES_Shortcode) !== FALSE) {
712 712
 					// map shortcode to post names and post IDs
713
-					EE_Registry::instance()->CFG->core->post_shortcodes[ $post->post_name ][ $EES_Shortcode ] = $post_ID;
713
+					EE_Registry::instance()->CFG->core->post_shortcodes[$post->post_name][$EES_Shortcode] = $post_ID;
714 714
 					// if the shortcode is NOT one of the critical page shortcodes like ESPRESSO_TXN_PAGE
715
-					if ( ! in_array( $EES_Shortcode, $critical_shortcodes )) {
715
+					if ( ! in_array($EES_Shortcode, $critical_shortcodes)) {
716 716
 						// add shortcode to "Posts page" tracking
717
-						EE_Registry::instance()->CFG->core->post_shortcodes[ $page_for_posts ][ $EES_Shortcode ] = $post_ID;
717
+						EE_Registry::instance()->CFG->core->post_shortcodes[$page_for_posts][$EES_Shortcode] = $post_ID;
718 718
 					}
719 719
 					$update_post_shortcodes = TRUE;
720
-					unset( $maybe_remove_from_posts[ $EES_Shortcode ] );
720
+					unset($maybe_remove_from_posts[$EES_Shortcode]);
721 721
 				} else {
722
-					$maybe_remove_from_posts[ $EES_Shortcode ] = $post_ID;
722
+					$maybe_remove_from_posts[$EES_Shortcode] = $post_ID;
723 723
 				}
724 724
 			}
725
-			if ( $update_post_shortcodes ) {
725
+			if ($update_post_shortcodes) {
726 726
 				// remove shortcodes from $maybe_remove_from_posts that are still being used
727
-				foreach ( EE_Registry::instance()->CFG->core->post_shortcodes as $post_name => $shortcodes ) {
728
-					if ( $post_name == $page_for_posts ) {
727
+				foreach (EE_Registry::instance()->CFG->core->post_shortcodes as $post_name => $shortcodes) {
728
+					if ($post_name == $page_for_posts) {
729 729
 						continue;
730 730
 					}
731 731
 					// compute difference between active post_shortcodes array and $maybe_remove_from_posts array
732
-					$maybe_remove_from_posts = array_diff_key( $maybe_remove_from_posts, $shortcodes );
732
+					$maybe_remove_from_posts = array_diff_key($maybe_remove_from_posts, $shortcodes);
733 733
 				}
734 734
 				// now unset unused shortcodes from the $page_for_posts post_shortcodes
735
-				foreach ( $maybe_remove_from_posts as $shortcode => $post_ID ) {
736
-					unset( EE_Registry::instance()->CFG->core->post_shortcodes[ $page_for_posts ][ $shortcode ] );
735
+				foreach ($maybe_remove_from_posts as $shortcode => $post_ID) {
736
+					unset(EE_Registry::instance()->CFG->core->post_shortcodes[$page_for_posts][$shortcode]);
737 737
 				}
738
-				EE_Registry::instance()->CFG->update_post_shortcodes( $page_for_posts );
738
+				EE_Registry::instance()->CFG->update_post_shortcodes($page_for_posts);
739 739
 			}
740 740
 		}
741 741
 	}
@@ -753,32 +753,32 @@  discard block
 block discarded – undo
753 753
 	 * @throws EE_Error
754 754
 	 * @return    string
755 755
 	 */
756
-	public function check_for_invalid_datetime_formats( $value, $option ) {
757
-		EE_Registry::instance()->load_helper( 'DTT_Helper' );
756
+	public function check_for_invalid_datetime_formats($value, $option) {
757
+		EE_Registry::instance()->load_helper('DTT_Helper');
758 758
 		// check for date_format or time_format
759
-		switch ( $option ) {
759
+		switch ($option) {
760 760
 			case 'date_format' :
761
-				$date_time_format = $value . ' ' . get_option('time_format');
761
+				$date_time_format = $value.' '.get_option('time_format');
762 762
 				break;
763 763
 			case 'time_format' :
764
-				$date_time_format = get_option('date_format') . ' ' . $value;
764
+				$date_time_format = get_option('date_format').' '.$value;
765 765
 				break;
766 766
 			default :
767 767
 				$date_time_format = FALSE;
768 768
 		}
769 769
 		// do we have a date_time format to check ?
770
-		if ( $date_time_format ) {
771
-			$error_msg = EEH_DTT_Helper::validate_format_string( $date_time_format );
770
+		if ($date_time_format) {
771
+			$error_msg = EEH_DTT_Helper::validate_format_string($date_time_format);
772 772
 
773
-			if ( is_array( $error_msg ) ) {
774
-				$msg = '<p>' . sprintf( __( 'The following date time "%s" ( %s ) is difficult to be properly parsed by PHP for the following reasons:', 'event_espresso' ), date( $date_time_format ) , $date_time_format  ) . '</p><p><ul>';
773
+			if (is_array($error_msg)) {
774
+				$msg = '<p>'.sprintf(__('The following date time "%s" ( %s ) is difficult to be properly parsed by PHP for the following reasons:', 'event_espresso'), date($date_time_format), $date_time_format).'</p><p><ul>';
775 775
 
776 776
 
777
-				foreach ( $error_msg as $error ) {
778
-					$msg .= '<li>' . $error . '</li>';
777
+				foreach ($error_msg as $error) {
778
+					$msg .= '<li>'.$error.'</li>';
779 779
 				}
780 780
 
781
-				$msg .= '</ul></p><p>' . sprintf( __( '%sPlease note that your date and time formats have been reset to "F j, Y" and "g:i a" respectively.%s', 'event_espresso' ), '<span style="color:#D54E21;">', '</span>' ) . '</p>';
781
+				$msg .= '</ul></p><p>'.sprintf(__('%sPlease note that your date and time formats have been reset to "F j, Y" and "g:i a" respectively.%s', 'event_espresso'), '<span style="color:#D54E21;">', '</span>').'</p>';
782 782
 
783 783
 				// trigger WP settings error
784 784
 				add_settings_error(
@@ -788,7 +788,7 @@  discard block
 block discarded – undo
788 788
 				);
789 789
 
790 790
 				// set format to something valid
791
-				switch ( $option ) {
791
+				switch ($option) {
792 792
 					case 'date_format' :
793 793
 						$value = 'F j, Y';
794 794
 						break;
@@ -814,14 +814,14 @@  discard block
 block discarded – undo
814 814
 	 * @param 	$value
815 815
 	 * @return 	void
816 816
 	 */
817
-	public function reset_page_for_posts_on_change( $option, $old_value, $value ) {
818
-		if ( $option == 'page_for_posts' ) {
817
+	public function reset_page_for_posts_on_change($option, $old_value, $value) {
818
+		if ($option == 'page_for_posts') {
819 819
 			global $wpdb;
820
-			$SQL = 'SELECT post_name from ' . $wpdb->posts . ' WHERE post_type="posts" OR post_type="page" AND post_status="publish" AND ID=%s';
821
-			$old_page_for_posts = $old_value ? $wpdb->get_var( $wpdb->prepare( $SQL, $old_value )) : 'posts';
822
-			$new_page_for_posts = $value ? $wpdb->get_var( $wpdb->prepare( $SQL, $value )) : 'posts';
823
-			EE_Registry::instance()->CFG->core->post_shortcodes[ $new_page_for_posts ] = EE_Registry::instance()->CFG->core->post_shortcodes[ $old_page_for_posts ];
824
-			EE_Registry::instance()->CFG->update_post_shortcodes( $new_page_for_posts );
820
+			$SQL = 'SELECT post_name from '.$wpdb->posts.' WHERE post_type="posts" OR post_type="page" AND post_status="publish" AND ID=%s';
821
+			$old_page_for_posts = $old_value ? $wpdb->get_var($wpdb->prepare($SQL, $old_value)) : 'posts';
822
+			$new_page_for_posts = $value ? $wpdb->get_var($wpdb->prepare($SQL, $value)) : 'posts';
823
+			EE_Registry::instance()->CFG->core->post_shortcodes[$new_page_for_posts] = EE_Registry::instance()->CFG->core->post_shortcodes[$old_page_for_posts];
824
+			EE_Registry::instance()->CFG->update_post_shortcodes($new_page_for_posts);
825 825
 		}
826 826
 	}
827 827
 
@@ -834,8 +834,8 @@  discard block
 block discarded – undo
834 834
 	 * @param $content
835 835
 	 * @return    string
836 836
 	 */
837
-	public function its_eSpresso( $content ) {
838
-		return str_replace( '[EXPRESSO_', '[ESPRESSO_', $content );
837
+	public function its_eSpresso($content) {
838
+		return str_replace('[EXPRESSO_', '[ESPRESSO_', $content);
839 839
 	}
840 840
 
841 841
 
@@ -848,9 +848,9 @@  discard block
 block discarded – undo
848 848
 	 */
849 849
 	public function espresso_admin_footer() {
850 850
 		return sprintf(
851
-			__( 'Event Registration and Ticketing Powered by %sEvent Registration Powered by Event Espresso%s', 'event_espresso' ),
851
+			__('Event Registration and Ticketing Powered by %sEvent Registration Powered by Event Espresso%s', 'event_espresso'),
852 852
 			'<a href="http://eventespresso.com/" title="',
853
-			'">' . EVENT_ESPRESSO_POWERED_BY . '</a>'
853
+			'">'.EVENT_ESPRESSO_POWERED_BY.'</a>'
854 854
 		);
855 855
 	}
856 856
 
@@ -870,11 +870,11 @@  discard block
 block discarded – undo
870 870
 	 * @param array $config
871 871
 	 * @return void
872 872
 	 */
873
-	public static function register_ee_admin_page( $page_basename, $page_path, $config = array() ) {
874
-		EE_Error::doing_it_wrong( __METHOD__, sprintf( __('Usage is deprecated.  Use EE_Register_Admin_Page::register() for registering the %s admin page.', 'event_espresso'), $page_basename), '4.3' );
875
-		if ( class_exists( 'EE_Register_Admin_Page' ) )
873
+	public static function register_ee_admin_page($page_basename, $page_path, $config = array()) {
874
+		EE_Error::doing_it_wrong(__METHOD__, sprintf(__('Usage is deprecated.  Use EE_Register_Admin_Page::register() for registering the %s admin page.', 'event_espresso'), $page_basename), '4.3');
875
+		if (class_exists('EE_Register_Admin_Page'))
876 876
 			$config['page_path'] = $page_path;
877
-			EE_Register_Admin_Page::register( $page_basename, $config );
877
+			EE_Register_Admin_Page::register($page_basename, $config);
878 878
 	}
879 879
 
880 880
 
Please login to merge, or discard this patch.
core/helpers/EEH_Template.helper.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 	 *
283 283
 	 * given two paths, this determines if there is a common base path between the two
284 284
 	 *
285
-	 * @param array $paths
285
+	 * @param string[] $paths
286 286
 	 * @return string
287 287
 	 */
288 288
 	protected static function _find_common_base_path( $paths ) {
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 	 * @param bool|string $template_path server path to the file to be loaded, including file name and extension
310 310
 	 * @param  array      $template_args an array of arguments to be extracted for use in the template
311 311
 	 * @param  boolean    $return_string whether to send output immediately to screen, or capture and return as a string
312
-	 * @return mixed string
312
+	 * @return string string
313 313
 	 */
314 314
 	public static function display_template( $template_path = FALSE, $template_args = array(), $return_string = FALSE ) {
315 315
 		//require the template validator for verifying variables are set according to how the template requires
Please login to merge, or discard this patch.
Spacing   +196 added lines, -196 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 
16 16
 
17 17
 
18
-if ( ! function_exists( 'espresso_get_template_part' )) {
18
+if ( ! function_exists('espresso_get_template_part')) {
19 19
 	/**
20 20
 	 * espresso_get_template_part
21 21
 	 * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead, and doesn't add base versions of files
@@ -25,14 +25,14 @@  discard block
 block discarded – undo
25 25
 	 * @param string $name The name of the specialised template.
26 26
 	 * @return string        the html output for the formatted money value
27 27
 	 */
28
-	function espresso_get_template_part( $slug = NULL, $name = NULL ) {
29
-		EEH_Template::get_template_part( $slug, $name );
28
+	function espresso_get_template_part($slug = NULL, $name = NULL) {
29
+		EEH_Template::get_template_part($slug, $name);
30 30
 	}
31 31
 }
32 32
 
33 33
 
34 34
 
35
-if ( ! function_exists( 'espresso_get_object_css_class' )) {
35
+if ( ! function_exists('espresso_get_object_css_class')) {
36 36
 	/**
37 37
 	 * espresso_get_object_css_class - attempts to generate a css class based on the type of EE object passed
38 38
 	 *
@@ -42,8 +42,8 @@  discard block
 block discarded – undo
42 42
 	 * @param  string $suffix added to the end of the generated class
43 43
 	 * @return string
44 44
 	 */
45
-	function espresso_get_object_css_class( $object = NULL, $prefix = '', $suffix = '' ) {
46
-		return EEH_Template::get_object_css_class( $object, $prefix, $suffix );
45
+	function espresso_get_object_css_class($object = NULL, $prefix = '', $suffix = '') {
46
+		return EEH_Template::get_object_css_class($object, $prefix, $suffix);
47 47
 	}
48 48
 }
49 49
 
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 	 * 	@return boolean
71 71
 	 */
72 72
 	public static function is_espresso_theme() {
73
-		return wp_get_theme()->get( 'TextDomain' ) == 'event_espresso' ? TRUE : FALSE;
73
+		return wp_get_theme()->get('TextDomain') == 'event_espresso' ? TRUE : FALSE;
74 74
 	}
75 75
 
76 76
 	/**
@@ -79,9 +79,9 @@  discard block
 block discarded – undo
79 79
 	 * 	@return void
80 80
 	 */
81 81
 	public static function load_espresso_theme_functions() {
82
-		if ( ! defined( 'EE_THEME_FUNCTIONS_LOADED' )) {
83
-			if ( is_readable( EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php' )) {
84
-				require_once( EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php' );
82
+		if ( ! defined('EE_THEME_FUNCTIONS_LOADED')) {
83
+			if (is_readable(EE_PUBLIC.EE_Config::get_current_theme().DS.'functions.php')) {
84
+				require_once(EE_PUBLIC.EE_Config::get_current_theme().DS.'functions.php');
85 85
 			}
86 86
 		}
87 87
 	}
@@ -93,17 +93,17 @@  discard block
 block discarded – undo
93 93
 	 * 	@return array
94 94
 	 */
95 95
 	public static function get_espresso_themes() {
96
-		if ( empty( EEH_Template::$_espresso_themes )) {
97
-			$espresso_themes =  glob( EE_PUBLIC . '*', GLOB_ONLYDIR );
98
-			if ( empty( $espresso_themes ) ) {
96
+		if (empty(EEH_Template::$_espresso_themes)) {
97
+			$espresso_themes = glob(EE_PUBLIC.'*', GLOB_ONLYDIR);
98
+			if (empty($espresso_themes)) {
99 99
 				return array();
100 100
 			}
101
-			if (( $key = array_search( 'global_assets', $espresso_themes )) !== FALSE ) {
102
-			    unset( $espresso_themes[ $key ] );
101
+			if (($key = array_search('global_assets', $espresso_themes)) !== FALSE) {
102
+			    unset($espresso_themes[$key]);
103 103
 			}
104 104
 			EEH_Template::$_espresso_themes = array();
105
-			foreach ( $espresso_themes as $espresso_theme ) {
106
-				EEH_Template::$_espresso_themes[ basename( $espresso_theme ) ] = $espresso_theme;
105
+			foreach ($espresso_themes as $espresso_theme) {
106
+				EEH_Template::$_espresso_themes[basename($espresso_theme)] = $espresso_theme;
107 107
 			}
108 108
 		}
109 109
 		return EEH_Template::$_espresso_themes;
@@ -122,16 +122,16 @@  discard block
 block discarded – undo
122 122
 	 * @param bool   $return_string
123 123
 	 * @return string        the html output for the formatted money value
124 124
 	 */
125
-	public static function get_template_part( $slug = NULL, $name = NULL, $template_args = array(), $return_string = FALSE  ) {
126
-		do_action( "get_template_part_{$slug}-{$name}", $slug, $name );
125
+	public static function get_template_part($slug = NULL, $name = NULL, $template_args = array(), $return_string = FALSE) {
126
+		do_action("get_template_part_{$slug}-{$name}", $slug, $name);
127 127
 		$templates = array();
128 128
 		$name = (string) $name;
129
-		if ( $name != '' ) {
129
+		if ($name != '') {
130 130
 			$templates[] = "{$slug}-{$name}.php";
131 131
 		}
132 132
 		// allow template parts to be turned off via something like: add_filter( 'FHEE__content_espresso_events_tickets_template__display_datetimes', '__return_false' );
133
-		if ( apply_filters( "FHEE__EEH_Template__get_template_part__display__{$slug}_{$name}", TRUE )) {
134
-			EEH_Template::locate_template( $templates, $template_args, TRUE, $return_string );
133
+		if (apply_filters("FHEE__EEH_Template__get_template_part__display__{$slug}_{$name}", TRUE)) {
134
+			EEH_Template::locate_template($templates, $template_args, TRUE, $return_string);
135 135
 		}
136 136
 	}
137 137
 
@@ -171,26 +171,26 @@  discard block
 block discarded – undo
171 171
 	 * 				Used in places where you don't actually load the template, you just want to know if there's a custom version of it.
172 172
 	 * @return mixed
173 173
 	 */
174
-	public static function locate_template( $templates = array(), $template_args = array(), $load = TRUE, $return_string = TRUE, $check_if_custom = FALSE ) {
174
+	public static function locate_template($templates = array(), $template_args = array(), $load = TRUE, $return_string = TRUE, $check_if_custom = FALSE) {
175 175
 		// first use WP locate_template to check for template in the current theme folder
176
-		$template_path = locate_template( $templates );
176
+		$template_path = locate_template($templates);
177 177
 
178
-		if ( $check_if_custom && !empty( $template_path ) )
178
+		if ($check_if_custom && ! empty($template_path))
179 179
 			return TRUE;
180 180
 
181 181
 		// not in the theme
182
-		if ( empty( $template_path )) {
182
+		if (empty($template_path)) {
183 183
 			// not even a template to look for ?
184
-			if ( empty( $templates )) {
184
+			if (empty($templates)) {
185 185
 				// get post_type
186
-				$post_type = EE_Registry::instance()->REQ->get( 'post_type' );
186
+				$post_type = EE_Registry::instance()->REQ->get('post_type');
187 187
 				// get array of EE Custom Post Types
188 188
 				$EE_CPTs = EE_Register_CPTs::get_CPTs();
189 189
 				// build template name based on request
190
-				if ( isset( $EE_CPTs[ $post_type ] )) {
191
-					$archive_or_single =  is_archive() ? 'archive' : '';
192
-					$archive_or_single =  is_single() ? 'single' : $archive_or_single;
193
-					$templates = $archive_or_single . '-' . $post_type . '.php';
190
+				if (isset($EE_CPTs[$post_type])) {
191
+					$archive_or_single = is_archive() ? 'archive' : '';
192
+					$archive_or_single = is_single() ? 'single' : $archive_or_single;
193
+					$templates = $archive_or_single.'-'.$post_type.'.php';
194 194
 				}
195 195
 			}
196 196
 			// currently active EE template theme
@@ -199,80 +199,80 @@  discard block
 block discarded – undo
199 199
 			// array of paths to folders that may contain templates
200 200
 			$template_folder_paths = array(
201 201
 				// first check the /wp-content/uploads/espresso/templates/(current EE theme)/  folder for an EE theme template file
202
-				EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme,
202
+				EVENT_ESPRESSO_TEMPLATE_DIR.$current_theme,
203 203
 				// then in the root of the /wp-content/uploads/espresso/templates/ folder
204 204
 				EVENT_ESPRESSO_TEMPLATE_DIR
205 205
 			);
206 206
 
207 207
 			//add core plugin folders for checking only if we're not $check_if_custom
208
-			if ( ! $check_if_custom ) {
208
+			if ( ! $check_if_custom) {
209 209
 				$core_paths = array(
210 210
 					// in the  /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin
211
-					EE_PUBLIC . $current_theme,
211
+					EE_PUBLIC.$current_theme,
212 212
 					// in the  /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin
213
-					EE_TEMPLATES . $current_theme,
213
+					EE_TEMPLATES.$current_theme,
214 214
 					// or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/
215 215
 					EE_PLUGIN_DIR_PATH
216 216
 					);
217
-				$template_folder_paths = array_merge( $template_folder_paths, $core_paths );
217
+				$template_folder_paths = array_merge($template_folder_paths, $core_paths);
218 218
 			}
219 219
 
220 220
 			// now filter that array
221
-			$template_folder_paths = apply_filters( 'FHEE__EEH_Template__locate_template__template_folder_paths', $template_folder_paths );
222
-			$templates = is_array( $templates ) ? $templates : array( $templates );
223
-			$template_folder_paths = is_array( $template_folder_paths ) ? $template_folder_paths : array( $template_folder_paths );
221
+			$template_folder_paths = apply_filters('FHEE__EEH_Template__locate_template__template_folder_paths', $template_folder_paths);
222
+			$templates = is_array($templates) ? $templates : array($templates);
223
+			$template_folder_paths = is_array($template_folder_paths) ? $template_folder_paths : array($template_folder_paths);
224 224
 			// array to hold all possible template paths
225 225
 			$full_template_paths = array();
226 226
 
227 227
 			EE_Registry::instance()->load_helper('File');
228 228
 			// loop through $templates
229
-			foreach ( $templates as $template ) {
229
+			foreach ($templates as $template) {
230 230
 				// normalize directory separators
231
-				$template = EEH_File::standardise_directory_separators( $template );
232
-				$file_name = basename( $template );
233
-				$template_path_minus_file_name = substr( $template, 0, ( strlen( $file_name ) * -1 ) );
231
+				$template = EEH_File::standardise_directory_separators($template);
232
+				$file_name = basename($template);
233
+				$template_path_minus_file_name = substr($template, 0, (strlen($file_name) * -1));
234 234
 				// while looping through all template folder paths
235
-				foreach ( $template_folder_paths as $template_folder_path ) {
235
+				foreach ($template_folder_paths as $template_folder_path) {
236 236
 					// normalize directory separators
237
-					$template_folder_path = EEH_File::standardise_directory_separators( $template_folder_path );
237
+					$template_folder_path = EEH_File::standardise_directory_separators($template_folder_path);
238 238
 					// determine if any common base path exists between the two paths
239 239
 					$common_base_path = EEH_Template::_find_common_base_path(
240
-						array( $template_folder_path, $template_path_minus_file_name )
240
+						array($template_folder_path, $template_path_minus_file_name)
241 241
 					);
242
-					if ( $common_base_path !== '' ) {
242
+					if ($common_base_path !== '') {
243 243
 						// both paths have a common base, so just tack the filename onto our search path
244
-						$resolved_path = EEH_File::end_with_directory_separator( $template_folder_path ) . $file_name;
244
+						$resolved_path = EEH_File::end_with_directory_separator($template_folder_path).$file_name;
245 245
 					} else {
246 246
 						// no common base path, so let's just concatenate
247
-						$resolved_path = EEH_File::end_with_directory_separator( $template_folder_path ) . $template;
247
+						$resolved_path = EEH_File::end_with_directory_separator($template_folder_path).$template;
248 248
 					}
249 249
 					// build up our template locations array by adding our resolved paths
250 250
 					$full_template_paths[] = $resolved_path;
251 251
 				}
252 252
 				// if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first
253
-				array_unshift( $full_template_paths, $template );
253
+				array_unshift($full_template_paths, $template);
254 254
 				// path to the directory of the current theme: /wp-content/themes/(current WP theme)/
255
-				array_unshift( $full_template_paths, get_template_directory() . DS . $file_name );
255
+				array_unshift($full_template_paths, get_template_directory().DS.$file_name);
256 256
 			}
257 257
 			// filter final array of full template paths
258
-			$full_template_paths = apply_filters( 'FHEE__EEH_Template__locate_template__full_template_paths', $full_template_paths );
258
+			$full_template_paths = apply_filters('FHEE__EEH_Template__locate_template__full_template_paths', $full_template_paths);
259 259
 			// now loop through our final array of template location paths and check each location
260
-			foreach ( (array)$full_template_paths as $full_template_path ) {
261
-				if ( is_readable( $full_template_path )) {
262
-					$template_path = str_replace( array( '\\', '/' ), DIRECTORY_SEPARATOR, $full_template_path );
260
+			foreach ((array) $full_template_paths as $full_template_path) {
261
+				if (is_readable($full_template_path)) {
262
+					$template_path = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $full_template_path);
263 263
 					break;
264 264
 				}
265 265
 			}
266 266
 		}
267 267
 		// if we got it and you want to see it...
268
-		if ( $template_path && $load && ! $check_if_custom  ) {
269
-			if ( $return_string ) {
270
-				return EEH_Template::display_template( $template_path, $template_args, TRUE );
268
+		if ($template_path && $load && ! $check_if_custom) {
269
+			if ($return_string) {
270
+				return EEH_Template::display_template($template_path, $template_args, TRUE);
271 271
 			} else {
272
-				EEH_Template::display_template( $template_path, $template_args, FALSE );
272
+				EEH_Template::display_template($template_path, $template_args, FALSE);
273 273
 			}
274 274
 		}
275
-		return $check_if_custom && ! empty( $template_path ) ? TRUE : $template_path;
275
+		return $check_if_custom && ! empty($template_path) ? TRUE : $template_path;
276 276
 	}
277 277
 
278 278
 
@@ -285,21 +285,21 @@  discard block
 block discarded – undo
285 285
 	 * @param array $paths
286 286
 	 * @return string
287 287
 	 */
288
-	protected static function _find_common_base_path( $paths ) {
288
+	protected static function _find_common_base_path($paths) {
289 289
 		$last_offset = 0;
290 290
 		$common_base_path = '';
291
-		while ( ( $index = strpos( $paths[ 0 ], DS, $last_offset ) ) !== false ) {
291
+		while (($index = strpos($paths[0], DS, $last_offset)) !== false) {
292 292
 			$dir_length = $index - $last_offset + 1;
293
-			$directory = substr( $paths[ 0 ], $last_offset, $dir_length );
294
-			foreach ( $paths as $path ) {
295
-				if ( substr( $path, $last_offset, $dir_length ) != $directory ) {
293
+			$directory = substr($paths[0], $last_offset, $dir_length);
294
+			foreach ($paths as $path) {
295
+				if (substr($path, $last_offset, $dir_length) != $directory) {
296 296
 					return $common_base_path;
297 297
 				}
298 298
 			}
299 299
 			$common_base_path .= $directory;
300 300
 			$last_offset = $index + 1;
301 301
 		}
302
-		return substr( $common_base_path, 0, -1 );
302
+		return substr($common_base_path, 0, -1);
303 303
 	}
304 304
 
305 305
 
@@ -311,9 +311,9 @@  discard block
 block discarded – undo
311 311
 	 * @param  boolean    $return_string whether to send output immediately to screen, or capture and return as a string
312 312
 	 * @return mixed string
313 313
 	 */
314
-	public static function display_template( $template_path = FALSE, $template_args = array(), $return_string = FALSE ) {
314
+	public static function display_template($template_path = FALSE, $template_args = array(), $return_string = FALSE) {
315 315
 		//require the template validator for verifying variables are set according to how the template requires
316
-		EE_Registry::instance()->load_helper( 'Template_Validator' );
316
+		EE_Registry::instance()->load_helper('Template_Validator');
317 317
 
318 318
 		/**
319 319
 		 * These two filters are intended for last minute changes to templates being loaded and/or template arg
@@ -324,26 +324,26 @@  discard block
 block discarded – undo
324 324
 		 *
325 325
 		 * @since 4.6.0
326 326
 		 */
327
-		$template_path = apply_filters( 'FHEE__EEH_Template__display_template__template_path', $template_path );
328
-		$template_args = apply_filters( 'FHEE__EEH_Template__display_template__template_args', $template_args );
327
+		$template_path = apply_filters('FHEE__EEH_Template__display_template__template_path', $template_path);
328
+		$template_args = apply_filters('FHEE__EEH_Template__display_template__template_args', $template_args);
329 329
 
330 330
 		// you gimme nuttin - YOU GET NUTTIN !!
331
-		if ( ! $template_path || ! is_readable( $template_path )) {
331
+		if ( ! $template_path || ! is_readable($template_path)) {
332 332
 			return '';
333 333
 		}
334 334
 		// if $template_args are not in an array, then make it so
335
-		if ( ! is_array( $template_args ) && ! is_object( $template_args )) {
336
-			$template_args = array( $template_args );
335
+		if ( ! is_array($template_args) && ! is_object($template_args)) {
336
+			$template_args = array($template_args);
337 337
 		}
338
-		extract( (array) $template_args);
338
+		extract((array) $template_args);
339 339
 
340
-		if ( $return_string ) {
340
+		if ($return_string) {
341 341
 			// because we want to return a string, we are going to capture the output
342 342
 			ob_start();
343
-			include( $template_path );
343
+			include($template_path);
344 344
 			return ob_get_clean();
345 345
 		} else {
346
-			include( $template_path );
346
+			include($template_path);
347 347
 		}
348 348
 		return '';
349 349
 	}
@@ -361,27 +361,27 @@  discard block
 block discarded – undo
361 361
 	 * @param  string $suffix added to the end of the generated class
362 362
 	 * @return string
363 363
 	 */
364
-	public static function get_object_css_class( $object = NULL, $prefix = '', $suffix = '' ) {
364
+	public static function get_object_css_class($object = NULL, $prefix = '', $suffix = '') {
365 365
 		// in the beginning...
366
-		$prefix = ! empty( $prefix ) ? rtrim( $prefix, '-' ) . '-' : '';
366
+		$prefix = ! empty($prefix) ? rtrim($prefix, '-').'-' : '';
367 367
 		// da muddle
368 368
 		$class = '';
369 369
 		// the end
370
-		$suffix = ! empty( $suffix ) ? '-' . ltrim( $suffix, '-' ) : '';
370
+		$suffix = ! empty($suffix) ? '-'.ltrim($suffix, '-') : '';
371 371
 		// is the passed object an EE object ?
372
-		if ( $object instanceof EE_Base_Class ) {
372
+		if ($object instanceof EE_Base_Class) {
373 373
 			// grab the exact type of object
374
-			$obj_class = get_class( $object );
374
+			$obj_class = get_class($object);
375 375
 			// depending on the type of object...
376
-			switch ( $obj_class ) {
376
+			switch ($obj_class) {
377 377
 				// no specifics just yet...
378 378
 				default :
379
-					$class = strtolower( str_replace( '_', '-', $obj_class ));
380
-					$class .= method_exists( $obj_class, 'name' ) ? '-' . sanitize_title( $object->name() ) : '';
379
+					$class = strtolower(str_replace('_', '-', $obj_class));
380
+					$class .= method_exists($obj_class, 'name') ? '-'.sanitize_title($object->name()) : '';
381 381
 
382 382
 			}
383 383
 		}
384
-		return $prefix . $class . $suffix;
384
+		return $prefix.$class.$suffix;
385 385
 	}
386 386
 
387 387
 
@@ -397,50 +397,50 @@  discard block
 block discarded – undo
397 397
 	 * @param string      $cur_code_span_class
398 398
 	 * @return string        the html output for the formatted money value
399 399
 	 */
400
-	public static function format_currency( $amount = NULL, $return_raw = FALSE, $display_code = TRUE, $CNT_ISO = '', $cur_code_span_class = 'currency-code' ) {
400
+	public static function format_currency($amount = NULL, $return_raw = FALSE, $display_code = TRUE, $CNT_ISO = '', $cur_code_span_class = 'currency-code') {
401 401
 		// ensure amount was received
402
-		if ( is_null( $amount ) ) {
403
-			$msg = __( 'In order to format currency, an amount needs to be passed.', 'event_espresso' );
404
-			EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
402
+		if (is_null($amount)) {
403
+			$msg = __('In order to format currency, an amount needs to be passed.', 'event_espresso');
404
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
405 405
 			return '';
406 406
 		}
407 407
 		//ensure amount is float
408 408
 		$amount = (float) $amount;
409 409
 		// filter raw amount (allows 0.00 to be changed to "free" for example)
410
-		$amount_formatted = apply_filters( 'FHEE__EEH_Template__format_currency__amount', $amount, $return_raw );
410
+		$amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw);
411 411
 		// still a number or was amount converted to a string like "free" ?
412
-		if ( is_float( $amount_formatted )) {
412
+		if (is_float($amount_formatted)) {
413 413
 			// was a country ISO code passed ? if so generate currency config object for that country
414
-			$mny = $CNT_ISO !== '' ? new EE_Currency_Config( $CNT_ISO ) : NULL;
414
+			$mny = $CNT_ISO !== '' ? new EE_Currency_Config($CNT_ISO) : NULL;
415 415
 			// verify results
416
-			if ( ! $mny instanceof EE_Currency_Config ) {
416
+			if ( ! $mny instanceof EE_Currency_Config) {
417 417
 				// set default config country currency settings
418 418
 				$mny = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config ? EE_Registry::instance()->CFG->currency : new EE_Currency_Config();
419 419
 			}
420 420
 			// format float
421
-			$amount_formatted = number_format( $amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds );
421
+			$amount_formatted = number_format($amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds);
422 422
 			// add formatting ?
423
-			if ( ! $return_raw ) {
423
+			if ( ! $return_raw) {
424 424
 				// add currency sign
425
-				if( $mny->sign_b4 ){
426
-					if( $amount >= 0 ){
427
-						$amount_formatted = $mny->sign . $amount_formatted;
428
-					}else{
429
-						$amount_formatted = '-' . $mny->sign . str_replace( '-', '', $amount_formatted );
425
+				if ($mny->sign_b4) {
426
+					if ($amount >= 0) {
427
+						$amount_formatted = $mny->sign.$amount_formatted;
428
+					} else {
429
+						$amount_formatted = '-'.$mny->sign.str_replace('-', '', $amount_formatted);
430 430
 					}
431 431
 
432
-				}else{
433
-					$amount_formatted =  $amount_formatted . $mny->sign;
432
+				} else {
433
+					$amount_formatted = $amount_formatted.$mny->sign;
434 434
 				}
435 435
 
436 436
 				// add currency code ?
437
-				$amount_formatted = $display_code ? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>' : $amount_formatted;
437
+				$amount_formatted = $display_code ? $amount_formatted.' <span class="'.$cur_code_span_class.'">('.$mny->code.')</span>' : $amount_formatted;
438 438
 			}
439 439
 			// filter results
440
-			$amount_formatted = apply_filters( 'FHEE__EEH_Template__format_currency__amount_formatted', $amount_formatted, $mny, $return_raw );
440
+			$amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount_formatted', $amount_formatted, $mny, $return_raw);
441 441
 		}
442 442
 		// clean up vars
443
-		unset( $mny );
443
+		unset($mny);
444 444
 		// return formatted currency amount
445 445
 		return $amount_formatted;
446 446
 	}
@@ -455,11 +455,11 @@  discard block
 block discarded – undo
455 455
 	 * @param  string  $schema    'UPPER', 'lower', or 'Sentence'
456 456
 	 * @return string             The localized label for the status id.
457 457
 	 */
458
-	public static function pretty_status( $status_id, $plural = FALSE, $schema = 'upper' ) {
458
+	public static function pretty_status($status_id, $plural = FALSE, $schema = 'upper') {
459 459
 		/** @type EEM_Status $EEM_Status */
460
-		$EEM_Status = EE_Registry::instance()->load_model( 'Status' );
461
-		$status = $EEM_Status->localized_status( array( $status_id => __( 'unknown', 'event_espresso' )), $plural, $schema );
462
-		return $status[ $status_id ];
460
+		$EEM_Status = EE_Registry::instance()->load_model('Status');
461
+		$status = $EEM_Status->localized_status(array($status_id => __('unknown', 'event_espresso')), $plural, $schema);
462
+		return $status[$status_id];
463 463
 	}
464 464
 
465 465
 
@@ -472,9 +472,9 @@  discard block
 block discarded – undo
472 472
 	 * @param string  $icon
473 473
 	 * @return string 	the html output for the button
474 474
 	 */
475
-	public static function get_button_or_link( $url, $label, $class = 'button-primary', $icon = '' ) {
476
-		$label = ! empty( $icon ) ? '<span class="' . $icon . '"></span>' . $label : $label;
477
-		$button = '<a id="' . sanitize_title_with_dashes($label) . '" href="' . $url . '" class="' . $class . '">' . $label . '</a>';
475
+	public static function get_button_or_link($url, $label, $class = 'button-primary', $icon = '') {
476
+		$label = ! empty($icon) ? '<span class="'.$icon.'"></span>'.$label : $label;
477
+		$button = '<a id="'.sanitize_title_with_dashes($label).'" href="'.$url.'" class="'.$class.'">'.$label.'</a>';
478 478
 		return $button;
479 479
 	}
480 480
 
@@ -491,21 +491,21 @@  discard block
 block discarded – undo
491 491
 	 * @param bool|string $help_text   (optional) send help text you want to use for the link if default not to be used
492 492
 	 * @return string              generated link
493 493
 	 */
494
-	public static function get_help_tab_link( $help_tab_id, $page = FALSE, $action = FALSE, $icon_style = FALSE, $help_text = FALSE ) {
494
+	public static function get_help_tab_link($help_tab_id, $page = FALSE, $action = FALSE, $icon_style = FALSE, $help_text = FALSE) {
495 495
 
496
-		if ( ! $page )
497
-			$page = isset( $_REQUEST['page'] ) && ! empty( $_REQUEST['page'] ) ? sanitize_key( $_REQUEST['page'] ) : $page;
496
+		if ( ! $page)
497
+			$page = isset($_REQUEST['page']) && ! empty($_REQUEST['page']) ? sanitize_key($_REQUEST['page']) : $page;
498 498
 
499
-		if ( ! $action )
500
-			$action = isset( $_REQUEST['action'] ) && ! empty( $_REQUEST['action'] ) ? sanitize_key( $_REQUEST['action'] ) : $action;
499
+		if ( ! $action)
500
+			$action = isset($_REQUEST['action']) && ! empty($_REQUEST['action']) ? sanitize_key($_REQUEST['action']) : $action;
501 501
 
502 502
 		$action = empty($action) ? 'default' : $action;
503 503
 
504 504
 
505
-		$help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id;
506
-		$icon = !$icon_style ? ' dashicons-editor-help' : $icon_style;
507
-		$help_text = !$help_text ? '' : $help_text;
508
-		return '<a id="' . $help_tab_lnk . '" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22' . $icon . '" title="' . esc_attr__('Click to open the \'Help\' tab for more information about this feature.', 'event_espresso') . '" > ' . $help_text . ' </a>';
505
+		$help_tab_lnk = $page.'-'.$action.'-'.$help_tab_id;
506
+		$icon = ! $icon_style ? ' dashicons-editor-help' : $icon_style;
507
+		$help_text = ! $help_text ? '' : $help_text;
508
+		return '<a id="'.$help_tab_lnk.'" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22'.$icon.'" title="'.esc_attr__('Click to open the \'Help\' tab for more information about this feature.', 'event_espresso').'" > '.$help_text.' </a>';
509 509
 	}
510 510
 
511 511
 
@@ -517,31 +517,31 @@  discard block
 block discarded – undo
517 517
 	 * @param EE_Help_Tour
518 518
 	 * @return string         html
519 519
 	 */
520
-	public static function help_tour_stops_generator( EE_Help_Tour $tour ) {
520
+	public static function help_tour_stops_generator(EE_Help_Tour $tour) {
521 521
 		$id = $tour->get_slug();
522 522
 		$stops = $tour->get_stops();
523 523
 
524
-		$content = '<ol style="display:none" id="' . $id . '">';
524
+		$content = '<ol style="display:none" id="'.$id.'">';
525 525
 
526
-		foreach ( $stops as $stop ) {
527
-			$data_id = !empty( $stop['id'] ) ? ' data-id="' . $stop['id'] . '"' : '';
528
-			$data_class = empty( $data_id ) && !empty( $stop['class'] ) ? ' data-class="' . $stop['class'] . '"' : '';
526
+		foreach ($stops as $stop) {
527
+			$data_id = ! empty($stop['id']) ? ' data-id="'.$stop['id'].'"' : '';
528
+			$data_class = empty($data_id) && ! empty($stop['class']) ? ' data-class="'.$stop['class'].'"' : '';
529 529
 
530 530
 			//if container is set to modal then let's make sure we set the options accordingly
531
-			if ( empty( $data_id ) && empty( $data_class ) ) {
531
+			if (empty($data_id) && empty($data_class)) {
532 532
 				$stop['options']['modal'] = true;
533 533
 				$stop['options']['expose'] = true;
534 534
 			}
535 535
 
536
-			$custom_class = !empty( $stop['custom_class'] ) ? ' class="' . $stop['custom_class'] . '"' : '';
537
-			$button_text = !empty( $stop['button_text'] ) ? ' data-button="' . $stop['button_text'] . '"' : '';
536
+			$custom_class = ! empty($stop['custom_class']) ? ' class="'.$stop['custom_class'].'"' : '';
537
+			$button_text = ! empty($stop['button_text']) ? ' data-button="'.$stop['button_text'].'"' : '';
538 538
 			$inner_content = isset($stop['content']) ? $stop['content'] : '';
539 539
 
540 540
 			//options
541
-			if ( isset( $stop['options'] ) && is_array( $stop['options'] ) ) {
541
+			if (isset($stop['options']) && is_array($stop['options'])) {
542 542
 				$options = ' data-options="';
543
-				foreach ( $stop['options'] as $option => $value ) {
544
-					$options .= $option . ':' . $value . ';';
543
+				foreach ($stop['options'] as $option => $value) {
544
+					$options .= $option.':'.$value.';';
545 545
 				}
546 546
 				$options .= '"';
547 547
 			} else {
@@ -549,7 +549,7 @@  discard block
 block discarded – undo
549 549
 			}
550 550
 
551 551
 			//let's put all together
552
-			$content .= '<li' . $data_id . $data_class . $custom_class . $button_text . $options . '>' . $inner_content . '</li>';
552
+			$content .= '<li'.$data_id.$data_class.$custom_class.$button_text.$options.'>'.$inner_content.'</li>';
553 553
 		}
554 554
 
555 555
 		$content .= '</ol>';
@@ -570,31 +570,31 @@  discard block
 block discarded – undo
570 570
 	 * @throws EE_Error
571 571
 	 * @return string               html structure for status.
572 572
 	 */
573
-	public static function status_legend( $status_array, $active_status = '' ) {
574
-		if ( !is_array( $status_array ) )
575
-			throw new EE_Error( __('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!', 'event_espresso') );
573
+	public static function status_legend($status_array, $active_status = '') {
574
+		if ( ! is_array($status_array))
575
+			throw new EE_Error(__('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!', 'event_espresso'));
576 576
 
577 577
 		$setup_array = array();
578
-		foreach ( $status_array as $item => $status ) {
578
+		foreach ($status_array as $item => $status) {
579 579
 			$setup_array[$item] = array(
580
-					'class' => 'ee-status-legend ee-status-legend-' . $status,
581
-					'desc' => EEH_Template::pretty_status( $status, FALSE, 'sentence' ),
580
+					'class' => 'ee-status-legend ee-status-legend-'.$status,
581
+					'desc' => EEH_Template::pretty_status($status, FALSE, 'sentence'),
582 582
 					'status' => $status
583 583
 				);
584 584
 		}
585 585
 
586
-		$content = '<div class="ee-list-table-legend-container">' . "\n";
587
-		$content .= '<h4>' . __('Status Legend', 'event_espresso') . '</h4>' . "\n";
588
-		$content .= '<dl class="ee-list-table-legend">' . "\n\t";
589
-		foreach ( $setup_array as $item => $details ) {
586
+		$content = '<div class="ee-list-table-legend-container">'."\n";
587
+		$content .= '<h4>'.__('Status Legend', 'event_espresso').'</h4>'."\n";
588
+		$content .= '<dl class="ee-list-table-legend">'."\n\t";
589
+		foreach ($setup_array as $item => $details) {
590 590
 			$active_class = $active_status == $details['status'] ? ' class="ee-is-active-status"' : '';
591
-			$content .= '<dt id="ee-legend-item-tooltip-' . $item . '"' . $active_class . '>' . "\n\t\t";
592
-			$content .= '<span class="' . $details['class'] . '"></span>' . "\n\t\t";
593
-			$content .= '<span class="ee-legend-description">' . $details['desc'] . '</span>' . "\n\t";
594
-			$content .= '</dt>' . "\n";
591
+			$content .= '<dt id="ee-legend-item-tooltip-'.$item.'"'.$active_class.'>'."\n\t\t";
592
+			$content .= '<span class="'.$details['class'].'"></span>'."\n\t\t";
593
+			$content .= '<span class="ee-legend-description">'.$details['desc'].'</span>'."\n\t";
594
+			$content .= '</dt>'."\n";
595 595
 		}
596
-		$content .= '</dl>' . "\n";
597
-		$content .= '</div>' . "\n";
596
+		$content .= '</dl>'."\n";
597
+		$content .= '</div>'."\n";
598 598
 		return $content;
599 599
 	}
600 600
 
@@ -607,8 +607,8 @@  discard block
 block discarded – undo
607 607
 	 * @return string
608 608
 	 */
609 609
 	public static function layout_array_as_table($data) {
610
-	if (is_object($data) || $data instanceof __PHP_Incomplete_Class ) {
611
-		$data = (array)$data;
610
+	if (is_object($data) || $data instanceof __PHP_Incomplete_Class) {
611
+		$data = (array) $data;
612 612
 	}
613 613
 	EE_Registry::instance()->load_helper('Array');
614 614
 	ob_start();
@@ -622,10 +622,10 @@  discard block
 block discarded – undo
622 622
 						?>
623 623
 						<tr>
624 624
 							<td>
625
-								<?php echo $data_key;?>
625
+								<?php echo $data_key; ?>
626 626
 							</td>
627 627
 							<td>
628
-								<?php echo self::layout_array_as_table($data_values);?>
628
+								<?php echo self::layout_array_as_table($data_values); ?>
629 629
 							</td>
630 630
 						</tr>
631 631
 						<?php
@@ -639,7 +639,7 @@  discard block
 block discarded – undo
639 639
 			<ul>
640 640
 				<?php
641 641
 				foreach ($data as $datum) {
642
-					echo "<li>"; echo self::layout_array_as_table($datum);echo "</li>";
642
+					echo "<li>"; echo self::layout_array_as_table($datum); echo "</li>";
643 643
 				}?>
644 644
 			</ul>
645 645
 			<?php
@@ -669,8 +669,8 @@  discard block
 block discarded – undo
669 669
 	 *
670 670
 	 * @return string
671 671
 	 */
672
-	public static function paging_html( $total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array() ) {
673
-		echo self::get_paging_html( $total_items, $current, $per_page, $url, $show_num_field, $paged_arg_name, $items_label );
672
+	public static function paging_html($total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array()) {
673
+		echo self::get_paging_html($total_items, $current, $per_page, $url, $show_num_field, $paged_arg_name, $items_label);
674 674
 	}
675 675
 
676 676
 
@@ -694,13 +694,13 @@  discard block
 block discarded – undo
694 694
 	 *                                 )
695 695
 	 * @return  string
696 696
 	 */
697
-	public static function get_paging_html( $total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array() ) {
697
+	public static function get_paging_html($total_items, $current, $per_page, $url, $show_num_field = TRUE, $paged_arg_name = 'paged', $items_label = array()) {
698 698
 		$page_links = array();
699 699
 		$disable_first = $disable_last = '';
700 700
 		$total_items = (int) $total_items;
701 701
 		$per_page = (int) $per_page;
702 702
 		$current = (int) $current;
703
-		$paged_arg_name = empty( $paged_arg_name ) ? 'paged' : sanitize_key( $paged_arg_name );
703
+		$paged_arg_name = empty($paged_arg_name) ? 'paged' : sanitize_key($paged_arg_name);
704 704
 
705 705
 		//filter items_label
706 706
 		$items_label = apply_filters(
@@ -708,68 +708,68 @@  discard block
 block discarded – undo
708 708
 			$items_label
709 709
 		);
710 710
 
711
-		if ( empty( $items_label )
712
-		     || ! is_array( $items_label )
713
-		     || ! isset( $items_label['single'] )
714
-		     || ! isset( $items_label['plural'] ) ) {
711
+		if (empty($items_label)
712
+		     || ! is_array($items_label)
713
+		     || ! isset($items_label['single'])
714
+		     || ! isset($items_label['plural'])) {
715 715
 			$items_label = array(
716
-				'single' => __( '1 item', 'event_espresso' ),
717
-				'plural' => __( '%s items', 'event_espresso' )
716
+				'single' => __('1 item', 'event_espresso'),
717
+				'plural' => __('%s items', 'event_espresso')
718 718
 			);
719 719
 		} else {
720 720
 			$items_label = array(
721
-				'single' => '1 ' . esc_html( $items_label['single'] ),
722
-				'plural' => '%s ' . esc_html( $items_label['plural'] )
721
+				'single' => '1 '.esc_html($items_label['single']),
722
+				'plural' => '%s '.esc_html($items_label['plural'])
723 723
 			);
724 724
 		}
725 725
 
726
-		$total_pages = ceil( $total_items / $per_page );
726
+		$total_pages = ceil($total_items / $per_page);
727 727
 
728
-		if ( $total_pages <= 1 )
728
+		if ($total_pages <= 1)
729 729
 			return '';
730 730
 
731
-		$item_label = $total_items > 1 ? sprintf( $items_label['plural'], $total_items ) : $items_label['single'];
731
+		$item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single'];
732 732
 
733
-		$output = '<span class="displaying-num">' . $item_label . '</span>';
733
+		$output = '<span class="displaying-num">'.$item_label.'</span>';
734 734
 
735
-		if ( $current === 1 ) {
735
+		if ($current === 1) {
736 736
 			$disable_first = ' disabled';
737 737
 		}
738
-		if ( $current == $total_pages ) {
738
+		if ($current == $total_pages) {
739 739
 			$disable_last = ' disabled';
740 740
 		}
741 741
 
742
-		$page_links[] = sprintf( "<a class='%s' title='%s' href='%s'>%s</a>",
743
-			'first-page' . $disable_first,
744
-			esc_attr__( 'Go to the first page' ),
745
-			esc_url( remove_query_arg( $paged_arg_name, $url ) ),
742
+		$page_links[] = sprintf("<a class='%s' title='%s' href='%s'>%s</a>",
743
+			'first-page'.$disable_first,
744
+			esc_attr__('Go to the first page'),
745
+			esc_url(remove_query_arg($paged_arg_name, $url)),
746 746
 			'&laquo;'
747 747
 		);
748 748
 
749 749
 		$page_links[] = sprintf(
750 750
 			'<a class="%s" title="%s" href="%s">%s</a>',
751
-			'prev-page' . $disable_first,
752
-			esc_attr__( 'Go to the previous page' ),
753
-			esc_url( add_query_arg( $paged_arg_name, max( 1, $current-1 ), $url ) ),
751
+			'prev-page'.$disable_first,
752
+			esc_attr__('Go to the previous page'),
753
+			esc_url(add_query_arg($paged_arg_name, max(1, $current - 1), $url)),
754 754
 			'&lsaquo;'
755 755
 		);
756 756
 
757
-		if ( ! $show_num_field ) {
757
+		if ( ! $show_num_field) {
758 758
 			$html_current_page = $current;
759 759
 		} else {
760
-			$html_current_page = sprintf( "<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />",
761
-				esc_attr__( 'Current page' ),
760
+			$html_current_page = sprintf("<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />",
761
+				esc_attr__('Current page'),
762 762
 				$current,
763
-				strlen( $total_pages )
763
+				strlen($total_pages)
764 764
 			);
765 765
 		}
766 766
 
767 767
 		$html_total_pages = sprintf(
768 768
 			'<span class="total-pages">%s</span>',
769
-			number_format_i18n( $total_pages )
769
+			number_format_i18n($total_pages)
770 770
 		);
771 771
 		$page_links[] = sprintf(
772
-			_x( '%3$s%1$s of %2$s%4$s', 'paging' ),
772
+			_x('%3$s%1$s of %2$s%4$s', 'paging'),
773 773
 			$html_current_page,
774 774
 			$html_total_pages,
775 775
 			'<span class="paging-input">',
@@ -778,29 +778,29 @@  discard block
 block discarded – undo
778 778
 
779 779
 		$page_links[] = sprintf(
780 780
 			'<a class="%s" title="%s" href="%s">%s</a>',
781
-			'next-page' . $disable_last,
782
-			esc_attr__( 'Go to the next page' ),
783
-			esc_url( add_query_arg( $paged_arg_name, min( $total_pages, $current+1 ), $url ) ),
781
+			'next-page'.$disable_last,
782
+			esc_attr__('Go to the next page'),
783
+			esc_url(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)),
784 784
 			'&rsaquo;'
785 785
 		);
786 786
 
787 787
 		$page_links[] = sprintf(
788 788
 			'<a class="%s" title="%s" href="%s">%s</a>',
789
-			'last-page' . $disable_last,
790
-			esc_attr__( 'Go to the last page' ),
791
-			esc_url( add_query_arg( $paged_arg_name, $total_pages, $url ) ),
789
+			'last-page'.$disable_last,
790
+			esc_attr__('Go to the last page'),
791
+			esc_url(add_query_arg($paged_arg_name, $total_pages, $url)),
792 792
 			'&raquo;'
793 793
 		);
794 794
 
795
-		$output .= "\n" . '<span class="pagination-links">' . join( "\n", $page_links ) . '</span>';
795
+		$output .= "\n".'<span class="pagination-links">'.join("\n", $page_links).'</span>';
796 796
 		// set page class
797
-		if ( $total_pages ) {
797
+		if ($total_pages) {
798 798
 			$page_class = $total_pages < 2 ? ' one-page' : '';
799 799
 		} else {
800 800
 			$page_class = ' no-pages';
801 801
 		}
802 802
 
803
-		return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>';
803
+		return '<div class="tablenav"><div class="tablenav-pages'.$page_class.'">'.$output.'</div></div>';
804 804
 	}
805 805
 
806 806
 
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 				return array();
100 100
 			}
101 101
 			if (( $key = array_search( 'global_assets', $espresso_themes )) !== FALSE ) {
102
-			    unset( $espresso_themes[ $key ] );
102
+				unset( $espresso_themes[ $key ] );
103 103
 			}
104 104
 			EEH_Template::$_espresso_themes = array();
105 105
 			foreach ( $espresso_themes as $espresso_theme ) {
@@ -709,9 +709,9 @@  discard block
 block discarded – undo
709 709
 		);
710 710
 
711 711
 		if ( empty( $items_label )
712
-		     || ! is_array( $items_label )
713
-		     || ! isset( $items_label['single'] )
714
-		     || ! isset( $items_label['plural'] ) ) {
712
+			 || ! is_array( $items_label )
713
+			 || ! isset( $items_label['single'] )
714
+			 || ! isset( $items_label['plural'] ) ) {
715 715
 			$items_label = array(
716 716
 				'single' => __( '1 item', 'event_espresso' ),
717 717
 				'plural' => __( '%s items', 'event_espresso' )
Please login to merge, or discard this patch.