Completed
Branch BUG-9548-transaction-completio... (b1c41e)
by
unknown
519:42 queued 503:28
created
public/template_tags.php 2 patches
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -1,19 +1,19 @@
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); }
2 2
 //echo '<br/><h6 style="color:#2EA2CC;">' . __FILE__ . ' &nbsp; <span style="font-weight:normal;color:#E76700"> Line #: ' . __LINE__ . '</span></h6>';
3 3
 /**
4
- * Event Espresso
5
- *
6
- * Event Registration and Ticketing Management Plugin for WordPress
7
- *
8
- * @ package			Event Espresso
9
- * @ author			    Event Espresso
10
- * @ copyright		(c) 2008-2014 Event Espresso  All Rights Reserved.
11
- * @ license			http://eventespresso.com/support/terms-conditions/   * see Plugin Licensing *
12
- * @ link					http://www.eventespresso.com
13
- * @ version		 	$VID:$
14
- *
15
- * ------------------------------------------------------------------------
16
- */
4
+	 * Event Espresso
5
+	 *
6
+	 * Event Registration and Ticketing Management Plugin for WordPress
7
+	 *
8
+	 * @ package			Event Espresso
9
+	 * @ author			    Event Espresso
10
+	 * @ copyright		(c) 2008-2014 Event Espresso  All Rights Reserved.
11
+	 * @ license			http://eventespresso.com/support/terms-conditions/   * see Plugin Licensing *
12
+	 * @ link					http://www.eventespresso.com
13
+	 * @ version		 	$VID:$
14
+	 *
15
+	 * ------------------------------------------------------------------------
16
+	 */
17 17
 
18 18
 
19 19
 
Please login to merge, or discard this patch.
Spacing   +268 added lines, -268 removed lines patch added patch discarded remove patch
@@ -27,12 +27,12 @@  discard block
 block discarded – undo
27 27
  * @param int | \EE_Event $event
28 28
  * @return bool
29 29
  */
30
-function is_espresso_event( $event = NULL ) {
31
-	if ( can_use_espresso_conditionals( __FUNCTION__ )) {
30
+function is_espresso_event($event = NULL) {
31
+	if (can_use_espresso_conditionals(__FUNCTION__)) {
32 32
 		// extract EE_Event object from passed param regardless of what it is (within reason of course)
33
-		$event = EEH_Event_View::get_event( $event );
33
+		$event = EEH_Event_View::get_event($event);
34 34
 		// do we have a valid event ?
35
-		return $event instanceof EE_Event  ? TRUE : FALSE;
35
+		return $event instanceof EE_Event ? TRUE : FALSE;
36 36
 	}
37 37
 	return FALSE;
38 38
 }
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
  * @return bool
45 45
  */
46 46
 function is_espresso_event_single() {
47
-	if ( can_use_espresso_conditionals( __FUNCTION__ )) {
47
+	if (can_use_espresso_conditionals(__FUNCTION__)) {
48 48
 		global $wp_query;
49 49
 		// return conditionals set by CPTs
50 50
 		return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_single : FALSE;
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
  * @return bool
60 60
  */
61 61
 function is_espresso_event_archive() {
62
-	if ( can_use_espresso_conditionals( __FUNCTION__ )) {
62
+	if (can_use_espresso_conditionals(__FUNCTION__)) {
63 63
 		global $wp_query;
64 64
 		return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_archive : FALSE;
65 65
 	}
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
  * @return bool
74 74
  */
75 75
 function is_espresso_event_taxonomy() {
76
-	if ( can_use_espresso_conditionals( __FUNCTION__ )) {
76
+	if (can_use_espresso_conditionals(__FUNCTION__)) {
77 77
 		global $wp_query;
78 78
 		return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_taxonomy : FALSE;
79 79
 	}
@@ -87,10 +87,10 @@  discard block
 block discarded – undo
87 87
  * @param int | \EE_Venue $venue
88 88
  * @return bool
89 89
  */
90
-function is_espresso_venue( $venue = NULL ) {
91
-	if ( can_use_espresso_conditionals( __FUNCTION__ )) {
90
+function is_espresso_venue($venue = NULL) {
91
+	if (can_use_espresso_conditionals(__FUNCTION__)) {
92 92
 		// extract EE_Venue object from passed param regardless of what it is (within reason of course)
93
-		$venue = EEH_Venue_View::get_venue( $venue, FALSE );
93
+		$venue = EEH_Venue_View::get_venue($venue, FALSE);
94 94
 		// do we have a valid event ?
95 95
 		return $venue instanceof EE_Venue ? TRUE : FALSE;
96 96
 	}
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
  * @return bool
105 105
  */
106 106
 function is_espresso_venue_single() {
107
-	if ( can_use_espresso_conditionals( __FUNCTION__ )) {
107
+	if (can_use_espresso_conditionals(__FUNCTION__)) {
108 108
 		global $wp_query;
109 109
 		return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_single : FALSE;
110 110
 	}
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
  * @return bool
119 119
  */
120 120
 function is_espresso_venue_archive() {
121
-	if ( can_use_espresso_conditionals( __FUNCTION__ )) {
121
+	if (can_use_espresso_conditionals(__FUNCTION__)) {
122 122
 		global $wp_query;
123 123
 		return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_archive : FALSE;
124 124
 	}
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
  * @return bool
133 133
  */
134 134
 function is_espresso_venue_taxonomy() {
135
-	if ( can_use_espresso_conditionals( __FUNCTION__ )) {
135
+	if (can_use_espresso_conditionals(__FUNCTION__)) {
136 136
 		global $wp_query;
137 137
 		return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_taxonomy : FALSE;
138 138
 	}
@@ -146,12 +146,12 @@  discard block
 block discarded – undo
146 146
  * @param $conditional_tag
147 147
  * @return bool
148 148
  */
149
-function can_use_espresso_conditionals( $conditional_tag ) {
150
-	if ( ! did_action( 'AHEE__EE_System__initialize' )) {
149
+function can_use_espresso_conditionals($conditional_tag) {
150
+	if ( ! did_action('AHEE__EE_System__initialize')) {
151 151
 		EE_Error::doing_it_wrong(
152 152
 			__FUNCTION__,
153 153
 			sprintf(
154
-				__( 'The "%s" conditional tag can not be used until after the "init" hook has run, but works best when used within a theme\'s template files.','event_espresso'),
154
+				__('The "%s" conditional tag can not be used until after the "init" hook has run, but works best when used within a theme\'s template files.', 'event_espresso'),
155 155
 				$conditional_tag
156 156
 			),
157 157
 			'4.4.0'
@@ -166,13 +166,13 @@  discard block
 block discarded – undo
166 166
 
167 167
 /*************************** Event Queries ***************************/
168 168
 
169
-if ( ! function_exists( 'espresso_get_events' )) {
169
+if ( ! function_exists('espresso_get_events')) {
170 170
 	/**
171 171
 	 * 	espresso_get_events
172 172
 	 * @param array $params
173 173
 	 * @return array
174 174
 	 */
175
-	function espresso_get_events( $params = array() ) {
175
+	function espresso_get_events($params = array()) {
176 176
 		//set default params
177 177
 		$default_espresso_events_params = array(
178 178
 			'limit' => 10,
@@ -183,18 +183,18 @@  discard block
 block discarded – undo
183 183
 			'sort' => 'ASC'
184 184
 		);
185 185
 		// allow the defaults to be filtered
186
-		$default_espresso_events_params = apply_filters( 'espresso_get_events__default_espresso_events_params', $default_espresso_events_params );
186
+		$default_espresso_events_params = apply_filters('espresso_get_events__default_espresso_events_params', $default_espresso_events_params);
187 187
 		// grab params and merge with defaults, then extract
188
-		$params = array_merge( $default_espresso_events_params, $params );
188
+		$params = array_merge($default_espresso_events_params, $params);
189 189
 		// run the query
190
-		$events_query = new EE_Event_List_Query( $params );
190
+		$events_query = new EE_Event_List_Query($params);
191 191
 		// assign results to a variable so we can return it
192 192
 		$events = $events_query->have_posts() ? $events_query->posts : array();
193 193
 		// but first reset the query and postdata
194 194
 		wp_reset_query();
195 195
 		wp_reset_postdata();
196 196
 		EED_Events_Archive::remove_all_events_archive_filters();
197
-		unset( $events_query );
197
+		unset($events_query);
198 198
 		return $events;
199 199
 	}
200 200
 }
@@ -208,32 +208,32 @@  discard block
 block discarded – undo
208 208
  * espresso_load_ticket_selector
209 209
  */
210 210
 function espresso_load_ticket_selector() {
211
-	EE_Registry::instance()->load_file( EE_MODULES . 'ticket_selector', 'EED_Ticket_Selector', 'module' );
211
+	EE_Registry::instance()->load_file(EE_MODULES.'ticket_selector', 'EED_Ticket_Selector', 'module');
212 212
 }
213 213
 
214
-if ( ! function_exists( 'espresso_ticket_selector' )) {
214
+if ( ! function_exists('espresso_ticket_selector')) {
215 215
 	/**
216 216
 	 * espresso_ticket_selector
217 217
 	 * @param null $event
218 218
 	 */
219
-	function espresso_ticket_selector( $event = NULL ) {
220
-		if (  ! apply_filters( 'FHEE_disable_espresso_ticket_selector', FALSE ) ) {
219
+	function espresso_ticket_selector($event = NULL) {
220
+		if ( ! apply_filters('FHEE_disable_espresso_ticket_selector', FALSE)) {
221 221
 			espresso_load_ticket_selector();
222
-			echo EED_Ticket_Selector::display_ticket_selector( $event );
222
+			echo EED_Ticket_Selector::display_ticket_selector($event);
223 223
 		}
224 224
 	}
225 225
 }
226 226
 
227 227
 
228
-	if ( ! function_exists( 'espresso_view_details_btn' )) {
228
+	if ( ! function_exists('espresso_view_details_btn')) {
229 229
 	/**
230 230
 	 * espresso_view_details_btn
231 231
 	 * @param null $event
232 232
 	 */
233
-	function espresso_view_details_btn( $event = NULL ) {
234
-		if (  ! apply_filters( 'FHEE_disable_espresso_view_details_btn', FALSE ) ) {
233
+	function espresso_view_details_btn($event = NULL) {
234
+		if ( ! apply_filters('FHEE_disable_espresso_view_details_btn', FALSE)) {
235 235
 			espresso_load_ticket_selector();
236
-			echo EED_Ticket_Selector::display_ticket_selector( $event, TRUE );
236
+			echo EED_Ticket_Selector::display_ticket_selector($event, TRUE);
237 237
 		}
238 238
 	}
239 239
 }
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 
244 244
 /*************************** EEH_Event_View ***************************/
245 245
 
246
-if ( ! function_exists( 'espresso_load_event_list_assets' )) {
246
+if ( ! function_exists('espresso_load_event_list_assets')) {
247 247
 	/**
248 248
 	 * espresso_load_event_list_assets
249 249
 	 * ensures that event list styles and scripts are loaded
@@ -252,13 +252,13 @@  discard block
 block discarded – undo
252 252
 	 */
253 253
 	function espresso_load_event_list_assets() {
254 254
 		$event_list = EED_Events_Archive::instance();
255
-		add_action( 'AHEE__EE_System__initialize_last', array( $event_list, 'load_event_list_assets' ), 10 );
256
-		add_filter( 'FHEE_enable_default_espresso_css', '__return_true' );
255
+		add_action('AHEE__EE_System__initialize_last', array($event_list, 'load_event_list_assets'), 10);
256
+		add_filter('FHEE_enable_default_espresso_css', '__return_true');
257 257
 	}
258 258
 }
259 259
 
260 260
 
261
-if ( ! function_exists( 'espresso_event_reg_button' )) {
261
+if ( ! function_exists('espresso_event_reg_button')) {
262 262
 	/**
263 263
 	 * espresso_event_reg_button
264 264
 	 * returns the "Register Now" button if event is active,
@@ -270,9 +270,9 @@  discard block
 block discarded – undo
270 270
 	 * @param bool $EVT_ID
271 271
 	 * @return string
272 272
 	 */
273
-	function espresso_event_reg_button( $btn_text_if_active = NULL, $btn_text_if_inactive = FALSE, $EVT_ID = FALSE ) {
274
-		$event_status = EEH_Event_View::event_active_status( $EVT_ID );
275
-		switch ( $event_status ) {
273
+	function espresso_event_reg_button($btn_text_if_active = NULL, $btn_text_if_inactive = FALSE, $EVT_ID = FALSE) {
274
+		$event_status = EEH_Event_View::event_active_status($EVT_ID);
275
+		switch ($event_status) {
276 276
 			case EE_Datetime::sold_out :
277 277
 				$btn_text = __('Sold Out', 'event_espresso');
278 278
 				$class = 'ee-pink';
@@ -288,10 +288,10 @@  discard block
 block discarded – undo
288 288
 			case EE_Datetime::upcoming :
289 289
 			case EE_Datetime::active :
290 290
 			default :
291
-				$btn_text =! empty( $btn_text_if_active ) ? $btn_text_if_active : __( 'Register Now', 'event_espresso' );
291
+				$btn_text = ! empty($btn_text_if_active) ? $btn_text_if_active : __('Register Now', 'event_espresso');
292 292
 				$class = 'ee-green';
293 293
 		}
294
-		if ( $event_status < 1 && ! empty( $btn_text_if_inactive )) {
294
+		if ($event_status < 1 && ! empty($btn_text_if_inactive)) {
295 295
 			$btn_text = $btn_text_if_inactive;
296 296
 			$class = 'ee-grey';
297 297
 		}
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
 
306 306
 
307 307
 
308
-if ( ! function_exists( 'espresso_display_ticket_selector' )) {
308
+if ( ! function_exists('espresso_display_ticket_selector')) {
309 309
 	/**
310 310
 	 * espresso_display_ticket_selector
311 311
 	 * whether or not to display the Ticket Selector for an event
@@ -313,14 +313,14 @@  discard block
 block discarded – undo
313 313
 	 * @param bool $EVT_ID
314 314
 	 * @return boolean
315 315
 	 */
316
-	function espresso_display_ticket_selector( $EVT_ID = FALSE ) {
317
-		return EEH_Event_View::display_ticket_selector( $EVT_ID );
316
+	function espresso_display_ticket_selector($EVT_ID = FALSE) {
317
+		return EEH_Event_View::display_ticket_selector($EVT_ID);
318 318
 	}
319 319
 }
320 320
 
321 321
 
322 322
 
323
-if ( ! function_exists( 'espresso_event_status_banner' )) {
323
+if ( ! function_exists('espresso_event_status_banner')) {
324 324
 	/**
325 325
 	 * espresso_event_status
326 326
 	 * returns a banner showing the event status if it is sold out, expired, or inactive
@@ -328,13 +328,13 @@  discard block
 block discarded – undo
328 328
 	 * @param bool $EVT_ID
329 329
 	 * @return string
330 330
 	 */
331
-	function espresso_event_status_banner( $EVT_ID = FALSE ) {
332
-		return EEH_Event_View::event_status( $EVT_ID );
331
+	function espresso_event_status_banner($EVT_ID = FALSE) {
332
+		return EEH_Event_View::event_status($EVT_ID);
333 333
 	}
334 334
 }
335 335
 
336 336
 
337
-if ( ! function_exists( 'espresso_event_status' )) {
337
+if ( ! function_exists('espresso_event_status')) {
338 338
 	/**
339 339
 	 * espresso_event_status
340 340
 	 * returns the event status if it is sold out, expired, or inactive
@@ -343,17 +343,17 @@  discard block
 block discarded – undo
343 343
 	 * @param bool $echo
344 344
 	 * @return string
345 345
 	 */
346
-	function espresso_event_status( $EVT_ID = 0, $echo = TRUE ) {
347
-		if ( $echo ) {
348
-			echo EEH_Event_View::event_active_status( $EVT_ID );
346
+	function espresso_event_status($EVT_ID = 0, $echo = TRUE) {
347
+		if ($echo) {
348
+			echo EEH_Event_View::event_active_status($EVT_ID);
349 349
 			return '';
350 350
 		}
351
-		return EEH_Event_View::event_active_status( $EVT_ID );
351
+		return EEH_Event_View::event_active_status($EVT_ID);
352 352
 	}
353 353
 }
354 354
 
355 355
 
356
-if ( ! function_exists( 'espresso_event_categories' )) {
356
+if ( ! function_exists('espresso_event_categories')) {
357 357
 	/**
358 358
 	 * espresso_event_categories
359 359
 	 * returns the terms associated with an event
@@ -363,17 +363,17 @@  discard block
 block discarded – undo
363 363
 	 * @param bool $echo
364 364
 	 * @return string
365 365
 	 */
366
-	function espresso_event_categories( $EVT_ID = 0, $hide_uncategorized = TRUE, $echo = TRUE ) {
367
-		if ( $echo ) {
368
-			echo EEH_Event_View::event_categories( $EVT_ID, $hide_uncategorized );
366
+	function espresso_event_categories($EVT_ID = 0, $hide_uncategorized = TRUE, $echo = TRUE) {
367
+		if ($echo) {
368
+			echo EEH_Event_View::event_categories($EVT_ID, $hide_uncategorized);
369 369
 			return '';
370 370
 		}
371
-		return EEH_Event_View::event_categories( $EVT_ID, $hide_uncategorized );
371
+		return EEH_Event_View::event_categories($EVT_ID, $hide_uncategorized);
372 372
 	}
373 373
 }
374 374
 
375 375
 
376
-if ( ! function_exists( 'espresso_event_tickets_available' )) {
376
+if ( ! function_exists('espresso_event_tickets_available')) {
377 377
 	/**
378 378
 	 * espresso_event_tickets_available
379 379
 	 * returns the ticket types available for purchase for an event
@@ -383,26 +383,26 @@  discard block
 block discarded – undo
383 383
 	 * @param bool $format
384 384
 	 * @return string
385 385
 	 */
386
-	function espresso_event_tickets_available( $EVT_ID = 0, $echo = TRUE, $format = TRUE ) {
387
-		$tickets = EEH_Event_View::event_tickets_available( $EVT_ID );
388
-		if ( is_array( $tickets ) && ! empty( $tickets )) {
386
+	function espresso_event_tickets_available($EVT_ID = 0, $echo = TRUE, $format = TRUE) {
387
+		$tickets = EEH_Event_View::event_tickets_available($EVT_ID);
388
+		if (is_array($tickets) && ! empty($tickets)) {
389 389
 			// if formatting then $html will be a string, else it will be an array of ticket objects
390
-			$html = $format ? '<ul id="ee-event-tickets-ul-' . $EVT_ID . '" class="ee-event-tickets-ul">' : array();
391
-			foreach ( $tickets as $ticket ) {
392
-				if ( $ticket instanceof EE_Ticket ) {
393
-					if ( $format ) {
394
-						$html .= '<li id="ee-event-tickets-li-' . $ticket->ID() . '" class="ee-event-tickets-li">';
395
-						$html .= $ticket->name() . ' ' . EEH_Template::format_currency( $ticket->get_ticket_total_with_taxes() );
390
+			$html = $format ? '<ul id="ee-event-tickets-ul-'.$EVT_ID.'" class="ee-event-tickets-ul">' : array();
391
+			foreach ($tickets as $ticket) {
392
+				if ($ticket instanceof EE_Ticket) {
393
+					if ($format) {
394
+						$html .= '<li id="ee-event-tickets-li-'.$ticket->ID().'" class="ee-event-tickets-li">';
395
+						$html .= $ticket->name().' '.EEH_Template::format_currency($ticket->get_ticket_total_with_taxes());
396 396
 						$html .= '</li>';
397 397
 					} else {
398 398
 						$html[] = $ticket;
399 399
 					}
400 400
 				}
401 401
 			}
402
-			if ( $format ) {
402
+			if ($format) {
403 403
 				$html .= '</ul>';
404 404
 			}
405
-			if ( $echo && ! $format ) {
405
+			if ($echo && ! $format) {
406 406
 				echo $html;
407 407
 				return '';
408 408
 			}
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
 	}
413 413
 }
414 414
 
415
-if ( ! function_exists( 'espresso_event_date_obj' )) {
415
+if ( ! function_exists('espresso_event_date_obj')) {
416 416
 	/**
417 417
 	 * espresso_event_date_obj
418 418
 	 * returns the primary date object for an event
@@ -420,13 +420,13 @@  discard block
 block discarded – undo
420 420
 	 * @param bool $EVT_ID
421 421
 	 * @return object
422 422
 	 */
423
-	function espresso_event_date_obj( $EVT_ID = FALSE ) {
424
-		return EEH_Event_View::get_primary_date_obj( $EVT_ID );
423
+	function espresso_event_date_obj($EVT_ID = FALSE) {
424
+		return EEH_Event_View::get_primary_date_obj($EVT_ID);
425 425
 	}
426 426
 }
427 427
 
428 428
 
429
-if ( ! function_exists( 'espresso_event_date' )) {
429
+if ( ! function_exists('espresso_event_date')) {
430 430
 	/**
431 431
 	 * espresso_event_date
432 432
 	 * returns the primary date for an event
@@ -437,22 +437,22 @@  discard block
 block discarded – undo
437 437
 	 * @param bool $echo
438 438
 	 * @return string
439 439
 	 */
440
-	function espresso_event_date( $date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE ) {
441
-		$date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' );
442
-		$time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' );
443
-		$date_format = apply_filters( 'FHEE__espresso_event_date__date_format', $date_format );
444
-		$time_format = apply_filters( 'FHEE__espresso_event_date__time_format', $time_format );
445
-		if($echo){
446
-			echo EEH_Event_View::the_event_date( $date_format, $time_format, $EVT_ID );
440
+	function espresso_event_date($date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE) {
441
+		$date_format = ! empty($date_format) ? $date_format : get_option('date_format');
442
+		$time_format = ! empty($time_format) ? $time_format : get_option('time_format');
443
+		$date_format = apply_filters('FHEE__espresso_event_date__date_format', $date_format);
444
+		$time_format = apply_filters('FHEE__espresso_event_date__time_format', $time_format);
445
+		if ($echo) {
446
+			echo EEH_Event_View::the_event_date($date_format, $time_format, $EVT_ID);
447 447
 			return '';
448 448
 		}
449
-		return EEH_Event_View::the_event_date( $date_format, $time_format, $EVT_ID );
449
+		return EEH_Event_View::the_event_date($date_format, $time_format, $EVT_ID);
450 450
 
451 451
 	}
452 452
 }
453 453
 
454 454
 
455
-if ( ! function_exists( 'espresso_list_of_event_dates' )) {
455
+if ( ! function_exists('espresso_list_of_event_dates')) {
456 456
 	/**
457 457
 	 * espresso_list_of_event_dates
458 458
 	 * returns a unordered list of dates for an event
@@ -467,40 +467,40 @@  discard block
 block discarded – undo
467 467
 	 * @param null   $limit
468 468
 	 * @return string
469 469
 	 */
470
-	function espresso_list_of_event_dates( $EVT_ID = 0, $date_format = '', $time_format = '', $echo = TRUE, $show_expired = NULL, $format = TRUE, $add_breaks = TRUE, $limit = NULL ) {
471
-		$date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' );
472
-		$time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' );
473
-		$date_format = apply_filters( 'FHEE__espresso_list_of_event_dates__date_format', $date_format );
474
-		$time_format = apply_filters( 'FHEE__espresso_list_of_event_dates__time_format', $time_format );
475
-		$datetimes = EEH_Event_View::get_all_date_obj( $EVT_ID, $show_expired, FALSE, $limit );
476
-		if ( ! $format ) {
477
-			return apply_filters( 'FHEE__espresso_list_of_event_dates__datetimes', $datetimes );
470
+	function espresso_list_of_event_dates($EVT_ID = 0, $date_format = '', $time_format = '', $echo = TRUE, $show_expired = NULL, $format = TRUE, $add_breaks = TRUE, $limit = NULL) {
471
+		$date_format = ! empty($date_format) ? $date_format : get_option('date_format');
472
+		$time_format = ! empty($time_format) ? $time_format : get_option('time_format');
473
+		$date_format = apply_filters('FHEE__espresso_list_of_event_dates__date_format', $date_format);
474
+		$time_format = apply_filters('FHEE__espresso_list_of_event_dates__time_format', $time_format);
475
+		$datetimes = EEH_Event_View::get_all_date_obj($EVT_ID, $show_expired, FALSE, $limit);
476
+		if ( ! $format) {
477
+			return apply_filters('FHEE__espresso_list_of_event_dates__datetimes', $datetimes);
478 478
 		}
479 479
 		//d( $datetimes );
480
-		if ( is_array( $datetimes ) && ! empty( $datetimes )) {
480
+		if (is_array($datetimes) && ! empty($datetimes)) {
481 481
 			global $post;
482
-			$html = $format ? '<ul id="ee-event-datetimes-ul-' . $post->ID . '" class="ee-event-datetimes-ul">' : '';
483
-			foreach ( $datetimes as $datetime ) {
484
-				if ( $datetime instanceof EE_Datetime ) {
485
-					$html .= '<li id="ee-event-datetimes-li-' . $datetime->ID();
486
-					$html .= '" class="ee-event-datetimes-li ee-event-datetimes-li-' . $datetime->get_active_status() . '">';
482
+			$html = $format ? '<ul id="ee-event-datetimes-ul-'.$post->ID.'" class="ee-event-datetimes-ul">' : '';
483
+			foreach ($datetimes as $datetime) {
484
+				if ($datetime instanceof EE_Datetime) {
485
+					$html .= '<li id="ee-event-datetimes-li-'.$datetime->ID();
486
+					$html .= '" class="ee-event-datetimes-li ee-event-datetimes-li-'.$datetime->get_active_status().'">';
487 487
 					$datetime_name = $datetime->name();
488
-					$html .= ! empty( $datetime_name ) ? '<strong>' . $datetime_name . '</strong>' : '';
489
-					$html .= ! empty( $datetime_name )  && $add_breaks ? '<br />' : '';
490
-					$html .= '<span class="dashicons dashicons-calendar"></span>' . $datetime->date_range( $date_format ) . '<br/>';
491
-					$html .= '<span class="dashicons dashicons-clock"></span>' . $datetime->time_range( $time_format );
488
+					$html .= ! empty($datetime_name) ? '<strong>'.$datetime_name.'</strong>' : '';
489
+					$html .= ! empty($datetime_name) && $add_breaks ? '<br />' : '';
490
+					$html .= '<span class="dashicons dashicons-calendar"></span>'.$datetime->date_range($date_format).'<br/>';
491
+					$html .= '<span class="dashicons dashicons-clock"></span>'.$datetime->time_range($time_format);
492 492
 					$datetime_description = $datetime->description();
493
-					$html .= ! empty( $datetime_description )  && $add_breaks ? '<br />' : '';
494
-					$html .= ! empty( $datetime_description ) ? ' - ' . $datetime_description : '';
495
-					$html = apply_filters( 'FHEE__espresso_list_of_event_dates__datetime_html', $html, $datetime );
493
+					$html .= ! empty($datetime_description) && $add_breaks ? '<br />' : '';
494
+					$html .= ! empty($datetime_description) ? ' - '.$datetime_description : '';
495
+					$html = apply_filters('FHEE__espresso_list_of_event_dates__datetime_html', $html, $datetime);
496 496
 					$html .= '</li>';
497 497
 				}
498 498
 			}
499 499
 			$html .= $format ? '</ul>' : '';
500 500
 		} else {
501
-			$html = $format ?  '<p><span class="dashicons dashicons-marker pink-text"></span>' . __( 'There are no upcoming dates for this event.', 'event_espresso' ) . '</p><br/>' : '';
501
+			$html = $format ? '<p><span class="dashicons dashicons-marker pink-text"></span>'.__('There are no upcoming dates for this event.', 'event_espresso').'</p><br/>' : '';
502 502
 		}
503
-		if ( $echo ) {
503
+		if ($echo) {
504 504
 			echo $html;
505 505
 			return '';
506 506
 		}
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
 }
510 510
 
511 511
 
512
-if ( ! function_exists( 'espresso_event_end_date' )) {
512
+if ( ! function_exists('espresso_event_end_date')) {
513 513
 	/**
514 514
 	 * espresso_event_end_date
515 515
 	 * returns the last date for an event
@@ -520,20 +520,20 @@  discard block
 block discarded – undo
520 520
 	 * @param bool   $echo
521 521
 	 * @return string
522 522
 	 */
523
-	function espresso_event_end_date( $date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE ) {
524
-		$date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' );
525
-		$time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' );
526
-		$date_format = apply_filters( 'FHEE__espresso_event_end_date__date_format', $date_format );
527
-		$time_format = apply_filters( 'FHEE__espresso_event_end_date__time_format', $time_format );
528
-		if($echo){
529
-			echo EEH_Event_View::the_event_end_date( $date_format, $time_format, $EVT_ID );
523
+	function espresso_event_end_date($date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE) {
524
+		$date_format = ! empty($date_format) ? $date_format : get_option('date_format');
525
+		$time_format = ! empty($time_format) ? $time_format : get_option('time_format');
526
+		$date_format = apply_filters('FHEE__espresso_event_end_date__date_format', $date_format);
527
+		$time_format = apply_filters('FHEE__espresso_event_end_date__time_format', $time_format);
528
+		if ($echo) {
529
+			echo EEH_Event_View::the_event_end_date($date_format, $time_format, $EVT_ID);
530 530
 			return '';
531 531
 		}
532
-		return EEH_Event_View::the_event_end_date( $date_format, $time_format, $EVT_ID );
532
+		return EEH_Event_View::the_event_end_date($date_format, $time_format, $EVT_ID);
533 533
 	}
534 534
 }
535 535
 
536
-if ( ! function_exists( 'espresso_event_date_range' )) {
536
+if ( ! function_exists('espresso_event_date_range')) {
537 537
 	/**
538 538
 	 * espresso_event_date_range
539 539
 	 * returns the first and last chronologically ordered dates for an event (if different)
@@ -545,31 +545,31 @@  discard block
 block discarded – undo
545 545
 	 * @param bool   $EVT_ID
546 546
 	 * @return string
547 547
 	 */
548
-	function espresso_event_date_range( $date_format = '', $time_format = '', $single_date_format = '', $single_time_format = '', $EVT_ID = FALSE, $echo = TRUE ) {
548
+	function espresso_event_date_range($date_format = '', $time_format = '', $single_date_format = '', $single_time_format = '', $EVT_ID = FALSE, $echo = TRUE) {
549 549
 		// set and filter date and time formats when a range is returned
550
-		$date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' );
551
-		$date_format = apply_filters( 'FHEE__espresso_event_date_range__date_format', $date_format );
550
+		$date_format = ! empty($date_format) ? $date_format : get_option('date_format');
551
+		$date_format = apply_filters('FHEE__espresso_event_date_range__date_format', $date_format);
552 552
 		// get the start and end date with NO time portion
553
-		$the_event_date = EEH_Event_View::the_earliest_event_date( $date_format, '', $EVT_ID );
554
-		$the_event_end_date = EEH_Event_View::the_latest_event_date( $date_format, '', $EVT_ID );
553
+		$the_event_date = EEH_Event_View::the_earliest_event_date($date_format, '', $EVT_ID);
554
+		$the_event_end_date = EEH_Event_View::the_latest_event_date($date_format, '', $EVT_ID);
555 555
 		// now we can determine if date range spans more than one day
556
-		if ( $the_event_date != $the_event_end_date ) {
557
-			$time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' );
558
-			$time_format = apply_filters( 'FHEE__espresso_event_date_range__time_format', $time_format );
556
+		if ($the_event_date != $the_event_end_date) {
557
+			$time_format = ! empty($time_format) ? $time_format : get_option('time_format');
558
+			$time_format = apply_filters('FHEE__espresso_event_date_range__time_format', $time_format);
559 559
 			$html = sprintf(
560
-				__( '%1$s - %2$s', 'event_espresso' ),
561
-				EEH_Event_View::the_earliest_event_date( $date_format, $time_format, $EVT_ID ),
562
-				EEH_Event_View::the_latest_event_date( $date_format, $time_format, $EVT_ID )
560
+				__('%1$s - %2$s', 'event_espresso'),
561
+				EEH_Event_View::the_earliest_event_date($date_format, $time_format, $EVT_ID),
562
+				EEH_Event_View::the_latest_event_date($date_format, $time_format, $EVT_ID)
563 563
 			);
564 564
 		} else {
565 565
 			// set and filter date and time formats when only a single datetime is returned
566
-			$single_date_format = ! empty( $single_date_format ) ? $single_date_format : get_option( 'date_format' );
567
-			$single_time_format = ! empty( $single_time_format ) ? $single_time_format : get_option( 'time_format' );
568
-			$single_date_format = apply_filters( 'FHEE__espresso_event_date_range__single_date_format', $single_date_format );
569
-			$single_time_format = apply_filters( 'FHEE__espresso_event_date_range__single_time_format', $single_time_format );
570
-			$html = EEH_Event_View::the_earliest_event_date( $single_date_format, $single_time_format, $EVT_ID );
566
+			$single_date_format = ! empty($single_date_format) ? $single_date_format : get_option('date_format');
567
+			$single_time_format = ! empty($single_time_format) ? $single_time_format : get_option('time_format');
568
+			$single_date_format = apply_filters('FHEE__espresso_event_date_range__single_date_format', $single_date_format);
569
+			$single_time_format = apply_filters('FHEE__espresso_event_date_range__single_time_format', $single_time_format);
570
+			$html = EEH_Event_View::the_earliest_event_date($single_date_format, $single_time_format, $EVT_ID);
571 571
 		}
572
-		if ( $echo ) {
572
+		if ($echo) {
573 573
 			echo $html;
574 574
 			return '';
575 575
 		}
@@ -578,7 +578,7 @@  discard block
 block discarded – undo
578 578
 }
579 579
 
580 580
 
581
-if ( ! function_exists( 'espresso_event_date_as_calendar_page' )) {
581
+if ( ! function_exists('espresso_event_date_as_calendar_page')) {
582 582
 	/**
583 583
 	 * espresso_event_date_as_calendar_page
584 584
 	 * returns the primary date for an event, stylized to appear as the page of a calendar
@@ -586,15 +586,15 @@  discard block
 block discarded – undo
586 586
 	 * @param bool $EVT_ID
587 587
 	 * @return string
588 588
 	 */
589
-	function espresso_event_date_as_calendar_page( $EVT_ID = FALSE ) {
590
-		EEH_Event_View::event_date_as_calendar_page( $EVT_ID );
589
+	function espresso_event_date_as_calendar_page($EVT_ID = FALSE) {
590
+		EEH_Event_View::event_date_as_calendar_page($EVT_ID);
591 591
 	}
592 592
 }
593 593
 
594 594
 
595 595
 
596 596
 
597
-if ( ! function_exists( 'espresso_event_link_url' )) {
597
+if ( ! function_exists('espresso_event_link_url')) {
598 598
 	/**
599 599
 	 * espresso_event_link_url
600 600
 	 *
@@ -602,18 +602,18 @@  discard block
 block discarded – undo
602 602
 	 * @param bool $echo
603 603
 	 * @return string
604 604
 	 */
605
-	function espresso_event_link_url( $EVT_ID = 0, $echo = TRUE ) {
606
-		if ( $echo ) {
607
-			echo EEH_Event_View::event_link_url( $EVT_ID );
605
+	function espresso_event_link_url($EVT_ID = 0, $echo = TRUE) {
606
+		if ($echo) {
607
+			echo EEH_Event_View::event_link_url($EVT_ID);
608 608
 			return '';
609 609
 		}
610
-		return EEH_Event_View::event_link_url( $EVT_ID );
610
+		return EEH_Event_View::event_link_url($EVT_ID);
611 611
 	}
612 612
 }
613 613
 
614 614
 
615 615
 
616
-if ( ! function_exists( 'espresso_event_has_content_or_excerpt' )) {
616
+if ( ! function_exists('espresso_event_has_content_or_excerpt')) {
617 617
 	/**
618 618
 	 *    espresso_event_has_content_or_excerpt
619 619
 	 *
@@ -621,15 +621,15 @@  discard block
 block discarded – undo
621 621
 	 * @param bool $EVT_ID
622 622
 	 * @return    boolean
623 623
 	 */
624
-	function espresso_event_has_content_or_excerpt( $EVT_ID = FALSE ) {
625
-		return EEH_Event_View::event_has_content_or_excerpt( $EVT_ID );
624
+	function espresso_event_has_content_or_excerpt($EVT_ID = FALSE) {
625
+		return EEH_Event_View::event_has_content_or_excerpt($EVT_ID);
626 626
 	}
627 627
 }
628 628
 
629 629
 
630 630
 
631 631
 
632
-if ( ! function_exists( 'espresso_event_content_or_excerpt' )) {
632
+if ( ! function_exists('espresso_event_content_or_excerpt')) {
633 633
 	/**
634 634
 	 * espresso_event_content_or_excerpt
635 635
 	 *
@@ -638,18 +638,18 @@  discard block
 block discarded – undo
638 638
 	 * @param bool $echo
639 639
 	 * @return string
640 640
 	 */
641
-	function espresso_event_content_or_excerpt( $num_words = 55, $more = NULL, $echo = TRUE ) {
642
-		if ( $echo ) {
643
-			echo EEH_Event_View::event_content_or_excerpt( $num_words, $more );
641
+	function espresso_event_content_or_excerpt($num_words = 55, $more = NULL, $echo = TRUE) {
642
+		if ($echo) {
643
+			echo EEH_Event_View::event_content_or_excerpt($num_words, $more);
644 644
 			return '';
645 645
 		}
646
-		return EEH_Event_View::event_content_or_excerpt( $num_words, $more );
646
+		return EEH_Event_View::event_content_or_excerpt($num_words, $more);
647 647
 	}
648 648
 }
649 649
 
650 650
 
651 651
 
652
-if ( ! function_exists( 'espresso_event_phone' )) {
652
+if ( ! function_exists('espresso_event_phone')) {
653 653
 	/**
654 654
 	 * espresso_event_phone
655 655
 	 *
@@ -657,18 +657,18 @@  discard block
 block discarded – undo
657 657
 	 * @param bool $echo
658 658
 	 * @return string
659 659
 	 */
660
-	function espresso_event_phone( $EVT_ID = 0, $echo = TRUE ) {
661
-		if ( $echo ) {
662
-			echo EEH_Event_View::event_phone( $EVT_ID );
660
+	function espresso_event_phone($EVT_ID = 0, $echo = TRUE) {
661
+		if ($echo) {
662
+			echo EEH_Event_View::event_phone($EVT_ID);
663 663
 			return '';
664 664
 		}
665
-		return EEH_Event_View::event_phone( $EVT_ID );
665
+		return EEH_Event_View::event_phone($EVT_ID);
666 666
 	}
667 667
 }
668 668
 
669 669
 
670 670
 
671
-if ( ! function_exists( 'espresso_edit_event_link' )) {
671
+if ( ! function_exists('espresso_edit_event_link')) {
672 672
 	/**
673 673
 	 * espresso_edit_event_link
674 674
 	 * returns a link to edit an event
@@ -677,39 +677,39 @@  discard block
 block discarded – undo
677 677
 	 * @param bool $echo
678 678
 	 * @return string
679 679
 	 */
680
-	function espresso_edit_event_link( $EVT_ID = 0, $echo = TRUE ) {
681
-		if ( $echo ) {
682
-			echo EEH_Event_View::edit_event_link( $EVT_ID );
680
+	function espresso_edit_event_link($EVT_ID = 0, $echo = TRUE) {
681
+		if ($echo) {
682
+			echo EEH_Event_View::edit_event_link($EVT_ID);
683 683
 			return '';
684 684
 		}
685
-		return EEH_Event_View::edit_event_link( $EVT_ID );
685
+		return EEH_Event_View::edit_event_link($EVT_ID);
686 686
 	}
687 687
 }
688 688
 
689 689
 
690
-if ( ! function_exists( 'espresso_organization_name' )) {
690
+if ( ! function_exists('espresso_organization_name')) {
691 691
 	/**
692 692
 	 * espresso_organization_name
693 693
 	 * @param bool $echo
694 694
 	 * @return string
695 695
 	 */
696 696
 	function espresso_organization_name($echo = TRUE) {
697
-		if($echo){
698
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'name' );
697
+		if ($echo) {
698
+			echo EE_Registry::instance()->CFG->organization->get_pretty('name');
699 699
 			return '';
700 700
 		}
701
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'name' );
701
+		return EE_Registry::instance()->CFG->organization->get_pretty('name');
702 702
 	}
703 703
 }
704 704
 
705
-if ( ! function_exists( 'espresso_organization_address' )) {
705
+if ( ! function_exists('espresso_organization_address')) {
706 706
 	/**
707 707
 	 * espresso_organization_address
708 708
 	 * @param string $type
709 709
 	 * @return string
710 710
 	 */
711
-	function espresso_organization_address( $type = 'inline' ) {
712
-		if ( EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config ) {
711
+	function espresso_organization_address($type = 'inline') {
712
+		if (EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config) {
713 713
 			$address = new EventEspresso\core\entities\GenericAddress(
714 714
 				EE_Registry::instance()->CFG->organization->address_1,
715 715
 				EE_Registry::instance()->CFG->organization->address_2,
@@ -718,129 +718,129 @@  discard block
 block discarded – undo
718 718
 				EE_Registry::instance()->CFG->organization->zip,
719 719
 				EE_Registry::instance()->CFG->organization->CNT_ISO
720 720
 			);
721
-			return EEH_Address::format( $address, $type );
721
+			return EEH_Address::format($address, $type);
722 722
 		}
723 723
 		return '';
724 724
 	}
725 725
 }
726 726
 
727
-if ( ! function_exists( 'espresso_organization_email' )) {
727
+if ( ! function_exists('espresso_organization_email')) {
728 728
 	/**
729 729
 	 * espresso_organization_email
730 730
 	 * @param bool $echo
731 731
 	 * @return string
732 732
 	 */
733
-	function espresso_organization_email( $echo = TRUE ) {
734
-		if($echo){
735
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'email' );
733
+	function espresso_organization_email($echo = TRUE) {
734
+		if ($echo) {
735
+			echo EE_Registry::instance()->CFG->organization->get_pretty('email');
736 736
 			return '';
737 737
 		}
738
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'email' );
738
+		return EE_Registry::instance()->CFG->organization->get_pretty('email');
739 739
 	}
740 740
 }
741 741
 
742
-if ( ! function_exists( 'espresso_organization_logo_url' )) {
742
+if ( ! function_exists('espresso_organization_logo_url')) {
743 743
 	/**
744 744
 	 * espresso_organization_logo_url
745 745
 	 * @param bool $echo
746 746
 	 * @return string
747 747
 	 */
748
-	function espresso_organization_logo_url( $echo = TRUE ) {
749
-		if($echo){
750
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'logo_url' );
748
+	function espresso_organization_logo_url($echo = TRUE) {
749
+		if ($echo) {
750
+			echo EE_Registry::instance()->CFG->organization->get_pretty('logo_url');
751 751
 			return '';
752 752
 		}
753
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'logo_url' );
753
+		return EE_Registry::instance()->CFG->organization->get_pretty('logo_url');
754 754
 	}
755 755
 }
756 756
 
757
-if ( ! function_exists( 'espresso_organization_facebook' )) {
757
+if ( ! function_exists('espresso_organization_facebook')) {
758 758
 	/**
759 759
 	 * espresso_organization_facebook
760 760
 	 * @param bool $echo
761 761
 	 * @return string
762 762
 	 */
763
-	function espresso_organization_facebook( $echo = TRUE ) {
764
-		if($echo){
765
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'facebook' );
763
+	function espresso_organization_facebook($echo = TRUE) {
764
+		if ($echo) {
765
+			echo EE_Registry::instance()->CFG->organization->get_pretty('facebook');
766 766
 			return '';
767 767
 		}
768
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'facebook' );
768
+		return EE_Registry::instance()->CFG->organization->get_pretty('facebook');
769 769
 	}
770 770
 }
771 771
 
772
-if ( ! function_exists( 'espresso_organization_twitter' )) {
772
+if ( ! function_exists('espresso_organization_twitter')) {
773 773
 	/**
774 774
 	 * espresso_organization_twitter
775 775
 	 * @param bool $echo
776 776
 	 * @return string
777 777
 	 */
778
-	function espresso_organization_twitter( $echo = TRUE ) {
779
-		if($echo){
780
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'twitter' );
778
+	function espresso_organization_twitter($echo = TRUE) {
779
+		if ($echo) {
780
+			echo EE_Registry::instance()->CFG->organization->get_pretty('twitter');
781 781
 			return '';
782 782
 		}
783
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'twitter' );
783
+		return EE_Registry::instance()->CFG->organization->get_pretty('twitter');
784 784
 	}
785 785
 }
786 786
 
787
-if ( ! function_exists( 'espresso_organization_linkedin' )) {
787
+if ( ! function_exists('espresso_organization_linkedin')) {
788 788
 	/**
789 789
 	 * espresso_organization_linkedin
790 790
 	 * @param bool $echo
791 791
 	 * @return string
792 792
 	 */
793
-	function espresso_organization_linkedin( $echo = TRUE ) {
794
-		if($echo){
795
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'linkedin' );
793
+	function espresso_organization_linkedin($echo = TRUE) {
794
+		if ($echo) {
795
+			echo EE_Registry::instance()->CFG->organization->get_pretty('linkedin');
796 796
 			return '';
797 797
 		}
798
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'linkedin' );
798
+		return EE_Registry::instance()->CFG->organization->get_pretty('linkedin');
799 799
 	}
800 800
 }
801 801
 
802
-if ( ! function_exists( 'espresso_organization_pinterest' )) {
802
+if ( ! function_exists('espresso_organization_pinterest')) {
803 803
 	/**
804 804
 	 * espresso_organization_pinterest
805 805
 	 * @param bool $echo
806 806
 	 * @return string
807 807
 	 */
808
-	function espresso_organization_pinterest( $echo = TRUE ) {
809
-		if($echo){
810
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'pinterest' );
808
+	function espresso_organization_pinterest($echo = TRUE) {
809
+		if ($echo) {
810
+			echo EE_Registry::instance()->CFG->organization->get_pretty('pinterest');
811 811
 			return '';
812 812
 		}
813
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'pinterest' );
813
+		return EE_Registry::instance()->CFG->organization->get_pretty('pinterest');
814 814
 	}
815 815
 }
816 816
 
817
-if ( ! function_exists( 'espresso_organization_google' )) {
817
+if ( ! function_exists('espresso_organization_google')) {
818 818
 	/**
819 819
 	 * espresso_organization_google
820 820
 	 * @param bool $echo
821 821
 	 * @return string
822 822
 	 */
823
-	function espresso_organization_google( $echo = TRUE ) {
824
-		if($echo){
825
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'google' );
823
+	function espresso_organization_google($echo = TRUE) {
824
+		if ($echo) {
825
+			echo EE_Registry::instance()->CFG->organization->get_pretty('google');
826 826
 			return '';
827 827
 		}
828
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'google' );
828
+		return EE_Registry::instance()->CFG->organization->get_pretty('google');
829 829
 	}
830 830
 }
831 831
 
832
-if ( ! function_exists( 'espresso_organization_instagram' )) {
832
+if ( ! function_exists('espresso_organization_instagram')) {
833 833
 	/**
834 834
 	 * espresso_organization_instagram
835 835
 	 * @param bool $echo
836 836
 	 * @return string
837 837
 	 */
838
-	function espresso_organization_instagram( $echo = TRUE ) {
839
-		if($echo){
840
-			echo EE_Registry::instance()->CFG->organization->get_pretty( 'instagram' );
838
+	function espresso_organization_instagram($echo = TRUE) {
839
+		if ($echo) {
840
+			echo EE_Registry::instance()->CFG->organization->get_pretty('instagram');
841 841
 			return '';
842 842
 		}
843
-		return EE_Registry::instance()->CFG->organization->get_pretty( 'instagram' );
843
+		return EE_Registry::instance()->CFG->organization->get_pretty('instagram');
844 844
 	}
845 845
 }
846 846
 
@@ -850,7 +850,7 @@  discard block
 block discarded – undo
850 850
 
851 851
 
852 852
 
853
-if ( ! function_exists( 'espresso_event_venues' )) {
853
+if ( ! function_exists('espresso_event_venues')) {
854 854
 	/**
855 855
 	 * espresso_event_venues
856 856
 	 *
@@ -864,7 +864,7 @@  discard block
 block discarded – undo
864 864
 
865 865
 
866 866
 
867
-if ( ! function_exists( 'espresso_venue_id' )) {
867
+if ( ! function_exists('espresso_venue_id')) {
868 868
 	/**
869 869
 	 *    espresso_venue_name
870 870
 	 *
@@ -872,15 +872,15 @@  discard block
 block discarded – undo
872 872
 	 * @param     int $EVT_ID
873 873
 	 * @return    string
874 874
 	 */
875
-	function espresso_venue_id( $EVT_ID = 0 ) {
876
-		$venue = EEH_Venue_View::get_venue( $EVT_ID );
875
+	function espresso_venue_id($EVT_ID = 0) {
876
+		$venue = EEH_Venue_View::get_venue($EVT_ID);
877 877
 		return $venue instanceof EE_Venue ? $venue->ID() : 0;
878 878
 	}
879 879
 }
880 880
 
881 881
 
882 882
 
883
-if ( ! function_exists( 'espresso_is_venue_private' ) ) {
883
+if ( ! function_exists('espresso_is_venue_private')) {
884 884
 	/**
885 885
 	 * Return whether a venue is private or not.
886 886
 	 * @see EEH_Venue_View::get_venue() for more info on expected return results.
@@ -889,15 +889,15 @@  discard block
 block discarded – undo
889 889
 	 *
890 890
 	 * @return bool | null
891 891
 	 */
892
-	function espresso_is_venue_private( $VNU_ID = 0 ) {
893
-		return EEH_Venue_View::is_venue_private( $VNU_ID );
892
+	function espresso_is_venue_private($VNU_ID = 0) {
893
+		return EEH_Venue_View::is_venue_private($VNU_ID);
894 894
 	}
895 895
 }
896 896
 
897 897
 
898 898
 
899 899
 
900
-if ( ! function_exists( 'espresso_venue_name' )) {
900
+if ( ! function_exists('espresso_venue_name')) {
901 901
 	/**
902 902
 	 *    espresso_venue_name
903 903
 	 *
@@ -907,19 +907,19 @@  discard block
 block discarded – undo
907 907
 	 * @param bool   $echo
908 908
 	 * @return    string
909 909
 	 */
910
-	function espresso_venue_name( $VNU_ID = 0, $link_to = 'details', $echo = TRUE ) {
911
-		if($echo){
912
-			echo EEH_Venue_View::venue_name( $link_to, $VNU_ID );
910
+	function espresso_venue_name($VNU_ID = 0, $link_to = 'details', $echo = TRUE) {
911
+		if ($echo) {
912
+			echo EEH_Venue_View::venue_name($link_to, $VNU_ID);
913 913
 			return '';
914 914
 		}
915
-		return EEH_Venue_View::venue_name( $link_to, $VNU_ID );
915
+		return EEH_Venue_View::venue_name($link_to, $VNU_ID);
916 916
 	}
917 917
 }
918 918
 
919 919
 
920 920
 
921 921
 
922
-if ( ! function_exists( 'espresso_venue_link' )) {
922
+if ( ! function_exists('espresso_venue_link')) {
923 923
 	/**
924 924
 	 * 	espresso_venue_link
925 925
 	 *
@@ -928,14 +928,14 @@  discard block
 block discarded – undo
928 928
 	 *  @param 	string 	$text
929 929
 	 *  @return 	string
930 930
 	 */
931
-	function espresso_venue_link( $VNU_ID = 0, $text = '' ) {
932
-		return EEH_Venue_View::venue_details_link( $VNU_ID, $text );
931
+	function espresso_venue_link($VNU_ID = 0, $text = '') {
932
+		return EEH_Venue_View::venue_details_link($VNU_ID, $text);
933 933
 	}
934 934
 }
935 935
 
936 936
 
937 937
 
938
-if ( ! function_exists( 'espresso_venue_description' )) {
938
+if ( ! function_exists('espresso_venue_description')) {
939 939
 	/**
940 940
 	 *    espresso_venue_description
941 941
 	 *
@@ -944,17 +944,17 @@  discard block
 block discarded – undo
944 944
 	 * @param bool $echo
945 945
 	 * @return    string
946 946
 	 */
947
-	function espresso_venue_description( $VNU_ID = FALSE, $echo = TRUE ) {
948
-		if($echo){
949
-			echo EEH_Venue_View::venue_description( $VNU_ID );
947
+	function espresso_venue_description($VNU_ID = FALSE, $echo = TRUE) {
948
+		if ($echo) {
949
+			echo EEH_Venue_View::venue_description($VNU_ID);
950 950
 			return '';
951 951
 		}
952
-		return EEH_Venue_View::venue_description( $VNU_ID );
952
+		return EEH_Venue_View::venue_description($VNU_ID);
953 953
 	}
954 954
 }
955 955
 
956 956
 
957
-if ( ! function_exists( 'espresso_venue_excerpt' )) {
957
+if ( ! function_exists('espresso_venue_excerpt')) {
958 958
 	/**
959 959
 	 *    espresso_venue_excerpt
960 960
 	 *
@@ -963,18 +963,18 @@  discard block
 block discarded – undo
963 963
 	 * @param bool $echo
964 964
 	 * @return    string
965 965
 	 */
966
-	function espresso_venue_excerpt( $VNU_ID = 0,  $echo = TRUE ) {
967
-		if ( $echo ) {
968
-			echo EEH_Venue_View::venue_excerpt( $VNU_ID );
966
+	function espresso_venue_excerpt($VNU_ID = 0, $echo = TRUE) {
967
+		if ($echo) {
968
+			echo EEH_Venue_View::venue_excerpt($VNU_ID);
969 969
 			return '';
970 970
 		}
971
-		return EEH_Venue_View::venue_excerpt( $VNU_ID );
971
+		return EEH_Venue_View::venue_excerpt($VNU_ID);
972 972
 	}
973 973
 }
974 974
 
975 975
 
976 976
 
977
-if ( ! function_exists( 'espresso_venue_categories' )) {
977
+if ( ! function_exists('espresso_venue_categories')) {
978 978
 	/**
979 979
 	 * espresso_venue_categories
980 980
 	 * returns the terms associated with a venue
@@ -984,17 +984,17 @@  discard block
 block discarded – undo
984 984
 	 * @param bool $echo
985 985
 	 * @return string
986 986
 	 */
987
-	function espresso_venue_categories( $VNU_ID = 0, $hide_uncategorized = TRUE,  $echo = TRUE ) {
988
-		if ( $echo ) {
989
-			echo EEH_Venue_View::venue_categories( $VNU_ID, $hide_uncategorized );
987
+	function espresso_venue_categories($VNU_ID = 0, $hide_uncategorized = TRUE, $echo = TRUE) {
988
+		if ($echo) {
989
+			echo EEH_Venue_View::venue_categories($VNU_ID, $hide_uncategorized);
990 990
 			return '';
991 991
 		}
992
-		return EEH_Venue_View::venue_categories( $VNU_ID, $hide_uncategorized );
992
+		return EEH_Venue_View::venue_categories($VNU_ID, $hide_uncategorized);
993 993
 	}
994 994
 }
995 995
 
996 996
 
997
-if ( ! function_exists( 'espresso_venue_address' )) {
997
+if ( ! function_exists('espresso_venue_address')) {
998 998
 	/**
999 999
 	 * espresso_venue_address
1000 1000
 	 * returns a formatted block of html  for displaying a venue's address
@@ -1004,17 +1004,17 @@  discard block
 block discarded – undo
1004 1004
 	 * @param bool   $echo
1005 1005
 	 * @return string
1006 1006
 	 */
1007
-	function espresso_venue_address( $type = 'multiline', $VNU_ID = 0, $echo = TRUE ) {
1008
-		if ( $echo ) {
1009
-			echo EEH_Venue_View::venue_address( $type, $VNU_ID );
1007
+	function espresso_venue_address($type = 'multiline', $VNU_ID = 0, $echo = TRUE) {
1008
+		if ($echo) {
1009
+			echo EEH_Venue_View::venue_address($type, $VNU_ID);
1010 1010
 			return '';
1011 1011
 		}
1012
-		return EEH_Venue_View::venue_address( $type, $VNU_ID );
1012
+		return EEH_Venue_View::venue_address($type, $VNU_ID);
1013 1013
 	}
1014 1014
 }
1015 1015
 
1016 1016
 
1017
-if ( ! function_exists( 'espresso_venue_raw_address' )) {
1017
+if ( ! function_exists('espresso_venue_raw_address')) {
1018 1018
 	/**
1019 1019
 	 * espresso_venue_address
1020 1020
 	 * returns an UN-formatted string containing a venue's address
@@ -1024,17 +1024,17 @@  discard block
 block discarded – undo
1024 1024
 	 * @param bool     $echo
1025 1025
 	 * @return string
1026 1026
 	 */
1027
-	function espresso_venue_raw_address( $type = 'multiline', $VNU_ID = 0, $echo = TRUE ) {
1028
-		if ( $echo ) {
1029
-			echo EEH_Venue_View::venue_address( $type, $VNU_ID, FALSE, FALSE );
1027
+	function espresso_venue_raw_address($type = 'multiline', $VNU_ID = 0, $echo = TRUE) {
1028
+		if ($echo) {
1029
+			echo EEH_Venue_View::venue_address($type, $VNU_ID, FALSE, FALSE);
1030 1030
 			return '';
1031 1031
 		}
1032
-		return EEH_Venue_View::venue_address( $type, $VNU_ID, FALSE, FALSE );
1032
+		return EEH_Venue_View::venue_address($type, $VNU_ID, FALSE, FALSE);
1033 1033
 	}
1034 1034
 }
1035 1035
 
1036 1036
 
1037
-if ( ! function_exists( 'espresso_venue_has_address' )) {
1037
+if ( ! function_exists('espresso_venue_has_address')) {
1038 1038
 	/**
1039 1039
 	 * espresso_venue_has_address
1040 1040
 	 * returns TRUE or FALSE if a Venue has address information
@@ -1042,13 +1042,13 @@  discard block
 block discarded – undo
1042 1042
 	 * @param int $VNU_ID
1043 1043
 	 * @return bool
1044 1044
 	 */
1045
-	function espresso_venue_has_address( $VNU_ID = 0 ) {
1046
-		return EEH_Venue_View::venue_has_address( $VNU_ID );
1045
+	function espresso_venue_has_address($VNU_ID = 0) {
1046
+		return EEH_Venue_View::venue_has_address($VNU_ID);
1047 1047
 	}
1048 1048
 }
1049 1049
 
1050 1050
 
1051
-if ( ! function_exists( 'espresso_venue_gmap' )) {
1051
+if ( ! function_exists('espresso_venue_gmap')) {
1052 1052
 	/**
1053 1053
 	 * espresso_venue_gmap
1054 1054
 	 * returns a google map for the venue address
@@ -1059,17 +1059,17 @@  discard block
 block discarded – undo
1059 1059
 	 * @param bool     $echo
1060 1060
 	 * @return string
1061 1061
 	 */
1062
-	function espresso_venue_gmap( $VNU_ID = 0, $map_ID = FALSE, $gmap = array(), $echo = TRUE  ) {
1063
-		if ( $echo ) {
1064
-			echo EEH_Venue_View::venue_gmap( $VNU_ID, $map_ID, $gmap );
1062
+	function espresso_venue_gmap($VNU_ID = 0, $map_ID = FALSE, $gmap = array(), $echo = TRUE) {
1063
+		if ($echo) {
1064
+			echo EEH_Venue_View::venue_gmap($VNU_ID, $map_ID, $gmap);
1065 1065
 			return '';
1066 1066
 		}
1067
-		return EEH_Venue_View::venue_gmap( $VNU_ID, $map_ID, $gmap );
1067
+		return EEH_Venue_View::venue_gmap($VNU_ID, $map_ID, $gmap);
1068 1068
 	}
1069 1069
 }
1070 1070
 
1071 1071
 
1072
-if ( ! function_exists( 'espresso_venue_phone' )) {
1072
+if ( ! function_exists('espresso_venue_phone')) {
1073 1073
 	/**
1074 1074
 	 * espresso_venue_phone
1075 1075
 	 *
@@ -1077,18 +1077,18 @@  discard block
 block discarded – undo
1077 1077
 	 * @param bool $echo
1078 1078
 	 * @return string
1079 1079
 	 */
1080
-	function espresso_venue_phone( $VNU_ID = 0, $echo = TRUE ) {
1081
-		if ( $echo ) {
1082
-			echo EEH_Venue_View::venue_phone( $VNU_ID );
1080
+	function espresso_venue_phone($VNU_ID = 0, $echo = TRUE) {
1081
+		if ($echo) {
1082
+			echo EEH_Venue_View::venue_phone($VNU_ID);
1083 1083
 			return '';
1084 1084
 		}
1085
-		return EEH_Venue_View::venue_phone( $VNU_ID );
1085
+		return EEH_Venue_View::venue_phone($VNU_ID);
1086 1086
 	}
1087 1087
 }
1088 1088
 
1089 1089
 
1090 1090
 
1091
-if ( ! function_exists( 'espresso_venue_website' )) {
1091
+if ( ! function_exists('espresso_venue_website')) {
1092 1092
 	/**
1093 1093
 	 * espresso_venue_website
1094 1094
 	 *
@@ -1096,18 +1096,18 @@  discard block
 block discarded – undo
1096 1096
 	 * @param bool $echo
1097 1097
 	 * @return string
1098 1098
 	 */
1099
-	function espresso_venue_website( $VNU_ID = 0, $echo = TRUE ) {
1100
-		if ( $echo ) {
1101
-			echo EEH_Venue_View::venue_website_link( $VNU_ID );
1099
+	function espresso_venue_website($VNU_ID = 0, $echo = TRUE) {
1100
+		if ($echo) {
1101
+			echo EEH_Venue_View::venue_website_link($VNU_ID);
1102 1102
 			return '';
1103 1103
 		}
1104
-		return EEH_Venue_View::venue_website_link( $VNU_ID );
1104
+		return EEH_Venue_View::venue_website_link($VNU_ID);
1105 1105
 	}
1106 1106
 }
1107 1107
 
1108 1108
 
1109 1109
 
1110
-if ( ! function_exists( 'espresso_edit_venue_link' )) {
1110
+if ( ! function_exists('espresso_edit_venue_link')) {
1111 1111
 	/**
1112 1112
 	 * espresso_edit_venue_link
1113 1113
 	 *
@@ -1115,12 +1115,12 @@  discard block
 block discarded – undo
1115 1115
 	 * @param bool $echo
1116 1116
 	 * @return string
1117 1117
 	 */
1118
-	function espresso_edit_venue_link( $VNU_ID = 0, $echo = TRUE ) {
1119
-		if($echo){
1120
-			echo EEH_Venue_View::edit_venue_link( $VNU_ID );
1118
+	function espresso_edit_venue_link($VNU_ID = 0, $echo = TRUE) {
1119
+		if ($echo) {
1120
+			echo EEH_Venue_View::edit_venue_link($VNU_ID);
1121 1121
 			return '';
1122 1122
 		}
1123
-		return EEH_Venue_View::edit_venue_link( $VNU_ID );
1123
+		return EEH_Venue_View::edit_venue_link($VNU_ID);
1124 1124
 	}
1125 1125
 }
1126 1126
 
Please login to merge, or discard this patch.
core/helpers/EEH_Event_View.helper.php 2 patches
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -1,28 +1,28 @@
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
2 2
 /**
3
- * Event Espresso
4
- *
5
- * Event Registration and Management Plugin for WordPress
6
- *
7
- * @ package			Event Espresso
8
- * @ author			Seth Shoultes
9
- * @ copyright		(c) 2008-2011 Event Espresso  All Rights Reserved.
10
- * @ license			http://eventespresso.com/support/terms-conditions/   * see Plugin Licensing *
11
- * @ link					http://www.eventespresso.com
12
- * @ version		 	4.0
13
- *
14
- */
3
+	 * Event Espresso
4
+	 *
5
+	 * Event Registration and Management Plugin for WordPress
6
+	 *
7
+	 * @ package			Event Espresso
8
+	 * @ author			Seth Shoultes
9
+	 * @ copyright		(c) 2008-2011 Event Espresso  All Rights Reserved.
10
+	 * @ license			http://eventespresso.com/support/terms-conditions/   * see Plugin Licensing *
11
+	 * @ link					http://www.eventespresso.com
12
+	 * @ version		 	4.0
13
+	 *
14
+	 */
15 15
 /**
16
- * ------------------------------------------------------------------------
17
- *
18
- * EEH_Event_View Helper
19
- *
20
- * @package			Event Espresso
21
- * @subpackage	/core/
22
- * @author				Brent Christensen
23
- *
24
- * ------------------------------------------------------------------------
25
- */
16
+	 * ------------------------------------------------------------------------
17
+	 *
18
+	 * EEH_Event_View Helper
19
+	 *
20
+	 * @package			Event Espresso
21
+	 * @subpackage	/core/
22
+	 * @author				Brent Christensen
23
+	 *
24
+	 * ------------------------------------------------------------------------
25
+	 */
26 26
 class EEH_Event_View extends EEH_Base {
27 27
 
28 28
 	/**
Please login to merge, or discard this patch.
Spacing   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -40,27 +40,27 @@  discard block
 block discarded – undo
40 40
 	 * @param    int $EVT_ID
41 41
 	 * @return    object
42 42
 	 */
43
-	public static function get_event( $EVT_ID = 0 ) {
44
-		$EVT_ID = $EVT_ID instanceof WP_Post ? $EVT_ID->ID : absint( $EVT_ID );
43
+	public static function get_event($EVT_ID = 0) {
44
+		$EVT_ID = $EVT_ID instanceof WP_Post ? $EVT_ID->ID : absint($EVT_ID);
45 45
 		// do we already have the Event  you are looking for?
46
-		if ( EEH_Event_View::$_event instanceof EE_Event && $EVT_ID && EEH_Event_View::$_event->ID() === $EVT_ID ) {
46
+		if (EEH_Event_View::$_event instanceof EE_Event && $EVT_ID && EEH_Event_View::$_event->ID() === $EVT_ID) {
47 47
 			return EEH_Event_View::$_event;
48 48
 		}
49 49
 		EEH_Event_View::$_event = NULL;
50 50
 		// international newspaper?
51 51
 		global $post;
52 52
 		// if this is being called from an EE_Event post, then we can just grab the attached EE_Event object
53
-		 if ( isset( $post->post_type ) && $post->post_type == 'espresso_events' || $EVT_ID ) {
53
+		 if (isset($post->post_type) && $post->post_type == 'espresso_events' || $EVT_ID) {
54 54
 //			d( $post );
55 55
 			// grab the event we're looking for
56
-			if ( isset( $post->EE_Event ) && ( $EVT_ID == 0 || ( $EVT_ID == $post->ID ))) {
56
+			if (isset($post->EE_Event) && ($EVT_ID == 0 || ($EVT_ID == $post->ID))) {
57 57
 				EEH_Event_View::$_event = $post->EE_Event;
58 58
 //				d( EEH_Event_View::$_event );
59 59
 			}
60 60
 			// now if we STILL do NOT have an EE_Event model object, BUT we have an Event ID...
61
-			if ( ! EEH_Event_View::$_event instanceof EE_Event && $EVT_ID ) {
61
+			if ( ! EEH_Event_View::$_event instanceof EE_Event && $EVT_ID) {
62 62
 				// sigh... pull it from the db
63
-				EEH_Event_View::$_event = EEM_Event::instance()->get_one_by_ID( $EVT_ID );
63
+				EEH_Event_View::$_event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
64 64
 //				d( EEH_Event_View::$_event );
65 65
 			}
66 66
 		}
@@ -76,8 +76,8 @@  discard block
 block discarded – undo
76 76
 	 * @param    int $EVT_ID
77 77
 	 * @return    boolean
78 78
 	 */
79
-	public static function display_ticket_selector( $EVT_ID = 0 ) {
80
-		$event = EEH_Event_View::get_event( $EVT_ID );
79
+	public static function display_ticket_selector($EVT_ID = 0) {
80
+		$event = EEH_Event_View::get_event($EVT_ID);
81 81
 		return $event instanceof EE_Event ? $event->display_ticket_selector() : FALSE;
82 82
 	}
83 83
 
@@ -90,9 +90,9 @@  discard block
 block discarded – undo
90 90
 	 * @param    int $EVT_ID
91 91
 	 * @return    string
92 92
 	 */
93
-	public static function event_status( $EVT_ID = 0 ) {
94
-		$event = EEH_Event_View::get_event( $EVT_ID );
95
-		return $event instanceof EE_Event ? $event->pretty_active_status( FALSE ) : '';
93
+	public static function event_status($EVT_ID = 0) {
94
+		$event = EEH_Event_View::get_event($EVT_ID);
95
+		return $event instanceof EE_Event ? $event->pretty_active_status(FALSE) : '';
96 96
 	}
97 97
 
98 98
 
@@ -104,8 +104,8 @@  discard block
 block discarded – undo
104 104
 	 * @param    int $EVT_ID
105 105
 	 *  @return 	string
106 106
 	 */
107
-	public static function event_active_status( $EVT_ID = 0 ) {
108
-		$event = EEH_Event_View::get_event( $EVT_ID );
107
+	public static function event_active_status($EVT_ID = 0) {
108
+		$event = EEH_Event_View::get_event($EVT_ID);
109 109
 		return $event instanceof EE_Event ? $event->pretty_active_status() : 'inactive';
110 110
 	}
111 111
 
@@ -118,13 +118,13 @@  discard block
 block discarded – undo
118 118
 	 * @param    int $EVT_ID
119 119
 	 *  @return 	string
120 120
 	 */
121
-	public static function event_has_content_or_excerpt( $EVT_ID = 0 ) {
122
-		$event = EEH_Event_View::get_event( $EVT_ID );
121
+	public static function event_has_content_or_excerpt($EVT_ID = 0) {
122
+		$event = EEH_Event_View::get_event($EVT_ID);
123 123
 		$has_content_or_excerpt = FALSE;
124
-		if ( $event instanceof EE_Event ) {
125
-			$has_content_or_excerpt = $event->description() != '' || $event->short_description( NULL, NULL, TRUE ) != '' ? TRUE : FALSE;
124
+		if ($event instanceof EE_Event) {
125
+			$has_content_or_excerpt = $event->description() != '' || $event->short_description(NULL, NULL, TRUE) != '' ? TRUE : FALSE;
126 126
 		}
127
-		if ( is_archive() && ! ( espresso_display_full_description_in_event_list() || espresso_display_excerpt_in_event_list() )) {
127
+		if (is_archive() && ! (espresso_display_full_description_in_event_list() || espresso_display_excerpt_in_event_list())) {
128 128
 			$has_content_or_excerpt = FALSE;
129 129
 		}
130 130
 		return $has_content_or_excerpt;
@@ -140,45 +140,45 @@  discard block
 block discarded – undo
140 140
 	 * @param null $more
141 141
 	 * @return    string
142 142
 	 */
143
-	public static function event_content_or_excerpt( $num_words = NULL, $more = NULL ) {
143
+	public static function event_content_or_excerpt($num_words = NULL, $more = NULL) {
144 144
 		global $post;
145 145
 
146 146
 		ob_start();
147
-		if (( is_single() ) || ( is_archive() && espresso_display_full_description_in_event_list() )) {
147
+		if ((is_single()) || (is_archive() && espresso_display_full_description_in_event_list())) {
148 148
 
149 149
 			// admin has chosen "full description" for the "Event Espresso - Events > Templates > Display Description" option
150 150
 			the_content();
151 151
 
152
-		} else if (( is_archive() && has_excerpt( $post->ID ) && espresso_display_excerpt_in_event_list() ) ) {
152
+		} else if ((is_archive() && has_excerpt($post->ID) && espresso_display_excerpt_in_event_list())) {
153 153
 
154 154
 			// admin has chosen "excerpt (short desc)" for the "Event Espresso - Events > Templates > Display Description" option
155 155
 			// AND an excerpt actually exists
156 156
 			the_excerpt();
157 157
 
158
-		} else if (( is_archive() && ! has_excerpt( $post->ID ) && espresso_display_excerpt_in_event_list() )) {
158
+		} else if ((is_archive() && ! has_excerpt($post->ID) && espresso_display_excerpt_in_event_list())) {
159 159
 
160 160
 			// admin has chosen "excerpt (short desc)" for the "Event Espresso - Events > Templates > Display Description" option
161 161
 			// but NO excerpt actually exists, so we need to create one
162
-			if ( ! empty( $num_words )) {
163
-				if ( empty( $more )) {
164
-					$more_link_text = __( '(more&hellip;)' );
165
-					$more = ' <a href="' . get_permalink() . '" class="more-link">' . $more_link_text . '</a>';
166
-					$more = apply_filters( 'the_content_more_link', $more, $more_link_text );
162
+			if ( ! empty($num_words)) {
163
+				if (empty($more)) {
164
+					$more_link_text = __('(more&hellip;)');
165
+					$more = ' <a href="'.get_permalink().'" class="more-link">'.$more_link_text.'</a>';
166
+					$more = apply_filters('the_content_more_link', $more, $more_link_text);
167 167
 				}
168
-				$content = str_replace( 'NOMORELINK', '', get_the_content( 'NOMORELINK' ));
168
+				$content = str_replace('NOMORELINK', '', get_the_content('NOMORELINK'));
169 169
 
170
-				$content =  wp_trim_words( $content, $num_words, ' ' ) . $more;
170
+				$content = wp_trim_words($content, $num_words, ' ').$more;
171 171
 			} else {
172
-				$content =  get_the_content();
172
+				$content = get_the_content();
173 173
 			}
174 174
 			global $allowedtags;
175
-			$content = wp_kses( $content, $allowedtags );
176
-			$content = strip_shortcodes( $content );
177
-			echo apply_filters( 'the_content', $content );
175
+			$content = wp_kses($content, $allowedtags);
176
+			$content = strip_shortcodes($content);
177
+			echo apply_filters('the_content', $content);
178 178
 
179 179
 		} else {
180 180
 			// admin has chosen "none" for the "Event Espresso - Events > Templates > Display Description" option
181
-			echo apply_filters( 'the_content', '' );
181
+			echo apply_filters('the_content', '');
182 182
 		}
183 183
 		return ob_get_clean();
184 184
 	}
@@ -192,13 +192,13 @@  discard block
 block discarded – undo
192 192
 	 * @param    int $EVT_ID
193 193
 	 *  @return 	EE_Ticket[]
194 194
 	 */
195
-	public static function event_tickets_available( $EVT_ID = 0 ) {
196
-		$event = EEH_Event_View::get_event( $EVT_ID );
195
+	public static function event_tickets_available($EVT_ID = 0) {
196
+		$event = EEH_Event_View::get_event($EVT_ID);
197 197
 		$tickets_available_for_purchase = array();
198
-		if( $event instanceof EE_Event ) {
199
-			$datetimes = EEH_Event_View::get_all_date_obj( $EVT_ID, FALSE );
200
-			foreach( $datetimes as $datetime ) {
201
-				$tickets_available_for_purchase = array_merge( $tickets_available_for_purchase, $datetime->ticket_types_available_for_purchase() );
198
+		if ($event instanceof EE_Event) {
199
+			$datetimes = EEH_Event_View::get_all_date_obj($EVT_ID, FALSE);
200
+			foreach ($datetimes as $datetime) {
201
+				$tickets_available_for_purchase = array_merge($tickets_available_for_purchase, $datetime->ticket_types_available_for_purchase());
202 202
 			}
203 203
 		}
204 204
 		return $tickets_available_for_purchase;
@@ -214,22 +214,22 @@  discard block
 block discarded – undo
214 214
 	 * @param 	  bool   $hide_uncategorized
215 215
 	 * @return    string
216 216
 	 */
217
-	public static function event_categories( $EVT_ID = 0, $hide_uncategorized = TRUE ) {
217
+	public static function event_categories($EVT_ID = 0, $hide_uncategorized = TRUE) {
218 218
 		$category_links = array();
219
-		$event = EEH_Event_View::get_event( $EVT_ID );
220
-		if ( $event instanceof EE_Event ) {
221
-			$event_categories = get_the_terms( $event->ID(), 'espresso_event_categories' );
222
-			if ( $event_categories ) {
219
+		$event = EEH_Event_View::get_event($EVT_ID);
220
+		if ($event instanceof EE_Event) {
221
+			$event_categories = get_the_terms($event->ID(), 'espresso_event_categories');
222
+			if ($event_categories) {
223 223
 				// loop thru terms and create links
224
-				foreach ( $event_categories as $term ) {
225
-					$url = get_term_link( $term, 'espresso_venue_categories' );
226
-					if ( ! is_wp_error( $url ) && (( $hide_uncategorized && strtolower( $term->name ) != __( 'uncategorized', 'event_espresso' )) || ! $hide_uncategorized )) {
227
-						$category_links[] = '<a href="' . esc_url( $url ) . '" rel="tag">' . $term->name . '</a>';
224
+				foreach ($event_categories as $term) {
225
+					$url = get_term_link($term, 'espresso_venue_categories');
226
+					if ( ! is_wp_error($url) && (($hide_uncategorized && strtolower($term->name) != __('uncategorized', 'event_espresso')) || ! $hide_uncategorized)) {
227
+						$category_links[] = '<a href="'.esc_url($url).'" rel="tag">'.$term->name.'</a>';
228 228
 					}
229 229
 				}
230 230
 			}
231 231
 		}
232
-		return implode( ', ', $category_links );
232
+		return implode(', ', $category_links);
233 233
 	}
234 234
 
235 235
 
@@ -243,10 +243,10 @@  discard block
 block discarded – undo
243 243
 	 * @param int    $EVT_ID
244 244
 	 * @return    string
245 245
 	 */
246
-	public static function the_event_date( $dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0 ) {
247
-		$datetime = EEH_Event_View::get_primary_date_obj( $EVT_ID );
248
-		$format = ! empty( $dt_frmt ) && ! empty( $tm_frmt ) ? $dt_frmt . ' ' . $tm_frmt : $dt_frmt . $tm_frmt;
249
-		return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime( 'DTT_EVT_start', $format ) :  '';
246
+	public static function the_event_date($dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0) {
247
+		$datetime = EEH_Event_View::get_primary_date_obj($EVT_ID);
248
+		$format = ! empty($dt_frmt) && ! empty($tm_frmt) ? $dt_frmt.' '.$tm_frmt : $dt_frmt.$tm_frmt;
249
+		return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_start', $format) : '';
250 250
 	}
251 251
 
252 252
 
@@ -260,10 +260,10 @@  discard block
 block discarded – undo
260 260
 	 * @param int    $EVT_ID
261 261
 	 * @return    string
262 262
 	 */
263
-	public static function the_event_end_date( $dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0 ) {
264
-		$datetime = EEH_Event_View::get_last_date_obj( $EVT_ID );
265
-		$format = ! empty( $dt_frmt ) && ! empty( $tm_frmt ) ? $dt_frmt . ' ' . $tm_frmt : $dt_frmt . $tm_frmt;
266
-		return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime( 'DTT_EVT_end', $format ) : '';
263
+	public static function the_event_end_date($dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0) {
264
+		$datetime = EEH_Event_View::get_last_date_obj($EVT_ID);
265
+		$format = ! empty($dt_frmt) && ! empty($tm_frmt) ? $dt_frmt.' '.$tm_frmt : $dt_frmt.$tm_frmt;
266
+		return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_end', $format) : '';
267 267
 	}
268 268
 
269 269
 
@@ -277,10 +277,10 @@  discard block
 block discarded – undo
277 277
 	 * @param int    $EVT_ID
278 278
 	 * @return    string
279 279
 	 */
280
-	public static function the_earliest_event_date( $dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0 ) {
281
-		$datetime = EEH_Event_View::get_earliest_date_obj( $EVT_ID );
282
-		$format = ! empty( $dt_frmt ) && ! empty( $tm_frmt ) ? $dt_frmt . ' ' . $tm_frmt : $dt_frmt . $tm_frmt;
283
-		return $datetime instanceof EE_Datetime ?  $datetime->get_i18n_datetime( 'DTT_EVT_start', $format ) : '';
280
+	public static function the_earliest_event_date($dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0) {
281
+		$datetime = EEH_Event_View::get_earliest_date_obj($EVT_ID);
282
+		$format = ! empty($dt_frmt) && ! empty($tm_frmt) ? $dt_frmt.' '.$tm_frmt : $dt_frmt.$tm_frmt;
283
+		return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_start', $format) : '';
284 284
 	}
285 285
 
286 286
 
@@ -294,10 +294,10 @@  discard block
 block discarded – undo
294 294
 	 * @param int    $EVT_ID
295 295
 	 * @return    string
296 296
 	 */
297
-	public static function the_latest_event_date( $dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0 ) {
298
-		$datetime = EEH_Event_View::get_last_date_obj( $EVT_ID );
299
-		$format = ! empty( $dt_frmt ) && ! empty( $tm_frmt ) ? $dt_frmt . ' ' . $tm_frmt : $dt_frmt . $tm_frmt;
300
-		return $datetime instanceof EE_Datetime ?  $datetime->get_i18n_datetime( 'DTT_EVT_end', $format ) : '';
297
+	public static function the_latest_event_date($dt_frmt = 'D M jS', $tm_frmt = 'g:i a', $EVT_ID = 0) {
298
+		$datetime = EEH_Event_View::get_last_date_obj($EVT_ID);
299
+		$format = ! empty($dt_frmt) && ! empty($tm_frmt) ? $dt_frmt.' '.$tm_frmt : $dt_frmt.$tm_frmt;
300
+		return $datetime instanceof EE_Datetime ? $datetime->get_i18n_datetime('DTT_EVT_end', $format) : '';
301 301
 	}
302 302
 
303 303
 
@@ -309,13 +309,13 @@  discard block
 block discarded – undo
309 309
 	 * @param int $EVT_ID
310 310
 	 * @return    string
311 311
 	 */
312
-	public static function event_date_as_calendar_page( $EVT_ID = 0 ) {
313
-		$datetime = EEH_Event_View::get_primary_date_obj( $EVT_ID );
314
-		if ( $datetime instanceof EE_Datetime ) {
312
+	public static function event_date_as_calendar_page($EVT_ID = 0) {
313
+		$datetime = EEH_Event_View::get_primary_date_obj($EVT_ID);
314
+		if ($datetime instanceof EE_Datetime) {
315 315
 	?>
316 316
 		<div class="event-date-calendar-page-dv">
317
-			<div class="event-date-calendar-page-month-dv"><?php echo $datetime->get_i18n_datetime( 'DTT_EVT_start', 'M' );?></div>
318
-			<div class="event-date-calendar-page-day-dv"><?php echo $datetime->start_date( 'd' );?></div>
317
+			<div class="event-date-calendar-page-month-dv"><?php echo $datetime->get_i18n_datetime('DTT_EVT_start', 'M'); ?></div>
318
+			<div class="event-date-calendar-page-day-dv"><?php echo $datetime->start_date('d'); ?></div>
319 319
 		</div>
320 320
 	<?php
321 321
 		}
@@ -330,17 +330,17 @@  discard block
 block discarded – undo
330 330
 	 * @param int $EVT_ID
331 331
 	 * @return    string
332 332
 	 */
333
-	public static function get_primary_date_obj( $EVT_ID = 0 ) {
334
-		$event = EEH_Event_View::get_event( $EVT_ID );
335
-		if ( $event instanceof EE_Event ) {
333
+	public static function get_primary_date_obj($EVT_ID = 0) {
334
+		$event = EEH_Event_View::get_event($EVT_ID);
335
+		if ($event instanceof EE_Event) {
336 336
 			$datetimes = $event->get_many_related(
337 337
 				'Datetime',
338 338
 				array(
339 339
 					'limit' => 1,
340
-					'order_by' => array( 'DTT_order' => 'ASC' )
340
+					'order_by' => array('DTT_order' => 'ASC')
341 341
 				)
342 342
 			);
343
-			return reset( $datetimes );
343
+			return reset($datetimes);
344 344
 		} else {
345 345
 			 return FALSE;
346 346
 		}
@@ -355,17 +355,17 @@  discard block
 block discarded – undo
355 355
 	 * @param int $EVT_ID
356 356
 	 * @return    string
357 357
 	 */
358
-	public static function get_last_date_obj( $EVT_ID = 0 ) {
359
-		$event = EEH_Event_View::get_event( $EVT_ID );
360
-		if ( $event instanceof EE_Event ) {
358
+	public static function get_last_date_obj($EVT_ID = 0) {
359
+		$event = EEH_Event_View::get_event($EVT_ID);
360
+		if ($event instanceof EE_Event) {
361 361
 			$datetimes = $event->get_many_related(
362 362
 				'Datetime',
363 363
 				array(
364 364
 					'limit' => 1,
365
-					'order_by' => array( 'DTT_order' => 'DESC' )
365
+					'order_by' => array('DTT_order' => 'DESC')
366 366
 				)
367 367
 			);
368
-			return end( $datetimes );
368
+			return end($datetimes);
369 369
 		} else {
370 370
 			return FALSE;
371 371
 		}
@@ -380,17 +380,17 @@  discard block
 block discarded – undo
380 380
 	 * @param int $EVT_ID
381 381
 	 * @return    string
382 382
 	 */
383
-	public static function get_earliest_date_obj( $EVT_ID = 0 ) {
384
-		$event = EEH_Event_View::get_event( $EVT_ID );
385
-		if ( $event instanceof EE_Event ) {
383
+	public static function get_earliest_date_obj($EVT_ID = 0) {
384
+		$event = EEH_Event_View::get_event($EVT_ID);
385
+		if ($event instanceof EE_Event) {
386 386
 			$datetimes = $event->get_many_related(
387 387
 				'Datetime',
388 388
 				array(
389 389
 					'limit' => 1,
390
-					'order_by' => array( 'DTT_EVT_start' => 'ASC' )
390
+					'order_by' => array('DTT_EVT_start' => 'ASC')
391 391
 				)
392 392
 			);
393
-			return reset( $datetimes );
393
+			return reset($datetimes);
394 394
 		} else {
395 395
 			 return FALSE;
396 396
 		}
@@ -405,17 +405,17 @@  discard block
 block discarded – undo
405 405
 	 * @param int $EVT_ID
406 406
 	 * @return    string
407 407
 	 */
408
-	public static function get_latest_date_obj( $EVT_ID = 0 ) {
409
-		$event = EEH_Event_View::get_event( $EVT_ID );
410
-		if ( $event instanceof EE_Event ) {
408
+	public static function get_latest_date_obj($EVT_ID = 0) {
409
+		$event = EEH_Event_View::get_event($EVT_ID);
410
+		if ($event instanceof EE_Event) {
411 411
 			$datetimes = $event->get_many_related(
412 412
 				'Datetime',
413 413
 				array(
414 414
 					'limit' => 1,
415
-					'order_by' => array( 'DTT_EVT_start' => 'DESC' )
415
+					'order_by' => array('DTT_EVT_start' => 'DESC')
416 416
 				)
417 417
 			);
418
-			return end( $datetimes );
418
+			return end($datetimes);
419 419
 		} else {
420 420
 			return FALSE;
421 421
 		}
@@ -433,17 +433,17 @@  discard block
 block discarded – undo
433 433
 	 * @param null $limit
434 434
 	 * @return EE_Datetime[]
435 435
 	 */
436
-	public static function get_all_date_obj( $EVT_ID = 0, $include_expired = null, $include_deleted = false, $limit = NULL ) {
437
-		$event = EEH_Event_View::get_event( $EVT_ID );
438
-		if($include_expired === null){
439
-			if($event instanceof EE_Event && $event->is_expired()){
436
+	public static function get_all_date_obj($EVT_ID = 0, $include_expired = null, $include_deleted = false, $limit = NULL) {
437
+		$event = EEH_Event_View::get_event($EVT_ID);
438
+		if ($include_expired === null) {
439
+			if ($event instanceof EE_Event && $event->is_expired()) {
440 440
 				$include_expired = true;
441
-			}else{
441
+			} else {
442 442
 				$include_expired = false;
443 443
 			}
444 444
 		}
445 445
 
446
-		if ( $event instanceof EE_Event ) {
446
+		if ($event instanceof EE_Event) {
447 447
 			return $event->datetimes_ordered($include_expired, $include_deleted, $limit);
448 448
 		} else {
449 449
 			 return array();
@@ -459,11 +459,11 @@  discard block
 block discarded – undo
459 459
 	 * @param int $EVT_ID
460 460
 	 * @return    string
461 461
 	 */
462
-	public static function event_link_url( $EVT_ID = 0 ) {
463
-		$event = EEH_Event_View::get_event( $EVT_ID );
464
-		if ( $event instanceof EE_Event ) {
465
-			$url = $event->external_url() !== NULL && $event->external_url() !== '' ? $event->external_url() : get_permalink( $event->ID() );
466
-			return preg_match( "~^(?:f|ht)tps?://~i", $url ) ? $url : 'http://' . $url;
462
+	public static function event_link_url($EVT_ID = 0) {
463
+		$event = EEH_Event_View::get_event($EVT_ID);
464
+		if ($event instanceof EE_Event) {
465
+			$url = $event->external_url() !== NULL && $event->external_url() !== '' ? $event->external_url() : get_permalink($event->ID());
466
+			return preg_match("~^(?:f|ht)tps?://~i", $url) ? $url : 'http://'.$url;
467 467
 		}
468 468
 		return NULL;
469 469
 	}
@@ -477,10 +477,10 @@  discard block
 block discarded – undo
477 477
 	 * @param int $EVT_ID
478 478
 	 * @return    string
479 479
 	 */
480
-	public static function event_phone( $EVT_ID = 0 ) {
481
-		$event = EEH_Event_View::get_event( $EVT_ID );
482
-		if ( $event instanceof EE_Event ) {
483
-			return EEH_Schema::telephone( $event->phone() );
480
+	public static function event_phone($EVT_ID = 0) {
481
+		$event = EEH_Event_View::get_event($EVT_ID);
482
+		if ($event instanceof EE_Event) {
483
+			return EEH_Schema::telephone($event->phone());
484 484
 		}
485 485
 		return NULL;
486 486
 	}
@@ -497,23 +497,23 @@  discard block
 block discarded – undo
497 497
 	 * @param string $after
498 498
 	 * @return    string
499 499
 	 */
500
-	public static function edit_event_link( $EVT_ID = 0, $link = '', $before = '', $after = '' ) {
501
-		$event = EEH_Event_View::get_event( $EVT_ID );
502
-		if ( $event instanceof EE_Event ) {
500
+	public static function edit_event_link($EVT_ID = 0, $link = '', $before = '', $after = '') {
501
+		$event = EEH_Event_View::get_event($EVT_ID);
502
+		if ($event instanceof EE_Event) {
503 503
 			// can the user edit this post ?
504
-			if ( current_user_can( 'edit_post', $event->ID() )) {
504
+			if (current_user_can('edit_post', $event->ID())) {
505 505
 				// set link text
506
-				$link = ! empty( $link ) ? $link : __('edit this event');
506
+				$link = ! empty($link) ? $link : __('edit this event');
507 507
 				// generate nonce
508
-				$nonce = wp_create_nonce( 'edit_nonce' );
508
+				$nonce = wp_create_nonce('edit_nonce');
509 509
 				// generate url to event editor for this event
510
-				$url = add_query_arg( array( 'page' => 'espresso_events', 'action' => 'edit', 'post' => $event->ID(), 'edit_nonce' => $nonce ), admin_url() );
510
+				$url = add_query_arg(array('page' => 'espresso_events', 'action' => 'edit', 'post' => $event->ID(), 'edit_nonce' => $nonce), admin_url());
511 511
 				// get edit CPT text
512
-				$post_type_obj = get_post_type_object( 'espresso_events' );
512
+				$post_type_obj = get_post_type_object('espresso_events');
513 513
 				// build final link html
514
-				$link = '<a class="post-edit-link" href="' . $url . '" title="' . esc_attr( $post_type_obj->labels->edit_item ) . '">' . $link . '</a>';
514
+				$link = '<a class="post-edit-link" href="'.$url.'" title="'.esc_attr($post_type_obj->labels->edit_item).'">'.$link.'</a>';
515 515
 				// put it all together
516
-				return $before . apply_filters( 'edit_post_link', $link, $event->ID() ) . $after;
516
+				return $before.apply_filters('edit_post_link', $link, $event->ID()).$after;
517 517
 			}
518 518
 		}
519 519
 		return '';
Please login to merge, or discard this patch.
core/libraries/batch/JobHandlers/RegistrationsReport.php 2 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,17 +1,17 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- *
4
- * Class RegistrationsReport
5
- *
6
- * Generates the registrations report for the specified event,
7
- * or for all events
8
- *
9
- * @package         Event Espresso
10
- * @subpackage    batch
11
- * @author				Mike Nelson
12
- * @since		 	   4.8.26
13
- *
14
- */
3
+	 *
4
+	 * Class RegistrationsReport
5
+	 *
6
+	 * Generates the registrations report for the specified event,
7
+	 * or for all events
8
+	 *
9
+	 * @package         Event Espresso
10
+	 * @subpackage    batch
11
+	 * @author				Mike Nelson
12
+	 * @since		 	   4.8.26
13
+	 *
14
+	 */
15 15
 namespace EventEspressoBatchRequest\JobHandlers;
16 16
 
17 17
 use EventEspressoBatchRequest\JobHandlerBaseClasses\JobHandlerFile;
Please login to merge, or discard this patch.
Spacing   +136 added lines, -136 removed lines patch added patch discarded remove patch
@@ -19,8 +19,8 @@  discard block
 block discarded – undo
19 19
 use EventEspressoBatchRequest\Helpers\JobParameters;
20 20
 use EventEspressoBatchRequest\Helpers\JobStepResponse;
21 21
 
22
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
23
-	exit( 'No direct script access allowed' );
22
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
23
+	exit('No direct script access allowed');
24 24
 }
25 25
 
26 26
 
@@ -35,35 +35,35 @@  discard block
 block discarded – undo
35 35
 	 * @throws BatchRequestException
36 36
 	 * @return JobStepResponse
37 37
 	 */
38
-	public function create_job( JobParameters $job_parameters ) {
39
-		$event_id = intval( $job_parameters->request_datum( 'EVT_ID', '0' ) );
40
-		if( ! \EE_Capabilities::instance()->current_user_can( 'ee_read_registrations', 'generating_report' ) ) {
38
+	public function create_job(JobParameters $job_parameters) {
39
+		$event_id = intval($job_parameters->request_datum('EVT_ID', '0'));
40
+		if ( ! \EE_Capabilities::instance()->current_user_can('ee_read_registrations', 'generating_report')) {
41 41
 			throw new BatchRequestException(
42
-				__( 'You do not have permission to view registrations', 'event_espresso')
42
+				__('You do not have permission to view registrations', 'event_espresso')
43 43
 			);
44 44
 		}
45 45
 		$filepath = $this->create_file_from_job_with_name(
46 46
 			$job_parameters->job_id(),
47
-			$this->get_filename_from_event( $event_id )
47
+			$this->get_filename_from_event($event_id)
48 48
 		);
49
-		$job_parameters->add_extra_data( 'filepath', $filepath );
50
-		$question_data_for_columns = $this->_get_questions_for_report( $event_id );
51
-		$job_parameters->add_extra_data( 'questions_data', $question_data_for_columns );
52
-		$job_parameters->set_job_size( $this->count_units_to_process( $event_id ) );
49
+		$job_parameters->add_extra_data('filepath', $filepath);
50
+		$question_data_for_columns = $this->_get_questions_for_report($event_id);
51
+		$job_parameters->add_extra_data('questions_data', $question_data_for_columns);
52
+		$job_parameters->set_job_size($this->count_units_to_process($event_id));
53 53
 		//we should also set the header columns
54 54
 		$csv_data_for_row = $this->get_csv_data_for(
55 55
 			$event_id,
56 56
 			0,
57 57
 			1,
58
-			$job_parameters->extra_datum( 'questions_data' ) );
59
-		\EEH_Export::write_data_array_to_csv( $filepath, $csv_data_for_row, true );
58
+			$job_parameters->extra_datum('questions_data') );
59
+		\EEH_Export::write_data_array_to_csv($filepath, $csv_data_for_row, true);
60 60
 		//if we actually processed a row there, record it
61
-		if( $job_parameters->job_size() ) {
62
-			$job_parameters->mark_processed( 1 );
61
+		if ($job_parameters->job_size()) {
62
+			$job_parameters->mark_processed(1);
63 63
 		}
64 64
 		return new JobStepResponse(
65 65
 			$job_parameters,
66
-			__( 'Registrations report started successfully...', 'event_espresso' )
66
+			__('Registrations report started successfully...', 'event_espresso')
67 67
 		);
68 68
 	}
69 69
 
@@ -74,16 +74,16 @@  discard block
 block discarded – undo
74 74
 	 * @param int $event_id
75 75
 	 * @return string
76 76
 	 */
77
-	protected function get_filename_from_event( $event_id ) {
78
-		if( $event_id ){
79
-			$event_slug =  \EEM_Event::instance()->get_var( array( array( 'EVT_ID' => $event_id ) ), 'EVT_slug' );
80
-			if( ! $event_slug ) {
81
-				$event_slug = __( 'unknown', 'event_espresso' );
77
+	protected function get_filename_from_event($event_id) {
78
+		if ($event_id) {
79
+			$event_slug = \EEM_Event::instance()->get_var(array(array('EVT_ID' => $event_id)), 'EVT_slug');
80
+			if ( ! $event_slug) {
81
+				$event_slug = __('unknown', 'event_espresso');
82 82
 			}
83
-		}else{
84
-			$event_slug = __( 'all', 'event_espresso' );
83
+		} else {
84
+			$event_slug = __('all', 'event_espresso');
85 85
 		}
86
-		return sprintf( "registrations-for-%s.csv", $event_slug );
86
+		return sprintf("registrations-for-%s.csv", $event_slug);
87 87
 	}
88 88
 
89 89
 	/**
@@ -92,17 +92,17 @@  discard block
 block discarded – undo
92 92
 	 * @param int|null $event_id
93 93
 	 * @return array of wpdb results for questions which are to be used for this report
94 94
 	 */
95
-	protected function _get_questions_for_report( $event_id ) {
95
+	protected function _get_questions_for_report($event_id) {
96 96
 		$question_query_params = array(
97 97
 			array(
98
-				'Answer.ANS_ID' => array( 'IS_NOT_NULL' ),
98
+				'Answer.ANS_ID' => array('IS_NOT_NULL'),
99 99
 			),
100
-			'group_by' => array( 'QST_ID' )
100
+			'group_by' => array('QST_ID')
101 101
 		);
102
-		if( $event_id ) {
102
+		if ($event_id) {
103 103
 			$question_query_params[0]['Answer.Registration.EVT_ID'] = $event_id;
104 104
 		}
105
-		return \EEM_Question::instance()->get_all_wpdb_results( $question_query_params );
105
+		return \EEM_Question::instance()->get_all_wpdb_results($question_query_params);
106 106
 	}
107 107
 
108 108
 
@@ -115,27 +115,27 @@  discard block
 block discarded – undo
115 115
 	 * @return JobStepResponse
116 116
 	 * @throws \EE_Error
117 117
 	 */
118
-	public function continue_job( JobParameters $job_parameters, $batch_size = 50 ) {
118
+	public function continue_job(JobParameters $job_parameters, $batch_size = 50) {
119 119
 		$csv_data = $this->get_csv_data_for(
120
-			$job_parameters->request_datum( 'EVT_ID', '0'),
120
+			$job_parameters->request_datum('EVT_ID', '0'),
121 121
 			$job_parameters->units_processed(),
122 122
 			$batch_size,
123
-			$job_parameters->extra_datum( 'questions_data' ) );
124
-		\EEH_Export::write_data_array_to_csv( $job_parameters->extra_datum( 'filepath' ), $csv_data, false );
125
-		$units_processed = count( $csv_data );
126
-		$job_parameters->mark_processed( $units_processed );
123
+			$job_parameters->extra_datum('questions_data') );
124
+		\EEH_Export::write_data_array_to_csv($job_parameters->extra_datum('filepath'), $csv_data, false);
125
+		$units_processed = count($csv_data);
126
+		$job_parameters->mark_processed($units_processed);
127 127
 		$extra_response_data = array(
128 128
 			'file_url' => ''
129 129
 		);
130
-		if( $units_processed < $batch_size ) {
131
-			$job_parameters->set_status( JobParameters::status_complete );
132
-			$extra_response_data[ 'file_url' ] = $this->get_url_to_file( $job_parameters->extra_datum( 'filepath' ) );
130
+		if ($units_processed < $batch_size) {
131
+			$job_parameters->set_status(JobParameters::status_complete);
132
+			$extra_response_data['file_url'] = $this->get_url_to_file($job_parameters->extra_datum('filepath'));
133 133
 		}
134 134
 		return new JobStepResponse(
135 135
 				$job_parameters,
136 136
 				sprintf(
137
-					__( 'Wrote %1$s rows to report CSV file...', 'event_espresso' ),
138
-					count( $csv_data ) ),
137
+					__('Wrote %1$s rows to report CSV file...', 'event_espresso'),
138
+					count($csv_data) ),
139 139
 				$extra_response_data );
140 140
 	}
141 141
 
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 	 * @return array top-level keys are numeric, next-level keys are column headers
149 149
 	 *
150 150
 	 */
151
-	function get_csv_data_for( $event_id, $offset, $limit, $questions_for_these_regs_rows ) {
151
+	function get_csv_data_for($event_id, $offset, $limit, $questions_for_these_regs_rows) {
152 152
 		$reg_fields_to_include = array(
153 153
 			'TXN_ID',
154 154
 			'ATT_ID',
@@ -179,165 +179,165 @@  discard block
 block discarded – undo
179 179
 				array(
180 180
 					'OR' => array(
181 181
 						//don't include registrations from failed or abandoned transactions...
182
-						'Transaction.STS_ID' => array( 'NOT IN', array( \EEM_Transaction::failed_status_code, \EEM_Transaction::abandoned_status_code ) ),
182
+						'Transaction.STS_ID' => array('NOT IN', array(\EEM_Transaction::failed_status_code, \EEM_Transaction::abandoned_status_code)),
183 183
 						//unless the registration is approved, in which case include it regardless of transaction status
184 184
 						'STS_ID' => \EEM_Registration::status_id_approved
185 185
 						),
186
-					'Ticket.TKT_deleted' => array( 'IN', array( true, false ) )
186
+					'Ticket.TKT_deleted' => array('IN', array(true, false))
187 187
 					),
188
-				'order_by' => array('Transaction.TXN_ID'=>'asc','REG_count'=>'asc'),
189
-				'force_join' => array( 'Transaction', 'Ticket', 'Attendee' ),
190
-				'limit' => array( $offset, $limit ),
188
+				'order_by' => array('Transaction.TXN_ID'=>'asc', 'REG_count'=>'asc'),
189
+				'force_join' => array('Transaction', 'Ticket', 'Attendee'),
190
+				'limit' => array($offset, $limit),
191 191
 			),
192 192
 			$event_id
193 193
 		);
194
-		if( $event_id ){
195
-			$query_params[0]['EVT_ID'] =  $event_id;
196
-		}else{
197
-			$query_params[ 'force_join' ][] = 'Event';
194
+		if ($event_id) {
195
+			$query_params[0]['EVT_ID'] = $event_id;
196
+		} else {
197
+			$query_params['force_join'][] = 'Event';
198 198
 		}
199
-		$registration_rows = $reg_model->get_all_wpdb_results( $query_params );
199
+		$registration_rows = $reg_model->get_all_wpdb_results($query_params);
200 200
 		//get all questions which relate to someone in this group
201 201
 		$registration_ids = array();
202
-		foreach( $registration_rows as $reg_row ) {
203
-			$registration_ids[] = intval( $reg_row[ 'Registration.REG_ID'] );
202
+		foreach ($registration_rows as $reg_row) {
203
+			$registration_ids[] = intval($reg_row['Registration.REG_ID']);
204 204
 		}
205 205
 
206
-		foreach($registration_rows as $reg_row){
207
-			if ( is_array( $reg_row ) ) {
206
+		foreach ($registration_rows as $reg_row) {
207
+			if (is_array($reg_row)) {
208 208
 				$reg_csv_array = array();
209
-				if( ! $event_id ){
209
+				if ( ! $event_id) {
210 210
 					//get the event's name and Id
211
-					$reg_csv_array[ __( 'Event', 'event_espresso' ) ] = sprintf( __( '%1$s (%2$s)', 'event_espresso' ), \EEH_Export::prepare_value_from_db_for_display( \EEM_Event::instance(), 'EVT_name', $reg_row[ 'Event_CPT.post_title'] ), $reg_row[ 'Event_CPT.ID' ] );
211
+					$reg_csv_array[__('Event', 'event_espresso')] = sprintf(__('%1$s (%2$s)', 'event_espresso'), \EEH_Export::prepare_value_from_db_for_display(\EEM_Event::instance(), 'EVT_name', $reg_row['Event_CPT.post_title']), $reg_row['Event_CPT.ID']);
212 212
 				}
213
-				$is_primary_reg = $reg_row[ 'Registration.REG_count' ] == '1' ? true : false;
213
+				$is_primary_reg = $reg_row['Registration.REG_count'] == '1' ? true : false;
214 214
 				/*@var $reg_row EE_Registration */
215
-				foreach($reg_fields_to_include as $field_name){
215
+				foreach ($reg_fields_to_include as $field_name) {
216 216
 					$field = $reg_model->field_settings_for($field_name);
217
-					if($field_name == 'REG_final_price'){
218
-						$value = \EEH_Export::prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ 'Registration.REG_final_price'], 'localized_float' );
219
-					}elseif( $field_name == 'REG_count' ){
220
-						$value = sprintf( __( '%s of %s', 'event_espresso' ), \EEH_Export::prepare_value_from_db_for_display( $reg_model, 'REG_count', $reg_row['Registration.REG_count'] ), \EEH_Export::prepare_value_from_db_for_display( $reg_model, 'REG_group_size', $reg_row['Registration.REG_group_size' ] ) );
221
-					}elseif( $field_name == 'REG_date' ) {
222
-						$value = \EEH_Export::prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ 'Registration.REG_date'], 'no_html' );
223
-					}else{
224
-						$value = \EEH_Export::prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ $field->get_qualified_column() ] );
217
+					if ($field_name == 'REG_final_price') {
218
+						$value = \EEH_Export::prepare_value_from_db_for_display($reg_model, $field_name, $reg_row['Registration.REG_final_price'], 'localized_float');
219
+					}elseif ($field_name == 'REG_count') {
220
+						$value = sprintf(__('%s of %s', 'event_espresso'), \EEH_Export::prepare_value_from_db_for_display($reg_model, 'REG_count', $reg_row['Registration.REG_count']), \EEH_Export::prepare_value_from_db_for_display($reg_model, 'REG_group_size', $reg_row['Registration.REG_group_size']));
221
+					}elseif ($field_name == 'REG_date') {
222
+						$value = \EEH_Export::prepare_value_from_db_for_display($reg_model, $field_name, $reg_row['Registration.REG_date'], 'no_html');
223
+					} else {
224
+						$value = \EEH_Export::prepare_value_from_db_for_display($reg_model, $field_name, $reg_row[$field->get_qualified_column()]);
225 225
 					}
226 226
 					$reg_csv_array[\EEH_Export::get_column_name_for_field($field)] = $value;
227
-					if($field_name == 'REG_final_price'){
227
+					if ($field_name == 'REG_final_price') {
228 228
 						//add a column named Currency after the final price
229 229
 						$reg_csv_array[__("Currency", "event_espresso")] = \EE_Config::instance()->currency->code;
230 230
 					}
231 231
 				}
232 232
 				//get pretty status
233
-				$stati = \EEM_Status::instance()->localized_status( array(
234
-					$reg_row[ 'Registration.STS_ID' ] => __( 'unknown', 'event_espresso' ),
235
-					$reg_row[ 'Transaction.STS_ID' ] => __( 'unknown', 'event_espresso' ) ),
233
+				$stati = \EEM_Status::instance()->localized_status(array(
234
+					$reg_row['Registration.STS_ID'] => __('unknown', 'event_espresso'),
235
+					$reg_row['Transaction.STS_ID'] => __('unknown', 'event_espresso') ),
236 236
 						FALSE,
237
-						'sentence' );
238
-				$reg_csv_array[__("Registration Status", 'event_espresso')] = $stati[ $reg_row[ 'Registration.STS_ID' ] ];
237
+						'sentence');
238
+				$reg_csv_array[__("Registration Status", 'event_espresso')] = $stati[$reg_row['Registration.STS_ID']];
239 239
 				//get pretty transaction status
240
-				$reg_csv_array[__("Transaction Status", 'event_espresso')] = $stati[ $reg_row[ 'Transaction.STS_ID' ] ];
241
-				$reg_csv_array[ __( 'Transaction Amount Due', 'event_espresso' ) ] = $is_primary_reg ? \EEH_Export::prepare_value_from_db_for_display( \EEM_Transaction::instance(), 'TXN_total', $reg_row[ 'Transaction.TXN_total' ], 'localized_float' ) : '0.00';
242
-				$reg_csv_array[ __( 'Amount Paid', 'event_espresso' )] = $is_primary_reg ? \EEH_Export::prepare_value_from_db_for_display( \EEM_Transaction::instance(), 'TXN_paid', $reg_row[ 'Transaction.TXN_paid' ], 'localized_float' ) : '0.00';
240
+				$reg_csv_array[__("Transaction Status", 'event_espresso')] = $stati[$reg_row['Transaction.STS_ID']];
241
+				$reg_csv_array[__('Transaction Amount Due', 'event_espresso')] = $is_primary_reg ? \EEH_Export::prepare_value_from_db_for_display(\EEM_Transaction::instance(), 'TXN_total', $reg_row['Transaction.TXN_total'], 'localized_float') : '0.00';
242
+				$reg_csv_array[__('Amount Paid', 'event_espresso')] = $is_primary_reg ? \EEH_Export::prepare_value_from_db_for_display(\EEM_Transaction::instance(), 'TXN_paid', $reg_row['Transaction.TXN_paid'], 'localized_float') : '0.00';
243 243
 				$payment_methods = array();
244 244
 				$gateway_txn_ids_etc = array();
245 245
 				$payment_times = array();
246
-				if( $is_primary_reg && $reg_row[ 'Transaction.TXN_ID' ] ){
246
+				if ($is_primary_reg && $reg_row['Transaction.TXN_ID']) {
247 247
 					$payments_info = \EEM_Payment::instance()->get_all_wpdb_results(
248 248
 							array(
249 249
 								array(
250
-									'TXN_ID' => $reg_row[ 'Transaction.TXN_ID' ],
250
+									'TXN_ID' => $reg_row['Transaction.TXN_ID'],
251 251
 									'STS_ID' => \EEM_Payment::status_id_approved
252 252
 								),
253
-								'force_join' => array( 'Payment_Method' ),
253
+								'force_join' => array('Payment_Method'),
254 254
 
255 255
 							),
256 256
 							ARRAY_A,
257 257
 							'Payment_Method.PMD_admin_name as name, Payment.PAY_txn_id_chq_nmbr as gateway_txn_id, Payment.PAY_timestamp as payment_time' );
258 258
 
259
-					foreach( $payments_info as $payment_method_and_gateway_txn_id ){
260
-						$payment_methods[] = isset( $payment_method_and_gateway_txn_id[ 'name' ] ) ? $payment_method_and_gateway_txn_id[ 'name' ] : __( 'Unknown', 'event_espresso' );
261
-						$gateway_txn_ids_etc[] = isset( $payment_method_and_gateway_txn_id[ 'gateway_txn_id' ] ) ? $payment_method_and_gateway_txn_id[ 'gateway_txn_id' ] : '';
262
-						$payment_times[] = isset( $payment_method_and_gateway_txn_id[ 'payment_time' ] ) ? $payment_method_and_gateway_txn_id[ 'payment_time' ] : '';
259
+					foreach ($payments_info as $payment_method_and_gateway_txn_id) {
260
+						$payment_methods[] = isset($payment_method_and_gateway_txn_id['name']) ? $payment_method_and_gateway_txn_id['name'] : __('Unknown', 'event_espresso');
261
+						$gateway_txn_ids_etc[] = isset($payment_method_and_gateway_txn_id['gateway_txn_id']) ? $payment_method_and_gateway_txn_id['gateway_txn_id'] : '';
262
+						$payment_times[] = isset($payment_method_and_gateway_txn_id['payment_time']) ? $payment_method_and_gateway_txn_id['payment_time'] : '';
263 263
 					}
264 264
 
265 265
 				}
266
-				$reg_csv_array[ __( 'Payment Date(s)', 'event_espresso' ) ] = implode( ',', $payment_times );
267
-				$reg_csv_array[ __( 'Payment Method(s)', 'event_espresso' ) ] = implode( ",", $payment_methods );
268
-				$reg_csv_array[ __( 'Gateway Transaction ID(s)', 'event_espresso' )] = implode( ',', $gateway_txn_ids_etc );
266
+				$reg_csv_array[__('Payment Date(s)', 'event_espresso')] = implode(',', $payment_times);
267
+				$reg_csv_array[__('Payment Method(s)', 'event_espresso')] = implode(",", $payment_methods);
268
+				$reg_csv_array[__('Gateway Transaction ID(s)', 'event_espresso')] = implode(',', $gateway_txn_ids_etc);
269 269
 
270 270
 				//get whether or not the user has checked in
271
-				$reg_csv_array[__("Check-Ins", "event_espresso")] = $reg_model->count_related( $reg_row[ 'Registration.REG_ID'] , 'Checkin' );
271
+				$reg_csv_array[__("Check-Ins", "event_espresso")] = $reg_model->count_related($reg_row['Registration.REG_ID'], 'Checkin');
272 272
 				//get ticket of registration and its price
273 273
 				$ticket_model = \EE_Registry::instance()->load_model('Ticket');
274
-				if( $reg_row[ 'Ticket.TKT_ID'] ) {
275
-					$ticket_name = \EEH_Export::prepare_value_from_db_for_display( $ticket_model, 'TKT_name', $reg_row[ 'Ticket.TKT_name' ] );
274
+				if ($reg_row['Ticket.TKT_ID']) {
275
+					$ticket_name = \EEH_Export::prepare_value_from_db_for_display($ticket_model, 'TKT_name', $reg_row['Ticket.TKT_name']);
276 276
 					$datetimes_strings = array();
277
-					foreach( \EEM_Datetime::instance()->get_all_wpdb_results( array( array( 'Ticket.TKT_ID' => $reg_row[ 'Ticket.TKT_ID' ] ), 'order_by' => array( 'DTT_EVT_start' => 'ASC' ), 'default_where_conditions' => 'none' ) ) as $datetime){
278
-						$datetimes_strings[] = \EEH_Export::prepare_value_from_db_for_display( \EEM_Datetime::instance(), 'DTT_EVT_start', $datetime[ 'Datetime.DTT_EVT_start'] );
277
+					foreach (\EEM_Datetime::instance()->get_all_wpdb_results(array(array('Ticket.TKT_ID' => $reg_row['Ticket.TKT_ID']), 'order_by' => array('DTT_EVT_start' => 'ASC'), 'default_where_conditions' => 'none')) as $datetime) {
278
+						$datetimes_strings[] = \EEH_Export::prepare_value_from_db_for_display(\EEM_Datetime::instance(), 'DTT_EVT_start', $datetime['Datetime.DTT_EVT_start']);
279 279
 					}
280 280
 
281 281
 				} else {
282
-					$ticket_name = __( 'Unknown', 'event_espresso' );
283
-					$datetimes_strings = array( __( 'Unknown', 'event_espresso' ) );
282
+					$ticket_name = __('Unknown', 'event_espresso');
283
+					$datetimes_strings = array(__('Unknown', 'event_espresso'));
284 284
 				}
285 285
 				$reg_csv_array[$ticket_model->field_settings_for('TKT_name')->get_nicename()] = $ticket_name;
286 286
 				$reg_csv_array[__("Datetimes of Ticket", "event_espresso")] = implode(", ", $datetimes_strings);
287 287
 				//get datetime(s) of registration
288 288
 
289 289
 				//add attendee columns
290
-				foreach($att_fields_to_include as $att_field_name){
290
+				foreach ($att_fields_to_include as $att_field_name) {
291 291
 					$field_obj = \EEM_Attendee::instance()->field_settings_for($att_field_name);
292
-					if( $reg_row[ 'Attendee_CPT.ID' ]){
293
-						if($att_field_name == 'STA_ID'){
294
-							$value = \EEM_State::instance()->get_var( array( array( 'STA_ID' => $reg_row[ 'Attendee_Meta.STA_ID' ] ) ), 'STA_name' );
295
-						}elseif($att_field_name == 'CNT_ISO'){
296
-							$value = \EEM_Country::instance()->get_var( array( array( 'CNT_ISO' => $reg_row[ 'Attendee_Meta.CNT_ISO' ] ) ), 'CNT_name' );
297
-						}else{
298
-							$value = \EEH_Export::prepare_value_from_db_for_display( \EEM_Attendee::instance(), $att_field_name, $reg_row[ $field_obj->get_qualified_column() ] );
292
+					if ($reg_row['Attendee_CPT.ID']) {
293
+						if ($att_field_name == 'STA_ID') {
294
+							$value = \EEM_State::instance()->get_var(array(array('STA_ID' => $reg_row['Attendee_Meta.STA_ID'])), 'STA_name');
295
+						}elseif ($att_field_name == 'CNT_ISO') {
296
+							$value = \EEM_Country::instance()->get_var(array(array('CNT_ISO' => $reg_row['Attendee_Meta.CNT_ISO'])), 'CNT_name');
297
+						} else {
298
+							$value = \EEH_Export::prepare_value_from_db_for_display(\EEM_Attendee::instance(), $att_field_name, $reg_row[$field_obj->get_qualified_column()]);
299 299
 						}
300
-					}else{
300
+					} else {
301 301
 						$value = '';
302 302
 					}
303 303
 
304
-					$reg_csv_array[ \EEH_Export::get_column_name_for_field($field_obj) ] = $value;
304
+					$reg_csv_array[\EEH_Export::get_column_name_for_field($field_obj)] = $value;
305 305
 				}
306 306
 
307 307
 				//make sure each registration has the same questions in the same order
308
-				foreach($questions_for_these_regs_rows as $question_row){
309
-					if( ! isset($reg_csv_array[$question_row[ 'Question.QST_admin_label']])){
310
-						$reg_csv_array[$question_row[ 'Question.QST_admin_label' ] ] = null;
308
+				foreach ($questions_for_these_regs_rows as $question_row) {
309
+					if ( ! isset($reg_csv_array[$question_row['Question.QST_admin_label']])) {
310
+						$reg_csv_array[$question_row['Question.QST_admin_label']] = null;
311 311
 					}
312 312
 				}
313 313
 				$answers = \EEM_Answer::instance()->get_all_wpdb_results(
314 314
 					array(
315
-						array( 'REG_ID' => $reg_row[ 'Registration.REG_ID' ] ),
316
-						'force_join' => array( 'Question' )
315
+						array('REG_ID' => $reg_row['Registration.REG_ID']),
316
+						'force_join' => array('Question')
317 317
 					)
318 318
 				);
319 319
 				//now fill out the questions THEY answered
320
-				foreach( $answers as $answer_row ){
321
-					if( $answer_row[ 'Question.QST_ID' ] ){
320
+				foreach ($answers as $answer_row) {
321
+					if ($answer_row['Question.QST_ID']) {
322 322
 						$question_label = \EEH_Export::prepare_value_from_db_for_display(
323 323
 							\EEM_Question::instance(),
324 324
 							'QST_admin_label',
325
-							$answer_row[ 'Question.QST_admin_label' ]
325
+							$answer_row['Question.QST_admin_label']
326 326
 						);
327 327
 					} else {
328
-						$question_label = sprintf( __( 'Question $s', 'event_espresso' ), $answer_row[ 'Answer.QST_ID' ] );
328
+						$question_label = sprintf(__('Question $s', 'event_espresso'), $answer_row['Answer.QST_ID']);
329 329
 					}
330
-					if ( isset( $answer_row[ 'Question.QST_type' ] )
331
-						 && $answer_row[ 'Question.QST_type' ] == \EEM_Question::QST_type_state
330
+					if (isset($answer_row['Question.QST_type'])
331
+						 && $answer_row['Question.QST_type'] == \EEM_Question::QST_type_state
332 332
 					) {
333
-						$reg_csv_array[ $question_label ] = \EEM_State::instance()->get_state_name_by_ID(
334
-							$answer_row[ 'Answer.ANS_value' ]
333
+						$reg_csv_array[$question_label] = \EEM_State::instance()->get_state_name_by_ID(
334
+							$answer_row['Answer.ANS_value']
335 335
 						);
336 336
 					} else {
337
-						$reg_csv_array[ $question_label ] = \EEH_Export::prepare_value_from_db_for_display(
337
+						$reg_csv_array[$question_label] = \EEH_Export::prepare_value_from_db_for_display(
338 338
 							\EEM_Answer::instance(),
339 339
 							'ANS_value',
340
-							$answer_row[ 'Answer.ANS_value' ]
340
+							$answer_row['Answer.ANS_value']
341 341
 						);
342 342
 					}
343 343
 				}
@@ -348,17 +348,17 @@  discard block
 block discarded – undo
348 348
 			}
349 349
 		}
350 350
 		//if we couldn't export anything, we want to at least show the column headers
351
-		if ( empty( $registrations_csv_ready_array ) ) {
351
+		if (empty($registrations_csv_ready_array)) {
352 352
 			$reg_csv_array = array();
353 353
 			$model_and_fields_to_include = array(
354 354
 				'Registration' => $reg_fields_to_include,
355 355
 				'Attendee'     => $att_fields_to_include
356 356
 			);
357
-			foreach ( $model_and_fields_to_include as $model_name => $field_list ) {
358
-				$model = \EE_Registry::instance()->load_model( $model_name );
359
-				foreach ( $field_list as $field_name ) {
360
-					$field = $model->field_settings_for( $field_name );
361
-					$reg_csv_array[ \EEH_Export::get_column_name_for_field( $field ) ] = null;
357
+			foreach ($model_and_fields_to_include as $model_name => $field_list) {
358
+				$model = \EE_Registry::instance()->load_model($model_name);
359
+				foreach ($field_list as $field_name) {
360
+					$field = $model->field_settings_for($field_name);
361
+					$reg_csv_array[\EEH_Export::get_column_name_for_field($field)] = null;
362 362
 				}
363 363
 			}
364 364
 			$registrations_csv_ready_array[] = $reg_csv_array;
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
 	 * @param int $event_id
375 375
 	 * @return int
376 376
 	 */
377
-	public function count_units_to_process( $event_id ) {
377
+	public function count_units_to_process($event_id) {
378 378
 		//use the legacy filter
379 379
 		$query_params = apply_filters(
380 380
 			'FHEE__EE_Export__report_registration_for_event',
@@ -382,23 +382,23 @@  discard block
 block discarded – undo
382 382
 				array(
383 383
 					'OR' => array(
384 384
 						//don't include registrations from failed or abandoned transactions...
385
-						'Transaction.STS_ID' => array( 'NOT IN', array( \EEM_Transaction::failed_status_code, \EEM_Transaction::abandoned_status_code ) ),
385
+						'Transaction.STS_ID' => array('NOT IN', array(\EEM_Transaction::failed_status_code, \EEM_Transaction::abandoned_status_code)),
386 386
 						//unless the registration is approved, in which case include it regardless of transaction status
387 387
 						'STS_ID' => \EEM_Registration::status_id_approved
388 388
 						),
389
-					'Ticket.TKT_deleted' => array( 'IN', array( true, false ) )
389
+					'Ticket.TKT_deleted' => array('IN', array(true, false))
390 390
 					),
391
-				'order_by' => array('Transaction.TXN_ID'=>'asc','REG_count'=>'asc'),
392
-				'force_join' => array( 'Transaction', 'Ticket', 'Attendee' )
391
+				'order_by' => array('Transaction.TXN_ID'=>'asc', 'REG_count'=>'asc'),
392
+				'force_join' => array('Transaction', 'Ticket', 'Attendee')
393 393
 			),
394 394
 			$event_id
395 395
 		);
396
-		if( $event_id ){
397
-			$query_params[0]['EVT_ID'] =  $event_id;
396
+		if ($event_id) {
397
+			$query_params[0]['EVT_ID'] = $event_id;
398 398
 		} else {
399
-			$query_params[ 'force_join' ][] = 'Event';
399
+			$query_params['force_join'][] = 'Event';
400 400
 		}
401
-		return \EEM_Registration::instance()->count( $query_params );
401
+		return \EEM_Registration::instance()->count($query_params);
402 402
 	}
403 403
 
404 404
 
@@ -409,13 +409,13 @@  discard block
 block discarded – undo
409 409
 	 * @param JobParameters $job_parameters
410 410
 	 * @return boolean
411 411
 	 */
412
-	public function cleanup_job( JobParameters $job_parameters ){
412
+	public function cleanup_job(JobParameters $job_parameters) {
413 413
 		$this->_file_helper->delete(
414
-			\EEH_File::remove_filename_from_filepath( $job_parameters->extra_datum( 'filepath' ) ),
414
+			\EEH_File::remove_filename_from_filepath($job_parameters->extra_datum('filepath')),
415 415
 			true,
416 416
 			'd'
417 417
 		);
418
-		return new JobStepResponse( $job_parameters, __( 'Cleaned up temporary file', 'event_espresso' ) );
418
+		return new JobStepResponse($job_parameters, __('Cleaned up temporary file', 'event_espresso'));
419 419
 	}
420 420
 }
421 421
 
Please login to merge, or discard this patch.
admin_pages/transactions/Transactions_Admin_Page.core.php 2 patches
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -1,26 +1,26 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
2 2
 /**
3
- * Event Espresso
4
- *
5
- * Event Registration and Management Plugin for WordPress
6
- *
7
- * @ package			Event Espresso
8
- * @ author				Seth Shoultes
9
- * @ copyright		(c) 2008-2011 Event Espresso  All Rights Reserved.
10
- * @ license			{@link http://eventespresso.com/support/terms-conditions/}   * see Plugin Licensing *
11
- * @ link					{@link http://www.eventespresso.com}
12
- * @ since		 		4.0
13
- *
14
- * ------------------------------------------------------------------------
15
- *
16
- * EE_Admin_Transactions class
17
- *
18
- * @package			Event Espresso
19
- * @subpackage	includes/core/admin/transactions/Transactions_Admin_Page.core.php
20
- * @author				Brent Christensen
21
- *
22
- * ------------------------------------------------------------------------
23
- */
3
+	 * Event Espresso
4
+	 *
5
+	 * Event Registration and Management Plugin for WordPress
6
+	 *
7
+	 * @ package			Event Espresso
8
+	 * @ author				Seth Shoultes
9
+	 * @ copyright		(c) 2008-2011 Event Espresso  All Rights Reserved.
10
+	 * @ license			{@link http://eventespresso.com/support/terms-conditions/}   * see Plugin Licensing *
11
+	 * @ link					{@link http://www.eventespresso.com}
12
+	 * @ since		 		4.0
13
+	 *
14
+	 * ------------------------------------------------------------------------
15
+	 *
16
+	 * EE_Admin_Transactions class
17
+	 *
18
+	 * @package			Event Espresso
19
+	 * @subpackage	includes/core/admin/transactions/Transactions_Admin_Page.core.php
20
+	 * @author				Brent Christensen
21
+	 *
22
+	 * ------------------------------------------------------------------------
23
+	 */
24 24
 class Transactions_Admin_Page extends EE_Admin_Page {
25 25
 
26 26
 	/**
@@ -106,9 +106,9 @@  discard block
 block discarded – undo
106 106
 
107 107
 	/**
108 108
 	 * 		grab url requests and route them
109
-	*		@access private
110
-	*		@return void
111
-	*/
109
+	 *		@access private
110
+	 *		@return void
111
+	 */
112 112
 	public function _set_page_routes() {
113 113
 
114 114
 		$this->_set_transaction_status_array();
@@ -261,10 +261,10 @@  discard block
 block discarded – undo
261 261
 	/**
262 262
 	 * _set_transaction_status_array
263 263
 	 * sets list of transaction statuses
264
-	*
264
+	 *
265 265
 	 * @access private
266
-	*	@return void
267
-	*/
266
+	 *	@return void
267
+	 */
268 268
 	private function _set_transaction_status_array() {
269 269
 		self::$_txn_status = EEM_Transaction::instance()->status_array(TRUE);
270 270
 	}
@@ -286,10 +286,10 @@  discard block
 block discarded – undo
286 286
 
287 287
 	/**
288 288
 	 * 	get list of payment statuses
289
-	*
289
+	 *
290 290
 	 * @access private
291
-	*	@return void
292
-	*/
291
+	 *	@return void
292
+	 */
293 293
 	private function _get_payment_status_array() {
294 294
 		self::$_pay_status = EEM_Payment::instance()->status_array(TRUE);
295 295
 		$this->_template_args['payment_status'] = self::$_pay_status;
@@ -397,18 +397,18 @@  discard block
 block discarded – undo
397 397
 		if ( is_object( $this->_transaction) )
398 398
 			return; //get out we've already set the object
399 399
 
400
-	    $TXN = EEM_Transaction::instance();
400
+		$TXN = EEM_Transaction::instance();
401 401
 
402
-	    $TXN_ID = ( ! empty( $this->_req_data['TXN_ID'] )) ? absint( $this->_req_data['TXN_ID'] ) : FALSE;
402
+		$TXN_ID = ( ! empty( $this->_req_data['TXN_ID'] )) ? absint( $this->_req_data['TXN_ID'] ) : FALSE;
403 403
 
404
-	    //get transaction object
405
-	    $this->_transaction = $TXN->get_one_by_ID($TXN_ID);
406
-	    $this->_session = !empty( $this->_transaction ) ? $this->_transaction->get('TXN_session_data') : NULL;
404
+		//get transaction object
405
+		$this->_transaction = $TXN->get_one_by_ID($TXN_ID);
406
+		$this->_session = !empty( $this->_transaction ) ? $this->_transaction->get('TXN_session_data') : NULL;
407 407
 
408 408
 	 	if ( empty( $this->_transaction ) ) {
409
-	    	$error_msg = __('An error occurred and the details for Transaction ID #', 'event_espresso') . $TXN_ID .  __(' could not be retrieved.', 'event_espresso');
409
+			$error_msg = __('An error occurred and the details for Transaction ID #', 'event_espresso') . $TXN_ID .  __(' could not be retrieved.', 'event_espresso');
410 410
 			EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ );
411
-	    }
411
+		}
412 412
 	}
413 413
 
414 414
 
@@ -510,12 +510,12 @@  discard block
 block discarded – undo
510 510
 
511 511
 
512 512
 	/**
513
-	* 	_transaction_details
513
+	 * 	_transaction_details
514 514
 	 * generates HTML for the View Transaction Details Admin page
515
-	*
515
+	 *
516 516
 	 * @access protected
517
-	*	@return void
518
-	*/
517
+	 *	@return void
518
+	 */
519 519
 	protected function _transaction_details() {
520 520
 		do_action( 'AHEE__Transactions_Admin_Page__transaction_details__start', $this->_transaction );
521 521
 		EE_Registry::instance()->load_helper( 'MSG_Template' );
@@ -568,7 +568,7 @@  discard block
 block discarded – undo
568 568
 						'button secondary-button right',
569 569
 						'dashicons dashicons-email-alt'
570 570
 					)
571
-				    : '';
571
+					: '';
572 572
 		} else {
573 573
 			$this->_template_args['send_payment_reminder_button'] = '';
574 574
 		}
@@ -722,10 +722,10 @@  discard block
 block discarded – undo
722 722
 	/**
723 723
 	 * txn_details_meta_box
724 724
 	 * generates HTML for the Transaction main meta box
725
-	*
725
+	 *
726 726
 	 * @access public
727
-	*	@return void
728
-	*/
727
+	 *	@return void
728
+	 */
729 729
 	public function txn_details_meta_box() {
730 730
 
731 731
 		$this->_set_transaction_object();
@@ -1066,10 +1066,10 @@  discard block
 block discarded – undo
1066 1066
 	/**
1067 1067
 	 * txn_billing_info_side_meta_box
1068 1068
 	 * 	generates HTML for the Edit Transaction side meta box
1069
-	*
1069
+	 *
1070 1070
 	 * @access public
1071
-	*	@return void
1072
-	*/
1071
+	 *	@return void
1072
+	 */
1073 1073
 	public function txn_billing_info_side_meta_box() {
1074 1074
 
1075 1075
 		$this->_template_args['billing_form'] = $this->_transaction->billing_info();
@@ -1087,10 +1087,10 @@  discard block
 block discarded – undo
1087 1087
 	/**
1088 1088
 	 * apply_payments_or_refunds
1089 1089
 	 * 	registers a payment or refund made towards a transaction
1090
-	*
1090
+	 *
1091 1091
 	 * @access public
1092
-	*	@return void
1093
-	*/
1092
+	 *	@return void
1093
+	 */
1094 1094
 	public function apply_payments_or_refunds() {
1095 1095
 		$json_response_data = array( 'return_data' => FALSE );
1096 1096
 		$valid_data = $this->_validate_payment_request_data();
@@ -1244,9 +1244,9 @@  discard block
 block discarded – undo
1244 1244
 							'default' => '',
1245 1245
 							'required' => false,
1246 1246
 							'html_label_text' => __( 'Transaction or Cheque Number', 'event_espresso' ),
1247
-                                                        'validation_strategies' => array(
1248
-                                                            new EE_Max_Length_Validation_Strategy( __('Input too long', 'event_espresso'), 100 ),
1249
-                                                        )
1247
+														'validation_strategies' => array(
1248
+															new EE_Max_Length_Validation_Strategy( __('Input too long', 'event_espresso'), 100 ),
1249
+														)
1250 1250
 						)
1251 1251
 					),
1252 1252
 					'po_number' => new EE_Text_Input(
@@ -1254,9 +1254,9 @@  discard block
 block discarded – undo
1254 1254
 							'default' => '',
1255 1255
 							'required' => false,
1256 1256
 							'html_label_text' => __( 'Purchase Order Number', 'event_espresso' ),
1257
-                                                        'validation_strategies' => array(
1258
-                                                            new EE_Max_Length_Validation_Strategy( __('Input too long', 'event_espresso'), 100 ),
1259
-                                                        )
1257
+														'validation_strategies' => array(
1258
+															new EE_Max_Length_Validation_Strategy( __('Input too long', 'event_espresso'), 100 ),
1259
+														)
1260 1260
 						)
1261 1261
 					),
1262 1262
 					'accounting' => new EE_Text_Input(
@@ -1264,9 +1264,9 @@  discard block
 block discarded – undo
1264 1264
 							'default' => '',
1265 1265
 							'required' => false,
1266 1266
 							'html_label_text' => __( 'Extra Field for Accounting', 'event_espresso' ),
1267
-                                                        'validation_strategies' => array(
1268
-                                                            new EE_Max_Length_Validation_Strategy( __('Input too long', 'event_espresso'), 100 ),
1269
-                                                        )
1267
+														'validation_strategies' => array(
1268
+															new EE_Max_Length_Validation_Strategy( __('Input too long', 'event_espresso'), 100 ),
1269
+														)
1270 1270
 						)
1271 1271
 					),
1272 1272
 				)
@@ -1561,10 +1561,10 @@  discard block
 block discarded – undo
1561 1561
 	/**
1562 1562
 	 * delete_payment
1563 1563
 	 * 	delete a payment or refund made towards a transaction
1564
-	*
1564
+	 *
1565 1565
 	 * @access public
1566
-	*	@return void
1567
-	*/
1566
+	 *	@return void
1567
+	 */
1568 1568
 	public function delete_payment() {
1569 1569
 		$json_response_data = array( 'return_data' => FALSE );
1570 1570
 		$PAY_ID = isset( $this->_req_data['delete_txn_admin_payment'], $this->_req_data['delete_txn_admin_payment']['PAY_ID'] ) ? absint( $this->_req_data['delete_txn_admin_payment']['PAY_ID'] ) : 0;
@@ -1682,12 +1682,12 @@  discard block
 block discarded – undo
1682 1682
 	/**
1683 1683
 	 * _send_payment_reminder
1684 1684
 	 * 	generates HTML for the View Transaction Details Admin page
1685
-	*
1685
+	 *
1686 1686
 	 * @access protected
1687
-	*	@return void
1688
-	*/
1687
+	 *	@return void
1688
+	 */
1689 1689
 	protected function _send_payment_reminder() {
1690
-	    $TXN_ID = ( ! empty( $this->_req_data['TXN_ID'] )) ? absint( $this->_req_data['TXN_ID'] ) : FALSE;
1690
+		$TXN_ID = ( ! empty( $this->_req_data['TXN_ID'] )) ? absint( $this->_req_data['TXN_ID'] ) : FALSE;
1691 1691
 		$transaction = EEM_Transaction::instance()->get_one_by_ID( $TXN_ID );
1692 1692
 		$query_args = isset($this->_req_data['redirect_to'] ) ? array('action' => $this->_req_data['redirect_to'], 'TXN_ID' => $this->_req_data['TXN_ID'] ) : array();
1693 1693
 		do_action( 'AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder', $transaction );
@@ -1709,29 +1709,29 @@  discard block
 block discarded – undo
1709 1709
 
1710 1710
 		$TXN = EEM_Transaction::instance();
1711 1711
 
1712
-	    $start_date = isset( $this->_req_data['txn-filter-start-date'] ) ? wp_strip_all_tags( $this->_req_data['txn-filter-start-date'] ) : date( 'm/d/Y', strtotime( '-10 year' ));
1713
-	    $end_date = isset( $this->_req_data['txn-filter-end-date'] ) ? wp_strip_all_tags( $this->_req_data['txn-filter-end-date'] ) : date( 'm/d/Y' );
1712
+		$start_date = isset( $this->_req_data['txn-filter-start-date'] ) ? wp_strip_all_tags( $this->_req_data['txn-filter-start-date'] ) : date( 'm/d/Y', strtotime( '-10 year' ));
1713
+		$end_date = isset( $this->_req_data['txn-filter-end-date'] ) ? wp_strip_all_tags( $this->_req_data['txn-filter-end-date'] ) : date( 'm/d/Y' );
1714 1714
 
1715
-	    //make sure our timestamps start and end right at the boundaries for each day
1716
-	    $start_date = date( 'Y-m-d', strtotime( $start_date ) ) . ' 00:00:00';
1717
-	    $end_date = date( 'Y-m-d', strtotime( $end_date ) ) . ' 23:59:59';
1715
+		//make sure our timestamps start and end right at the boundaries for each day
1716
+		$start_date = date( 'Y-m-d', strtotime( $start_date ) ) . ' 00:00:00';
1717
+		$end_date = date( 'Y-m-d', strtotime( $end_date ) ) . ' 23:59:59';
1718 1718
 
1719 1719
 
1720
-	    //convert to timestamps
1721
-	    $start_date = strtotime( $start_date );
1722
-	    $end_date = strtotime( $end_date );
1720
+		//convert to timestamps
1721
+		$start_date = strtotime( $start_date );
1722
+		$end_date = strtotime( $end_date );
1723 1723
 
1724
-	    //makes sure start date is the lowest value and vice versa
1725
-	    $start_date = min( $start_date, $end_date );
1726
-	    $end_date = max( $start_date, $end_date );
1724
+		//makes sure start date is the lowest value and vice versa
1725
+		$start_date = min( $start_date, $end_date );
1726
+		$end_date = max( $start_date, $end_date );
1727 1727
 
1728
-	    //convert to correct format for query
1728
+		//convert to correct format for query
1729 1729
 	$start_date = EEM_Transaction::instance()->convert_datetime_for_query( 'TXN_timestamp', date( 'Y-m-d H:i:s', $start_date ), 'Y-m-d H:i:s' );
1730 1730
 	$end_date = EEM_Transaction::instance()->convert_datetime_for_query( 'TXN_timestamp', date( 'Y-m-d H:i:s', $end_date ), 'Y-m-d H:i:s' );
1731 1731
 
1732 1732
 
1733 1733
 
1734
-	    //set orderby
1734
+		//set orderby
1735 1735
 		$this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : '';
1736 1736
 
1737 1737
 		switch ( $this->_req_data['orderby'] ) {
Please login to merge, or discard this patch.
Spacing   +398 added lines, -398 removed lines patch added patch discarded remove patch
@@ -56,8 +56,8 @@  discard block
 block discarded – undo
56 56
 	 * @param bool $routing
57 57
 	 * @return Transactions_Admin_Page
58 58
 	 */
59
-	public function __construct( $routing = TRUE ) {
60
-		parent::__construct( $routing );
59
+	public function __construct($routing = TRUE) {
60
+		parent::__construct($routing);
61 61
 	}
62 62
 
63 63
 
@@ -80,9 +80,9 @@  discard block
 block discarded – undo
80 80
 	 * @return void
81 81
 	 */
82 82
 	protected function _ajax_hooks() {
83
-		add_action('wp_ajax_espresso_apply_payment', array( $this, 'apply_payments_or_refunds'));
84
-		add_action('wp_ajax_espresso_apply_refund', array( $this, 'apply_payments_or_refunds'));
85
-		add_action('wp_ajax_espresso_delete_payment', array( $this, 'delete_payment'));
83
+		add_action('wp_ajax_espresso_apply_payment', array($this, 'apply_payments_or_refunds'));
84
+		add_action('wp_ajax_espresso_apply_refund', array($this, 'apply_payments_or_refunds'));
85
+		add_action('wp_ajax_espresso_delete_payment', array($this, 'delete_payment'));
86 86
 	}
87 87
 
88 88
 
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 			'buttons' => array(
98 98
 				'add' => __('Add New Transaction', 'event_espresso'),
99 99
 				'edit' => __('Edit Transaction', 'event_espresso'),
100
-				'delete' => __('Delete Transaction','event_espresso'),
100
+				'delete' => __('Delete Transaction', 'event_espresso'),
101 101
 			)
102 102
 		);
103 103
 	}
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 
114 114
 		$this->_set_transaction_status_array();
115 115
 
116
-		$txn_id = ! empty( $this->_req_data['TXN_ID'] ) && ! is_array( $this->_req_data['TXN_ID'] ) ? $this->_req_data['TXN_ID'] : 0;
116
+		$txn_id = ! empty($this->_req_data['TXN_ID']) && ! is_array($this->_req_data['TXN_ID']) ? $this->_req_data['TXN_ID'] : 0;
117 117
 
118 118
 		$this->_page_routes = array(
119 119
 
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 						'filename' => 'transactions_overview_views_filters_search'
186 186
 					),
187 187
 				),
188
-				'help_tour' => array( 'Transactions_Overview_Help_Tour' ),
188
+				'help_tour' => array('Transactions_Overview_Help_Tour'),
189 189
 				/**
190 190
 				 * commented out because currently we are not displaying tips for transaction list table status but this
191 191
 				 * may change in a later iteration so want to keep the code for then.
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 				'nav' => array(
198 198
 					'label' => __('View Transaction', 'event_espresso'),
199 199
 					'order' => 5,
200
-					'url' => isset($this->_req_data['TXN_ID']) ? add_query_arg(array('TXN_ID' => $this->_req_data['TXN_ID'] ), $this->_current_page_view_url )  : $this->_admin_base_url,
200
+					'url' => isset($this->_req_data['TXN_ID']) ? add_query_arg(array('TXN_ID' => $this->_req_data['TXN_ID']), $this->_current_page_view_url) : $this->_admin_base_url,
201 201
 					'persistent' => FALSE
202 202
 					),
203 203
 				'help_tabs' => array(
@@ -218,8 +218,8 @@  discard block
 block discarded – undo
218 218
 						'filename' => 'transactions_view_transaction_primary_registrant_billing_information'
219 219
 					),
220 220
 				),
221
-				'qtips' => array( 'Transaction_Details_Tips' ),
222
-				'help_tour' => array( 'Transaction_Details_Help_Tour' ),
221
+				'qtips' => array('Transaction_Details_Tips'),
222
+				'help_tour' => array('Transaction_Details_Help_Tour'),
223 223
 				'metaboxes' => array('_transaction_details_metaboxes'),
224 224
 
225 225
 				'require_nonce' => FALSE
@@ -237,21 +237,21 @@  discard block
 block discarded – undo
237 237
 		// IF a registration was JUST added via the admin...
238 238
 		if (
239 239
 		isset(
240
-			$this->_req_data[ 'redirect_from' ],
241
-			$this->_req_data[ 'EVT_ID' ],
242
-			$this->_req_data[ 'event_name' ]
240
+			$this->_req_data['redirect_from'],
241
+			$this->_req_data['EVT_ID'],
242
+			$this->_req_data['event_name']
243 243
 		)
244 244
 		) {
245 245
 			// then set a cookie so that we can block any attempts to use
246 246
 			// the back button as a way to enter another registration.
247
-			setcookie( 'ee_registration_added', $this->_req_data[ 'EVT_ID' ], time() + WEEK_IN_SECONDS, '/' );
247
+			setcookie('ee_registration_added', $this->_req_data['EVT_ID'], time() + WEEK_IN_SECONDS, '/');
248 248
 			// and update the global
249
-			$_COOKIE[ 'ee_registration_added' ] = $this->_req_data[ 'EVT_ID' ];
249
+			$_COOKIE['ee_registration_added'] = $this->_req_data['EVT_ID'];
250 250
 		}
251
-		EE_Registry::$i18n_js_strings[ 'invalid_server_response' ] = __( 'An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.', 'event_espresso' );
252
-		EE_Registry::$i18n_js_strings[ 'error_occurred' ] = __( 'An error occurred! Please refresh the page and try again.', 'event_espresso' );
253
-		EE_Registry::$i18n_js_strings[ 'txn_status_array' ] = self::$_txn_status;
254
-		EE_Registry::$i18n_js_strings[ 'pay_status_array' ] = self::$_pay_status;
251
+		EE_Registry::$i18n_js_strings['invalid_server_response'] = __('An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.', 'event_espresso');
252
+		EE_Registry::$i18n_js_strings['error_occurred'] = __('An error occurred! Please refresh the page and try again.', 'event_espresso');
253
+		EE_Registry::$i18n_js_strings['txn_status_array'] = self::$_txn_status;
254
+		EE_Registry::$i18n_js_strings['pay_status_array'] = self::$_pay_status;
255 255
 	}
256 256
 	public function admin_notices() {}
257 257
 	public function admin_footer_scripts() {}
@@ -318,14 +318,14 @@  discard block
 block discarded – undo
318 318
 	 */
319 319
 	public function load_scripts_styles() {
320 320
 		//enqueue style
321
-		wp_register_style( 'espresso_txn', TXN_ASSETS_URL . 'espresso_transactions_admin.css', array(), EVENT_ESPRESSO_VERSION );
321
+		wp_register_style('espresso_txn', TXN_ASSETS_URL.'espresso_transactions_admin.css', array(), EVENT_ESPRESSO_VERSION);
322 322
 		wp_enqueue_style('espresso_txn');
323 323
 
324 324
 		//scripts
325 325
 		add_filter('FHEE_load_accounting_js', '__return_true');
326 326
 
327 327
 		//scripts
328
-		wp_register_script('espresso_txn', TXN_ASSETS_URL . 'espresso_transactions_admin.js', array('ee_admin_js', 'ee-datepicker', 'jquery-ui-datepicker', 'jquery-ui-draggable', 'ee-dialog', 'ee-accounting', 'ee-serialize-full-array'), EVENT_ESPRESSO_VERSION, TRUE);
328
+		wp_register_script('espresso_txn', TXN_ASSETS_URL.'espresso_transactions_admin.js', array('ee_admin_js', 'ee-datepicker', 'jquery-ui-datepicker', 'jquery-ui-draggable', 'ee-dialog', 'ee-accounting', 'ee-serialize-full-array'), EVENT_ESPRESSO_VERSION, TRUE);
329 329
 		wp_enqueue_script('espresso_txn');
330 330
 
331 331
 	}
@@ -365,8 +365,8 @@  discard block
 block discarded – undo
365 365
 	 *	@return void
366 366
 	 */
367 367
 	protected function _set_list_table_views_default() {
368
-		$this->_views = array (
369
-			'all' => array (
368
+		$this->_views = array(
369
+			'all' => array(
370 370
 				'slug' 		=> 'all',
371 371
 				'label' 		=> __('View All Transactions', 'event_espresso'),
372 372
 				'count' 	=> 0
@@ -394,20 +394,20 @@  discard block
 block discarded – undo
394 394
 	 *	@return void
395 395
 	 */
396 396
 	private function _set_transaction_object() {
397
-		if ( is_object( $this->_transaction) )
397
+		if (is_object($this->_transaction))
398 398
 			return; //get out we've already set the object
399 399
 
400 400
 	    $TXN = EEM_Transaction::instance();
401 401
 
402
-	    $TXN_ID = ( ! empty( $this->_req_data['TXN_ID'] )) ? absint( $this->_req_data['TXN_ID'] ) : FALSE;
402
+	    $TXN_ID = ( ! empty($this->_req_data['TXN_ID'])) ? absint($this->_req_data['TXN_ID']) : FALSE;
403 403
 
404 404
 	    //get transaction object
405 405
 	    $this->_transaction = $TXN->get_one_by_ID($TXN_ID);
406
-	    $this->_session = !empty( $this->_transaction ) ? $this->_transaction->get('TXN_session_data') : NULL;
406
+	    $this->_session = ! empty($this->_transaction) ? $this->_transaction->get('TXN_session_data') : NULL;
407 407
 
408
-	 	if ( empty( $this->_transaction ) ) {
409
-	    	$error_msg = __('An error occurred and the details for Transaction ID #', 'event_espresso') . $TXN_ID .  __(' could not be retrieved.', 'event_espresso');
410
-			EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ );
408
+	 	if (empty($this->_transaction)) {
409
+	    	$error_msg = __('An error occurred and the details for Transaction ID #', 'event_espresso').$TXN_ID.__(' could not be retrieved.', 'event_espresso');
410
+			EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
411 411
 	    }
412 412
 	}
413 413
 
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
 				),
434 434
 				'view_receipt' => array(
435 435
 					'class' => 'dashicons dashicons-media-default',
436
-					'desc' => __('View Transaction Receipt', 'event_espresso' )
436
+					'desc' => __('View Transaction Receipt', 'event_espresso')
437 437
 				),
438 438
 				'view_registration' => array(
439 439
 					'class' => 'dashicons dashicons-clipboard',
@@ -442,9 +442,9 @@  discard block
 block discarded – undo
442 442
 			)
443 443
 		);
444 444
 
445
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'espresso_transactions_send_payment_reminder' ) ) {
445
+		if (EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'espresso_transactions_send_payment_reminder')) {
446 446
 
447
-			if ( EEH_MSG_Template::is_mt_active( 'payment_reminder' ) ) {
447
+			if (EEH_MSG_Template::is_mt_active('payment_reminder')) {
448 448
 				$items['send_payment_reminder'] = array(
449 449
 					'class' => 'dashicons dashicons-email-alt',
450 450
 					'desc' => __('Send Payment Reminder', 'event_espresso')
@@ -465,29 +465,29 @@  discard block
 block discarded – undo
465 465
 			'FHEE__Transactions_Admin_Page___transaction_legend_items__more_items',
466 466
 			array(
467 467
 				'overpaid'   => array(
468
-					'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::overpaid_status_code,
469
-					'desc'  => EEH_Template::pretty_status( EEM_Transaction::overpaid_status_code, FALSE, 'sentence' )
468
+					'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::overpaid_status_code,
469
+					'desc'  => EEH_Template::pretty_status(EEM_Transaction::overpaid_status_code, FALSE, 'sentence')
470 470
 				),
471 471
 				'complete'   => array(
472
-					'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::complete_status_code,
473
-					'desc'  => EEH_Template::pretty_status( EEM_Transaction::complete_status_code, FALSE, 'sentence' )
472
+					'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::complete_status_code,
473
+					'desc'  => EEH_Template::pretty_status(EEM_Transaction::complete_status_code, FALSE, 'sentence')
474 474
 				),
475 475
 				'incomplete' => array(
476
-					'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::incomplete_status_code,
477
-					'desc'  => EEH_Template::pretty_status( EEM_Transaction::incomplete_status_code, FALSE, 'sentence' )
476
+					'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::incomplete_status_code,
477
+					'desc'  => EEH_Template::pretty_status(EEM_Transaction::incomplete_status_code, FALSE, 'sentence')
478 478
 				),
479 479
 				'abandoned'  => array(
480
-					'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::abandoned_status_code,
481
-					'desc'  => EEH_Template::pretty_status( EEM_Transaction::abandoned_status_code, FALSE, 'sentence' )
480
+					'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::abandoned_status_code,
481
+					'desc'  => EEH_Template::pretty_status(EEM_Transaction::abandoned_status_code, FALSE, 'sentence')
482 482
 				),
483 483
 				'failed'     => array(
484
-					'class' => 'ee-status-legend ee-status-legend-' . EEM_Transaction::failed_status_code,
485
-					'desc'  => EEH_Template::pretty_status( EEM_Transaction::failed_status_code, FALSE, 'sentence' )
484
+					'class' => 'ee-status-legend ee-status-legend-'.EEM_Transaction::failed_status_code,
485
+					'desc'  => EEH_Template::pretty_status(EEM_Transaction::failed_status_code, FALSE, 'sentence')
486 486
 				)
487 487
 			)
488 488
 		);
489 489
 
490
-		return array_merge( $items, $more_items);
490
+		return array_merge($items, $more_items);
491 491
 	}
492 492
 
493 493
 
@@ -500,9 +500,9 @@  discard block
 block discarded – undo
500 500
 	 */
501 501
 	protected function _transactions_overview_list_table() {
502 502
 		$this->_admin_page_title = __('Transactions', 'event_espresso');
503
-		$event = isset($this->_req_data['EVT_ID']) ? EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID'] ) : NULL;
504
-		$this->_template_args['admin_page_header'] = $event instanceof EE_Event ? sprintf( __('%sViewing Transactions for the Event: %s%s', 'event_espresso'), '<h3>', '<a href="' . EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit', 'post' => $event->ID()), EVENTS_ADMIN_URL ) . '" title="' . esc_attr__('Click to Edit event', 'event_espresso') . '">' . $event->get('EVT_name') . '</a>', '</h3>' ) : '';
505
-		$this->_template_args['after_list_table'] = $this->_display_legend( $this->_transaction_legend_items() );
503
+		$event = isset($this->_req_data['EVT_ID']) ? EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID']) : NULL;
504
+		$this->_template_args['admin_page_header'] = $event instanceof EE_Event ? sprintf(__('%sViewing Transactions for the Event: %s%s', 'event_espresso'), '<h3>', '<a href="'.EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit', 'post' => $event->ID()), EVENTS_ADMIN_URL).'" title="'.esc_attr__('Click to Edit event', 'event_espresso').'">'.$event->get('EVT_name').'</a>', '</h3>') : '';
505
+		$this->_template_args['after_list_table'] = $this->_display_legend($this->_transaction_legend_items());
506 506
 		$this->display_admin_list_table_page_with_no_sidebar();
507 507
 	}
508 508
 
@@ -516,7 +516,7 @@  discard block
 block discarded – undo
516 516
 	*	@return void
517 517
 	*/
518 518
 	protected function _transaction_details() {
519
-		do_action( 'AHEE__Transactions_Admin_Page__transaction_details__start', $this->_transaction );
519
+		do_action('AHEE__Transactions_Admin_Page__transaction_details__start', $this->_transaction);
520 520
 
521 521
 		$this->_set_transaction_status_array();
522 522
 
@@ -529,14 +529,14 @@  discard block
 block discarded – undo
529 529
 		$attendee = $primary_registration instanceof EE_Registration ? $primary_registration->attendee() : NULL;
530 530
 
531 531
 		$this->_template_args['txn_nmbr']['value'] = $this->_transaction->ID();
532
-		$this->_template_args['txn_nmbr']['label'] = __( 'Transaction Number', 'event_espresso' );
532
+		$this->_template_args['txn_nmbr']['label'] = __('Transaction Number', 'event_espresso');
533 533
 
534
-		$this->_template_args['txn_datetime']['value'] = $this->_transaction->get_datetime('TXN_timestamp', 'l F j, Y', 'g:i:s a' );
535
-		$this->_template_args['txn_datetime']['label'] = __( 'Date', 'event_espresso' );
534
+		$this->_template_args['txn_datetime']['value'] = $this->_transaction->get_datetime('TXN_timestamp', 'l F j, Y', 'g:i:s a');
535
+		$this->_template_args['txn_datetime']['label'] = __('Date', 'event_espresso');
536 536
 
537
-		$this->_template_args['txn_status']['value'] = self::$_txn_status[ $this->_transaction->get('STS_ID') ];
538
-		$this->_template_args['txn_status']['label'] = __( 'Transaction Status', 'event_espresso' );
539
-		$this->_template_args['txn_status']['class'] = 'status-' . $this->_transaction->get('STS_ID');
537
+		$this->_template_args['txn_status']['value'] = self::$_txn_status[$this->_transaction->get('STS_ID')];
538
+		$this->_template_args['txn_status']['label'] = __('Transaction Status', 'event_espresso');
539
+		$this->_template_args['txn_status']['class'] = 'status-'.$this->_transaction->get('STS_ID');
540 540
 
541 541
 		$this->_template_args['grand_total'] = $this->_transaction->get('TXN_total');
542 542
 		$this->_template_args['total_paid'] = $this->_transaction->get('TXN_paid');
@@ -549,7 +549,7 @@  discard block
 block discarded – undo
549 549
 			)
550 550
 		) {
551 551
 			$this->_template_args['send_payment_reminder_button'] =
552
-				EEH_MSG_Template::is_mt_active( 'payment_reminder' )
552
+				EEH_MSG_Template::is_mt_active('payment_reminder')
553 553
 				&& $this->_transaction->get('STS_ID') != EEM_Transaction::complete_status_code
554 554
 				&& $this->_transaction->get('STS_ID') != EEM_Transaction::overpaid_status_code
555 555
 					? EEH_Template::get_button_or_link(
@@ -571,40 +571,40 @@  discard block
 block discarded – undo
571 571
 		}
572 572
 
573 573
 		$amount_due = $this->_transaction->get('TXN_total') - $this->_transaction->get('TXN_paid');
574
-		$this->_template_args['amount_due'] = EEH_Template::format_currency( $amount_due, TRUE );
575
-		if ( EE_Registry::instance()->CFG->currency->sign_b4 ) {
576
-			$this->_template_args['amount_due'] = EE_Registry::instance()->CFG->currency->sign . $this->_template_args['amount_due'];
574
+		$this->_template_args['amount_due'] = EEH_Template::format_currency($amount_due, TRUE);
575
+		if (EE_Registry::instance()->CFG->currency->sign_b4) {
576
+			$this->_template_args['amount_due'] = EE_Registry::instance()->CFG->currency->sign.$this->_template_args['amount_due'];
577 577
 		} else {
578
-			$this->_template_args['amount_due'] = $this->_template_args['amount_due'] . EE_Registry::instance()->CFG->currency->sign;
578
+			$this->_template_args['amount_due'] = $this->_template_args['amount_due'].EE_Registry::instance()->CFG->currency->sign;
579 579
 		}
580
-		$this->_template_args['amount_due_class'] =  '';
580
+		$this->_template_args['amount_due_class'] = '';
581 581
 
582
-		if ( $this->_transaction->get('TXN_paid') == $this->_transaction->get('TXN_total') ) {
582
+		if ($this->_transaction->get('TXN_paid') == $this->_transaction->get('TXN_total')) {
583 583
 			// paid in full
584
-			$this->_template_args['amount_due'] =  FALSE;
585
-		} elseif ( $this->_transaction->get('TXN_paid') > $this->_transaction->get('TXN_total') ) {
584
+			$this->_template_args['amount_due'] = FALSE;
585
+		} elseif ($this->_transaction->get('TXN_paid') > $this->_transaction->get('TXN_total')) {
586 586
 			// overpaid
587
-			$this->_template_args['amount_due_class'] =  'txn-overview-no-payment-spn';
588
-		} elseif (( $this->_transaction->get('TXN_total') > 0 ) && ( $this->_transaction->get('TXN_paid') > 0 )) {
587
+			$this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn';
588
+		} elseif (($this->_transaction->get('TXN_total') > 0) && ($this->_transaction->get('TXN_paid') > 0)) {
589 589
 			// monies owing
590
-			$this->_template_args['amount_due_class'] =  'txn-overview-part-payment-spn';
591
-		} elseif (( $this->_transaction->get('TXN_total') > 0 ) && ( $this->_transaction->get('TXN_paid') == 0 )) {
590
+			$this->_template_args['amount_due_class'] = 'txn-overview-part-payment-spn';
591
+		} elseif (($this->_transaction->get('TXN_total') > 0) && ($this->_transaction->get('TXN_paid') == 0)) {
592 592
 			// no payments made yet
593
-			$this->_template_args['amount_due_class'] =  'txn-overview-no-payment-spn';
594
-		} elseif ( $this->_transaction->get('TXN_total') == 0 ) {
593
+			$this->_template_args['amount_due_class'] = 'txn-overview-no-payment-spn';
594
+		} elseif ($this->_transaction->get('TXN_total') == 0) {
595 595
 			// free event
596
-			$this->_template_args['amount_due'] =  FALSE;
596
+			$this->_template_args['amount_due'] = FALSE;
597 597
 		}
598 598
 
599 599
 		$payment_method = $this->_transaction->payment_method();
600 600
 
601 601
 		$this->_template_args['method_of_payment_name'] = $payment_method instanceof EE_Payment_Method
602 602
 			? $payment_method->admin_name()
603
-			: __( 'Unknown', 'event_espresso' );
603
+			: __('Unknown', 'event_espresso');
604 604
 
605 605
 		$this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
606 606
 		// link back to overview
607
-		$this->_template_args['txn_overview_url'] = ! empty ( $_SERVER['HTTP_REFERER'] )
607
+		$this->_template_args['txn_overview_url'] = ! empty ($_SERVER['HTTP_REFERER'])
608 608
 			? $_SERVER['HTTP_REFERER']
609 609
 			: TXN_ADMIN_URL;
610 610
 
@@ -612,13 +612,13 @@  discard block
 block discarded – undo
612 612
 		// next link
613 613
 		$next_txn = $this->_transaction->next(
614 614
 			null,
615
-			array( array( 'STS_ID' => array( '!=', EEM_Transaction::failed_status_code ) ) ),
615
+			array(array('STS_ID' => array('!=', EEM_Transaction::failed_status_code))),
616 616
 			'TXN_ID'
617 617
 		);
618 618
 		$this->_template_args['next_transaction'] = $next_txn
619 619
 			? $this->_next_link(
620 620
 				EE_Admin_Page::add_query_args_and_nonce(
621
-					array( 'action' => 'view_transaction', 'TXN_ID' => $next_txn['TXN_ID'] ),
621
+					array('action' => 'view_transaction', 'TXN_ID' => $next_txn['TXN_ID']),
622 622
 					TXN_ADMIN_URL
623 623
 				),
624 624
 				'dashicons dashicons-arrow-right ee-icon-size-22'
@@ -627,13 +627,13 @@  discard block
 block discarded – undo
627 627
 		// previous link
628 628
 		$previous_txn = $this->_transaction->previous(
629 629
 			null,
630
-			array( array( 'STS_ID' => array( '!=', EEM_Transaction::failed_status_code ) ) ),
630
+			array(array('STS_ID' => array('!=', EEM_Transaction::failed_status_code))),
631 631
 			'TXN_ID'
632 632
 		);
633 633
 		$this->_template_args['previous_transaction'] = $previous_txn
634 634
 			? $this->_previous_link(
635 635
 				EE_Admin_Page::add_query_args_and_nonce(
636
-					array( 'action' => 'view_transaction', 'TXN_ID' => $previous_txn['TXN_ID'] ),
636
+					array('action' => 'view_transaction', 'TXN_ID' => $previous_txn['TXN_ID']),
637 637
 					TXN_ADMIN_URL
638 638
 				),
639 639
 				'dashicons dashicons-arrow-left ee-icon-size-22'
@@ -643,16 +643,16 @@  discard block
 block discarded – undo
643 643
 		// were we just redirected here after adding a new registration ???
644 644
 		if (
645 645
 			isset(
646
-				$this->_req_data[ 'redirect_from' ],
647
-				$this->_req_data[ 'EVT_ID' ],
648
-				$this->_req_data[ 'event_name' ]
646
+				$this->_req_data['redirect_from'],
647
+				$this->_req_data['EVT_ID'],
648
+				$this->_req_data['event_name']
649 649
 			)
650 650
 		) {
651 651
 			if (
652 652
 				EE_Registry::instance()->CAP->current_user_can(
653 653
 					'ee_edit_registrations',
654 654
 					'espresso_registrations_new_registration',
655
-					$this->_req_data[ 'EVT_ID' ]
655
+					$this->_req_data['EVT_ID']
656 656
 				)
657 657
 			) {
658 658
 				$this->_admin_page_title .= '<a id="add-new-registration" class="add-new-h2 button-primary" href="';
@@ -662,7 +662,7 @@  discard block
 block discarded – undo
662 662
 						'action'   => 'new_registration',
663 663
 						'return'   => 'default',
664 664
 						'TXN_ID'   => $this->_transaction->ID(),
665
-						'event_id' => $this->_req_data[ 'EVT_ID' ],
665
+						'event_id' => $this->_req_data['EVT_ID'],
666 666
 					),
667 667
 					REG_ADMIN_URL
668 668
 				);
@@ -670,17 +670,17 @@  discard block
 block discarded – undo
670 670
 
671 671
 				$this->_admin_page_title .= sprintf(
672 672
 					__('Add Another New Registration to Event: "%1$s" ?'),
673
-					htmlentities( urldecode( $this->_req_data[ 'event_name' ] ), ENT_QUOTES, 'UTF-8' )
673
+					htmlentities(urldecode($this->_req_data['event_name']), ENT_QUOTES, 'UTF-8')
674 674
 				);
675 675
 				$this->_admin_page_title .= '</a>';
676 676
 			}
677
-			EE_Registry::instance()->SSN->clear_session( __CLASS__, __FUNCTION__ );
677
+			EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
678 678
 		}
679 679
 		// grab messages at the last second
680 680
 		$this->_template_args['notices'] = EE_Error::get_notices();
681 681
 		// path to template
682
-		$template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_header.template.php';
683
-		$this->_template_args['admin_page_header'] = EEH_Template::display_template( $template_path, $this->_template_args, TRUE );
682
+		$template_path = TXN_TEMPLATE_PATH.'txn_admin_details_header.template.php';
683
+		$this->_template_args['admin_page_header'] = EEH_Template::display_template($template_path, $this->_template_args, TRUE);
684 684
 
685 685
 		// the details template wrapper
686 686
 		$this->display_admin_page_with_sidebar();
@@ -699,18 +699,18 @@  discard block
 block discarded – undo
699 699
 
700 700
 		$this->_set_transaction_object();
701 701
 
702
-		add_meta_box( 'edit-txn-details-mbox', __( 'Transaction Details', 'event_espresso' ), array( $this, 'txn_details_meta_box' ), $this->_wp_page_slug, 'normal', 'high' );
702
+		add_meta_box('edit-txn-details-mbox', __('Transaction Details', 'event_espresso'), array($this, 'txn_details_meta_box'), $this->_wp_page_slug, 'normal', 'high');
703 703
 		add_meta_box(
704 704
 			'edit-txn-attendees-mbox',
705
-			__( 'Attendees Registered in this Transaction', 'event_espresso' ),
706
-			array( $this, 'txn_attendees_meta_box' ),
705
+			__('Attendees Registered in this Transaction', 'event_espresso'),
706
+			array($this, 'txn_attendees_meta_box'),
707 707
 			$this->_wp_page_slug,
708 708
 			'normal',
709 709
 			'high',
710
-			array( 'TXN_ID' => $this->_transaction->ID() )
710
+			array('TXN_ID' => $this->_transaction->ID())
711 711
 		);
712
-		add_meta_box( 'edit-txn-registrant-mbox', __( 'Primary Contact', 'event_espresso' ), array( $this, 'txn_registrant_side_meta_box' ), $this->_wp_page_slug, 'side', 'high' );
713
-		add_meta_box( 'edit-txn-billing-info-mbox', __( 'Billing Information', 'event_espresso' ), array( $this, 'txn_billing_info_side_meta_box' ), $this->_wp_page_slug, 'side', 'high' );
712
+		add_meta_box('edit-txn-registrant-mbox', __('Primary Contact', 'event_espresso'), array($this, 'txn_registrant_side_meta_box'), $this->_wp_page_slug, 'side', 'high');
713
+		add_meta_box('edit-txn-billing-info-mbox', __('Billing Information', 'event_espresso'), array($this, 'txn_billing_info_side_meta_box'), $this->_wp_page_slug, 'side', 'high');
714 714
 
715 715
 	}
716 716
 
@@ -731,15 +731,15 @@  discard block
 block discarded – undo
731 731
 
732 732
 		//get line table
733 733
 		EEH_Autoloader::register_line_item_display_autoloaders();
734
-		$Line_Item_Display = new EE_Line_Item_Display( 'admin_table', 'EE_Admin_Table_Line_Item_Display_Strategy' );
735
-		$this->_template_args['line_item_table'] = $Line_Item_Display->display_line_item( $this->_transaction->total_line_item() );
734
+		$Line_Item_Display = new EE_Line_Item_Display('admin_table', 'EE_Admin_Table_Line_Item_Display_Strategy');
735
+		$this->_template_args['line_item_table'] = $Line_Item_Display->display_line_item($this->_transaction->total_line_item());
736 736
 		$this->_template_args['REG_code'] = $this->_transaction->get_first_related('Registration')->get('REG_code');
737 737
 
738 738
 		// process taxes
739
-		$taxes = $this->_transaction->get_many_related( 'Line_Item', array( array( 'LIN_type' => EEM_Line_Item::type_tax )));
740
-		$this->_template_args['taxes'] = ! empty( $taxes ) ? $taxes : FALSE;
739
+		$taxes = $this->_transaction->get_many_related('Line_Item', array(array('LIN_type' => EEM_Line_Item::type_tax)));
740
+		$this->_template_args['taxes'] = ! empty($taxes) ? $taxes : FALSE;
741 741
 
742
-		$this->_template_args['grand_total'] = EEH_Template::format_currency($this->_transaction->get('TXN_total'), FALSE, FALSE );
742
+		$this->_template_args['grand_total'] = EEH_Template::format_currency($this->_transaction->get('TXN_total'), FALSE, FALSE);
743 743
 		$this->_template_args['grand_raw_total'] = $this->_transaction->get('TXN_total');
744 744
 		$this->_template_args['TXN_status'] = $this->_transaction->get('STS_ID');
745 745
 
@@ -747,63 +747,63 @@  discard block
 block discarded – undo
747 747
 
748 748
 		// process payment details
749 749
 		$payments = $this->_transaction->get_many_related('Payment');
750
-		if( ! empty(  $payments ) ) {
751
-			$this->_template_args[ 'payments' ] = $payments;
752
-			$this->_template_args[ 'existing_reg_payments' ] = $this->_get_registration_payment_IDs( $payments );
750
+		if ( ! empty($payments)) {
751
+			$this->_template_args['payments'] = $payments;
752
+			$this->_template_args['existing_reg_payments'] = $this->_get_registration_payment_IDs($payments);
753 753
 		} else {
754
-			$this->_template_args[ 'payments' ] = false;
755
-			$this->_template_args[ 'existing_reg_payments' ] = array();
754
+			$this->_template_args['payments'] = false;
755
+			$this->_template_args['existing_reg_payments'] = array();
756 756
 		}
757 757
 
758
-		$this->_template_args['edit_payment_url'] = add_query_arg( array( 'action' => 'edit_payment'  ), TXN_ADMIN_URL );
759
-		$this->_template_args['delete_payment_url'] = add_query_arg( array( 'action' => 'espresso_delete_payment' ), TXN_ADMIN_URL );
758
+		$this->_template_args['edit_payment_url'] = add_query_arg(array('action' => 'edit_payment'), TXN_ADMIN_URL);
759
+		$this->_template_args['delete_payment_url'] = add_query_arg(array('action' => 'espresso_delete_payment'), TXN_ADMIN_URL);
760 760
 
761
-		if ( isset( $txn_details['invoice_number'] )) {
761
+		if (isset($txn_details['invoice_number'])) {
762 762
 			$this->_template_args['txn_details']['invoice_number']['value'] = $this->_template_args['REG_code'];
763
-			$this->_template_args['txn_details']['invoice_number']['label'] = __( 'Invoice Number', 'event_espresso' );
763
+			$this->_template_args['txn_details']['invoice_number']['label'] = __('Invoice Number', 'event_espresso');
764 764
 		}
765 765
 
766 766
 		$this->_template_args['txn_details']['registration_session']['value'] = $this->_transaction->get_first_related('Registration')->get('REG_session');
767
-		$this->_template_args['txn_details']['registration_session']['label'] = __( 'Registration Session', 'event_espresso' );
767
+		$this->_template_args['txn_details']['registration_session']['label'] = __('Registration Session', 'event_espresso');
768 768
 
769
-		$this->_template_args['txn_details']['ip_address']['value'] = isset( $this->_session['ip_address'] ) ? $this->_session['ip_address'] : '';
770
-		$this->_template_args['txn_details']['ip_address']['label'] = __( 'Transaction placed from IP', 'event_espresso' );
769
+		$this->_template_args['txn_details']['ip_address']['value'] = isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '';
770
+		$this->_template_args['txn_details']['ip_address']['label'] = __('Transaction placed from IP', 'event_espresso');
771 771
 
772
-		$this->_template_args['txn_details']['user_agent']['value'] = isset( $this->_session['user_agent'] ) ? $this->_session['user_agent'] : '';
773
-		$this->_template_args['txn_details']['user_agent']['label'] = __( 'Registrant User Agent', 'event_espresso' );
772
+		$this->_template_args['txn_details']['user_agent']['value'] = isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '';
773
+		$this->_template_args['txn_details']['user_agent']['label'] = __('Registrant User Agent', 'event_espresso');
774 774
 
775 775
 		$reg_steps = '<ul>';
776
-		foreach ( $this->_transaction->reg_steps() as $reg_step => $reg_step_status ) {
777
-			if ( $reg_step_status === true ) {
778
-				$reg_steps .= '<li style="color:#70cc50">' . sprintf( __( '%1$s : Completed', 'event_espresso' ), ucwords( str_replace( '_', ' ', $reg_step ) ) ) . '</li>';
779
-			} else if ( is_numeric( $reg_step_status ) && $reg_step_status !== false ) {
780
-					$reg_steps .= '<li style="color:#2EA2CC">' . sprintf(
781
-							__( '%1$s : Initiated %2$s', 'event_espresso' ),
782
-							ucwords( str_replace( '_', ' ', $reg_step ) ),
783
-							gmdate( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), ( $reg_step_status + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) ) )
784
-						) . '</li>';
776
+		foreach ($this->_transaction->reg_steps() as $reg_step => $reg_step_status) {
777
+			if ($reg_step_status === true) {
778
+				$reg_steps .= '<li style="color:#70cc50">'.sprintf(__('%1$s : Completed', 'event_espresso'), ucwords(str_replace('_', ' ', $reg_step))).'</li>';
779
+			} else if (is_numeric($reg_step_status) && $reg_step_status !== false) {
780
+					$reg_steps .= '<li style="color:#2EA2CC">'.sprintf(
781
+							__('%1$s : Initiated %2$s', 'event_espresso'),
782
+							ucwords(str_replace('_', ' ', $reg_step)),
783
+							gmdate(get_option('date_format').' '.get_option('time_format'), ($reg_step_status + (get_option('gmt_offset') * HOUR_IN_SECONDS)))
784
+						).'</li>';
785 785
 				} else {
786
-				$reg_steps .= '<li style="color:#E76700">' . sprintf( __( '%1$s : Never Initiated', 'event_espresso' ), ucwords( str_replace( '_', ' ', $reg_step ) ) ) . '</li>';
786
+				$reg_steps .= '<li style="color:#E76700">'.sprintf(__('%1$s : Never Initiated', 'event_espresso'), ucwords(str_replace('_', ' ', $reg_step))).'</li>';
787 787
 			}
788 788
 		}
789 789
 		$reg_steps .= '</ul>';
790 790
 		$this->_template_args['txn_details']['reg_steps']['value'] = $reg_steps;
791
-		$this->_template_args['txn_details']['reg_steps']['label'] = __( 'Registration Step Progress', 'event_espresso' );
791
+		$this->_template_args['txn_details']['reg_steps']['label'] = __('Registration Step Progress', 'event_espresso');
792 792
 
793 793
 
794 794
 		$this->_get_registrations_to_apply_payment_to();
795
-		$this->_get_payment_methods( $payments );
795
+		$this->_get_payment_methods($payments);
796 796
 		$this->_get_payment_status_array();
797 797
 		$this->_get_reg_status_selection(); //sets up the template args for the reg status array for the transaction.
798 798
 
799
-		$this->_template_args['transaction_form_url'] = add_query_arg( array( 'action' => 'edit_transaction', 'process' => 'transaction'  ), TXN_ADMIN_URL );
800
-		$this->_template_args['apply_payment_form_url'] = add_query_arg( array( 'page' => 'espresso_transactions', 'action' => 'espresso_apply_payment' ), WP_AJAX_URL );
801
-		$this->_template_args['delete_payment_form_url'] = add_query_arg( array( 'page' => 'espresso_transactions', 'action' => 'espresso_delete_payment' ), WP_AJAX_URL );
799
+		$this->_template_args['transaction_form_url'] = add_query_arg(array('action' => 'edit_transaction', 'process' => 'transaction'), TXN_ADMIN_URL);
800
+		$this->_template_args['apply_payment_form_url'] = add_query_arg(array('page' => 'espresso_transactions', 'action' => 'espresso_apply_payment'), WP_AJAX_URL);
801
+		$this->_template_args['delete_payment_form_url'] = add_query_arg(array('page' => 'espresso_transactions', 'action' => 'espresso_delete_payment'), WP_AJAX_URL);
802 802
 
803 803
 		// 'espresso_delete_payment_nonce'
804 804
 
805
-		$template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_txn_details.template.php';
806
-		echo EEH_Template::display_template( $template_path, $this->_template_args, TRUE );
805
+		$template_path = TXN_TEMPLATE_PATH.'txn_admin_details_main_meta_box_txn_details.template.php';
806
+		echo EEH_Template::display_template($template_path, $this->_template_args, TRUE);
807 807
 
808 808
 	}
809 809
 
@@ -818,27 +818,27 @@  discard block
 block discarded – undo
818 818
 	 * @param EE_Payment[] $payments
819 819
 	 * @return array
820 820
 	 */
821
-	protected function _get_registration_payment_IDs( $payments = array() ) {
821
+	protected function _get_registration_payment_IDs($payments = array()) {
822 822
 		$existing_reg_payments = array();
823 823
 		// get all reg payments for these payments
824
-		$reg_payments = EEM_Registration_Payment::instance()->get_all( array(
824
+		$reg_payments = EEM_Registration_Payment::instance()->get_all(array(
825 825
 			array(
826 826
 				'PAY_ID' => array(
827 827
 					'IN',
828
-					array_keys( $payments )
828
+					array_keys($payments)
829 829
 				)
830 830
 			)
831
-		) );
832
-		if ( ! empty( $reg_payments ) ) {
833
-			foreach ( $payments as $payment ) {
834
-				if ( ! $payment instanceof EE_Payment ) {
831
+		));
832
+		if ( ! empty($reg_payments)) {
833
+			foreach ($payments as $payment) {
834
+				if ( ! $payment instanceof EE_Payment) {
835 835
 					continue;
836
-				} else if ( ! isset( $existing_reg_payments[ $payment->ID() ] ) ) {
837
-					$existing_reg_payments[ $payment->ID() ] = array();
836
+				} else if ( ! isset($existing_reg_payments[$payment->ID()])) {
837
+					$existing_reg_payments[$payment->ID()] = array();
838 838
 				}
839
-				foreach ( $reg_payments as $reg_payment ) {
840
-					if ( $reg_payment instanceof EE_Registration_Payment && $reg_payment->payment_ID() === $payment->ID() ) {
841
-						$existing_reg_payments[ $payment->ID() ][ ] = $reg_payment->registration_ID();
839
+				foreach ($reg_payments as $reg_payment) {
840
+					if ($reg_payment instanceof EE_Registration_Payment && $reg_payment->payment_ID() === $payment->ID()) {
841
+						$existing_reg_payments[$payment->ID()][] = $reg_payment->registration_ID();
842 842
 					}
843 843
 				}
844 844
 			}
@@ -875,39 +875,39 @@  discard block
 block discarded – undo
875 875
 		$registrations_to_apply_payment_to .= '<br /><div class="admin-primary-mbox-tbl-wrap">';
876 876
 		$registrations_to_apply_payment_to .= '<table class="admin-primary-mbox-tbl">';
877 877
 		$registrations_to_apply_payment_to .= '<thead><tr>';
878
-		$registrations_to_apply_payment_to .= '<td>' . __( 'ID', 'event_espresso' ) . '</td>';
879
-		$registrations_to_apply_payment_to .= '<td>' . __( 'Registrant', 'event_espresso' ) . '</td>';
880
-		$registrations_to_apply_payment_to .= '<td>' . __( 'Ticket', 'event_espresso' ) . '</td>';
881
-		$registrations_to_apply_payment_to .= '<td>' . __( 'Event', 'event_espresso' ) . '</td>';
882
-		$registrations_to_apply_payment_to .= '<td class="txn-admin-payment-paid-td jst-cntr">' . __( 'Paid', 'event_espresso' ) . '</td>';
883
-		$registrations_to_apply_payment_to .= '<td class="txn-admin-payment-owing-td jst-cntr">' . __( 'Owing', 'event_espresso' ) . '</td>';
884
-		$registrations_to_apply_payment_to .= '<td class="jst-cntr">' . __( 'Apply', 'event_espresso' ) . '</td>';
878
+		$registrations_to_apply_payment_to .= '<td>'.__('ID', 'event_espresso').'</td>';
879
+		$registrations_to_apply_payment_to .= '<td>'.__('Registrant', 'event_espresso').'</td>';
880
+		$registrations_to_apply_payment_to .= '<td>'.__('Ticket', 'event_espresso').'</td>';
881
+		$registrations_to_apply_payment_to .= '<td>'.__('Event', 'event_espresso').'</td>';
882
+		$registrations_to_apply_payment_to .= '<td class="txn-admin-payment-paid-td jst-cntr">'.__('Paid', 'event_espresso').'</td>';
883
+		$registrations_to_apply_payment_to .= '<td class="txn-admin-payment-owing-td jst-cntr">'.__('Owing', 'event_espresso').'</td>';
884
+		$registrations_to_apply_payment_to .= '<td class="jst-cntr">'.__('Apply', 'event_espresso').'</td>';
885 885
 		$registrations_to_apply_payment_to .= '</tr></thead><tbody>';
886 886
 		// get registrations for TXN
887
-		$registrations = $this->_transaction->registrations( $query_params );
888
-		foreach ( $registrations as $registration ) {
889
-			if ( $registration instanceof EE_Registration ) {
887
+		$registrations = $this->_transaction->registrations($query_params);
888
+		foreach ($registrations as $registration) {
889
+			if ($registration instanceof EE_Registration) {
890 890
 				$owing = $registration->final_price() - $registration->paid();
891
-				$taxable = $registration->ticket()->taxable() ? ' <span class="smaller-text lt-grey-text"> ' . __( '+ tax', 'event_espresso' ) . '</span>' : '';
892
-				$checked = empty( $existing_reg_payments ) || in_array( $registration->ID(), $existing_reg_payments ) ? ' checked="checked"' : '';
893
-				$registrations_to_apply_payment_to .= '<tr id="apply-payment-registration-row-' . $registration->ID() . '">';
891
+				$taxable = $registration->ticket()->taxable() ? ' <span class="smaller-text lt-grey-text"> '.__('+ tax', 'event_espresso').'</span>' : '';
892
+				$checked = empty($existing_reg_payments) || in_array($registration->ID(), $existing_reg_payments) ? ' checked="checked"' : '';
893
+				$registrations_to_apply_payment_to .= '<tr id="apply-payment-registration-row-'.$registration->ID().'">';
894 894
 				// add html for checkbox input and label
895
-				$registrations_to_apply_payment_to .= '<td>' . $registration->ID() . '</td>';
896
-				$registrations_to_apply_payment_to .= '<td>' . $registration->attendee() instanceof EE_Attendee ? $registration->attendee()->full_name() : __( 'Unknown Attendee', 'event_espresso' ) . '</td>';
897
-				$registrations_to_apply_payment_to .= '<td>' . $registration->ticket()->name() . ' : ' . $registration->ticket()->pretty_price() . $taxable . '</td>';
898
-				$registrations_to_apply_payment_to .= '<td>' . $registration->event_name() . '</td>';
899
-				$registrations_to_apply_payment_to .= '<td class="txn-admin-payment-paid-td jst-rght">' . $registration->pretty_paid() . '</td>';
900
-				$registrations_to_apply_payment_to .= '<td class="txn-admin-payment-owing-td jst-rght">' . EEH_Template::format_currency( $owing ) . '</td>';
895
+				$registrations_to_apply_payment_to .= '<td>'.$registration->ID().'</td>';
896
+				$registrations_to_apply_payment_to .= '<td>'.$registration->attendee() instanceof EE_Attendee ? $registration->attendee()->full_name() : __('Unknown Attendee', 'event_espresso').'</td>';
897
+				$registrations_to_apply_payment_to .= '<td>'.$registration->ticket()->name().' : '.$registration->ticket()->pretty_price().$taxable.'</td>';
898
+				$registrations_to_apply_payment_to .= '<td>'.$registration->event_name().'</td>';
899
+				$registrations_to_apply_payment_to .= '<td class="txn-admin-payment-paid-td jst-rght">'.$registration->pretty_paid().'</td>';
900
+				$registrations_to_apply_payment_to .= '<td class="txn-admin-payment-owing-td jst-rght">'.EEH_Template::format_currency($owing).'</td>';
901 901
 				$registrations_to_apply_payment_to .= '<td class="jst-cntr">';
902 902
 				$disabled = $registration->final_price() > 0 ? '' : ' disabled';
903
-				$registrations_to_apply_payment_to .= '<input type="checkbox" value="' . $registration->ID() . '" name="txn_admin_payment[registrations]"' . $checked . $disabled . '>';
903
+				$registrations_to_apply_payment_to .= '<input type="checkbox" value="'.$registration->ID().'" name="txn_admin_payment[registrations]"'.$checked.$disabled.'>';
904 904
 				$registrations_to_apply_payment_to .= '</td>';
905 905
 				$registrations_to_apply_payment_to .= '</tr>';
906 906
 			}
907 907
 		}
908 908
 		$registrations_to_apply_payment_to .= '</tbody></table></div>';
909
-		$registrations_to_apply_payment_to .= '<p class="clear description">' . __( 'The payment will only be applied to the registrations that have a check mark in their corresponding check box. Checkboxes for free registrations have been disabled.', 'event_espresso' ) . '</p></div>';
910
-		$this->_template_args[ 'registrations_to_apply_payment_to' ] = $registrations_to_apply_payment_to;
909
+		$registrations_to_apply_payment_to .= '<p class="clear description">'.__('The payment will only be applied to the registrations that have a check mark in their corresponding check box. Checkboxes for free registrations have been disabled.', 'event_espresso').'</p></div>';
910
+		$this->_template_args['registrations_to_apply_payment_to'] = $registrations_to_apply_payment_to;
911 911
 	}
912 912
 
913 913
 
@@ -924,9 +924,9 @@  discard block
 block discarded – undo
924 924
 		$statuses = EEM_Registration::reg_status_array(array(), TRUE);
925 925
 		//let's add a "don't change" option.
926 926
 		$status_array['NAN'] = __('Leave the Same', 'event_espresso');
927
-		$status_array = array_merge( $status_array, $statuses );
928
-		$this->_template_args['status_change_select'] = EEH_Form_Fields::select_input( 'txn_reg_status_change[reg_status]', $status_array, 'NAN', 'id="txn-admin-payment-reg-status-inp"', 'txn-reg-status-change-reg-status' );
929
-		$this->_template_args['delete_status_change_select'] = EEH_Form_Fields::select_input( 'delete_txn_reg_status_change[reg_status]', $status_array, 'NAN', 'delete-txn-admin-payment-reg-status-inp', 'delete-txn-reg-status-change-reg-status' );
927
+		$status_array = array_merge($status_array, $statuses);
928
+		$this->_template_args['status_change_select'] = EEH_Form_Fields::select_input('txn_reg_status_change[reg_status]', $status_array, 'NAN', 'id="txn-admin-payment-reg-status-inp"', 'txn-reg-status-change-reg-status');
929
+		$this->_template_args['delete_status_change_select'] = EEH_Form_Fields::select_input('delete_txn_reg_status_change[reg_status]', $status_array, 'NAN', 'delete-txn-admin-payment-reg-status-inp', 'delete-txn-reg-status-change-reg-status');
930 930
 
931 931
 	}
932 932
 
@@ -941,21 +941,21 @@  discard block
 block discarded – undo
941 941
 	 * @param EE_Payment[] to show on this page
942 942
 	 *	@return void
943 943
 	 */
944
-	private function _get_payment_methods( $payments = array() ) {
944
+	private function _get_payment_methods($payments = array()) {
945 945
 		$payment_methods_of_payments = array();
946
-		foreach( $payments as $payment ){
947
-			if( $payment instanceof EE_Payment ){
948
-				$payment_methods_of_payments[] = $payment->get( 'PMD_ID' );
946
+		foreach ($payments as $payment) {
947
+			if ($payment instanceof EE_Payment) {
948
+				$payment_methods_of_payments[] = $payment->get('PMD_ID');
949 949
 			}
950 950
 		}
951
-		if( $payment_methods_of_payments ){
952
-			$query_args = array( array( 'OR*payment_method_for_payment' => array(
953
-					'PMD_ID' => array( 'IN', $payment_methods_of_payments ),
954
-					'PMD_scope' => array( 'LIKE', '%' . EEM_Payment_Method::scope_admin . '%' ) ) ) );
955
-		}else{
956
-			$query_args = array( array( 'PMD_scope' => array( 'LIKE', '%' . EEM_Payment_Method::scope_admin . '%' ) ) );
951
+		if ($payment_methods_of_payments) {
952
+			$query_args = array(array('OR*payment_method_for_payment' => array(
953
+					'PMD_ID' => array('IN', $payment_methods_of_payments),
954
+					'PMD_scope' => array('LIKE', '%'.EEM_Payment_Method::scope_admin.'%') )));
955
+		} else {
956
+			$query_args = array(array('PMD_scope' => array('LIKE', '%'.EEM_Payment_Method::scope_admin.'%')));
957 957
 		}
958
-		$this->_template_args['payment_methods'] = EEM_Payment_Method::instance()->get_all( $query_args );
958
+		$this->_template_args['payment_methods'] = EEM_Payment_Method::instance()->get_all($query_args);
959 959
 	}
960 960
 
961 961
 
@@ -969,46 +969,46 @@  discard block
 block discarded – undo
969 969
 	 * @param array $metabox
970 970
 	 * @return void
971 971
 	 */
972
-	public function txn_attendees_meta_box( $post, $metabox = array( 'args' => array() )) {
972
+	public function txn_attendees_meta_box($post, $metabox = array('args' => array())) {
973 973
 
974
-		extract( $metabox['args'] );
974
+		extract($metabox['args']);
975 975
 		$this->_template_args['post'] = $post;
976 976
 		$this->_template_args['event_attendees'] = array();
977 977
 		// process items in cart
978
-		$line_items = $this->_transaction->get_many_related('Line_Item', array( array( 'LIN_type' => 'line-item' ) ) );
979
-		if ( ! empty( $line_items )) {
980
-			foreach ( $line_items as $item ) {
981
-				if ( $item instanceof EE_Line_Item ) {
982
-					switch( $item->OBJ_type() ) {
978
+		$line_items = $this->_transaction->get_many_related('Line_Item', array(array('LIN_type' => 'line-item')));
979
+		if ( ! empty($line_items)) {
980
+			foreach ($line_items as $item) {
981
+				if ($item instanceof EE_Line_Item) {
982
+					switch ($item->OBJ_type()) {
983 983
 
984 984
 						case 'Event' :
985 985
 							break;
986 986
 
987 987
 						case 'Ticket' :
988 988
 							$ticket = $item->ticket();
989
-							if ( empty( $ticket )) {
989
+							if (empty($ticket)) {
990 990
 								continue; //right now we're only handling tickets here.  Cause its expected that only tickets will have attendees right?
991 991
 							}
992
-							$ticket_price = EEH_Template::format_currency( $item->get( 'LIN_unit_price' ));
992
+							$ticket_price = EEH_Template::format_currency($item->get('LIN_unit_price'));
993 993
 							$event = $ticket->get_first_related('Registration')->get_first_related('Event');
994
-							$event_name = $event instanceof EE_Event ? $event->get('EVT_name') . ' - ' . $item->get('LIN_name') : '';
994
+							$event_name = $event instanceof EE_Event ? $event->get('EVT_name').' - '.$item->get('LIN_name') : '';
995 995
 
996
-							$registrations = $ticket->get_many_related('Registration', array( array('TXN_ID' => $this->_transaction->ID() )));
997
-							foreach( $registrations as $registration ) {
998
-								$this->_template_args['event_attendees'][$registration->ID()]['att_num'] 						= $registration->get('REG_count');
999
-								$this->_template_args['event_attendees'][$registration->ID()]['event_ticket_name'] 	= $event_name;
1000
-								$this->_template_args['event_attendees'][$registration->ID()]['ticket_price'] 				= $ticket_price;
996
+							$registrations = $ticket->get_many_related('Registration', array(array('TXN_ID' => $this->_transaction->ID())));
997
+							foreach ($registrations as $registration) {
998
+								$this->_template_args['event_attendees'][$registration->ID()]['att_num'] = $registration->get('REG_count');
999
+								$this->_template_args['event_attendees'][$registration->ID()]['event_ticket_name'] = $event_name;
1000
+								$this->_template_args['event_attendees'][$registration->ID()]['ticket_price'] = $ticket_price;
1001 1001
 								// attendee info
1002 1002
 								$attendee = $registration->get_first_related('Attendee');
1003
-								if ( $attendee instanceof EE_Attendee ) {
1003
+								if ($attendee instanceof EE_Attendee) {
1004 1004
 									$this->_template_args['event_attendees'][$registration->ID()]['att_id'] 			= $attendee->ID();
1005 1005
 									$this->_template_args['event_attendees'][$registration->ID()]['attendee'] 	= $attendee->full_name();
1006
-									$this->_template_args['event_attendees'][$registration->ID()]['email'] 			= '<a href="mailto:' . $attendee->email() . '?subject=' . $event->get('EVT_name') . __(' Event', 'event_espresso') . '">' . $attendee->email() . '</a>';
1007
-									$this->_template_args['event_attendees'][$registration->ID()]['address'] 		=  implode(',<br>', $attendee->full_address_as_array() );
1006
+									$this->_template_args['event_attendees'][$registration->ID()]['email'] = '<a href="mailto:'.$attendee->email().'?subject='.$event->get('EVT_name').__(' Event', 'event_espresso').'">'.$attendee->email().'</a>';
1007
+									$this->_template_args['event_attendees'][$registration->ID()]['address'] 		= implode(',<br>', $attendee->full_address_as_array());
1008 1008
 								} else {
1009 1009
 									$this->_template_args['event_attendees'][$registration->ID()]['att_id'] 			= '';
1010 1010
 									$this->_template_args['event_attendees'][$registration->ID()]['attendee'] 	= '';
1011
-									$this->_template_args['event_attendees'][$registration->ID()]['email'] 			= '';
1011
+									$this->_template_args['event_attendees'][$registration->ID()]['email'] = '';
1012 1012
 									$this->_template_args['event_attendees'][$registration->ID()]['address'] 		= '';
1013 1013
 								}
1014 1014
 							}
@@ -1018,12 +1018,12 @@  discard block
 block discarded – undo
1018 1018
 				}
1019 1019
 			}
1020 1020
 
1021
-			$this->_template_args['transaction_form_url'] = add_query_arg( array( 'action' => 'edit_transaction', 'process' => 'attendees'  ), TXN_ADMIN_URL );
1022
-			echo EEH_Template::display_template( TXN_TEMPLATE_PATH . 'txn_admin_details_main_meta_box_attendees.template.php', $this->_template_args, TRUE );
1021
+			$this->_template_args['transaction_form_url'] = add_query_arg(array('action' => 'edit_transaction', 'process' => 'attendees'), TXN_ADMIN_URL);
1022
+			echo EEH_Template::display_template(TXN_TEMPLATE_PATH.'txn_admin_details_main_meta_box_attendees.template.php', $this->_template_args, TRUE);
1023 1023
 
1024 1024
 		} else {
1025 1025
 			echo sprintf(
1026
-				__( '%1$sFor some reason, there are no attendees registered for this transaction. Likely the registration was abandoned in process.%2$s', 'event_espresso' ),
1026
+				__('%1$sFor some reason, there are no attendees registered for this transaction. Likely the registration was abandoned in process.%2$s', 'event_espresso'),
1027 1027
 				'<p class="important-notice">',
1028 1028
 				'</p>'
1029 1029
 			);
@@ -1042,19 +1042,19 @@  discard block
 block discarded – undo
1042 1042
 	 */
1043 1043
 	public function txn_registrant_side_meta_box() {
1044 1044
 		$primary_att = $this->_transaction->primary_registration() instanceof EE_Registration ? $this->_transaction->primary_registration()->get_first_related('Attendee') : null;
1045
-		if ( ! $primary_att instanceof EE_Attendee ) {
1045
+		if ( ! $primary_att instanceof EE_Attendee) {
1046 1046
 			$this->_template_args['no_attendee_message'] = __('There is no attached contact for this transaction.  The transaction either failed due to an error or was abandoned.', 'event_espresso');
1047 1047
 			$primary_att = EEM_Attendee::instance()->create_default_object();
1048 1048
 		}
1049
-		$this->_template_args['ATT_ID'] 						= $primary_att->ID();
1049
+		$this->_template_args['ATT_ID'] = $primary_att->ID();
1050 1050
 		$this->_template_args['prime_reg_fname']		= $primary_att->fname();
1051 1051
 		$this->_template_args['prime_reg_lname']		= $primary_att->lname();
1052
-		$this->_template_args['prime_reg_email'] 		= $primary_att->email();
1052
+		$this->_template_args['prime_reg_email'] = $primary_att->email();
1053 1053
 		$this->_template_args['prime_reg_phone'] 	= $primary_att->phone();
1054
-		$this->_template_args['edit_attendee_url'] 	= EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'edit_attendee', 'post' => $primary_att->ID()  ), REG_ADMIN_URL );
1054
+		$this->_template_args['edit_attendee_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit_attendee', 'post' => $primary_att->ID()), REG_ADMIN_URL);
1055 1055
 		// get formatted address for registrant
1056
-		$this->_template_args[ 'formatted_address' ] = EEH_Address::format( $primary_att );
1057
-		echo EEH_Template::display_template( TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_registrant.template.php', $this->_template_args, TRUE );
1056
+		$this->_template_args['formatted_address'] = EEH_Address::format($primary_att);
1057
+		echo EEH_Template::display_template(TXN_TEMPLATE_PATH.'txn_admin_details_side_meta_box_registrant.template.php', $this->_template_args, TRUE);
1058 1058
 	}
1059 1059
 
1060 1060
 
@@ -1070,12 +1070,12 @@  discard block
 block discarded – undo
1070 1070
 
1071 1071
 		$this->_template_args['billing_form'] = $this->_transaction->billing_info();
1072 1072
 		$this->_template_args['billing_form_url'] = add_query_arg(
1073
-			array( 'action' => 'edit_transaction', 'process' => 'billing'  ),
1073
+			array('action' => 'edit_transaction', 'process' => 'billing'),
1074 1074
 			TXN_ADMIN_URL
1075 1075
 		);
1076 1076
 
1077
-		$template_path = TXN_TEMPLATE_PATH . 'txn_admin_details_side_meta_box_billing_info.template.php';
1078
-		echo EEH_Template::display_template( $template_path, $this->_template_args, TRUE );/**/
1077
+		$template_path = TXN_TEMPLATE_PATH.'txn_admin_details_side_meta_box_billing_info.template.php';
1078
+		echo EEH_Template::display_template($template_path, $this->_template_args, TRUE); /**/
1079 1079
 	}
1080 1080
 
1081 1081
 
@@ -1088,42 +1088,42 @@  discard block
 block discarded – undo
1088 1088
 	*	@return void
1089 1089
 	*/
1090 1090
 	public function apply_payments_or_refunds() {
1091
-		$json_response_data = array( 'return_data' => FALSE );
1091
+		$json_response_data = array('return_data' => FALSE);
1092 1092
 		$valid_data = $this->_validate_payment_request_data();
1093
-		if ( ! empty( $valid_data ) ) {
1094
-			$PAY_ID = $valid_data[ 'PAY_ID' ];
1093
+		if ( ! empty($valid_data)) {
1094
+			$PAY_ID = $valid_data['PAY_ID'];
1095 1095
 			//save  the new payment
1096
-			$payment = $this->_create_payment_from_request_data( $valid_data );
1096
+			$payment = $this->_create_payment_from_request_data($valid_data);
1097 1097
 			// get the TXN for this payment
1098 1098
 			$transaction = $payment->transaction();
1099 1099
 			// verify transaction
1100
-			if ( $transaction instanceof EE_Transaction ) {
1100
+			if ($transaction instanceof EE_Transaction) {
1101 1101
 				// calculate_total_payments_and_update_status
1102
-				$this->_process_transaction_payments( $transaction );
1103
-				$REG_IDs = $this->_get_REG_IDs_to_apply_payment_to( $payment );
1104
-				$this->_remove_existing_registration_payments( $payment, $PAY_ID );
1102
+				$this->_process_transaction_payments($transaction);
1103
+				$REG_IDs = $this->_get_REG_IDs_to_apply_payment_to($payment);
1104
+				$this->_remove_existing_registration_payments($payment, $PAY_ID);
1105 1105
 				// apply payment to registrations (if applicable)
1106
-				if ( ! empty( $REG_IDs ) ) {
1107
-					$this->_update_registration_payments( $transaction, $payment, $REG_IDs );
1106
+				if ( ! empty($REG_IDs)) {
1107
+					$this->_update_registration_payments($transaction, $payment, $REG_IDs);
1108 1108
 					$this->_maybe_send_notifications();
1109 1109
 					// now process status changes for the same registrations
1110
-					$this->_process_registration_status_change( $transaction, $REG_IDs );
1110
+					$this->_process_registration_status_change($transaction, $REG_IDs);
1111 1111
 				}
1112
-				$this->_maybe_send_notifications( $payment );
1112
+				$this->_maybe_send_notifications($payment);
1113 1113
 				//prepare to render page
1114
-				$json_response_data[ 'return_data' ] = $this->_build_payment_json_response( $payment, $REG_IDs );
1115
-				do_action( 'AHEE__Transactions_Admin_Page__apply_payments_or_refund__after_recording', $transaction, $payment );
1114
+				$json_response_data['return_data'] = $this->_build_payment_json_response($payment, $REG_IDs);
1115
+				do_action('AHEE__Transactions_Admin_Page__apply_payments_or_refund__after_recording', $transaction, $payment);
1116 1116
 			} else {
1117 1117
 				EE_Error::add_error(
1118
-					__( 'A valid Transaction for this payment could not be retrieved.', 'event_espresso' ),
1118
+					__('A valid Transaction for this payment could not be retrieved.', 'event_espresso'),
1119 1119
 					__FILE__, __FUNCTION__, __LINE__
1120 1120
 				);
1121 1121
 			}
1122 1122
 		} else {
1123
-			EE_Error::add_error( __( 'The payment form data could not be processed. Please try again.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
1123
+			EE_Error::add_error(__('The payment form data could not be processed. Please try again.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1124 1124
 		}
1125 1125
 
1126
-		$notices = EE_Error::get_notices( false, false, false );
1126
+		$notices = EE_Error::get_notices(false, false, false);
1127 1127
 		$this->_template_args = array(
1128 1128
 			'data' => $json_response_data,
1129 1129
 			'error' => $notices['errors'],
@@ -1140,30 +1140,30 @@  discard block
 block discarded – undo
1140 1140
 	 * @return array
1141 1141
 	 */
1142 1142
 	protected function _validate_payment_request_data() {
1143
-		if ( ! isset( $this->_req_data[ 'txn_admin_payment' ] ) ) {
1143
+		if ( ! isset($this->_req_data['txn_admin_payment'])) {
1144 1144
 			return false;
1145 1145
 		}
1146 1146
 		$payment_form = $this->_generate_payment_form_section();
1147 1147
 		try {
1148
-			if ( $payment_form->was_submitted() ) {
1148
+			if ($payment_form->was_submitted()) {
1149 1149
 				$payment_form->receive_form_submission();
1150
-				if ( ! $payment_form->is_valid() ) {
1150
+				if ( ! $payment_form->is_valid()) {
1151 1151
 					$submission_error_messages = array();
1152
-					foreach ( $payment_form->get_validation_errors_accumulated() as $validation_error ) {
1153
-						if ( $validation_error instanceof EE_Validation_Error ) {
1152
+					foreach ($payment_form->get_validation_errors_accumulated() as $validation_error) {
1153
+						if ($validation_error instanceof EE_Validation_Error) {
1154 1154
 							$submission_error_messages[] = sprintf(
1155
-								_x( '%s : %s', 'Form Section Name : Form Validation Error', 'event_espresso' ),
1155
+								_x('%s : %s', 'Form Section Name : Form Validation Error', 'event_espresso'),
1156 1156
 								$validation_error->get_form_section()->html_label_text(),
1157 1157
 								$validation_error->getMessage()
1158 1158
 							);
1159 1159
 						}
1160 1160
 					}
1161
-					EE_Error::add_error( join( '<br />', $submission_error_messages ), __FILE__, __FUNCTION__, __LINE__ );
1161
+					EE_Error::add_error(join('<br />', $submission_error_messages), __FILE__, __FUNCTION__, __LINE__);
1162 1162
 					return array();
1163 1163
 				}
1164 1164
 			}
1165
-		} catch ( EE_Error $e ) {
1166
-			EE_Error::add_error( $e->getMessage(), __FILE__, __FUNCTION__, __LINE__ );
1165
+		} catch (EE_Error $e) {
1166
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
1167 1167
 			return array();
1168 1168
 		}
1169 1169
 		return $payment_form->valid_data();
@@ -1185,63 +1185,63 @@  discard block
 block discarded – undo
1185 1185
 						array(
1186 1186
 							'default' => 0,
1187 1187
 							'required' => false,
1188
-							'html_label_text' => __( 'Payment ID', 'event_espresso' ),
1189
-							'validation_strategies' => array( new EE_Int_Normalization() )
1188
+							'html_label_text' => __('Payment ID', 'event_espresso'),
1189
+							'validation_strategies' => array(new EE_Int_Normalization())
1190 1190
 						)
1191 1191
 					),
1192 1192
 					'TXN_ID' => new EE_Text_Input(
1193 1193
 						array(
1194 1194
 							'default' => 0,
1195 1195
 							'required' => true,
1196
-							'html_label_text' => __( 'Transaction ID', 'event_espresso' ),
1197
-							'validation_strategies' => array( new EE_Int_Normalization() )
1196
+							'html_label_text' => __('Transaction ID', 'event_espresso'),
1197
+							'validation_strategies' => array(new EE_Int_Normalization())
1198 1198
 						)
1199 1199
 					),
1200 1200
 					'type' => new EE_Text_Input(
1201 1201
 						array(
1202 1202
 							'default' => 1,
1203 1203
 							'required' => true,
1204
-							'html_label_text' => __( 'Payment or Refund', 'event_espresso' ),
1205
-							'validation_strategies' => array( new EE_Int_Normalization() )
1204
+							'html_label_text' => __('Payment or Refund', 'event_espresso'),
1205
+							'validation_strategies' => array(new EE_Int_Normalization())
1206 1206
 						)
1207 1207
 					),
1208 1208
 					'amount' => new EE_Text_Input(
1209 1209
 						array(
1210 1210
 							'default' => 0,
1211 1211
 							'required' => true,
1212
-							'html_label_text' => __( 'Payment amount', 'event_espresso' ),
1213
-							'validation_strategies' => array( new EE_Float_Normalization() )
1212
+							'html_label_text' => __('Payment amount', 'event_espresso'),
1213
+							'validation_strategies' => array(new EE_Float_Normalization())
1214 1214
 						)
1215 1215
 					),
1216 1216
 					'status' => new EE_Text_Input(
1217 1217
 						array(
1218 1218
 							'default' => EEM_Payment::status_id_approved,
1219 1219
 							'required' => true,
1220
-							'html_label_text' => __( 'Payment status', 'event_espresso' ),
1220
+							'html_label_text' => __('Payment status', 'event_espresso'),
1221 1221
 						)
1222 1222
 					),
1223 1223
 					'PMD_ID' => new EE_Text_Input(
1224 1224
 						array(
1225 1225
 							'default' => 2,
1226 1226
 							'required' => true,
1227
-							'html_label_text' => __( 'Payment Method', 'event_espresso' ),
1228
-							'validation_strategies' => array( new EE_Int_Normalization() )
1227
+							'html_label_text' => __('Payment Method', 'event_espresso'),
1228
+							'validation_strategies' => array(new EE_Int_Normalization())
1229 1229
 						)
1230 1230
 					),
1231 1231
 					'date' => new EE_Text_Input(
1232 1232
 						array(
1233 1233
 							'default' => time(),
1234 1234
 							'required' => true,
1235
-							'html_label_text' => __( 'Payment date', 'event_espresso' ),
1235
+							'html_label_text' => __('Payment date', 'event_espresso'),
1236 1236
 						)
1237 1237
 					),
1238 1238
 					'txn_id_chq_nmbr' => new EE_Text_Input(
1239 1239
 						array(
1240 1240
 							'default' => '',
1241 1241
 							'required' => false,
1242
-							'html_label_text' => __( 'Transaction or Cheque Number', 'event_espresso' ),
1242
+							'html_label_text' => __('Transaction or Cheque Number', 'event_espresso'),
1243 1243
                                                         'validation_strategies' => array(
1244
-                                                            new EE_Max_Length_Validation_Strategy( __('Input too long', 'event_espresso'), 100 ),
1244
+                                                            new EE_Max_Length_Validation_Strategy(__('Input too long', 'event_espresso'), 100),
1245 1245
                                                         )
1246 1246
 						)
1247 1247
 					),
@@ -1249,9 +1249,9 @@  discard block
 block discarded – undo
1249 1249
 						array(
1250 1250
 							'default' => '',
1251 1251
 							'required' => false,
1252
-							'html_label_text' => __( 'Purchase Order Number', 'event_espresso' ),
1252
+							'html_label_text' => __('Purchase Order Number', 'event_espresso'),
1253 1253
                                                         'validation_strategies' => array(
1254
-                                                            new EE_Max_Length_Validation_Strategy( __('Input too long', 'event_espresso'), 100 ),
1254
+                                                            new EE_Max_Length_Validation_Strategy(__('Input too long', 'event_espresso'), 100),
1255 1255
                                                         )
1256 1256
 						)
1257 1257
 					),
@@ -1259,9 +1259,9 @@  discard block
 block discarded – undo
1259 1259
 						array(
1260 1260
 							'default' => '',
1261 1261
 							'required' => false,
1262
-							'html_label_text' => __( 'Extra Field for Accounting', 'event_espresso' ),
1262
+							'html_label_text' => __('Extra Field for Accounting', 'event_espresso'),
1263 1263
                                                         'validation_strategies' => array(
1264
-                                                            new EE_Max_Length_Validation_Strategy( __('Input too long', 'event_espresso'), 100 ),
1264
+                                                            new EE_Max_Length_Validation_Strategy(__('Input too long', 'event_espresso'), 100),
1265 1265
                                                         )
1266 1266
 						)
1267 1267
 					),
@@ -1278,37 +1278,37 @@  discard block
 block discarded – undo
1278 1278
 	 * @param array $valid_data
1279 1279
 	 * @return EE_Payment
1280 1280
 	 */
1281
-	protected function _create_payment_from_request_data( $valid_data ) {
1282
-		$PAY_ID = $valid_data[ 'PAY_ID' ];
1281
+	protected function _create_payment_from_request_data($valid_data) {
1282
+		$PAY_ID = $valid_data['PAY_ID'];
1283 1283
 		// get payment amount
1284
-		$amount = $valid_data[ 'amount' ] ? abs( $valid_data[ 'amount' ] ) : 0;
1284
+		$amount = $valid_data['amount'] ? abs($valid_data['amount']) : 0;
1285 1285
 		// payments have a type value of 1 and refunds have a type value of -1
1286 1286
 		// so multiplying amount by type will give a positive value for payments, and negative values for refunds
1287
-		$amount = $valid_data[ 'type' ] < 0 ? $amount * -1 : $amount;
1287
+		$amount = $valid_data['type'] < 0 ? $amount * -1 : $amount;
1288 1288
 		// for some reason the date string coming in has extra spaces between the date and time.  This fixes that.
1289
-		$date = $valid_data['date'] ? preg_replace( '/\s+/', ' ', $valid_data['date'] ) : date( 'Y-m-d g:i a', current_time( 'timestamp' ) );
1289
+		$date = $valid_data['date'] ? preg_replace('/\s+/', ' ', $valid_data['date']) : date('Y-m-d g:i a', current_time('timestamp'));
1290 1290
 		$payment = EE_Payment::new_instance(
1291 1291
 			array(
1292
-				'TXN_ID' 								=> $valid_data[ 'TXN_ID' ],
1293
-				'STS_ID' 								=> $valid_data[ 'status' ],
1292
+				'TXN_ID' 								=> $valid_data['TXN_ID'],
1293
+				'STS_ID' 								=> $valid_data['status'],
1294 1294
 				'PAY_timestamp' 				=> $date,
1295 1295
 				'PAY_source'           			=> EEM_Payment_Method::scope_admin,
1296
-				'PMD_ID'               				=> $valid_data[ 'PMD_ID' ],
1296
+				'PMD_ID'               				=> $valid_data['PMD_ID'],
1297 1297
 				'PAY_amount'           			=> $amount,
1298
-				'PAY_txn_id_chq_nmbr'  	=> $valid_data[ 'txn_id_chq_nmbr' ],
1299
-				'PAY_po_number'        		=> $valid_data[ 'po_number' ],
1300
-				'PAY_extra_accntng'    		=> $valid_data[ 'accounting' ],
1298
+				'PAY_txn_id_chq_nmbr'  	=> $valid_data['txn_id_chq_nmbr'],
1299
+				'PAY_po_number'        		=> $valid_data['po_number'],
1300
+				'PAY_extra_accntng'    		=> $valid_data['accounting'],
1301 1301
 				'PAY_details'          				=> $valid_data,
1302 1302
 				'PAY_ID'               				=> $PAY_ID
1303 1303
 			),
1304 1304
 			'',
1305
-			array( 'Y-m-d', 'g:i a' )
1305
+			array('Y-m-d', 'g:i a')
1306 1306
 		);
1307 1307
 
1308
-		if ( ! $payment->save() ) {
1308
+		if ( ! $payment->save()) {
1309 1309
 			EE_Error::add_error(
1310 1310
 				sprintf(
1311
-					__( 'Payment %1$d has not been successfully saved to the database.', 'event_espresso' ),
1311
+					__('Payment %1$d has not been successfully saved to the database.', 'event_espresso'),
1312 1312
 					$payment->ID()
1313 1313
 				),
1314 1314
 				__FILE__, __FUNCTION__, __LINE__
@@ -1325,15 +1325,15 @@  discard block
 block discarded – undo
1325 1325
 	 * @param \EE_Transaction $transaction
1326 1326
 	 * @return array
1327 1327
 	 */
1328
-	protected function _process_transaction_payments( EE_Transaction $transaction ) {
1328
+	protected function _process_transaction_payments(EE_Transaction $transaction) {
1329 1329
 		/** @type EE_Transaction_Payments $transaction_payments */
1330
-		$transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' );
1330
+		$transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
1331 1331
 		//update the transaction with this payment
1332
-		if ( $transaction_payments->calculate_total_payments_and_update_status( $transaction ) ) {
1333
-			EE_Error::add_success( __( 'The payment has been processed successfully.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
1332
+		if ($transaction_payments->calculate_total_payments_and_update_status($transaction)) {
1333
+			EE_Error::add_success(__('The payment has been processed successfully.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1334 1334
 		} else {
1335 1335
 			EE_Error::add_error(
1336
-				__( 'The payment was processed successfully but the amount paid for the transaction was not updated.', 'event_espresso' )
1336
+				__('The payment was processed successfully but the amount paid for the transaction was not updated.', 'event_espresso')
1337 1337
 				, __FILE__, __FUNCTION__, __LINE__
1338 1338
 			);
1339 1339
 		}
@@ -1349,19 +1349,19 @@  discard block
 block discarded – undo
1349 1349
 	 * @param \EE_Payment $payment
1350 1350
 	 * @return array
1351 1351
 	 */
1352
-	protected function _get_REG_IDs_to_apply_payment_to( EE_Payment $payment ) {
1352
+	protected function _get_REG_IDs_to_apply_payment_to(EE_Payment $payment) {
1353 1353
 		$REG_IDs = array();
1354 1354
 		// grab array of IDs for specific registrations to apply changes to
1355
-		if ( isset( $this->_req_data[ 'txn_admin_payment' ][ 'registrations' ] ) ) {
1356
-			$REG_IDs = (array)$this->_req_data[ 'txn_admin_payment' ][ 'registrations' ];
1355
+		if (isset($this->_req_data['txn_admin_payment']['registrations'])) {
1356
+			$REG_IDs = (array) $this->_req_data['txn_admin_payment']['registrations'];
1357 1357
 		}
1358 1358
 		//nothing specified ? then get all reg IDs
1359
-		if ( empty( $REG_IDs ) ) {
1359
+		if (empty($REG_IDs)) {
1360 1360
 			$registrations = $payment->transaction()->registrations();
1361
-			$REG_IDs = ! empty( $registrations ) ? array_keys( $registrations ) : $this->_get_existing_reg_payment_REG_IDs( $payment );
1361
+			$REG_IDs = ! empty($registrations) ? array_keys($registrations) : $this->_get_existing_reg_payment_REG_IDs($payment);
1362 1362
 		}
1363 1363
 		// ensure that REG_IDs are integers and NOT strings
1364
-		return array_map( 'intval', $REG_IDs );
1364
+		return array_map('intval', $REG_IDs);
1365 1365
 	}
1366 1366
 
1367 1367
 
@@ -1378,7 +1378,7 @@  discard block
 block discarded – undo
1378 1378
 	/**
1379 1379
 	 * @param array $existing_reg_payment_REG_IDs
1380 1380
 	 */
1381
-	public function set_existing_reg_payment_REG_IDs( $existing_reg_payment_REG_IDs = null ) {
1381
+	public function set_existing_reg_payment_REG_IDs($existing_reg_payment_REG_IDs = null) {
1382 1382
 		$this->_existing_reg_payment_REG_IDs = $existing_reg_payment_REG_IDs;
1383 1383
 	}
1384 1384
 
@@ -1393,13 +1393,13 @@  discard block
 block discarded – undo
1393 1393
 	 * @param \EE_Payment $payment
1394 1394
 	 * @return array
1395 1395
 	 */
1396
-	protected function _get_existing_reg_payment_REG_IDs( EE_Payment $payment ) {
1397
-		if ( $this->existing_reg_payment_REG_IDs() === null ) {
1396
+	protected function _get_existing_reg_payment_REG_IDs(EE_Payment $payment) {
1397
+		if ($this->existing_reg_payment_REG_IDs() === null) {
1398 1398
 			// let's get any existing reg payment records for this payment
1399
-			$existing_reg_payment_REG_IDs = $payment->get_many_related( 'Registration' );
1399
+			$existing_reg_payment_REG_IDs = $payment->get_many_related('Registration');
1400 1400
 			// but we only want the REG IDs, so grab the array keys
1401
-			$existing_reg_payment_REG_IDs = ! empty( $existing_reg_payment_REG_IDs ) ? array_keys( $existing_reg_payment_REG_IDs ) : array();
1402
-			$this->set_existing_reg_payment_REG_IDs( $existing_reg_payment_REG_IDs );
1401
+			$existing_reg_payment_REG_IDs = ! empty($existing_reg_payment_REG_IDs) ? array_keys($existing_reg_payment_REG_IDs) : array();
1402
+			$this->set_existing_reg_payment_REG_IDs($existing_reg_payment_REG_IDs);
1403 1403
 		}
1404 1404
 		return $this->existing_reg_payment_REG_IDs();
1405 1405
 	}
@@ -1418,23 +1418,23 @@  discard block
 block discarded – undo
1418 1418
 	 * @param int         $PAY_ID
1419 1419
 	 * @return bool;
1420 1420
 	 */
1421
-	protected function _remove_existing_registration_payments( EE_Payment $payment, $PAY_ID = 0 ) {
1421
+	protected function _remove_existing_registration_payments(EE_Payment $payment, $PAY_ID = 0) {
1422 1422
 		// newly created payments will have nothing recorded for $PAY_ID
1423
-		if ( $PAY_ID == 0 ) {
1423
+		if ($PAY_ID == 0) {
1424 1424
 			return false;
1425 1425
 		}
1426
-		$existing_reg_payment_REG_IDs = $this->_get_existing_reg_payment_REG_IDs( $payment );
1427
-		if ( empty( $existing_reg_payment_REG_IDs )) {
1426
+		$existing_reg_payment_REG_IDs = $this->_get_existing_reg_payment_REG_IDs($payment);
1427
+		if (empty($existing_reg_payment_REG_IDs)) {
1428 1428
 			return false;
1429 1429
 		}
1430 1430
 		/** @type EE_Transaction_Payments $transaction_payments */
1431
-		$transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' );
1431
+		$transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
1432 1432
 		return $transaction_payments->delete_registration_payments_and_update_registrations(
1433 1433
 			$payment,
1434 1434
 			array(
1435 1435
 				array(
1436 1436
 					'PAY_ID' => $payment->ID(),
1437
-					'REG_ID' => array( 'IN', $existing_reg_payment_REG_IDs ),
1437
+					'REG_ID' => array('IN', $existing_reg_payment_REG_IDs),
1438 1438
 				)
1439 1439
 			)
1440 1440
 		);
@@ -1453,25 +1453,25 @@  discard block
 block discarded – undo
1453 1453
 	 * @param array $REG_IDs
1454 1454
 	 * @return bool
1455 1455
 	 */
1456
-	protected function _update_registration_payments( EE_Transaction $transaction, EE_Payment $payment, $REG_IDs = array() ) {
1456
+	protected function _update_registration_payments(EE_Transaction $transaction, EE_Payment $payment, $REG_IDs = array()) {
1457 1457
 		// we can pass our own custom set of registrations to EE_Payment_Processor::process_registration_payments()
1458 1458
 		// so let's do that using our set of REG_IDs from the form
1459 1459
 		$registration_query_where_params = array(
1460
-			'REG_ID' => array( 'IN', $REG_IDs )
1460
+			'REG_ID' => array('IN', $REG_IDs)
1461 1461
 		);
1462 1462
 		// but add in some conditions regarding payment,
1463 1463
 		// so that we don't apply payments to registrations that are free or have already been paid for
1464 1464
 		// but ONLY if the payment is NOT a refund ( ie: the payment amount is not negative )
1465
-		if ( ! $payment->is_a_refund() ) {
1466
-			$registration_query_where_params[ 'REG_final_price' ]  = array( '!=', 0 );
1467
-			$registration_query_where_params[ 'REG_final_price*' ]  = array( '!=', 'REG_paid', true );
1465
+		if ( ! $payment->is_a_refund()) {
1466
+			$registration_query_where_params['REG_final_price'] = array('!=', 0);
1467
+			$registration_query_where_params['REG_final_price*'] = array('!=', 'REG_paid', true);
1468 1468
 		}
1469 1469
 		//EEH_Debug_Tools::printr( $registration_query_where_params, '$registration_query_where_params', __FILE__, __LINE__ );
1470
-		$registrations = $transaction->registrations( array( $registration_query_where_params ) );
1471
-		if ( ! empty( $registrations ) ) {
1470
+		$registrations = $transaction->registrations(array($registration_query_where_params));
1471
+		if ( ! empty($registrations)) {
1472 1472
 			/** @type EE_Payment_Processor $payment_processor */
1473
-			$payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' );
1474
-			$payment_processor->process_registration_payments( $transaction, $payment, $registrations );
1473
+			$payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
1474
+			$payment_processor->process_registration_payments($transaction, $payment, $registrations);
1475 1475
 		}
1476 1476
 	}
1477 1477
 
@@ -1487,22 +1487,22 @@  discard block
 block discarded – undo
1487 1487
 	 * @param array $REG_IDs
1488 1488
 	 * @return bool
1489 1489
 	 */
1490
-	protected function _process_registration_status_change( EE_Transaction $transaction, $REG_IDs = array() ) {
1490
+	protected function _process_registration_status_change(EE_Transaction $transaction, $REG_IDs = array()) {
1491 1491
 		// first if there is no change in status then we get out.
1492 1492
 		if (
1493
-			! isset( $this->_req_data['txn_reg_status_change'], $this->_req_data[ 'txn_reg_status_change' ][ 'reg_status' ] )
1493
+			! isset($this->_req_data['txn_reg_status_change'], $this->_req_data['txn_reg_status_change']['reg_status'])
1494 1494
 			|| $this->_req_data['txn_reg_status_change']['reg_status'] == 'NAN'
1495 1495
 		) {
1496 1496
 			//no error message, no change requested, just nothing to do man.
1497 1497
 			return FALSE;
1498 1498
 		}
1499 1499
 		/** @type EE_Transaction_Processor $transaction_processor */
1500
-		$transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' );
1500
+		$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
1501 1501
 		// made it here dude?  Oh WOW.  K, let's take care of changing the statuses
1502 1502
 		return $transaction_processor->manually_update_registration_statuses(
1503 1503
 			$transaction,
1504
-			sanitize_text_field( $this->_req_data[ 'txn_reg_status_change' ][ 'reg_status' ] ),
1505
-			array( array( 'REG_ID' => array( 'IN', $REG_IDs ) ) )
1504
+			sanitize_text_field($this->_req_data['txn_reg_status_change']['reg_status']),
1505
+			array(array('REG_ID' => array('IN', $REG_IDs)))
1506 1506
 		);
1507 1507
 	}
1508 1508
 
@@ -1517,16 +1517,16 @@  discard block
 block discarded – undo
1517 1517
 	 * @param bool | null        $delete_txn_reg_status_change
1518 1518
 	 * @return array
1519 1519
 	 */
1520
-	protected function _build_payment_json_response( EE_Payment $payment, $REG_IDs = array(), $delete_txn_reg_status_change = null ) {
1520
+	protected function _build_payment_json_response(EE_Payment $payment, $REG_IDs = array(), $delete_txn_reg_status_change = null) {
1521 1521
 		// was the payment deleted ?
1522
-		if ( is_bool( $delete_txn_reg_status_change )) {
1522
+		if (is_bool($delete_txn_reg_status_change)) {
1523 1523
 			return array(
1524 1524
 				'PAY_ID' 				=> $payment->ID(),
1525 1525
 				'amount' 			=> $payment->amount(),
1526 1526
 				'total_paid' 			=> $payment->transaction()->paid(),
1527 1527
 				'txn_status' 			=> $payment->transaction()->status_ID(),
1528 1528
 				'pay_status' 		=> $payment->STS_ID(),
1529
-				'registrations' 	=> $this->_registration_payment_data_array( $REG_IDs ),
1529
+				'registrations' 	=> $this->_registration_payment_data_array($REG_IDs),
1530 1530
 				'delete_txn_reg_status_change' => $delete_txn_reg_status_change,
1531 1531
 			);
1532 1532
 		} else {
@@ -1538,16 +1538,16 @@  discard block
 block discarded – undo
1538 1538
 				'pay_status' 	=> $payment->STS_ID(),
1539 1539
 				'PAY_ID'           => $payment->ID(),
1540 1540
 				'STS_ID' 			=> $payment->STS_ID(),
1541
-				'status' 			=> self::$_pay_status[ $payment->STS_ID() ],
1542
-				'date' 				=> $payment->timestamp( 'Y-m-d', 'h:i a' ),
1543
-				'method' 		=> strtoupper( $payment->source() ),
1541
+				'status' 			=> self::$_pay_status[$payment->STS_ID()],
1542
+				'date' 				=> $payment->timestamp('Y-m-d', 'h:i a'),
1543
+				'method' 		=> strtoupper($payment->source()),
1544 1544
 				'PM_ID' 			=> $payment->payment_method() ? $payment->payment_method()->ID() : 1,
1545
-				'gateway' 		=> $payment->payment_method() ? $payment->payment_method()->admin_name() : __( "Unknown", 'event_espresso' ),
1545
+				'gateway' 		=> $payment->payment_method() ? $payment->payment_method()->admin_name() : __("Unknown", 'event_espresso'),
1546 1546
 				'gateway_response' 	=> $payment->gateway_response(),
1547 1547
 				'txn_id_chq_nmbr'  	=> $payment->txn_id_chq_nmbr(),
1548 1548
 				'po_number'        		=> $payment->po_number(),
1549 1549
 				'extra_accntng'    		=> $payment->extra_accntng(),
1550
-				'registrations'    			=> $this->_registration_payment_data_array( $REG_IDs ),
1550
+				'registrations'    			=> $this->_registration_payment_data_array($REG_IDs),
1551 1551
 			);
1552 1552
 		}
1553 1553
 	}
@@ -1562,39 +1562,39 @@  discard block
 block discarded – undo
1562 1562
 	*	@return void
1563 1563
 	*/
1564 1564
 	public function delete_payment() {
1565
-		$json_response_data = array( 'return_data' => FALSE );
1566
-		$PAY_ID = isset( $this->_req_data['delete_txn_admin_payment'], $this->_req_data['delete_txn_admin_payment']['PAY_ID'] ) ? absint( $this->_req_data['delete_txn_admin_payment']['PAY_ID'] ) : 0;
1567
-		if ( $PAY_ID ) {
1568
-			$delete_txn_reg_status_change = isset( $this->_req_data[ 'delete_txn_reg_status_change' ] ) ? $this->_req_data[ 'delete_txn_reg_status_change' ] : false;
1569
-			$payment = EEM_Payment::instance()->get_one_by_ID( $PAY_ID );
1570
-			if ( $payment instanceof EE_Payment ) {
1571
-				$REG_IDs = $this->_get_existing_reg_payment_REG_IDs( $payment );
1565
+		$json_response_data = array('return_data' => FALSE);
1566
+		$PAY_ID = isset($this->_req_data['delete_txn_admin_payment'], $this->_req_data['delete_txn_admin_payment']['PAY_ID']) ? absint($this->_req_data['delete_txn_admin_payment']['PAY_ID']) : 0;
1567
+		if ($PAY_ID) {
1568
+			$delete_txn_reg_status_change = isset($this->_req_data['delete_txn_reg_status_change']) ? $this->_req_data['delete_txn_reg_status_change'] : false;
1569
+			$payment = EEM_Payment::instance()->get_one_by_ID($PAY_ID);
1570
+			if ($payment instanceof EE_Payment) {
1571
+				$REG_IDs = $this->_get_existing_reg_payment_REG_IDs($payment);
1572 1572
 				/** @type EE_Transaction_Payments $transaction_payments */
1573
-				$transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' );
1574
-				if ( $transaction_payments->delete_payment_and_update_transaction( $payment )) {
1575
-					$json_response_data['return_data'] = $this->_build_payment_json_response( $payment, $REG_IDs, $delete_txn_reg_status_change );
1576
-					if ( $delete_txn_reg_status_change ) {
1573
+				$transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
1574
+				if ($transaction_payments->delete_payment_and_update_transaction($payment)) {
1575
+					$json_response_data['return_data'] = $this->_build_payment_json_response($payment, $REG_IDs, $delete_txn_reg_status_change);
1576
+					if ($delete_txn_reg_status_change) {
1577 1577
 						$this->_req_data['txn_reg_status_change'] = $delete_txn_reg_status_change;
1578 1578
 						//MAKE sure we also add the delete_txn_req_status_change to the
1579 1579
 						//$_REQUEST global because that's how messages will be looking for it.
1580 1580
 						$_REQUEST['txn_reg_status_change'] = $delete_txn_reg_status_change;
1581 1581
 						$this->_maybe_send_notifications();
1582
-						$this->_process_registration_status_change( $payment->transaction(), $REG_IDs );
1582
+						$this->_process_registration_status_change($payment->transaction(), $REG_IDs);
1583 1583
 					}
1584 1584
 				}
1585 1585
 			} else {
1586 1586
 				EE_Error::add_error(
1587
-					__( 'Valid Payment data could not be retrieved from the database.', 'event_espresso' ),
1587
+					__('Valid Payment data could not be retrieved from the database.', 'event_espresso'),
1588 1588
 					__FILE__, __FUNCTION__, __LINE__
1589 1589
 				);
1590 1590
 			}
1591 1591
 		} else {
1592 1592
 			EE_Error::add_error(
1593
-				__( 'A valid Payment ID was not received, therefore payment form data could not be loaded.', 'event_espresso' ),
1593
+				__('A valid Payment ID was not received, therefore payment form data could not be loaded.', 'event_espresso'),
1594 1594
 				__FILE__, __FUNCTION__, __LINE__
1595 1595
 			);
1596 1596
 		}
1597
-		$notices = EE_Error::get_notices( false, false, false);
1597
+		$notices = EE_Error::get_notices(false, false, false);
1598 1598
 		$this->_template_args = array(
1599 1599
 			'data' => $json_response_data,
1600 1600
 			'success' => $notices['success'],
@@ -1614,16 +1614,16 @@  discard block
 block discarded – undo
1614 1614
 	 * @param array $REG_IDs
1615 1615
 	 * @return array
1616 1616
 	 */
1617
-	protected function _registration_payment_data_array( $REG_IDs ) {
1617
+	protected function _registration_payment_data_array($REG_IDs) {
1618 1618
 		$registration_payment_data = array();
1619 1619
 		//if non empty reg_ids lets get an array of registrations and update the values for the apply_payment/refund rows.
1620
-		if ( ! empty( $REG_IDs ) ) {
1621
-			$registrations = EEM_Registration::instance()->get_all( array( array( 'REG_ID' => array( 'IN', $REG_IDs ) ) ) );
1622
-			foreach ( $registrations as $registration ) {
1623
-				if ( $registration instanceof EE_Registration ) {
1624
-					$registration_payment_data[ $registration->ID() ] = array(
1620
+		if ( ! empty($REG_IDs)) {
1621
+			$registrations = EEM_Registration::instance()->get_all(array(array('REG_ID' => array('IN', $REG_IDs))));
1622
+			foreach ($registrations as $registration) {
1623
+				if ($registration instanceof EE_Registration) {
1624
+					$registration_payment_data[$registration->ID()] = array(
1625 1625
 						'paid' => $registration->pretty_paid(),
1626
-						'owing' => EEH_Template::format_currency( $registration->final_price() - $registration->paid() ),
1626
+						'owing' => EEH_Template::format_currency($registration->final_price() - $registration->paid()),
1627 1627
 					);
1628 1628
 				}
1629 1629
 			}
@@ -1643,30 +1643,30 @@  discard block
 block discarded – undo
1643 1643
 	 * @access protected
1644 1644
 	 * @param \EE_Payment | null $payment
1645 1645
 	 */
1646
-	protected function _maybe_send_notifications( $payment = null ) {
1647
-		switch ( $payment instanceof EE_Payment ) {
1646
+	protected function _maybe_send_notifications($payment = null) {
1647
+		switch ($payment instanceof EE_Payment) {
1648 1648
 			// payment notifications
1649 1649
 			case true :
1650 1650
 				if (
1651 1651
 					isset(
1652
-						$this->_req_data[ 'txn_payments' ],
1653
-						$this->_req_data[ 'txn_payments' ][ 'send_notifications' ]
1652
+						$this->_req_data['txn_payments'],
1653
+						$this->_req_data['txn_payments']['send_notifications']
1654 1654
 					) &&
1655
-					filter_var( $this->_req_data[ 'txn_payments' ][ 'send_notifications' ], FILTER_VALIDATE_BOOLEAN )
1655
+					filter_var($this->_req_data['txn_payments']['send_notifications'], FILTER_VALIDATE_BOOLEAN)
1656 1656
 				) {
1657
-					$this->_process_payment_notification( $payment );
1657
+					$this->_process_payment_notification($payment);
1658 1658
 				}
1659 1659
 				break;
1660 1660
 			// registration notifications
1661 1661
 			case false :
1662 1662
 				if (
1663 1663
 					isset(
1664
-						$this->_req_data[ 'txn_reg_status_change' ],
1665
-						$this->_req_data[ 'txn_reg_status_change' ][ 'send_notifications' ]
1664
+						$this->_req_data['txn_reg_status_change'],
1665
+						$this->_req_data['txn_reg_status_change']['send_notifications']
1666 1666
 					) &&
1667
-					filter_var( $this->_req_data[ 'txn_reg_status_change' ][ 'send_notifications' ], FILTER_VALIDATE_BOOLEAN )
1667
+					filter_var($this->_req_data['txn_reg_status_change']['send_notifications'], FILTER_VALIDATE_BOOLEAN)
1668 1668
 				) {
1669
-					add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true' );
1669
+					add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true');
1670 1670
 				}
1671 1671
 				break;
1672 1672
 		}
@@ -1682,11 +1682,11 @@  discard block
 block discarded – undo
1682 1682
 	*	@return void
1683 1683
 	*/
1684 1684
 	protected function _send_payment_reminder() {
1685
-	    $TXN_ID = ( ! empty( $this->_req_data['TXN_ID'] )) ? absint( $this->_req_data['TXN_ID'] ) : FALSE;
1686
-		$transaction = EEM_Transaction::instance()->get_one_by_ID( $TXN_ID );
1687
-		$query_args = isset($this->_req_data['redirect_to'] ) ? array('action' => $this->_req_data['redirect_to'], 'TXN_ID' => $this->_req_data['TXN_ID'] ) : array();
1688
-		do_action( 'AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder', $transaction );
1689
-		$this->_redirect_after_action( FALSE, __('payment reminder', 'event_espresso'), __('sent', 'event_espresso'), $query_args, TRUE );
1685
+	    $TXN_ID = ( ! empty($this->_req_data['TXN_ID'])) ? absint($this->_req_data['TXN_ID']) : FALSE;
1686
+		$transaction = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
1687
+		$query_args = isset($this->_req_data['redirect_to']) ? array('action' => $this->_req_data['redirect_to'], 'TXN_ID' => $this->_req_data['TXN_ID']) : array();
1688
+		do_action('AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder', $transaction);
1689
+		$this->_redirect_after_action(FALSE, __('payment reminder', 'event_espresso'), __('sent', 'event_espresso'), $query_args, TRUE);
1690 1690
 	}
1691 1691
 
1692 1692
 
@@ -1700,36 +1700,36 @@  discard block
 block discarded – undo
1700 1700
 	 * @param string   $view
1701 1701
 	 * @return mixed int = count || array of transaction objects
1702 1702
 	 */
1703
-	public function get_transactions( $perpage, $count = FALSE, $view = '' ) {
1703
+	public function get_transactions($perpage, $count = FALSE, $view = '') {
1704 1704
 
1705 1705
 		$TXN = EEM_Transaction::instance();
1706 1706
 
1707
-	    $start_date = isset( $this->_req_data['txn-filter-start-date'] ) ? wp_strip_all_tags( $this->_req_data['txn-filter-start-date'] ) : date( 'm/d/Y', strtotime( '-10 year' ));
1708
-	    $end_date = isset( $this->_req_data['txn-filter-end-date'] ) ? wp_strip_all_tags( $this->_req_data['txn-filter-end-date'] ) : date( 'm/d/Y' );
1707
+	    $start_date = isset($this->_req_data['txn-filter-start-date']) ? wp_strip_all_tags($this->_req_data['txn-filter-start-date']) : date('m/d/Y', strtotime('-10 year'));
1708
+	    $end_date = isset($this->_req_data['txn-filter-end-date']) ? wp_strip_all_tags($this->_req_data['txn-filter-end-date']) : date('m/d/Y');
1709 1709
 
1710 1710
 	    //make sure our timestamps start and end right at the boundaries for each day
1711
-	    $start_date = date( 'Y-m-d', strtotime( $start_date ) ) . ' 00:00:00';
1712
-	    $end_date = date( 'Y-m-d', strtotime( $end_date ) ) . ' 23:59:59';
1711
+	    $start_date = date('Y-m-d', strtotime($start_date)).' 00:00:00';
1712
+	    $end_date = date('Y-m-d', strtotime($end_date)).' 23:59:59';
1713 1713
 
1714 1714
 
1715 1715
 	    //convert to timestamps
1716
-	    $start_date = strtotime( $start_date );
1717
-	    $end_date = strtotime( $end_date );
1716
+	    $start_date = strtotime($start_date);
1717
+	    $end_date = strtotime($end_date);
1718 1718
 
1719 1719
 	    //makes sure start date is the lowest value and vice versa
1720
-	    $start_date = min( $start_date, $end_date );
1721
-	    $end_date = max( $start_date, $end_date );
1720
+	    $start_date = min($start_date, $end_date);
1721
+	    $end_date = max($start_date, $end_date);
1722 1722
 
1723 1723
 	    //convert to correct format for query
1724
-	$start_date = EEM_Transaction::instance()->convert_datetime_for_query( 'TXN_timestamp', date( 'Y-m-d H:i:s', $start_date ), 'Y-m-d H:i:s' );
1725
-	$end_date = EEM_Transaction::instance()->convert_datetime_for_query( 'TXN_timestamp', date( 'Y-m-d H:i:s', $end_date ), 'Y-m-d H:i:s' );
1724
+	$start_date = EEM_Transaction::instance()->convert_datetime_for_query('TXN_timestamp', date('Y-m-d H:i:s', $start_date), 'Y-m-d H:i:s');
1725
+	$end_date = EEM_Transaction::instance()->convert_datetime_for_query('TXN_timestamp', date('Y-m-d H:i:s', $end_date), 'Y-m-d H:i:s');
1726 1726
 
1727 1727
 
1728 1728
 
1729 1729
 	    //set orderby
1730 1730
 		$this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : '';
1731 1731
 
1732
-		switch ( $this->_req_data['orderby'] ) {
1732
+		switch ($this->_req_data['orderby']) {
1733 1733
 			case 'TXN_ID':
1734 1734
 				$orderby = 'TXN_ID';
1735 1735
 				break;
@@ -1743,66 +1743,66 @@  discard block
 block discarded – undo
1743 1743
 				$orderby = 'TXN_timestamp';
1744 1744
 		}
1745 1745
 
1746
-		$sort = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] )) ? $this->_req_data['order'] : 'DESC';
1747
-		$current_page = isset( $this->_req_data['paged'] ) && !empty( $this->_req_data['paged'] ) ? $this->_req_data['paged'] : 1;
1748
-		$per_page = isset( $perpage ) && !empty( $perpage ) ? $perpage : 10;
1749
-		$per_page = isset( $this->_req_data['perpage'] ) && !empty( $this->_req_data['perpage'] ) ? $this->_req_data['perpage'] : $per_page;
1746
+		$sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'DESC';
1747
+		$current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1;
1748
+		$per_page = isset($perpage) && ! empty($perpage) ? $perpage : 10;
1749
+		$per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $per_page;
1750 1750
 
1751
-		$offset = ($current_page-1)*$per_page;
1752
-		$limit = array( $offset, $per_page );
1751
+		$offset = ($current_page - 1) * $per_page;
1752
+		$limit = array($offset, $per_page);
1753 1753
 
1754 1754
 		$_where = array(
1755
-			'TXN_timestamp' => array('BETWEEN', array($start_date, $end_date) ),
1755
+			'TXN_timestamp' => array('BETWEEN', array($start_date, $end_date)),
1756 1756
 			'Registration.REG_count' => 1
1757 1757
 		);
1758 1758
 
1759
-		if ( isset( $this->_req_data['EVT_ID'] ) ) {
1759
+		if (isset($this->_req_data['EVT_ID'])) {
1760 1760
 			$_where['Registration.EVT_ID'] = $this->_req_data['EVT_ID'];
1761 1761
 		}
1762 1762
 
1763
-		if ( isset( $this->_req_data['s'] ) ) {
1764
-			$search_string = '%' . $this->_req_data['s'] . '%';
1763
+		if (isset($this->_req_data['s'])) {
1764
+			$search_string = '%'.$this->_req_data['s'].'%';
1765 1765
 			$_where['OR'] = array(
1766
-				'Registration.Event.EVT_name' => array( 'LIKE', $search_string ),
1767
-				'Registration.Event.EVT_desc' => array( 'LIKE', $search_string ),
1768
-				'Registration.Event.EVT_short_desc' => array( 'LIKE' , $search_string ),
1769
-				'Registration.Attendee.ATT_full_name' => array( 'LIKE', $search_string ),
1770
-				'Registration.Attendee.ATT_fname' => array( 'LIKE', $search_string ),
1771
-				'Registration.Attendee.ATT_lname' => array( 'LIKE', $search_string ),
1772
-				'Registration.Attendee.ATT_short_bio' => array( 'LIKE', $search_string ),
1773
-				'Registration.Attendee.ATT_email' => array('LIKE', $search_string ),
1774
-				'Registration.Attendee.ATT_address' => array( 'LIKE', $search_string ),
1775
-				'Registration.Attendee.ATT_address2' => array( 'LIKE', $search_string ),
1776
-				'Registration.Attendee.ATT_city' => array( 'LIKE', $search_string ),
1777
-				'Registration.REG_final_price' => array( 'LIKE', $search_string ),
1778
-				'Registration.REG_code' => array( 'LIKE', $search_string ),
1779
-				'Registration.REG_count' => array( 'LIKE' , $search_string ),
1780
-				'Registration.REG_group_size' => array( 'LIKE' , $search_string ),
1781
-				'Registration.Ticket.TKT_name' => array( 'LIKE', $search_string ),
1782
-				'Registration.Ticket.TKT_description' => array( 'LIKE', $search_string ),
1783
-				'Payment.PAY_source' => array('LIKE', $search_string ),
1784
-				'Payment.Payment_Method.PMD_name' => array('LIKE', $search_string ),
1785
-				'TXN_session_data' => array( 'LIKE', $search_string ),
1786
-				'Payment.PAY_txn_id_chq_nmbr' => array( 'LIKE', $search_string )
1766
+				'Registration.Event.EVT_name' => array('LIKE', $search_string),
1767
+				'Registration.Event.EVT_desc' => array('LIKE', $search_string),
1768
+				'Registration.Event.EVT_short_desc' => array('LIKE', $search_string),
1769
+				'Registration.Attendee.ATT_full_name' => array('LIKE', $search_string),
1770
+				'Registration.Attendee.ATT_fname' => array('LIKE', $search_string),
1771
+				'Registration.Attendee.ATT_lname' => array('LIKE', $search_string),
1772
+				'Registration.Attendee.ATT_short_bio' => array('LIKE', $search_string),
1773
+				'Registration.Attendee.ATT_email' => array('LIKE', $search_string),
1774
+				'Registration.Attendee.ATT_address' => array('LIKE', $search_string),
1775
+				'Registration.Attendee.ATT_address2' => array('LIKE', $search_string),
1776
+				'Registration.Attendee.ATT_city' => array('LIKE', $search_string),
1777
+				'Registration.REG_final_price' => array('LIKE', $search_string),
1778
+				'Registration.REG_code' => array('LIKE', $search_string),
1779
+				'Registration.REG_count' => array('LIKE', $search_string),
1780
+				'Registration.REG_group_size' => array('LIKE', $search_string),
1781
+				'Registration.Ticket.TKT_name' => array('LIKE', $search_string),
1782
+				'Registration.Ticket.TKT_description' => array('LIKE', $search_string),
1783
+				'Payment.PAY_source' => array('LIKE', $search_string),
1784
+				'Payment.Payment_Method.PMD_name' => array('LIKE', $search_string),
1785
+				'TXN_session_data' => array('LIKE', $search_string),
1786
+				'Payment.PAY_txn_id_chq_nmbr' => array('LIKE', $search_string)
1787 1787
 				);
1788 1788
 		}
1789 1789
 
1790 1790
 		//failed transactions
1791
-		$failed = ( ! empty( $this->_req_data['status'] ) && $this->_req_data['status'] == 'failed' && ! $count ) || ( $count && $view == 'failed' ) ? TRUE: FALSE;
1792
-		$abandoned = ( ! empty( $this->_req_data['status'] ) && $this->_req_data['status'] == 'abandoned' && ! $count ) || ( $count && $view == 'abandoned' ) ? TRUE: FALSE;
1791
+		$failed = ( ! empty($this->_req_data['status']) && $this->_req_data['status'] == 'failed' && ! $count) || ($count && $view == 'failed') ? TRUE : FALSE;
1792
+		$abandoned = ( ! empty($this->_req_data['status']) && $this->_req_data['status'] == 'abandoned' && ! $count) || ($count && $view == 'abandoned') ? TRUE : FALSE;
1793 1793
 
1794
-		if ( $failed ) {
1795
-			$_where[ 'STS_ID' ] = EEM_Transaction::failed_status_code;
1796
-		} else if ( $abandoned ) {
1794
+		if ($failed) {
1795
+			$_where['STS_ID'] = EEM_Transaction::failed_status_code;
1796
+		} else if ($abandoned) {
1797 1797
 				$_where['STS_ID'] = EEM_Transaction::abandoned_status_code;
1798 1798
 		} else {
1799
-				$_where['STS_ID'] = array( '!=', EEM_Transaction::failed_status_code );
1800
-				$_where['STS_ID*'] = array( '!=', EEM_Transaction::abandoned_status_code );
1799
+				$_where['STS_ID'] = array('!=', EEM_Transaction::failed_status_code);
1800
+				$_where['STS_ID*'] = array('!=', EEM_Transaction::abandoned_status_code);
1801 1801
 		}
1802 1802
 
1803
-		$query_params = array( $_where, 'order_by' => array( $orderby => $sort ), 'limit' => $limit );
1803
+		$query_params = array($_where, 'order_by' => array($orderby => $sort), 'limit' => $limit);
1804 1804
 
1805
-		$transactions = $count ? $TXN->count( array($_where), 'TXN_ID', TRUE ) : $TXN->get_all($query_params);
1805
+		$transactions = $count ? $TXN->count(array($_where), 'TXN_ID', TRUE) : $TXN->get_all($query_params);
1806 1806
 
1807 1807
 
1808 1808
 		return $transactions;
Please login to merge, or discard this patch.
core/helpers/EEH_Activation.helper.php 2 patches
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 			if ( is_array( $hooks_to_fire_at_time ) ) {
208 208
 				foreach ( $hooks_to_fire_at_time as $hook_name => $hook_actions ) {
209 209
 					if ( isset( $ee_cron_tasks_to_remove[ $hook_name ] )
210
-					     && is_array( $ee_cron_tasks_to_remove[ $hook_name ] )
210
+						 && is_array( $ee_cron_tasks_to_remove[ $hook_name ] )
211 211
 					) {
212 212
 						unset( $crons[ $timestamp ][ $hook_name ] );
213 213
 					}
@@ -1124,14 +1124,14 @@  discard block
 block discarded – undo
1124 1124
 							$QSG_ID = reset( $id_col );
1125 1125
 						} else {
1126 1126
 							//ok so we didn't find it in the db either?? that's weird because we should have inserted it at the start of this method
1127
-                                                        EE_Log::instance()->log(
1128
-                                                                __FILE__,
1129
-                                                                __FUNCTION__,
1130
-                                                                sprintf(
1131
-                                                                        __( 'Could not associate question %1$s to a question group because no system question group existed', 'event_espresso'),
1132
-                                                                        $QST_ID ),
1133
-                                                                'error' );
1134
-                                                        continue;
1127
+														EE_Log::instance()->log(
1128
+																__FILE__,
1129
+																__FUNCTION__,
1130
+																sprintf(
1131
+																		__( 'Could not associate question %1$s to a question group because no system question group existed', 'event_espresso'),
1132
+																		$QST_ID ),
1133
+																'error' );
1134
+														continue;
1135 1135
 						}
1136 1136
 					}
1137 1137
 
@@ -1139,8 +1139,8 @@  discard block
 block discarded – undo
1139 1139
 					$wpdb->insert(
1140 1140
 						EEH_Activation::ensure_table_name_has_prefix( 'esp_question_group_question' ),
1141 1141
 						array( 'QSG_ID'    => $QSG_ID,
1142
-						       'QST_ID'    => $QST_ID,
1143
-						       'QGQ_order' => ( $QSG_ID === 1 ) ? $order_for_group_1++ : $order_for_group_2++
1142
+							   'QST_ID'    => $QST_ID,
1143
+							   'QGQ_order' => ( $QSG_ID === 1 ) ? $order_for_group_1++ : $order_for_group_2++
1144 1144
 						),
1145 1145
 						array( '%d', '%d', '%d' )
1146 1146
 					);
@@ -1678,8 +1678,8 @@  discard block
 block discarded – undo
1678 1678
 				}
1679 1679
 			}
1680 1680
 		}
1681
-                //also, let's make sure the "ee_config_option_names" wp option stays out by removing the action that adds it
1682
-                remove_action( 'shutdown', array( EE_Config::instance(), 'shutdown' ), 10 );
1681
+				//also, let's make sure the "ee_config_option_names" wp option stays out by removing the action that adds it
1682
+				remove_action( 'shutdown', array( EE_Config::instance(), 'shutdown' ), 10 );
1683 1683
 
1684 1684
 		if ( $remove_all && $espresso_db_update = get_option( 'espresso_db_update' )) {
1685 1685
 			$db_update_sans_ee4 = array();
Please login to merge, or discard this patch.
Spacing   +376 added lines, -376 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed');}
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed'); }
2 2
 /**
3 3
  * EEH_Activation Helper
4 4
  *
@@ -48,9 +48,9 @@  discard block
 block discarded – undo
48 48
 	 * @param $table_name
49 49
 	 * @return string
50 50
 	 */
51
-	public static function ensure_table_name_has_prefix( $table_name ) {
51
+	public static function ensure_table_name_has_prefix($table_name) {
52 52
 		global $wpdb;
53
-		return strpos( $table_name, $wpdb->prefix ) === 0 ? $table_name : $wpdb->prefix . $table_name;
53
+		return strpos($table_name, $wpdb->prefix) === 0 ? $table_name : $wpdb->prefix.$table_name;
54 54
 	}
55 55
 
56 56
 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	 * @return boolean success, whether the database and folders are setup properly
79 79
 	 * @throws \EE_Error
80 80
 	 */
81
-	public static function initialize_db_and_folders(){
81
+	public static function initialize_db_and_folders() {
82 82
 		$good_filesystem = EEH_Activation::create_upload_directories();
83 83
 		$good_db = EEH_Activation::create_database_tables();
84 84
 		return $good_filesystem && $good_db;
@@ -94,9 +94,9 @@  discard block
 block discarded – undo
94 94
 	 *
95 95
 	 * @throws \EE_Error
96 96
 	 */
97
-	public static function initialize_db_content(){
97
+	public static function initialize_db_content() {
98 98
 		//let's avoid doing all this logic repeatedly, especially when addons are requesting it
99
-		if( EEH_Activation::$_initialized_db_content_already_in_this_request ) {
99
+		if (EEH_Activation::$_initialized_db_content_already_in_this_request) {
100 100
 			return;
101 101
 		}
102 102
 		EEH_Activation::$_initialized_db_content_already_in_this_request = true;
@@ -113,9 +113,9 @@  discard block
 block discarded – undo
113 113
 		EEH_Activation::remove_cron_tasks();
114 114
 		EEH_Activation::create_cron_tasks();
115 115
 		// remove all TXN locks since that is being done via extra meta now
116
-		delete_option( 'ee_locked_transactions' );
116
+		delete_option('ee_locked_transactions');
117 117
 		//also, check for CAF default db content
118
-		do_action( 'AHEE__EEH_Activation__initialize_db_content' );
118
+		do_action('AHEE__EEH_Activation__initialize_db_content');
119 119
 		//also: EEM_Gateways::load_all_gateways() outputs a lot of success messages
120 120
 		//which users really won't care about on initial activation
121 121
 		EE_Error::overwrite_success();
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 	 * @return array
135 135
 	 * @throws \EE_Error
136 136
 	 */
137
-	public static function get_cron_tasks( $which_to_include ) {
137
+	public static function get_cron_tasks($which_to_include) {
138 138
 		$cron_tasks = apply_filters(
139 139
 			'FHEE__EEH_Activation__get_cron_tasks',
140 140
 			array(
@@ -143,16 +143,16 @@  discard block
 block discarded – undo
143 143
 				'AHEE__EE_Cron_Tasks__update_transaction_with_payment' => EEH_Activation::cron_task_no_longer_in_use, //there may have been a bug which prevented from these cron tasks from getting unscheduled, so we might want to remove these for a few updates
144 144
 			)
145 145
 		);
146
-		if ( $which_to_include === 'old' ) {
146
+		if ($which_to_include === 'old') {
147 147
 			$cron_tasks = array_filter(
148 148
 				$cron_tasks,
149
-				function ( $value ) {
149
+				function($value) {
150 150
 					return $value === EEH_Activation::cron_task_no_longer_in_use;
151 151
 				}
152 152
 			);
153
-		} elseif ( $which_to_include === 'current' ) {
154
-			$cron_tasks = array_filter( $cron_tasks );
155
-		} elseif ( WP_DEBUG && $which_to_include !== 'all' ) {
153
+		} elseif ($which_to_include === 'current') {
154
+			$cron_tasks = array_filter($cron_tasks);
155
+		} elseif (WP_DEBUG && $which_to_include !== 'all') {
156 156
 			throw new EE_Error(
157 157
 				sprintf(
158 158
 					__(
@@ -175,9 +175,9 @@  discard block
 block discarded – undo
175 175
 	 */
176 176
 	public static function create_cron_tasks() {
177 177
 
178
-		foreach( EEH_Activation::get_cron_tasks( 'current' ) as $hook_name => $frequency ) {
179
-			if( ! wp_next_scheduled( $hook_name ) ) {
180
-				wp_schedule_event( time(), $frequency, $hook_name );
178
+		foreach (EEH_Activation::get_cron_tasks('current') as $hook_name => $frequency) {
179
+			if ( ! wp_next_scheduled($hook_name)) {
180
+				wp_schedule_event(time(), $frequency, $hook_name);
181 181
 			}
182 182
 		}
183 183
 
@@ -191,10 +191,10 @@  discard block
 block discarded – undo
191 191
 	 * @param boolean $remove_all whether to only remove the old ones, or remove absolutely ALL the EE ones
192 192
 	 * @throws \EE_Error
193 193
 	 */
194
-	public static function remove_cron_tasks( $remove_all = true ) {
194
+	public static function remove_cron_tasks($remove_all = true) {
195 195
 		$cron_tasks_to_remove = $remove_all ? 'all' : 'old';
196 196
 		$crons = _get_cron_array();
197
-		$crons = is_array( $crons ) ? $crons : array();
197
+		$crons = is_array($crons) ? $crons : array();
198 198
 		/* reminder of what $crons look like:
199 199
 		 * Top-level keys are timestamps, and their values are arrays.
200 200
 		 * The 2nd level arrays have keys with each of the cron task hook names to run at that time
@@ -212,23 +212,23 @@  discard block
 block discarded – undo
212 212
 		 *					...
213 213
 		 *      ...
214 214
 		 */
215
-		$ee_cron_tasks_to_remove = EEH_Activation::get_cron_tasks( $cron_tasks_to_remove );
216
-		foreach ( $crons as $timestamp => $hooks_to_fire_at_time ) {
217
-			if ( is_array( $hooks_to_fire_at_time ) ) {
218
-				foreach ( $hooks_to_fire_at_time as $hook_name => $hook_actions ) {
219
-					if ( isset( $ee_cron_tasks_to_remove[ $hook_name ] )
220
-					     && is_array( $ee_cron_tasks_to_remove[ $hook_name ] )
215
+		$ee_cron_tasks_to_remove = EEH_Activation::get_cron_tasks($cron_tasks_to_remove);
216
+		foreach ($crons as $timestamp => $hooks_to_fire_at_time) {
217
+			if (is_array($hooks_to_fire_at_time)) {
218
+				foreach ($hooks_to_fire_at_time as $hook_name => $hook_actions) {
219
+					if (isset($ee_cron_tasks_to_remove[$hook_name])
220
+					     && is_array($ee_cron_tasks_to_remove[$hook_name])
221 221
 					) {
222
-						unset( $crons[ $timestamp ][ $hook_name ] );
222
+						unset($crons[$timestamp][$hook_name]);
223 223
 					}
224 224
 				}
225 225
 				//also take care of any empty cron timestamps.
226
-				if ( empty( $hooks_to_fire_at_time ) ) {
227
-					unset( $crons[ $timestamp ] );
226
+				if (empty($hooks_to_fire_at_time)) {
227
+					unset($crons[$timestamp]);
228 228
 				}
229 229
 			}
230 230
 		}
231
-		_set_cron_array( $crons );
231
+		_set_cron_array($crons);
232 232
 	}
233 233
 
234 234
 
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 	 */
244 244
 	public static function CPT_initialization() {
245 245
 		// register Custom Post Types
246
-		EE_Registry::instance()->load_core( 'Register_CPTs' );
246
+		EE_Registry::instance()->load_core('Register_CPTs');
247 247
 		flush_rewrite_rules();
248 248
 	}
249 249
 
@@ -261,8 +261,8 @@  discard block
 block discarded – undo
261 261
 	 * 	@return void
262 262
 	 */
263 263
 	public static function reset_and_update_config() {
264
-		do_action( 'AHEE__EE_Config___load_core_config__start', array( 'EEH_Activation', 'load_calendar_config' ) );
265
-		add_filter( 'FHEE__EE_Config___load_core_config__config_settings', array( 'EEH_Activation', 'migrate_old_config_data' ), 10, 3 );
264
+		do_action('AHEE__EE_Config___load_core_config__start', array('EEH_Activation', 'load_calendar_config'));
265
+		add_filter('FHEE__EE_Config___load_core_config__config_settings', array('EEH_Activation', 'migrate_old_config_data'), 10, 3);
266 266
 		//EE_Config::reset();
267 267
 	}
268 268
 
@@ -275,28 +275,28 @@  discard block
 block discarded – undo
275 275
 	 */
276 276
 	public static function load_calendar_config() {
277 277
 		// grab array of all plugin folders and loop thru it
278
-		$plugins = glob( WP_PLUGIN_DIR . DS . '*', GLOB_ONLYDIR );
279
-		if ( empty( $plugins ) ) {
278
+		$plugins = glob(WP_PLUGIN_DIR.DS.'*', GLOB_ONLYDIR);
279
+		if (empty($plugins)) {
280 280
 			return;
281 281
 		}
282
-		foreach ( $plugins as $plugin_path ) {
282
+		foreach ($plugins as $plugin_path) {
283 283
 			// grab plugin folder name from path
284
-			$plugin = basename( $plugin_path );
284
+			$plugin = basename($plugin_path);
285 285
 			// drill down to Espresso plugins
286 286
 			// then to calendar related plugins
287 287
 			if (
288
-				strpos( $plugin, 'espresso' ) !== FALSE
289
-				|| strpos( $plugin, 'Espresso' ) !== FALSE
290
-				|| strpos( $plugin, 'ee4' ) !== FALSE
291
-				|| strpos( $plugin, 'EE4' ) !== FALSE
292
-				|| strpos( $plugin, 'calendar' ) !== false
288
+				strpos($plugin, 'espresso') !== FALSE
289
+				|| strpos($plugin, 'Espresso') !== FALSE
290
+				|| strpos($plugin, 'ee4') !== FALSE
291
+				|| strpos($plugin, 'EE4') !== FALSE
292
+				|| strpos($plugin, 'calendar') !== false
293 293
 			) {
294 294
 				// this is what we are looking for
295
-				$calendar_config = $plugin_path . DS . 'EE_Calendar_Config.php';
295
+				$calendar_config = $plugin_path.DS.'EE_Calendar_Config.php';
296 296
 				// does it exist in this folder ?
297
-				if ( is_readable( $calendar_config )) {
297
+				if (is_readable($calendar_config)) {
298 298
 					// YEAH! let's load it
299
-					require_once( $calendar_config );
299
+					require_once($calendar_config);
300 300
 				}
301 301
 			}
302 302
 		}
@@ -312,21 +312,21 @@  discard block
 block discarded – undo
312 312
 	 * @param \EE_Config     $EE_Config
313 313
 	 * @return \stdClass
314 314
 	 */
315
-	public static function migrate_old_config_data( $settings = array(), $config = '', EE_Config $EE_Config ) {
316
-		$convert_from_array = array( 'addons' );
315
+	public static function migrate_old_config_data($settings = array(), $config = '', EE_Config $EE_Config) {
316
+		$convert_from_array = array('addons');
317 317
 		// in case old settings were saved as an array
318
-		if ( is_array( $settings ) && in_array( $config, $convert_from_array )) {
318
+		if (is_array($settings) && in_array($config, $convert_from_array)) {
319 319
 			// convert existing settings to an object
320 320
 			$config_array = $settings;
321 321
 			$settings = new stdClass();
322
-			foreach ( $config_array as $key => $value ){
323
-				if ( $key === 'calendar' && class_exists( 'EE_Calendar_Config' )) {
324
-					$EE_Config->set_config( 'addons', 'EE_Calendar', 'EE_Calendar_Config', $value );
322
+			foreach ($config_array as $key => $value) {
323
+				if ($key === 'calendar' && class_exists('EE_Calendar_Config')) {
324
+					$EE_Config->set_config('addons', 'EE_Calendar', 'EE_Calendar_Config', $value);
325 325
 				} else {
326 326
 					$settings->{$key} = $value;
327 327
 				}
328 328
 			}
329
-			add_filter( 'FHEE__EE_Config___load_core_config__update_espresso_config', '__return_true' );
329
+			add_filter('FHEE__EE_Config___load_core_config__update_espresso_config', '__return_true');
330 330
 		}
331 331
 		return $settings;
332 332
 	}
@@ -342,8 +342,8 @@  discard block
 block discarded – undo
342 342
 	 */
343 343
 	public static function deactivate_event_espresso() {
344 344
 		// check permissions
345
-		if ( current_user_can( 'activate_plugins' )) {
346
-			deactivate_plugins( EE_PLUGIN_BASENAME, TRUE );
345
+		if (current_user_can('activate_plugins')) {
346
+			deactivate_plugins(EE_PLUGIN_BASENAME, TRUE);
347 347
 		}
348 348
 	}
349 349
 
@@ -365,25 +365,25 @@  discard block
 block discarded – undo
365 365
 		$critical_pages = array(
366 366
 			array(
367 367
 				'id' =>'reg_page_id',
368
-				'name' => __( 'Registration Checkout', 'event_espresso' ),
368
+				'name' => __('Registration Checkout', 'event_espresso'),
369 369
 				'post' => NULL,
370 370
 				'code' => 'ESPRESSO_CHECKOUT'
371 371
 			),
372 372
 			array(
373 373
 				'id' => 'txn_page_id',
374
-				'name' => __( 'Transactions', 'event_espresso' ),
374
+				'name' => __('Transactions', 'event_espresso'),
375 375
 				'post' => NULL,
376 376
 				'code' => 'ESPRESSO_TXN_PAGE'
377 377
 			),
378 378
 			array(
379 379
 				'id' => 'thank_you_page_id',
380
-				'name' => __( 'Thank You', 'event_espresso' ),
380
+				'name' => __('Thank You', 'event_espresso'),
381 381
 				'post' => NULL,
382 382
 				'code' => 'ESPRESSO_THANK_YOU'
383 383
 			),
384 384
 			array(
385 385
 				'id' => 'cancel_page_id',
386
-				'name' => __( 'Registration Cancelled', 'event_espresso' ),
386
+				'name' => __('Registration Cancelled', 'event_espresso'),
387 387
 				'post' => NULL,
388 388
 				'code' => 'ESPRESSO_CANCELLED'
389 389
 			),
@@ -391,62 +391,62 @@  discard block
 block discarded – undo
391 391
 
392 392
 		$EE_Core_Config = EE_Registry::instance()->CFG->core;
393 393
 
394
-		foreach ( $critical_pages as $critical_page ) {
394
+		foreach ($critical_pages as $critical_page) {
395 395
 			// is critical page ID set in config ?
396
-			if ( $EE_Core_Config->{$critical_page[ 'id' ]} !== FALSE ) {
396
+			if ($EE_Core_Config->{$critical_page['id']} !== FALSE) {
397 397
 				// attempt to find post by ID
398
-				$critical_page['post'] = get_post( $EE_Core_Config->{$critical_page[ 'id' ]} );
398
+				$critical_page['post'] = get_post($EE_Core_Config->{$critical_page['id']} );
399 399
 			}
400 400
 			// no dice?
401
-			if ( $critical_page['post'] === null ) {
401
+			if ($critical_page['post'] === null) {
402 402
 				// attempt to find post by title
403
-				$critical_page['post'] = self::get_page_by_ee_shortcode( $critical_page['code'] );
403
+				$critical_page['post'] = self::get_page_by_ee_shortcode($critical_page['code']);
404 404
 				// still nothing?
405
-				if ( $critical_page['post'] === null ) {
406
-					$critical_page = EEH_Activation::create_critical_page( $critical_page );
405
+				if ($critical_page['post'] === null) {
406
+					$critical_page = EEH_Activation::create_critical_page($critical_page);
407 407
 					// REALLY? Still nothing ??!?!?
408
-					if ( $critical_page['post'] === null ) {
409
-						$msg = __( 'The Event Espresso critical page configuration settings could not be updated.', 'event_espresso' );
410
-						EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
408
+					if ($critical_page['post'] === null) {
409
+						$msg = __('The Event Espresso critical page configuration settings could not be updated.', 'event_espresso');
410
+						EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
411 411
 						break;
412 412
 					}
413 413
 				}
414 414
 			}
415 415
 			// track post_shortcodes
416
-			if ( $critical_page['post'] ) {
417
-				EEH_Activation::_track_critical_page_post_shortcodes( $critical_page );
416
+			if ($critical_page['post']) {
417
+				EEH_Activation::_track_critical_page_post_shortcodes($critical_page);
418 418
 			}
419 419
 			// check that Post ID matches critical page ID in config
420 420
 			if (
421
-				isset( $critical_page['post']->ID )
422
-				&& $critical_page['post']->ID !== $EE_Core_Config->{$critical_page[ 'id' ]}
421
+				isset($critical_page['post']->ID)
422
+				&& $critical_page['post']->ID !== $EE_Core_Config->{$critical_page['id']}
423 423
 			) {
424 424
 				//update Config with post ID
425
-				$EE_Core_Config->{$critical_page[ 'id' ]} = $critical_page['post']->ID;
426
-				if ( ! EE_Config::instance()->update_espresso_config( FALSE, FALSE ) ) {
427
-					$msg = __( 'The Event Espresso critical page configuration settings could not be updated.', 'event_espresso' );
428
-					EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
425
+				$EE_Core_Config->{$critical_page['id']} = $critical_page['post']->ID;
426
+				if ( ! EE_Config::instance()->update_espresso_config(FALSE, FALSE)) {
427
+					$msg = __('The Event Espresso critical page configuration settings could not be updated.', 'event_espresso');
428
+					EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
429 429
 				}
430 430
 			}
431 431
 
432 432
 			$critical_page_problem =
433
-				! isset( $critical_page['post']->post_status )
433
+				! isset($critical_page['post']->post_status)
434 434
 				|| $critical_page['post']->post_status !== 'publish'
435
-				|| strpos( $critical_page['post']->post_content, $critical_page['code'] ) === FALSE
435
+				|| strpos($critical_page['post']->post_content, $critical_page['code']) === FALSE
436 436
 					? TRUE
437 437
 					: $critical_page_problem;
438 438
 
439 439
 		}
440 440
 
441
-		if ( $critical_page_problem ) {
441
+		if ($critical_page_problem) {
442 442
 			$msg = sprintf(
443
-				__('A potential issue has been detected with one or more of your Event Espresso pages. Go to %s to view your Event Espresso pages.', 'event_espresso' ),
444
-				'<a href="' . admin_url('admin.php?page=espresso_general_settings&action=critical_pages') . '">' . __('Event Espresso Critical Pages Settings', 'event_espresso') . '</a>'
443
+				__('A potential issue has been detected with one or more of your Event Espresso pages. Go to %s to view your Event Espresso pages.', 'event_espresso'),
444
+				'<a href="'.admin_url('admin.php?page=espresso_general_settings&action=critical_pages').'">'.__('Event Espresso Critical Pages Settings', 'event_espresso').'</a>'
445 445
 			);
446
-			EE_Error::add_persistent_admin_notice( 'critical_page_problem', $msg );
446
+			EE_Error::add_persistent_admin_notice('critical_page_problem', $msg);
447 447
 		}
448
-		if ( EE_Error::has_notices() ) {
449
-			EE_Error::get_notices( FALSE, TRUE, TRUE );
448
+		if (EE_Error::has_notices()) {
449
+			EE_Error::get_notices(FALSE, TRUE, TRUE);
450 450
 		}
451 451
 	}
452 452
 
@@ -458,13 +458,13 @@  discard block
 block discarded – undo
458 458
 	 * parameter to the shortcode
459 459
 	 * @return WP_Post or NULl
460 460
 	 */
461
-	public static function get_page_by_ee_shortcode($ee_shortcode){
461
+	public static function get_page_by_ee_shortcode($ee_shortcode) {
462 462
 		global $wpdb;
463 463
 		$shortcode_and_opening_bracket = '['.$ee_shortcode;
464 464
 		$post_id = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_content LIKE '%$shortcode_and_opening_bracket%' LIMIT 1");
465
-		if($post_id){
465
+		if ($post_id) {
466 466
 			return get_post($post_id);
467
-		}else{
467
+		} else {
468 468
 			return NULL;
469 469
 		}
470 470
 
@@ -481,32 +481,32 @@  discard block
 block discarded – undo
481 481
 	 * @param array $critical_page
482 482
 	 * @return array
483 483
 	 */
484
-	public static function create_critical_page( $critical_page ) {
484
+	public static function create_critical_page($critical_page) {
485 485
 
486 486
 		$post_args = array(
487 487
 			'post_title' => $critical_page['name'],
488 488
 			'post_status' => 'publish',
489 489
 			'post_type' => 'page',
490 490
 			'comment_status' => 'closed',
491
-			'post_content' => '[' . $critical_page['code'] . ']'
491
+			'post_content' => '['.$critical_page['code'].']'
492 492
 		);
493 493
 
494
-		$post_id = wp_insert_post( $post_args );
495
-		if ( ! $post_id ) {
494
+		$post_id = wp_insert_post($post_args);
495
+		if ( ! $post_id) {
496 496
 			$msg = sprintf(
497
-				__( 'The Event Espresso  critical page entitled "%s" could not be created.', 'event_espresso' ),
497
+				__('The Event Espresso  critical page entitled "%s" could not be created.', 'event_espresso'),
498 498
 				$critical_page['name']
499 499
 			);
500
-			EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
500
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
501 501
 			return $critical_page;
502 502
 		}
503 503
 		// get newly created post's details
504
-		if ( ! $critical_page['post'] = get_post( $post_id )) {
504
+		if ( ! $critical_page['post'] = get_post($post_id)) {
505 505
 			$msg = sprintf(
506
-				__( 'The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso' ),
506
+				__('The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso'),
507 507
 				$critical_page['name']
508 508
 			);
509
-			EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
509
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
510 510
 		}
511 511
 
512 512
 		return $critical_page;
@@ -525,35 +525,35 @@  discard block
 block discarded – undo
525 525
 	 * @param array $critical_page
526 526
 	 * @return void
527 527
 	 */
528
-	private static function _track_critical_page_post_shortcodes( $critical_page = array() ) {
528
+	private static function _track_critical_page_post_shortcodes($critical_page = array()) {
529 529
 		// check the goods
530
-		if ( ! $critical_page['post'] instanceof WP_Post ) {
530
+		if ( ! $critical_page['post'] instanceof WP_Post) {
531 531
 			$msg = sprintf(
532
-				__( 'The Event Espresso critical page shortcode for the page %s can not be tracked because it is not a WP_Post object.', 'event_espresso' ),
532
+				__('The Event Espresso critical page shortcode for the page %s can not be tracked because it is not a WP_Post object.', 'event_espresso'),
533 533
 				$critical_page['name']
534 534
 			);
535
-			EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
535
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
536 536
 			return;
537 537
 		}
538 538
 		$EE_Core_Config = EE_Registry::instance()->CFG->core;
539 539
 		// map shortcode to post
540
-		$EE_Core_Config->post_shortcodes[ $critical_page['post']->post_name ][ $critical_page['code'] ] = $critical_page['post']->ID;
540
+		$EE_Core_Config->post_shortcodes[$critical_page['post']->post_name][$critical_page['code']] = $critical_page['post']->ID;
541 541
 		// and make sure it's NOT added to the WP "Posts Page"
542 542
 		// name of the WP Posts Page
543 543
 		$posts_page = EE_Config::get_page_for_posts();
544
-		if ( isset( $EE_Core_Config->post_shortcodes[ $posts_page ] )) {
545
-			unset( $EE_Core_Config->post_shortcodes[ $posts_page ][ $critical_page['code'] ] );
544
+		if (isset($EE_Core_Config->post_shortcodes[$posts_page])) {
545
+			unset($EE_Core_Config->post_shortcodes[$posts_page][$critical_page['code']]);
546 546
 		}
547
-		if ( $posts_page !== 'posts' && isset( $EE_Core_Config->post_shortcodes['posts'] )) {
548
-			unset( $EE_Core_Config->post_shortcodes['posts'][ $critical_page['code'] ] );
547
+		if ($posts_page !== 'posts' && isset($EE_Core_Config->post_shortcodes['posts'])) {
548
+			unset($EE_Core_Config->post_shortcodes['posts'][$critical_page['code']]);
549 549
 		}
550 550
 		// update post_shortcode CFG
551
-		if ( ! EE_Config::instance()->update_espresso_config( FALSE, FALSE )) {
551
+		if ( ! EE_Config::instance()->update_espresso_config(FALSE, FALSE)) {
552 552
 			$msg = sprintf(
553
-				__( 'The Event Espresso critical page shortcode for the %s page could not be configured properly.', 'event_espresso' ),
553
+				__('The Event Espresso critical page shortcode for the %s page could not be configured properly.', 'event_espresso'),
554 554
 				$critical_page['name']
555 555
 			);
556
-			EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
556
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
557 557
 		}
558 558
 	}
559 559
 
@@ -571,24 +571,24 @@  discard block
 block discarded – undo
571 571
 	public static function get_default_creator_id() {
572 572
 		global $wpdb;
573 573
 
574
-		if ( ! empty( self::$_default_creator_id ) ) {
574
+		if ( ! empty(self::$_default_creator_id)) {
575 575
 			return self::$_default_creator_id;
576 576
 		}/**/
577 577
 
578
-		$role_to_check = apply_filters( 'FHEE__EEH_Activation__get_default_creator_id__role_to_check', 'administrator' );
578
+		$role_to_check = apply_filters('FHEE__EEH_Activation__get_default_creator_id__role_to_check', 'administrator');
579 579
 
580 580
 		//let's allow pre_filtering for early exits by alternative methods for getting id.  We check for truthy result and if so then exit early.
581
-		$pre_filtered_id = apply_filters( 'FHEE__EEH_Activation__get_default_creator_id__pre_filtered_id', false, $role_to_check );
582
-		if ( $pre_filtered_id !== false ) {
581
+		$pre_filtered_id = apply_filters('FHEE__EEH_Activation__get_default_creator_id__pre_filtered_id', false, $role_to_check);
582
+		if ($pre_filtered_id !== false) {
583 583
 			return (int) $pre_filtered_id;
584 584
 		}
585 585
 
586
-		$capabilities_key = EEH_Activation::ensure_table_name_has_prefix( 'capabilities' );
587
-		$query = $wpdb->prepare( "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$capabilities_key' AND meta_value LIKE %s ORDER BY user_id ASC LIMIT 0,1", '%' . $role_to_check . '%' );
588
-		$user_id = $wpdb->get_var( $query );
589
-		 $user_id = apply_filters( 'FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id );
590
-		 if ( $user_id && (int)$user_id ) {
591
-		 	self::$_default_creator_id = (int)$user_id;
586
+		$capabilities_key = EEH_Activation::ensure_table_name_has_prefix('capabilities');
587
+		$query = $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$capabilities_key' AND meta_value LIKE %s ORDER BY user_id ASC LIMIT 0,1", '%'.$role_to_check.'%');
588
+		$user_id = $wpdb->get_var($query);
589
+		 $user_id = apply_filters('FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id);
590
+		 if ($user_id && (int) $user_id) {
591
+		 	self::$_default_creator_id = (int) $user_id;
592 592
 		 	return self::$_default_creator_id;
593 593
 		 } else {
594 594
 		 	return NULL;
@@ -615,29 +615,29 @@  discard block
 block discarded – undo
615 615
 	 * 	@return void
616 616
 	 * @throws EE_Error if there are database errors
617 617
 	 */
618
-	public static function create_table( $table_name, $sql, $engine = 'ENGINE=MyISAM ', $drop_pre_existing_table = false ) {
619
-		if( apply_filters( 'FHEE__EEH_Activation__create_table__short_circuit', FALSE, $table_name, $sql ) ){
618
+	public static function create_table($table_name, $sql, $engine = 'ENGINE=MyISAM ', $drop_pre_existing_table = false) {
619
+		if (apply_filters('FHEE__EEH_Activation__create_table__short_circuit', FALSE, $table_name, $sql)) {
620 620
 			return;
621 621
 		}
622
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
623
-		if ( ! function_exists( 'dbDelta' )) {
624
-			require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
622
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
623
+		if ( ! function_exists('dbDelta')) {
624
+			require_once(ABSPATH.'wp-admin/includes/upgrade.php');
625 625
 		}
626 626
 		/** @var WPDB $wpdb */
627 627
 		global $wpdb;
628
-		$wp_table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name );
628
+		$wp_table_name = EEH_Activation::ensure_table_name_has_prefix($table_name);
629 629
 		// do we need to first delete an existing version of this table ?
630
-		if ( $drop_pre_existing_table && EEH_Activation::table_exists( $wp_table_name ) ){
630
+		if ($drop_pre_existing_table && EEH_Activation::table_exists($wp_table_name)) {
631 631
 			// ok, delete the table... but ONLY if it's empty
632
-			$deleted_safely = EEH_Activation::delete_db_table_if_empty( $wp_table_name );
632
+			$deleted_safely = EEH_Activation::delete_db_table_if_empty($wp_table_name);
633 633
 			// table is NOT empty, are you SURE you want to delete this table ???
634
-			if ( ! $deleted_safely && defined( 'EE_DROP_BAD_TABLES' ) && EE_DROP_BAD_TABLES ){
635
-				EEH_Activation::delete_unused_db_table( $wp_table_name );
636
-			} else if ( ! $deleted_safely ) {
634
+			if ( ! $deleted_safely && defined('EE_DROP_BAD_TABLES') && EE_DROP_BAD_TABLES) {
635
+				EEH_Activation::delete_unused_db_table($wp_table_name);
636
+			} else if ( ! $deleted_safely) {
637 637
 				// so we should be more cautious rather than just dropping tables so easily
638 638
 				EE_Error::add_persistent_admin_notice(
639
-						'bad_table_' . $wp_table_name . '_detected',
640
-						sprintf( __( 'Database table %1$s exists when it shouldn\'t, and may contain erroneous data. If you have previously restored your database from a backup that didn\'t remove the old tables, then we recommend adding %2$s to your %3$s file then restore to that backup again. This will clear out the invalid data from %1$s. Afterwards you should undo that change from your %3$s file. %4$sIf you cannot edit %3$s, you should remove the data from %1$s manually then restore to the backup again.', 'event_espresso' ),
639
+						'bad_table_'.$wp_table_name.'_detected',
640
+						sprintf(__('Database table %1$s exists when it shouldn\'t, and may contain erroneous data. If you have previously restored your database from a backup that didn\'t remove the old tables, then we recommend adding %2$s to your %3$s file then restore to that backup again. This will clear out the invalid data from %1$s. Afterwards you should undo that change from your %3$s file. %4$sIf you cannot edit %3$s, you should remove the data from %1$s manually then restore to the backup again.', 'event_espresso'),
641 641
 								$wp_table_name,
642 642
 								"<pre>define( 'EE_DROP_BAD_TABLES', TRUE );</pre>",
643 643
 								'<b>wp-config.php</b>',
@@ -646,25 +646,25 @@  discard block
 block discarded – undo
646 646
 			}
647 647
 		}
648 648
 		// does $sql contain valid column information? ( LPT: https://regex101.com/ is great for working out regex patterns )
649
-		if ( preg_match( '((((.*?))(,\s))+)', $sql, $valid_column_data ) ) {
649
+		if (preg_match('((((.*?))(,\s))+)', $sql, $valid_column_data)) {
650 650
 			$SQL = "CREATE TABLE $wp_table_name ( $sql ) $engine DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;";
651 651
 			//get $wpdb to echo errors, but buffer them. This way at least WE know an error
652 652
 			//happened. And then we can choose to tell the end user
653
-			$old_show_errors_policy = $wpdb->show_errors( TRUE );
654
-			$old_error_suppression_policy = $wpdb->suppress_errors( FALSE );
653
+			$old_show_errors_policy = $wpdb->show_errors(TRUE);
654
+			$old_error_suppression_policy = $wpdb->suppress_errors(FALSE);
655 655
 			ob_start();
656
-			dbDelta( $SQL );
656
+			dbDelta($SQL);
657 657
 			$output = ob_get_contents();
658 658
 			ob_end_clean();
659
-			$wpdb->show_errors( $old_show_errors_policy );
660
-			$wpdb->suppress_errors( $old_error_suppression_policy );
661
-			if( ! empty( $output ) ){
662
-				throw new EE_Error( $output	);
659
+			$wpdb->show_errors($old_show_errors_policy);
660
+			$wpdb->suppress_errors($old_error_suppression_policy);
661
+			if ( ! empty($output)) {
662
+				throw new EE_Error($output);
663 663
 			}
664 664
 		} else {
665 665
 			throw new EE_Error(
666 666
 				sprintf(
667
-					__( 'The following table creation SQL does not contain valid information about the table columns: %1$s %2$s', 'event_espresso' ),
667
+					__('The following table creation SQL does not contain valid information about the table columns: %1$s %2$s', 'event_espresso'),
668 668
 					'<br />',
669 669
 					$sql
670 670
 				)
@@ -686,15 +686,15 @@  discard block
 block discarded – undo
686 686
 	 * @param string $column_info if your SQL were 'ALTER TABLE table_name ADD price VARCHAR(10)', this would be 'VARCHAR(10)'
687 687
 	 * @return bool|int
688 688
 	 */
689
-	public static function add_column_if_it_doesnt_exist($table_name,$column_name,$column_info='INT UNSIGNED NOT NULL'){
690
-		if( apply_filters( 'FHEE__EEH_Activation__add_column_if_it_doesnt_exist__short_circuit', FALSE ) ){
689
+	public static function add_column_if_it_doesnt_exist($table_name, $column_name, $column_info = 'INT UNSIGNED NOT NULL') {
690
+		if (apply_filters('FHEE__EEH_Activation__add_column_if_it_doesnt_exist__short_circuit', FALSE)) {
691 691
 			return FALSE;
692 692
 		}
693 693
 		global $wpdb;
694
-		$full_table_name= EEH_Activation::ensure_table_name_has_prefix( $table_name );
694
+		$full_table_name = EEH_Activation::ensure_table_name_has_prefix($table_name);
695 695
 		$fields = self::get_fields_on_table($table_name);
696
-		if (!in_array($column_name, $fields)){
697
-			$alter_query="ALTER TABLE $full_table_name ADD $column_name $column_info";
696
+		if ( ! in_array($column_name, $fields)) {
697
+			$alter_query = "ALTER TABLE $full_table_name ADD $column_name $column_info";
698 698
 			//echo "alter query:$alter_query";
699 699
 			return $wpdb->query($alter_query);
700 700
 		}
@@ -713,14 +713,14 @@  discard block
 block discarded – undo
713 713
 	 * 	@param string $table_name, without prefixed $wpdb->prefix
714 714
 	 * 	@return array of database column names
715 715
 	 */
716
-	public static function get_fields_on_table( $table_name = NULL ) {
716
+	public static function get_fields_on_table($table_name = NULL) {
717 717
 		global $wpdb;
718
-		$table_name= EEH_Activation::ensure_table_name_has_prefix( $table_name );
719
-		if ( ! empty( $table_name )) {
718
+		$table_name = EEH_Activation::ensure_table_name_has_prefix($table_name);
719
+		if ( ! empty($table_name)) {
720 720
 			$columns = $wpdb->get_results("SHOW COLUMNS FROM $table_name ");
721 721
 			if ($columns !== FALSE) {
722 722
 				$field_array = array();
723
-				foreach($columns as $column ){
723
+				foreach ($columns as $column) {
724 724
 					$field_array[] = $column->Field;
725 725
 				}
726 726
 				return $field_array;
@@ -739,12 +739,12 @@  discard block
 block discarded – undo
739 739
 	 * @param string $table_name
740 740
 	 * @return bool
741 741
 	 */
742
-	public static function db_table_is_empty( $table_name ) {
742
+	public static function db_table_is_empty($table_name) {
743 743
 		global $wpdb;
744
-		$table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name );
745
-		if ( EEH_Activation::table_exists( $table_name ) ) {
746
-			$count = $wpdb->get_var( "SELECT COUNT(*) FROM $table_name" );
747
-			return absint( $count ) === 0 ? true : false;
744
+		$table_name = EEH_Activation::ensure_table_name_has_prefix($table_name);
745
+		if (EEH_Activation::table_exists($table_name)) {
746
+			$count = $wpdb->get_var("SELECT COUNT(*) FROM $table_name");
747
+			return absint($count) === 0 ? true : false;
748 748
 		}
749 749
 		return false;
750 750
 	}
@@ -759,9 +759,9 @@  discard block
 block discarded – undo
759 759
 	 * @param string $table_name
760 760
 	 * @return bool | int
761 761
 	 */
762
-	public static function delete_db_table_if_empty( $table_name ) {
763
-		if ( EEH_Activation::db_table_is_empty( $table_name ) ) {
764
-			return EEH_Activation::delete_unused_db_table( $table_name );
762
+	public static function delete_db_table_if_empty($table_name) {
763
+		if (EEH_Activation::db_table_is_empty($table_name)) {
764
+			return EEH_Activation::delete_unused_db_table($table_name);
765 765
 		}
766 766
 		return false;
767 767
 	}
@@ -776,11 +776,11 @@  discard block
 block discarded – undo
776 776
 	 * @param string $table_name
777 777
 	 * @return bool | int
778 778
 	 */
779
-	public static function delete_unused_db_table( $table_name ) {
779
+	public static function delete_unused_db_table($table_name) {
780 780
 		global $wpdb;
781
-		if ( EEH_Activation::table_exists( $table_name ) ) {
782
-			$table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name );
783
-			return $wpdb->query( "DROP TABLE IF EXISTS $table_name" );
781
+		if (EEH_Activation::table_exists($table_name)) {
782
+			$table_name = EEH_Activation::ensure_table_name_has_prefix($table_name);
783
+			return $wpdb->query("DROP TABLE IF EXISTS $table_name");
784 784
 		}
785 785
 		return false;
786 786
 	}
@@ -796,18 +796,18 @@  discard block
 block discarded – undo
796 796
 	 * @param string $index_name
797 797
 	 * @return bool | int
798 798
 	 */
799
-	public static function drop_index( $table_name, $index_name ) {
800
-		if( apply_filters( 'FHEE__EEH_Activation__drop_index__short_circuit', FALSE ) ){
799
+	public static function drop_index($table_name, $index_name) {
800
+		if (apply_filters('FHEE__EEH_Activation__drop_index__short_circuit', FALSE)) {
801 801
 			return FALSE;
802 802
 		}
803 803
 		global $wpdb;
804
-		$table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name );
804
+		$table_name = EEH_Activation::ensure_table_name_has_prefix($table_name);
805 805
 		$index_exists_query = "SHOW INDEX FROM $table_name WHERE Key_name = '$index_name'";
806 806
 		if (
807
-			$wpdb->get_var( "SHOW TABLES LIKE '$table_name'" ) === $table_name
808
-			&& $wpdb->get_var( $index_exists_query ) === $table_name //using get_var with the $index_exists_query returns the table's name
807
+			$wpdb->get_var("SHOW TABLES LIKE '$table_name'") === $table_name
808
+			&& $wpdb->get_var($index_exists_query) === $table_name //using get_var with the $index_exists_query returns the table's name
809 809
 		) {
810
-			return $wpdb->query( "ALTER TABLE $table_name DROP INDEX $index_name" );
810
+			return $wpdb->query("ALTER TABLE $table_name DROP INDEX $index_name");
811 811
 		}
812 812
 		return TRUE;
813 813
 	}
@@ -823,27 +823,27 @@  discard block
 block discarded – undo
823 823
 	 * @return boolean success (whether database is setup properly or not)
824 824
 	 */
825 825
 	public static function create_database_tables() {
826
-		EE_Registry::instance()->load_core( 'Data_Migration_Manager' );
826
+		EE_Registry::instance()->load_core('Data_Migration_Manager');
827 827
 		//find the migration script that sets the database to be compatible with the code
828 828
 		$dms_name = EE_Data_Migration_Manager::instance()->get_most_up_to_date_dms();
829
-		if( $dms_name ){
830
-			$current_data_migration_script = EE_Registry::instance()->load_dms( $dms_name );
831
-			$current_data_migration_script->set_migrating( false );
829
+		if ($dms_name) {
830
+			$current_data_migration_script = EE_Registry::instance()->load_dms($dms_name);
831
+			$current_data_migration_script->set_migrating(false);
832 832
 			$current_data_migration_script->schema_changes_before_migration();
833 833
 			$current_data_migration_script->schema_changes_after_migration();
834
-			if( $current_data_migration_script->get_errors() ){
835
-				if( WP_DEBUG ){
836
-					foreach( $current_data_migration_script->get_errors() as $error ){
837
-						EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__ );
834
+			if ($current_data_migration_script->get_errors()) {
835
+				if (WP_DEBUG) {
836
+					foreach ($current_data_migration_script->get_errors() as $error) {
837
+						EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__);
838 838
 					}
839
-				}else{
840
-					EE_Error::add_error( __( 'There were errors creating the Event Espresso database tables and Event Espresso has been deactivated. To view the errors, please enable WP_DEBUG in your wp-config.php file.', 'event_espresso' ) );
839
+				} else {
840
+					EE_Error::add_error(__('There were errors creating the Event Espresso database tables and Event Espresso has been deactivated. To view the errors, please enable WP_DEBUG in your wp-config.php file.', 'event_espresso'));
841 841
 				}
842 842
 				return false;
843 843
 			}
844 844
 			EE_Data_Migration_Manager::instance()->update_current_database_state_to();
845
-		}else{
846
-			EE_Error::add_error( __( 'Could not determine most up-to-date data migration script from which to pull database schema structure. So database is probably not setup properly', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__);
845
+		} else {
846
+			EE_Error::add_error(__('Could not determine most up-to-date data migration script from which to pull database schema structure. So database is probably not setup properly', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
847 847
 			return false;
848 848
 		}
849 849
 		return true;
@@ -863,27 +863,27 @@  discard block
 block discarded – undo
863 863
 	public static function initialize_system_questions() {
864 864
 		// QUESTION GROUPS
865 865
 		global $wpdb;
866
-		$table_name = EEH_Activation::ensure_table_name_has_prefix( 'esp_question_group' );
866
+		$table_name = EEH_Activation::ensure_table_name_has_prefix('esp_question_group');
867 867
 		$SQL = "SELECT QSG_system FROM $table_name WHERE QSG_system != 0";
868 868
 		// what we have
869
-		$question_groups = $wpdb->get_col( $SQL );
869
+		$question_groups = $wpdb->get_col($SQL);
870 870
 		// check the response
871
-		$question_groups = is_array( $question_groups ) ? $question_groups : array();
871
+		$question_groups = is_array($question_groups) ? $question_groups : array();
872 872
 		// what we should have
873
-		$QSG_systems = array( 1, 2 );
873
+		$QSG_systems = array(1, 2);
874 874
 		// loop thru what we should have and compare to what we have
875
-		foreach ( $QSG_systems as $QSG_system ) {
875
+		foreach ($QSG_systems as $QSG_system) {
876 876
 			// reset values array
877 877
 			$QSG_values = array();
878 878
 			// if we don't have what we should have (but use $QST_system as as string because that's what we got from the db)
879
-			if ( ! in_array( "$QSG_system", $question_groups )) {
879
+			if ( ! in_array("$QSG_system", $question_groups)) {
880 880
 				// add it
881
-				switch ( $QSG_system ) {
881
+				switch ($QSG_system) {
882 882
 
883 883
 					case 1:
884 884
 							$QSG_values = array(
885
-									'QSG_name' => __( 'Personal Information', 'event_espresso' ),
886
-									'QSG_identifier' => 'personal-information-' . time(),
885
+									'QSG_name' => __('Personal Information', 'event_espresso'),
886
+									'QSG_identifier' => 'personal-information-'.time(),
887 887
 									'QSG_desc' => '',
888 888
 									'QSG_order' => 1,
889 889
 									'QSG_show_group_name' => 1,
@@ -895,8 +895,8 @@  discard block
 block discarded – undo
895 895
 
896 896
 					case 2:
897 897
 							$QSG_values = array(
898
-									'QSG_name' => __( 'Address Information','event_espresso' ),
899
-									'QSG_identifier' => 'address-information-' . time(),
898
+									'QSG_name' => __('Address Information', 'event_espresso'),
899
+									'QSG_identifier' => 'address-information-'.time(),
900 900
 									'QSG_desc' => '',
901 901
 									'QSG_order' => 2,
902 902
 									'QSG_show_group_name' => 1,
@@ -908,14 +908,14 @@  discard block
 block discarded – undo
908 908
 
909 909
 				}
910 910
 				// make sure we have some values before inserting them
911
-				if ( ! empty( $QSG_values )) {
911
+				if ( ! empty($QSG_values)) {
912 912
 					// insert system question
913 913
 					$wpdb->insert(
914 914
 						$table_name,
915 915
 						$QSG_values,
916
-						array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d' )
916
+						array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d')
917 917
 					);
918
-					$QSG_IDs[ $QSG_system ] = $wpdb->insert_id;
918
+					$QSG_IDs[$QSG_system] = $wpdb->insert_id;
919 919
 				}
920 920
 			}
921 921
 		}
@@ -924,10 +924,10 @@  discard block
 block discarded – undo
924 924
 
925 925
 		// QUESTIONS
926 926
 		global $wpdb;
927
-		$table_name = EEH_Activation::ensure_table_name_has_prefix( 'esp_question' );
927
+		$table_name = EEH_Activation::ensure_table_name_has_prefix('esp_question');
928 928
 		$SQL = "SELECT QST_system FROM $table_name WHERE QST_system != ''";
929 929
 		// what we have
930
-		$questions = $wpdb->get_col( $SQL );
930
+		$questions = $wpdb->get_col($SQL);
931 931
 		// what we should have
932 932
 		$QST_systems = array(
933 933
 			'fname',
@@ -944,25 +944,25 @@  discard block
 block discarded – undo
944 944
 		$order_for_group_1 = 1;
945 945
 		$order_for_group_2 = 1;
946 946
 		// loop thru what we should have and compare to what we have
947
-		foreach ( $QST_systems as $QST_system ) {
947
+		foreach ($QST_systems as $QST_system) {
948 948
 			// reset values array
949 949
 			$QST_values = array();
950 950
 			// if we don't have what we should have
951
-			if ( ! in_array( $QST_system, $questions )) {
951
+			if ( ! in_array($QST_system, $questions)) {
952 952
 				// add it
953
-				switch ( $QST_system ) {
953
+				switch ($QST_system) {
954 954
 
955 955
 					case 'fname':
956 956
 							$QST_values = array(
957
-									'QST_display_text' => __( 'First Name', 'event_espresso' ),
958
-									'QST_admin_label' => __( 'First Name - System Question', 'event_espresso' ),
957
+									'QST_display_text' => __('First Name', 'event_espresso'),
958
+									'QST_admin_label' => __('First Name - System Question', 'event_espresso'),
959 959
 									'QST_system' => 'fname',
960 960
 									'QST_type' => 'TEXT',
961 961
 									'QST_required' => 1,
962
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
962
+									'QST_required_text' => __('This field is required', 'event_espresso'),
963 963
 									'QST_order' => 1,
964 964
 									'QST_admin_only' => 0,
965
-									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ),
965
+									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
966 966
 									'QST_wp_user' => self::get_default_creator_id(),
967 967
 									'QST_deleted' => 0
968 968
 								);
@@ -970,15 +970,15 @@  discard block
 block discarded – undo
970 970
 
971 971
 					case 'lname':
972 972
 							$QST_values = array(
973
-									'QST_display_text' => __( 'Last Name', 'event_espresso' ),
974
-									'QST_admin_label' => __( 'Last Name - System Question', 'event_espresso' ),
973
+									'QST_display_text' => __('Last Name', 'event_espresso'),
974
+									'QST_admin_label' => __('Last Name - System Question', 'event_espresso'),
975 975
 									'QST_system' => 'lname',
976 976
 									'QST_type' => 'TEXT',
977 977
 									'QST_required' => 1,
978
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
978
+									'QST_required_text' => __('This field is required', 'event_espresso'),
979 979
 									'QST_order' => 2,
980 980
 									'QST_admin_only' => 0,
981
-									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ),
981
+									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
982 982
 									'QST_wp_user' => self::get_default_creator_id(),
983 983
 									'QST_deleted' => 0
984 984
 								);
@@ -986,15 +986,15 @@  discard block
 block discarded – undo
986 986
 
987 987
 					case 'email':
988 988
 							$QST_values = array(
989
-									'QST_display_text' => __( 'Email Address', 'event_espresso' ),
990
-									'QST_admin_label' => __( 'Email Address - System Question', 'event_espresso' ),
989
+									'QST_display_text' => __('Email Address', 'event_espresso'),
990
+									'QST_admin_label' => __('Email Address - System Question', 'event_espresso'),
991 991
 									'QST_system' => 'email',
992 992
 									'QST_type' => 'TEXT',
993 993
 									'QST_required' => 1,
994
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
994
+									'QST_required_text' => __('This field is required', 'event_espresso'),
995 995
 									'QST_order' => 3,
996 996
 									'QST_admin_only' => 0,
997
-									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ),
997
+									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
998 998
 									'QST_wp_user' => self::get_default_creator_id(),
999 999
 									'QST_deleted' => 0
1000 1000
 								);
@@ -1002,15 +1002,15 @@  discard block
 block discarded – undo
1002 1002
 
1003 1003
 					case 'address':
1004 1004
 							$QST_values = array(
1005
-									'QST_display_text' => __( 'Address', 'event_espresso' ),
1006
-									'QST_admin_label' => __( 'Address - System Question', 'event_espresso' ),
1005
+									'QST_display_text' => __('Address', 'event_espresso'),
1006
+									'QST_admin_label' => __('Address - System Question', 'event_espresso'),
1007 1007
 									'QST_system' => 'address',
1008 1008
 									'QST_type' => 'TEXT',
1009 1009
 									'QST_required' => 0,
1010
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
1010
+									'QST_required_text' => __('This field is required', 'event_espresso'),
1011 1011
 									'QST_order' => 4,
1012 1012
 									'QST_admin_only' => 0,
1013
-									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ),
1013
+									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1014 1014
 									'QST_wp_user' => self::get_default_creator_id(),
1015 1015
 									'QST_deleted' => 0
1016 1016
 								);
@@ -1018,15 +1018,15 @@  discard block
 block discarded – undo
1018 1018
 
1019 1019
 					case 'address2':
1020 1020
 							$QST_values = array(
1021
-									'QST_display_text' => __( 'Address2', 'event_espresso' ),
1022
-									'QST_admin_label' => __( 'Address2 - System Question', 'event_espresso' ),
1021
+									'QST_display_text' => __('Address2', 'event_espresso'),
1022
+									'QST_admin_label' => __('Address2 - System Question', 'event_espresso'),
1023 1023
 									'QST_system' => 'address2',
1024 1024
 									'QST_type' => 'TEXT',
1025 1025
 									'QST_required' => 0,
1026
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
1026
+									'QST_required_text' => __('This field is required', 'event_espresso'),
1027 1027
 									'QST_order' => 5,
1028 1028
 									'QST_admin_only' => 0,
1029
-									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ),
1029
+									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1030 1030
 									'QST_wp_user' => self::get_default_creator_id(),
1031 1031
 									'QST_deleted' => 0
1032 1032
 								);
@@ -1034,15 +1034,15 @@  discard block
 block discarded – undo
1034 1034
 
1035 1035
 					case 'city':
1036 1036
 							$QST_values = array(
1037
-									'QST_display_text' => __( 'City', 'event_espresso' ),
1038
-									'QST_admin_label' => __( 'City - System Question', 'event_espresso' ),
1037
+									'QST_display_text' => __('City', 'event_espresso'),
1038
+									'QST_admin_label' => __('City - System Question', 'event_espresso'),
1039 1039
 									'QST_system' => 'city',
1040 1040
 									'QST_type' => 'TEXT',
1041 1041
 									'QST_required' => 0,
1042
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
1042
+									'QST_required_text' => __('This field is required', 'event_espresso'),
1043 1043
 									'QST_order' => 6,
1044 1044
 									'QST_admin_only' => 0,
1045
-									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ),
1045
+									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1046 1046
 									'QST_wp_user' => self::get_default_creator_id(),
1047 1047
 									'QST_deleted' => 0
1048 1048
 								);
@@ -1050,12 +1050,12 @@  discard block
 block discarded – undo
1050 1050
 
1051 1051
 					case 'state':
1052 1052
 							$QST_values = array(
1053
-									'QST_display_text' => __( 'State/Province', 'event_espresso' ),
1054
-									'QST_admin_label' => __( 'State/Province - System Question', 'event_espresso' ),
1053
+									'QST_display_text' => __('State/Province', 'event_espresso'),
1054
+									'QST_admin_label' => __('State/Province - System Question', 'event_espresso'),
1055 1055
 									'QST_system' => 'state',
1056 1056
 									'QST_type' => 'STATE',
1057 1057
 									'QST_required' => 0,
1058
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
1058
+									'QST_required_text' => __('This field is required', 'event_espresso'),
1059 1059
 									'QST_order' => 7,
1060 1060
 									'QST_admin_only' => 0,
1061 1061
 									'QST_wp_user' => self::get_default_creator_id(),
@@ -1065,12 +1065,12 @@  discard block
 block discarded – undo
1065 1065
 
1066 1066
 					case 'country' :
1067 1067
 							$QST_values = array(
1068
-									'QST_display_text' => __( 'Country', 'event_espresso' ),
1069
-									'QST_admin_label' => __( 'Country - System Question', 'event_espresso' ),
1068
+									'QST_display_text' => __('Country', 'event_espresso'),
1069
+									'QST_admin_label' => __('Country - System Question', 'event_espresso'),
1070 1070
 									'QST_system' => 'country',
1071 1071
 									'QST_type' => 'COUNTRY',
1072 1072
 									'QST_required' => 0,
1073
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
1073
+									'QST_required_text' => __('This field is required', 'event_espresso'),
1074 1074
 									'QST_order' => 8,
1075 1075
 									'QST_admin_only' => 0,
1076 1076
 									'QST_wp_user' => self::get_default_creator_id(),
@@ -1080,15 +1080,15 @@  discard block
 block discarded – undo
1080 1080
 
1081 1081
 					case 'zip':
1082 1082
 							$QST_values = array(
1083
-									'QST_display_text' => __( 'Zip/Postal Code', 'event_espresso' ),
1084
-									'QST_admin_label' => __( 'Zip/Postal Code - System Question', 'event_espresso' ),
1083
+									'QST_display_text' => __('Zip/Postal Code', 'event_espresso'),
1084
+									'QST_admin_label' => __('Zip/Postal Code - System Question', 'event_espresso'),
1085 1085
 									'QST_system' => 'zip',
1086 1086
 									'QST_type' => 'TEXT',
1087 1087
 									'QST_required' => 0,
1088
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
1088
+									'QST_required_text' => __('This field is required', 'event_espresso'),
1089 1089
 									'QST_order' => 9,
1090 1090
 									'QST_admin_only' => 0,
1091
-									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ),
1091
+									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1092 1092
 									'QST_wp_user' => self::get_default_creator_id(),
1093 1093
 									'QST_deleted' => 0
1094 1094
 								);
@@ -1096,49 +1096,49 @@  discard block
 block discarded – undo
1096 1096
 
1097 1097
 					case 'phone':
1098 1098
 							$QST_values = array(
1099
-									'QST_display_text' => __( 'Phone Number', 'event_espresso' ),
1100
-									'QST_admin_label' => __( 'Phone Number - System Question', 'event_espresso' ),
1099
+									'QST_display_text' => __('Phone Number', 'event_espresso'),
1100
+									'QST_admin_label' => __('Phone Number - System Question', 'event_espresso'),
1101 1101
 									'QST_system' => 'phone',
1102 1102
 									'QST_type' => 'TEXT',
1103 1103
 									'QST_required' => 0,
1104
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
1104
+									'QST_required_text' => __('This field is required', 'event_espresso'),
1105 1105
 									'QST_order' => 10,
1106 1106
 									'QST_admin_only' => 0,
1107
-									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ),
1107
+									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1108 1108
 									'QST_wp_user' => self::get_default_creator_id(),
1109 1109
 									'QST_deleted' => 0
1110 1110
 								);
1111 1111
 						break;
1112 1112
 
1113 1113
 				}
1114
-				if ( ! empty( $QST_values )) {
1114
+				if ( ! empty($QST_values)) {
1115 1115
 					// insert system question
1116 1116
 					$wpdb->insert(
1117 1117
 						$table_name,
1118 1118
 						$QST_values,
1119
-						array( '%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%d', '%d' )
1119
+						array('%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%d', '%d')
1120 1120
 					);
1121 1121
 					$QST_ID = $wpdb->insert_id;
1122 1122
 
1123 1123
 					// QUESTION GROUP QUESTIONS
1124
-					if(  in_array( $QST_system, array( 'fname', 'lname', 'email' ) ) ) {
1124
+					if (in_array($QST_system, array('fname', 'lname', 'email'))) {
1125 1125
 						$system_question_we_want = EEM_Question_Group::system_personal;
1126 1126
 					} else {
1127 1127
 						$system_question_we_want = EEM_Question_Group::system_address;
1128 1128
 					}
1129
-					if( isset( $QSG_IDs[ $system_question_we_want ] ) ) {
1130
-						$QSG_ID = $QSG_IDs[ $system_question_we_want ];
1129
+					if (isset($QSG_IDs[$system_question_we_want])) {
1130
+						$QSG_ID = $QSG_IDs[$system_question_we_want];
1131 1131
 					} else {
1132
-						$id_col = EEM_Question_Group::instance()->get_col( array( array( 'QSG_system' => $system_question_we_want ) ) );
1133
-						if( is_array( $id_col ) ) {
1134
-							$QSG_ID = reset( $id_col );
1132
+						$id_col = EEM_Question_Group::instance()->get_col(array(array('QSG_system' => $system_question_we_want)));
1133
+						if (is_array($id_col)) {
1134
+							$QSG_ID = reset($id_col);
1135 1135
 						} else {
1136 1136
 							//ok so we didn't find it in the db either?? that's weird because we should have inserted it at the start of this method
1137 1137
                                                         EE_Log::instance()->log(
1138 1138
                                                                 __FILE__,
1139 1139
                                                                 __FUNCTION__,
1140 1140
                                                                 sprintf(
1141
-                                                                        __( 'Could not associate question %1$s to a question group because no system question group existed', 'event_espresso'),
1141
+                                                                        __('Could not associate question %1$s to a question group because no system question group existed', 'event_espresso'),
1142 1142
                                                                         $QST_ID ),
1143 1143
                                                                 'error' );
1144 1144
                                                         continue;
@@ -1147,12 +1147,12 @@  discard block
 block discarded – undo
1147 1147
 
1148 1148
 					// add system questions to groups
1149 1149
 					$wpdb->insert(
1150
-						EEH_Activation::ensure_table_name_has_prefix( 'esp_question_group_question' ),
1151
-						array( 'QSG_ID'    => $QSG_ID,
1150
+						EEH_Activation::ensure_table_name_has_prefix('esp_question_group_question'),
1151
+						array('QSG_ID'    => $QSG_ID,
1152 1152
 						       'QST_ID'    => $QST_ID,
1153
-						       'QGQ_order' => ( $QSG_ID === 1 ) ? $order_for_group_1++ : $order_for_group_2++
1153
+						       'QGQ_order' => ($QSG_ID === 1) ? $order_for_group_1++ : $order_for_group_2++
1154 1154
 						),
1155
-						array( '%d', '%d', '%d' )
1155
+						array('%d', '%d', '%d')
1156 1156
 					);
1157 1157
 				}
1158 1158
 			}
@@ -1168,11 +1168,11 @@  discard block
 block discarded – undo
1168 1168
 	 *
1169 1169
 	 * @throws \EE_Error
1170 1170
 	 */
1171
-	public static function insert_default_payment_methods(){
1172
-		if( ! EEM_Payment_Method::instance()->count_active( EEM_Payment_Method::scope_cart ) ){
1173
-			EE_Registry::instance()->load_lib( 'Payment_Method_Manager' );
1174
-			EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type( 'Invoice' );
1175
-		}else{
1171
+	public static function insert_default_payment_methods() {
1172
+		if ( ! EEM_Payment_Method::instance()->count_active(EEM_Payment_Method::scope_cart)) {
1173
+			EE_Registry::instance()->load_lib('Payment_Method_Manager');
1174
+			EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type('Invoice');
1175
+		} else {
1176 1176
 			EEM_Payment_Method::instance()->verify_button_urls();
1177 1177
 		}
1178 1178
 	}
@@ -1188,7 +1188,7 @@  discard block
 block discarded – undo
1188 1188
 
1189 1189
 		global $wpdb;
1190 1190
 
1191
-		if ( EEH_Activation::table_exists( EEM_Status::instance()->table() ) ) {
1191
+		if (EEH_Activation::table_exists(EEM_Status::instance()->table())) {
1192 1192
 
1193 1193
 			$table_name = EEM_Status::instance()->table();
1194 1194
 
@@ -1258,33 +1258,33 @@  discard block
 block discarded – undo
1258 1258
 		$folders = array(
1259 1259
 				EVENT_ESPRESSO_TEMPLATE_DIR,
1260 1260
 				EVENT_ESPRESSO_GATEWAY_DIR,
1261
-				EVENT_ESPRESSO_UPLOAD_DIR . 'logs/',
1262
-				EVENT_ESPRESSO_UPLOAD_DIR . 'css/',
1263
-				EVENT_ESPRESSO_UPLOAD_DIR . 'tickets/'
1261
+				EVENT_ESPRESSO_UPLOAD_DIR.'logs/',
1262
+				EVENT_ESPRESSO_UPLOAD_DIR.'css/',
1263
+				EVENT_ESPRESSO_UPLOAD_DIR.'tickets/'
1264 1264
 		);
1265
-		foreach ( $folders as $folder ) {
1265
+		foreach ($folders as $folder) {
1266 1266
 			try {
1267
-				EEH_File::ensure_folder_exists_and_is_writable( $folder );
1268
-				@ chmod( $folder, 0755 );
1269
-			} catch( EE_Error $e ){
1267
+				EEH_File::ensure_folder_exists_and_is_writable($folder);
1268
+				@ chmod($folder, 0755);
1269
+			} catch (EE_Error $e) {
1270 1270
 				EE_Error::add_error(
1271 1271
 					sprintf(
1272
-						__(  'Could not create the folder at "%1$s" because: %2$s', 'event_espresso' ),
1272
+						__('Could not create the folder at "%1$s" because: %2$s', 'event_espresso'),
1273 1273
 						$folder,
1274
-						'<br />' . $e->getMessage()
1274
+						'<br />'.$e->getMessage()
1275 1275
 					),
1276 1276
 					__FILE__, __FUNCTION__, __LINE__
1277 1277
 				);
1278 1278
 				//indicate we'll need to fix this later
1279
-				update_option( EEH_Activation::upload_directories_incomplete_option_name, true );
1279
+				update_option(EEH_Activation::upload_directories_incomplete_option_name, true);
1280 1280
 				return FALSE;
1281 1281
 			}
1282 1282
 		}
1283 1283
 		//just add the .htaccess file to the logs directory to begin with. Even if logging
1284 1284
 		//is disabled, there might be activation errors recorded in there
1285
-		EEH_File::add_htaccess_deny_from_all( EVENT_ESPRESSO_UPLOAD_DIR . 'logs/' );
1285
+		EEH_File::add_htaccess_deny_from_all(EVENT_ESPRESSO_UPLOAD_DIR.'logs/');
1286 1286
 		//remember EE's folders are all good
1287
-		delete_option( EEH_Activation::upload_directories_incomplete_option_name );
1287
+		delete_option(EEH_Activation::upload_directories_incomplete_option_name);
1288 1288
 		return TRUE;
1289 1289
 	}
1290 1290
 
@@ -1297,7 +1297,7 @@  discard block
 block discarded – undo
1297 1297
 	 * @return boolean
1298 1298
 	 */
1299 1299
 	public static function upload_directories_incomplete() {
1300
-		return get_option( EEH_Activation::upload_directories_incomplete_option_name, false );
1300
+		return get_option(EEH_Activation::upload_directories_incomplete_option_name, false);
1301 1301
 	}
1302 1302
 
1303 1303
 
@@ -1321,10 +1321,10 @@  discard block
 block discarded – undo
1321 1321
 		$installed = EEH_MSG_Template::get_installed_message_objects();
1322 1322
 
1323 1323
 		//let's setup the $installed messengers in an array AND the messengers that are set to be activated on install.
1324
-		foreach ( $installed['messengers'] as $msgr ) {
1325
-			if ( $msgr instanceof EE_messenger ) {
1324
+		foreach ($installed['messengers'] as $msgr) {
1325
+			if ($msgr instanceof EE_messenger) {
1326 1326
 				$installed_messengers[$msgr->name] = $msgr;
1327
-				if ( $msgr->activate_on_install ) {
1327
+				if ($msgr->activate_on_install) {
1328 1328
 					$default_messengers[] = $msgr->name;
1329 1329
 				}
1330 1330
 			}
@@ -1334,38 +1334,38 @@  discard block
 block discarded – undo
1334 1334
 		$active_messengers = EEH_MSG_Template::get_active_messengers_in_db();
1335 1335
 
1336 1336
 		//things that have already been activated before
1337
-		$has_activated = get_option( 'ee_has_activated_messenger' );
1337
+		$has_activated = get_option('ee_has_activated_messenger');
1338 1338
 
1339 1339
 		//do an initial loop to determine if we need to continue
1340 1340
 		$def_ms = array();
1341
-		foreach ( $default_messengers as $msgr ) {
1342
-			if ( isset($active_messengers[$msgr] ) || isset( $has_activated[$msgr] ) ) {
1341
+		foreach ($default_messengers as $msgr) {
1342
+			if (isset($active_messengers[$msgr]) || isset($has_activated[$msgr])) {
1343 1343
 				continue;
1344 1344
 			}
1345 1345
 			$def_ms[] = $msgr;
1346 1346
 		}
1347 1347
 
1348 1348
 		//setup the $installed_mts in an array
1349
-		foreach ( $installed['message_types'] as $imt ) {
1350
-			if ( $imt instanceof EE_message_type ) {
1349
+		foreach ($installed['message_types'] as $imt) {
1350
+			if ($imt instanceof EE_message_type) {
1351 1351
 				$installed_mts[$imt->name] = $imt;
1352 1352
 			}
1353 1353
 		}
1354 1354
 
1355 1355
 		//loop through default array for default messengers (if present)
1356
-		if ( ! empty( $def_ms ) ) {
1357
-			foreach ( $def_ms as $messenger ) {
1356
+		if ( ! empty($def_ms)) {
1357
+			foreach ($def_ms as $messenger) {
1358 1358
 				//all is good so let's setup the default stuff. We need to use the given messenger object (if exists) to get the default message type for the messenger.
1359
-				if ( ! isset( $installed_messengers[$messenger] )) {
1359
+				if ( ! isset($installed_messengers[$messenger])) {
1360 1360
 					continue;
1361 1361
 				}
1362 1362
 				/** @var EE_messenger[] $installed_messengers  */
1363 1363
 				$default_mts = $installed_messengers[$messenger]->get_default_message_types();
1364 1364
 				$active_messengers[$messenger]['obj'] = $installed_messengers[$messenger];
1365
-				foreach ( $default_mts as $index => $mt ) {
1365
+				foreach ($default_mts as $index => $mt) {
1366 1366
 					//is there an installed_mt matching the default string?  If not then nothing to do here.
1367
-					if ( ! isset( $installed_mts[$mt] ) ) {
1368
-						unset( $default_mts[$index] );
1367
+					if ( ! isset($installed_mts[$mt])) {
1368
+						unset($default_mts[$index]);
1369 1369
 						continue;
1370 1370
 					}
1371 1371
 
@@ -1374,41 +1374,41 @@  discard block
 block discarded – undo
1374 1374
 					/** @var EE_message_type[] $installed_mts */
1375 1375
 					$settings_fields = $installed_mts[$mt]->get_admin_settings_fields();
1376 1376
 					$settings = array();
1377
-					if ( is_array( $settings_fields ) ) {
1378
-						foreach ( $settings_fields as $field => $values ) {
1379
-							if ( isset( $values['default'] ) ) {
1377
+					if (is_array($settings_fields)) {
1378
+						foreach ($settings_fields as $field => $values) {
1379
+							if (isset($values['default'])) {
1380 1380
 								$settings[$field] = $values['default'];
1381 1381
 							}
1382 1382
 						}
1383 1383
 					}
1384 1384
 
1385
-					$active_messengers[$messenger]['settings'][$messenger . '-message_types'][$mt]['settings'] = $settings;
1385
+					$active_messengers[$messenger]['settings'][$messenger.'-message_types'][$mt]['settings'] = $settings;
1386 1386
 					$has_activated[$messenger][] = $mt;
1387 1387
 				}
1388 1388
 
1389 1389
 				//setup any initial settings for the messenger
1390 1390
 				$msgr_settings = $installed_messengers[$messenger]->get_admin_settings_fields();
1391 1391
 
1392
-				if ( !empty( $msgr_settings ) ) {
1393
-					foreach ( $msgr_settings as $field => $value ) {
1392
+				if ( ! empty($msgr_settings)) {
1393
+					foreach ($msgr_settings as $field => $value) {
1394 1394
 						$active_messengers[$messenger]['settings'][$field] = $value;
1395 1395
 					}
1396 1396
 				}
1397 1397
 
1398 1398
 				//now let's save the settings for this messenger! Must do now because the validator checks the db for active messengers to validate.
1399
-				EEH_MSG_Template::update_active_messengers_in_db( $active_messengers );
1399
+				EEH_MSG_Template::update_active_messengers_in_db($active_messengers);
1400 1400
 
1401 1401
 				//let's generate all the templates but only if the messenger has default_mts (otherwise its just activated).
1402
-				if ( !empty( $default_mts ) ) {
1403
-					$success = EEH_MSG_Template::generate_new_templates( $messenger, $default_mts, '', TRUE );
1402
+				if ( ! empty($default_mts)) {
1403
+					$success = EEH_MSG_Template::generate_new_templates($messenger, $default_mts, '', TRUE);
1404 1404
 				}
1405 1405
 			}
1406 1406
 		} //end check for empty( $def_ms )
1407 1407
 
1408 1408
 		//still need to see if there are any message types to activate for active messengers
1409
-		foreach ( $active_messengers as $messenger => $settings ) {
1409
+		foreach ($active_messengers as $messenger => $settings) {
1410 1410
 			$msg_obj = $settings['obj'];
1411
-			if ( ! $msg_obj instanceof EE_messenger ) {
1411
+			if ( ! $msg_obj instanceof EE_messenger) {
1412 1412
 				continue;
1413 1413
 			}
1414 1414
 
@@ -1416,49 +1416,49 @@  discard block
 block discarded – undo
1416 1416
 			$new_default_mts = array();
1417 1417
 
1418 1418
 			//loop through each default mt reported by the messenger and make sure its set in its active db entry.
1419
-			foreach( $all_default_mts as $index => $mt ) {
1419
+			foreach ($all_default_mts as $index => $mt) {
1420 1420
 				//already active? already has generated templates? || has already been activated before (we dont' want to reactivate things users intentionally deactivated).
1421 1421
 				if (
1422
-					isset( $active_messengers[ $messenger ]['settings'][ $messenger . '-message_types' ][ $mt ] )
1423
-					|| ( isset( $has_activated[ $messenger ] ) && in_array( $mt, $has_activated[ $messenger ] ) )
1424
-					||  EEH_MSG_Template::already_generated( $messenger, $mt, 0, FALSE )
1422
+					isset($active_messengers[$messenger]['settings'][$messenger.'-message_types'][$mt])
1423
+					|| (isset($has_activated[$messenger]) && in_array($mt, $has_activated[$messenger]))
1424
+					||  EEH_MSG_Template::already_generated($messenger, $mt, 0, FALSE)
1425 1425
 				) {
1426 1426
 					continue;
1427 1427
 				}
1428 1428
 
1429 1429
 				//is there an installed_mt matching the default string?  If not then nothing to do here.
1430
-				if ( ! isset( $installed_mts[$mt] ) ) {
1431
-					unset( $all_default_mts[$mt] );
1430
+				if ( ! isset($installed_mts[$mt])) {
1431
+					unset($all_default_mts[$mt]);
1432 1432
 					continue;
1433 1433
 				}
1434 1434
 
1435 1435
 				$settings_fields = $installed_mts[$mt]->get_admin_settings_fields();
1436 1436
 				$settings = array();
1437
-				if ( is_array( $settings_fields ) ) {
1438
-					foreach ( $settings_fields as $field => $values ) {
1439
-						if ( isset( $values['default'] ) ) {
1437
+				if (is_array($settings_fields)) {
1438
+					foreach ($settings_fields as $field => $values) {
1439
+						if (isset($values['default'])) {
1440 1440
 							$settings[$field] = $values['default'];
1441 1441
 						}
1442 1442
 					}
1443 1443
 				}
1444 1444
 
1445
-				$active_messengers[$messenger]['settings'][$messenger . '-message_types'][$mt]['settings'] = $settings;
1445
+				$active_messengers[$messenger]['settings'][$messenger.'-message_types'][$mt]['settings'] = $settings;
1446 1446
 				$new_default_mts[] = $mt;
1447 1447
 				$has_activated[$messenger][] = $mt;
1448 1448
 			}
1449 1449
 
1450 1450
 
1451
-			if ( ! empty( $new_default_mts ) ) {
1452
-				$success = EEH_MSG_Template::generate_new_templates( $messenger, $new_default_mts, '', TRUE );
1451
+			if ( ! empty($new_default_mts)) {
1452
+				$success = EEH_MSG_Template::generate_new_templates($messenger, $new_default_mts, '', TRUE);
1453 1453
 			}
1454 1454
 
1455 1455
 		}
1456 1456
 
1457 1457
 		//now let's save the settings for this messenger!
1458
-		EEH_MSG_Template::update_active_messengers_in_db( $active_messengers );
1458
+		EEH_MSG_Template::update_active_messengers_in_db($active_messengers);
1459 1459
 
1460 1460
 		//update $has_activated record
1461
-		update_option( 'ee_has_activated_messenger', $has_activated );
1461
+		update_option('ee_has_activated_messenger', $has_activated);
1462 1462
 
1463 1463
 		//that's it!
1464 1464
 		return $success;
@@ -1482,40 +1482,40 @@  discard block
 block discarded – undo
1482 1482
 		$installed = EEH_MSG_Template::get_installed_message_objects();
1483 1483
 		$installed_messengers = $installed_mts = array();
1484 1484
 		//set up the arrays so they can be handled easier.
1485
-		foreach( $installed['messengers'] as $im ) {
1486
-			if ( $im instanceof EE_messenger ) {
1485
+		foreach ($installed['messengers'] as $im) {
1486
+			if ($im instanceof EE_messenger) {
1487 1487
 				$installed_messengers[$im->name] = $im;
1488 1488
 			}
1489 1489
 		}
1490
-		foreach( $installed['message_types'] as $imt ) {
1491
-			if ( $imt instanceof EE_message_type ) {
1490
+		foreach ($installed['message_types'] as $imt) {
1491
+			if ($imt instanceof EE_message_type) {
1492 1492
 				$installed_mts[$imt->name] = $imt;
1493 1493
 			}
1494 1494
 		}
1495 1495
 
1496 1496
 		//now let's loop through the active array and validate
1497
-		foreach( $active_messengers as $messenger => $active_details ) {
1497
+		foreach ($active_messengers as $messenger => $active_details) {
1498 1498
 			//first let's see if this messenger is installed.
1499
-			if ( ! isset( $installed_messengers[$messenger] ) ) {
1499
+			if ( ! isset($installed_messengers[$messenger])) {
1500 1500
 				//not set so let's just remove from actives and make sure templates are inactive.
1501
-				unset( $active_messengers[$messenger] );
1502
-				EEH_MSG_Template::update_to_inactive( $messenger );
1501
+				unset($active_messengers[$messenger]);
1502
+				EEH_MSG_Template::update_to_inactive($messenger);
1503 1503
 				continue;
1504 1504
 			}
1505 1505
 
1506 1506
 			//messenger is active, so let's just make sure that any active message types not installed are deactivated.
1507
-			$mts = ! empty( $active_details['settings'][$messenger . '-message_types'] ) ? $active_details['settings'][$messenger . '-message_types'] : array();
1508
-			foreach ( $mts as $mt_name => $mt ) {
1509
-				if ( ! isset( $installed_mts[$mt_name] )  ) {
1510
-					unset( $active_messengers[$messenger]['settings'][$messenger . '-message_types'][$mt_name] );
1511
-					EEH_MSG_Template::update_to_inactive( $messenger, $mt_name );
1507
+			$mts = ! empty($active_details['settings'][$messenger.'-message_types']) ? $active_details['settings'][$messenger.'-message_types'] : array();
1508
+			foreach ($mts as $mt_name => $mt) {
1509
+				if ( ! isset($installed_mts[$mt_name])) {
1510
+					unset($active_messengers[$messenger]['settings'][$messenger.'-message_types'][$mt_name]);
1511
+					EEH_MSG_Template::update_to_inactive($messenger, $mt_name);
1512 1512
 				}
1513 1513
 			}
1514 1514
 		}
1515 1515
 
1516 1516
 		//all done! let's update the active_messengers.
1517
-		EEH_MSG_Template::update_active_messengers_in_db( $active_messengers );
1518
-		do_action( 'AHEE__EEH_Activation__validate_messages_system' );
1517
+		EEH_MSG_Template::update_active_messengers_in_db($active_messengers);
1518
+		do_action('AHEE__EEH_Activation__validate_messages_system');
1519 1519
 	}
1520 1520
 
1521 1521
 
@@ -1528,12 +1528,12 @@  discard block
 block discarded – undo
1528 1528
 	 * 	@static
1529 1529
 	 * 	@return void
1530 1530
 	 */
1531
-	public static function create_no_ticket_prices_array(){
1531
+	public static function create_no_ticket_prices_array() {
1532 1532
 		// this creates an array for tracking events that have no active ticket prices created
1533 1533
 		// this allows us to warn admins of the situation so that it can be corrected
1534
-		$espresso_no_ticket_prices = get_option( 'ee_no_ticket_prices', FALSE );
1535
-		if ( ! $espresso_no_ticket_prices ) {
1536
-			add_option( 'ee_no_ticket_prices', array(), '', FALSE );
1534
+		$espresso_no_ticket_prices = get_option('ee_no_ticket_prices', FALSE);
1535
+		if ( ! $espresso_no_ticket_prices) {
1536
+			add_option('ee_no_ticket_prices', array(), '', FALSE);
1537 1537
 		}
1538 1538
 	}
1539 1539
 
@@ -1557,24 +1557,24 @@  discard block
 block discarded – undo
1557 1557
 	 * @global wpdb $wpdb
1558 1558
 	 * @throws \EE_Error
1559 1559
 	 */
1560
-	public static function delete_all_espresso_cpt_data(){
1560
+	public static function delete_all_espresso_cpt_data() {
1561 1561
 		global $wpdb;
1562 1562
 		//get all the CPT post_types
1563 1563
 		$ee_post_types = array();
1564
-		foreach(EE_Registry::instance()->non_abstract_db_models as $model_name){
1565
-			if ( method_exists( $model_name, 'instance' )) {
1566
-				$model_obj = call_user_func( array( $model_name, 'instance' ));
1567
-				if ( $model_obj instanceof EEM_CPT_Base ) {
1568
-					$ee_post_types[] = $wpdb->prepare("%s",$model_obj->post_type());
1564
+		foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) {
1565
+			if (method_exists($model_name, 'instance')) {
1566
+				$model_obj = call_user_func(array($model_name, 'instance'));
1567
+				if ($model_obj instanceof EEM_CPT_Base) {
1568
+					$ee_post_types[] = $wpdb->prepare("%s", $model_obj->post_type());
1569 1569
 				}
1570 1570
 			}
1571 1571
 		}
1572 1572
 		//get all our CPTs
1573
-		$query = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (".implode(",",$ee_post_types).")";
1573
+		$query = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (".implode(",", $ee_post_types).")";
1574 1574
 		$cpt_ids = $wpdb->get_col($query);
1575 1575
 		//delete each post meta and term relations too
1576
-		foreach($cpt_ids as $post_id){
1577
-			wp_delete_post($post_id,true);
1576
+		foreach ($cpt_ids as $post_id) {
1577
+			wp_delete_post($post_id, true);
1578 1578
 		}
1579 1579
 	}
1580 1580
 
@@ -1588,18 +1588,18 @@  discard block
 block discarded – undo
1588 1588
 	 * @param bool $remove_all
1589 1589
 	 * @return void
1590 1590
 	 */
1591
-	public static function delete_all_espresso_tables_and_data( $remove_all = true ) {
1591
+	public static function delete_all_espresso_tables_and_data($remove_all = true) {
1592 1592
 		global $wpdb;
1593 1593
 		$undeleted_tables = array();
1594 1594
 
1595 1595
 		// load registry
1596
-		foreach( EE_Registry::instance()->non_abstract_db_models as $model_name ){
1597
-			if ( method_exists( $model_name, 'instance' )) {
1598
-				$model_obj = call_user_func( array( $model_name, 'instance' ));
1599
-				if ( $model_obj instanceof EEM_Base ) {
1600
-					foreach ( $model_obj->get_tables() as $table ) {
1601
-						if ( strpos( $table->get_table_name(), 'esp_' )) {
1602
-							switch ( EEH_Activation::delete_unused_db_table( $table->get_table_name() )) {
1596
+		foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) {
1597
+			if (method_exists($model_name, 'instance')) {
1598
+				$model_obj = call_user_func(array($model_name, 'instance'));
1599
+				if ($model_obj instanceof EEM_Base) {
1600
+					foreach ($model_obj->get_tables() as $table) {
1601
+						if (strpos($table->get_table_name(), 'esp_')) {
1602
+							switch (EEH_Activation::delete_unused_db_table($table->get_table_name())) {
1603 1603
 								case false :
1604 1604
 									$undeleted_tables[] = $table->get_table_name();
1605 1605
 								break;
@@ -1624,8 +1624,8 @@  discard block
 block discarded – undo
1624 1624
 			'esp_promotion_rule',
1625 1625
 			'esp_rule'
1626 1626
 		);
1627
-		foreach( $tables_without_models as $table ){
1628
-			EEH_Activation::delete_db_table_if_empty( $table );
1627
+		foreach ($tables_without_models as $table) {
1628
+			EEH_Activation::delete_db_table_if_empty($table);
1629 1629
 		}
1630 1630
 
1631 1631
 
@@ -1663,58 +1663,58 @@  discard block
 block discarded – undo
1663 1663
 			'ee_job_parameters_' => false,
1664 1664
 			'ee_upload_directories_incomplete' => true,
1665 1665
 		);
1666
-		if( is_main_site() ) {
1667
-			$wp_options_to_delete[ 'ee_network_config' ] = true;
1666
+		if (is_main_site()) {
1667
+			$wp_options_to_delete['ee_network_config'] = true;
1668 1668
 		}
1669 1669
 
1670 1670
 		$undeleted_options = array();
1671
-		foreach ( $wp_options_to_delete as $option_name => $no_wildcard ) {
1671
+		foreach ($wp_options_to_delete as $option_name => $no_wildcard) {
1672 1672
 
1673
-			if( $no_wildcard ){
1674
-				if( ! delete_option( $option_name ) ){
1673
+			if ($no_wildcard) {
1674
+				if ( ! delete_option($option_name)) {
1675 1675
 					$undeleted_options[] = $option_name;
1676 1676
 				}
1677
-			}else{
1678
-				$option_names_to_delete_from_wildcard = $wpdb->get_col( "SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'" );
1679
-				foreach($option_names_to_delete_from_wildcard as $option_name_from_wildcard ){
1680
-					if( ! delete_option( $option_name_from_wildcard ) ){
1677
+			} else {
1678
+				$option_names_to_delete_from_wildcard = $wpdb->get_col("SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'");
1679
+				foreach ($option_names_to_delete_from_wildcard as $option_name_from_wildcard) {
1680
+					if ( ! delete_option($option_name_from_wildcard)) {
1681 1681
 						$undeleted_options[] = $option_name_from_wildcard;
1682 1682
 					}
1683 1683
 				}
1684 1684
 			}
1685 1685
 		}
1686 1686
                 //also, let's make sure the "ee_config_option_names" wp option stays out by removing the action that adds it
1687
-                remove_action( 'shutdown', array( EE_Config::instance(), 'shutdown' ), 10 );
1687
+                remove_action('shutdown', array(EE_Config::instance(), 'shutdown'), 10);
1688 1688
 
1689
-		if ( $remove_all && $espresso_db_update = get_option( 'espresso_db_update' )) {
1689
+		if ($remove_all && $espresso_db_update = get_option('espresso_db_update')) {
1690 1690
 			$db_update_sans_ee4 = array();
1691
-			foreach($espresso_db_update as $version => $times_activated){
1692
-				if( (string)$version[0] === '3'){//if its NON EE4
1691
+			foreach ($espresso_db_update as $version => $times_activated) {
1692
+				if ((string) $version[0] === '3') {//if its NON EE4
1693 1693
 					$db_update_sans_ee4[$version] = $times_activated;
1694 1694
 				}
1695 1695
 			}
1696
-			update_option( 'espresso_db_update', $db_update_sans_ee4 );
1696
+			update_option('espresso_db_update', $db_update_sans_ee4);
1697 1697
 		}
1698 1698
 
1699 1699
 		$errors = '';
1700
-		if ( ! empty( $undeleted_tables )) {
1700
+		if ( ! empty($undeleted_tables)) {
1701 1701
 			$errors .= sprintf(
1702
-				__( 'The following tables could not be deleted: %s%s', 'event_espresso' ),
1702
+				__('The following tables could not be deleted: %s%s', 'event_espresso'),
1703 1703
 				'<br/>',
1704
-				implode( ',<br/>', $undeleted_tables )
1704
+				implode(',<br/>', $undeleted_tables)
1705 1705
 			);
1706 1706
 		}
1707
-		if ( ! empty( $undeleted_options )) {
1708
-			$errors .= ! empty( $undeleted_tables ) ? '<br/>' : '';
1707
+		if ( ! empty($undeleted_options)) {
1708
+			$errors .= ! empty($undeleted_tables) ? '<br/>' : '';
1709 1709
 			$errors .= sprintf(
1710
-				__( 'The following wp-options could not be deleted: %s%s', 'event_espresso' ),
1710
+				__('The following wp-options could not be deleted: %s%s', 'event_espresso'),
1711 1711
 				'<br/>',
1712
-				implode( ',<br/>', $undeleted_options )
1712
+				implode(',<br/>', $undeleted_options)
1713 1713
 			);
1714 1714
 
1715 1715
 		}
1716
-		if ( ! empty( $errors ) ) {
1717
-			EE_Error::add_attention( $errors, __FILE__, __FUNCTION__, __LINE__ );
1716
+		if ( ! empty($errors)) {
1717
+			EE_Error::add_attention($errors, __FILE__, __FUNCTION__, __LINE__);
1718 1718
 		}
1719 1719
 	}
1720 1720
 
@@ -1724,23 +1724,23 @@  discard block
 block discarded – undo
1724 1724
 	 * @param string $table_name with or without $wpdb->prefix
1725 1725
 	 * @return boolean
1726 1726
 	 */
1727
-	public static function table_exists( $table_name ){
1727
+	public static function table_exists($table_name) {
1728 1728
 		global $wpdb, $EZSQL_ERROR;
1729
-		$table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name );
1729
+		$table_name = EEH_Activation::ensure_table_name_has_prefix($table_name);
1730 1730
 		//ignore if this causes an sql error
1731 1731
 		$old_error = $wpdb->last_error;
1732 1732
 		$old_suppress_errors = $wpdb->suppress_errors();
1733
-		$old_show_errors_value = $wpdb->show_errors( FALSE );
1733
+		$old_show_errors_value = $wpdb->show_errors(FALSE);
1734 1734
 		$ezsql_error_cache = $EZSQL_ERROR;
1735
-		$wpdb->get_results( "SELECT * from $table_name LIMIT 1");
1736
-		$wpdb->show_errors( $old_show_errors_value );
1737
-		$wpdb->suppress_errors( $old_suppress_errors );
1735
+		$wpdb->get_results("SELECT * from $table_name LIMIT 1");
1736
+		$wpdb->show_errors($old_show_errors_value);
1737
+		$wpdb->suppress_errors($old_suppress_errors);
1738 1738
 		$new_error = $wpdb->last_error;
1739 1739
 		$wpdb->last_error = $old_error;
1740 1740
 		$EZSQL_ERROR = $ezsql_error_cache;
1741
-		if( empty( $new_error ) ){
1741
+		if (empty($new_error)) {
1742 1742
 			return TRUE;
1743
-		}else{
1743
+		} else {
1744 1744
 			return FALSE;
1745 1745
 		}
1746 1746
 	}
@@ -1748,7 +1748,7 @@  discard block
 block discarded – undo
1748 1748
 	/**
1749 1749
 	 * Resets the cache on EEH_Activation
1750 1750
 	 */
1751
-	public static function reset(){
1751
+	public static function reset() {
1752 1752
 		self::$_default_creator_id = NULL;
1753 1753
 		self::$_initialized_db_content_already_in_this_request = false;
1754 1754
 	}
Please login to merge, or discard this patch.
core/db_classes/EE_Base_Class.class.php 2 patches
Indentation   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -1,28 +1,28 @@  discard block
 block discarded – undo
1 1
 <?php if (!defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed');}
2 2
 do_action( 'AHEE_log', __FILE__, ' FILE LOADED', '' );
3 3
 /**
4
- *
5
- * Event Espresso
6
- *
7
- * Event Registration and Management Plugin for WordPress
8
- *
9
- * @ package			Event Espresso
10
- * @ author				Seth Shoultes
11
- * @ copyright		(c) 2008-2011 Event Espresso  All Rights Reserved.
12
- * @ license			http://eventespresso.com/support/terms-conditions/   * see Plugin Licensing *
13
- * @ link					http://www.eventespresso.com
14
- * @ version		 	4.0
15
- *
16
- * ------------------------------------------------------------------------
17
- *
18
- * EE_Base_Class class
19
- *
20
- * @package				Event Espresso
21
- * @subpackage			includes/classes/EE_Base_Class.class.php
22
- * @author					Michael Nelson
23
- *
24
- * ------------------------------------------------------------------------
25
- */
4
+	 *
5
+	 * Event Espresso
6
+	 *
7
+	 * Event Registration and Management Plugin for WordPress
8
+	 *
9
+	 * @ package			Event Espresso
10
+	 * @ author				Seth Shoultes
11
+	 * @ copyright		(c) 2008-2011 Event Espresso  All Rights Reserved.
12
+	 * @ license			http://eventespresso.com/support/terms-conditions/   * see Plugin Licensing *
13
+	 * @ link					http://www.eventespresso.com
14
+	 * @ version		 	4.0
15
+	 *
16
+	 * ------------------------------------------------------------------------
17
+	 *
18
+	 * EE_Base_Class class
19
+	 *
20
+	 * @package				Event Espresso
21
+	 * @subpackage			includes/classes/EE_Base_Class.class.php
22
+	 * @author					Michael Nelson
23
+	 *
24
+	 * ------------------------------------------------------------------------
25
+	 */
26 26
 
27 27
 abstract class EE_Base_Class{
28 28
 
@@ -47,25 +47,25 @@  discard block
 block discarded – undo
47 47
 
48 48
 
49 49
 	/**
50
-    *	date format
51
-	*
52
-    *	pattern or format for displaying dates
53
-	*
54
-	*	@access	protected
55
-    *	@var string
56
-    */
50
+	 *	date format
51
+	 *
52
+	 *	pattern or format for displaying dates
53
+	 *
54
+	 *	@access	protected
55
+	 *	@var string
56
+	 */
57 57
 	protected $_dt_frmt;
58 58
 
59 59
 
60 60
 
61
-    /**
62
-    *	time format
63
-	*
64
-    *	pattern or format for displaying time
65
-	*
66
-	*	@access	protected
67
-    *	@var string
68
-    */
61
+	/**
62
+	 *	time format
63
+	 *
64
+	 *	pattern or format for displaying time
65
+	 *
66
+	 *	@access	protected
67
+	 *	@var string
68
+	 */
69 69
 	protected $_tm_frmt;
70 70
 
71 71
 
@@ -1430,24 +1430,24 @@  discard block
 block discarded – undo
1430 1430
 	 *
1431 1431
 	 * @throws \EE_Error
1432 1432
 	 */
1433
-        public function refresh_cache_of_related_objects() {
1434
-            foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ) {
1435
-                if( ! empty( $this->_model_relations[ $relation_name ] ) ) {
1436
-                    $related_objects = $this->_model_relations[ $relation_name ];
1437
-                    if( $relation_obj instanceof EE_Belongs_To_Relation ) {
1438
-                        //this relation only stores a single model object, not an array
1439
-                        //but let's make it consistent
1440
-                        $related_objects = array( $related_objects );
1441
-                    }
1442
-                    foreach( $related_objects as $related_object ) {
1443
-                        //only refresh their cache if they're in memory
1444
-                        if( $related_object instanceof EE_Base_Class ) {
1433
+		public function refresh_cache_of_related_objects() {
1434
+			foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ) {
1435
+				if( ! empty( $this->_model_relations[ $relation_name ] ) ) {
1436
+					$related_objects = $this->_model_relations[ $relation_name ];
1437
+					if( $relation_obj instanceof EE_Belongs_To_Relation ) {
1438
+						//this relation only stores a single model object, not an array
1439
+						//but let's make it consistent
1440
+						$related_objects = array( $related_objects );
1441
+					}
1442
+					foreach( $related_objects as $related_object ) {
1443
+						//only refresh their cache if they're in memory
1444
+						if( $related_object instanceof EE_Base_Class ) {
1445 1445
 							$related_object->clear_cache( $this->get_model()->get_this_model_name(), $this );
1446
-                        }
1447
-                    }
1448
-                }
1449
-            }
1450
-        }
1446
+						}
1447
+					}
1448
+				}
1449
+			}
1450
+		}
1451 1451
 
1452 1452
 
1453 1453
 
@@ -1688,7 +1688,7 @@  discard block
 block discarded – undo
1688 1688
 		if ( self::_get_model( $classname )->has_primary_key_field() ) {
1689 1689
 			$primary_id_ref = self::_get_primary_key_name( $classname );
1690 1690
 			if ( array_key_exists( $primary_id_ref, $props_n_values )
1691
-			     && ! empty( $props_n_values[ $primary_id_ref ] )
1691
+				 && ! empty( $props_n_values[ $primary_id_ref ] )
1692 1692
 			) {
1693 1693
 				$existing = self::_get_model( $classname, $timezone )->get_one_by_ID(
1694 1694
 					$props_n_values[ $primary_id_ref ]
@@ -1840,9 +1840,9 @@  discard block
 block discarded – undo
1840 1840
 			$otherObject = $this->get_model()->add_relationship_to( $this, $otherObjectModelObjectOrID, $relationName, $extra_join_model_fields_n_values );
1841 1841
 			//clear cache so future get_many_related and get_first_related() return new results.
1842 1842
 			$this->clear_cache( $relationName, $otherObject, TRUE );
1843
-                        if( $otherObject instanceof EE_Base_Class ) {
1844
-                            $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this );
1845
-                        }
1843
+						if( $otherObject instanceof EE_Base_Class ) {
1844
+							$otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this );
1845
+						}
1846 1846
 		} else {
1847 1847
 			//this thing doesn't exist in the DB,  so just cache it
1848 1848
 			if( ! $otherObjectModelObjectOrID instanceof EE_Base_Class){
@@ -1856,18 +1856,18 @@  discard block
 block discarded – undo
1856 1856
 			}
1857 1857
 			$this->cache( $relationName, $otherObjectModelObjectOrID, $cache_id );
1858 1858
 		}
1859
-                if( $otherObject instanceof EE_Base_Class ) {
1860
-                    //fix the reciprocal relation too
1861
-                    if( $otherObject->ID() ) {
1862
-                            //its saved so assumed relations exist in the DB, so we can just
1863
-                            //clear the cache so future queries use the updated info in the DB
1864
-                            $otherObject->clear_cache( $this->get_model()->get_this_model_name(), null, true );
1865
-                    } else {
1866
-
1867
-                            //it's not saved, so it caches relations like this
1868
-                            $otherObject->cache( $this->get_model()->get_this_model_name(), $this );
1869
-                    }
1870
-                }
1859
+				if( $otherObject instanceof EE_Base_Class ) {
1860
+					//fix the reciprocal relation too
1861
+					if( $otherObject->ID() ) {
1862
+							//its saved so assumed relations exist in the DB, so we can just
1863
+							//clear the cache so future queries use the updated info in the DB
1864
+							$otherObject->clear_cache( $this->get_model()->get_this_model_name(), null, true );
1865
+					} else {
1866
+
1867
+							//it's not saved, so it caches relations like this
1868
+							$otherObject->cache( $this->get_model()->get_this_model_name(), $this );
1869
+					}
1870
+				}
1871 1871
 		return $otherObject;
1872 1872
 	}
1873 1873
 
@@ -1898,9 +1898,9 @@  discard block
 block discarded – undo
1898 1898
 			//this doesn't exist in the DB, just remove it from the cache
1899 1899
 			$otherObject = $this->clear_cache( $relationName, $otherObjectModelObjectOrID );
1900 1900
 		}
1901
-                if( $otherObject instanceof EE_Base_Class ) {
1902
-                    $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this );
1903
-                }
1901
+				if( $otherObject instanceof EE_Base_Class ) {
1902
+					$otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this );
1903
+				}
1904 1904
 		return $otherObject;
1905 1905
 	}
1906 1906
 
@@ -1923,11 +1923,11 @@  discard block
 block discarded – undo
1923 1923
 			//this doesn't exist in the DB, just remove it from the cache
1924 1924
 			$otherObjects = $this->clear_cache( $relationName, null, true );
1925 1925
 		}
1926
-                if( is_array( $otherObjects ) ) {
1927
-                    foreach ( $otherObjects as $otherObject ) {
1928
-                            $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this );
1929
-                    }
1930
-                }
1926
+				if( is_array( $otherObjects ) ) {
1927
+					foreach ( $otherObjects as $otherObject ) {
1928
+							$otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this );
1929
+					}
1930
+				}
1931 1931
 		return $otherObjects;
1932 1932
 	}
1933 1933
 
Please login to merge, or discard this patch.
Spacing   +484 added lines, -484 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1
-<?php if (!defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed');}
2
-do_action( 'AHEE_log', __FILE__, ' FILE LOADED', '' );
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed'); }
2
+do_action('AHEE_log', __FILE__, ' FILE LOADED', '');
3 3
 /**
4 4
  *
5 5
  * Event Espresso
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
  * ------------------------------------------------------------------------
25 25
  */
26 26
 
27
-abstract class EE_Base_Class{
27
+abstract class EE_Base_Class {
28 28
 
29 29
 	/**
30 30
 	 * This is an array of the original properties and values provided during construction
@@ -117,59 +117,59 @@  discard block
 block discarded – undo
117 117
 	 * @throws EE_Error
118 118
 	 * @return \EE_Base_Class
119 119
 	 */
120
-	protected function __construct( $fieldValues = array(), $bydb = FALSE, $timezone = '', $date_formats = array() ){
120
+	protected function __construct($fieldValues = array(), $bydb = FALSE, $timezone = '', $date_formats = array()) {
121 121
 
122
-		$className=get_class($this);
122
+		$className = get_class($this);
123 123
 
124
-		do_action("AHEE__{$className}__construct",$this,$fieldValues);
125
-		$model=$this->get_model();
126
-		$model_fields = $model->field_settings( FALSE );
124
+		do_action("AHEE__{$className}__construct", $this, $fieldValues);
125
+		$model = $this->get_model();
126
+		$model_fields = $model->field_settings(FALSE);
127 127
 		// ensure $fieldValues is an array
128
-		$fieldValues = is_array( $fieldValues ) ? $fieldValues : array( $fieldValues );
128
+		$fieldValues = is_array($fieldValues) ? $fieldValues : array($fieldValues);
129 129
 		// EEH_Debug_Tools::printr( $fieldValues, '$fieldValues  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
130 130
 		// verify client code has not passed any invalid field names
131
-		foreach($fieldValues as $field_name=> $field_value){
132
-			if( ! isset( $model_fields[ $field_name] ) ){
133
-				throw new EE_Error(sprintf(__("Invalid field (%s) passed to constructor of %s. Allowed fields are :%s", "event_espresso"),$field_name,get_class($this),implode(", ",array_keys($model_fields))));
131
+		foreach ($fieldValues as $field_name=> $field_value) {
132
+			if ( ! isset($model_fields[$field_name])) {
133
+				throw new EE_Error(sprintf(__("Invalid field (%s) passed to constructor of %s. Allowed fields are :%s", "event_espresso"), $field_name, get_class($this), implode(", ", array_keys($model_fields))));
134 134
 			}
135 135
 		}
136 136
 		// EEH_Debug_Tools::printr( $model_fields, '$model_fields  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
137
-		$this->_timezone = EEH_DTT_Helper::get_valid_timezone_string( $timezone );
137
+		$this->_timezone = EEH_DTT_Helper::get_valid_timezone_string($timezone);
138 138
 
139
-		if ( ! empty( $date_formats ) && is_array( $date_formats ) ) {
139
+		if ( ! empty($date_formats) && is_array($date_formats)) {
140 140
 			$this->_dt_frmt = $date_formats[0];
141 141
 			$this->_tm_frmt = $date_formats[1];
142 142
 		} else {
143 143
 			//set default formats for date and time
144
-			$this->_dt_frmt = get_option( 'date_format' );
145
-			$this->_tm_frmt = get_option( 'time_format' );
144
+			$this->_dt_frmt = get_option('date_format');
145
+			$this->_tm_frmt = get_option('time_format');
146 146
 		}
147 147
 
148 148
 		//if db model is instantiating
149
-		if ( $bydb ){
149
+		if ($bydb) {
150 150
 			//client code has indicated these field values are from the database
151
-			foreach( $model_fields as $fieldName => $field ){
152
-				$this->set_from_db( $fieldName, isset( $fieldValues[ $fieldName] ) ? $fieldValues[ $fieldName ] : null );
151
+			foreach ($model_fields as $fieldName => $field) {
152
+				$this->set_from_db($fieldName, isset($fieldValues[$fieldName]) ? $fieldValues[$fieldName] : null);
153 153
 			}
154 154
 		} else {
155 155
 			//we're constructing a brand
156 156
 			//new instance of the model object. Generally, this means we'll need to do more field validation
157
-			foreach( $model_fields as $fieldName => $field ){
158
-				$this->set( $fieldName, isset( $fieldValues[ $fieldName ] ) ? $fieldValues[ $fieldName ] : null, true );
157
+			foreach ($model_fields as $fieldName => $field) {
158
+				$this->set($fieldName, isset($fieldValues[$fieldName]) ? $fieldValues[$fieldName] : null, true);
159 159
 			}
160 160
 		}
161 161
 
162 162
 		//remember what values were passed to this constructor
163 163
 		$this->_props_n_values_provided_in_constructor = $fieldValues;
164 164
 		//remember in entity mapper
165
-		if( ! $bydb  && $model->has_primary_key_field() && $this->ID() ){
165
+		if ( ! $bydb && $model->has_primary_key_field() && $this->ID()) {
166 166
 			$model->add_to_entity_map($this);
167 167
 		}
168 168
 		//setup all the relations
169
-		foreach($this->get_model()->relation_settings() as $relation_name=>$relation_obj){
170
-			if($relation_obj instanceof EE_Belongs_To_Relation){
169
+		foreach ($this->get_model()->relation_settings() as $relation_name=>$relation_obj) {
170
+			if ($relation_obj instanceof EE_Belongs_To_Relation) {
171 171
 				$this->_model_relations[$relation_name] = NULL;
172
-			}else{
172
+			} else {
173 173
 				$this->_model_relations[$relation_name] = array();
174 174
 			}
175 175
 		}
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
 		 * Action done at the end of each model object construction
178 178
 		 * @param EE_Base_Class $this the model object just created
179 179
 		 */
180
-		do_action( 'AHEE__EE_Base_Class__construct__finished', $this );
180
+		do_action('AHEE__EE_Base_Class__construct__finished', $this);
181 181
 	}
182 182
 
183 183
 	/**
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 	 * @param boolean $allow_persist
198 198
 	 * @return boolean
199 199
 	 */
200
-	public function set_allow_persist( $allow_persist ) {
200
+	public function set_allow_persist($allow_persist) {
201 201
 		return $this->_allow_persist = $allow_persist;
202 202
 	}
203 203
 
@@ -211,11 +211,11 @@  discard block
 block discarded – undo
211 211
 	 * @return mixed|null
212 212
 	 * @throws \EE_Error
213 213
 	 */
214
-	public function get_original( $field_name ){
215
-		if( isset( $this->_props_n_values_provided_in_constructor[ $field_name ] ) &&
216
-				$field_settings = $this->get_model()->field_settings_for( $field_name )){
217
-			return $field_settings->prepare_for_get( $this->_props_n_values_provided_in_constructor[ $field_name ] );
218
-		}else{
214
+	public function get_original($field_name) {
215
+		if (isset($this->_props_n_values_provided_in_constructor[$field_name]) &&
216
+				$field_settings = $this->get_model()->field_settings_for($field_name)) {
217
+			return $field_settings->prepare_for_get($this->_props_n_values_provided_in_constructor[$field_name]);
218
+		} else {
219 219
 			return NULL;
220 220
 		}
221 221
 	}
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 	 * @param EE_Base_Class $obj
226 226
 	 * @return string
227 227
 	 */
228
-	public function get_class($obj){
228
+	public function get_class($obj) {
229 229
 		return get_class($obj);
230 230
 	}
231 231
 
@@ -240,19 +240,19 @@  discard block
 block discarded – undo
240 240
 	 * @param bool      $use_default
241 241
 	 * @throws \EE_Error
242 242
 	 */
243
-	public function set( $field_name, $field_value, $use_default = FALSE ){
244
-		$field_obj = $this->get_model()->field_settings_for( $field_name );
245
-		if ( $field_obj instanceof EE_Model_Field_Base ) {
243
+	public function set($field_name, $field_value, $use_default = FALSE) {
244
+		$field_obj = $this->get_model()->field_settings_for($field_name);
245
+		if ($field_obj instanceof EE_Model_Field_Base) {
246 246
 //			if ( method_exists( $field_obj, 'set_timezone' )) {
247
-			if ( $field_obj instanceof EE_Datetime_Field ) {
248
-				$field_obj->set_timezone( $this->_timezone );
249
-				$field_obj->set_date_format( $this->_dt_frmt );
250
-				$field_obj->set_time_format( $this->_tm_frmt );
247
+			if ($field_obj instanceof EE_Datetime_Field) {
248
+				$field_obj->set_timezone($this->_timezone);
249
+				$field_obj->set_date_format($this->_dt_frmt);
250
+				$field_obj->set_time_format($this->_tm_frmt);
251 251
 			}
252 252
 
253 253
 			$holder_of_value = $field_obj->prepare_for_set($field_value);
254 254
 			//should the value be null?
255
-			if( ($field_value === NULL || $holder_of_value === NULL || $holder_of_value ==='') && $use_default){
255
+			if (($field_value === NULL || $holder_of_value === NULL || $holder_of_value === '') && $use_default) {
256 256
 				$this->_fields[$field_name] = $field_obj->get_default_value();
257 257
 
258 258
 				/**
@@ -264,26 +264,26 @@  discard block
 block discarded – undo
264 264
 				 */
265 265
 				if (
266 266
 					$field_obj instanceof EE_Datetime_Field
267
-					&& $this->_fields[ $field_name ] !== null
267
+					&& $this->_fields[$field_name] !== null
268 268
 					&& ! $this->_fields[$field_name] instanceof DateTime
269 269
 				) {
270
-					empty( $this->_fields[$field_name] )
271
-						? $this->set( $field_name, time() )
272
-						: $this->set( $field_name, $this->_fields[$field_name] );
270
+					empty($this->_fields[$field_name])
271
+						? $this->set($field_name, time())
272
+						: $this->set($field_name, $this->_fields[$field_name]);
273 273
 				}
274 274
 
275
-			}else{
275
+			} else {
276 276
 				$this->_fields[$field_name] = $holder_of_value;
277 277
 			}
278 278
 
279 279
 			//if we're not in the constructor...
280 280
 			//now check if what we set was a primary key
281
-			if(
281
+			if (
282 282
 				//note: props_n_values_provided_in_constructor is only set at the END of the constructor
283 283
 				$this->_props_n_values_provided_in_constructor
284 284
 				&& $field_value
285
-				&& $field_name === self::_get_primary_key_name( get_class( $this ) )
286
-			){
285
+				&& $field_name === self::_get_primary_key_name(get_class($this))
286
+			) {
287 287
 				//if so, we want all this object's fields to be filled either with
288 288
 				//what we've explicitly set on this model
289 289
 				//or what we have in the db
@@ -291,20 +291,20 @@  discard block
 block discarded – undo
291 291
 				$fields_on_model = self::_get_model(get_class($this))->field_settings();
292 292
 
293 293
 				$obj_in_db = self::_get_model(get_class($this))->get_one_by_ID($field_value);
294
-				foreach($fields_on_model as $field_obj){
295
-					if( ! array_key_exists($field_obj->get_name(), $this->_props_n_values_provided_in_constructor)
296
-						&& $field_obj->get_name() !== $field_name ){
294
+				foreach ($fields_on_model as $field_obj) {
295
+					if ( ! array_key_exists($field_obj->get_name(), $this->_props_n_values_provided_in_constructor)
296
+						&& $field_obj->get_name() !== $field_name) {
297 297
 
298
-						$this->set($field_obj->get_name(),$obj_in_db->get($field_obj->get_name()));
298
+						$this->set($field_obj->get_name(), $obj_in_db->get($field_obj->get_name()));
299 299
 					}
300 300
 				}
301 301
 				//oh this model object has an ID? well make sure its in the entity mapper
302 302
 				$this->get_model()->add_to_entity_map($this);
303 303
 			}
304 304
 			//let's unset any cache for this field_name from the $_cached_properties property.
305
-			$this->_clear_cached_property( $field_name );
306
-		}else{
307
-			throw new EE_Error( sprintf( __( "A valid EE_Model_Field_Base could not be found for the given field name: %s", "event_espresso" ), $field_name  ) );
305
+			$this->_clear_cached_property($field_name);
306
+		} else {
307
+			throw new EE_Error(sprintf(__("A valid EE_Model_Field_Base could not be found for the given field name: %s", "event_espresso"), $field_name));
308 308
 		}
309 309
 
310 310
 	}
@@ -321,14 +321,14 @@  discard block
 block discarded – undo
321 321
 	 * @return int|bool @see EE_Base_Class::update_extra_meta() for return docs.
322 322
 	 * @throws \EE_Error
323 323
 	 */
324
-	public function set_field_or_extra_meta( $field_name, $field_value ) {
325
-		if ( $this->get_model()->has_field( $field_name ) ) {
326
-			$this->set( $field_name, $field_value );
324
+	public function set_field_or_extra_meta($field_name, $field_value) {
325
+		if ($this->get_model()->has_field($field_name)) {
326
+			$this->set($field_name, $field_value);
327 327
 			return true;
328 328
 		} else {
329 329
 			//ensure this object is saved first so that extra meta can be properly related.
330 330
 			$this->save();
331
-			return $this->update_extra_meta( $field_name, $field_value );
331
+			return $this->update_extra_meta($field_name, $field_value);
332 332
 		}
333 333
 	}
334 334
 
@@ -349,12 +349,12 @@  discard block
 block discarded – undo
349 349
 	 * @return mixed|null  value for the field if found.  null if not found.
350 350
 	 * @throws \EE_Error
351 351
 	 */
352
-	public function get_field_or_extra_meta( $field_name ) {
353
-		if ( $this->get_model()->has_field( $field_name ) ) {
354
-			$column_value = $this->get( $field_name );
352
+	public function get_field_or_extra_meta($field_name) {
353
+		if ($this->get_model()->has_field($field_name)) {
354
+			$column_value = $this->get($field_name);
355 355
 		} else {
356 356
 			//This isn't a column in the main table, let's see if it is in the extra meta.
357
-			$column_value = $this->get_extra_meta( $field_name, true, null );
357
+			$column_value = $this->get_extra_meta($field_name, true, null);
358 358
 		}
359 359
 		return $column_value;
360 360
 	}
@@ -370,18 +370,18 @@  discard block
 block discarded – undo
370 370
 	 * @return void
371 371
 	 * @throws \EE_Error
372 372
 	 */
373
-	public function set_timezone( $timezone = '' ) {
374
-		$this->_timezone = EEH_DTT_Helper::get_valid_timezone_string( $timezone );
373
+	public function set_timezone($timezone = '') {
374
+		$this->_timezone = EEH_DTT_Helper::get_valid_timezone_string($timezone);
375 375
 		//make sure we clear all cached properties because they won't be relevant now
376 376
 		$this->_clear_cached_properties();
377 377
 
378 378
 		//make sure we update field settings and the date for all EE_Datetime_Fields
379
-		$model_fields = $this->get_model()->field_settings( false );
380
-		foreach ( $model_fields as $field_name => $field_obj ) {
381
-			if ( $field_obj instanceof EE_Datetime_Field ) {
382
-				$field_obj->set_timezone( $this->_timezone );
383
-				if ( isset( $this->_fields[$field_name] ) && $this->_fields[$field_name] instanceof DateTime ) {
384
-					$this->_fields[$field_name]->setTimezone( new DateTimeZone( $this->_timezone ) );
379
+		$model_fields = $this->get_model()->field_settings(false);
380
+		foreach ($model_fields as $field_name => $field_obj) {
381
+			if ($field_obj instanceof EE_Datetime_Field) {
382
+				$field_obj->set_timezone($this->_timezone);
383
+				if (isset($this->_fields[$field_name]) && $this->_fields[$field_name] instanceof DateTime) {
384
+					$this->_fields[$field_name]->setTimezone(new DateTimeZone($this->_timezone));
385 385
 				}
386 386
 			}
387 387
 		}
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
 	 *
411 411
 	 * @param string $format   should be a format recognizable by PHP date() functions.
412 412
 	 */
413
-	public function set_date_format( $format ) {
413
+	public function set_date_format($format) {
414 414
 		$this->_dt_frmt = $format;
415 415
 		//clear cached_properties because they won't be relevant now.
416 416
 		$this->_clear_cached_properties();
@@ -426,7 +426,7 @@  discard block
 block discarded – undo
426 426
 	 * @since 4.6
427 427
 	 * @param string $format should be a format recognizable by PHP date() functions.
428 428
 	 */
429
-	public function set_time_format( $format ) {
429
+	public function set_time_format($format) {
430 430
 		$this->_tm_frmt = $format;
431 431
 		//clear cached_properties because they won't be relevant now.
432 432
 		$this->_clear_cached_properties();
@@ -443,8 +443,8 @@  discard block
 block discarded – undo
443 443
 	 *
444 444
 	 * @return mixed string|array
445 445
 	 */
446
-	public function get_format( $full = true ) {
447
-		return $full ? $this->_dt_frmt . ' ' . $this->_tm_frmt : array( $this->_dt_frmt, $this->_tm_frmt );
446
+	public function get_format($full = true) {
447
+		return $full ? $this->_dt_frmt.' '.$this->_tm_frmt : array($this->_dt_frmt, $this->_tm_frmt);
448 448
 	}
449 449
 
450 450
 
@@ -462,17 +462,17 @@  discard block
 block discarded – undo
462 462
 	 * @throws EE_Error
463 463
 	 * @return mixed    index into cache, or just TRUE if the relation is of type Belongs_To (because there's only one related thing, no array)
464 464
 	 */
465
-	public function cache( $relationName = '', $object_to_cache = NULL, $cache_id = NULL ){
465
+	public function cache($relationName = '', $object_to_cache = NULL, $cache_id = NULL) {
466 466
 		// its entirely possible that there IS no related object yet in which case there is nothing to cache.
467
-		if ( ! $object_to_cache instanceof EE_Base_Class ) {
467
+		if ( ! $object_to_cache instanceof EE_Base_Class) {
468 468
 			return FALSE;
469 469
 		}
470 470
 		// also get "how" the object is related, or throw an error
471
-		if( ! $relationship_to_model = $this->get_model()->related_settings_for( $relationName )) {
472
-			throw new EE_Error( sprintf( __( 'There is no relationship to %s on a %s. Cannot cache it', 'event_espresso' ), $relationName, get_class( $this )));
471
+		if ( ! $relationship_to_model = $this->get_model()->related_settings_for($relationName)) {
472
+			throw new EE_Error(sprintf(__('There is no relationship to %s on a %s. Cannot cache it', 'event_espresso'), $relationName, get_class($this)));
473 473
 		}
474 474
 		// how many things are related ?
475
-		if( $relationship_to_model instanceof EE_Belongs_To_Relation ){
475
+		if ($relationship_to_model instanceof EE_Belongs_To_Relation) {
476 476
 			// if it's a "belongs to" relationship, then there's only one related model object  eg, if this is a registration, there's only 1 attendee for it
477 477
 			// so for these model objects just set it to be cached
478 478
 			$this->_model_relations[$relationName] = $object_to_cache;
@@ -480,26 +480,26 @@  discard block
 block discarded – undo
480 480
 		} else {
481 481
 			// otherwise, this is the "many" side of a one to many relationship, so we'll add the object to the array of related objects for that type.
482 482
 			// eg: if this is an event, there are many registrations for that event, so we cache the registrations in an array
483
-			if( ! is_array( $this->_model_relations[$relationName] )) {
483
+			if ( ! is_array($this->_model_relations[$relationName])) {
484 484
 				// if for some reason, the cached item is a model object, then stick that in the array, otherwise start with an empty array
485
-				$this->_model_relations[$relationName] = $this->_model_relations[$relationName] instanceof EE_Base_Class ? array( $this->_model_relations[$relationName] ) : array();
485
+				$this->_model_relations[$relationName] = $this->_model_relations[$relationName] instanceof EE_Base_Class ? array($this->_model_relations[$relationName]) : array();
486 486
 			}
487 487
 			// first check for a cache_id which is normally empty
488
-			if ( ! empty( $cache_id )) {
488
+			if ( ! empty($cache_id)) {
489 489
 				// if the cache_id exists, then it means we are purposely trying to cache this with a known key that can then be used to retrieve the object later on
490
-				$this->_model_relations[$relationName][ $cache_id ] = $object_to_cache;
490
+				$this->_model_relations[$relationName][$cache_id] = $object_to_cache;
491 491
 				$return = $cache_id;
492
-			} elseif ( $object_to_cache->ID() ) {
492
+			} elseif ($object_to_cache->ID()) {
493 493
 				// OR the cached object originally came from the db, so let's just use it's PK for an ID
494
-				$this->_model_relations[$relationName][ $object_to_cache->ID() ] = $object_to_cache;
494
+				$this->_model_relations[$relationName][$object_to_cache->ID()] = $object_to_cache;
495 495
 				$return = $object_to_cache->ID();
496 496
 			} else {
497 497
 				// OR it's a new object with no ID, so just throw it in the array with an auto-incremented ID
498 498
 				$this->_model_relations[$relationName][] = $object_to_cache;
499 499
 				  // move the internal pointer to the end of the array
500
-				end( $this->_model_relations[$relationName] );
500
+				end($this->_model_relations[$relationName]);
501 501
 				// and grab the key so that we can return it
502
-				$return = key( $this->_model_relations[$relationName] );
502
+				$return = key($this->_model_relations[$relationName]);
503 503
 			}
504 504
 
505 505
 		}
@@ -518,11 +518,11 @@  discard block
 block discarded – undo
518 518
 	 * @return void
519 519
 	 * @throws \EE_Error
520 520
 	 */
521
-	protected function _set_cached_property( $fieldname, $value, $cache_type = NULL ) {
521
+	protected function _set_cached_property($fieldname, $value, $cache_type = NULL) {
522 522
 		//first make sure this property exists
523 523
 		$this->get_model()->field_settings_for($fieldname);
524 524
 
525
-		$cache_type = empty( $cache_type ) ? 'standard' : $cache_type;
525
+		$cache_type = empty($cache_type) ? 'standard' : $cache_type;
526 526
 		$this->_cached_properties[$fieldname][$cache_type] = $value;
527 527
 	}
528 528
 
@@ -543,36 +543,36 @@  discard block
 block discarded – undo
543 543
 	 * @return mixed                   whatever the value for the property is we're retrieving
544 544
 	 * @throws \EE_Error
545 545
 	 */
546
-	protected function _get_cached_property( $fieldname, $pretty = FALSE, $extra_cache_ref = NULL ) {
546
+	protected function _get_cached_property($fieldname, $pretty = FALSE, $extra_cache_ref = NULL) {
547 547
 		//verify the field exists
548 548
 		$this->get_model()->field_settings_for($fieldname);
549 549
 
550 550
 		$cache_type = $pretty ? 'pretty' : 'standard';
551
-		$cache_type .= !empty( $extra_cache_ref ) ? '_' . $extra_cache_ref : '';
551
+		$cache_type .= ! empty($extra_cache_ref) ? '_'.$extra_cache_ref : '';
552 552
 
553
-		if ( isset( $this->_cached_properties[$fieldname][$cache_type] ) ) {
553
+		if (isset($this->_cached_properties[$fieldname][$cache_type])) {
554 554
 			return $this->_cached_properties[$fieldname][$cache_type];
555 555
 		}
556 556
 
557 557
 		$field_obj = $this->get_model()->field_settings_for($fieldname);
558
-		if ( $field_obj instanceof EE_Model_Field_Base ) {
558
+		if ($field_obj instanceof EE_Model_Field_Base) {
559 559
 			/**
560 560
 			 * maybe this is EE_Datetime_Field.  If so we need to make sure timezone and
561 561
 			 * formats are correct.
562 562
 			 */
563
-			if ( $field_obj instanceof EE_Datetime_Field ) {
564
-				$field_obj->set_timezone( $this->_timezone );
565
-				$field_obj->set_date_format( $this->_dt_frmt, $pretty );
566
-				$field_obj->set_time_format( $this->_tm_frmt, $pretty );
563
+			if ($field_obj instanceof EE_Datetime_Field) {
564
+				$field_obj->set_timezone($this->_timezone);
565
+				$field_obj->set_date_format($this->_dt_frmt, $pretty);
566
+				$field_obj->set_time_format($this->_tm_frmt, $pretty);
567 567
 			}
568 568
 
569
-			if( ! isset($this->_fields[$fieldname])){
569
+			if ( ! isset($this->_fields[$fieldname])) {
570 570
 				$this->_fields[$fieldname] = NULL;
571 571
 			}
572 572
 			$value = $pretty
573 573
 				? $field_obj->prepare_for_pretty_echoing($this->_fields[$fieldname], $extra_cache_ref)
574
-				: $field_obj->prepare_for_get($this->_fields[$fieldname] );
575
-			$this->_set_cached_property( $fieldname, $value, $cache_type );
574
+				: $field_obj->prepare_for_get($this->_fields[$fieldname]);
575
+			$this->_set_cached_property($fieldname, $value, $cache_type);
576 576
 			return $value;
577 577
 		}
578 578
 		return null;
@@ -598,9 +598,9 @@  discard block
 block discarded – undo
598 598
 	 * @param  string $property_name the property to remove if it exists (from the _cached_properties array)
599 599
 	 * @return void
600 600
 	 */
601
-	protected function _clear_cached_property( $property_name ) {
602
-		if ( isset( $this->_cached_properties[ $property_name ] ) ) {
603
-			unset( $this->_cached_properties[ $property_name ] );
601
+	protected function _clear_cached_property($property_name) {
602
+		if (isset($this->_cached_properties[$property_name])) {
603
+			unset($this->_cached_properties[$property_name]);
604 604
 		}
605 605
 	}
606 606
 
@@ -614,12 +614,12 @@  discard block
 block discarded – undo
614 614
 	 * @return EE_Base_Class
615 615
 	 * @throws \EE_Error
616 616
 	 */
617
-	protected function ensure_related_thing_is_model_obj($object_or_id,$model_name){
617
+	protected function ensure_related_thing_is_model_obj($object_or_id, $model_name) {
618 618
 		$other_model_instance = self::_get_model_instance_with_name(
619
-			self::_get_model_classname( $model_name ),
619
+			self::_get_model_classname($model_name),
620 620
 			$this->_timezone
621 621
 		);
622
-		return $other_model_instance->ensure_is_obj( $object_or_id );
622
+		return $other_model_instance->ensure_is_obj($object_or_id);
623 623
 	}
624 624
 
625 625
 
@@ -636,32 +636,32 @@  discard block
 block discarded – undo
636 636
 	 * @throws EE_Error
637 637
 	 * @return EE_Base_Class | boolean from which was cleared from the cache, or true if we requested to remove a relation from all
638 638
 	 */
639
-	public function clear_cache($relationName, $object_to_remove_or_index_into_array = NULL, $clear_all = FALSE){
639
+	public function clear_cache($relationName, $object_to_remove_or_index_into_array = NULL, $clear_all = FALSE) {
640 640
 		$relationship_to_model = $this->get_model()->related_settings_for($relationName);
641 641
 		$index_in_cache = '';
642
-		if( ! $relationship_to_model){
642
+		if ( ! $relationship_to_model) {
643 643
 			throw new EE_Error(
644 644
 				sprintf(
645
-					__( "There is no relationship to %s on a %s. Cannot clear that cache", 'event_espresso' ),
645
+					__("There is no relationship to %s on a %s. Cannot clear that cache", 'event_espresso'),
646 646
 					$relationName,
647
-					get_class( $this )
647
+					get_class($this)
648 648
 				)
649 649
 			);
650 650
 		}
651
-		if($clear_all){
651
+		if ($clear_all) {
652 652
 			$obj_removed = true;
653 653
 			$this->_model_relations[$relationName]  = null;
654
-		}elseif($relationship_to_model instanceof EE_Belongs_To_Relation){
654
+		}elseif ($relationship_to_model instanceof EE_Belongs_To_Relation) {
655 655
 			$obj_removed = $this->_model_relations[$relationName];
656 656
 			$this->_model_relations[$relationName]  = null;
657
-		}else{
658
-			if($object_to_remove_or_index_into_array instanceof EE_Base_Class && $object_to_remove_or_index_into_array->ID()){
657
+		} else {
658
+			if ($object_to_remove_or_index_into_array instanceof EE_Base_Class && $object_to_remove_or_index_into_array->ID()) {
659 659
 				$index_in_cache = $object_to_remove_or_index_into_array->ID();
660
-				if( is_array($this->_model_relations[$relationName]) && ! isset($this->_model_relations[$relationName][$index_in_cache])){
660
+				if (is_array($this->_model_relations[$relationName]) && ! isset($this->_model_relations[$relationName][$index_in_cache])) {
661 661
 					$index_found_at = NULL;
662 662
 					//find this object in the array even though it has a different key
663
-					foreach($this->_model_relations[$relationName] as $index=>$obj){
664
-						if(
663
+					foreach ($this->_model_relations[$relationName] as $index=>$obj) {
664
+						if (
665 665
 							$obj instanceof EE_Base_Class
666 666
 							&& (
667 667
 								$obj == $object_to_remove_or_index_into_array
@@ -672,34 +672,34 @@  discard block
 block discarded – undo
672 672
 							break;
673 673
 						}
674 674
 					}
675
-					if($index_found_at){
675
+					if ($index_found_at) {
676 676
 						$index_in_cache = $index_found_at;
677
-					}else{
677
+					} else {
678 678
 						//it wasn't found. huh. well obviously it doesn't need to be removed from teh cache
679 679
 						//if it wasn't in it to begin with. So we're done
680 680
 						return $object_to_remove_or_index_into_array;
681 681
 					}
682 682
 				}
683
-			}elseif($object_to_remove_or_index_into_array instanceof EE_Base_Class){
683
+			}elseif ($object_to_remove_or_index_into_array instanceof EE_Base_Class) {
684 684
 				//so they provided a model object, but it's not yet saved to the DB... so let's go hunting for it!
685
-				foreach($this->get_all_from_cache($relationName) as $index => $potentially_obj_we_want){
686
-					if($potentially_obj_we_want == $object_to_remove_or_index_into_array){
685
+				foreach ($this->get_all_from_cache($relationName) as $index => $potentially_obj_we_want) {
686
+					if ($potentially_obj_we_want == $object_to_remove_or_index_into_array) {
687 687
 						$index_in_cache = $index;
688 688
 					}
689 689
 				}
690
-			}else{
690
+			} else {
691 691
 				$index_in_cache = $object_to_remove_or_index_into_array;
692 692
 			}
693 693
 			//supposedly we've found it. But it could just be that the client code
694 694
 			//provided a bad index/object
695 695
 			if (
696 696
 				isset(
697
-					$this->_model_relations[ $relationName ],
698
-					$this->_model_relations[ $relationName ][ $index_in_cache ]
697
+					$this->_model_relations[$relationName],
698
+					$this->_model_relations[$relationName][$index_in_cache]
699 699
 				)
700 700
 			) {
701
-				$obj_removed = $this->_model_relations[ $relationName ][ $index_in_cache ];
702
-				unset( $this->_model_relations[ $relationName ][ $index_in_cache ] );
701
+				$obj_removed = $this->_model_relations[$relationName][$index_in_cache];
702
+				unset($this->_model_relations[$relationName][$index_in_cache]);
703 703
 			} else {
704 704
 				//that thing was never cached anyways.
705 705
 				$obj_removed = null;
@@ -720,24 +720,24 @@  discard block
 block discarded – undo
720 720
 	 * @return boolean TRUE on success, FALSE on fail
721 721
 	 * @throws \EE_Error
722 722
 	 */
723
-	public function update_cache_after_object_save( $relationName, EE_Base_Class $newly_saved_object, $current_cache_id = '') {
723
+	public function update_cache_after_object_save($relationName, EE_Base_Class $newly_saved_object, $current_cache_id = '') {
724 724
 		// verify that incoming object is of the correct type
725
-		$obj_class = 'EE_' . $relationName;
726
-		if ( $newly_saved_object instanceof $obj_class ) {
725
+		$obj_class = 'EE_'.$relationName;
726
+		if ($newly_saved_object instanceof $obj_class) {
727 727
 			/* @type EE_Base_Class $newly_saved_object*/
728 728
 			// now get the type of relation
729
-			$relationship_to_model = $this->get_model()->related_settings_for( $relationName );
729
+			$relationship_to_model = $this->get_model()->related_settings_for($relationName);
730 730
 			// if this is a 1:1 relationship
731
-			if( $relationship_to_model instanceof EE_Belongs_To_Relation ) {
731
+			if ($relationship_to_model instanceof EE_Belongs_To_Relation) {
732 732
 				// then just replace the cached object with the newly saved object
733 733
 				$this->_model_relations[$relationName] = $newly_saved_object;
734 734
 				return TRUE;
735 735
 			// or if it's some kind of sordid feral polyamorous relationship...
736
-			} elseif ( is_array( $this->_model_relations[$relationName] ) && isset( $this->_model_relations[$relationName][ $current_cache_id ] )) {
736
+			} elseif (is_array($this->_model_relations[$relationName]) && isset($this->_model_relations[$relationName][$current_cache_id])) {
737 737
 				// then remove the current cached item
738
-				unset( $this->_model_relations[$relationName][ $current_cache_id ] );
738
+				unset($this->_model_relations[$relationName][$current_cache_id]);
739 739
 				// and cache the newly saved object using it's new ID
740
-				$this->_model_relations[$relationName][ $newly_saved_object->ID() ] = $newly_saved_object;
740
+				$this->_model_relations[$relationName][$newly_saved_object->ID()] = $newly_saved_object;
741 741
 				return TRUE;
742 742
 			}
743 743
 		}
@@ -753,11 +753,11 @@  discard block
 block discarded – undo
753 753
 	 * @param string $relationName
754 754
 	 * @return EE_Base_Class
755 755
 	 */
756
-	public function get_one_from_cache($relationName){
757
-		$cached_array_or_object = isset( $this->_model_relations[$relationName] ) ? $this->_model_relations[$relationName] : null;
758
-		if(is_array($cached_array_or_object)){
756
+	public function get_one_from_cache($relationName) {
757
+		$cached_array_or_object = isset($this->_model_relations[$relationName]) ? $this->_model_relations[$relationName] : null;
758
+		if (is_array($cached_array_or_object)) {
759 759
 			return array_shift($cached_array_or_object);
760
-		}else{
760
+		} else {
761 761
 			return $cached_array_or_object;
762 762
 		}
763 763
 	}
@@ -772,23 +772,23 @@  discard block
 block discarded – undo
772 772
 	 * @throws \EE_Error
773 773
 	 * @return EE_Base_Class[] NOT necessarily indexed by primary keys
774 774
 	 */
775
-	public function get_all_from_cache($relationName){
776
-		$objects = isset( $this->_model_relations[$relationName] ) ? $this->_model_relations[$relationName] : array();
775
+	public function get_all_from_cache($relationName) {
776
+		$objects = isset($this->_model_relations[$relationName]) ? $this->_model_relations[$relationName] : array();
777 777
 		// if the result is not an array, but exists, make it an array
778
-		$objects = is_array( $objects ) ? $objects : array( $objects );
778
+		$objects = is_array($objects) ? $objects : array($objects);
779 779
 		//bugfix for https://events.codebasehq.com/projects/event-espresso/tickets/7143
780 780
 		//basically, if this model object was stored in the session, and these cached model objects
781 781
 		//already have IDs, let's make sure they're in their model's entity mapper
782 782
 		//otherwise we will have duplicates next time we call
783 783
 		// EE_Registry::instance()->load_model( $relationName )->get_one_by_ID( $result->ID() );
784
-		$model = EE_Registry::instance()->load_model( $relationName );
785
-		foreach( $objects as $model_object ){
786
-			if( $model instanceof EEM_Base && $model_object instanceof EE_Base_Class ){
784
+		$model = EE_Registry::instance()->load_model($relationName);
785
+		foreach ($objects as $model_object) {
786
+			if ($model instanceof EEM_Base && $model_object instanceof EE_Base_Class) {
787 787
 				//ensure its in the map if it has an ID; otherwise it will be added to the map when its saved
788
-				if( $model_object->ID() ){
789
-					$model->add_to_entity_map( $model_object );
788
+				if ($model_object->ID()) {
789
+					$model->add_to_entity_map($model_object);
790 790
 				}
791
-			}else{
791
+			} else {
792 792
 				throw new EE_Error(
793 793
 					sprintf(
794 794
 						__(
@@ -796,7 +796,7 @@  discard block
 block discarded – undo
796 796
 							'event_espresso'
797 797
 						),
798 798
 						$relationName,
799
-						gettype( $model_object )
799
+						gettype($model_object)
800 800
 					)
801 801
 				);
802 802
 			}
@@ -818,15 +818,15 @@  discard block
 block discarded – undo
818 818
 	 * @return array|EE_Base_Class[]
819 819
 	 * @throws \EE_Error
820 820
 	 */
821
-	public function next_x( $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) {
822
-		$field = empty( $field_to_order_by ) && $this->get_model()->has_primary_key_field()
821
+	public function next_x($field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) {
822
+		$field = empty($field_to_order_by) && $this->get_model()->has_primary_key_field()
823 823
 			? $this->get_model()->get_primary_key_field()->get_name()
824 824
 			: $field_to_order_by;
825
-		$current_value = ! empty( $field ) ? $this->get( $field ) : null;
826
-		if ( empty( $field ) || empty( $current_value ) ) {
825
+		$current_value = ! empty($field) ? $this->get($field) : null;
826
+		if (empty($field) || empty($current_value)) {
827 827
 			return array();
828 828
 		}
829
-		return $this->get_model()->next_x( $current_value, $field, $limit, $query_params, $columns_to_select );
829
+		return $this->get_model()->next_x($current_value, $field, $limit, $query_params, $columns_to_select);
830 830
 	}
831 831
 
832 832
 
@@ -843,15 +843,15 @@  discard block
 block discarded – undo
843 843
 	 * @return array|EE_Base_Class[]
844 844
 	 * @throws \EE_Error
845 845
 	 */
846
-	public function previous_x( $field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null ) {
847
-		$field = empty( $field_to_order_by ) && $this->get_model()->has_primary_key_field()
846
+	public function previous_x($field_to_order_by = null, $limit = 1, $query_params = array(), $columns_to_select = null) {
847
+		$field = empty($field_to_order_by) && $this->get_model()->has_primary_key_field()
848 848
 			? $this->get_model()->get_primary_key_field()->get_name()
849 849
 			: $field_to_order_by;
850
-		$current_value = ! empty( $field ) ? $this->get( $field ) : null;
851
-		if ( empty( $field ) || empty( $current_value ) ) {
850
+		$current_value = ! empty($field) ? $this->get($field) : null;
851
+		if (empty($field) || empty($current_value)) {
852 852
 			return array();
853 853
 		}
854
-		return $this->get_model()->previous_x( $current_value, $field, $limit, $query_params, $columns_to_select );
854
+		return $this->get_model()->previous_x($current_value, $field, $limit, $query_params, $columns_to_select);
855 855
 	}
856 856
 
857 857
 
@@ -867,15 +867,15 @@  discard block
 block discarded – undo
867 867
 	 * @return array|EE_Base_Class
868 868
 	 * @throws \EE_Error
869 869
 	 */
870
-	public function next( $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) {
871
-		$field = empty( $field_to_order_by ) && $this->get_model()->has_primary_key_field()
870
+	public function next($field_to_order_by = null, $query_params = array(), $columns_to_select = null) {
871
+		$field = empty($field_to_order_by) && $this->get_model()->has_primary_key_field()
872 872
 			? $this->get_model()->get_primary_key_field()->get_name()
873 873
 			: $field_to_order_by;
874
-		$current_value = ! empty( $field ) ? $this->get( $field ) : null;
875
-		if ( empty( $field ) || empty( $current_value ) ) {
874
+		$current_value = ! empty($field) ? $this->get($field) : null;
875
+		if (empty($field) || empty($current_value)) {
876 876
 			return array();
877 877
 		}
878
-		return $this->get_model()->next( $current_value, $field, $query_params, $columns_to_select );
878
+		return $this->get_model()->next($current_value, $field, $query_params, $columns_to_select);
879 879
 	}
880 880
 
881 881
 
@@ -891,15 +891,15 @@  discard block
 block discarded – undo
891 891
 	 * @return array|EE_Base_Class
892 892
 	 * @throws \EE_Error
893 893
 	 */
894
-	public function previous( $field_to_order_by = null, $query_params = array(), $columns_to_select = null ) {
895
-		$field = empty( $field_to_order_by ) && $this->get_model()->has_primary_key_field()
894
+	public function previous($field_to_order_by = null, $query_params = array(), $columns_to_select = null) {
895
+		$field = empty($field_to_order_by) && $this->get_model()->has_primary_key_field()
896 896
 			? $this->get_model()->get_primary_key_field()->get_name()
897 897
 			: $field_to_order_by;
898
-		$current_value = ! empty( $field ) ? $this->get( $field ) : null;
899
-		if ( empty( $field ) || empty( $current_value ) ) {
898
+		$current_value = ! empty($field) ? $this->get($field) : null;
899
+		if (empty($field) || empty($current_value)) {
900 900
 			return array();
901 901
 		}
902
-		return $this->get_model()->previous( $current_value, $field, $query_params, $columns_to_select );
902
+		return $this->get_model()->previous($current_value, $field, $query_params, $columns_to_select);
903 903
 	}
904 904
 
905 905
 
@@ -912,25 +912,25 @@  discard block
 block discarded – undo
912 912
 	 * @param mixed  $field_value_from_db
913 913
 	 * @throws \EE_Error
914 914
 	 */
915
-	public function set_from_db($field_name,$field_value_from_db){
915
+	public function set_from_db($field_name, $field_value_from_db) {
916 916
 		$field_obj = $this->get_model()->field_settings_for($field_name);
917
-		if ( $field_obj instanceof EE_Model_Field_Base ) {
917
+		if ($field_obj instanceof EE_Model_Field_Base) {
918 918
 			//you would think the DB has no NULLs for non-null label fields right? wrong!
919 919
 			//eg, a CPT model object could have an entry in the posts table, but no
920 920
 			//entry in the meta table. Meaning that all its columns in the meta table
921 921
 			//are null! yikes! so when we find one like that, use defaults for its meta columns
922
-			if($field_value_from_db === NULL ){
923
-				if( $field_obj->is_nullable()){
922
+			if ($field_value_from_db === NULL) {
923
+				if ($field_obj->is_nullable()) {
924 924
 					//if the field allows nulls, then let it be null
925 925
 					$field_value = NULL;
926
-				}else{
926
+				} else {
927 927
 					$field_value = $field_obj->get_default_value();
928 928
 				}
929
-			}else{
930
-				$field_value = $field_obj->prepare_for_set_from_db( $field_value_from_db );
929
+			} else {
930
+				$field_value = $field_obj->prepare_for_set_from_db($field_value_from_db);
931 931
 			}
932 932
 			$this->_fields[$field_name] = $field_value;
933
-			$this->_clear_cached_property( $field_name );
933
+			$this->_clear_cached_property($field_name);
934 934
 		}
935 935
 	}
936 936
 
@@ -946,8 +946,8 @@  discard block
 block discarded – undo
946 946
 	 * @return mixed
947 947
 	 * @throws \EE_Error
948 948
 	 */
949
-	public function get($field_name, $extra_cache_ref = NULL ){
950
-		return $this->_get_cached_property( $field_name, FALSE, $extra_cache_ref );
949
+	public function get($field_name, $extra_cache_ref = NULL) {
950
+		return $this->_get_cached_property($field_name, FALSE, $extra_cache_ref);
951 951
 	}
952 952
 
953 953
 
@@ -980,10 +980,10 @@  discard block
 block discarded – undo
980 980
 	 *                                         just null is returned (because that indicates that likely
981 981
 	 *                                         this field is nullable).
982 982
 	 */
983
-	public function get_DateTime_object( $field_name ) {
984
-		$field_settings = $this->get_model()->field_settings_for( $field_name );
983
+	public function get_DateTime_object($field_name) {
984
+		$field_settings = $this->get_model()->field_settings_for($field_name);
985 985
 
986
-		if ( ! $field_settings instanceof EE_Datetime_Field ) {
986
+		if ( ! $field_settings instanceof EE_Datetime_Field) {
987 987
 			EE_Error::add_error(
988 988
 				sprintf(
989 989
 					__(
@@ -1015,7 +1015,7 @@  discard block
 block discarded – undo
1015 1015
 	 * @return void
1016 1016
 	 * @throws \EE_Error
1017 1017
 	 */
1018
-	public function e($field_name, $extra_cache_ref = NULL){
1018
+	public function e($field_name, $extra_cache_ref = NULL) {
1019 1019
 		echo $this->get_pretty($field_name, $extra_cache_ref);
1020 1020
 	}
1021 1021
 
@@ -1029,8 +1029,8 @@  discard block
 block discarded – undo
1029 1029
 	 * @return void
1030 1030
 	 * @throws \EE_Error
1031 1031
 	 */
1032
-	public function f($field_name){
1033
-		$this->e($field_name,'form_input');
1032
+	public function f($field_name) {
1033
+		$this->e($field_name, 'form_input');
1034 1034
 	}
1035 1035
 
1036 1036
 
@@ -1043,8 +1043,8 @@  discard block
 block discarded – undo
1043 1043
 	 * @return mixed
1044 1044
 	 * @throws \EE_Error
1045 1045
 	 */
1046
-	public function get_pretty($field_name, $extra_cache_ref = NULL){
1047
-		return  $this->_get_cached_property( $field_name, TRUE, $extra_cache_ref );
1046
+	public function get_pretty($field_name, $extra_cache_ref = NULL) {
1047
+		return  $this->_get_cached_property($field_name, TRUE, $extra_cache_ref);
1048 1048
 	}
1049 1049
 
1050 1050
 
@@ -1062,36 +1062,36 @@  discard block
 block discarded – undo
1062 1062
 	 * @return void | string | bool | EE_Error string on success, FALSE on fail, or EE_Error Exception is thrown if field is not a valid dtt field, or void if echoing
1063 1063
 	 * @throws \EE_Error
1064 1064
 	 */
1065
-	protected function _get_datetime( $field_name, $dt_frmt = NULL, $tm_frmt = NULL, $date_or_time = NULL, $echo = FALSE ) {
1065
+	protected function _get_datetime($field_name, $dt_frmt = NULL, $tm_frmt = NULL, $date_or_time = NULL, $echo = FALSE) {
1066 1066
 
1067
-		$in_dt_frmt = empty($dt_frmt) ? $this->_dt_frmt :  $dt_frmt;
1067
+		$in_dt_frmt = empty($dt_frmt) ? $this->_dt_frmt : $dt_frmt;
1068 1068
 		$in_tm_frmt = empty($tm_frmt) ? $this->_tm_frmt : $tm_frmt;
1069 1069
 
1070 1070
 		//validate field for datetime and returns field settings if valid.
1071
-		$field = $this->_get_dtt_field_settings( $field_name );
1071
+		$field = $this->_get_dtt_field_settings($field_name);
1072 1072
 
1073 1073
 		//clear cached property if either formats are not null.
1074
-		if( $dt_frmt !== null || $tm_frmt !== null ) {
1075
-			$this->_clear_cached_property( $field_name );
1074
+		if ($dt_frmt !== null || $tm_frmt !== null) {
1075
+			$this->_clear_cached_property($field_name);
1076 1076
 			//reset format properties because they are used in get()
1077 1077
 			$this->_dt_frmt = $in_dt_frmt;
1078 1078
 			$this->_tm_frmt = $in_tm_frmt;
1079 1079
 		}
1080
-		if ( $echo ) {
1081
-			$field->set_pretty_date_format( $in_dt_frmt );
1080
+		if ($echo) {
1081
+			$field->set_pretty_date_format($in_dt_frmt);
1082 1082
 		} else {
1083
-			$field->set_date_format( $in_dt_frmt );
1083
+			$field->set_date_format($in_dt_frmt);
1084 1084
 		}
1085
-		if ( $echo ) {
1086
-			$field->set_pretty_time_format( $in_tm_frmt );
1085
+		if ($echo) {
1086
+			$field->set_pretty_time_format($in_tm_frmt);
1087 1087
 		} else {
1088
-			$field->set_time_format( $in_tm_frmt );
1088
+			$field->set_time_format($in_tm_frmt);
1089 1089
 		}
1090 1090
 		//set timezone in field object
1091
-		$field->set_timezone( $this->_timezone );
1091
+		$field->set_timezone($this->_timezone);
1092 1092
 
1093 1093
 		//set the output returned
1094
-		switch ( $date_or_time ) {
1094
+		switch ($date_or_time) {
1095 1095
 
1096 1096
 			case 'D' :
1097 1097
 				$field->set_date_time_output('date');
@@ -1106,11 +1106,11 @@  discard block
 block discarded – undo
1106 1106
 		}
1107 1107
 
1108 1108
 
1109
-		if ( $echo ) {
1110
-			$this->e( $field_name, $date_or_time );
1109
+		if ($echo) {
1110
+			$this->e($field_name, $date_or_time);
1111 1111
 			return '';
1112 1112
 		 }
1113
-		return $this->get( $field_name, $date_or_time );
1113
+		return $this->get($field_name, $date_or_time);
1114 1114
 	}
1115 1115
 
1116 1116
 
@@ -1123,8 +1123,8 @@  discard block
 block discarded – undo
1123 1123
 	 * @return string            datetime value formatted
1124 1124
 	 * @throws \EE_Error
1125 1125
 	 */
1126
-	public function get_date( $field_name, $format = NULL ) {
1127
-		return $this->_get_datetime( $field_name, $format, NULL, 'D' );
1126
+	public function get_date($field_name, $format = NULL) {
1127
+		return $this->_get_datetime($field_name, $format, NULL, 'D');
1128 1128
 	}
1129 1129
 
1130 1130
 
@@ -1134,8 +1134,8 @@  discard block
 block discarded – undo
1134 1134
 	 * @param null $format
1135 1135
 	 * @throws \EE_Error
1136 1136
 	 */
1137
-	public function e_date( $field_name, $format = NULL ) {
1138
-		$this->_get_datetime( $field_name, $format, NULL, 'D', TRUE );
1137
+	public function e_date($field_name, $format = NULL) {
1138
+		$this->_get_datetime($field_name, $format, NULL, 'D', TRUE);
1139 1139
 	}
1140 1140
 
1141 1141
 
@@ -1148,8 +1148,8 @@  discard block
 block discarded – undo
1148 1148
 	 * @return string             datetime value formatted
1149 1149
 	 * @throws \EE_Error
1150 1150
 	 */
1151
-	public function get_time( $field_name, $format = NULL ) {
1152
-		return $this->_get_datetime( $field_name, NULL, $format, 'T' );
1151
+	public function get_time($field_name, $format = NULL) {
1152
+		return $this->_get_datetime($field_name, NULL, $format, 'T');
1153 1153
 	}
1154 1154
 
1155 1155
 
@@ -1159,8 +1159,8 @@  discard block
 block discarded – undo
1159 1159
 	 * @param null $format
1160 1160
 	 * @throws \EE_Error
1161 1161
 	 */
1162
-	public function e_time( $field_name, $format = NULL ) {
1163
-		$this->_get_datetime( $field_name, NULL, $format, 'T', TRUE );
1162
+	public function e_time($field_name, $format = NULL) {
1163
+		$this->_get_datetime($field_name, NULL, $format, 'T', TRUE);
1164 1164
 	}
1165 1165
 
1166 1166
 
@@ -1174,8 +1174,8 @@  discard block
 block discarded – undo
1174 1174
 	 * @return string             datetime value formatted
1175 1175
 	 * @throws \EE_Error
1176 1176
 	 */
1177
-	public function get_datetime( $field_name, $dt_frmt = NULL, $tm_frmt = NULL ) {
1178
-		return $this->_get_datetime( $field_name, $dt_frmt, $tm_frmt );
1177
+	public function get_datetime($field_name, $dt_frmt = NULL, $tm_frmt = NULL) {
1178
+		return $this->_get_datetime($field_name, $dt_frmt, $tm_frmt);
1179 1179
 	}
1180 1180
 
1181 1181
 
@@ -1186,8 +1186,8 @@  discard block
 block discarded – undo
1186 1186
 	 * @param null $tm_frmt
1187 1187
 	 * @throws \EE_Error
1188 1188
 	 */
1189
-	public function e_datetime( $field_name, $dt_frmt = NULL, $tm_frmt = NULL ) {
1190
-		$this->_get_datetime( $field_name, $dt_frmt, $tm_frmt, NULL, TRUE);
1189
+	public function e_datetime($field_name, $dt_frmt = NULL, $tm_frmt = NULL) {
1190
+		$this->_get_datetime($field_name, $dt_frmt, $tm_frmt, NULL, TRUE);
1191 1191
 	}
1192 1192
 
1193 1193
 
@@ -1201,11 +1201,11 @@  discard block
 block discarded – undo
1201 1201
 	 * @throws \EE_Error
1202 1202
 	 *                           field name.
1203 1203
 	 */
1204
-	public function get_i18n_datetime( $field_name, $format = NULL ) {
1205
-		$format = empty( $format ) ? $this->_dt_frmt . ' ' . $this->_tm_frmt : $format;
1204
+	public function get_i18n_datetime($field_name, $format = NULL) {
1205
+		$format = empty($format) ? $this->_dt_frmt.' '.$this->_tm_frmt : $format;
1206 1206
 		return date_i18n(
1207 1207
 			$format,
1208
-			EEH_DTT_Helper::get_timestamp_with_offset( $this->get_raw( $field_name ), $this->_timezone )
1208
+			EEH_DTT_Helper::get_timestamp_with_offset($this->get_raw($field_name), $this->_timezone)
1209 1209
 		);
1210 1210
 	}
1211 1211
 
@@ -1218,14 +1218,14 @@  discard block
 block discarded – undo
1218 1218
 	 * @throws EE_Error
1219 1219
 	 * @return EE_Datetime_Field
1220 1220
 	 */
1221
-	protected function _get_dtt_field_settings( $field_name ) {
1221
+	protected function _get_dtt_field_settings($field_name) {
1222 1222
 		$field = $this->get_model()->field_settings_for($field_name);
1223 1223
 
1224 1224
 		//check if field is dtt
1225
-		if ( $field instanceof EE_Datetime_Field ) {
1225
+		if ($field instanceof EE_Datetime_Field) {
1226 1226
 			return $field;
1227 1227
 		} else {
1228
-			throw new EE_Error( sprintf( __('The field name "%s" has been requested for the EE_Base_Class datetime functions and it is not a valid EE_Datetime_Field.  Please check the spelling of the field and make sure it has been setup as a EE_Datetime_Field in the %s model constructor', 'event_espresso'), $field_name, self::_get_model_classname( get_class($this) ) ) );
1228
+			throw new EE_Error(sprintf(__('The field name "%s" has been requested for the EE_Base_Class datetime functions and it is not a valid EE_Datetime_Field.  Please check the spelling of the field and make sure it has been setup as a EE_Datetime_Field in the %s model constructor', 'event_espresso'), $field_name, self::_get_model_classname(get_class($this))));
1229 1229
 		}
1230 1230
 	}
1231 1231
 
@@ -1246,8 +1246,8 @@  discard block
 block discarded – undo
1246 1246
 	 * @param string          $fieldname the name of the field the time is being set on (must match a EE_Datetime_Field)
1247 1247
 	 * @throws \EE_Error
1248 1248
 	 */
1249
-	protected function _set_time_for( $time, $fieldname ) {
1250
-		$this->_set_date_time( 'T', $time, $fieldname );
1249
+	protected function _set_time_for($time, $fieldname) {
1250
+		$this->_set_date_time('T', $time, $fieldname);
1251 1251
 	}
1252 1252
 
1253 1253
 
@@ -1260,8 +1260,8 @@  discard block
 block discarded – undo
1260 1260
 	 * @param string          $fieldname the name of the field the date is being set on (must match a EE_Datetime_Field)
1261 1261
 	 * @throws \EE_Error
1262 1262
 	 */
1263
-	protected function _set_date_for( $date, $fieldname ) {
1264
-		$this->_set_date_time( 'D', $date, $fieldname );
1263
+	protected function _set_date_for($date, $fieldname) {
1264
+		$this->_set_date_time('D', $date, $fieldname);
1265 1265
 	}
1266 1266
 
1267 1267
 
@@ -1275,26 +1275,26 @@  discard block
 block discarded – undo
1275 1275
 	 * @param string          $fieldname      the name of the field the date OR time is being set on (must match a EE_Datetime_Field property)
1276 1276
 	 * @throws \EE_Error
1277 1277
 	 */
1278
-	protected function _set_date_time( $what = 'T', $datetime_value, $fieldname ) {
1279
-		$field = $this->_get_dtt_field_settings( $fieldname );
1280
-		$field->set_timezone( $this->_timezone );
1281
-		$field->set_date_format( $this->_dt_frmt );
1282
-		$field->set_time_format( $this->_tm_frmt );
1283
-		switch ( $what ) {
1278
+	protected function _set_date_time($what = 'T', $datetime_value, $fieldname) {
1279
+		$field = $this->_get_dtt_field_settings($fieldname);
1280
+		$field->set_timezone($this->_timezone);
1281
+		$field->set_date_format($this->_dt_frmt);
1282
+		$field->set_time_format($this->_tm_frmt);
1283
+		switch ($what) {
1284 1284
 			case 'T' :
1285
-				$this->_fields[ $fieldname ] = $field->prepare_for_set_with_new_time(
1285
+				$this->_fields[$fieldname] = $field->prepare_for_set_with_new_time(
1286 1286
 					$datetime_value,
1287
-					$this->_fields[ $fieldname ]
1287
+					$this->_fields[$fieldname]
1288 1288
 				);
1289 1289
 				break;
1290 1290
 			case 'D' :
1291
-				$this->_fields[ $fieldname ] = $field->prepare_for_set_with_new_date(
1291
+				$this->_fields[$fieldname] = $field->prepare_for_set_with_new_date(
1292 1292
 					$datetime_value,
1293
-					$this->_fields[ $fieldname ]
1293
+					$this->_fields[$fieldname]
1294 1294
 				);
1295 1295
 				break;
1296 1296
 			case 'B' :
1297
-				$this->_fields[ $fieldname ] = $field->prepare_for_set( $datetime_value );
1297
+				$this->_fields[$fieldname] = $field->prepare_for_set($datetime_value);
1298 1298
 				break;
1299 1299
 		}
1300 1300
 		$this->_clear_cached_property($fieldname);
@@ -1316,17 +1316,17 @@  discard block
 block discarded – undo
1316 1316
 	 * @throws EE_Error
1317 1317
 	 * @return string timestamp
1318 1318
 	 */
1319
-	public function display_in_my_timezone( $field_name, $callback = 'get_datetime', $args = NULL, $prepend = '', $append = '' ) {
1319
+	public function display_in_my_timezone($field_name, $callback = 'get_datetime', $args = NULL, $prepend = '', $append = '') {
1320 1320
 		$timezone = EEH_DTT_Helper::get_timezone();
1321
-		if ( $timezone === $this->_timezone ) {
1321
+		if ($timezone === $this->_timezone) {
1322 1322
 			return '';
1323 1323
 		}
1324 1324
 		$original_timezone = $this->_timezone;
1325
-		$this->set_timezone( $timezone );
1325
+		$this->set_timezone($timezone);
1326 1326
 
1327 1327
 		$fn = (array) $field_name;
1328
-		$args = array_merge( $fn, (array) $args );
1329
-		if ( ! method_exists( $this, $callback ) ) {
1328
+		$args = array_merge($fn, (array) $args);
1329
+		if ( ! method_exists($this, $callback)) {
1330 1330
 			throw new EE_Error(
1331 1331
 				sprintf(
1332 1332
 					__(
@@ -1338,9 +1338,9 @@  discard block
 block discarded – undo
1338 1338
 			);
1339 1339
 		}
1340 1340
 		$args = (array) $args;
1341
-		$return =  $prepend . call_user_func_array( array( $this, $callback ), $args ) . $append;
1341
+		$return = $prepend.call_user_func_array(array($this, $callback), $args).$append;
1342 1342
 
1343
-		$this->set_timezone( $original_timezone );
1343
+		$this->set_timezone($original_timezone);
1344 1344
 		return $return;
1345 1345
 	}
1346 1346
 
@@ -1354,7 +1354,7 @@  discard block
 block discarded – undo
1354 1354
 	 * @return boolean | int
1355 1355
 	 * @throws \EE_Error
1356 1356
 	 */
1357
-	public function delete(){
1357
+	public function delete() {
1358 1358
 		/**
1359 1359
 		 * Called just before the `EE_Base_Class::_delete` method call.
1360 1360
 		 * Note: `EE_Base_Class::_delete` might be overridden by child classes so any client code hooking into these actions
@@ -1363,7 +1363,7 @@  discard block
 block discarded – undo
1363 1363
 		 *
1364 1364
 		 * @param EE_Base_Class $model_object about to be 'deleted'
1365 1365
 		 */
1366
-		do_action( 'AHEE__EE_Base_Class__delete__before', $this );
1366
+		do_action('AHEE__EE_Base_Class__delete__before', $this);
1367 1367
 		$result = $this->_delete();
1368 1368
 		/**
1369 1369
 		 * Called just after the `EE_Base_Class::_delete` method call.
@@ -1373,7 +1373,7 @@  discard block
 block discarded – undo
1373 1373
 		 * @param EE_Base_Class $model_object that was just 'deleted'
1374 1374
 		 * @param boolean $result
1375 1375
 		 */
1376
-		do_action( 'AHEE__EE_Base_Class__delete__end', $this, $result );
1376
+		do_action('AHEE__EE_Base_Class__delete__end', $this, $result);
1377 1377
 		return $result;
1378 1378
 	}
1379 1379
 
@@ -1399,22 +1399,22 @@  discard block
 block discarded – undo
1399 1399
 	 * @return bool | int
1400 1400
 	 * @throws \EE_Error
1401 1401
 	 */
1402
-	public function delete_permanently(){
1402
+	public function delete_permanently() {
1403 1403
 		/**
1404 1404
 		 * Called just before HARD deleting a model object
1405 1405
 		 *
1406 1406
 		 * @param EE_Base_Class $model_object about to be 'deleted'
1407 1407
 		 */
1408
-		do_action( 'AHEE__EE_Base_Class__delete_permanently__before', $this );
1409
-		$model=$this->get_model();
1410
-		$result=$model->delete_permanently_by_ID($this->ID());
1408
+		do_action('AHEE__EE_Base_Class__delete_permanently__before', $this);
1409
+		$model = $this->get_model();
1410
+		$result = $model->delete_permanently_by_ID($this->ID());
1411 1411
 		$this->refresh_cache_of_related_objects();
1412 1412
 		/**
1413 1413
 		 * Called just after HARD deleting a model object
1414 1414
 		 * @param EE_Base_Class $model_object that was just 'deleted'
1415 1415
 		 * @param boolean $result
1416 1416
 		 */
1417
-		do_action( 'AHEE__EE_Base_Class__delete_permanently__end', $this, $result );
1417
+		do_action('AHEE__EE_Base_Class__delete_permanently__end', $this, $result);
1418 1418
 		return $result;
1419 1419
 	}
1420 1420
 
@@ -1427,18 +1427,18 @@  discard block
 block discarded – undo
1427 1427
 	 * @throws \EE_Error
1428 1428
 	 */
1429 1429
         public function refresh_cache_of_related_objects() {
1430
-            foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ) {
1431
-                if( ! empty( $this->_model_relations[ $relation_name ] ) ) {
1432
-                    $related_objects = $this->_model_relations[ $relation_name ];
1433
-                    if( $relation_obj instanceof EE_Belongs_To_Relation ) {
1430
+            foreach ($this->get_model()->relation_settings() as $relation_name => $relation_obj) {
1431
+                if ( ! empty($this->_model_relations[$relation_name])) {
1432
+                    $related_objects = $this->_model_relations[$relation_name];
1433
+                    if ($relation_obj instanceof EE_Belongs_To_Relation) {
1434 1434
                         //this relation only stores a single model object, not an array
1435 1435
                         //but let's make it consistent
1436
-                        $related_objects = array( $related_objects );
1436
+                        $related_objects = array($related_objects);
1437 1437
                     }
1438
-                    foreach( $related_objects as $related_object ) {
1438
+                    foreach ($related_objects as $related_object) {
1439 1439
                         //only refresh their cache if they're in memory
1440
-                        if( $related_object instanceof EE_Base_Class ) {
1441
-							$related_object->clear_cache( $this->get_model()->get_this_model_name(), $this );
1440
+                        if ($related_object instanceof EE_Base_Class) {
1441
+							$related_object->clear_cache($this->get_model()->get_this_model_name(), $this);
1442 1442
                         }
1443 1443
                     }
1444 1444
                 }
@@ -1458,17 +1458,17 @@  discard block
 block discarded – undo
1458 1458
 	 * @return int , 1 on a successful update, the ID of the new entry on insert; 0 on failure or if the model object
1459 1459
 	 * isn't allowed to persist (as determined by EE_Base_Class::allow_persist())
1460 1460
 	 */
1461
-	public function save($set_cols_n_values=array()) {
1461
+	public function save($set_cols_n_values = array()) {
1462 1462
 		/**
1463 1463
 		 * Filters the fields we're about to save on the model object
1464 1464
 		 *
1465 1465
 		 * @param array $set_cols_n_values
1466 1466
 		 * @param EE_Base_Class $model_object
1467 1467
 		 */
1468
-		$set_cols_n_values = (array)apply_filters( 'FHEE__EE_Base_Class__save__set_cols_n_values', $set_cols_n_values, $this  );
1468
+		$set_cols_n_values = (array) apply_filters('FHEE__EE_Base_Class__save__set_cols_n_values', $set_cols_n_values, $this);
1469 1469
 		//set attributes as provided in $set_cols_n_values
1470
-		foreach($set_cols_n_values as $column=>$value){
1471
-			$this->set($column,$value);
1470
+		foreach ($set_cols_n_values as $column=>$value) {
1471
+			$this->set($column, $value);
1472 1472
 		}
1473 1473
 		/**
1474 1474
 		 * Saving a model object.
@@ -1476,8 +1476,8 @@  discard block
 block discarded – undo
1476 1476
 		 * Before we perform a save, this action is fired.
1477 1477
 		 * @param EE_Base_Class $model_object the model object about to be saved.
1478 1478
 		 */
1479
-		do_action( 'AHEE__EE_Base_Class__save__begin', $this );
1480
-		if( ! $this->allow_persist() ) {
1479
+		do_action('AHEE__EE_Base_Class__save__begin', $this);
1480
+		if ( ! $this->allow_persist()) {
1481 1481
 			return 0;
1482 1482
 		}
1483 1483
 		//now get current attribute values
@@ -1487,61 +1487,61 @@  discard block
 block discarded – undo
1487 1487
 		$old_assumption_concerning_value_preparation = $this->get_model()->get_assumption_concerning_values_already_prepared_by_model_object();
1488 1488
 		$this->get_model()->assume_values_already_prepared_by_model_object(true);
1489 1489
 		//does this model have an autoincrement PK?
1490
-		if($this->get_model()->has_primary_key_field()){
1491
-			if($this->get_model()->get_primary_key_field()->is_auto_increment()){
1490
+		if ($this->get_model()->has_primary_key_field()) {
1491
+			if ($this->get_model()->get_primary_key_field()->is_auto_increment()) {
1492 1492
 				//ok check if it's set, if so: update; if not, insert
1493
-				if ( ! empty( $save_cols_n_values[self::_get_primary_key_name( get_class($this) )] ) ){
1494
-					$results = $this->get_model()->update_by_ID ( $save_cols_n_values, $this->ID() );
1493
+				if ( ! empty($save_cols_n_values[self::_get_primary_key_name(get_class($this))])) {
1494
+					$results = $this->get_model()->update_by_ID($save_cols_n_values, $this->ID());
1495 1495
 				} else {
1496
-					unset($save_cols_n_values[self::_get_primary_key_name( get_class( $this) )]);
1497
-					$results = $this->get_model()->insert( $save_cols_n_values );
1498
-					if($results){
1496
+					unset($save_cols_n_values[self::_get_primary_key_name(get_class($this))]);
1497
+					$results = $this->get_model()->insert($save_cols_n_values);
1498
+					if ($results) {
1499 1499
 						//if successful, set the primary key
1500 1500
 						//but don't use the normal SET method, because it will check if
1501 1501
 						//an item with the same ID exists in the mapper & db, then
1502 1502
 						//will find it in the db (because we just added it) and THAT object
1503 1503
 						//will get added to the mapper before we can add this one!
1504 1504
 						//but if we just avoid using the SET method, all that headache can be avoided
1505
-						$pk_field_name =self::_get_primary_key_name( get_class($this));
1505
+						$pk_field_name = self::_get_primary_key_name(get_class($this));
1506 1506
 						$this->_fields[$pk_field_name] = $results;
1507 1507
 						$this->_clear_cached_property($pk_field_name);
1508
-						$this->get_model()->add_to_entity_map( $this );
1508
+						$this->get_model()->add_to_entity_map($this);
1509 1509
 						$this->_update_cached_related_model_objs_fks();
1510 1510
 					}
1511 1511
 				}
1512
-			}else{//PK is NOT auto-increment
1512
+			} else {//PK is NOT auto-increment
1513 1513
 				//so check if one like it already exists in the db
1514
-				if( $this->get_model()->exists_by_ID( $this->ID() ) ){
1515
-					if( WP_DEBUG && ! $this->in_entity_map() ){
1514
+				if ($this->get_model()->exists_by_ID($this->ID())) {
1515
+					if (WP_DEBUG && ! $this->in_entity_map()) {
1516 1516
 						throw new EE_Error(
1517 1517
 							sprintf(
1518
-								__( 'Using a model object %1$s that is NOT in the entity map, can lead to unexpected errors. You should either: %4$s 1. Put it in the entity mapper by calling %2$s %4$s 2. Discard this model object and use what is in the entity mapper %4$s 3. Fetch from the database using %3$s', 'event_espresso' ),
1518
+								__('Using a model object %1$s that is NOT in the entity map, can lead to unexpected errors. You should either: %4$s 1. Put it in the entity mapper by calling %2$s %4$s 2. Discard this model object and use what is in the entity mapper %4$s 3. Fetch from the database using %3$s', 'event_espresso'),
1519 1519
 								get_class($this),
1520
-								get_class( $this->get_model() ) . '::instance()->add_to_entity_map()',
1521
-								get_class( $this->get_model() ) . '::instance()->get_one_by_ID()',
1520
+								get_class($this->get_model()).'::instance()->add_to_entity_map()',
1521
+								get_class($this->get_model()).'::instance()->get_one_by_ID()',
1522 1522
 								'<br />'
1523 1523
 							)
1524 1524
 						);
1525 1525
 					}
1526 1526
 					$results = $this->get_model()->update_by_ID($save_cols_n_values, $this->ID());
1527
-				}else{
1527
+				} else {
1528 1528
 					$results = $this->get_model()->insert($save_cols_n_values);
1529 1529
 					$this->_update_cached_related_model_objs_fks();
1530 1530
 				}
1531 1531
 			}
1532
-		}else{//there is NO primary key
1532
+		} else {//there is NO primary key
1533 1533
 			$already_in_db = false;
1534
-			foreach($this->get_model()->unique_indexes() as $index){
1534
+			foreach ($this->get_model()->unique_indexes() as $index) {
1535 1535
 				$uniqueness_where_params = array_intersect_key($save_cols_n_values, $index->fields());
1536
-				if($this->get_model()->exists(array($uniqueness_where_params))){
1536
+				if ($this->get_model()->exists(array($uniqueness_where_params))) {
1537 1537
 					$already_in_db = true;
1538 1538
 				}
1539 1539
 			}
1540
-			if( $already_in_db ){
1541
-				$combined_pk_fields_n_values = array_intersect_key( $save_cols_n_values, $this->get_model()->get_combined_primary_key_fields() );
1542
-				$results = $this->get_model()->update( $save_cols_n_values,$combined_pk_fields_n_values );
1543
-			}else{
1544
-				$results = $this->get_model()->insert( $save_cols_n_values );
1540
+			if ($already_in_db) {
1541
+				$combined_pk_fields_n_values = array_intersect_key($save_cols_n_values, $this->get_model()->get_combined_primary_key_fields());
1542
+				$results = $this->get_model()->update($save_cols_n_values, $combined_pk_fields_n_values);
1543
+			} else {
1544
+				$results = $this->get_model()->insert($save_cols_n_values);
1545 1545
 			}
1546 1546
 		}
1547 1547
 		//restore the old assumption about values being prepared by the model object
@@ -1554,7 +1554,7 @@  discard block
 block discarded – undo
1554 1554
 		 * @param boolean|int $results if it were updated, TRUE or FALSE; if it were newly inserted
1555 1555
 		 * the new ID (or 0 if an error occurred and it wasn't updated)
1556 1556
 		 */
1557
-		do_action( 'AHEE__EE_Base_Class__save__end', $this, $results );
1557
+		do_action('AHEE__EE_Base_Class__save__end', $this, $results);
1558 1558
 		return $results;
1559 1559
 	}
1560 1560
 
@@ -1569,15 +1569,15 @@  discard block
 block discarded – undo
1569 1569
 	 * @return void
1570 1570
 	 * @throws \EE_Error
1571 1571
 	 */
1572
-	protected function _update_cached_related_model_objs_fks(){
1573
-		foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ){
1574
-			if( $relation_obj instanceof EE_Has_Many_Relation ){
1575
-				foreach( $this->get_all_from_cache( $relation_name ) as $related_model_obj_in_cache) {
1572
+	protected function _update_cached_related_model_objs_fks() {
1573
+		foreach ($this->get_model()->relation_settings() as $relation_name => $relation_obj) {
1574
+			if ($relation_obj instanceof EE_Has_Many_Relation) {
1575
+				foreach ($this->get_all_from_cache($relation_name) as $related_model_obj_in_cache) {
1576 1576
 					$fk_to_this = $related_model_obj_in_cache->get_model()->get_foreign_key_to(
1577 1577
 						$this->get_model()->get_this_model_name()
1578 1578
 					);
1579
-					$related_model_obj_in_cache->set($fk_to_this->get_name(), $this->ID() );
1580
-					if( $related_model_obj_in_cache->ID() ){
1579
+					$related_model_obj_in_cache->set($fk_to_this->get_name(), $this->ID());
1580
+					if ($related_model_obj_in_cache->ID()) {
1581 1581
 						$related_model_obj_in_cache->save();
1582 1582
 					}
1583 1583
 				}
@@ -1598,21 +1598,21 @@  discard block
 block discarded – undo
1598 1598
 	 * @return int ID of new model object on save; 0 on failure+
1599 1599
 	 * @throws \EE_Error
1600 1600
 	 */
1601
-	public function save_new_cached_related_model_objs(){
1601
+	public function save_new_cached_related_model_objs() {
1602 1602
 		//make sure this has been saved
1603
-		if( ! $this->ID()){
1603
+		if ( ! $this->ID()) {
1604 1604
 			$id = $this->save();
1605
-		}else{
1605
+		} else {
1606 1606
 			$id = $this->ID();
1607 1607
 		}
1608 1608
 		//now save all the NEW cached model objects  (ie they don't exist in the DB)
1609
-		foreach($this->get_model()->relation_settings() as $relationName => $relationObj){
1609
+		foreach ($this->get_model()->relation_settings() as $relationName => $relationObj) {
1610 1610
 
1611 1611
 
1612
-			if($this->_model_relations[$relationName]){
1612
+			if ($this->_model_relations[$relationName]) {
1613 1613
 				//is this a relation where we should expect just ONE related object (ie, EE_Belongs_To_relation)
1614 1614
 				//or MANY related objects (ie, EE_HABTM_Relation or EE_Has_Many_Relation)?
1615
-				if($relationObj instanceof EE_Belongs_To_Relation){
1615
+				if ($relationObj instanceof EE_Belongs_To_Relation) {
1616 1616
 					//add a relation to that relation type (which saves the appropriate thing in the process)
1617 1617
 					//but ONLY if it DOES NOT exist in the DB
1618 1618
 					/* @var $related_model_obj EE_Base_Class */
@@ -1621,8 +1621,8 @@  discard block
 block discarded – undo
1621 1621
 						$this->_add_relation_to($related_model_obj, $relationName);
1622 1622
 						$related_model_obj->save_new_cached_related_model_objs();
1623 1623
 //					}
1624
-				}else{
1625
-					foreach($this->_model_relations[$relationName] as $related_model_obj){
1624
+				} else {
1625
+					foreach ($this->_model_relations[$relationName] as $related_model_obj) {
1626 1626
 						//add a relation to that relation type (which saves the appropriate thing in the process)
1627 1627
 						//but ONLY if it DOES NOT exist in the DB
1628 1628
 //						if( ! $related_model_obj->ID()){
@@ -1643,8 +1643,8 @@  discard block
 block discarded – undo
1643 1643
 	 * @return \EEM_Base | \EEM_CPT_Base
1644 1644
 	 */
1645 1645
 	public function get_model() {
1646
-		$modelName = self::_get_model_classname( get_class($this) );
1647
-		return self::_get_model_instance_with_name($modelName, $this->_timezone );
1646
+		$modelName = self::_get_model_classname(get_class($this));
1647
+		return self::_get_model_instance_with_name($modelName, $this->_timezone);
1648 1648
 	}
1649 1649
 
1650 1650
 
@@ -1655,10 +1655,10 @@  discard block
 block discarded – undo
1655 1655
 	 * @return mixed bool|EE_Base_Class|EEM_CPT_Base
1656 1656
 	 * @throws \EE_Error
1657 1657
 	 */
1658
-	protected static function _get_object_from_entity_mapper($props_n_values, $classname){
1658
+	protected static function _get_object_from_entity_mapper($props_n_values, $classname) {
1659 1659
 		//TODO: will not work for Term_Relationships because they have no PK!
1660
-		$primary_id_ref = self::_get_primary_key_name( $classname );
1661
-		if ( array_key_exists( $primary_id_ref, $props_n_values ) && !empty( $props_n_values[$primary_id_ref] ) ) {
1660
+		$primary_id_ref = self::_get_primary_key_name($classname);
1661
+		if (array_key_exists($primary_id_ref, $props_n_values) && ! empty($props_n_values[$primary_id_ref])) {
1662 1662
 			$id = $props_n_values[$primary_id_ref];
1663 1663
 			return self::_get_model($classname)->get_from_entity_map($id);
1664 1664
 		}
@@ -1679,37 +1679,37 @@  discard block
 block discarded – undo
1679 1679
 	 * @return mixed (EE_Base_Class|bool)
1680 1680
 	 * @throws \EE_Error
1681 1681
 	 */
1682
-	protected static function _check_for_object( $props_n_values, $classname, $timezone = NULL, $date_formats = array() ) {
1682
+	protected static function _check_for_object($props_n_values, $classname, $timezone = NULL, $date_formats = array()) {
1683 1683
 		$existing = null;
1684
-		if ( self::_get_model( $classname )->has_primary_key_field() ) {
1685
-			$primary_id_ref = self::_get_primary_key_name( $classname );
1686
-			if ( array_key_exists( $primary_id_ref, $props_n_values )
1687
-			     && ! empty( $props_n_values[ $primary_id_ref ] )
1684
+		if (self::_get_model($classname)->has_primary_key_field()) {
1685
+			$primary_id_ref = self::_get_primary_key_name($classname);
1686
+			if (array_key_exists($primary_id_ref, $props_n_values)
1687
+			     && ! empty($props_n_values[$primary_id_ref])
1688 1688
 			) {
1689
-				$existing = self::_get_model( $classname, $timezone )->get_one_by_ID(
1690
-					$props_n_values[ $primary_id_ref ]
1689
+				$existing = self::_get_model($classname, $timezone)->get_one_by_ID(
1690
+					$props_n_values[$primary_id_ref]
1691 1691
 				);
1692 1692
 			}
1693
-		} elseif ( self::_get_model( $classname, $timezone )->has_all_combined_primary_key_fields( $props_n_values ) ) {
1693
+		} elseif (self::_get_model($classname, $timezone)->has_all_combined_primary_key_fields($props_n_values)) {
1694 1694
 			//no primary key on this model, but there's still a matching item in the DB
1695
-			$existing = self::_get_model( $classname, $timezone )->get_one_by_ID(
1696
-				self::_get_model( $classname, $timezone )->get_index_primary_key_string( $props_n_values )
1695
+			$existing = self::_get_model($classname, $timezone)->get_one_by_ID(
1696
+				self::_get_model($classname, $timezone)->get_index_primary_key_string($props_n_values)
1697 1697
 			);
1698 1698
 		}
1699
-		if ( $existing ) {
1699
+		if ($existing) {
1700 1700
 
1701 1701
 			//set date formats if present before setting values
1702
-			if ( ! empty( $date_formats ) && is_array( $date_formats ) ) {
1703
-				$existing->set_date_format( $date_formats[0] );
1704
-				$existing->set_time_format( $date_formats[1] );
1702
+			if ( ! empty($date_formats) && is_array($date_formats)) {
1703
+				$existing->set_date_format($date_formats[0]);
1704
+				$existing->set_time_format($date_formats[1]);
1705 1705
 			} else {
1706 1706
 				//set default formats for date and time
1707
-				$existing->set_date_format( get_option( 'date_format' ) );
1708
-				$existing->set_time_format( get_option( 'time_format' ) );
1707
+				$existing->set_date_format(get_option('date_format'));
1708
+				$existing->set_time_format(get_option('time_format'));
1709 1709
 			}
1710 1710
 
1711
-			foreach ( $props_n_values as $property => $field_value ) {
1712
-				$existing->set( $property, $field_value );
1711
+			foreach ($props_n_values as $property => $field_value) {
1712
+				$existing->set($property, $field_value);
1713 1713
 			}
1714 1714
 			return $existing;
1715 1715
 		} else {
@@ -1727,9 +1727,9 @@  discard block
 block discarded – undo
1727 1727
 	 * @throws EE_Error
1728 1728
 	 * @return EEM_Base
1729 1729
 	 */
1730
-	protected static function  _get_model( $classname, $timezone = NULL ){
1730
+	protected static function  _get_model($classname, $timezone = NULL) {
1731 1731
 		//find model for this class
1732
-		if( ! $classname ){
1732
+		if ( ! $classname) {
1733 1733
 			throw new EE_Error(
1734 1734
 				sprintf(
1735 1735
 					__(
@@ -1740,8 +1740,8 @@  discard block
 block discarded – undo
1740 1740
 				)
1741 1741
 			);
1742 1742
 		}
1743
-		$modelName=self::_get_model_classname($classname);
1744
-		return self::_get_model_instance_with_name($modelName, $timezone );
1743
+		$modelName = self::_get_model_classname($classname);
1744
+		return self::_get_model_instance_with_name($modelName, $timezone);
1745 1745
 	}
1746 1746
 
1747 1747
 
@@ -1752,10 +1752,10 @@  discard block
 block discarded – undo
1752 1752
 	 * @param null   $timezone
1753 1753
 	 * @return EEM_Base
1754 1754
 	 */
1755
-	protected static function _get_model_instance_with_name($model_classname, $timezone = NULL){
1756
-		$model_classname = str_replace( 'EEM_', '', $model_classname );
1757
-		$model = EE_Registry::instance()->load_model( $model_classname );
1758
-		$model->set_timezone( $timezone );
1755
+	protected static function _get_model_instance_with_name($model_classname, $timezone = NULL) {
1756
+		$model_classname = str_replace('EEM_', '', $model_classname);
1757
+		$model = EE_Registry::instance()->load_model($model_classname);
1758
+		$model->set_timezone($timezone);
1759 1759
 		return $model;
1760 1760
 	}
1761 1761
 
@@ -1767,10 +1767,10 @@  discard block
 block discarded – undo
1767 1767
 	 * @param null $model_name
1768 1768
 	 * @return string like EEM_Attendee
1769 1769
 	 */
1770
-	private static function _get_model_classname( $model_name = null){
1771
-		if(strpos($model_name,"EE_")===0){
1772
-			$model_classname=str_replace("EE_","EEM_",$model_name);
1773
-		}else{
1770
+	private static function _get_model_classname($model_name = null) {
1771
+		if (strpos($model_name, "EE_") === 0) {
1772
+			$model_classname = str_replace("EE_", "EEM_", $model_name);
1773
+		} else {
1774 1774
 			$model_classname = "EEM_".$model_name;
1775 1775
 		}
1776 1776
 		return $model_classname;
@@ -1784,16 +1784,16 @@  discard block
 block discarded – undo
1784 1784
 	 * @throws EE_Error
1785 1785
 	 * @return string
1786 1786
 	 */
1787
-	protected static function _get_primary_key_name( $classname = NULL ){
1788
-		if( ! $classname){
1787
+	protected static function _get_primary_key_name($classname = NULL) {
1788
+		if ( ! $classname) {
1789 1789
 			throw new EE_Error(
1790 1790
 				sprintf(
1791
-					__( "What were you thinking calling _get_primary_key_name(%s)", "event_espresso" ),
1791
+					__("What were you thinking calling _get_primary_key_name(%s)", "event_espresso"),
1792 1792
 					$classname
1793 1793
 				)
1794 1794
 			);
1795 1795
 		}
1796
-		return self::_get_model( $classname )->get_primary_key_field()->get_name();
1796
+		return self::_get_model($classname)->get_primary_key_field()->get_name();
1797 1797
 	}
1798 1798
 
1799 1799
 
@@ -1807,12 +1807,12 @@  discard block
 block discarded – undo
1807 1807
 	 * @return mixed, if the primary key is of type INT it'll be an int. Otherwise it could be a string
1808 1808
 	 * @throws \EE_Error
1809 1809
 	 */
1810
-	public function ID(){
1810
+	public function ID() {
1811 1811
 		//now that we know the name of the variable, use a variable variable to get its value and return its
1812
-		if( $this->get_model()->has_primary_key_field() ) {
1813
-			return $this->_fields[ self::_get_primary_key_name( get_class($this) ) ];
1814
-		}else{
1815
-			return $this->get_model()->get_index_primary_key_string( $this->_fields );
1812
+		if ($this->get_model()->has_primary_key_field()) {
1813
+			return $this->_fields[self::_get_primary_key_name(get_class($this))];
1814
+		} else {
1815
+			return $this->get_model()->get_index_primary_key_string($this->_fields);
1816 1816
 		}
1817 1817
 	}
1818 1818
 
@@ -1830,38 +1830,38 @@  discard block
 block discarded – undo
1830 1830
 	 * @throws EE_Error
1831 1831
 	 * @return EE_Base_Class the object the relation was added to
1832 1832
 	 */
1833
-	public function _add_relation_to( $otherObjectModelObjectOrID,$relationName, $extra_join_model_fields_n_values = array(), $cache_id = NULL ){
1833
+	public function _add_relation_to($otherObjectModelObjectOrID, $relationName, $extra_join_model_fields_n_values = array(), $cache_id = NULL) {
1834 1834
 		//if this thing exists in the DB, save the relation to the DB
1835
-		if( $this->ID() ){
1836
-			$otherObject = $this->get_model()->add_relationship_to( $this, $otherObjectModelObjectOrID, $relationName, $extra_join_model_fields_n_values );
1835
+		if ($this->ID()) {
1836
+			$otherObject = $this->get_model()->add_relationship_to($this, $otherObjectModelObjectOrID, $relationName, $extra_join_model_fields_n_values);
1837 1837
 			//clear cache so future get_many_related and get_first_related() return new results.
1838
-			$this->clear_cache( $relationName, $otherObject, TRUE );
1839
-                        if( $otherObject instanceof EE_Base_Class ) {
1840
-                            $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this );
1838
+			$this->clear_cache($relationName, $otherObject, TRUE);
1839
+                        if ($otherObject instanceof EE_Base_Class) {
1840
+                            $otherObject->clear_cache($this->get_model()->get_this_model_name(), $this);
1841 1841
                         }
1842 1842
 		} else {
1843 1843
 			//this thing doesn't exist in the DB,  so just cache it
1844
-			if( ! $otherObjectModelObjectOrID instanceof EE_Base_Class){
1845
-				throw new EE_Error( sprintf(
1846
-					__( 'Before a model object is saved to the database, calls to _add_relation_to must be passed an actual object, not just an ID. You provided %s as the model object to a %s', 'event_espresso' ),
1844
+			if ( ! $otherObjectModelObjectOrID instanceof EE_Base_Class) {
1845
+				throw new EE_Error(sprintf(
1846
+					__('Before a model object is saved to the database, calls to _add_relation_to must be passed an actual object, not just an ID. You provided %s as the model object to a %s', 'event_espresso'),
1847 1847
 					$otherObjectModelObjectOrID,
1848
-					get_class( $this )
1848
+					get_class($this)
1849 1849
 				));
1850 1850
 			} else {
1851 1851
 				$otherObject = $otherObjectModelObjectOrID;
1852 1852
 			}
1853
-			$this->cache( $relationName, $otherObjectModelObjectOrID, $cache_id );
1853
+			$this->cache($relationName, $otherObjectModelObjectOrID, $cache_id);
1854 1854
 		}
1855
-                if( $otherObject instanceof EE_Base_Class ) {
1855
+                if ($otherObject instanceof EE_Base_Class) {
1856 1856
                     //fix the reciprocal relation too
1857
-                    if( $otherObject->ID() ) {
1857
+                    if ($otherObject->ID()) {
1858 1858
                             //its saved so assumed relations exist in the DB, so we can just
1859 1859
                             //clear the cache so future queries use the updated info in the DB
1860
-                            $otherObject->clear_cache( $this->get_model()->get_this_model_name(), null, true );
1860
+                            $otherObject->clear_cache($this->get_model()->get_this_model_name(), null, true);
1861 1861
                     } else {
1862 1862
 
1863 1863
                             //it's not saved, so it caches relations like this
1864
-                            $otherObject->cache( $this->get_model()->get_this_model_name(), $this );
1864
+                            $otherObject->cache($this->get_model()->get_this_model_name(), $this);
1865 1865
                     }
1866 1866
                 }
1867 1867
 		return $otherObject;
@@ -1885,17 +1885,17 @@  discard block
 block discarded – undo
1885 1885
 	 * @return EE_Base_Class the relation was removed from
1886 1886
 	 * @throws \EE_Error
1887 1887
 	 */
1888
-	public function _remove_relation_to($otherObjectModelObjectOrID,$relationName, $where_query = array() ){
1889
-		if ( $this->ID() ) {
1888
+	public function _remove_relation_to($otherObjectModelObjectOrID, $relationName, $where_query = array()) {
1889
+		if ($this->ID()) {
1890 1890
 			//if this exists in the DB, save the relation change to the DB too
1891
-			$otherObject = $this->get_model()->remove_relationship_to( $this, $otherObjectModelObjectOrID, $relationName, $where_query );
1892
-			$this->clear_cache( $relationName, $otherObject );
1891
+			$otherObject = $this->get_model()->remove_relationship_to($this, $otherObjectModelObjectOrID, $relationName, $where_query);
1892
+			$this->clear_cache($relationName, $otherObject);
1893 1893
 		} else {
1894 1894
 			//this doesn't exist in the DB, just remove it from the cache
1895
-			$otherObject = $this->clear_cache( $relationName, $otherObjectModelObjectOrID );
1895
+			$otherObject = $this->clear_cache($relationName, $otherObjectModelObjectOrID);
1896 1896
 		}
1897
-                if( $otherObject instanceof EE_Base_Class ) {
1898
-                    $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this );
1897
+                if ($otherObject instanceof EE_Base_Class) {
1898
+                    $otherObject->clear_cache($this->get_model()->get_this_model_name(), $this);
1899 1899
                 }
1900 1900
 		return $otherObject;
1901 1901
 	}
@@ -1910,18 +1910,18 @@  discard block
 block discarded – undo
1910 1910
 	 * @return EE_Base_Class
1911 1911
 	 * @throws \EE_Error
1912 1912
 	 */
1913
-	public function _remove_relations($relationName,$where_query_params = array()){
1914
-		if ( $this->ID() ) {
1913
+	public function _remove_relations($relationName, $where_query_params = array()) {
1914
+		if ($this->ID()) {
1915 1915
 			//if this exists in the DB, save the relation change to the DB too
1916
-			$otherObjects = $this->get_model()->remove_relations( $this, $relationName, $where_query_params );
1917
-			$this->clear_cache( $relationName, null, true );
1916
+			$otherObjects = $this->get_model()->remove_relations($this, $relationName, $where_query_params);
1917
+			$this->clear_cache($relationName, null, true);
1918 1918
 		} else {
1919 1919
 			//this doesn't exist in the DB, just remove it from the cache
1920
-			$otherObjects = $this->clear_cache( $relationName, null, true );
1920
+			$otherObjects = $this->clear_cache($relationName, null, true);
1921 1921
 		}
1922
-                if( is_array( $otherObjects ) ) {
1923
-                    foreach ( $otherObjects as $otherObject ) {
1924
-                            $otherObject->clear_cache( $this->get_model()->get_this_model_name(), $this );
1922
+                if (is_array($otherObjects)) {
1923
+                    foreach ($otherObjects as $otherObject) {
1924
+                            $otherObject->clear_cache($this->get_model()->get_this_model_name(), $this);
1925 1925
                     }
1926 1926
                 }
1927 1927
 		return $otherObjects;
@@ -1941,27 +1941,27 @@  discard block
 block discarded – undo
1941 1941
 	 * @throws \EE_Error
1942 1942
 	 *                             or might not be saved yet. Consider using EEM_Base::get_IDs() on these results if you want IDs
1943 1943
 	 */
1944
-	public function get_many_related($relationName,$query_params = array()){
1945
-		if($this->ID()){
1944
+	public function get_many_related($relationName, $query_params = array()) {
1945
+		if ($this->ID()) {
1946 1946
 			//this exists in the DB, so get the related things from either the cache or the DB
1947 1947
 			//if there are query parameters, forget about caching the related model objects.
1948
-			if( $query_params ){
1948
+			if ($query_params) {
1949 1949
 				$related_model_objects = $this->get_model()->get_all_related($this, $relationName, $query_params);
1950
-			}else{
1950
+			} else {
1951 1951
 				//did we already cache the result of this query?
1952 1952
 				$cached_results = $this->get_all_from_cache($relationName);
1953
-				if ( ! $cached_results ){
1953
+				if ( ! $cached_results) {
1954 1954
 					$related_model_objects = $this->get_model()->get_all_related($this, $relationName, $query_params);
1955 1955
 					//if no query parameters were passed, then we got all the related model objects
1956 1956
 					//for that relation. We can cache them then.
1957
-					foreach($related_model_objects as $related_model_object){
1957
+					foreach ($related_model_objects as $related_model_object) {
1958 1958
 						$this->cache($relationName, $related_model_object);
1959 1959
 					}
1960
-				}else{
1960
+				} else {
1961 1961
 					$related_model_objects = $cached_results;
1962 1962
 				}
1963 1963
 			}
1964
-		}else{
1964
+		} else {
1965 1965
 			//this doesn't exist in the DB, so just get the related things from the cache
1966 1966
 			$related_model_objects = $this->get_all_from_cache($relationName);
1967 1967
 		}
@@ -1979,8 +1979,8 @@  discard block
 block discarded – undo
1979 1979
 	 * @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;
1980 1980
 	 * @return int
1981 1981
 	 */
1982
-	public function count_related($relation_name, $query_params =array(),$field_to_count = NULL, $distinct = FALSE){
1983
-		return $this->get_model()->count_related($this,$relation_name,$query_params,$field_to_count,$distinct);
1982
+	public function count_related($relation_name, $query_params = array(), $field_to_count = NULL, $distinct = FALSE) {
1983
+		return $this->get_model()->count_related($this, $relation_name, $query_params, $field_to_count, $distinct);
1984 1984
 	}
1985 1985
 
1986 1986
 
@@ -1994,7 +1994,7 @@  discard block
 block discarded – undo
1994 1994
 	 * 						By default, uses primary key (which doesn't make much sense, so you should probably change it)
1995 1995
 	 * @return int
1996 1996
 	 */
1997
-	public function sum_related($relation_name, $query_params = array(), $field_to_sum = null){
1997
+	public function sum_related($relation_name, $query_params = array(), $field_to_sum = null) {
1998 1998
 		return $this->get_model()->sum_related($this, $relation_name, $query_params, $field_to_sum);
1999 1999
 	}
2000 2000
 
@@ -2008,33 +2008,33 @@  discard block
 block discarded – undo
2008 2008
 	 * @return EE_Base_Class (not an array, a single object)
2009 2009
 	 * @throws \EE_Error
2010 2010
 	 */
2011
-	public function get_first_related($relationName,$query_params = array()){
2012
-		if($this->ID()){//this exists in the DB, get from the cache OR the DB
2011
+	public function get_first_related($relationName, $query_params = array()) {
2012
+		if ($this->ID()) {//this exists in the DB, get from the cache OR the DB
2013 2013
 
2014 2014
 			//if they've provided some query parameters, don't bother trying to cache the result
2015 2015
 			//also make sure we're not caching the result of get_first_related
2016 2016
 			//on a relation which should have an array of objects (because the cache might have an array of objects)
2017
-			if ($query_params || ! $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation){
2018
-				$related_model_object =  $this->get_model()->get_first_related($this, $relationName, $query_params);
2019
-			}else{
2017
+			if ($query_params || ! $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation) {
2018
+				$related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params);
2019
+			} else {
2020 2020
 				//first, check if we've already cached the result of this query
2021 2021
 				$cached_result = $this->get_one_from_cache($relationName);
2022
-				if ( ! $cached_result ){
2022
+				if ( ! $cached_result) {
2023 2023
 
2024 2024
 					$related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params);
2025
-					$this->cache($relationName,$related_model_object);
2026
-				}else{
2025
+					$this->cache($relationName, $related_model_object);
2026
+				} else {
2027 2027
 					$related_model_object = $cached_result;
2028 2028
 				}
2029 2029
 			}
2030
-		}else{
2030
+		} else {
2031 2031
 			$related_model_object = null;
2032 2032
 			//this doesn't exist in the Db, but maybe the relation is of type belongs to, and so the related thing might
2033
-			if( $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation){
2034
-				$related_model_object =  $this->get_model()->get_first_related($this, $relationName, $query_params);
2033
+			if ($this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation) {
2034
+				$related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params);
2035 2035
 			}
2036 2036
 			//this doesn't exist in the DB and apparently the thing it belongs to doesn't either, just get what's cached on this object
2037
-			if( ! $related_model_object){
2037
+			if ( ! $related_model_object) {
2038 2038
 				$related_model_object = $this->get_one_from_cache($relationName);
2039 2039
 			}
2040 2040
 
@@ -2056,12 +2056,12 @@  discard block
 block discarded – undo
2056 2056
 	 * @return int how many deleted
2057 2057
 	 * @throws \EE_Error
2058 2058
 	 */
2059
-	public function delete_related($relationName,$query_params = array()){
2060
-		if($this->ID()){
2061
-			$count =  $this->get_model()->delete_related($this, $relationName, $query_params);
2062
-		}else{
2059
+	public function delete_related($relationName, $query_params = array()) {
2060
+		if ($this->ID()) {
2061
+			$count = $this->get_model()->delete_related($this, $relationName, $query_params);
2062
+		} else {
2063 2063
 			$count = count($this->get_all_from_cache($relationName));
2064
-			$this->clear_cache($relationName,NULL,TRUE);
2064
+			$this->clear_cache($relationName, NULL, TRUE);
2065 2065
 		}
2066 2066
 		return $count;
2067 2067
 	}
@@ -2080,13 +2080,13 @@  discard block
 block discarded – undo
2080 2080
 	 * @return int how many deleted (including those soft deleted)
2081 2081
 	 * @throws \EE_Error
2082 2082
 	 */
2083
-	public function delete_related_permanently($relationName,$query_params = array()){
2084
-		if($this->ID()){
2085
-			$count =  $this->get_model()->delete_related_permanently($this, $relationName, $query_params);
2086
-		}else{
2083
+	public function delete_related_permanently($relationName, $query_params = array()) {
2084
+		if ($this->ID()) {
2085
+			$count = $this->get_model()->delete_related_permanently($this, $relationName, $query_params);
2086
+		} else {
2087 2087
 			$count = count($this->get_all_from_cache($relationName));
2088 2088
 		}
2089
-		$this->clear_cache($relationName,NULL,TRUE);
2089
+		$this->clear_cache($relationName, NULL, TRUE);
2090 2090
 		return $count;
2091 2091
 	}
2092 2092
 
@@ -2102,7 +2102,7 @@  discard block
 block discarded – undo
2102 2102
 	 * @param  string $field_name property to check
2103 2103
 	 * @return bool            				  TRUE if existing,FALSE if not.
2104 2104
 	 */
2105
-	public function is_set( $field_name ) {
2105
+	public function is_set($field_name) {
2106 2106
 		return isset($this->_fields[$field_name]);
2107 2107
 	}
2108 2108
 
@@ -2114,11 +2114,11 @@  discard block
 block discarded – undo
2114 2114
 	 * @throws EE_Error
2115 2115
 	 * @return bool                              TRUE if existing, throw EE_Error if not.
2116 2116
 	 */
2117
-	protected function _property_exists( $properties ) {
2117
+	protected function _property_exists($properties) {
2118 2118
 
2119
-		foreach ( (array) $properties as $property_name ) {
2119
+		foreach ((array) $properties as $property_name) {
2120 2120
 			//first make sure this property exists
2121
-			if ( ! $this->_fields[ $property_name ] ) {
2121
+			if ( ! $this->_fields[$property_name]) {
2122 2122
 				throw new EE_Error(
2123 2123
 					sprintf(
2124 2124
 						__(
@@ -2146,7 +2146,7 @@  discard block
 block discarded – undo
2146 2146
 		$fields = $this->get_model()->field_settings(FALSE);
2147 2147
 		$properties = array();
2148 2148
 		//remove prepended underscore
2149
-		foreach ( $fields as $field_name => $settings ) {
2149
+		foreach ($fields as $field_name => $settings) {
2150 2150
 			$properties[$field_name] = $this->get($field_name);
2151 2151
 		}
2152 2152
 		return $properties;
@@ -2176,10 +2176,10 @@  discard block
 block discarded – undo
2176 2176
 	 * @throws EE_Error
2177 2177
 	 * @return mixed whatever the plugin which calls add_filter decides
2178 2178
 	 */
2179
-	public function __call($methodName,$args){
2180
-		$className=get_class($this);
2181
-		$tagName="FHEE__{$className}__{$methodName}";
2182
-		if ( ! has_filter( $tagName ) ) {
2179
+	public function __call($methodName, $args) {
2180
+		$className = get_class($this);
2181
+		$tagName = "FHEE__{$className}__{$methodName}";
2182
+		if ( ! has_filter($tagName)) {
2183 2183
 			throw new EE_Error(
2184 2184
 				sprintf(
2185 2185
 					__(
@@ -2192,7 +2192,7 @@  discard block
 block discarded – undo
2192 2192
 				)
2193 2193
 			);
2194 2194
 		}
2195
-		return apply_filters($tagName,null,$this,$args);
2195
+		return apply_filters($tagName, null, $this, $args);
2196 2196
 	}
2197 2197
 
2198 2198
 
@@ -2208,7 +2208,7 @@  discard block
 block discarded – undo
2208 2208
 	 * @throws \EE_Error
2209 2209
 	 * NOTE: if the values haven't changed, returns 0
2210 2210
 	 */
2211
-	public function update_extra_meta($meta_key,$meta_value,$previous_value = NULL){
2211
+	public function update_extra_meta($meta_key, $meta_value, $previous_value = NULL) {
2212 2212
 		$query_params = array(
2213 2213
 			array(
2214 2214
 				'EXM_key'  => $meta_key,
@@ -2216,17 +2216,17 @@  discard block
 block discarded – undo
2216 2216
 				'EXM_type' => $this->get_model()->get_this_model_name()
2217 2217
 			)
2218 2218
 		);
2219
-		if ( $previous_value !== null ) {
2219
+		if ($previous_value !== null) {
2220 2220
 			$query_params[0]['EXM_value'] = $meta_value;
2221 2221
 		}
2222
-		$existing_rows_like_that = EEM_Extra_Meta::instance()->get_all( $query_params );
2223
-		if ( ! $existing_rows_like_that ) {
2224
-			return $this->add_extra_meta( $meta_key, $meta_value );
2222
+		$existing_rows_like_that = EEM_Extra_Meta::instance()->get_all($query_params);
2223
+		if ( ! $existing_rows_like_that) {
2224
+			return $this->add_extra_meta($meta_key, $meta_value);
2225 2225
 		} else {
2226
-			foreach ( $existing_rows_like_that as $existing_row ) {
2227
-				$existing_row->save( array( 'EXM_value' => $meta_value ) );
2226
+			foreach ($existing_rows_like_that as $existing_row) {
2227
+				$existing_row->save(array('EXM_value' => $meta_value));
2228 2228
 			}
2229
-			return count( $existing_rows_like_that );
2229
+			return count($existing_rows_like_that);
2230 2230
 		}
2231 2231
 	}
2232 2232
 
@@ -2243,8 +2243,8 @@  discard block
 block discarded – undo
2243 2243
 	 * @return boolean
2244 2244
 	 * @throws \EE_Error
2245 2245
 	 */
2246
-	public function add_extra_meta($meta_key,$meta_value,$unique = false){
2247
-		if ( $unique ) {
2246
+	public function add_extra_meta($meta_key, $meta_value, $unique = false) {
2247
+		if ($unique) {
2248 2248
 			$existing_extra_meta = EEM_Extra_Meta::instance()->get_one(
2249 2249
 				array(
2250 2250
 					array(
@@ -2254,7 +2254,7 @@  discard block
 block discarded – undo
2254 2254
 					)
2255 2255
 				)
2256 2256
 			);
2257
-			if ( $existing_extra_meta ) {
2257
+			if ($existing_extra_meta) {
2258 2258
 				return false;
2259 2259
 			}
2260 2260
 		}
@@ -2281,7 +2281,7 @@  discard block
 block discarded – undo
2281 2281
 	 * @return int number of extra meta rows deleted
2282 2282
 	 * @throws \EE_Error
2283 2283
 	 */
2284
-	public function delete_extra_meta($meta_key,$meta_value = NULL){
2284
+	public function delete_extra_meta($meta_key, $meta_value = NULL) {
2285 2285
 		$query_params = array(
2286 2286
 			array(
2287 2287
 				'EXM_key'  => $meta_key,
@@ -2289,10 +2289,10 @@  discard block
 block discarded – undo
2289 2289
 				'EXM_type' => $this->get_model()->get_this_model_name()
2290 2290
 			)
2291 2291
 		);
2292
-		if ( $meta_value !== null ) {
2292
+		if ($meta_value !== null) {
2293 2293
 			$query_params[0]['EXM_value'] = $meta_value;
2294 2294
 		}
2295
-		return EEM_Extra_Meta::instance()->delete( $query_params );
2295
+		return EEM_Extra_Meta::instance()->delete($query_params);
2296 2296
 	}
2297 2297
 
2298 2298
 
@@ -2308,25 +2308,25 @@  discard block
 block discarded – undo
2308 2308
 	 * @return mixed single value if $single; array if ! $single
2309 2309
 	 * @throws \EE_Error
2310 2310
 	 */
2311
-	public function get_extra_meta($meta_key,$single = FALSE,$default = NULL){
2312
-		if($single){
2313
-			$result = $this->get_first_related('Extra_Meta',array(array('EXM_key'=>$meta_key)));
2314
-			if ( $result instanceof EE_Extra_Meta ){
2311
+	public function get_extra_meta($meta_key, $single = FALSE, $default = NULL) {
2312
+		if ($single) {
2313
+			$result = $this->get_first_related('Extra_Meta', array(array('EXM_key'=>$meta_key)));
2314
+			if ($result instanceof EE_Extra_Meta) {
2315 2315
 				return $result->value();
2316
-			}else{
2316
+			} else {
2317 2317
 				return $default;
2318 2318
 			}
2319
-		}else{
2320
-			$results =  $this->get_many_related('Extra_Meta',array(array('EXM_key'=>$meta_key)));
2321
-			if($results){
2319
+		} else {
2320
+			$results = $this->get_many_related('Extra_Meta', array(array('EXM_key'=>$meta_key)));
2321
+			if ($results) {
2322 2322
 				$values = array();
2323
-				foreach($results as $result){
2324
-					if ( $result instanceof EE_Extra_Meta ){
2323
+				foreach ($results as $result) {
2324
+					if ($result instanceof EE_Extra_Meta) {
2325 2325
 						$values[$result->ID()] = $result->value();
2326 2326
 					}
2327 2327
 				}
2328 2328
 				return $values;
2329
-			}else{
2329
+			} else {
2330 2330
 				return $default;
2331 2331
 			}
2332 2332
 		}
@@ -2348,20 +2348,20 @@  discard block
 block discarded – undo
2348 2348
 	 * @return array
2349 2349
 	 * @throws \EE_Error
2350 2350
 	 */
2351
-	public function all_extra_meta_array($one_of_each_key = true){
2351
+	public function all_extra_meta_array($one_of_each_key = true) {
2352 2352
 		$return_array = array();
2353
-		if($one_of_each_key){
2353
+		if ($one_of_each_key) {
2354 2354
 			$extra_meta_objs = $this->get_many_related('Extra_Meta', array('group_by'=>'EXM_key'));
2355
-			foreach($extra_meta_objs as $extra_meta_obj){
2356
-				if ( $extra_meta_obj instanceof EE_Extra_Meta ) {
2355
+			foreach ($extra_meta_objs as $extra_meta_obj) {
2356
+				if ($extra_meta_obj instanceof EE_Extra_Meta) {
2357 2357
 					$return_array[$extra_meta_obj->key()] = $extra_meta_obj->value();
2358 2358
 				}
2359 2359
 			}
2360
-		}else{
2360
+		} else {
2361 2361
 			$extra_meta_objs = $this->get_many_related('Extra_Meta');
2362
-			foreach($extra_meta_objs as $extra_meta_obj){
2363
-				if ( $extra_meta_obj instanceof EE_Extra_Meta ) {
2364
-					if( ! isset($return_array[$extra_meta_obj->key()])){
2362
+			foreach ($extra_meta_objs as $extra_meta_obj) {
2363
+				if ($extra_meta_obj instanceof EE_Extra_Meta) {
2364
+					if ( ! isset($return_array[$extra_meta_obj->key()])) {
2365 2365
 						$return_array[$extra_meta_obj->key()] = array();
2366 2366
 					}
2367 2367
 					$return_array[$extra_meta_obj->key()][$extra_meta_obj->ID()] = $extra_meta_obj->value();
@@ -2379,19 +2379,19 @@  discard block
 block discarded – undo
2379 2379
 	 * @return string
2380 2380
 	 * @throws \EE_Error
2381 2381
 	 */
2382
-	public function name(){
2382
+	public function name() {
2383 2383
 		//find a field that's not a text field
2384 2384
 		$field_we_can_use = $this->get_model()->get_a_field_of_type('EE_Text_Field_Base');
2385
-		if($field_we_can_use){
2385
+		if ($field_we_can_use) {
2386 2386
 			return $this->get($field_we_can_use->get_name());
2387
-		}else{
2387
+		} else {
2388 2388
 			$first_few_properties = $this->model_field_array();
2389
-			$first_few_properties = array_slice($first_few_properties,0,3);
2389
+			$first_few_properties = array_slice($first_few_properties, 0, 3);
2390 2390
 			$name_parts = array();
2391
-			foreach( $first_few_properties as $name=> $value ){
2391
+			foreach ($first_few_properties as $name=> $value) {
2392 2392
 				$name_parts[] = "$name:$value";
2393 2393
 			}
2394
-			return implode(",",$name_parts);
2394
+			return implode(",", $name_parts);
2395 2395
 		}
2396 2396
 	}
2397 2397
 
@@ -2404,11 +2404,11 @@  discard block
 block discarded – undo
2404 2404
 	 * @return boolean
2405 2405
 	 * @throws \EE_Error
2406 2406
 	 */
2407
-	public function in_entity_map(){
2408
-		if( $this->ID() && $this->get_model()->get_from_entity_map( $this->ID() ) === $this ) {
2407
+	public function in_entity_map() {
2408
+		if ($this->ID() && $this->get_model()->get_from_entity_map($this->ID()) === $this) {
2409 2409
 			//well, if we looked, did we find it in the entity map?
2410 2410
 			return TRUE;
2411
-		}else{
2411
+		} else {
2412 2412
 			return FALSE;
2413 2413
 		}
2414 2414
 	}
@@ -2419,21 +2419,21 @@  discard block
 block discarded – undo
2419 2419
 	 * @throws EE_Error if this model object isn't in the entity mapper (because then you should
2420 2420
 	 * just use what's in the entity mapper and refresh it) and WP_DEBUG is TRUE
2421 2421
 	 */
2422
-	public function refresh_from_db(){
2423
-		if( $this->ID() && $this->in_entity_map() ){
2424
-			$this->get_model()->refresh_entity_map_from_db( $this->ID() );
2425
-		}else{
2422
+	public function refresh_from_db() {
2423
+		if ($this->ID() && $this->in_entity_map()) {
2424
+			$this->get_model()->refresh_entity_map_from_db($this->ID());
2425
+		} else {
2426 2426
 			//if it doesn't have ID, you shouldn't be asking to refresh it from teh database (because its not in the database)
2427 2427
 			//if it has an ID but it's not in the map, and you're asking me to refresh it
2428 2428
 			//that's kinda dangerous. You should just use what's in the entity map, or add this to the entity map if there's
2429 2429
 			//absolutely nothing in it for this ID
2430
-			if( WP_DEBUG ) {
2430
+			if (WP_DEBUG) {
2431 2431
 				throw new EE_Error(
2432 2432
 					sprintf(
2433
-						__( 'Trying to refresh a model object with ID "%1$s" that\'s not in the entity map? First off: you should put it in the entity map by calling %2$s. Second off, if you want what\'s in the database right now, you should just call %3$s yourself and discard this model object.', 'event_espresso' ),
2433
+						__('Trying to refresh a model object with ID "%1$s" that\'s not in the entity map? First off: you should put it in the entity map by calling %2$s. Second off, if you want what\'s in the database right now, you should just call %3$s yourself and discard this model object.', 'event_espresso'),
2434 2434
 						$this->ID(),
2435
-						get_class( $this->get_model() ) . '::instance()->add_to_entity_map()',
2436
-						get_class( $this->get_model() ) . '::instance()->refresh_entity_map()'
2435
+						get_class($this->get_model()).'::instance()->add_to_entity_map()',
2436
+						get_class($this->get_model()).'::instance()->refresh_entity_map()'
2437 2437
 					)
2438 2438
 				);
2439 2439
 			}
@@ -2447,11 +2447,11 @@  discard block
 block discarded – undo
2447 2447
 	 * (probably a bad assumption they have made, oh well)
2448 2448
 	 * @return string
2449 2449
 	 */
2450
-	public function __toString(){
2450
+	public function __toString() {
2451 2451
 		try {
2452
-			return sprintf( '%s (%s)', $this->name(), $this->ID() );
2453
-		} catch ( Exception $e ) {
2454
-			EE_Error::add_error( $e->getMessage(), __FILE__, __FUNCTION__, __LINE__ );
2452
+			return sprintf('%s (%s)', $this->name(), $this->ID());
2453
+		} catch (Exception $e) {
2454
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
2455 2455
 			return '';
2456 2456
 		}
2457 2457
 	}
@@ -2487,16 +2487,16 @@  discard block
 block discarded – undo
2487 2487
 	 * @throws \EE_Error
2488 2488
 	 */
2489 2489
 	public function __sleep() {
2490
-		foreach( $this->get_model()->relation_settings() as $relation_name => $relation_obj ) {
2491
-			if( $relation_obj instanceof EE_Belongs_To_Relation ) {
2492
-				$classname = 'EE_' . $this->get_model()->get_this_model_name();
2493
-				if( $this->get_one_from_cache( $relation_name ) instanceof $classname &&
2494
-						$this->get_one_from_cache( $relation_name )->ID() ) {
2495
-					$this->clear_cache( $relation_name, $this->get_one_from_cache( $relation_name )->ID() );
2490
+		foreach ($this->get_model()->relation_settings() as $relation_name => $relation_obj) {
2491
+			if ($relation_obj instanceof EE_Belongs_To_Relation) {
2492
+				$classname = 'EE_'.$this->get_model()->get_this_model_name();
2493
+				if ($this->get_one_from_cache($relation_name) instanceof $classname &&
2494
+						$this->get_one_from_cache($relation_name)->ID()) {
2495
+					$this->clear_cache($relation_name, $this->get_one_from_cache($relation_name)->ID());
2496 2496
 				}
2497 2497
 			}
2498 2498
 		}
2499
-		return array_keys( get_object_vars( $this ) );
2499
+		return array_keys(get_object_vars($this));
2500 2500
 	}
2501 2501
 
2502 2502
 
Please login to merge, or discard this patch.
core/entities/GenericAddress.php 2 patches
Doc Comments   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -42,6 +42,8 @@  discard block
 block discarded – undo
42 42
 	 * @param \EE_State | string   $state
43 43
 	 * @param string              $zip
44 44
 	 * @param \EE_Country | string $country
45
+	 * @param integer $state
46
+	 * @param string $country
45 47
 	 * @return GenericAddress
46 48
 	 */
47 49
 	public function __construct( $address, $address2, $city, $state, $zip, $country ) {
@@ -135,7 +137,7 @@  discard block
 block discarded – undo
135 137
 
136 138
 
137 139
 	/**
138
-	 * @return \EE_State
140
+	 * @return string
139 141
 	 */
140 142
 	public function state_obj() {
141 143
 		return $this->_state_obj;
@@ -188,7 +190,7 @@  discard block
 block discarded – undo
188 190
 
189 191
 
190 192
 	/**
191
-	 * @return \EE_Country
193
+	 * @return string
192 194
 	 */
193 195
 	public function country_obj() {
194 196
 		return $this->_country_obj;
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace EventEspresso\core\entities;
3 3
 
4
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
5
-	exit( 'No direct script access allowed' );
4
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
5
+	exit('No direct script access allowed');
6 6
 }
7 7
 
8 8
 
@@ -44,18 +44,18 @@  discard block
 block discarded – undo
44 44
 	 * @param \EE_Country | string $country
45 45
 	 * @return GenericAddress
46 46
 	 */
47
-	public function __construct( $address, $address2, $city, $state, $zip, $country ) {
47
+	public function __construct($address, $address2, $city, $state, $zip, $country) {
48 48
 		$this->_address = $address;
49 49
 		$this->_address2 = $address2;
50 50
 		$this->_city = $city;
51
-		if ( $state instanceof \EE_State ) {
51
+		if ($state instanceof \EE_State) {
52 52
 			$this->_state_obj = $state;
53 53
 		} else {
54 54
 			$this->_state_ID = $state;
55 55
 			$this->_state_obj = $this->_get_state_obj();
56 56
 		}
57 57
 		$this->_zip = $zip;
58
-		if ( $country instanceof \EE_Country ) {
58
+		if ($country instanceof \EE_Country) {
59 59
 			$this->_country_obj = $country;
60 60
 		} else {
61 61
 			$this->_country_ID = $country;
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 	private function _get_state_obj() {
99 99
 		return $this->_state_obj instanceof \EE_State
100 100
 			? $this->_state_obj
101
-			: \EE_Registry::instance()->load_model( 'State' )->get_one_by_ID( $this->_state_ID );
101
+			: \EE_Registry::instance()->load_model('State')->get_one_by_ID($this->_state_ID);
102 102
 	}
103 103
 
104 104
 
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 	 * @return string
148 148
 	 */
149 149
 	public function state() {
150
-		if ( apply_filters( 'FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj() ) ) {
150
+		if (apply_filters('FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj())) {
151 151
 			return $this->state_obj()->abbrev();
152 152
 		} else {
153 153
 			return $this->state_name();
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 	private function _get_country_obj() {
163 163
 		return $this->_country_obj instanceof \EE_Country
164 164
 			? $this->_country_obj
165
-			: \EE_Registry::instance()->load_model( 'Country' )->get_one_by_ID( $this->_country_ID );
165
+			: \EE_Registry::instance()->load_model('Country')->get_one_by_ID($this->_country_ID);
166 166
 	}
167 167
 
168 168
 
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 	 * @return string
201 201
 	 */
202 202
 	public function country() {
203
-		if ( apply_filters( 'FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj() ) ) {
203
+		if (apply_filters('FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj())) {
204 204
 			return $this->country_ID();
205 205
 		} else {
206 206
 			return $this->country_name();
Please login to merge, or discard this patch.
core/helpers/EEH_Debug_Tools.helper.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 
188 188
 	/**
189 189
 	 * 	start_timer
190
-	 * @param null $timer_name
190
+	 * @param string $timer_name
191 191
 	 */
192 192
 	public function start_timer( $timer_name = NULL ){
193 193
 		$this->_start_times[$timer_name] = microtime( TRUE );
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
 
445 445
 
446 446
 	/**
447
-	 * @param mixed  $var
447
+	 * @param string  $var
448 448
 	 * @param string $var_name
449 449
 	 * @param string $file
450 450
 	 * @param int    $line
Please login to merge, or discard this patch.
Spacing   +150 added lines, -150 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed');}
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed'); }
2 2
 /**
3 3
  * Class EEH_Debug_Tools
4 4
  *
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @since 				4.0
9 9
  *
10 10
  */
11
-class EEH_Debug_Tools{
11
+class EEH_Debug_Tools {
12 12
 
13 13
 	/**
14 14
 	 * 	instance of the EEH_Autoloader object
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 	 */
42 42
 	public static function instance() {
43 43
 		// check if class object is instantiated, and instantiated properly
44
-		if ( ! self::$_instance instanceof EEH_Debug_Tools ) {
44
+		if ( ! self::$_instance instanceof EEH_Debug_Tools) {
45 45
 			self::$_instance = new self();
46 46
 		}
47 47
 		return self::$_instance;
@@ -57,21 +57,21 @@  discard block
 block discarded – undo
57 57
 	 */
58 58
 	private function __construct() {
59 59
 		// load Kint PHP debugging library
60
-		if ( ! class_exists( 'Kint' ) &&  file_exists( EE_PLUGIN_DIR_PATH . 'tests' . DS . 'kint' . DS . 'Kint.class.php' )){
60
+		if ( ! class_exists('Kint') && file_exists(EE_PLUGIN_DIR_PATH.'tests'.DS.'kint'.DS.'Kint.class.php')) {
61 61
 			// despite EE4 having a check for an existing copy of the Kint debugging class,
62 62
 			// if another plugin was loaded AFTER EE4 and they did NOT perform a similar check,
63 63
 			// then hilarity would ensue as PHP throws a "Cannot redeclare class Kint" error
64 64
 			// so we've moved it to our test folder so that it is not included with production releases
65 65
 			// plz use https://wordpress.org/plugins/kint-debugger/  if testing production versions of EE
66
-			require_once( EE_PLUGIN_DIR_PATH . 'tests' . DS . 'kint' . DS . 'Kint.class.php' );
66
+			require_once(EE_PLUGIN_DIR_PATH.'tests'.DS.'kint'.DS.'Kint.class.php');
67 67
 		}
68 68
 		// if ( ! defined('DOING_AJAX') || $_REQUEST['noheader'] !== 'true' || ! isset( $_REQUEST['noheader'], $_REQUEST['TB_iframe'] ) ) {
69 69
 			//add_action( 'shutdown', array($this,'espresso_session_footer_dump') );
70 70
 		// }
71
-		$plugin = basename( EE_PLUGIN_DIR_PATH );
72
-		add_action( "activate_{$plugin}", array( 'EEH_Debug_Tools', 'ee_plugin_activation_errors' ));
73
-		add_action( 'activated_plugin', array( 'EEH_Debug_Tools', 'ee_plugin_activation_errors' ));
74
-		add_action( 'shutdown', array( 'EEH_Debug_Tools', 'show_db_name' ));
71
+		$plugin = basename(EE_PLUGIN_DIR_PATH);
72
+		add_action("activate_{$plugin}", array('EEH_Debug_Tools', 'ee_plugin_activation_errors'));
73
+		add_action('activated_plugin', array('EEH_Debug_Tools', 'ee_plugin_activation_errors'));
74
+		add_action('shutdown', array('EEH_Debug_Tools', 'show_db_name'));
75 75
 	}
76 76
 
77 77
 
@@ -82,10 +82,10 @@  discard block
 block discarded – undo
82 82
 	 * 	@return void
83 83
 	 */
84 84
 	public static function show_db_name() {
85
-		if ( ! defined( 'DOING_AJAX' ) && ( defined( 'EE_ERROR_EMAILS' ) && EE_ERROR_EMAILS )) {
86
-			echo '<p style="font-size:10px;font-weight:normal;color:#E76700;margin: 1em 2em; text-align: right;">DB_NAME: '. DB_NAME .'</p>';
85
+		if ( ! defined('DOING_AJAX') && (defined('EE_ERROR_EMAILS') && EE_ERROR_EMAILS)) {
86
+			echo '<p style="font-size:10px;font-weight:normal;color:#E76700;margin: 1em 2em; text-align: right;">DB_NAME: '.DB_NAME.'</p>';
87 87
 		}
88
-		if ( EE_DEBUG ) {
88
+		if (EE_DEBUG) {
89 89
 			EEH_Debug_Tools::instance()->show_times();
90 90
 		}
91 91
 	}
@@ -99,15 +99,15 @@  discard block
 block discarded – undo
99 99
 	 */
100 100
 	public function espresso_session_footer_dump() {
101 101
 		if (
102
-			( defined( 'WP_DEBUG' ) && WP_DEBUG )
103
-			&& ! defined( 'DOING_AJAX' )
104
-			&& class_exists( 'Kint' )
105
-			&& function_exists( 'wp_get_current_user' )
106
-			&& current_user_can( 'update_core' )
107
-			&& class_exists( 'EE_Registry' )
102
+			(defined('WP_DEBUG') && WP_DEBUG)
103
+			&& ! defined('DOING_AJAX')
104
+			&& class_exists('Kint')
105
+			&& function_exists('wp_get_current_user')
106
+			&& current_user_can('update_core')
107
+			&& class_exists('EE_Registry')
108 108
 		) {
109
-			Kint::dump(  EE_Registry::instance()->SSN->id() );
110
-			Kint::dump( EE_Registry::instance()->SSN );
109
+			Kint::dump(EE_Registry::instance()->SSN->id());
110
+			Kint::dump(EE_Registry::instance()->SSN);
111 111
 			//			Kint::dump( EE_Registry::instance()->SSN->get_session_data('cart')->get_tickets() );
112 112
 			$this->espresso_list_hooked_functions();
113 113
 			$this->show_times();
@@ -124,27 +124,27 @@  discard block
 block discarded – undo
124 124
 	 * @param string $tag
125 125
 	 * @return void
126 126
 	 */
127
-	public function espresso_list_hooked_functions( $tag='' ){
127
+	public function espresso_list_hooked_functions($tag = '') {
128 128
 		global $wp_filter;
129 129
 		echo '<br/><br/><br/><h3>Hooked Functions</h3>';
130
-		if ( $tag ) {
131
-			$hook[$tag]=$wp_filter[$tag];
132
-			if ( ! is_array( $hook[$tag] )) {
133
-				trigger_error( "Nothing found for '$tag' hook", E_USER_WARNING );
130
+		if ($tag) {
131
+			$hook[$tag] = $wp_filter[$tag];
132
+			if ( ! is_array($hook[$tag])) {
133
+				trigger_error("Nothing found for '$tag' hook", E_USER_WARNING);
134 134
 				return;
135 135
 			}
136
-			echo '<h5>For Tag: '. $tag .'</h5>';
136
+			echo '<h5>For Tag: '.$tag.'</h5>';
137 137
 		}
138 138
 		else {
139
-			$hook=$wp_filter;
140
-			ksort( $hook );
139
+			$hook = $wp_filter;
140
+			ksort($hook);
141 141
 		}
142
-		foreach( $hook as $tag_name => $priorities ) {
142
+		foreach ($hook as $tag_name => $priorities) {
143 143
 			echo "<br />&gt;&gt;&gt;&gt;&gt;\t<strong>$tag_name</strong><br />";
144
-			ksort( $priorities );
145
-			foreach( $priorities as $priority => $function ){
144
+			ksort($priorities);
145
+			foreach ($priorities as $priority => $function) {
146 146
 				echo $priority;
147
-				foreach( $function as $name => $properties ) {
147
+				foreach ($function as $name => $properties) {
148 148
 					echo "\t$name<br />";
149 149
 				}
150 150
 			}
@@ -159,15 +159,15 @@  discard block
 block discarded – undo
159 159
 	 * @param string $hook_name
160 160
 	 * @return array
161 161
 	 */
162
-	public static function registered_filter_callbacks( $hook_name = '' ) {
162
+	public static function registered_filter_callbacks($hook_name = '') {
163 163
 		$filters = array();
164 164
 		global $wp_filter;
165
-		if ( isset( $wp_filter[ $hook_name ] ) ) {
166
-			$filters[ $hook_name ] = array();
167
-			foreach ( $wp_filter[ $hook_name ] as $priority => $callbacks ) {
168
-				$filters[ $hook_name ][ $priority ] = array();
169
-				foreach ( $callbacks as $callback ) {
170
-					$filters[ $hook_name ][ $priority ][] = $callback['function'];
165
+		if (isset($wp_filter[$hook_name])) {
166
+			$filters[$hook_name] = array();
167
+			foreach ($wp_filter[$hook_name] as $priority => $callbacks) {
168
+				$filters[$hook_name][$priority] = array();
169
+				foreach ($callbacks as $callback) {
170
+					$filters[$hook_name][$priority][] = $callback['function'];
171 171
 				}
172 172
 			}
173 173
 		}
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 	/**
180 180
 	 * reset_times
181 181
 	 */
182
-	public function reset_times(){
182
+	public function reset_times() {
183 183
 		$this->_times = array();
184 184
 	}
185 185
 
@@ -189,8 +189,8 @@  discard block
 block discarded – undo
189 189
 	 * 	start_timer
190 190
 	 * @param null $timer_name
191 191
 	 */
192
-	public function start_timer( $timer_name = NULL ){
193
-		$this->_start_times[$timer_name] = microtime( TRUE );
192
+	public function start_timer($timer_name = NULL) {
193
+		$this->_start_times[$timer_name] = microtime(TRUE);
194 194
 	}
195 195
 
196 196
 
@@ -199,15 +199,15 @@  discard block
 block discarded – undo
199 199
 	 * stop_timer
200 200
 	 * @param string $timer_name
201 201
 	 */
202
-	public function stop_timer( $timer_name = '' ){
202
+	public function stop_timer($timer_name = '') {
203 203
 		$timer_name = $timer_name !== '' ? $timer_name : get_called_class();
204
-		if( isset( $this->_start_times[ $timer_name ] ) ){
205
-			$start_time = $this->_start_times[ $timer_name ];
206
-			unset( $this->_start_times[ $timer_name ] );
207
-		}else{
208
-			$start_time = array_pop( $this->_start_times );
204
+		if (isset($this->_start_times[$timer_name])) {
205
+			$start_time = $this->_start_times[$timer_name];
206
+			unset($this->_start_times[$timer_name]);
207
+		} else {
208
+			$start_time = array_pop($this->_start_times);
209 209
 		}
210
-		$this->_times[ $timer_name ] =  number_format( microtime( true ) - $start_time, 8 );
210
+		$this->_times[$timer_name] = number_format(microtime(true) - $start_time, 8);
211 211
 	}
212 212
 
213 213
 
@@ -217,10 +217,10 @@  discard block
 block discarded – undo
217 217
 	 * @param boolean $output_now whether to echo now, or wait until EEH_Debug_Tools::show_times() is called
218 218
 	 * @return void
219 219
 	 */
220
-	public function measure_memory( $label, $output_now = false ) {
221
-		$memory_used = $this->convert( memory_get_peak_usage( true ) );
222
-		$this->_memory_usage_points[ $label ] = $memory_used;
223
-		if( $output_now ) {
220
+	public function measure_memory($label, $output_now = false) {
221
+		$memory_used = $this->convert(memory_get_peak_usage(true));
222
+		$this->_memory_usage_points[$label] = $memory_used;
223
+		if ($output_now) {
224 224
 			echo "\r\n<br>$label : $memory_used";
225 225
 		}
226 226
 	}
@@ -230,9 +230,9 @@  discard block
 block discarded – undo
230 230
 	 * @param int $size
231 231
 	 * @return string
232 232
 	 */
233
-	public function convert( $size ) {
234
-		$unit=array('b','kb','mb','gb','tb','pb');
235
-		return @round( $size / pow( 1024, $i = floor( log( $size, 1024 ) ) ), 2 ) . ' ' . $unit[ absint( $i ) ];
233
+	public function convert($size) {
234
+		$unit = array('b', 'kb', 'mb', 'gb', 'tb', 'pb');
235
+		return @round($size / pow(1024, $i = floor(log($size, 1024))), 2).' '.$unit[absint($i)];
236 236
 	}
237 237
 
238 238
 
@@ -242,25 +242,25 @@  discard block
 block discarded – undo
242 242
 	 * @param bool $output_now
243 243
 	 * @return string
244 244
 	 */
245
-	public function show_times($output_now=true){
245
+	public function show_times($output_now = true) {
246 246
 		$output = '';
247
-		if ( ! empty( $this->_times )) {
247
+		if ( ! empty($this->_times)) {
248 248
 			$total = 0;
249 249
 			$output .= '<h2 style="margin:1em .5em 0;">Times:</h2>';
250 250
 			$output .= '<span style="color:#9999CC; font-size:.8em; margin:0 1.5em 0;">( in milliseconds )</span><br />';
251
-			foreach( $this->_times as $timer_name => $total_time ) {
252
-				$output .= $this->format_time( $timer_name, $total_time );
251
+			foreach ($this->_times as $timer_name => $total_time) {
252
+				$output .= $this->format_time($timer_name, $total_time);
253 253
 				$total += $total_time;
254 254
 			}
255 255
 			$output .= '<br />';
256 256
 			$output .= '<h4 style="margin:1em .5em 0;">TOTAL TIME</h4>';
257
-			$output .= $this->format_time( '', $total );
257
+			$output .= $this->format_time('', $total);
258 258
 			$output .= '<br />';
259 259
 		}
260
-		if ( ! empty( $this->_memory_usage_points )) {
261
-			$output .= '<h2 style="margin:1em .5em 0;">Memory</h2>' . implode( '<br />', $this->_memory_usage_points );
260
+		if ( ! empty($this->_memory_usage_points)) {
261
+			$output .= '<h2 style="margin:1em .5em 0;">Memory</h2>'.implode('<br />', $this->_memory_usage_points);
262 262
 		}
263
-		if( $output_now ){
263
+		if ($output_now) {
264 264
 			echo $output;
265 265
 			return '';
266 266
 		}
@@ -274,9 +274,9 @@  discard block
 block discarded – undo
274 274
 	 * @param float $total_time
275 275
 	 * @return string
276 276
 	 */
277
-	public function format_time( $timer_name, $total_time ) {
277
+	public function format_time($timer_name, $total_time) {
278 278
 		$total_time = $total_time * 1000;
279
-		switch ( $total_time ) {
279
+		switch ($total_time) {
280 280
 			case $total_time < 0.01 :
281 281
 				$color = '#8A549A';
282 282
 				$bold = 'normal';
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
 			. '; font-weight:'
308 308
 			. $bold
309 309
 			. '; font-size:1.2em;">'
310
-			. str_pad( number_format( $total_time, 5 ), 11, '0', STR_PAD_LEFT )
310
+			. str_pad(number_format($total_time, 5), 11, '0', STR_PAD_LEFT)
311 311
 			. '</span> '
312 312
 			. $timer_name
313 313
 			. '<br />';
@@ -321,25 +321,25 @@  discard block
 block discarded – undo
321 321
 	 * 	@return void
322 322
 	 */
323 323
 	public static function ee_plugin_activation_errors() {
324
-		if ( WP_DEBUG ) {
324
+		if (WP_DEBUG) {
325 325
 			$activation_errors = ob_get_contents();
326
-			if ( ! empty( $activation_errors ) ) {
327
-				$activation_errors = date( 'Y-m-d H:i:s' ) . "\n" . $activation_errors;
326
+			if ( ! empty($activation_errors)) {
327
+				$activation_errors = date('Y-m-d H:i:s')."\n".$activation_errors;
328 328
 			}
329
-			espresso_load_required( 'EEH_File', EE_HELPERS . 'EEH_File.helper.php' );
330
-			if ( class_exists( 'EEH_File' )) {
329
+			espresso_load_required('EEH_File', EE_HELPERS.'EEH_File.helper.php');
330
+			if (class_exists('EEH_File')) {
331 331
 				try {
332
-					EEH_File::ensure_file_exists_and_is_writable( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html' );
333
-					EEH_File::write_to_file( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html', $activation_errors );
334
-				} catch( EE_Error $e ){
335
-					EE_Error::add_error( sprintf( __(  'The Event Espresso activation errors file could not be setup because: %s', 'event_espresso' ), $e->getMessage() ), __FILE__, __FUNCTION__, __LINE__ );
332
+					EEH_File::ensure_file_exists_and_is_writable(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.'espresso_plugin_activation_errors.html');
333
+					EEH_File::write_to_file(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.'espresso_plugin_activation_errors.html', $activation_errors);
334
+				} catch (EE_Error $e) {
335
+					EE_Error::add_error(sprintf(__('The Event Espresso activation errors file could not be setup because: %s', 'event_espresso'), $e->getMessage()), __FILE__, __FUNCTION__, __LINE__);
336 336
 				}
337 337
 			} else {
338 338
 				// old school attempt
339
-				file_put_contents( EVENT_ESPRESSO_UPLOAD_DIR . 'logs' . DS . 'espresso_plugin_activation_errors.html', $activation_errors );
339
+				file_put_contents(EVENT_ESPRESSO_UPLOAD_DIR.'logs'.DS.'espresso_plugin_activation_errors.html', $activation_errors);
340 340
 			}
341
-			$activation_errors = get_option( 'ee_plugin_activation_errors', '' ) . $activation_errors;
342
-			update_option( 'ee_plugin_activation_errors', $activation_errors );
341
+			$activation_errors = get_option('ee_plugin_activation_errors', '').$activation_errors;
342
+			update_option('ee_plugin_activation_errors', $activation_errors);
343 343
 		}
344 344
 	}
345 345
 
@@ -355,22 +355,22 @@  discard block
 block discarded – undo
355 355
 	 * @param int     $error_type
356 356
 	 * @uses trigger_error()
357 357
 	 */
358
-	public function doing_it_wrong( $function, $message, $version, $error_type = E_USER_NOTICE ) {
359
-		do_action( 'AHEE__EEH_Debug_Tools__doing_it_wrong_run', $function, $message, $version);
360
-		$version = $version === null ? '' : sprintf( __('(This message was added in version %s of Event Espresso.', 'event_espresso' ), $version );
361
-		$error_message = sprintf( esc_html__('%1$s was called %2$sincorrectly%3$s. %4$s %5$s','event_espresso' ), $function, '<strong>', '</strong>', $message, $version );
358
+	public function doing_it_wrong($function, $message, $version, $error_type = E_USER_NOTICE) {
359
+		do_action('AHEE__EEH_Debug_Tools__doing_it_wrong_run', $function, $message, $version);
360
+		$version = $version === null ? '' : sprintf(__('(This message was added in version %s of Event Espresso.', 'event_espresso'), $version);
361
+		$error_message = sprintf(esc_html__('%1$s was called %2$sincorrectly%3$s. %4$s %5$s', 'event_espresso'), $function, '<strong>', '</strong>', $message, $version);
362 362
 
363 363
 		//don't trigger error if doing ajax, instead we'll add a transient EE_Error notice that in theory should show on the next request.
364
-		if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
365
-			$error_message .= esc_html__( 'This is a doing_it_wrong message that was triggered during an ajax request.  The request params on this request were: ', 'event_espresso' );
364
+		if (defined('DOING_AJAX') && DOING_AJAX) {
365
+			$error_message .= esc_html__('This is a doing_it_wrong message that was triggered during an ajax request.  The request params on this request were: ', 'event_espresso');
366 366
 			$error_message .= '<ul><li>';
367
-			$error_message .= implode( '</li><li>', EE_Registry::instance()->REQ->params() );
367
+			$error_message .= implode('</li><li>', EE_Registry::instance()->REQ->params());
368 368
 			$error_message .= '</ul>';
369
-			EE_Error::add_error( $error_message, 'debug::doing_it_wrong', $function, '42' );
369
+			EE_Error::add_error($error_message, 'debug::doing_it_wrong', $function, '42');
370 370
 			//now we set this on the transient so it shows up on the next request.
371
-			EE_Error::get_notices( is_admin(), true );
371
+			EE_Error::get_notices(is_admin(), true);
372 372
 		} else {
373
-			trigger_error( $error_message, $error_type );
373
+			trigger_error($error_message, $error_type);
374 374
 		}
375 375
 	}
376 376
 
@@ -392,22 +392,22 @@  discard block
 block discarded – undo
392 392
 	 * @param string $debug_index
393 393
 	 * @param string $debug_key
394 394
 	 */
395
-	public static function log( $class='', $func = '', $line = '', $info = array(), $display_request = false,  $debug_index = '', $debug_key = 'EE_DEBUG_SPCO' ) {
396
-		if ( WP_DEBUG && false ) {
397
-			$debug_key = $debug_key . '_' . EE_Session::instance()->id();
398
-			$debug_data = get_option( $debug_key, array() );
395
+	public static function log($class = '', $func = '', $line = '', $info = array(), $display_request = false, $debug_index = '', $debug_key = 'EE_DEBUG_SPCO') {
396
+		if (WP_DEBUG && false) {
397
+			$debug_key = $debug_key.'_'.EE_Session::instance()->id();
398
+			$debug_data = get_option($debug_key, array());
399 399
 			$default_data = array(
400
-				$class => $func . '() : ' . $line,
400
+				$class => $func.'() : '.$line,
401 401
 				'REQ'  => $display_request ? $_REQUEST : '',
402 402
 			);
403 403
 			// don't serialize objects
404
-			$info = self::strip_objects( $info );
405
-			$index = ! empty( $debug_index ) ? $debug_index : 0;
406
-			if ( ! isset( $debug_data[$index] ) ) {
404
+			$info = self::strip_objects($info);
405
+			$index = ! empty($debug_index) ? $debug_index : 0;
406
+			if ( ! isset($debug_data[$index])) {
407 407
 				$debug_data[$index] = array();
408 408
 			}
409
-			$debug_data[$index][microtime()] = array_merge( $default_data, $info );
410
-			update_option( $debug_key, $debug_data );
409
+			$debug_data[$index][microtime()] = array_merge($default_data, $info);
410
+			update_option($debug_key, $debug_data);
411 411
 		}
412 412
 	}
413 413
 
@@ -419,26 +419,26 @@  discard block
 block discarded – undo
419 419
 	 * @param array $info
420 420
 	 * @return array
421 421
 	 */
422
-	public static function strip_objects( $info = array() ) {
423
-		foreach ( $info as $key => $value ) {
424
-			if ( is_array( $value ) ) {
425
-				$info[ $key ] = self::strip_objects( $value );
426
-			} else if ( is_object( $value ) ) {
427
-				$object_class = get_class( $value );
428
-				$info[ $object_class ] = array();
429
-				$info[ $object_class ][ 'ID' ] = method_exists( $value, 'ID' ) ? $value->ID() : spl_object_hash( $value );
430
-				if ( method_exists( $value, 'ID' ) ) {
431
-					$info[ $object_class ][ 'ID' ] = $value->ID();
422
+	public static function strip_objects($info = array()) {
423
+		foreach ($info as $key => $value) {
424
+			if (is_array($value)) {
425
+				$info[$key] = self::strip_objects($value);
426
+			} else if (is_object($value)) {
427
+				$object_class = get_class($value);
428
+				$info[$object_class] = array();
429
+				$info[$object_class]['ID'] = method_exists($value, 'ID') ? $value->ID() : spl_object_hash($value);
430
+				if (method_exists($value, 'ID')) {
431
+					$info[$object_class]['ID'] = $value->ID();
432 432
 				}
433
-				if ( method_exists( $value, 'status' ) ) {
434
-					$info[ $object_class ][ 'status' ] = $value->status();
435
-				} else if ( method_exists( $value, 'status_ID' ) ) {
436
-					$info[ $object_class ][ 'status' ] = $value->status_ID();
433
+				if (method_exists($value, 'status')) {
434
+					$info[$object_class]['status'] = $value->status();
435
+				} else if (method_exists($value, 'status_ID')) {
436
+					$info[$object_class]['status'] = $value->status_ID();
437 437
 				}
438
-				unset( $info[ $key ] );
438
+				unset($info[$key]);
439 439
 			}
440 440
 		}
441
-		return (array)$info;
441
+		return (array) $info;
442 442
 	}
443 443
 
444 444
 
@@ -451,22 +451,22 @@  discard block
 block discarded – undo
451 451
 	 * @param int    $header
452 452
 	 * @param bool   $die
453 453
 	 */
454
-	public static function printv( $var, $var_name = '', $file = __FILE__, $line = __LINE__, $header = 5, $die = false ) {
454
+	public static function printv($var, $var_name = '', $file = __FILE__, $line = __LINE__, $header = 5, $die = false) {
455 455
 		$var_name = ! $var_name ? 'string' : $var_name;
456 456
 		$heading_tag = 'h';
457
-		$heading_tag .= is_int( $header ) ? $header : 5;
458
-		$var_name = ucwords( str_replace( '$', '', $var_name ) );
459
-		$is_method = method_exists( $var_name, $var );
460
-		$var_name = ucwords( str_replace( '_', ' ', $var_name ) );
461
-		$result = '<' . $heading_tag . ' style="color:#2EA2CC; margin:25px 0 0;"><b>' . $var_name . '</b>';
457
+		$heading_tag .= is_int($header) ? $header : 5;
458
+		$var_name = ucwords(str_replace('$', '', $var_name));
459
+		$is_method = method_exists($var_name, $var);
460
+		$var_name = ucwords(str_replace('_', ' ', $var_name));
461
+		$result = '<'.$heading_tag.' style="color:#2EA2CC; margin:25px 0 0;"><b>'.$var_name.'</b>';
462 462
 		$result .= $is_method
463
-			? '<span style="color:#999">::</span><span style="color:#E76700">' . $var . '()</span><br />'
464
-			: '<span style="color:#999"> : </span><span style="color:#E76700">' . $var . '</span><br />';
465
-		$result .= '<span style="font-size:9px;font-weight:normal;color:#666;line-height: 12px;">' . $file;
466
-		$result .= '<br />line no: ' . $line . '</span>';
467
-		$result .= '</' . $heading_tag . '>';
468
-		if ( $die ) {
469
-			die( $result );
463
+			? '<span style="color:#999">::</span><span style="color:#E76700">'.$var.'()</span><br />'
464
+			: '<span style="color:#999"> : </span><span style="color:#E76700">'.$var.'</span><br />';
465
+		$result .= '<span style="font-size:9px;font-weight:normal;color:#666;line-height: 12px;">'.$file;
466
+		$result .= '<br />line no: '.$line.'</span>';
467
+		$result .= '</'.$heading_tag.'>';
468
+		if ($die) {
469
+			die($result);
470 470
 		} else {
471 471
 			echo $result;
472 472
 		}
@@ -481,35 +481,35 @@  discard block
 block discarded – undo
481 481
 	 * @param int $header
482 482
 	 * @param bool $die
483 483
 	 */
484
-	public static function printr( $var, $var_name = '', $file = __FILE__, $line = __LINE__, $header = 5, $die = false ) {
484
+	public static function printr($var, $var_name = '', $file = __FILE__, $line = __LINE__, $header = 5, $die = false) {
485 485
 		// return;
486
-		$file = str_replace( rtrim( ABSPATH, '\\/' ), '', $file );
486
+		$file = str_replace(rtrim(ABSPATH, '\\/'), '', $file);
487 487
 		//$print_r = false;
488
-		if ( is_string( $var ) ) {
489
-			EEH_Debug_Tools::printv( $var, $var_name, $file, $line, $header, $die );
488
+		if (is_string($var)) {
489
+			EEH_Debug_Tools::printv($var, $var_name, $file, $line, $header, $die);
490 490
 			return;
491
-		} else if ( is_object( $var ) ) {
491
+		} else if (is_object($var)) {
492 492
 			$var_name = ! $var_name ? 'object' : $var_name;
493 493
 			//$print_r = true;
494
-		} else if ( is_array( $var ) ) {
494
+		} else if (is_array($var)) {
495 495
 			$var_name = ! $var_name ? 'array' : $var_name;
496 496
 			//$print_r = true;
497
-		} else if ( is_numeric( $var ) ) {
497
+		} else if (is_numeric($var)) {
498 498
 			$var_name = ! $var_name ? 'numeric' : $var_name;
499
-		} else if ( is_null( $var ) ) {
499
+		} else if (is_null($var)) {
500 500
 			$var_name = ! $var_name ? 'null' : $var_name;
501 501
 		}
502 502
 		$heading_tag = 'h';
503
-		$heading_tag .= is_int( $header ) ? $header : 5;
504
-		$var_name = ucwords( str_replace( array( '$', '_' ), array( '', ' ' ), $var_name ) );
505
-		$result = '<' . $heading_tag . ' style="color:#2EA2CC; margin:25px 0 0;"><b>' . $var_name . '</b>';
503
+		$heading_tag .= is_int($header) ? $header : 5;
504
+		$var_name = ucwords(str_replace(array('$', '_'), array('', ' '), $var_name));
505
+		$result = '<'.$heading_tag.' style="color:#2EA2CC; margin:25px 0 0;"><b>'.$var_name.'</b>';
506 506
 		$result .= '<span style="color:#999;"> : </span><span style="color:#E76700;">';
507 507
 		$result .= '<pre style="color:#999; padding:1em; background: #fff">';
508
-		$result .= var_export( $var, true );
509
-		$result .= '</pre></span><br /><span style="font-size:9px;font-weight:normal;color:#666;line-height: 12px;">' . $file;
510
-		$result .= '<br />line no: ' . $line . '</span></' . $heading_tag . '>';
511
-		if ( $die ) {
512
-			die( $result );
508
+		$result .= var_export($var, true);
509
+		$result .= '</pre></span><br /><span style="font-size:9px;font-weight:normal;color:#666;line-height: 12px;">'.$file;
510
+		$result .= '<br />line no: '.$line.'</span></'.$heading_tag.'>';
511
+		if ($die) {
512
+			die($result);
513 513
 		} else {
514 514
 			echo $result;
515 515
 		}
@@ -526,8 +526,8 @@  discard block
 block discarded – undo
526 526
  * borrowed from Kint Debugger
527 527
  * Plugin URI: http://upthemes.com/plugins/kint-debugger/
528 528
  */
529
-if ( class_exists('Kint') && ! function_exists( 'dump_wp_query' ) ) {
530
-	function dump_wp_query(){
529
+if (class_exists('Kint') && ! function_exists('dump_wp_query')) {
530
+	function dump_wp_query() {
531 531
 		global $wp_query;
532 532
 		d($wp_query);
533 533
 	}
@@ -537,8 +537,8 @@  discard block
 block discarded – undo
537 537
  * borrowed from Kint Debugger
538 538
  * Plugin URI: http://upthemes.com/plugins/kint-debugger/
539 539
  */
540
-if ( class_exists('Kint') && ! function_exists( 'dump_wp' ) ) {
541
-	function dump_wp(){
540
+if (class_exists('Kint') && ! function_exists('dump_wp')) {
541
+	function dump_wp() {
542 542
 		global $wp;
543 543
 		d($wp);
544 544
 	}
@@ -548,8 +548,8 @@  discard block
 block discarded – undo
548 548
  * borrowed from Kint Debugger
549 549
  * Plugin URI: http://upthemes.com/plugins/kint-debugger/
550 550
  */
551
-if ( class_exists('Kint') && ! function_exists( 'dump_post' ) ) {
552
-	function dump_post(){
551
+if (class_exists('Kint') && ! function_exists('dump_post')) {
552
+	function dump_post() {
553 553
 		global $post;
554 554
 		d($post);
555 555
 	}
Please login to merge, or discard this patch.
core/helpers/EEH_Formatter.helper.php 2 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -74,6 +74,7 @@
 block discarded – undo
74 74
 	 * [ee_tep_not_null description]
75 75
 	 *
76 76
 	 * @param  string | array $value [description]
77
+	 * @param string $value
77 78
 	 * @return bool       [description]
78 79
 	 */
79 80
 	static public function ee_tep_not_null( $value ) {
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
3
-	exit( 'NO direct script access allowed' );
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3
+	exit('NO direct script access allowed');
4 4
 }
5 5
 
6 6
 
@@ -26,8 +26,8 @@  discard block
 block discarded – undo
26 26
 	 * @param  string $content content to format
27 27
 	 * @return string          formatted content
28 28
 	 */
29
-	static public function admin_format_content( $content = '' ) {
30
-		return wpautop( stripslashes_deep( html_entity_decode( $content, ENT_QUOTES, "UTF-8" ) ) );
29
+	static public function admin_format_content($content = '') {
30
+		return wpautop(stripslashes_deep(html_entity_decode($content, ENT_QUOTES, "UTF-8")));
31 31
 	}
32 32
 
33 33
 
@@ -43,14 +43,14 @@  discard block
 block discarded – undo
43 43
 	 * @param  boolean $protected true then we run htmlspecialchars and return
44 44
 	 * @return string
45 45
 	 */
46
-	static public function ee_tep_output_string( $string, $translate = false, $protected = false ) {
47
-		if ( $protected === true ) {
48
-			return htmlspecialchars( $string );
46
+	static public function ee_tep_output_string($string, $translate = false, $protected = false) {
47
+		if ($protected === true) {
48
+			return htmlspecialchars($string);
49 49
 		} else {
50
-			if ( $translate === false ) {
51
-				return self::ee_tep_parse_input_field_data( $string, array( '"' => '&quot;' ) );
50
+			if ($translate === false) {
51
+				return self::ee_tep_parse_input_field_data($string, array('"' => '&quot;'));
52 52
 			} else {
53
-				return self::ee_tep_parse_input_field_data( $string, $translate );
53
+				return self::ee_tep_parse_input_field_data($string, $translate);
54 54
 			}
55 55
 		}
56 56
 	}
@@ -64,8 +64,8 @@  discard block
 block discarded – undo
64 64
 	 * @param         array ] $parse array in the form array( 'from' => 'to', ... )
65 65
 	 * @return string
66 66
 	 */
67
-	static public function ee_tep_parse_input_field_data( $data, $parse ) {
68
-		return strtr( trim( $data ), $parse );
67
+	static public function ee_tep_parse_input_field_data($data, $parse) {
68
+		return strtr(trim($data), $parse);
69 69
 	}
70 70
 
71 71
 
@@ -76,15 +76,15 @@  discard block
 block discarded – undo
76 76
 	 * @param  string | array $value [description]
77 77
 	 * @return bool       [description]
78 78
 	 */
79
-	static public function ee_tep_not_null( $value ) {
80
-		if ( is_array( $value ) ) {
81
-			if ( count( $value ) > 0 ) {
79
+	static public function ee_tep_not_null($value) {
80
+		if (is_array($value)) {
81
+			if (count($value) > 0) {
82 82
 				return true;
83 83
 			} else {
84 84
 				return false;
85 85
 			}
86 86
 		} else {
87
-			if ( ( $value !== '' ) && ( strtolower( $value ) !== 'null' ) && ( strlen( trim( $value ) ) > 0 ) ) {
87
+			if (($value !== '') && (strtolower($value) !== 'null') && (strlen(trim($value)) > 0)) {
88 88
 				return true;
89 89
 			} else {
90 90
 				return false;
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 	 * @return string
105 105
 	 * @deprecated v4.6.21
106 106
 	 */
107
-	static public function event_date_display( $date, $format = '' ) {
107
+	static public function event_date_display($date, $format = '') {
108 108
 		EE_Error::doing_it_wrong(
109 109
 			__METHOD__,
110 110
 			__(
Please login to merge, or discard this patch.